Commit Graph
4370 Commits
Author SHA1 Message Date
Anees Iqbal 27bca2eeab draw_costs: a pass step's arm answers as the other steps' do 2026-11-12 01:55:19 -08:00
Anees Iqbal e74e1b70d9 draw_costs: the consumer's compositor frame as a shape, shadow lines on stderr
The consumer's per-draw table on the Radeon 780M measures a window compositor's command
buffer: five passes that load a layer's surface and draw 4 quads each, then a pass that clears
a 3840x2400 framebuffer surface and draws 15, every surface a texture over its own buffer's
IOSurface plane. Its draws cost about 12 us each and its pass ends about 39 us on that host,
against draw_costs's 1.9 us: its surfaces are shadows. draw_costs had no shape of it.

- compositor: 8 command buffers of that frame (6 passes, 35 draws, 21 indexed), each pass
  opened with set_viewport, each draw setting a pipeline state where its kind changes (plain,
  masked, backdrop; blended), two vertex buffers and a fragment buffer at moving slots of one
  no-copy buffer over host pages, one or two fragment textures (a backdrop draw reads its own
  pass's color attachment at the fragment's pixel), a sampler and a scissor rectangle. Surfaces
  over Private buffers, or with --pages over host pages.
- Steps: a Pass step opens a compositor pass (a command buffer of other steps opens the
  bench's one pass as before); fragment textures take an index; indexed draws; the calls
  set_viewport and draw_indexed_primitives counted apart with --calls.
- With METAL2VULKAN_LOG_SHADOWS=1 the sink prints the shadow log's lines and each degrade
  notice's text on stderr.
- draw_costs.metal: the compositor's quad functions, written for this example.

Verified: the build and the 780M run follow in the next jobs (the metallib is compiled on the
M3 Max).
2026-11-12 01:55:19 -08:00
Anees Iqbal 54c2f82432 Revert the pass-end tile count's sweep: count_colors and covered_tiles are 0.4% at this pin
reims's 780M encode-thread profile (m3-max-19824, cache mode) puts count_colors and DrawnArea::covered_tiles at 0.4% of the encoding thread together, so the sweep (e5f571166b) is not worth its code. On draw_costs damage --shadowed (500 rectangles a pass) it took 17,659 instructions a draw to 17,210 on the 780M (m3-max-19827); no shape the consumer runs has such passes.
2026-11-12 01:55:19 -08:00
Anees Iqbal d4d66d3f74 Pass-end tile count: one sweep down the rows, each rectangle looked at once
DrawnArea::covered_tiles (WorkCounts::shadow_attachment_tiles_covered, counted at each pass
end for a shadowed color loaded within its draws' scissors) walked every rectangle for every
band of tile rows between two rectangle edges: O(bands x rectangles), up to 2047 x 1024 at
MOST_RECTS, about 34 x N on a 1080p pass of N damaged rectangles. reims's 780M encode-thread
profile put count_colors / covered_tiles at ~6.4%.

Now each rectangle's tile columns enter a sweep at its first row of tiles and leave past its
last; a count per column of the rectangles reaching it and the number of columns any reaches
give each band's tiles at once: O(N log N + the rectangles' widths in tiles). The answer is
the same count (the existing brute-force comparison over 200 random sets holds it).

Test: clear_reach::tests::covered_tiles_look_at_each_rectangle_once counts the rectangles a
count looks at (made::LOOKED): 1024 one-tile rectangles in 1024 rows of tiles, and 1024
overlapping ones checked tile by tile, each looked at once.
2026-11-12 01:55:19 -08:00
Anees Iqbal 99c40c6e28 draw_costs: a damage shape and a shadowed, loaded target
A guest's compositor pass loads its window surface, a texture over guest pages, and draws
inside damaged rectangles, so the pass's end plans a shadow's copy back and counts its tiles
against its draws' scissor rectangles (count_colors, DrawnArea::covered_tiles). draw_costs
had neither: its target is a cleared Private texture and its clips shape takes two
rectangles.

- damage: as clips, each draw after a scissor rectangle of its own, the next cell of a
  25 x 20 grid of 20x25 pixels (500 rectangles a pass).
- --shadowed: the target is a texture over a no-copy buffer of host pages at its packed
  rows, loaded, the device opened with HostPageTexturePolicy::Shadow so it is a shadow on
  every device.
- The host-page mapping is one helper (host_pages) for the chunks and the target.

Verified: built in the next commit's job; the before/after numbers are in its message.
2026-11-12 01:55:19 -08:00
Anees Iqbal 77d3f928cf Re-pin the runtime sources at the landing tip
The landed packet changed a runtime-sources input, so the committed digest no

longer described the sources and `the_runtime_sources_are_the_committed_ones`

would fail. Recomputed over the same inputs and committed by land-pkt.sh.
2026-11-12 01:53:49 -08:00
Anees Iqbal cf4d8017f2 FAST-PATHS: the heap answer row's measured counts and bytes
heap_texture_images at 4c6ffc7567 (code identical to this tip), under each HeapAnswerPolicy:
of the 22 compositor shapes, on ANV (Iris Xe, m3-max-20000) 14 lie in an image put in place of
their first one and 7 are shadows in Metal's tiles under Metal, none of either under Device, the
answers 3769962 bytes against Metal's 3656426; on the RX 7900 XTX (m3-max-20001) 1 and 8 under
Metal, none under Device, 4155498 bytes. heap_compression_costs on ANV under the default
(m3-max-20014): the 2048x2048 render target still takes the linear image under both compression
values (clear 955.3 and 971.4 us), so the HeapCompression row now says so.

Verified: the jobs named; docs only here.
2026-11-12 01:52:37 -08:00
Anees Iqbal b63d1553e9 Docs: Device::heap_texture_size_and_align names its answer under each HeapAnswerPolicy
The public query's doc said it answered Metal's numbers wherever the runtime models them; under
the default HeapAnswerPolicy::Device a texture whose image needs more answers the larger of the
two within the bounds.

Verified: cargo fmt only; a doc comment.
2026-11-12 01:52:37 -08:00
Anees Iqbal 5b5362124c FAST-PATHS: the heap-shadow cost entry is HeapAnswerPolicy::Metal's
Under the default HeapAnswerPolicy::Device a heap texture Metal keeps uncompressed lies in its
device's image wherever its alignment is within the answer's bounds, so the entry's shadow and its
ANV figures describe the switch, and a texture past the bounds whose 4 KiB image does not fit.

Verified: docs only.
2026-11-12 01:52:37 -08:00
Anees Iqbal 20a186a87e Docs: a heap texture's answer under each HeapAnswerPolicy
The heap module's size-and-alignment bullet, the heap-texture-larger-than-metal declaration and
its catalogue entry, docs/API.md's heaps-and-memory bullet (which said every answer was the
device's image's, where the code answered Metal's model) and WorkCounts::heap_textures_refit now
say what each policy value answers: under Device the larger of Metal's answer and the route's
image within the 64 KiB and 4 KiB-or-size bounds, the 4 KiB image in its place past them; under
Metal, Metal's answer held by a refit or a shadow.

Verified: cargo fmt only; docs alone, no code moved.
2026-11-12 01:52:37 -08:00
Anees Iqbal d8b584a939 RUNTIME_VERSION 2097: a heap texture answers its device's image where that needs more than Metal's answer
Add DevicePolicy::heap_answers, HeapAnswerPolicy::{Device (the default), Metal (in
exact_answers)}. Under Device, a single-sample heap texture whose image binds into the heap's
memory and needs more bytes or a coarser alignment than Metal's modelled answer answers the
larger of Metal's answer and that image's (heap_extent), and lies in that image: no refit to an
image that fits Metal's answer and no shadow of Metal's tiles. A Shared texture's answer also
holds the linear image a heap over host pages binds for it (host_route_extent), so a heap over
guest pages places it too. The answer's alignment is taken only up to 64 KiB (the largest a Mac
answers: an AMD Radeon Pro 5300M) and up to the larger of 4 KiB and its own size, so padding
before a texture stays at most a page or its own bytes. Where the first route's alignment is
coarser than that (ANV's compressed image of a small texture: 64 KiB for 16 KiB), the image a
4 KiB alignment holds (host-transfer usage, else linear: fitting_heap_image with no tiles) lies
there in its place and the answer is that image's, before any shadow. Metal's measured answers
(4:2:2, one-plane YCbCr, two-plane, X32_Stencil8, BlockWritesOnly), multisample textures and
textures whose image lies in memory of its own keep Metal's answer. Metal keeps today's
behaviour exactly.

Why: Metal's 128-byte model made every non-MoltenVK device refit or shadow its heap textures.
Measured with heap_shadow_costs::heap_texture_images, 0 of a guest compositor's 22 heap shapes
fit Metal's answer on ANV (Iris Xe, every optimal image at 65536), on the RTX 3090 (1024) and on
the RX 7900 XTX (256 to 65536). The shadow costs a frame that clears and blits a 1x1 array 34.7
us against 8.2 us outside a heap (ANV). The ledger gets the row; the HeapCompression row notes
that its compressed figure needs the device's answer.

heap_texture_images now runs under both values, makes each shape in a heap and prints a
HEAP-COUNT line (refits, tiled shadows, answer bytes against Metal's).

Verified: cargo fmt only, here; the build, clippy and tests run as potluck jobs after this commit.
2026-11-12 01:52:36 -08:00
Anees Iqbal ad01568553 Re-pin the runtime sources at the landing tip
The landed packet changed a runtime-sources input, so the committed digest no

longer described the sources and `the_runtime_sources_are_the_committed_ones`

would fail. Recomputed over the same inputs and committed by land-pkt.sh.
2026-11-12 01:52:07 -08:00
Anees Iqbal 3be4e7669f RUNTIME_VERSION 2096: a texture over pooled memory is in place at any size; the LinearCost bound is gone
The commits before this one. A tracked texture over a Private buffer in pooled memory larger than
POOLED_PITCHED_BYTES (48 KiB) was a shadow by a speed bound measured on Iris alone (ShadowCause::LinearCost):
a linear image judged slower to sample than an optimal shadow plus its copies. The owner's rule (11-12):
shadows are a fallback, never a first option. Such a texture now takes its DRM_FORMAT_MOD_LINEAR image at
Metal's pitch at any size wherever the device makes one and the pooled check passed; it is a shadow only for
a cause the device has (Refused, CheckFailed, Unchecked, a pending check, or the Shadow policy). Removed:
POOLED_PITCHED_BYTES, ShadowCause::LinearCost and the public TextureShadowReason::LinearCost (api_signatures:
one variant fewer), and the code only the bound used (texture_spans.rs and its moves, Texels::
only_commands_write, the bound's cost benches). API.md, HOWTO.md and the FAST-PATHS in-place row say "at any
size". On every device.

Measured, Radeon 780M (RADV PHOENIX), a 3840x2400 BGRA8 RT|ShaderRead texture at 15616-byte rows (37 MB)
over a Private buffer, per frame (upload, read through the texture, clear pass, read back): with the bound
(m3-max-19924) a LinearCost shadow, 9,216,000 texels copied back each frame; without it (m3-max-19966,
20011) in place, 0 copied in or back.

Test: tests::padding_unobserved::a_large_texture_over_a_private_buffer_is_in_place_where_the_device_makes_it_and_reads_right
(780M 20011, lavapipe 20007: in place, 0 copies, texels right). Touched tests on lavapipe (19928), api
tables 15/15 (19963), lint three ways and rustdoc (19922, 20006).
2026-11-12 01:51:07 -08:00
Anees Iqbal e45394cb76 padding_unobserved: the large texture is a shadow only for a cause the device has
On lavapipe (m3-max-19963) its first three rows were no control either: llvmpipe answered
Shadow(Refused(Pitch)) for 3840x3 at 15616 while the 37 MB texture took its DRM_FORMAT_MOD_LINEAR
image in place (pitched 1, no shadow texel copied in two frames). A smaller shape is no oracle of
what the driver makes. The test now asserts the answer itself: in place with no shadow texel
copied, or a shadow whose cause is the device's (Refused, CheckFailed, Unchecked), never another
reason; under the old bound the 780M's Shadow(LinearCost) fails it.
2026-11-12 01:50:58 -08:00
Anees Iqbal 9a7779de13 padding_unobserved: the large texture's control is its first three rows, not one
On lavapipe (m3-max-19928) the one-row control answered Shadow(Refused(Pitch)) while the 37 MB
texture took its DRM_FORMAT_MOD_LINEAR image in place (pitched 1, no shadow texel copied), so
the equality failed for the control's sake: llvmpipe makes no image of a single row at a padded
pitch. Three rows (46,848 bytes, under the old bound too) are the control the pitched-image test
already uses (3662x3 at 14656).
2026-11-12 01:50:58 -08:00
Anees Iqbal ee9e1140b1 API.md: a texture's size never makes a texture over the runtime's own memory a shadow
The clause the bound's removal left read as a trailing participle; it now states the rule.
2026-11-12 01:50:58 -08:00
Anees Iqbal 0d144ec0de Pooled memory: no bound on a texture's bytes; ShadowCause::LinearCost is gone
The owner, through reims: zero copy, in place where possible, shadow copies a fallback and never
a first option. A tracked texture over a Private buffer of the runtime's pooled memory whose rows
the device's own linear image lays out otherwise was a shadow past 48 KiB to its pitch
(TextureShadowReason::LinearCost), a speed choice measured on an Iris Xe alone that shadowed 1001
of an RTX 2080 guest boot's 1366 textures. It now takes its DRM_FORMAT_MOD_LINEAR image at Metal's
pitch at any size, wherever the device makes one and its check of the pooled memory passed, as a
texture over a Shared buffer already did; it is a shadow only where the device makes no such
image (its format, usage, pitch or limits), its policy is HostPageTexturePolicy::Shadow, or the
check failed or is pending (a pending one still moves in place once it passes).

Removed with the bound: in_place::POOLED_PITCHED_BYTES, ShadowCause::LinearCost and the public
TextureShadowReason::LinearCost (a breaking change of metal2vulkan-runtime's surface:
api_signatures.tsv loses its variant), texture_spans.rs (the runs of bytes textures were made
over, which only the bound read) and the moves it fed (MoveAfter::Aliases, LoneShadow, the
buffer's note and wait), Texels::only_commands_write (the bound's alone), the bench behind the
bound (runtime_lane::pooled_draw_costs, its crossover additions included) and
aliased_surfaces' cost bench. aliased_surfaces' first check now asserts every texture over one
surface's bytes takes the image at Metal's pitch, the first included, and a read copies nothing;
its one-after-another check, about the first texture's shadow, is gone. storage_over_buffer is
one function again (REFUSALS.md regenerated for the name). API.md, HOWTO.md, FAST-PATHS.md (the
in-place row) say "at any size".

RUNTIME_VERSION is not bumped here: the landing bumps it and re-pins the runtime sources.
2026-11-12 01:50:58 -08:00
Anees Iqbal 20d84ebf33 Pooled memory: a test that a 3840x2400 texture over a Private buffer lies as its first row does
a_large_texture_over_a_private_buffer_lies_as_its_one_row_does_and_reads_right replaces the
pooled bound's test. A compositor's texture, 3840x2400 BGRA8Unorm that renders and samples at
rows of 15,616 bytes (37 MB) over a tracked Private buffer that declares its padding unobserved,
must take the placement its first row alone takes at the same pitch: the DRM_FORMAT_MOD_LINEAR
image in place wherever the device makes one, whatever the texture's bytes. Two frames each
upload texels into the buffer, read them through the texture, clear it through a pass and read
the buffer back; it prints the shadow texels copied in and back a frame (LARGE-POOLED) and, in
place, asserts none. With the 48 KiB bound still in the runtime it fails (the texture answers
Shadow(LinearCost), its row NotHostPages): the next commit removes the bound.
2026-11-12 01:50:58 -08:00
Anees Iqbal 0910ffd92e Validation lane: a guest's shadows of their linear cost, alone and beside another texture (pooled_guest_set)
The 15 shapes of a guest boot's 1001 LinearCost shadows on an RTX 2080 (textures over Private
buffers that declare their padding unobserved), each weighed by how many it made: where the
placement query puts each alone over its bytes (the pooled bound read) and beside a one-row
texture made over them first (the image at Metal's pitch at any size where the device makes it).
Report only, ignored, run by name.
2026-11-12 01:50:57 -08:00
Anees Iqbal 5b228b1309 Validation lane: the pooled bound's crossover per device (pooled_crossover_costs)
One texture over a Private buffer, BGRA8Unorm and RGBA16Float, 16 KiB to 4 MiB to its pitch and
the guest's 723x625 shape, in place at its pitch (a one-row texture made over the bytes first, so
the measured one takes the DRM_FORMAT_MOD_LINEAR image at any size) against a shadow, each frame
a compositor-like draw that samples it whole, the texture changing every frame or every 60th by a
render pass or by a blit into its buffer. Report only, ignored, run by name in release: the
numbers decide the bound on each device.
2026-11-12 01:50:57 -08:00
Anees Iqbal 2afea6eb77 Re-pin the runtime sources at the landing tip
The landed packet changed a runtime-sources input, so the committed digest no

longer described the sources and `the_runtime_sources_are_the_committed_ones`

would fail. Recomputed over the same inputs and committed by land-pkt.sh.
2026-11-12 01:35:27 -08:00
Anees Iqbal 28be5e8adc RUNTIME_VERSION 2095: a shadow's move in place counts in the views epoch, so no bind pushes its freed views
The commits before this one. A texture over host pages made before its in-place verdicts is a shadow;
when the verdicts pass, Prepared::move_in moves it in place and ShadowAfterMove frees the shadow's image
and views once the committing command buffer completes. The move did not bump DeviceShared::views_epoch,
so the render encoders' bind memo (kept on the device, views keyed by texture address) still held the
shadow's view, and a later encoder's bind pushed a freed VkImageView. move_in now calls views_go on the
shadow, under its views lock, before the flag that lets the shadow be freed; the pooled-memory moves take
the same path. On every device.

Found by reims's per-draw repro in pages mode: SIGSEGV on the RTX 3090 about 70 s in (the original core:
the pushed combined image sampler's view was freed memory, its sampler intact; gdb m3-max-19818, 19829).

Test: tests::first_host_texture::a_surface_moved_in_place_is_drawn_through_its_image_once_its_shadow_went,
RTX 3090 (m3-max-19897): without the fix the later draw worked out 0 views and read wrong rows; with it
1 view, the new texels, pass. lavapipe (m3-max-19891) 29/29 of the touched files; lint three ways
(m3-max-19908, 19909).
2026-11-12 01:34:26 -08:00
Anees Iqbal e26d12b544 A shadow's move in place counts in the views epoch, so no bind names its views after they went
A texture over host pages made before its pages' in-place verdicts is a shadow;
once they pass, a commit moves it in place (TextureShared::moved) and the shadow's
VkImage, views and memory go when that command buffer completes
(ShadowAfterMove). Render encoders' bind memo (binding::BindMemo) keeps each
texture slot's VkImageView by the texture's address, current while the device's
views epoch holds; the move changed the image the texture presents without
moving the epoch. A later encoder's draw then took the shadow's view from the
memo and pushed it after it was destroyed: on the RTX 3090 (NVIDIA 620.70.06) a
consumer's per-draw run with surfaces over host pages died with SIGSEGV in
vkCmdPushDescriptorSet (push_set <- Recording::record <- draw_resident; the
pushed combined image sampler's view object was freed memory). Before the
shadow went, the same draw read the shadow instead of the image in place.

The move now counts as the shadow letting its views go, under the shadow's
views lock, before the flag that lets ShadowAfterMove free it: every kept view
is dropped at the next bind, which works out the view of the image in place.
The pooled-memory moves take the same path. Docs of the epoch, the memo, the
counter and the storage-form module say so.

Verified: cargo fmt; the device runs are in the report.
2026-11-12 01:34:17 -08:00
Anees Iqbal 3bc7cb60a9 Test a surface over host pages drawn after its move in place, once its shadow went
A ShaderRead BGRA8 surface of tight rows over a no-copy buffer, made on a new
device before its in-place verdict, is drawn through its shadow; once the check
settles, the next commit moves it in place and its shadow's image and views go
when that command buffer completes. A later render encoder starts from the bind
memo the first encoder left its device: its draw must work out the texture's
view again (bind_views_worked_out) and read the texels the CPU wrote into the
pages after the move. Without a fix the memo hands it the shadow's view, which
was destroyed: on NVIDIA 620.70.06 (RTX 3090) vkCmdPushDescriptorSet faults on
it, as a consumer's per-draw run over host pages did (SIGSEGV in push_set,
binding 3, a combined image sampler whose VkImageView object was freed).

The draw and the blit helpers are shared with the odd-width test, which reads
as before.

Verified: cargo fmt; device runs follow in the fix's commit.
2026-11-12 01:34:17 -08:00
Anees Iqbal 2c8a34a79e Test: recorded_at_the_call counts fills once the device's queue-switch check ended
What: a_fill_is_recorded_at_its_call waits for the device's queue-switch check
(settle_queue_switch_check, 120 s) after making its command queue and before it counts, as the
other tests that read commands_recorded do (fill_waits, fill_queue, draw_again).

Why: the test's expectation went stale at RUNTIME_VERSION 2089 (24f233db8b). The check's rounds
now open their gate on the GPU with a vkCmdFillBuffer of the check's scratch buffer, recorded on
the check's thread, and WorkCounts::commands_recorded counts every command of the device whatever
the thread (its contract). The test counts all of the device's fills, so a check whose opening was
recorded between the test's fill and its commit read as "the fill recorded again": the RTX 5080's
runtime suite at pin 45 (m3-max-19738) saw 1 at the call and 2 after the commit.

Verified on the RTX 5080 Laptop GPU (NVIDIA 615.71.09), b5080 batch m3-max-19866, with a scratch
probe that counts the device's fills from before its first command queue until its check settled,
the program recording none: 0 at pin 44 (bf442ceb9e + the probe) and 1 at development 9768c1b352
(+ the probe), the check's verdict Idles at both. In that batch this commit's test passed (fills 1
at the call, 1 after the commit). The failure itself needs the check's recording to land inside
the test's window (it did under the suite's load); the unsettled test passed alone in the batch,
as it did in the other devices' suites.
2026-11-12 01:32:26 -08:00
Anees Iqbal ec8991b130 Re-pin the runtime sources at the landing tip
The landed packet changed a runtime-sources input, so the committed digest no

longer described the sources and `the_runtime_sources_are_the_committed_ones`

would fail. Recomputed over the same inputs and committed by land-pkt.sh.
2026-11-12 01:14:20 -08:00
Anees Iqbal fbef0a0948 Docs: the copied buffers' 7840HS and pass figures are of comparisons on four threads
The ledger's copied-buffer rows (FAST-PATHS) and copied.rs's Cost bullet quote
the copied_bench and copied_pass_bench figures measured while a comparison ran
on up to four threads; it now runs on up to eight, so they say so, in the past
tense, rather than read as the eight-thread cost. The two FAST-PATHS rows are
rewrapped to 100 columns (one line ran to 130).

No behaviour change; no figure is new.
2026-11-12 01:13:40 -08:00
Anees Iqbal 9768c1b352 Re-pin the runtime sources at the landing tip
The landed packet changed a runtime-sources input, so the committed digest no

longer described the sources and `the_runtime_sources_are_the_committed_ones`

would fail. Recomputed over the same inputs and committed by land-pkt.sh.
2026-11-12 01:12:19 -08:00
Anees Iqbal cd8a3600c1 RUNTIME_VERSION 2094: a batch waits for other queues' first work only where its commands or its own first work may reach that memory
The commits before this one. A batch on another VkQueue waited on the GPU for every batch that did new
resources' first work (image first moves, staged texel copies, fills at a batch's start) until it
completed. Each such batch is now kept with what owns the memory its work wrote, and a batch waits for
it only where its commands may reach that memory (its uses name it or make it resident; a command
reaches unnamed memory, the root table or work recorded on the GPU alone; or the owner is unknown, the
device's own resources) or where the first work it took lies in that memory. Internal submissions still
wait for every one. On every device. Counted: WorkCounts::first_work_waits and first_work_waits_unused
(the conformance cost SUBMISSION group lists first_work_waits).

Measured, RTX 3090, release, one run (m3-max-19766), a compositor's frame p50 beside an app on another
queue:
- app making two 1024x1024 Private textures per command buffer: 17.07 -> 2.06 ms (2.10 with nothing
  made); waits on unused first work per 4 s 247 -> 0;
- making buffers and textures: 12.07 -> 2.00 ms;
- a device with no fill queue: buffers 16.51 -> 2.12 ms (unused 231 -> 0), textures 17.07 -> 2.06 ms.

Test: tests::fill_waits::a_batch_that_reaches_no_new_texture_waits_for_none_of_its_first_work saw 16
unused waits before (fail), 0 after. The zero-read test now holds a heap texture and a plain Private
texture whose moves are taken behind a long load on another queue: both read what was written. 23/23
zeroed_start / fill_queue / first_move tests on the 3090 (19766), lavapipe 26/26 touched (19767), lint
19732. Not run: the 5080, RADV, Intel, MoltenVK.
2026-11-12 01:11:24 -08:00
Anees Iqbal 49e4ec15f4 First moves' docs: the narrowed waits for other queues' first work, as the RTX 3090 measured them
Job m3-max-19766, one before/after on the RTX 3090 (before: c76b6d619a's code, every batch waiting for all of it; after: 22064bea33). tests::fill_waits_bench, the compositor's frame p50: app making textures 17.07 -> 2.06 ms (247 -> 0 unused waits in 4 s), buffers and textures 12.07 -> 2.00 ms; on the device made with no fill queue, buffers 16.51 -> 2.12 ms (231 -> 0), textures 17.07 -> 2.06 ms. tests::fill_waits::a_batch_that_reaches_no_new_texture_waits_for_none_of_its_first_work: 16 unused waits before (fails), 0 after (passes); zeroed_start, fill_queue, first_moves and first_move: 23/23 after.
2026-11-12 01:11:15 -08:00
Anees Iqbal 5cf984c6d1 Test fill_waits: the texture blit helper is write_and_read, apart from the pointer test's command buffer
Named through, it was shadowed by the zero-reach test's local command buffer of that name (E0618 under --cfg m2v_gpu, job m3-max-19719).
2026-11-12 01:11:15 -08:00
Anees Iqbal 8c4cbbfa9e Other queues' first work: a batch waits for that of memory its commands or its own first work may reach
A batch on another VkQueue waited on the GPU for every batch that did new resources' first work until it completed, whatever it used: on the RTX 3090 a compositor's one-dispatch frame took 17 ms (p50) beside an app making two 1024x1024 Private textures per command buffer, against 2.1 ms with nothing made (tests::fill_waits_bench, job m3-max-19457), and so for new buffers' fills at a batch's start on a device without a fill queue. Now it waits for those whose work wrote memory its encoders' uses name or make resident, every one where a command may reach memory no use names or where the work's owner is unknown, and those whose memory its own first work lies in, which comes after theirs. Internal submissions still wait for every one. Evidence to follow in the next commits' jobs.
2026-11-12 01:11:15 -08:00
Anees Iqbal 948a1f24f1 Count batches that waited for other queues' first work their commands and own first work reach none of
Each batch that did new resources' first work (images' moves, staged copies into them, fills at its start) is now kept until it completed with what owns the memory that work wrote: the owner under the image's key, the staged copy's image key or the fill's key (used_resources::owner_of), learned at the take on every device (FillTake::Owned where the device has no fill queue). WorkCounts::first_work_waits and first_work_waits_unused count the batches that waited for such work, and those whose commands and own first work reach none of it. Every batch still waits for all of it; the narrowing follows. tests::fill_waits gains a_batch_that_reaches_no_new_texture_waits_for_none_of_its_first_work (fails on unused until the narrowing), and the zero-reach test's textures are moved behind a long run of kernels on another queue.
2026-11-12 01:11:14 -08:00
Anees Iqbal eb50c1b24e Re-pin the runtime sources at the landing tip
The landed packet changed a runtime-sources input, so the committed digest no

longer described the sources and `the_runtime_sources_are_the_committed_ones`

would fail. Recomputed over the same inputs and committed by land-pkt.sh.
2026-11-12 01:07:18 -08:00
Anees Iqbal a7e882a498 RUNTIME_VERSION 2093: a long queue settles on an idle VkQueue no command queue holds before one another holds
The commit before this one. When a command queue went long, its one move (queue_share.rs settle)
took the least recently used idle VkQueue whoever held it, so it could land on the VkQueue a
compositor had just moved to. Seen on the RTX 5080 (nv5080reg's run at 66942365f6):
a_compositor_beside_a_queue_waiting_on_the_gpu_for_long_work_keeps_its_latency failed with p99
21.52 ms, 128 stalls of 9467: at 37.0 ms the compositor left VkQueue 1 for idle VkQueue 2, at 37.2 ms
the waiter's move picked VkQueue 2 too, and the compositor sat behind its 30 ms waits until 103.3 ms.
settle now takes an idle VkQueue no command queue holds where one is, else the one the fewest hold,
least recently used among equals: the rule 2084 gave placement and unshared queues.

Test: a_long_queue_settles_on_an_idle_vk_queue_no_command_queue_holds_before_a_held_one fails on the
old rule (m3-max-19728: left Some(2), right Some(3)); queue_share pure tests 9/9 (19727); clippy plain
(19752) and m2v_gpu (19753). Not run with the fix: the device test on the 5080 or the 3090.

Also landed (no behaviour change): examples/queue_plan_cost.rs gains --rooms, --runtime-rooms,
--runtime-fill and --overlap, and made_within_resources' doc says why a refused device takes its least
plan at once. Stepping down (18, 11, 7, 3 VkQueues) was measured against it: on the RTX 2080 eGPU it
made one device of 11 queues instead of 3 and two more devices refused (12 vs 14 made; 19615/19616);
on the 3090 it changed nothing and added 0.42 s to the device that took 3 (19620/19622).
2026-11-12 01:06:23 -08:00
Anees Iqbal 051316767c Queue sharing: a long queue settles on a VkQueue no command queue holds before a short queue's
A long queue's one move (settle) took the least recently used idle VkQueue no long or unshared
queue held, whoever else held it. On the RTX 5080 Laptop GPU (nv5080reg's run of
a_compositor_beside_a_queue_waiting_on_the_gpu_for_long_work_keeps_its_latency at 66942365f6) the
waiter queue went long on VkQueue 1, the compositor left VkQueue 1 for idle VkQueue 2 at 37.0 ms,
and the waiter settled on VkQueue 2 at 37.2 ms: the compositor sat behind its 30 ms waits again
until 103.3 ms, 128 samples over 10 ms in the 2 s window, p99 21.52 ms. settle now takes, of the
idle VkQueues no long or unshared queue holds, one no command queue holds where one is (else the
one the fewest hold), least recently used among equals, as placement and unshared queues do
since 2084.

Test: a_long_queue_settles_on_an_idle_vk_queue_no_command_queue_holds_before_a_held_one (the
compositor's VkQueue used longer ago than an empty one: the old rule took the compositor's).

Verified: cargo fmt; tests and the device repro in the following jobs.
2026-11-12 01:06:14 -08:00
Anees Iqbal 523de4d0c2 queue_plan_cost: the overlap phase function's doc wrapped too
Verified: text only; no line of the example past 100 columns.
2026-11-12 01:06:14 -08:00
Anees Iqbal 837d2c883b queue_plan_cost: the overlap phase's doc wrapped at 100 columns
Verified: text only; no line of the file past 100 columns.
2026-11-12 01:06:14 -08:00
Anees Iqbal c5379296b8 queue_plan_cost: wrap the overlap phase's doc line
Verified: text only.
2026-11-12 01:06:14 -08:00
Anees Iqbal b7f7719957 Runtime docs: why a refused device takes its least plan at once, measured against stepping down
made_within_resources now says why it takes the least plan at once rather than plans between: on a
GPU out of channels, what one refused device takes the next is refused. Measured with
queue_plan_cost --runtime-fill (one runtime device per process) at RUNTIME_VERSION 2084 against a
step-down branch (steelbrain/queuestep a595a24225: round robin halved on each refusal, 18 then
11, 7 and 3 VkQueues):
- RTX 2080 (Thunderbolt, 620.70.06): least at once 11 plan + 3 least devices, the 15th refused
  (m3-max-19615); stepping down 11 plan + one of 11, the 13th refused (19616).
- RTX 3090 (620.70.06): 58 plan + the 59th least either way; stepping down added 0.42 s to the
  59th (1111 vs 688 ms) and 0.21 s to the refused 60th (612 vs 398 ms) (19620, 19622).
- Refused vkCreateDevice of 7 to 15 VkQueues beside 12 runtime devices on the RTX 2080: 237 to
  270 ms each (19639, --runtime-rooms).
The example's overlap phase docs no longer speak of steps.

Verified: cargo fmt; the numbers are the jobs named.
2026-11-12 01:06:13 -08:00
Anees Iqbal c6c9e8f4be queue_plan_cost: the overlap phase, K processes making a device of each step's shape at once
For the plan's shape and each step a refused device takes (16+2, 9+2, 5+2, 1+2 on NVIDIA), K
processes make one device each at the same moment: each vkCreateDevice's time and the time until
all K were made, as when every device of a GPU is made again at once after a device loss. Asked
for by the orchestrator alongside the step-down measurements.

Verified: cargo fmt; built and run in the next jobs.
2026-11-12 01:06:13 -08:00
Anees Iqbal 66ac110484 queue_plan_cost: runtime rooms, and a runtime fill of distinct devices
Device::system_default_with returns the live device of equal options, so the runtime fill child
made one device per process and held five more handles of it (job m3-max-19562, on the RTX 2080:
0 ms for each after the first). Each device of a child now takes a shader cache directory of its
own. The runtime rooms phase holds N runtime devices and probes which bare queue counts the driver
still makes beside them: on the RTX 2080 a runtime device holds more than a bare device of its
queues (66 bare devices of 3 queues left room for 18; the 12th runtime device was refused 18).

Verified: cargo fmt; built and run in the next jobs.
2026-11-12 01:06:13 -08:00
Anees Iqbal 26230d0382 queue_plan_cost: rooms and runtime fill phases
The rooms phase holds K devices of the plan's shape and N of the least
plan's, then asks for a device of every graphics-family count from the
plan's down to one, timing each vkCreateDevice: which queue counts the
driver accepts beside what is held, and what a refusal costs. The
runtime fill phase fills the GPU with the runtime's own devices, each
printing its make time and the VkQueues it took. Both measure the step
down from a refused queue plan; neither runs unless asked.

Verified: cargo fmt; built in the next job.
2026-11-12 01:06:13 -08:00
Anees Iqbal 2da731e8b6 Re-pin the runtime sources at the landing tip
The landed packet changed a runtime-sources input, so the committed digest no

longer described the sources and `the_runtime_sources_are_the_committed_ones`

would fail. Recomputed over the same inputs and committed by land-pkt.sh.
2026-11-12 00:54:05 -08:00
Anees Iqbal 9cad865bb2 RUNTIME_VERSION 2092: a batch waits only for the fill queue's fills of memory its commands may reach
The commits before this one. On a device with a fill queue (NVIDIA, 2074), every other submission
waited on the GPU for the fill queue's last fill until the host saw it complete, fills it never
touched included. A batch now takes and waits for only the fills of memory its commands may reach:
memory its uses name or make resident; everything where a command reaches memory no use names, or
where it took a move in another resource's memory or a staged copy; and the device's own buffers.
Internal submissions still wait for the fill queue's last submission; other devices take every fill
as before. Counted: WorkCounts::fill_queue_waits and fill_queue_waits_unused.

Measured (release; a compositor's one-dispatch frame while an app on another queue makes two 4 MiB
Private buffers per command buffer):
- RTX 3090: p50 9.0 -> 2.10 ms (2.10 ms with nothing made); frames that waited for fills they never
  use, per 4 s, 424-429 -> 0 (m3-max-19457).
- RTX 5080 Laptop: p50 13.2 / 7.5 -> 1.18 ms (1.18-1.36 with nothing made); unused waits 288 / 430 ->
  0 (b5080 fillq-ab-233804, batch m3-max-19646).
Shared texture makings wait for no queued fill: p50 <= 0.011 ms, max 1.33 ms, both GPUs.

Test: tests::fill_waits::a_batch_that_reaches_no_new_memory_waits_for_none_of_its_fills saw 8 unused
waits and failed before the fix, 0 after (3090 19457, 5080 19646); zero-reads passes (19739);
zeroed_start / fill_queue / first_move tests 22/22 on both GPUs; lavapipe 24/24 touched (19668);
lint 19638, rustdoc 19732. Not run: RADV, Intel, MoltenVK (no fill queue there).
2026-11-12 00:53:10 -08:00
Anees Iqbal 47265e78f3 Fill-queue docs: what a batch's uses reach includes what they make resident; a texture's handle is no unnamed reach
State::reaches_unnamed is set by root tables, work recorded on the GPU alone and records resolved by host steps; a render encoder's handle-table reads set only that encoder's own flag (linear attachments). What a handle reaches is what Metal asks the program to make resident (useResource, useHeap), which the uses' check reads (used_resources::names_any). Docs only.
2026-11-12 00:52:55 -08:00
Anees Iqbal 86d6fd9cb2 FAST-PATHS: the fill queue's narrowed waits, as the RTX 3090 measured them
tests::fill_waits_bench on the RTX 3090 (job m3-max-19457): beside an app making two 4 MiB Private buffers per command buffer, the compositor's frame p50 went from 8.96-9.01 ms (every batch waiting for the fill queue's last submission, 424-429 unused waits in 4 s) to 2.10 ms (0 unused), as with nothing made (2.08-2.12 ms).
2026-11-12 00:52:55 -08:00
Anees Iqbal f0d03ea256 Test fill_waits: the pointer kernel's stores land in the new buffer's second half, which no copy reads
ob2_loaded_pointer stores tid | 0xb0000000 into the words its indices 8 to 15 name. They named words 8 to 15 of the new buffer, which the copies on the other queues read in no order with that kernel, so the test failed 6 of 10 runs on the RTX 3090 with the code before the narrowed take and 9 of 10 with it (job m3-max-19536): a race in the test, not the runtime's zeros. The copies now read the first half alone, and the stores go to the second.
2026-11-12 00:52:55 -08:00
Anees Iqbal 455ae850e9 Test fill_waits: a zero-read failure names every read that was not zero, its count, first offset and byte
On the RTX 3090 the code before the narrowed fill take (8c8dbec6b5) failed this test at its first batch's read (job m3-max-19457); the message now says which reads saw what, so a failure tells a late fill from another writer.
2026-11-12 00:52:55 -08:00
Anees Iqbal bf732b7213 Test fill_waits: the frame's floats read through as_chunks, as clippy asks
Clippy under --cfg m2v_gpu (job m3-max-19318) flagged chunks_exact with a constant chunk size.
2026-11-12 00:52:55 -08:00