Commit Graph
2474 Commits
Author SHA1 Message Date
Anees Iqbal 3f5c8bfa27 Record no coverage query in an instance of views
A precise occlusion query begun in a subpass with a view mask uses one query of the pool for
each view (VUID-vkCmdBeginQuery-query-00808), which would overlap the next reader's query. The
snapshot path refuses passes of more than one layer, so no measured reader draws views today;
the filter makes the query's recording not depend on that.

(cherry picked from commit d7b0e5652610fb46d5288d53e7c514c8258860cf)
2026-11-08 01:41:30 -08:00
Anees Iqbal 26d00a396c Weigh a reader of its pass's color by what it covered in its last measured pass
The area rule weighs a reader through no scissor at the share least favourable to each form,
since a draw's recording cannot know what it covers. A 1280x720 or 1080p reader covering the
whole target therefore took the snapshot, 1.97-2.34x the split's GPU time on the Radeon 780M,
while the consumer's readers over 3% of a 3662x2039 target need the snapshot (Iris 12.8 ->
1.7 ms a frame). Both shapes weigh the same at recording, so no static rule serves both.

Now, on a device with occlusionQueryPrecise that resets queries on the host, each reader the
rule would weigh records its drawing commands inside a precise occlusion query of its pass's
own pool (render/coverage.rs). As the command buffer completes, the count is kept on the
reader's first color's texture, keyed by the pipeline state and the reader's place among that
state's readers of the texture in the pass. Later passes weigh that reader at its count: the
snapshot where SNAPSHOT_PIXEL_COST per covered pixel per color costs no more than the split's
copy. A device without precise queries or host reset, a reader inside an app's visibility
query (already refused the snapshot), a pending pipeline's draw and a replay record no query
and keep the area rule. Instances recorded inline after a split keep the query's begin and end
with their draws. Both forms are exact; a stale count costs the form it chose until a pass
after the change completes.

Counted: WorkCounts::coverage_queries and reading_draws_by_coverage. The crossover lane runs
each cell once untimed so its timed frame is weighed by the learned count.

