Commit Graph
2451 Commits
Author SHA1 Message Date
Anees Iqbal 513e323884 Build the tiled texture buffer of two levels past the descriptor's check in its planner test
The descriptor's own check stops a texture buffer of more than one level before
the buffer's plan sees it (RuntimeGap::TextureBufferLevels), so the case
panicked in the helper on the M3 (potluck m3-max-7540). The test now takes the
checked one-level layout and sets two levels, which the plan stops as
MipmapLevelCount.

Verified: the device run that follows.
(cherry picked from commit ec197cff3e0d414fe4a5524b40391cc1ff5e9318)
2026-11-08 00:39:19 -08:00
Anees Iqbal 7205978cfa Make a tiled texture of more than one level over a buffer's bytes
The x86 macOS guests' WindowServer asks for a texture over a buffer with several
mipmap levels through Metal's private newTiledTextureWithDescriptor:offset:
bytesPerRow: (BGRA8Unorm 54x54 of 6 levels, 64x60 of 7, ShaderRead, over a new
16384-byte Shared buffer at 256 bytes a row). The runtime had no such entry, so
the guest's bundle answered nil and the x86 featureProfile could not be turned on.

Buffer::new_tiled_texture makes what new_texture makes, and a 2D texture of more
levels (BufferTextureCall::Tiled lets linear_plan take them; a texture buffer of
more levels stays MipmapLevelCount, and its offset keeps the validated 16-byte
rule as the linear SPI's does). No Vulkan image lays level 0 over the buffer's
rows and the other levels elsewhere, so the shared route sends it to a shadow
over any buffer (Route::Levels, answered TextureShadowReason::Mipmapped): one
image of every level, made zero in a Shared or Managed texture, whose existing
shadow copies move level 0's texels alone (their range was already level 0), so
the bytes reach level 0 before the GPU reads it and level 0's writes reach the
bytes by the end of the encoder. Announced as shadowed-texture, naming the
levels; counted in shadowed_textures and shadows_zeroed.

The paths that assumed every texture over a buffer has one level:
- blits: such a texture is an image to a blit, as a heap shadow is
  (Texture::blit_texels; BlitCommandEncoder::see notes it), so every level is a
  blit source and destination, generate_mipmaps included;
- get_bytes and replace_region reach level 0 in the bytes and the other levels
  in the image;
- a reinterpreting view shadow and a usage shadow, whose truth would be the
  bytes alone, are refused for it.

Buffer::tiled_texture_placement answers the placement for the new call. Docs:
the item's rustdoc (Metal's selector and what differs), docs/API.md, the
degrade catalogue, RUNTIME-PORTING, the runtime README; api_signatures blessed
(three additions, no breakage), REFUSALS regenerated (MipmapLevelCount's text).

Verified: api-signatures, refusal-surface and metal-coverage checks locally; the
builds, lint and device runs are the potluck jobs that follow.

(cherry picked from commit b040d815059b99a20426234239aa756b282b25b9)
2026-11-08 00:39:19 -08:00
Anees Iqbal cb4dfa3bbe texture_placement_device: the pitch test counts the refusals a device reached, and requires none
Development's lavapipe leg at edde5779b1 failed
a_pitch_the_device_lays_no_image_at_answers_its_shadow: llvmpipe refused
none of the 8 pitches (its DRM_FORMAT_MOD_LINEAR image takes every one),
and the test required at least one. Every answer matched the texture made
there, as on the M3, where MoltenVK refuses six of the eight and the
refusal arm runs (inplace's m3-max-7464). Which pitches a device refuses
is the driver's answer, so the test reports the count and holds the
answer-against-made comparison only.

Verified: the lavapipe rerun at edde5779b1 (msi m3-max-7539) printed every
case's answer equal to its made route, 0 of 8 refused.
2026-11-08 00:33:17 -08:00
Anees Iqbal edde5779b1 Bump RUNTIME_VERSION to 1874: a device call lost under its generation runs again on the serving one; the placement route names its padding
perdraw (recovery race): a root-handle call that took a generation lost
mid-call ran into MadeBeforeRecovery (each_recovery_announces_its_own_wait,
9/30 failures on the M3 at its base); it now runs again on the serving
generation. M3 7281: 30/30 at tip, device_recovery 7/7; gem10 7277 green
but for two explicit_auto_deref lints, fixed in 27820b9359 (re-check 7474).

selfread 9e124d9d91: development at 4c18274ab7 did not compile (by
reading): the placement query's Route::Host pattern and literal in
texture/route.rs lacked the padding field the writes-padding rule added
(E0027, E0063); two branches each built alone. Development's lint leg
at this commit is the proof.
2026-11-08 00:15:49 -08:00
Anees Iqbal db97e7ebc4 Let the serving-generation calls auto-deref their device
Clippy's explicit_auto_deref flagged call(&*device) in Device::at_serving and
at_serving_taking (gem10 job m3-max-7277, all three cfgs); &device derefs the same.

Verified: cargo fmt only locally; clippy in three cfgs is a potluck job.
(cherry picked from commit 27820b935963df0d8d4491b7fc5d33033550cef9)
2026-11-08 00:14:43 -08:00
Anees Iqbal e038e8b5fa Tell a loss refusal apart by lost_refusal's own answer, and regenerate the refusal surface
Device::lost_under named RuntimeGap::MadeBeforeRecovery in a match, which
the refusal surface script counts as a refusal site of the gap (a third
one, lost_under, which refuses nothing). It now compares the answer with
DeviceLost and with lost_refusal's own answer for the generation, which is
MadeBeforeRecovery wherever the line recovers past it, as the check already
requires: the same calls go to the serving generation.

docs/REFUSALS.md regenerated: the gap keeps its two sites; five refusal
sites read their _now function's name now that the public forwarders run
through Device::at_serving (the refusals are unchanged).

(cherry picked from commit 0eea4c413fdcddf56a39f7f12b89c8ca23f9ff01)
2026-11-08 00:14:43 -08:00
Anees Iqbal ab8651ae38 Run a device call again on the serving generation where its own was lost under it
tests::device_recovery::each_recovery_announces_its_own_wait failed on the M3
in 10 of 30 runs at 2fed3c2453 (m3-max-7120): a waiter thread's
`device.new_buffer(..)` returned NotImplemented(MadeBeforeRecovery) while
another thread recovered the device. A public call of a root handle took the
serving generation (Device::current -> Line::current), the recovery marked it
lost, and the call's own check of the loss (new_buffer_placed's is_lost) then
refused it through lost_refusal, whose line had gone past the generation. The
call came from the device the program holds, which Metal keeps across a
recovery: it must not be refused because the generation it took was lost
while it ran (rule 2).

The device's public calls now run through Device::at_serving: a run refused
for its generation's loss (DeviceLost, or MadeBeforeRecovery as lost_refusal
answers it) where the line went past that generation runs again on the one
serving next. A run refused so kept nothing, so the call runs whole again.
Each run is on a later generation than the one before, after its recovery,
which Line::current waits for, announced past RECOVERY_NOTICE as before; a
line that cannot recover still answers the loss, and a thread command
buffers' completion depends on, whose calls reach the lost generation, is
answered as before (no retry). A call refused for an object of an earlier
generation while its own generation serves is answered as before.

The calls that consume arguments a refused run could not hand to a second
one (host memory and its deallocator or keep-alive, a range token, a buffer
descriptor's contents) run through Device::at_serving_taking: they go to the
generation once it is not lost, else to the next, and from there a loss of
it follows the call: the thread's RunsOn scope makes Device::is_lost answer
false for that generation to the call's own checks, so the call completes on
it as one the loss came after, its object made before the recovery. The two
texture calls with a range token make the texture through at_serving and keep
the token on it after (their _now forms, used by nothing else, are gone). The
calls that wrap the consumer's own Vulkan objects (new_texture_with_vk_image,
_plane, new_buffer_with_vk_buffer) are unchanged: those objects belong to the
VkDevice the caller made them on.

Tests: device_recovery gains a call whose first run meets a recovery and runs
again on the next generation, and a taking call that completes on the
generation lost after it took its arguments. Docs: the runtime README's lost
device section, API.md's device-recovered notice, line.rs's module docs.

(cherry picked from commit 3af6741dcf79b99a608ea0a464b98734dac52ba5)
2026-11-08 00:14:43 -08:00
Anees Iqbal a11400d217 Placement query: carry the route's padding through the in-place image check
What: Device::placement_over_buffer's match on Route::Host names the `padding` field and puts
it back in the route it builds.

Why: Route::Host gained `padding` with the Writes padding rule (3f8b07c044), and the placement
query's answer through the image in place's making (d60e8b5b60) landed after it with a pattern
and a struct literal that name only `class`, `rows` and `way`: a missing field in a struct
pattern without `..` (E0027) and in a struct literal (E0063), so the runtime does not compile at
4c18274ab7.

Verified: by reading (every other Route::Host site on development names the field or uses `..`);
the build check follows.

(cherry picked from commit 9e124d9d9174db735d0d551482fc69945568247a)
2026-11-08 00:14:43 -08:00
Anees Iqbal 4c18274ab7 Bump RUNTIME_VERSION to 1873: a texture's placement answered through the image in place's making up to its bind
inplace: the placement query makes the unbound image(s) through the same
functions as the making (unplaced / place / release_unplaced), reads the
layout and requirements and releases them, so Pitch, Image, Rows and
Placement refusals answer exactly. Over dma-buf pages, Source and DmaBuf
stay unknowable until the bind. A pending texture's later move makes the
same image and stays a shadow on a refusal.

Evidence (inplace, M3): 7464 44/44 (in_place, first_host_texture,
storage_form, fresh_pages, dma_buf, texture_placement); the pitch test
refused 6 of 8 pitches on MoltenVK (61x16 at 272/320/512/1024, 3664x16 at
14672/14848 answered Shadow(Refused(Pitch)) and were made as Pitch
shadows; 256 and 14656 answered and were made in place); 7476 each query
1 vkCreateImage + 1 vkDestroyImage, 0 binds, 0 submissions; negative
control 7468 (route without the image steps) fails at 272. Pending:
lavapipe, clippy in 3 cfgs and rustdoc (gem10 7459) and the 780M run.
2026-11-08 00:03:34 -08:00
Anees Iqbal 0b56c0360d Mend two placement doc sentences: a garbled clause and an unwrapped line
Buffer::texture_placement's doc said a making fails on memory or a lost device
"as this may making those images"; it now says the query may fail so too in
making them. TexturePlacement::Pending's doc ran past 100 columns after the
last change; rewrapped.

Verified: api-signatures and refusal-surface checks pass locally; rustdoc runs
in the gem10 lint job.

(cherry picked from commit 204144d579a42d72d41d29cf3b6508f98b3d1dfd)
2026-11-08 00:02:46 -08:00
Anees Iqbal 19553ba3bc Bound a placement query's cost in the device test: images made, none bound, nothing submitted
The pitch test now asks every case once before any texture is made and reads
the process's ObjectChurn and the device's queue_submissions across the query:
no vkBindImageMemory, no submission, no more vkDestroyImage than vkCreateImage
(a creation the driver refuses is counted and has nothing to release), and one
or two vkCreateImage calls where the answer is InPlace. Printed per case.

Verified: the pitch test itself passed on the M3 (m3-max-7464, 6 of 8 pitches
refused, each query matching the making) and failed with the route's answer
ignored (m3-max-7468: 272 bytes asked InPlace, made Refused(Pitch)); the cost
check runs in the potluck runs that follow.

(cherry picked from commit 5cc6e0a175034b81ce1a37debf2b480b20890743)
2026-11-08 00:02:46 -08:00
Anees Iqbal 4ea55180e8 Release an unplaced host image as a statement, and say a pending move needs its image too
The match arm returned release::object's bool where the function returns
nothing, which the M3 build (potluck m3-max-7448) refused. dma_buf_image_or_why
has no caller outside dma_buf.rs since the image in place is made unbound, so it
is private again. TexturePlacement::Pending said a pending texture moves in
place where the verdicts pass; the move also makes the image in place and stays
a shadow where the device refuses it (storage_form.rs, Wanted::Move), so the doc
says so.

Verified: api-signatures and refusal-surface checks pass locally; the build is
the potluck runs that follow.

(cherry picked from commit b6468bfc9bce1d651840a2bfa563691ccc41feab)
2026-11-08 00:02:46 -08:00
Anees Iqbal d60e8b5b60 Answer a texture's placement through the image in place's making up to its bind
On the Radeon 780M (RADV) a guest surface whose pitch is no multiple of 256
bytes (3664 px BGRA8 at 14656 bytes a row) is refused Refusal::Pitch where the
image in place is made: the driver lays its linear image's rows out at another
pitch, and refuses the DRM_FORMAT_MOD_LINEAR image at that one. The query
stopped at the route and answered InPlace, so the consumer sent such a surface
in place and got a shadow copied in for every command buffer, the case the
query exists to prevent.

Now the image in place's making is two steps, shared: Device::unplaced makes
and checks the image of a plan before any memory is bound (over pages imported
by their pointer, in_place_unbound's linear or DRM_FORMAT_MOD_LINEAR image and
its requirements against the bytes' place and memory type; over dma-buf pages,
dma_buf_image_unbound's image checked against the pages, before the caller's
source is asked), and Device::place binds it. in_place_image runs the rows
check, then the wider plans and the declared plan through both steps as
before. The query's placement_over_buffer, where the route is the image in
place, calls Device::in_place_image_made: the same rows check and the same
unbound step for the declared plan first and then the wider plans, releasing
each image unbound, answering Shadow(Refused(kind)) with the declared plan's
refusal where none is made. Its cost: one or two VkImages where the declared
plan is made in place, a pair more per wider plan where it is refused; nothing
bound or submitted. What only the bind shows stays unknown: over dma-buf pages
the caller's source and the driver's import of its dma-buf.

The new device test a_pitch_the_device_lays_no_image_at_answers_its_shadow
asks and makes BGRA8Unorm textures at pitches past their rows (61 texels at
256..1024 bytes, 3664 texels at 14656, 14672 and 14848, a render target), each
answer equal to what the making counted, and at least one Shadow(Refused(Pitch)).

(cherry picked from commit fb619a2a4f6fa9bfa524cd7ae88c6e76a10d12ed)
2026-11-08 00:02:46 -08:00
Anees Iqbal 06099fa943 Bump RUNTIME_VERSION to 1872: a kernel's writes of a texture over a buffer may change its rows' padding
selfread: the in-place check gives buffer textures under kernel writes a
verdict of their own (CHECK_VERSION 7, 24 verdicts): a round that changes
only the rows' in-pitch padding passes it. Real Macs disagree there (the
row-padding probe: the UHD 630 on 26.7.1 changes the padding under kernel
writes into buffer-backed textures; the M3 keeps it), so it is inside
Metal's envelope; IOSurface planes and renders stay strict. Also the
check's shape bound and the self-read lane's surface rows.

Evidence (selfread):
- Iris Xe (ms01 7387), 10 fresh-cache checks with the rule: buffer writes
  Passed on both row ends, Pointer/Fresh writes InLines Failed, renders
  InLines Failed, as before otherwise; the notes show the Iris changed
  only padding. A RGBA16Float 61x64 texture at 496-byte rows over a buffer
  is now in place and written on the Iris (a shadow under the old verdicts).
- Check time: Iris median 366 -> 386 ms (inside the spread); XTX median
  686 -> 577 ms, all 24 verdicts Passed (7383).
- runtime_lane::in_place_textures 7/7 on the Iris (7387, 7449): in place
  against shadow 35.6 vs 1184.1 us for 32 rows of 3840x2160.
- At the same rule patch (7b2343d53b): clippy cpuicd/gpucfg and rustdoc
  clean (7345, 7364); unit and lavapipe tests 134/134 (7342). Rebased tip's
  own checks (route.rs conflict resolved): gem10 7467, pending.
2026-11-07 23:58:00 -08:00
Anees Iqbal 3f8b07c044 In-place check: a kernel's writes of a texture over a buffer may change its rows' padding
What: a second verdict for a kernel's writes, Access::BufferWrites, taken by a texture over a
buffer's rows (no IOSurface plane's) whose buffer holds its last row to its pitch and whose rows,
each to its pitch, start and end on a line of the device's memory (in_place::Padding::Free). The
same Writes rounds give it: the writer and the compare tell a change of a byte of the shape's
rows' padding (after a row's last texel, before its pitch, the last row's included) apart from
any other change. A round that changed only such bytes (Round::Padded) fails Writes for its row
ends, as before, and counts as kept for BufferWrites, and the rounds go on through every shape;
any other change (a texel, a byte past the last row's pitch) fails both and ends the class's
rounds. in_place() asks BufferWrites in the stead of Writes for such a texture; renders, an
IOSurface plane's rows and a render target's storage usage (storable) keep the strict verdict.
The rebind's choice of fresh pages carries whether the padding is the buffer's own. 24 verdicts,
CHECK_VERSION 7; the report adds `{class} buffer writes` lines.

Why: real Macs disagree on those bytes, so Metal leaves them to the GPU. The probe
(row_padding_writes.m) found an Intel UHD Graphics 630 under macOS 26.7.1 writing older values
back over the CPU's writes to the padding of textures over a buffer under a kernel's writes
(10,197 and 28,162 bytes in 100 rounds of 3662x64 and 61x64 BGRA8, 304 and 307 in the last row;
m3-max-7240, m3-max-7269), keeping them over IOSurfaces and under clears, stores and draws; an M3
Max under 27.0.1 (arm64 and x86_64, m3-max-7241) and a Radeon Pro 5300M (static check, 7269) kept
every byte. The owner's ruling: follow the x86 Macs' envelope and remove the shadow copy where
possible. On the Iris Xe, whose writes write back the 64-byte line holding a row's last texels,
written textures over a buffer whose rows end inside a line now take the image in place.

Docs: in_place.rs and in_place_check.rs module docs, docs/API.md (the in-place paragraph, the
shadowed-texture notice, section 10 Kernels with the three probe results), FAST-PATHS row 41, the
runtime README. Lanes: in_place_textures' VERDICTS 24 and its written-texture checks ask the
buffer writes verdict where the padding is free (in_place_rows::padding_free/writes), the
padding bytes of a texture in place with free padding no longer held to the pattern.

Tests: tests::in_place's decision test over both paddings; Padding::of cases (the guest's
3662x2039 surface at a 14656-byte pitch is free, 416x51 at 64-byte lines kept, slices apart);
Bytes::compare telling a change of each row's padding (the last row's last byte included) apart
from one past the last row's pitch or of a texel, and from padding that is not free; Tally's
verdicts for the Iris's walk and the others.