Tests: tests::learned_coverage (forms and bytes across a sparse -> whole -> sparse change;
an app's Counting visibility query keeps its count with a reader inside), coverage unit tests.

(cherry picked from commit 1108cd1bdebfb15f9da91b39ed80d91d8624bc28)
2026-11-08 01:41:29 -08:00
Anees Iqbal a335824604 Record host_copy_blocks_readied in indirect-mesh-commands-object-threadgroup-lengths
wake's readied host-copy blocks (20038c5c45) added WorkCounts::host_copy_blocks_readied:
a block for color host-copy images made ready off the program's thread. The case's first
host-copy texture now lands in a readied block (1); its record predates the count, so the
replay held it to 0 (round at 9bd38c7994, m3-max-7680: that case, that field alone over
bounds; 35333 counts gated within bounds otherwise). Recorded on the M3 at 12b73cfe04 (s37-pl.sh
record: the whole-set write, every other record put back, then cost --alone --write and
times over the one case). Records outside it touched: 0.

(cherry picked from commit 322a3752ecc68396fcccd92152ee05d2f53fae0d)
2026-11-08 01:30:33 -08:00
Anees Iqbal 1c4c445111 Bump RUNTIME_VERSION to 1878: every pipeline making registers the exit hook again once its driver call returns
The exit hook now runs ahead of the destructor of anything a returned pipeline making registered (a static
of the driver's compiler, or a library loaded at its first compile), and it still waits for makings in
progress. This closes the NVIDIA exit-time crash in the driver's SPIR-V compiler racing teardown.
Verified by perdraw: fork tests with a negative control on msi 7686 (43 vs 42 with the registration
removed, pass restored), and the exits lane making_exit case 10/10 on the M3 (7685, 7695: pool_busy=1,
at_makings=1, clean exits in 18-22 ms) and 10/10 on lavapipe (7686). Clippy in three cfgs and rustdoc on
7686. A 5080 entry is queued.
2026-11-08 01:30:29 -08:00
Anees Iqbal 91bedcf4a8 exits lane: making_exit says its pool's pieces and the hook's registrations as it exits
The parent prints the child's line and holds it to a registration after a making:
the evidence that the program's thread's making registered the hook again, and
whether the pool's making was still in progress at the exit (pool_busy).

Verified: cargo fmt only locally.
(cherry picked from commit 37637be4d47b303840e65c810997f582bb31b8ff)
2026-11-08 01:29:28 -08:00
Anees Iqbal 5f6bd96ec9 exits lane: bring AirLibrary into scope for making_exit's library
The msi build (m3-max-7675, 7684) failed: new_library_with_air is the lane's
AirLibrary trait's.

Verified: cargo fmt only locally.
(cherry picked from commit b03288d9c38231e2a1106d0e958d9a16b82c9198)
2026-11-08 01:29:28 -08:00
Anees Iqbal 9f01e3ce07 Register the exit hook again after every pipeline making's driver call
A consumer's 5080 run (reims-vgpu job 7350, at 0e420a1834): a runtime test printed
'test result: ok', then its process ended with SIGSEGV at 0x18 inside
libnvidia-glvkspirv.so during exit, on a thread the test's had started; alone it
passes 3/3. The hook waits for makings in sections (up to MAKING_BOUND), so the
compile it found running had lost a static of the driver's compiler to a
destructor that ran before the hook: one registered after the hook's last
registration, by a making (a static made at a compiler path's first use, or a
compiler the driver loads only at its first compile). Sections registered again
only after an entry point's first call and at powers of two, and the program's own
makings never.

Each vkCreate*Pipelines the runtime makes goes through device/compiles.rs's routed
entry points (every platform); each now calls exit_guard::pipelines_made after the
driver's call returns, which registers the hook again where it is registered in
this process and the guard is open (counted in Registrations::at_makings). So every
destructor a making that returned registered runs after the hook, which waits for
the makings in progress. A making takes milliseconds to seconds; one more entry in
the C library's exit list (32 bytes) per making is nothing beside it. The hole left:
a static first made by the making in progress as the exit begins.

Tests:
- exit_guard: a_pipeline_making_that_returned_registers_the_hook_again (a destructor
  registered inside the making runs after the hook) and
  an_exit_mid_making_waits_for_it_before_an_earlier_making_s_destructor (a forked
  child exits while a pool-style making is in progress, an earlier making's
  destructor registered; it must see the making ended). Both read 43 without the
  registration.
- exits lane: making_exit / an_exit_mid_making_is_clean: a state made on the
  program's thread, then a dispatch whose region's making goes to the pool, both of
  opcodes from the clock so the driver compiles them, and an exit at once.
- devices_made_again_register_the_exit_hook_no_more: the sections' bound check
  leaves the makings' registrations aside.

Verified: cargo fmt only locally; builds, clippy and tests are potluck jobs.
(cherry picked from commit 6368538b94a9fc607f926d2856b504e7f0c770a7)
2026-11-08 01:29:28 -08:00
Anees Iqbal 96ba9a104c The unshared-queue test bursts on until a choice withholds a join
tests::queue_share_device::no_queue_joins_an_unshared_queue_s_vk_queue_and_
one_placed_there_leaves asserts that, where the device shares VkQueues, at
least one of the choices its three other queues make after the unshared
queue's 16 bursts withheld a join from the unshared queue's VkQueue
(WorkCounts::joins_withheld_from_unshared), so that its check that no
queue landed there is not empty. A choice withholds one only while that
VkQueue is busy and its oldest batch young (queue_share.rs), which a choice
made right after a burst finds unless the host comes back late: each burst
is 24 command buffers of a 1 MiB fill, done on the RTX 5080 within some
tens of microseconds. On a development round's RTX 5080 suite partition
(dv-rt1-221823, at 7e9acd5e73) none of the 48 choices withheld one, and
the test failed at its assertion.

The test now goes on bursting past the 16, where the device shares, until
a choice withheld a join, for at most its WAIT (20 s), and prints the
bursts and the choices' counts. Nothing else changes.

Verified, RTX 5080, entry holds-holds-unshared-1-010148 (c, beside a
development lane), eight copies of the test at once for 5 min each:
- development's test with the counts printed (scratch, 16 bursts): 72 of
  72 passed; in each Adaptive leg every choice either withheld a join or
  found no other VkQueue busy (the burst seen complete before it),
  withheld 1 to 42 of the 48, the least 1 against 47 found idle: the
  choices that withhold none find the burst done, the failure's case, not
  a busy VkQueue passed over unseen.
- this change: 80 of 80 passed, each within the 16 bursts there (withheld
  3 to 44 of 48), so the longer run is taken only where a choice missed
  them all.
- its build under --cfg m2v_gpu: no warning (msi, m3-max-7629).

(cherry picked from commit 0af88b819edb4977a9a67911bfd0dbb3d9e859d3)
2026-11-08 01:16:06 -08:00
Anees Iqbal 3738986cb0 Bump RUNTIME_VERSION to 1877: in-place images take the usages their textures lack; a declaration that the bytes between rows are unobserved
selfread stack (7 commits): the in-place check imports the dma-buf class's
pages only as their dma-buf (CHECK_VERSION 8); an in-place image takes the
storage or attachment usage its texture lacks where the check passed for
what they reach, so an undeclared kernel write or render pass reaches the
texels in place with no copy; the shadow notice names in-place images;
lane rows for the guest's 3664x2039 surface at 256-byte and 16-px pitches.

selfread unobserved2: BufferDescriptor::padding_unobserved (refused with
no-copy contents, Invalid(PaddingUnobservedNoCopy)): a texture over such a
runtime-owned buffer lies in place where only the bytes between its rows
(and slices) could change; TextureShadowReason::BytesBetweenRows where it
may not; WorkCounts::unobserved_padding_aliases. For the consumer's device
cache (780M desktop surface, ~1 G texels/s of shadow copies in a drag).

Evidence for the stack (at base edde5779b1, same patches): gem10 7573
clippy cpuicd/gpucfg and rustdoc clean, lavapipe 283/285 with both failures
fixed (ed7f182441, cb4dfa3bbe); Iris 7635 in_place_textures 8/8,
IN-PLACE-USAGE in place with 0 texels copied in for kernel and pass at
1024/512-byte rows (shadows before, 7387); in place vs shadow 31.0 vs
1019.9 us (3840x2160 top 32 rows). The declaration: fmt and generators
only; build, clippy, lavapipe and the 780M lane pending (gem10 7652, M3
7653). The Iris DmaBuf class stays Unchecked (its import is refused;
separate fix).
2026-11-08 01:12:47 -08:00
Anees Iqbal b136c2531a Buffers: a declaration that the bytes between a texture's rows are unobserved
A consumer's cache buffer of the runtime's own memory (the 780M guest's 3662x2038 desktop
surface, more guest-page pieces than udmabuf takes) holds textures whose rows lie 14848 bytes
apart, 14648 bytes of texels each. linear_plan::holding shadows every such texture, since an image
at that pitch holds the bytes between rows and Vulkan lets its layout moves and a render pass's
load and store write them; the consumer's download copies each row's texels alone, so it never
reads those bytes, and the shadow's copies cost it about 1 G texels/s in a Finder drag.

BufferDescriptor::padding_unobserved (with_padding_unobserved) is the maker's declaration that
nothing reads the bytes between a texture's rows over the buffer (each row's bytes after its
texels to its pitch, the last row's included) nor between its slices. A runtime extension with
no Metal counterpart, only for the runtime's own memory: refused, Invalid
(PaddingUnobservedNoCopy), with NoCopy contents. The buffer keeps it (Buffer::padding_unobserved).

- The route (texture/route.rs) decides it for a buffer of the device's own memory:
  Route::Device { holds } carries linear_plan::holding's answer, which with the declaration
  holds rows and slices that lie apart (rows that share bytes stay refused). The making and the
  placement query share it: the query answers NotHostPages where an image may hold the texels,
  and the new TextureShadowReason::BytesBetweenRows where it may not (it answered NotHostPages
  for both before).
- aliases takes the declaration: the image's subresources may then hold the padding
  (linear_plan::within_padding: each subresource ends at its slice's last row's pitch or before,
  slices at Metal's stride), never a byte past the last row's pitch, nor memory past the
  buffer's. A byte of the image's memory past every subresource is reached by no operation on
  it, the reading texels_alone already rests on, so no new check class is needed.
- WorkCounts::unobserved_padding_aliases counts the aliasing images that hold such bytes.
- A buffer the runtime lays in fresh pages (a long one where pointer imports cost submissions
  nothing) keeps the in-place check's route: the declaration lets nothing more there (documented).

Docs: the field and builder, NotHostPages and BytesBetweenRows, HOWTO's paragraph on textures
over the runtime's own memory, API.md's shadow reasons and placement answers, the runtime
README; REFUSALS.md and api_signatures.tsv regenerated.

Tests: linear_plan's unit tests of the declared holding and aliasing (padding to the last row's
pitch held, past it or past the buffer refused, slices at Metal's stride alone, shared rows
refused); the route's placement test of both Route::Device answers; a device test
(tests/padding_unobserved.rs): a 101x48 BGRA8Unorm texture at 416, 448 and 512 bytes a row over
an undeclared buffer answers Shadow(BytesBetweenRows) and is a shadow, over a declared one answers
NotHostPages and is an aliasing image wherever the device lays one at the pitch (counted), at
least one pitch aliasing, its texels read back by a blit; and the declaration refused over the
caller's memory. The in-place lane's unobserved_padding_costs times a frame reading the
consumer's surface shape over a declared and an undeclared buffer.

Verified: pending (lavapipe and MoltenVK device tests, the 780M lane run next).
(cherry picked from commit 430523ce0e4dbd8433eb2b514f837d44ce1c5a9a)
2026-11-08 01:11:45 -08:00
Anees Iqbal 9fdf288419 In-place check test: lavapipe makes no dma-buf image of the shapes whose rows end inside lines
the_in_place_check_imports_its_dma_buf_pages_as_dma_bufs asserted the DmaBuf class's reads
answered for both row ends. On lavapipe (job 7573, llvmpipe of LLVM 23.1.4) the verdicts read
[Unchecked x4, Passed x4]: rows on lines Passed, rows inside lines Unchecked. The cause is
RuntimeDriverDefect::ExplicitPlaneRowsPastHeight: lavapipe renders an explicit
DRM_FORMAT_MOD_LINEAR plane's rows past its height, so dma_buf_image_unbound makes no such image
of a height that is no multiple of 4 (explicit_plane_rows), and every one of SHAPES whose rows
end inside lines has such a height (37, 29, 50, 17, 9, 51). The check rightly leaves the class
unchecked there; the product makes none of those images either.

The test now skips the rows-inside-lines verdict where the device has that defect, and its doc
says why.

Verified: pending (the stacked lavapipe run next).
(cherry picked from commit ed7f1824417145e6a7fe38f957fe1870e1bccee5)
2026-11-08 01:11:45 -08:00
Anees Iqbal 2194a99493 In place: count a usage set's members by its raw bits
The commit that gave in-place images the usages their descriptor lacks sorted the sets of them by
`set.bits()`, a method Metal's option sets (`metal_flags!`) do not have, so the runtime did not
build from it. The sets are sorted by how many usages each holds, most first: `as_raw()`'s bits,
counted.

Verified: the stacked checks dispatched next build it (clippy in both cfgs, rustdoc, lavapipe
tests); job 7532 at the commit before failed on this alone (E0599 at in_place_image.rs:471).

(cherry picked from commit 58aabe1d8f9cf6b5bec95bd546cfade7da468b81)
2026-11-08 01:11:45 -08:00
Anees Iqbal d9e1c2177d In place: writes_reach asks the padding's writes check again, not an unbound render flag
The commit that named in-place images in the shadow notice changed writes_reach's match to
`(texels.padding(line), renders)`, a name not bound in that function, so the runtime did not
compile from it on. writes_reach asks for a texture that does not render (its caller returns
before it for one that does), so its writes check is the padding's alone: BufferWrites where the
rows' padding is free, Writes where it is kept, as the commit before had it.

Verified: the stacked checks dispatched next build it (clippy in both cfgs, rustdoc, lavapipe
tests).

(cherry picked from commit e2edab712370a460b6c9049ae815211cd9ba7b7e)
2026-11-08 01:11:45 -08:00
Anees Iqbal c813bb74fc In-place lane: the guest's 3664x2039 surface at a 256-byte pitch and at its 16-pixel one
What: runtime_lane::in_place_textures::the_guests_surface_lies_in_place_where_its_checks_passed.
A 3664x2039 BGRA8Unorm texture over a no-copy buffer of anonymous pages, at 14848-byte rows (the
next multiple of 256, at which RADV lays linear rows) and at 14656, of ShaderRead usage, with
RenderTarget, and with ShaderWrite. Each is in place only where the device's check passed for its
access and row ends; where it passed, in place or refused by the device's image (counted in
host_texture_shadows_refused_*). A blit reads the pages' texels through it, a pass clears and
stores it, or a kernel writes every texel; the pages then hold those texels, and the bytes between
the rows and past the last hold the pattern but free padding under a shader's writes. It prints
the placement query's answer, the path, the verdict and the refusals (IN-PLACE-SURFACE).

Why: reims pads the guest's pitches to 256 bytes so that RADV (780M) takes the surface in place;
this shows our side takes it the moment the padding ships, and the 14656 case shows what RADV
refuses today.

Verified: pending (the 780M run follows the dma-buf and narrow-store work).
(cherry picked from commit e7efd8b90cfc584f3e327fbd89243f235b9a8d3e)
2026-11-08 01:11:44 -08:00
Anees Iqbal 11a1901a23 In place: the shadow notice names in-place images; the lane counts image-to-image copies
Follows the commit before, whose "WIP" line this commit's verification replaces: an in-place
image of a texture that does not render takes the usages its descriptor lacks where the device's
check passed for what they reach (the storage usage where the writes check passed, the one that
lets free padding change; the attachment usage where the renders check passed; the sampled usage
always), the first set the device makes the image with, most usages first, each at the texels'
pitch in their memory or not made. A texture that renders keeps the route's `storable`
(`texture/route.rs`), the strict writes check, as before; renders stay strict.

- The `undeclared-usage-shadow` notice's declaration and docs/API.md's entry name the in-place
  case: a shadow or stand-in where the device's check failed for what the usage lets reach the
  pages, none where it passed.
- `fresh_pages_take`'s docs point at the route's `storable`.
- The lane counts a shadow's copies from an image too (`shadow_texels_copied_in_images`), which
  is how the usage shadow of an image in place copies, and prints the count on either path.
- The module docs split the declared usage, the lacking usages and a render target's usages
  into their own entries.

Verified: pending (clippy, rustdoc, the runtime's unit tests, lavapipe and Iris lanes run next).
(cherry picked from commit 11d16a1b92cfdca3c409ff2f0501a67f0c1b607c)
2026-11-08 01:11:44 -08:00
Anees Iqbal 16428e987f In place: an image takes the usages its texture lacks where the check passed for what they reach
WIP: verification pending.
(cherry picked from commit fb640a0ba6a1670b09573446f122e518556193ec)
2026-11-08 01:11:44 -08:00
Anees Iqbal b4fd8c9210 In-place check: import the dma-buf class's pages only as their dma-buf
What: HostMemory::dma_buf_only (crate-internal) has a no-copy import skip the pointer and take
the source's dma-bufs (buffer_descriptor.rs's host_window: by_pointer false). The check's
dma-buf pages, an allocation of the device's own exported as a dma-buf and mapped, take it.
CHECK_VERSION 8, so a record holding the old unchecked dma-buf verdicts is not read.

Why: a texture over host pages imported as dma-bufs asks the dma-buf class's verdicts. The
check made that class's pages as a no-copy buffer with a source of their dma-buf and kept the
class only where the buffer lay over the dma-buf; a no-copy import asks the pointer first, so a
driver that takes the pointer of its own mapped allocation (ANV on the Iris Xe) put the buffer
over the pointer and left the class unchecked, recorded. The guest's buffers on the Iris are
dma-buf class (a guest RAM imports its chunks as dma-bufs first where held pointer imports tax
every submission, host_ram.rs), so each of its textures over them asked the unchecked verdict and
was a shadow: reims counted 756 and 786 such shadows (host_texture_shadows_unchecked) in a guest
session of each mode on the Iris, the second-largest cause there.

Test: tests::in_place_check::the_in_place_check_imports_its_dma_buf_pages_as_dma_bufs (Linux
device tests): the dma-buf-only import lies over the dma-buf where the pointer-first import of
the same kind of pages is printed for contrast; the check's dma-buf reads are never unchecked;
a 234x18 BGRA8Unorm texture at 1024-byte rows over such pages (the guest's shape) is in place
exactly where the class's reads verdict for its row ends passed. It prints the verdicts.

Verified: pending (the Iris run follows).
(cherry picked from commit 3709d06189144f0981ed7a93c6fa51332357bfd3)
2026-11-08 01:11:44 -08:00
Anees Iqbal 9316c1aa3f Re-bless the authored compile census at 9bd38c7994
Its product fingerprint follows development's versions at 9bd38c7994. Blessed on the
M3 (s37-pl.sh censusbless --bless, dv-m3).

(cherry picked from commit 12b73cfe04148857024ac8c953cccab4f9094b3a)
2026-11-08 01:10:24 -08:00
Anees Iqbal 9bd38c7994 Bump RUNTIME_VERSION to 1876: the queue-switch check's round holds its queues through its gate's signal
holds: the 5080's device_recovery hang was a deadlock between the
queue-switch check and a drain (Device::drain_queues, under the queue's
lock, in vkQueueWaitIdle). The check's round submitted two batches waiting
on a gate as two separate uses of the queue, and signalled the gate only
after the second. A drain taken between the two uses waited for batch 1,
batch 1 for the gate, and the second submission for the drain's lock. A
round now takes its VkQueues' locks in index order before its first
submission and lets them go after the gate's signal, so every submission
on a free queue completes without host work.

Evidence (holds, RTX 5080, entry recovery-fix-1): negative control (each
submission its own use again) hung 2 of 2, the stacks showing the drain in
vkQueueWaitIdle under SlotHold::with and the check thread blocked in
QueueSlot::hold at the round's second submission; with the fix the new
test a_drain_beside_the_queue_switch_check_s_round_completes passed 60/60
(4 at once), and the 6 device_recovery tests, 4 copies at once, 216 runs,
no hang (a_loss_holds_the_hang_s_queue_until_the_recovery and
work_that_completed_before_a_failed_wait_completes 36/36 each; the race
test failed only on its pre-edde5779b1 base). The natural hang reproduced
in round 7e9acd5e73's 5080 part rt2 (a_loss_holds..., 943 s). M3 7419:
101/101 across relay, recovery, queue-share, teardown and submit-check
tests. The check runs on neither lavapipe nor MoltenVK. Pending: lint at
this commit (development's leg).
2026-11-08 00:59:11 -08:00
Anees Iqbal 47174c4775 Hold the queue-switch check's round's queues through its gate's signal
The queue-switch check (queue_switch_check.rs) submits each round's two
batches, each waiting for a gate timeline, then signals the gate from the
host. Each submission was a use of its queue of its own, so between the two
the queue's lock was free while the first batch waited there for the gate.
A wait for a queue to idle under its lock taken in that window never ended:
Device::drain_queues (a completion turn's, after a failed wait, and a
recovery's) or a submission check's idle after a refused call waited for
the first batch, which waited for the gate, which the check signals only
after its second submission, which waited for that lock. In a control round
(both batches on one VkQueue) that is the whole cycle; in an alternation
round the same follows where the other queue's pending work waits for work
behind the gated batch. The check runs on each device made with a cache
holding no verdict, at its first command queue, so beside the device tests'
marked losses, whose devices are not lost and whose queue waits wait for
the work: tests::device_recovery::work_that_completed_before_a_failed_wait_
completes hung on the RTX 5080 (more than 960 s), and
a_loss_holds_the_hang_s_queue_until_the_recovery hung there 2 of 9 runs,
and again for 943 s in a development round. lavapipe has one VkQueue, and
MoltenVK four families of one VkQueue each: no two VkQueues of one family,
so neither runs it.

A round now takes the lock of each of its VkQueues, in index order, before
its first submission and lets them go once it signalled the gate
(QueueUses::use_queues_kept, new, and its Together, through which each
submission is made as QueueUses::use_queue_kept makes it; QueueSlot::with
and with_counted now go through a SlotHold, the lock held, which the
use of several queues holds for each). No other thread takes one of the
round's queues while a batch there waits for the gate, so every submission
on a VkQueue whose lock is free completes with no more work of the host's.
The module docs of queue_switch_check.rs and Device::drain_queues' doc say
so. The device's loader word is still taken inside a queue's lock.

Test: tests::device_recovery::a_drain_beside_the_queue_switch_check_s_
round_completes holds the check between the two submissions of a round on
one VkQueue (a test-only hold, QueueSwitch::between), starts a drain on
another thread, lets the check go 200 ms later and asks the drain to
complete within 60 s. It skips a device that runs no check.

Verified (potluck jobs and RTX 5080 entries, the change built off
development a8239b35cb; rebased here onto 233275b457 with no conflict):
- The negative control (scratch commit 64dea87e34: each of the round's
  submissions its own use again, the test's hold kept), RTX 5080, entry
  holds-holds-recovery-fix-1-233656: the new test hung 2 of 2 runs; each
  thread's stack at 30 s shows the drain's thread in vkQueueWaitIdle
  (Device::drain_queues, under the queue's lock) and the check's thread
  blocked on that queue's lock in its second submission
  (queue_switch_check.rs, QueueUses::use_queue_kept).
- The change, RTX 5080, the same entry: the new test 60 of 60 runs, four at
  once (3.3 to 4.5 s each); then the six device_recovery tests, four copies
  of each at once, nine rounds, 216 runs, no hang (180 s bound per run):
  a_loss_holds_the_hang_s_queue_until_the_recovery and
  work_that_completed_before_a_failed_wait_completes 36 of 36 each. 27 of 36
  runs of each_recovery_announces_its_own_wait failed with
  MadeBeforeRecovery, the race development fixed apart (ab8651ae38, not in
  that build's base). Under 24 processes at once each run took 34 to 67 s.
- Apple M3 Max (MoltenVK, the relayed queues' marks through the new
  SlotHold path), m3-max-7419: the runtime's relay_facts, device_recovery,
  queue_share, teardown_threads, submit_check, submit_stalls, loader_word
  and exit_guard tests, 101 of 101; the new test skips there (m3-max-7433:
  "the device runs no queue-switch check").
- Plain clippy (all targets, all features), m3-max-7382: clean.
- Not run before this commit: the change rebased here (its build and
  clippy run as a job of their own, reported with the tip), and the timing
  of the program's submissions beside the check's rounds, queued as a
  timing entry.

(cherry picked from commit 254ce9c116f1ced2206dd5c4b63f13e8eabb1c0d)
2026-11-08 00:58:20 -08:00
Anees Iqbal 233275b457 tiled_texture_device: the copied-in count's multiple through is_multiple_of
The re-check of 3cb10fe276 (um790 m3-max-7583) found a third
manual_is_multiple_of in the same device test (line 276) that the first
lint run's output had not reached.
2026-11-08 00:45:34 -08:00
Anees Iqbal 3cb10fe276 tiled_texture_device: is_multiple_of and no usize-to-usize cast (clippy under the device cfgs)
Development's lint leg at 95b0042865 (um790 m3-max-7568) failed clippy
--cfg m2v_gpu and --cfg m2v_cpu_icd on two lints in the new device test,
which compiles only under those cfgs: manual_is_multiple_of in checker()
and unnecessary_cast in samples(). Plain clippy, fmt and rustdoc passed.
2026-11-08 00:44:06 -08:00
Anees Iqbal 95b0042865 Bump RUNTIME_VERSION to 1875: a tiled texture of more than one level over a buffer's bytes
inplace: Buffer::new_tiled_texture for Metal's private
newTiledTextureWithDescriptor:offset:bytesPerRow: (the x86 guests'
WindowServer asks it for 54x54 BGRA8 of 6 levels under the x86 Macs'
featureProfile). One level is new_texture's texture. More levels: one image
of every level, level 0 a shadow of the buffer's bytes kept in step at
command boundaries (Route::Levels, Shadow(Mipmapped { levels }), the
shadowed-texture notice naming the levels); levels 1+ are the image's own,
blit sources and destinations and mipmap targets. Buffer::
tiled_texture_placement answers it.

Evidence (inplace, M3 7543): 178/178 across tiled_texture, placement,
linear_plan, buffer_texture, blit, shadow and mipmap tests; the six new
device tests at 54x54/6 and 64x60/7 levels over a 16 KiB Shared buffer at
bpr 256 (CPU writes reach level 0, level-0 blits reach the buffer's rows
with padding untouched, generate_mipmaps fills level 1, levels 1+ round
trip, one level in place, one notice). Negative control 7547 (blits on the
bytes at every level): 3 of 6 fail. Pending: lavapipe, lint in 3 cfgs and
the 780M run (gem10 7546).
2026-11-08 00:40:06 -08:00
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