Verified: pending.
(cherry picked from commit 200f2a9e2b26eeaff45c1cc5ec71decf42d8437e)
2026-11-07 23:57:05 -08:00
Anees Iqbal 573b3bf5b1 In-place check: shapes at a driver's own pitch only where the class made none of their texel size
The row-ends change gave SHAPES and STORE_SHAPES two pairs of shapes whose rows end inside a line
at the pitch a driver that makes no image at an explicit pitch lays them at: 16 bytes (MoltenVK)
and 64 (llvmpipe). A device that makes images at an explicit pitch (RADV, ANV, NVIDIA) made all
four as well, eighteen rounds more a check, though each repeats a texel size the class's
512-byte shapes had checked: on the RX 7900 XTX the check took 811-952 ms with them (m3-max-7197,
gem10 loaded), against 535-561 without the 64-byte pair (m3-max-6817).

Each of those four is now a tight shape (Shape::tight, made by tight()), and a class runs it only
where no shape of its texel size whose texels share a line was made before it in the class
(Shape::runs; check_class keeps the texel sizes made). A device that makes explicit pitches makes
the 512-byte shapes first and skips all four; MoltenVK makes the 16-byte pair and skips the
64-byte one; llvmpipe makes neither the 512-byte shapes nor the 16-byte pair, so it runs the
64-byte one. ROUNDS's docs now count four shapes whose rows end inside a line on a device that
makes explicit pitches: twelve chances or more, odds below one in 10^20 for a device that
escapes each as often as the Iris Xe's worst shape did.

Tests: tests::in_place::shapes_at_a_driver_s_own_pitch_run_only_where_none_of_their_texel_size_was_made
walks a class as check_class does, for SHAPES and STORE_SHAPES: no tight shape on a device that
makes every shape, the pair at its own pitch on one that lays rows at the next multiple of 16 or
of 64 bytes alone, and the 64-byte pair none after the 16-byte one.

(cherry picked from commit ea09b939340a700afaee14ce06514487f88df682)
2026-11-07 23:57:05 -08:00
Anees Iqbal cc34e97716 Probe: whether Metal's GPU writes of a linear texture change its row padding
A texture's rows over a buffer or an IOSurface's plane lie bytesPerRow apart, past their texels.
ANV writes back the 64-byte line that holds a row's last texels, the padding beside them in it;
whether Metal's own writes keep that padding settles whether the runtime may count it as the
surface's. The probe writes a BGRA8Unorm texture 3662 or 61 texels wide, 64 rows, by a render
pass that clears and stores it, one that draws over it, and a kernel, 100 command buffers each,
over a buffer and over an IOSurface; on unified memory a CPU thread writes every padding byte over
and over meanwhile, checking each still holds its last write, and counts the last row's apart; on
discrete memory the padding holds a pattern through the writes and a synchronize. Test-only: no
crate builds it.

The header records what it found. The M3 Max (macOS 27.0.1, arm64 and x86_64) kept every byte;
the Intel UHD Graphics 630 (macOS 26.7.1) put older values back over the CPU's writes to the
padding of textures over a buffer under a kernel's writes (10,197 bytes at 3662x64, bpr 14848, 304
in the last row; 28,162 at 61x64, bpr 256, 307 in the last row) and kept it otherwise; the Radeon
Pro 5300M (macOS 26.7.1, static check) kept every byte.

Verified: built on the M3 by clang for arm64 and x86_64 (m3-max-7233; m3-max-7260 with the last
row apart) and run on the M3 Max, both architectures (m3-max-7241), and on macbook-pro-2019's UHD
630 and Radeon Pro 5300M (m3-max-7240; m3-max-7269 with the last row apart).

(cherry picked from commit 89b8dea1f3c7ae8b4df9975933454c6ad6f9b173)
2026-11-07 23:57:05 -08:00
Anees Iqbal 0f337c2e4f Self-read lane: the guest's surface at 3664x2039 beside 3662x2039
The consumer's guest now makes every display mode a multiple of 16 pixels wide, so its desktop
surface's rows of 4-byte texels start and end on a 64-byte line and the surface goes in place on a
device whose check fails rows that end inside one. self_reads, and keep_copy_costs with it, now run
that width too: a 3664x2039 surface, whose 14656-byte rows are 229 lines each, beside the 3662
one and the 3840x2160 one.

Verified: built and run in the jobs the next report names.
(cherry picked from commit 983a1f0e9942bf5eb516f1e21382ad7e54edc620)
2026-11-07 23:57:05 -08:00
Anees Iqbal 432d36590c Self-read lane: what one keep's copy of a surface's texels costs
A merged shadow's keep copies its texels into a kept image (vkCmdCopyImage) before each command
buffer's pass. keep_copy_costs times that copy alone, per command buffer of one blit of a private
BGRA8Unorm texture of each self-read size into another, so a frame's keep can be told apart from
its merge.

Verified: built and run in the jobs the next report names.
(cherry picked from commit 7c54127483878ed84f9d55ac0d950cafe032b556)
2026-11-07 23:57:04 -08:00
Anees Iqbal b429d4c6b3 Self-read lane: the surface over logged pages beside the unlogged one
The self_reads measurement's surface over host pages took a whole copy in of its shadow at each
command buffer wherever it was a shadow (the guest's 3662x2039 surface on the Iris Xe, whose rows
end inside a 64-byte line). Nothing told apart what that copy in costs a frame from what the keep
and the merge back cost. Each size now also runs the same surface over pages whose memory carries
a log of their writes (HostMemory::with_dirty_pages, the guest pages lane's GuestLog, which keeps
writers apart), which nothing but the runtime writes: after the first, each copy in takes no page,
so the logged surface's frames less the unlogged one's are the copies in. Each line also prints
the copies in the log gated, those it skipped and the bytes they copied.

Verified: built and run in the jobs the next report names.
(cherry picked from commit 9eb000878710df2b3ab17db0ef0a9d045212706d)
2026-11-07 23:57:04 -08:00
Anees Iqbal 95a5f1ad37 Point HOWTO's integrators at the texture placement query
docs/HOWTO.md's passage on textures over host pages told a program to start
the in-place check early with Device::settle_in_place_checks; it now also says
that a zero timeout later answers whether the verdicts are known, and that a
program routing each surface to its pages or to a copy of its own asks
Buffer::texture_placement (or texture_placement_with_iosurface_plane), whose
answer is the making's own decision. Docs only.

(cherry picked from commit 17bbae52a0330a75a5d1cd522407f2888dc7bcff)
2026-11-07 23:40:30 -08:00
Anees Iqbal f80b927bc9 Bump RUNTIME_VERSION to 1871: a texture over host pages answers its placement before it is made
inplace: Buffer::texture_placement and texture_placement_with_iosurface_plane
answer InPlace, Pending, Shadow(reason), NotHostPages or OtherShape by the
route decision the making itself takes (Device::route_over_buffer,
texture/route.rs); Device::settle_in_place_checks is public. For the
consumer, which sends surfaces that cannot lie in place to its own
IOSurface cache.

Verified by inplace: msi 7363 plain clippy runtime clean, unit tests 14/14,
api_signatures 3/3; M3 7369 (m2v_gpu) 40/40, the device test's answers
matching the made texture's route in every case reached (Pending then
InPlace after settle, StoreWidth, InPlace for render target / IOSurface
plane / fresh pages, OtherShape, NotHostPages, PastLength, Refused(Detached),
Policy, CheckFailed). Pending: lavapipe and clippy in the gpu/cpu_icd cfgs
and rustdoc (gem10 7370). Not reached: DeviceCopy (discrete Managed) and
the copied-buffer Refused(Placement).
2026-11-07 23:36:00 -08:00
Anees Iqbal 1aeff532b6 Answer where a texture over a buffer's bytes lies before it is made
A consumer that routes each surface either to textures over its pages in place
or to a cache of its own had to parse the doc-hidden in_place_check_report()
strings and re-derive row ends to learn the runtime's verdict. Now it asks:

- Buffer::texture_placement(descriptor, offset, bytes_per_row) and
  Buffer::texture_placement_with_iosurface_plane(descriptor, plane) answer a
  TexturePlacement: InPlace, Pending (a shadow made before its verdict, which
  moves in place where it passes), Shadow(TextureShadowReason) (policy, store
  width, check failed or unchecked with its InPlaceAccess and InPlaceRowEnds,
  Refused(InPlaceRefusal), texels past the length, a device copy),
  NotHostPages, or OtherShape.
- The answer is the making's own decision: the route a texture over a buffer
  takes (past its length, no host pages, a device copy, bytes detached or
  copied, and the in-place decision against the verdicts) moves out of
  storage_over_buffer into Device::route_over_buffer (texture/route.rs), which
  the making and the query both call. make_texture_over takes a goal, make or
  ask, so the query runs every check the making runs before it makes anything
  and refuses the same arguments with the same errors; the IOSurface client
  direction refusal is one function both use.
- Device::settle_in_place_checks is public, documented: it starts the check,
  says when the verdicts are known (a zero timeout waits for nothing), and how
  a recovery's new VkDevice reads them again or checks anew.

Tests: tests/texture_placement.rs maps every route and shadow cause to its
answer; tests/texture_placement_device.rs (m2v_gpu, m2v_cpu_icd) asks and
makes over host pages: pending then known after the settle, the pending
texture moving to the answer at the next quiet commit, a store width, a render
target, an IOSurface plane, a long buffer, texels past the length, no host
pages, a texture buffer, detached bytes, the Shadow policy and a forced failed
check, comparing each answer with the counts the making moved, and the
errors of refused arguments.

docs/API.md and the runtime README describe the query; api_signatures
re-blessed; docs/REFUSALS.md regenerated.

(cherry picked from commit bef6ce09f56d8a7c1ad5ee7ef934a06a39b58c7a)
2026-11-07 23:35:06 -08:00
Anees Iqbal a8239b35cb Bump RUNTIME_VERSION to 1870: slot rebinds filled in place, their lists kept across encoders
perdraw: cut 4's new allocations a draw removed. SlotRebinds is flat
lists filled in place (BindingPlan::slot_rebinds_into), the debug
cross-check refills a thread-local, the later-overlap mask folds into
pushes, and the lists live in LiveBind so an encoder's end keeps their room.

Allocations a draw (frame_costs, --cfg m2v_gpu), before cut 4 /
development / this: M3 debug 19.21 / 21.16 (over the bound of 20) / 19.21,
M3 release 7.38 / 8.54 (cut 4 alone) / 7.38; lavapipe debug 18.05 / 19.99 /
18.05, release 6.21 / - / 6.21. The bound is unchanged.

Verified by perdraw: gem10 7274 clippy plain, m2v_cpu_icd, m2v_gpu and
rustdoc clean; frame_costs 4/4 on lavapipe (7274) and the M3 (7273);
touched tests 24/24 and 27/27.
2026-11-07 23:26:35 -08:00
Anees Iqbal ba0641e4fe Keep a draw rebound's slot rebinds lists with its bind state, past its settle and encoder
7226 on the M3 read 2b2d3bf8d4 at 19.83 allocations a draw in debug and 8.00 in
release, against 19.21 and 7.38 before cut 4 (0f28b4b79e): the same +0.62 in
both, about 3.7 a pass of the frame's six draws. The lists lived in SettledHere,
which goes as its encoder ends (LiveBind::end_encoder forgets the settles), so
each pass's first draw rebound made them again. They now live in LiveBind beside
the settle (and in each set-aside state, swapped with it in select), so the
spare state the next encoder starts from carries their room; SettledHere keeps
only whether its plan's rebinds were made in them. took_place_of goes.

Verified: cargo fmt only locally; build, clippy and allocation numbers are potluck
jobs.

(cherry picked from commit 5e02b2812036f9af2fee8a8cd99603cabc1d06b1)
2026-11-07 23:25:48 -08:00
Anees Iqbal 973245f2c6 Make a rebound draw's slot rebinds and push overlaps allocate nothing in steady state
runtime_lane::frame_costs::a_frame_s_draws_and_pass_ends_allocate_within_their_bounds
read 21.16 allocations a draw on the M3 in a debug build, past its bound of
20 (round 7e9acd5e73). Cut 4 (2fed3c2453) added allocations to the draw path:

- BindingPlan::rebind_draw_slots_with checked the rebinds it was given
  against fresh ones (slot_rebinds) at every draw in builds with debug
  assertions: a new SlotRebinds, its lists and each changed buffer slot's two
  field lists, at each draw rebound.
- The runtime made a draw's slot rebinds anew at each miss of its cache
  (SettledHere::rebinds: a new settle, or a draw rebound that changed other
  slots): the slots' copy and the rebinds' lists, in release builds too.
- Bound kept each push write's later overlaps in a list of its own
  (push_later), one more list a record allocates at its first push.

Now:
- SlotRebinds holds flat lists of Copy items: a changed buffer slot's push
  fields are ranges of one list of fields (words) rather than two lists of
  its own. BindingPlan::slot_rebinds_into makes rebinds in place of what a
  SlotRebinds held, its lists keeping their room, so making them again for
  no more slots and fields allocates nothing; slot_rebinds makes them in a
  new one. SlotRebinds is Default (made of nothing) and names its slots
  (SlotRebinds::slots). The builder walks the template's changed push fields
  through one iterator (changed_fields) for the validity check, each
  buffer slot's residual and guest-address fields, and the loose ones, in
  the order the lists held before.
- rebind_draw_slots_with's debug check makes the rebinds again in a
  thread-local scratch whose lists keep their room: it allocates nothing
  past its first.
- SettledHere keeps the rebinds in a SlotRebinds it makes them in place in,
  and a new settle takes the replaced one's (SettledHere::took_place_of), so
  a cache miss allocates nothing where the lists had room.
- Bound keeps the overlaps beside each push write's shape in the one list.

Public: BindingPlan::slot_rebinds_into, SlotRebinds::slots and its Default
(signatures blessed; API.md says so). engine_graphics_binder checks
slot_rebinds_into over rebinds of other slots against slot_rebinds.

(cherry picked from commit 2b2d3bf8d43e0846f784ba5d2d896f3bdc94302c)
2026-11-07 23:25:48 -08:00
Anees Iqbal 5b8cdf8974 dispatch_executions: count a window's run that recorded no kept barrier buffer, up to three runs
The 5080 failed a_barrier_set_after_the_commit_records_the_commands_again
in round 7e9acd5e73's lane (part 3): the unset counted run recorded one
barrier command buffer to keep (left 1, right 0), so its barriers were not
the commands' own alone. The test assumed the one uncounted run meets every
list of barriers the queue keeps; a counted run met one more. Round
0950c1a0ab passed it.

Both tests that count the commands' own barriers now count a run that
recorded no barrier command buffer to keep (own_barriers): a run that did
is not counted and the window runs again, at most three times. A list
recorded again at each of its uses still fails every run. The assertions
on the barrier counts are unchanged.
2026-11-07 23:24:13 -08:00
Anees Iqbal ff7c0157e7 Bump RUNTIME_VERSION to 1869: a self-read's split weighed by the texels its copy moves
amdperf-31: a one-level, one-slice colour target's split is weighed by
its copy cut to the scissors' bound plus 1 px; other targets by the
whole level.

Evidence (amdperf, jobs 7079/7076/7077/7151/7080/7202/7201/7292):
- self_reads, private 3662x2039, ms a frame: Iris 1.70, 780M 2.09-2.11,
  XTX within noise of development (unchanged from amdperf-30).
- 1080p target, 960x540 scissor covered whole, us a pass
  (before amdperf-30 / development / this): Iris 506/605/507,
  780M 377/731/379, XTX 53.1/72.0/54.9.
- Sparse 960x540 readers go back to their pre-amdperf-30 times
  (Iris 217 -> 350 us, before 353); 320x180 now splits (0.67-1.17x
  of before); 1280x720 covered whole still takes the snapshot.
- Touched tests 25/25 Iris, XTX, 780M, lavapipe; M3 20/20; clippy
  in 3 cfgs and rustdoc clean at 2fb3261df0.
2026-11-07 23:06:18 -08:00
Anees Iqbal 46013629ca Give the area rule's measured costs on the Iris Xe and with the split weighed by its copy
The rule's doc (render/snapshot.rs) and FAST-PATHS's attachment-read paragraph now give what the
lanes measured at 2fb3261df0 (copies b9db87767a on ms01, 226fb24902 on gem10):

- snapshot_area_costs, no scissor (the rule against the split on a device withholding
  fragmentShaderPixelInterlock): a reader over 1.5% of the target 0.09-0.33x on the Iris Xe
  (m3-max-7079), 0.09-0.23x on the Radeon 780M (7077), 0.25-0.43x on the RX 7900 XTX (7076); over
  the whole target 1.03-1.20x, 1.95-2.30x and 1.30-2.10x.
- snapshot_crossover over a private 1920x1080 target, against the build before the rule
  (5a216c19b0; 0950c1a0ab on the Iris): 320x180 and 960x540 split, 1280x720 and the whole target
  take the snapshot. Through those, a reader covering 1.5% of its scissor 0.36-0.64x on the Iris
  (7079) and 0.28-0.97x on the 780M (7077, 7202), one covering the whole scissor 1.12-1.18x and
  1.97-2.34x. On the XTX 0.69-1.09x and 1.5-2.6x (7076, 7201): its times for one binary varied up
  to 1.75x between runs (7292: two copies of the same control binary, 180-317 us a pass on the
  same row, and self_reads 0.285-0.542 ms a frame).

Doc only.

(cherry picked from commit 2548a362de7c38b4354bb8106c0e6218c3975103)
2026-11-07 23:05:20 -08:00
Anees Iqbal 75b85a7dc6 Read a snapshot reader's pixels at the lane's own side
ed15457d04 grew snapshot_reads' target to 1024x1024 but kept attachment_reads' red(), whose rows
are that lane's 32 pixels: every pixel the tests held was read at the wrong offset (pixel (8, 8)
read the cleared red 64 where the block's 80 or 240 were). Six snapshot_reads tests failed so on
the M3 Max (m3-max-7039, copy 1e8c7f312c of ed15457d04), where every reader splits. snapshot_reads
now has its own red() over its SIDE, and attachment_reads' red and SIDE, used nowhere else now,
are private again.

(cherry picked from commit 2fb3261df0ca6e73baa924a2a4d4b34fd44cfaf7)
2026-11-07 23:05:20 -08:00
Anees Iqbal 9475afcf05 Say what the step-aside's cap measured: verdicts wait for the workload's quiet
step_aside.rs said a check under a program that never pauses for QUIET still goes on "so its
verdicts come". The 5080 A/B of the 100 ms MOST_ASIDE cap (b5080 entry amdperf-sa26-ab2-175417,
msi w685, the consumer's orders of tests/host_ram_window_bench.rs, 3 rounds of 12 runs per
variant; control 8378473c77 without the steps, tip 1ae40680fd's tree) shows each step going on
only once its 100 ms are up, about ten steps a second: over a fresh cache directory of the
device's own the takes of 5 ms or more fell from 12 of 36 runs to 2 (with the record missing
again: 4 to 0; all options: 10 to 5), and the submission checks' verdicts, 77 to 139 ms without
the steps, had not come by the end of any set, 10 steps aside (1 s) in each. The doc now says
so: the verdicts come at the program's next quiet or once the steps have gone through at that
pace. The cap stays as it is (the orchestrator's call: fewer slow takes are worth more to the
guest than verdicts inside a busy stretch). Doc only.

(cherry picked from commit c6abebaa68b60e82e645bf63af259a751ce1c8be)
2026-11-07 23:05:20 -08:00
Anees Iqbal 37875af7f3 Weigh a self-read's split by the texels its copy moves
The area rule (render/snapshot.rs) weighed the split as a copy of every texel of the color's
level. The split's copy for a draw that reads at its own pixels is cut: for a one-level,
one-slice color it moves only the texels inside the rectangle bounding the draw's scissors, a
pixel wider each way (render.rs's bound_own_pixel_reads, ShadowCopies::cuts). So the rule
overstated the split for readers through scissors smaller than the target, and since 61a367cb51
those took the snapshot where the split was the cheaper worst case: on the snapshot_crossover
lane's 1920x1080 private target, readers through 960x540 and 1280x720 scissors covering them
whole took up to 1.93x and 1.97x their split time on the Radeon 780M, and 1.32x and 1.41x on the
RX 7900 XTX (jobs 6872, 6871 against their own before runs).

The rule now weighs the split by what its copy moves, computed by the same two functions the copy
bound uses, now shared (scissors_bound, own_pixel_loads): a one-level, one-slice color's texels
around the scissors, else every texel of the level, as before. A reader through no scissor, the
consumer's self-reads, weighs as before and keeps the snapshot. By the rule a 4-byte color's
reader takes the snapshot through scissors whose rectangle holds about 786,432 pixels (1024x768)
or more and splits through smaller ones: on the crossover's target, 320x180 and 960x540 split,
1280x720 and the whole target snapshot.

Tests that relied on a small reader taking the snapshot now draw through scissors large enough:
- runtime_lane::snapshot_reads: a 1024x1024 target, the readers through the whole target's
  scissor (snapshot where the device takes the path); through QUARTER an RGBA8Unorm reader splits
  and an RGBA16Float one takes the snapshot; R8Unorm and RG8Unorm readers split; the
  feature-withheld and depth/stencil readers through the whole target, so their split is the
  feature's or the attachment's, not the rule's.
- tests::self_read_storage: a 1024x1024 target, the reader through no scissor.
- tests::snapshot_area: 8x8 scissors (copy of 10x10 texels): 4-byte split, 8-byte snapshot;
  960x540 split and 1280x720 snapshot over 1920x1080.
- attachment_read_costs: the composite workload's window readers split again; its docs say so.

docs/FAST-PATHS.md's attachment-read paragraph and the module docs carry the landed
snapshot_area_costs lane's numbers (rule against the split with fragmentShaderPixelInterlock
withheld): reader over 1.5% / the whole target, Radeon 780M 0.08-0.23x / 1.8-2.3x (job 6872),
RX 7900 XTX 0.25-0.43x / 1.3-2.1x (6871).

(cherry picked from commit ed15457d04c98f767511374ff4d368a0373a4361)
2026-11-07 23:05:20 -08:00
Anees Iqbal 20038c5c45 Bump RUNTIME_VERSION to 1868: host-copy blocks made ready off the program's thread, every page read
RADV after a GPU suspend: an app's first write into a host-copy texture
faulted on the block's mapping and waited for the kernel's clear of the
new VRAM block, ordered behind every submission of the process. The
blocks host copies place in are now made ahead, every page read once.

Evidence (wake, jobs 7290/7291/7303/7193/7187): XTX first write with the
GPU suspended 55-114 us (control 553-654 ms); awake 58-63 vs 68-96 us;
first-texture making no regression on XTX, 780M (order-balanced) and
lavapipe; touched tests 116/116 780M, 115/116 XTX, 116/117 lavapipe (the
one failure is the recovery race perdraw owns).
2026-11-07 23:04:54 -08:00
Anees Iqbal 902002273d Narrow RADV's first-write-after-suspend gap to moved and dedicated memory
Measured on the RX 7900 XTX (gem10, Mesa 26.2.6) with tests::zeroed_start's busy
test, five processes each started with the GPU in runtime suspend (job
m3-max-7290). The first replace_region into a texture made behind about 1.5 s of
fills took 55 to 114 us with the blocks host copies place in made ready ahead,
each run readying 1 block and making 0 in place. With that readying off
(negative control: 5ee5d0e582's keep_room change) it took 553 to 654 ms, and the
test failed on its readied-block assertion. Awake it took 58 to 63 us, against
68 to 96 us without.

What stays open, from the in-process probe on the same card: a texture placed
before a mid-process suspend waited 86 ms for the kernel's moves back, and a
texture of its own block (4096 x 4096) waited 73 ms.

(cherry picked from commit 065f04d7f3016469a01d9148aba4dc9e991dfd79)
2026-11-07 23:03:55 -08:00
Anees Iqbal 9bfe8581e4 Wait for no making of a host-copy block; list its modules as keepers
A placement that found its pool without room waited for the block being made
ready. That making may itself wait behind the program's GPU work (its pages'
faults wait for the kernel's clear), and a texture's making waits for no such
work. On lavapipe the first of 1000 textures made right after the device took
54 ms (um870 job m3-max-7180, ZEROED-MAKES). A placement now adds the block only
once its making has ended, and otherwise makes its own block as before
(host_copy_blocks_made_in_place).

tests::exit_guard::only_the_listed_modules_keep_the_device_s_functions failed on
lavapipe (m3-max-7180): memory.rs passes the device's functions to the making,
and memory/ready.rs keeps them on its thread. Both are now listed, with the
reason they cannot outlive the device: Memory::destroy joins the thread before
vkDestroyDevice.

tests::zeroed_start's busy test now waits until the block the first creation
call started is ready before it queues the busy work. It holds where the
textures lie, not how soon a making ends.

(cherry picked from commit fcdb9dc5a99d65d72e88b142766ec212ad90e16b)
2026-11-07 23:03:55 -08:00
Anees Iqbal d0e638cbe3 Name ash's host-transfer image usage by its extension name
The probe image of the host-copy pool named vk::ImageUsageFlags::HOST_TRANSFER, which
is metal2vulkan::vk's spelling; ash 0.38 names it HOST_TRANSFER_EXT. The runtime did
not compile (um870 job m3-max-7154, E0599).

(cherry picked from commit 26e4a38bc85c36a9179cbc36937614bdb3ca81f0)
2026-11-07 23:03:55 -08:00
Anees Iqbal 4abacee2be Add a block made ready for host copies only at a placement that lacks room
keep_room added a finished block as a creation call found it, so the pool's
blocks and free ranges changed at whichever creation call came after the making
ended: a count of the pools' room work across a run of creations
(tests::pool_room_creations) would move by timing. The block now waits, held,
until the first placement in its pool that finds no room adds it, so the pool
changes only at its placements. keep_room starts no other making while one is
held. host_copy_ready_waits is gone: every readied block is added by such a
placement, so it equalled host_copy_blocks_readied.

(cherry picked from commit 62f1158131f7cd8b259a88dd17bc2d33673ede63)
2026-11-07 23:03:55 -08:00
Anees Iqbal 9f5e68053d Make the blocks host copies place in ready ahead, every page read
On RADV after the GPU idled into runtime suspend, a fresh Shared texture's first
replace_region waited for the program's queued GPU work. Measured on the RX 7900 XTX
(gem10, Mesa 26.2.6, kernel 7.3.1) with ftrace: the write faults on the block's mapping
(amdgpu_gem_fault), the fault waits in dma_resv_wait_timeout for the kernel's clear of
the new block (dirty VRAM after resume), and that clear is ordered after every
submission of the process because the block shares the VM's reservation: 516 to 684 ms
behind about 1.5 s of fills, 160 us awake.

The pool a color texture's host-transfer image places in now gets its blocks made off
the program's thread (memory/ready.rs): keep_room, which the creation calls run, starts
one where the pool lacks room for half a block, the thread allocates it and reads every
page of its mapping, and the block enters the pool once ready. A placement that finds
no room waits for the block under way rather than making an untouched one. The first is
started at the device's first creation call, before the program queued any work.
RADV's host image copies use the runtime's own mapping of the block, so the touched
pages are the ones the copies use.

New WorkCounts fields: host_copy_blocks_readied, host_copy_ready_waits,
host_copy_blocks_made_in_place. tests::zeroed_start asserts a host-copy device readied
a block and made none in place across the busy test.

Not covered: a block evicted by a mid-process suspend comes back at the next
submission, and the first touch after it waits for those moves.

(cherry picked from commit a7c5fb891b078079852c0cbc32af8e657a6c4000)
2026-11-07 23:03:54 -08:00
Anees Iqbal c411930033 Bump RUNTIME_VERSION to 1867: a new heap set walks its live textures with no lock held, in parts
holds' first-set tip (c3187c1978): under the heaps lock a new set records the live textures with
the slot write that placed each and takes retirement and rebind tickets; it then walks them
unlocked in parts of 64, each in its own passing hold (a waiting making goes on between parts:
PassingHolds::makings, Device::let_makings_pass), and under the lock again writes those placed
since and forgets those gone since. Re-pinned.

Verified by holds, release, the heaps lock while the first set is made at 5000 textures: lavapipe
6.9-7.4 -> 0.51-0.71 ms (m3-max-7219), M3 13.2-13.3 -> 0.36-0.42 ms (7220); longest passing hold
lavapipe 6.9-7.3 -> 0.22-0.34 ms, M3 13.1 -> 0.05-0.07 ms; the set's total making about 1 ms
longer, off the lock. New tests::heap_set_walk; lavapipe 216/216 (7198); three negative controls
fail (7214); clippy x3 and rustdoc (7268). heap_set_walk not yet run on the M3.
2026-11-07 22:57:45 -08:00
Anees Iqbal 5f04beb449 Walk a new heap set's live textures with no lock held, in parts
A new heap set with an image array of a class no live set holds (the
device's first set, at a guest process's first argument-buffer heap) wrote
every live texture's elements under the device's `heaps` lock and inside
one passing hold: the views made at their first use and the descriptor
writes, 6.9-7.4 ms on lavapipe and 13.2-13.3 ms on the M3 at 5000 textures.
A texture going on another thread waited that long for the lock, and one
made there waited for the passing hold, as every making does.

heap_set now makes the set's layout, version and neutrals with no lock held
(SetEntry::unplaced, which takes over from Unplaced), then under the lock
records the live textures, each with the slot write that placed it (new
Placed::written, from DeviceHeaps::slot_writes), and takes a ticket of the
retirement and one of what a rebind or a detach replaced: a texture's image
gone meanwhile, and what such a rebind replaced, live until the set is
placed, so every view the walk writes is live as it is written; and while a
ticket is out no storage form swaps. With no lock held the walk takes the
textures in parts of WALK_PART (64), each inside a passing hold of its own,
and writes their elements into the set's version, which no command binds
and no other thread writes yet. Between two parts it lets the makings
waiting for the passing holds go on (PassingHolds counts the makings in
`wait`; Device::let_makings_pass waits until none waits), since back-to-back
holds would otherwise keep a making waiting for the whole walk. Under the
lock again the set is placed: it writes each texture placed since the walk
found it (its slot write differs), forgets what the walk noted of each one
gone since (as `clear` leaves a gone texture in a live set), copies its
other arrays from live sets as before, and gives the tickets back. The set
still holds every texture live at its placement. The resource_ids.rs and
heap_sets.rs module docs say so. No WorkCounts field or Degradation kind is
added.

Test: tests/heap_set_walk.rs makes two textures, pauses the making thread
once its walk took them (a test-only hook, DeviceHeaps::pause_walking),
releases the first and makes a texture, which takes the first's resource ID
back; both must be done within 2 s of the 4 s pause. The dispatch that made
the set must read the new texture through that ID (not the walk's view of
the released one), and a second dispatch the second texture as the walk
wrote it.

Verified (potluck jobs, off 7e9acd5e73; development since then touched
none of these files):
- lavapipe (--cfg m2v_cpu_icd), m3-max-7198 (homelab-um870-1): the runtime's
  tests::heap* (heap_set_walk, heap_set_unlocked, heap_set_copies among
  them), passing_holds, twin_reads, kept_heap_uses, storage_form, in_place,
  shadow, argument and resource_id tests: 216/216.
- Negative controls (scratch commits, not landed), m3-max-7214, lavapipe:
  the walk under the heaps lock: heap_set_walk fails, the release and the
  making having waited 4.001 s; the walk inside one passing hold: fails,
  4.0006 s; a walked ID taken as found whatever wrote it since: fails, the
  set holding the released texture's view at the reused ID (the ID check
  passed first). heap_set_unlocked passed in all three.
- Release before/after, one job and host each, a scratch timing test (the
  first set at 5000 and 514 live 8x1 textures, three rounds):
  - lavapipe (m3-max-7219, homelab-um870-1): heaps lock held while the set
    is made, 5000: 6.9-7.4 ms before, 0.51-0.71 ms after; 514: 0.44-0.48 ms
    before, 0.040-0.042 ms after. Longest passing hold, 5000: 6.9-7.3 ms
    before, 0.22-0.34 ms after; 514: 0.43-0.47 ms before, 0.07-0.08 ms
    after. The making in all: 11.4-11.8 ms before, 12.4-12.8 ms after.
  - Apple M3 Max (m3-max-7220): heaps lock, 5000: 13.2-13.3 ms before,
    0.36-0.42 ms after; 514: 2.55-2.63 ms before, 0.029-0.040 ms after.
    Longest passing hold, 5000: 13.1-13.2 ms before, 0.05-0.07 ms after;
    514: 2.5-2.6 ms before, 0.04-0.06 ms after. The making in all:
    13.4-13.5 ms before, 13.6-14.4 ms after.
- Not run before this commit: heap_set_walk on the M3 (development's M3
  lane runs it).

(cherry picked from commit c3187c19781fcdb967baf31255a445ac82bbb37f)
2026-11-07 22:56:56 -08:00
Anees Iqbal 0e420a1834 Re-bless the authored compile census at 7e9acd5e73
Its product fingerprint follows development's versions at 7e9acd5e73. Blessed on the
M3 (s37-pl.sh censusbless --bless, dv-m3).

(cherry picked from commit c902429761522e433d13a0bbd9243dbbf9a60b01)
2026-11-07 22:24:40 -08:00
Anees Iqbal 7e9acd5e73 Bump RUNTIME_VERSION to 1866: in-place verdicts by row ends, so a surface whose rows end on the device's lines takes its pages in place
selfread's row-ends tip (826eb4d65b, f815203f07): the in-place check's verdicts become 18,
class x access x row ends, the line being the device's nonCoherentAtomSize: OnLines texels share
no line with bytes beside them, InLines texels share one. CHECK_VERSION 6. On the Iris Xe renders
and writes fail InLines and pass OnLines, so a 3840x2160 surface goes in place (0 shadow copies
a frame where it copied 8.3M texels: self_reads baseline 3.5 -> 1.7 ms, self-read 5.0 -> 4.55 ms
GPU a frame) while the guest's 3662x2039 one, whose rows end inside a line, stays a shadow.
Re-pinned.

Verified by selfread: Iris (m3-max-6892) fresh checks x20 as above, 323-383 ms; the six lanes that
hold a texture to its verdict passed under validation (48 tests); M3 (7142) 12 Passed, 6 DmaBuf
Unchecked, 5/5, 306-311 ms, no cost record moves; RADV XTX (6817) 18 Passed 5/5, 535-561 ms;
clippy m2v_cpu_icd and m2v_gpu and rustdoc clean, API tables, ledger, tests::in_place 44 passed,
lavapipe 306/307 at b0043502d1 (the one failure fixed here by the 64-byte-pitch shapes; the
lavapipe rerun is 7152). The M3 verdict correction for 0950c1a0ab is in f815203f07's message.
2026-11-07 22:14:51 -08:00
Anees Iqbal 532fc35b7a In-place verdicts by row ends: texels that share a line of the device's memory with bytes beside them, and texels that share none
On the Iris Xe (ANV) a pass that clears and stores a linear image, and a draw into it, write back
whole the 64-byte line that holds a row's last texels. That puts an older value back over a CPU
write beside the texels, so the check fails render targets over host pages there, and every such
texture is a shadow. The write-back cannot reach a CPU write when no line holds both a texel and
a byte beside the texels: the probe read 0/100 for rows that end on a line, and 0/25 for a
3840x2160 surface of tight rows. A 3840x2160 BGRA8Unorm surface's 15360-byte rows are 240 lines
each.

The check's verdicts are now kept per class, access and row ends (in_place::RowEnds):
- The line is the device's nonCoherentAtomSize. vkspec defines it as "the size and alignment in
  bytes that bounds concurrent access to host-mapped device memory".
- RowEnds::of reads the texels' address, offset and pitches. Texels are OnLines where their first
  byte and their end lie on a line, and so do each row's (or slice's) start and end where bytes
  lie between rows (or slices). Elsewhere they are InLines.
- The check runs the shapes whose texels share no line first (Shape::rows; seven of SHAPES at
  64-byte lines). A byte changed beside one of them fails both row ends. A byte changed beside a
  shape that shares a line fails InLines alone, since the OnLines rounds have already run (the
  verdicts function). A device that fails InLines now also runs its OnLines shapes.
- SHAPES gains two shapes whose rows end inside a 16-byte line, at the 16-byte pitch a driver
  that lays rows tight uses: BGRA8Unorm 101x51 at 416 bytes and RGBA16Float 33x17 at 272, the
  same shapes STORE_SHAPES already holds. MoltenVK makes no linear image with bytes between rows
  except at that pitch, and its line is 16 bytes. Without these two, none of its shapes whose
  texels share a line was made, so its reads and renders were Unchecked for those texels: on
  the M3, a probe of this change without them gave Pointer and Fresh reads and renders Unchecked
  5/5 for InLines (m3-max-6750).
- SHAPES and STORE_SHAPES gain the same widths at the 64-byte pitch of a driver that lays rows
  at the next multiple of 64: BGRA8Unorm 101x51 at 448 and RGBA16Float 33x17 at 320, and
  RGBA8Uint 101x51 at 448 and RG32Uint 33x17 at 320. On lavapipe (llvmpipe's linear images take
  64-byte rows, its line 64 bytes) no shape whose texels share a line was made without them:
  tests::in_place_check::the_in_place_check_checks_fresh_pages_where_held_imports_cost_submissions
  read the Fresh verdicts Unchecked for all three accesses of those texels (m3-max-6991). The
  shape test now holds that drivers whose rows lie at the next multiple of 16, 64, 128 or 256
  bytes each have such a shape, for each access.
- The record holds 18 verdicts. CHECK_VERSION goes to 6, so a record of the old check is not read.
- The report keeps its nine lines, now the InLines verdicts (the old verdict exactly, since an
  OnLines failure fails both), and adds nine ", rows on lines" lines after them.
- The texture's own row ends decide, everywhere a texture asks for its verdict: its making
  (Texels::rows), a shadow's move in place (MoveWait, move_wanted) and a copied rebind into fresh
  pages (fresh_pages_take_images, from the watch's place in its pages). ShadowCause::CheckPending,
  CheckFailed and Unchecked name the row ends, and the notice says them.
- Device::in_place_check_line (doc-hidden) answers the line. The lanes that hold a texture to its
  verdict compute its row ends themselves (runtime_lane::in_place_rows, apart from the runtime's
  reckoning) and read that row ends' line.

Docs: FAST-PATHS row 41 and the API guide describe the row ends. The ShadowedTexture notice
docs name them. The known gap for rows that end on a line is closed and deleted.

Tests: RowEnds::of covers an offset, an address, a pitch and slices off a line, tight rows that
do or do not end on a line, a 1-byte line, the 3840 and 3662-wide surfaces, and the check's
shapes per class. The verdicts function: a change beside OnLines texels fails both row ends, a
change beside InLines texels fails InLines alone, and a forced failure and an unchecked class are
covered. The decision test runs every class with both row ends. The record test covers 18
verdicts.

Verified, the whole check on fresh caches (the probe test, this change plus the test alone;
the Iris Xe and RADV runs at 5beb0be2a5, before the 64-byte shapes, on development 0950c1a0ab):
- Iris Xe (RPL-P), ANV, Mesa 26.2.6, 64-byte line (m3-max-6892), 20 runs, every run the same:
  reads Passed for both row ends, Pointer and Fresh; renders and writes Failed for texels that
  share a line and Passed for texels that share none, Pointer and Fresh; DmaBuf Unchecked for
  all six. The failures are a byte between two rows: a clear and store or a draw of R8Unorm
  61x37 at 256 bytes a row (renders), and storage writes of RGBA8Uint 101x51 at 512 (writes).
  323-383 ms a check (median 345), against 156-342 ms before (m3-max-6226): a class that fails
  for texels that share a line now runs its rounds for texels that share none to the end, as a
  passing device's do. A build job ran on the same host meanwhile.
- M3 Max, MoltenVK 1.4.2, 16-byte line: Pointer and Fresh Passed 5/5 for reads, renders and
  writes, for both row ends (12); DmaBuf Unchecked for all six (no dma-bufs on macOS). 290-304
  ms a check at 5beb0be2a5 (m3-max-6804); with the 64-byte shapes, at 19a7c36f69 on
  development ee5d3cfab9 (m3-max-7142), the same verdicts and 306-311 ms, the first run 548 ms.
  Before this change, 299-582 ms (m3-max-6160). That earlier run had six verdicts Passed and
  the three DmaBuf ones Unchecked, not all nine Passed as 31b19fa7f0's body says. No M3 cost
  record's case changes path: every verdict the M3 passed before passes for both row ends.
- RX 7900 XTX, RADV, Mesa 26.2.6, 64-byte line (m3-max-6817): all 18 Passed 5/5. 535-561 ms a
  check, against 626-642 ms before (m3-max-6523).

Verified, self_reads on the Iris Xe (m3-max-6892, release, each process on a cache of its own),
the previous commit's lane alone (before) against this change (after), two rounds each, GPU
ms per frame (median) of the baseline and of 30 self-read pairs:
- 3840x2160 surface over host pages, InPlace policy: before a shadow, 3 shadow copies a frame,
  8294400 texels copied in, 1 keep and 1 merge; baseline 3.487 and 3.526, self-reads 4.994 and
  5.014. After in place: no shadow copy, no texel copied in, no keep or merge; baseline 1.676
  and 1.674, self-reads 4.544 and 4.559 (30 snapshots a frame, as before).
- 3662x2039 surface, InPlace policy: a shadow before and after (its rows end inside a line);
  self-reads 4.141 and 4.187 before, 4.168 and 4.205 after.
- Private targets, unchanged: 3662x2039 self-reads 11.48 to 12.12, 3840x2160 14.68 to 15.04
  (30 splits a frame, before and after, on development 0950c1a0ab). Under 61a367cb51's area
  rule, landed since, these readers are expected to take snapshots instead (not run here).
- The check, as the lane's device ran it: 202.6 and 193.8 ms before, 411.5 and 369.7 after.
The lanes that hold a texture to its verdict passed on the Iris Xe under validation
(in_place_textures 7, linear_attachments 25, snapshot_reads 7, linear_alignments 3,
first_use_writes 1, device_copies 5; m3-max-6892).

Checked at b0043502d1 (this change before the 64-byte shapes, on development ee5d3cfab9;
homelab-gem10-1, m3-max-6991): clippy with --cfg m2v_cpu_icd and with --cfg m2v_gpu, all
targets and features, clean; rustdoc with -D warnings clean; the API tables, the ledger test,
check_draw and tests::in_place (44) passed; on lavapipe 306 of the 307 touched tests passed, and
the one that failed is the fresh-pages test the 64-byte shapes fix (above). That test and the
runtime's in-place tests on lavapipe at this commit: m3-max-7152 (homelab-um870-1). The RADV
probe at this commit plus the probe test: m3-max-7153, then its run on the RX 7900 XTX.

(cherry picked from commit f815203f074e1b2f922cd2a2d337ba31ea51e02f)
2026-11-07 22:13:59 -08:00
Anees Iqbal 07f51baf16 Self-read lane: a 3840x2160 surface beside the guest's 3662x2039 one
The self_reads measurement ran one target size, the guest's 3662x2039 framebuffer. Its 14648
bytes of texels end inside a 64-byte line of each 14656-byte row. A 3840x2160 BGRA8Unorm
surface's 15360-byte rows are 240 lines each, which is the shape whose rows the in-place check
can tell apart from those that end inside a line. The lane now runs both sizes (SELF_SIZES),
each target's frames as before, and prints each line with its size. snapshot_area_costs keeps
the guest's size as its largest (SELF_SIZES[0]).

Verified: built in the check job below; the measurement itself is the evidence of the next
commit.

(cherry picked from commit 826eb4d65b56498baad6feb6950d0426b312c2a5)
2026-11-07 22:13:59 -08:00
Anees Iqbal 7940f65666 Bump RUNTIME_VERSION to 1865: a new heap set's layout and pool are made with the heaps lock released
holds' fourth tip (8b6bc56ace): heap_set takes the set's key under the lock, makes the
VkDescriptorSetLayout, pool and set with no lock held, then places the set under the lock,
writing or copying every texture live then (a texture made in the gap is held); a set another
thread placed meanwhile wins and this one is dropped unlocked. Re-pinned.

Verified by holds, release, before and after in one job each, the heaps lock's hold while a set
is made: lavapipe (m3-max-7134) third set 3.7-5.5 -> 0.17-0.20 ms at 5000 textures, second set
7.7-9.1 -> 1.1-1.4 ms, first 11.1-11.6 -> 5.9-6.5 ms (the rest writes 5000 textures); M3 (7113)
third set 0.22-0.27 -> 0.08-0.12 ms. New tests::heap_set_unlocked (negative control fails, the
texture waiting 4.0 s, 7132); heap, hold and twin tests 34/34 and lane 160/160 on lavapipe
(7099); clippy plain, m2v_cpu_icd, m2v_gpu for the runtime. Not yet run on the M3.
2026-11-07 22:13:59 -08:00
Anees Iqbal 1a466c0334 Make a new heap set's layout and pool with no lock held
A new heap set made its VkDescriptorSetLayout and, where the device lets a
pending set be written, its one version (a pool and its set) under the
device's `heaps` lock. A driver may clear every element of the pool as it
makes it (arrays of up to 65536), and every texture made on another thread
meanwhile waits on that lock to place itself.

heap_set now takes the set's key under the lock, makes the layout and
version with no lock held (`Unplaced`), and places the set under the lock
after: made_set writes or copies every texture that lives then, so a
texture made meanwhile, placed in the sets that lived as it was made, is
held by the new set too. Where another thread placed the layout's set
meanwhile, this one goes unused and its pool and layout are let go with
no lock held. The module doc says so.

Test: tests/heap_set_unlocked.rs pauses the making thread once it made the
layout and pool (a test-only hook, `DeviceHeaps::pause_making`), makes a
texture meanwhile (it must be made in under 2 s of the 4 s pause), then
lets the making go: the dispatch that made the set reads the texture
through its resource ID.

Verified (potluck jobs):
- clippy -p metal2vulkan-runtime --all-targets --all-features, plain and
  with --cfg m2v_cpu_icd and --cfg m2v_gpu: m3-max-7099 (msi-laptop).
- lavapipe (--cfg m2v_cpu_icd), m3-max-7099: the runtime's heap_set_unlocked,
  heap_set_copies, passing_holds, twin_reads, kept_heap_uses and
  tests::heap 34/34; the validation runtime_lane heap, resource_ids and
  textures tests and the argument_buffer tests 160/160.
- Negative control (scratch, not landed): the layout and pool made under the
  lock again; heap_set_unlocked fails, the texture having waited 4.0006 s
  for the making: m3-max-7132 (msi-laptop, lavapipe).
- Release-mode before/after, the same job and host each, a scratch timing
  test (5000 and 514 live textures; a third set, of the first layout again,
  whose classes the second set holds, so it copies its arrays and takes no
  passing hold). Heaps lock held while the third set is made:
  - Apple M3 Max (m3-max-7113): n=5000 0.22-0.27 ms before, 0.08-0.12 ms
    after; n=514 0.17-0.21 ms before, 0.016-0.020 ms after. The layout and
    pool take 0.11-0.23 ms there.
  - lavapipe (m3-max-7134, homelab-ms01-1): the layout and
    pool take 3.3-7.5 ms per set there, all of it now outside the lock.
    Third set: n=5000 3.7-5.5 ms before, 0.17-0.20 ms after; n=514
    3.5-3.8 ms before, 0.030-0.034 ms after. Second set (passing hold
    and writes): n=5000 7.7-9.1 ms to 1.1-1.4 ms; n=514 6.8-7.7 ms to
    0.12-0.14 ms. First set: n=5000 11.1-11.6 ms to 5.9-6.5 ms (the rest
    is writing 5000 textures); n=514 4.9-5.5 ms to 0.54-0.71 ms.

The tests and clippy ran on this change over 6105e4537f; development since
touched neither heap_sets.rs nor tests/mod.rs.

(cherry picked from commit 8b6bc56ace4fed8a80332b05dfe42d8d20569c93)
2026-11-07 22:12:57 -08:00
Anees Iqbal 6b1df74efb Staging lane: pass the device's name as it is, not borrowed again
8c161ef193 called staging_waits_bounded(&name, &read) where name is already a &str
(Device::name), so clippy's needless_borrow failed metal2vulkan-validation's lib test under
--cfg m2v_gpu and --cfg m2v_cpu_icd at both call sites (perdraw's check at a6c715e11,
m3-max-7133: 'could not compile metal2vulkan-validation (lib test) due to 2 previous errors' in
both configurations). Test-only.
2026-11-07 22:12:37 -08:00
Anees Iqbal 8ae0800c86 Bump RUNTIME_VERSION to 1864: an encoder reads whether a used heap made a texture since at one load, not a lock
perdraw's fifth piece (31cc724c42, a6c715e111): at each command an encoder that used a heap
reads the heap's count of textures made with one acquire load and takes the heap's texture list
lock only where the count moved. It removes a lock and unlock per draw per used heap, which
serves another thread making textures in the heap while an encoder draws; neither bench sees it
(single thread). Re-pinned.

Verified by perdraw, draws.10k --heap, base 2fed3c2453 against the tip, alternating: lavapipe
(7089) 5070 -> 5074 instructions (+0.09%), ns unchanged; M3 (7090) 5156-5161 -> 5151-5159, ns
noise; cost --check on the M3 moved no gated bound; touched tests (heap, residency, draw_again)
187 passed on lavapipe; plain clippy clean. Linux clippy m2v_gpu and m2v_cpu_icd, rustdoc and
the lavapipe suite follow (7133).
2026-11-07 22:02:48 -08:00
Anees Iqbal a880344652 Say what a heap's look costs now: one atomic load, its lock only for a texture made since
Residency::sync_heaps and heap_textures still said a heap that made no
texture since costs one lock; since 31cc724c42 it costs one acquire load
of the heap's count (Heap::textures_made), and only a heap whose count
moved takes its list's lock. Doc comments only.

(cherry picked from commit a6c715e111f24e2b4fa702ffc74ab3b7e8e8ad1a)
2026-11-07 22:02:08 -08:00
Anees Iqbal d50699c03b Read whether a used heap made a texture since at one load, not a lock
An encoder that used a heap looks, at each command, whether the heap
made a texture since it last looked (Residency::heap_textures): a lock
and unlock of the heap's texture list per draw and used heap, which on
macOS is a pthread mutex pair beside the encoder's own.

The heap now stores its count of textures made in an atomic as it holds
each texture, under the list's lock, with release ordering; the look
loads it with acquire ordering, and only a heap whose count moved takes
the lock to read the new textures, as before. A load that reads a
count then finds that texture under the lock.

(cherry picked from commit 31cc724c42fed99d476e625606edc63a088f95c8)
2026-11-07 22:02:08 -08:00