What: a read of a texture, sampler or threadgroup memory argument the pipeline's function
constants removed (the absent read, lower::access::absent, and texture::AbsentArgument) takes the
same zero of its result's type as before: a read's zeros and a query's size of 0, which the nil
texture, set 1's element 0, answers too, with a write of a removed texture dropped. A new profile
fact says whether it also marks the command buffer's status (device::profile::AbsentReads):
Device::new's profile keeps Marked (StatusBits::ABSENT_ARGUMENT_READ, the ExecutionStatus fact,
its push field or binding), byte for byte; Device::from_queries' takes Nil, where the read marks
nothing and the stage states no AbsentArgumentRead or ExecutionStatus fact, no
ExecutionStatusAddress push field and no status binding. One form per profile, so it holds on
every stage: a fragment function's read, which the replay recordings name, and a kernel's, whose
pipeline the translator refused before on from_queries' profile (IdentityDomains: the status
word's push field is outside what the identity domains admit), now run. The
fact keys from_queries' fingerprint; Device::new's renders its fields alone, unchanged.
docs/API.md's degrade entry and ExecutionStatus bullet say so. SEMANTICS_VERSION 2179.
Why: Metal gives such a read no value, and its compiler drops or folds it; the new runtime writes
no ExecutionStatus words, so the status a read marked was a refusal of the whole pipeline.
Verified:
- f0c676d4f7, this change before its rebase onto a47fc3e69d: clippy with all features and with
--cfg m2v_gpu clean, the focused tests 66 of 66 (job 46992). The rt device tests of a fragment
function's and a kernel's read of a removed texture pass with the validation layer on and no
validation error on the RX 550 (47027), the RTX 3090 (47028) and the Iris Xe (47029); the
control, built without the change, fails both (47030).
- Rebased on a47fc3e69d: clippy with all features and with --cfg m2v_gpu clean; the touched tests
(absent, function constants, profile, golden, render descriptor keys, public fixtures,
fingerprints) 257 of 258, the one failure the old render key's pin, which SEMANTICS_VERSION
2179 moves; re-pinned here, it passes (47245).
The submit thread counted `Metrics::submissions` (and `submit_infos`) after vkQueueSubmit2
returned. The work can complete before the call returns (lavapipe runs it at once), and a thread
waiting on it, such as a texture read's wait on its upload, goes on to read the metrics while the
submit thread has not yet counted. Under load the late count lands in the next counted window:
tests::pass::on_device::every_device_clears_loads_and_stores_render_attachments failed on
lavapipe at random, at pass.rs:359 and at pass.rs:419 (left (2, 1, 1), right (1, 1, 1)), each
window opening just after a texture read. The metric's contract is vkQueueSubmit2 calls, which the
count before the call keeps; a failed call loses the device either way.
Verified on lavapipe under load (job m3-max-47252, msi): four loops of the pass test beside two
loops of the rest of rt's device suite (8 threads each, LP_NUM_THREADS=1). With the old count
(HEAD~1's submit.rs) the test failed within 5 s, at pass.rs:437 (left (2, 2, 2), one submission
more); with the count before the call it ran 14,850 times in 425 s with no failure. Clippy
(--cfg m2v_cpu_icd, all targets, all features) is clean.
The zero mark (1823e99d4d) makes rt::Device::new_buffer skip the bytes a take
found zero, so the player's zeroing of a fresh block counted fewer bytes_zeroed
and the zero-once test's count failed on the 2080 (m3-max-47124) while its
checksum held. The player now zeroes from block.zeroed, as the mark's contract
says (bytes past the mark are the consumer's to zero), and the test counts the
bytes inside the marks (zeroed_bytes_taken) with the bytes the buffers zeroed.
A take that leaves the Shared class under 8 MiB free has the block-maker thread make and zero
its next allocation; on Linux the test prints /proc/self/statm's resident bytes before the take
and once the allocation is zeroed, the host pages that zeroing (and the driver's allocation)
committed. A print only; nothing asserts on it.
The zero mark (BlockInfo::zeroed): how many of a block's first bytes the runtime itself zeroed
and nothing held since, as the take found them. They read zero; bytes outside the mark are the
consumer's to zero where Metal owes zeros. Nothing is inferred from the driver, the memory type
or a fresh allocation: the runtime zeroes from the front only, on the block-maker thread.
- Each Shared allocation made ahead of need is zeroed whole before it joins the pool (each
device's first in its making), and its bytes are the allocation's clean ranges; a block carved
there takes the clean run at its offset as its mark.
- A Shared block given back is zeroed again from its first byte, in steps of 256 KiB, while it
is kept; a take of it between two steps waits at most for the step that runs (the thread
starts none while a take waits) and gets the mark as it stands. A kept block's zeroed bytes
given back to its allocation stay clean. A block given back has mark 0 until then: the
consumer may have written any byte.
- Device::new_buffer zeroes only a Shared buffer's bytes past the block's mark, and every
placement lowers the mark to its offset (new_managed_buffer's bytes too).
- Private blocks carry no mark. Device::zero_block_range(block, offset, length) zeroes a range
of one the consumer holds by a GPU fill on the upload path new_buffer's Private zeroing uses,
ahead of every later commit; it never waits and is never done at a take. Refusal::
ZeroRangePastBlock and Refusal::ZeroRangeShared (REFUSALS.md regenerated).
- Metrics: allocations_zeroed, allocation_zeroing_nanos, kept_bytes_zeroed, kept_zeroing_nanos,
zeroed_bytes_taken, zeroed_bytes_freed (zeroed bytes an idle free gave back before any take),
block_zero_fills, block_zero_fill_bytes; the replay player keys them; api_signatures blessed.
- README: the consumer contract and the zeroing of kept blocks under the consumer's mappings.
Tests: Ranges' run_at and cut; a Shared block of the made-ahead allocation is marked and reads
zero whole; written, given back and kept, a take after three steps answers three steps' bytes,
zero, the rest as written; a zeroed buffer then zeroes only past the mark and lowers it; given
back again it is zeroed to its end. A Private block written by a kernel, kept and taken again,
zero-filled over its first half, reads zero there to the next command buffer's kernel and the
kernel's words past it; the refusals and NoSuchBlock. The three tests that check kept Shared
bytes stay as written hold the zeroing.
Verification: the check job and device legs run on this commit.
An image-only kernel runs a grid more than one deep in 256-thread tiles, a VkPipeline each. The
tile came from the grid's extents alone (the translator's grid_tile, the shallowest first), so
threadgroups of 8x8x4 over 512x512x16 ran in 128x2x1 tiles: 1.8-2.3x the old runtime's GPU time on
the UHD 630, Iris, RX 7900 XTX and RTX 2080, against 0.88-1.23x for the guest's own 8x8x4.
The tile is now picked from the grid and the call's threadgroup size (encoder::image_tile): of the
45 tiles, the fewest threads launched, then the fewest tiles partly past the grid, then the depth
nearest the threadgroup's (the shallower of two as near), then the most square in x and y, then
the wider. Threadgroups of 8x8x4 over a grid 8x8x4 tiles divide run in 8x8x4; threadgroups one
deep in 16x16x1, the square pipeline made with the state. Grids one deep keep the square. A pure
function of the grid and the threadgroup size, the same on every device; the bound of 46
pipelines per image-only kernel is unchanged. Tiling kernels keep grid_tile.
Tests: choice.rs states the order over guest shapes and grids.
Rows for the deep image tile's choice, beside sampling_deep_512x512x16 (threadgroups of 8x8x4):
- sampling_deep_512x512x16_8x8x1, _16x16x1 and _4x4x4: the same work, sample_down_layers over
512x512x16, in threadgroups of 8x8x1, 16x16x1 and 4x4x4;
- sampling_distinct_64x64x16 and sampling_distinct_512x512x16, in threadgroups of 8x8x4, through
a new fixture kernel, sample_down_distinct: layer z is a 2x downsample of its own rows of the
source into its own rows of the destination, so no two layers read the same texels.
sample_down_layers samples the same source texels on every layer, which gives a tile deep in z
cache reuse across layers that a kernel reading distinct layers does not get.
Each is checked against its CPU reference. MSL in fixtures/public/harness/workloads.metal,
compiled with scripts/regen-air-fixtures --dir harness on the M3 (job m3-max-47067; the
TOOLCHAIN is unchanged).
What: under the identity domains (Device::from_queries' profile alone; Device::new never takes
them, so its modules are unchanged), the handle of a texture whose resource ID an argument buffer
holds is the ID's low word masked to its low 16 bits (IDENTITY_TEXTURES - 1, the two image
arrays' 65,536 elements, a power of two the compiler checks): one OpBitwiseAnd a handle. A bad ID
reads the element at index & 0xFFFF, never one outside the arrays. Nothing else changes: a slot's
index is the runtime's own push (SlotGuestBase), a constexpr sampler's too (ConstexprSampler), and
an argument buffer's sampler is not lowered under these domains, so the sampler arrays stay at
4,000 with no mask. docs/API.md, where that sampler's refusal is listed, and RESOURCE-ID.md say
the change that first lowers one masks its index the same way. The new runtime's README records,
among the known gaps of memory blocks, that a shader uses a buffer's gpuAddress unchecked, so a
stale one can still fault the device. SEMANTICS_VERSION 2178: from_queries' translations of such a
texture change (2177 is the unlanded float-array branch's).
The feedback elements (index + 65,536 in the sampled array, where the device reads attachments):
only a draw's push of a texture slot's index reaches them. The render encoder builds no
useResource: or useHeap:, so no draw makes an argument buffer's texture resident, and Metal reads
an argument buffer's texture only once it is resident; the mask keeps every argument-buffer index
below 65,536 besides. So an argument-buffer texture that is also the pass's attachment is never
offset to its feedback element: the shader reads element index, as before, a read Metal leaves
undefined while the texture is not made resident (only the compute encoder has use_resource and
use_heap).
Why: the ID is the program's word, and an index past the arrays fetches a descriptor outside
them.
Verified:
- Check 46942 (msi) at this change on 98efd4de50: clippy, all features, 0; clippy under
m2v_gpu 0; the identity, golden, old render key, resource ID and public fixture tests 86 of 87,
the one failure the old render key, pinned here at 64b84e0f... from that run (SEMANTICS 2178).
- Final check 47056 (msi) at this tree (as 5794117bcb): clippy, all features, 0; clippy under
m2v_gpu 0; the same tests 87 of 87, the old render key at its pin among them.
- Words per identity texture kernel (base d392d453d6, 46865 -> this change, 46942): without an
argument buffer 829 -> 829; with one 1172 -> 1191; without robustImageAccess2 942 -> 942 and
1368 -> 1387.
- Negative control 46864: with the mask taken out, the identity test of IDs 65,536 past the
arrays fails (rc 100); with it, passes.
- The rt device test, ID 0x1_0005 reading element 5 (index 5 and 5 + 0x1_0000 both answer
7 x 3 and the texel): RX 550 46854, XTX 46855, RTX 3090 46856, Iris Xe 46857, all pass.
- Harness module hashes, every compute row, the mask (8d9317bef0) against its base (d392d453d6),
the same harness: XTX 46951 19 of 19 equal; RTX 3090 46952 19 of 19 equal.
A time-boxed look at the copy form's nc rows (a pass that loads its target and samples another
texture, no copy), which core found slower than the old runtime on the UHD 630. Timed in one
exclusive job (m3-max-47162: harness, release, four rounds, GPU p50 a pass, on probe rows over
the clear form, 774dcebda2): 688.6 against 617.8 us as the pass's first draw and 923.5 against
831.8 us after a plain draw, at 1920 x 1080. The target's move out of shader-read-only and back
is not the cause: the same rows with a RenderTarget-only target, which no barrier moves, take
700.7 and 911.6 us. The sampled texture (and a shadow) is read in SHADER_READ_ONLY_OPTIMAL, of
SAMPLED and TRANSFER usage only, with no storage, mutable-format or feedback usage. The cause is
unknown and recorded as a known gap, beside the faster clearing pass (666.9 against 870.7 us).
The known gap gave a pass that clears its target and reads it at its first draw as 10.5% slower
than the old runtime at 3648 x 2038 (4,635.1 against 4,195.7 us), the copy of a cleared target.
With the clear of the shadow in its place, re-timed on the UHD 630 (harness, release, four rounds,
GPU p50 a pass, old and new runtimes in one exclusive job, m3-max-47088, on the probe rows over
a5f3159c76, the same code as 4780d85bf8): 4,200.8 against 4,159.4 us (+1.0%), and 1,095.3 against
1,109.1 us at 1920 x 1080 (-1.2%). The same runs give the other rows: after a barrier 4,836.4
against 5,429.4 us, the first read of a loaded target 3,849.6 against 4,218.2 us, the pass
reading another texture 2,341.2 and 644.2 us. The r3 and b3 frame figures were counted before
the clear, so they bound the copies from above.
Clippy's unnecessary_lazy_evaluations asked for then_some, which would read the clear value's
colour eagerly, also of a stencil attachment whose value holds only depth and stencil; an early
return keeps the read where it is a colour's. Verified by the next check job.
On a device without the attachment feedback loop, a draw that reads an attachment of its own
pass copies what it reads into the image's shadow first. At the pass's first draw, where the pass
cleared the attachment, the rendered level and layer holds only the clear colour inside the
render area, and the copy cost more there than anywhere (about 81 us a MiB at 3648 x 2038 on the
UHD 630, against about 50 for a loaded target: the cleared target moving to the transfer layout).
Where no draw of the pass has been recorded yet (RenderCommandEncoder::pass_drew, any draw of any
pipeline), the attachment's load cleared it, the shadow is of the attachment view's format (so
vkCmdClearColorImage converts the pass's clear value as the load did), and every area the draw
reads of the rendered level and layer lies in it alone and inside the render area
(shadow::clears), the shadow's level and layer is cleared to the pass's clear value
(Target::clear_color) between the same two barriers, in place of the copy; the image's rendered
level and layer stays in the attachment layout. Areas of other levels or layers are still copied,
and a target cleared and then drawn copies as before. Only the read areas are held, as for a copy.
Tests: host tests of shadow::clears and Area::reaches; the device test
every_device_reads_its_cleared_attachment_at_its_pass_first_draw (no copy counted and every pixel
the clear colour read, at the pass's first draw; one copy of the whole target after one draw); the
attachment-read and levels device tests now count one copy each on the copy form, the first read
and the rendered level being the clear's.
keep_texture kept each texture once by its id, which a view shares with its parent so the
hazard sets treat them as one texture. A view used after its parent was therefore not kept: the
command buffer held the parent (which a view holds, not the other way round), and a view the
program released while the command buffer was pending dropped at once, vacating its element of
set 1 and giving its image views (a shadow view among them) to the reaper while work could still
read them. Metal's command buffer retains every object its encoders use.
It now keeps each object once by identity (Texture::is, the inner Arc), a view apart from its
parent. What reads the kept list by id is unchanged in effect: the over copies' lookup finds a
texture over a buffer of that id, whose copy a view and its parent share, and the submit
thread's take of a Managed over's copy in is taken once per id, a second take finding none.
Test: tests::view::every_device_keeps_a_view_bound_after_its_parent_until_its_command_buffer_retires,
a blit out of the parent and then out of its view, held behind an event wait; the view is
released, and while the command buffer is pending the textures and descriptor slots gauges keep
it; once it completes they fall by one each.
The owner approved it on 2026-11-18, typed in the planner's session, verbatim: "I approve it", on the planner's question "allow it as an eighth query-chosen form". Rule 2's list now holds eight: a device without the nullDescriptor feature gives every element of the texture and sampler arrays that no resource owns a small zero image or the default sampler, recorded as a known gap. The closing sentence (a second form chosen by anything else is not allowed) is kept. Docs only; the form itself is not built yet (it waits for the Mac lane).
Under the owner rule the runtime gives a held index to the newer object, so a placement while
an earlier holder's work runs takes the element from under that work, which Metal leaves the
program never to do (docs/RESOURCE-ID.md); the program's own timing kept that duty, and the
player, the runtime's consumer here, now keeps it. Each index is owed to the last commit that
named an object holding it, live or released (a released one's uncommitted users owe it at their
commit; a command buffer released uncommitted owes nothing), and a placement there, named, lowest
or highest, first waits for that commit. The `indices named` line counts the waits and their
time.
A commit counts done once its completed handler has run: the runtime sets a command buffer's
status before it drops what the command buffer held, and runs the handlers after, so the status
alone could find the work done while the runtime still held the old holder.
Verified: the ledger's unit test an_index_is_owed_to_the_commits_that_named_its_holders (to run
in the lane's check). The device test that holds work in flight comes after the reruns.
A read of an unbound buffer argument is undefined in Metal; under the new runtime a draw that
makes one reads address 0 and loses the device. Whether release programs make such reads is a
count the player can take: each pipeline state's used buffer arguments come from the
translator's reflection of its descriptor (isUsed), and each encoder's bound indices from its
setBuffer, setBuffers and setBytes calls per stage (a nil buffer unsets one) until endEncoding.
The backend reports an `unbound buffer reads N: ...` line (the states, the unreflected ones, the
first eight by position and frame) and `unbound_buffer_reads` per frame.
Verified: the unit test a_draw_reading_a_buffer_argument_nothing_is_bound_to_is_counted (to run
in the lane's check).
A run that played every frame but whose objects' gpuResourceID differ from
the recording's exited 1 with an 'error ids' line, the status of a run that
stopped: two clean plays read as crashes. It now ends 'ids: played to the
end; ...' and exits 3; docs/REPLAY-STREAM.md says so.
Both tests count what a held group does only on a try where no busy submission completed
before the submit thread decided, and both read that wrongly under load (four loops of the
held tests beside the device suite on an RX 7900 XTX):
- The submit-infos test read the progress when the mix's last commit returned, but a commit
returns before the submit thread stages it. Staged after a busy one completed, the mix's first
command buffer went alone with fewer than three in flight: three submit infos, not two
(job m3-max-46906, 1 failure in about 160 runs). It now waits until every command buffer of
the mix has left Committed before it reads, as the second-queue test waits for its held ones.
- The second-queue test read the busy ones' status, which turns Completed only after the
completion thread has raised its progress, and the submit thread counts a queue's submissions
in flight by that progress. Between the two, a held fill went alone while the test still saw
every busy one running: four lone submissions, not three (job m3-max-46985, 1 failure in about
85 runs). It now compares the progress with its value before the busy work, as the
submit-infos test does.
On a try where the progress has not moved once everything is staged, no staging decision can
have seen a completion. Product unchanged.
The known gap gave the old runtime's times against the copy form's proxy rows, whose passes all
load their target. The built form was timed on the UHD 630 (harness, release, four rounds, GPU
p50 a pass, old and new runtimes in one exclusive job, m3-max-46957, on the probe rows over
a20271ce5b): at 3648 x 2038 it is faster than the old runtime after a barrier (4,652.6 against
5,438.8 us) and at the first read of a pass that loads its target (3,750.9 against 4,247.8 us),
and slower at the first read of a pass that clears it (4,635.1 against 4,195.7 us; 1,118.8
against 1,099.2 us at 1920 x 1080). Against the same pass reading another texture (2,341.0 and
668.5 us), a copy of a target its pass cleared costs about 81 and 57 us a MiB, above the 53.5
and 39.0 us of a loaded one. The README says so, and that the r3 and b3 frame figures assume no
copied target was cleared by its pass.
Image::shadow's doc said device-local memory; the shadow is made and bound like any texture's
image: a texture block, else memory of its own where it spills. Doc only.
The covering-area host test expected a read over nine held strips to copy all of it. The ninth
strip, at the read's end, is still held after the first went past eight, so the plan copies the
read less that strip, one area: [0, 64] by [0, 8].
The attachment-read device test expected seven barriers on the copy form. The new shadow is homed
by the next submission's upload, whose end barrier counts too: eight.
Verified: the UHD 630 leg of a20271ce5b (job m3-max-46933) failed exactly these two assertions,
62 of 64 passing, with attachment_read_copies 2 printed.
A device whose descriptor limits hold set 1's second elements but that does not report
attachmentFeedbackLoopLayout and attachmentFeedbackLoopDynamicState (the UHD 630 on Windows, driver
101.2145) refused every draw that reads an attachment of its own pass through a texture. It now
reads through a copy: the one form left on that device, recorded as a known gap.
The query: floor::Capabilities::attachment_reads is the descriptor room alone, and the new
feedback_loop is the room plus both extensions and features; device creation enables the
extensions, features and dynamic-state loader only where feedback_loop holds, so the extension
device test's expected list (core().feedback) follows the query unchanged.
The form (crate::shadow): an image a draw may read so gets one shadow, same format, extent, levels
and layers, made at its first reading draw, homed by the next submission's upload, freed with the
image (Free::Shadow) and counted in Gauges::shadows and shadow_bytes. A texture reaching the
rendered level and layer reads its own view of the shadow at its second element (index + 65,536),
written under the owner rule (Arrays::place_shadow); one reaching neither reads the image at home.
The points are the feedback form's: the pass's first reading draw, and a reading draw after a
memory barrier after draws (which leaves every shadow holding nothing). At any reading draw the
planner copies what the shadow does not hold, as one area per read where what is new is one, with
no look-ahead: an own-pixel slot reads the scissor a pixel wider each way, clamped; any other every
level and layer its texture reaches. The copy ends the rendering, records one barrier (a global
memory barrier, the image's copied ranges to transfer source from the attachment layout or home,
the shadow's to transfer destination), the copies and one barrier back, and begins again. Each
copy counts in Metrics::attachment_read_copies and attachment_read_copy_bytes, and in
bytes_copied.
Docs: the rt README (set 1's second elements, the render encoder's copy form, the floor's
attachment reads and extension table, the chosen-by-a-query note, and the known gap with the UHD
cost: 39.0 to 53.5 us a MiB plus 3 to 8 us a copy, about 12 to 16.5 ms a frame for r3 and 4 to 5.5
ms for b3, from the census's 298.0 and 93.4 MiB a frame), DrawKind::AttachmentRead, REFUSALS.md
regenerated and the public signatures blessed.
Tests: host unit tests of the planning (tests::shadow) and of the floor's two answers; the device
test of attachment reads now runs the copy form where the device has it, asserting its barriers
(7), copies (2) and bytes, the live shadow, and the texels, and printing the counters; the level
test runs it too, one copy a level. Checks are run on the potluck legs after this commit.
Five on-device tests in tests/sampling.rs passed the same label, "sampling", to each_device, so every device leg printed M2V-MATRIX gauge sampling/<kind>@drop five times, and the matrix (scripts/matrix/results.py) failed every leg with "recorded twice" (matrix 3309532960: 9 of 10 legs). Each test now has its own label. Test-only; no label is now shared by two tests (checked over tests/ by grep).
Blessed on the M3 at 98efd4de50 (potluck m3-max-46972, census-exit=0). Only the artifacts_at product fingerprint changed; every case's compile cell is unchanged. The golden hashes at the same sha (m3-max-46971) are green with no row added or removed.
behind_busy and the two tests with their own rounds commit busy command buffers of more fills
each round until the work outlasts the check. With each busy one now committed after the one
before it is submitted (3309532960), the first runs longer before the check, and under load the
last round, 1,024 fills of 16 MiB (16 GiB, about 17 ms on the RX 7900 XTX), was outlived by the
host once in about 530 runs of the three held-group tests beside two loops of the device suite
(m3-max-46831: every_device_sends_the_held_group_a_command_buffer_without_a_submission_retires_behind,
'the busy work ended before every check'; no wait timed out). One round more, of 4,096 fills, runs
only where the 1,024 one ended first.
Verified: the compile job and the XTX load run, named in the hand-off.
A render pass recorded a barrier before it and one after it, so a command buffer of one pass took
three (the 2,000-draw harness row's stream on the RTX 2080: a pre-pass ALL to ALL barrier, the
rendering, a post-pass barrier, the end timestamp and the segment's end barrier).
The first orders the pass after every earlier command. Where the pass opens its command buffer (the
command buffer's first command, or the first after an event's signal or wait) and no attachment
moves to another layout, every earlier command is in a command buffer that ended with a barrier
reaching every later command on the queue (record::end), as a copy-in already relies on
(crate::capture). The pass then records none: Building::opens_command_buffer decides it, after the
copies a pass may record before itself, so a pass behind those keeps its barrier.
The second orders the pass before later commands. Where no attachment moves home it is owed
instead (Building::owe_pass): the segment's next command records it first, and a barrier owed
after a pass is recorded as Reach::Commands whatever reach the paying command names
(Building::barrier), so a dispatch after a pass, whose own barriers reach only compute, is still
ordered after the pass's attachment and shader writes. A blit or a pass after it records its own
first barrier, which pays it; where nothing follows, the segment's end barrier is it. A pass that
moves an attachment (a shader-read texture's, home shader-read-only) or moved one to the feedback
layout records both barriers as before.
A command buffer of one pass whose attachments render at home is one barrier, its end's; two such
passes are two; a pass then a dispatch is two. The rt README and the module docs state the rule;
the draw tests' counts move from 3 to 1; pass.rs's test adds the cases at home, the second pass
loading what the first cleared.
Verified: clippy under --cfg m2v_gpu and all 228 rt tests on lavapipe (jobs named in the hand-off);
the GPU legs and timing follow.
The held-group tests commit IN_FLIGHT busy command buffers back to back and take the queue to
hold its next commit. Under load the submit thread can wake once for two of those commits and
send them as one group. The queue then has one submission fewer in flight than the test counts.
The next commit goes at once and nothing is held behind the busy ones.
On the RX 7900 XTX under the parallel suite (m3-max-46710, 4 of about 100 runs),
every_device_sends_the_held_group_a_command_buffer_without_a_submission_retires_behind read
`before + 3` submissions when its fill left Committed. At the 60 s timeout all five of its
command buffers were Completed and the count had not moved: four command buffers with GPU work in
three submissions. The empty command buffer behind them retired behind the work in flight with
no submission, as rt does when no group is held, so the wait for a new submission could never
end. rt was right; the test's precondition was not.
busy_alone commits a busy command buffer and returns once the submission counter has passed its
value before the commit. The next one is committed after that submission and cannot join its
group. behind_busy uses it, which covers three tests whose checks rest on IN_FLIGHT separate
submissions:
- every_device_sends_the_held_group_a_command_buffer_without_a_submission_retires_behind (the
timeout above);
- every_device_sends_a_held_group_when_a_submission_completes (asserts AHEAD + 1 submissions);
- every_device_sends_a_held_group_at_the_wait_hint (counts AHEAD before the hint).
every_device_keeps_three_submissions_in_flight_and_holds_the_fourth (waits for exactly before + 3)
and every_device_counts_what_a_second_queue_adds (counts AHEAD lone submissions) commit their busy
ones through it too. Every other behind_busy test gets the same exact precondition.
Verified: the compile job (m2v_gpu clippy and the tests on lavapipe) and an XTX run under load,
named in the hand-off.
The old runtime's render descriptor key hashes SEMANTICS_VERSION: at 2176 over the tip's tree it is
eeff4686..., from eda47054... at 2175; only the version it hashes changed. m3-max-46715 (f24b447f65,
um870) gave the key, and with it written in, the_old_render_descriptor_key_keeps_its_value and
golden_hashes_match_the_table passed (2/2).
The identity set 1's storage array of 65,536 is a binding-plan fact rt's pipelines key on, so the
version moves past development's 2175 (identity's meter). The bless writes the table the tip's
sources derive: this branch's removals (IndexClass::StorageTexture, Refusal::IndexInUse) and the
items development's table lacked (floor::ATTACHMENT_READ_EXTENSIONS, the OPTIONAL_EXTENSIONS value,
Capabilities.attachment_reads, Features.divisor, feedback_loop and feedback_loop_dynamic,
DrawKind::DividedBaseInstance). This supersedes the 2174 and the old render key bf8e7821... of
the branch's earlier commits; the key the combined tree gives is pinned next.
sample_down samples at the target's texel centers scaled to the source: into a texture of the
source's side (B) it writes each source texel of the first half of each side, not the mean of
four. m3-max-46660 (3090, c10808af0d) showed the write reaching B with exactly those texels.
The owner test counted three held indices before D where it holds four (the source, the target,
the sampler state and the index): every leg of 1177568059 failed it at its first count (left 4,
right 3; m3-max-46592 RX 550, 46593 780M HawkPoint, 46594 RTX 2080, 46596 Iris Xe).
every_device_of_the_cfgs_kind_enables_the_consumers_extensions_it_offers expected no
attachment-read extension, which device creation enables since 1524689478 where the device takes
the attachment reads; the same four legs failed it (VK_EXT_attachment_feedback_loop_layout and
VK_EXT_attachment_feedback_loop_dynamic_state enabled, not expected). It now expects
floor::ATTACHMENT_READ_EXTENSIONS after the optional ones where the device took them.
1524689478 added floor::ATTACHMENT_READ_EXTENSIONS, Capabilities::attachment_reads and
Features::feedback_loop{,_dynamic} to rt's public surface without the table's rows; the bless adds
them. No consumer break: the items are new.
The old runtime's render descriptor key hashes SEMANTICS_VERSION, so the bump to 2174 moves it
(bf8e7821..., from 98be3009...; only the version it hashes changed). The owner-rule test's pass
closure names its argument's type, so each call borrows its textures alone; the compute pipeline
doc links Device::new_texture by its path.
Verified: m3-max-46522 (fdeb5c21fc) named the three: the key's new value, E0505 at the two drops,
the unresolved link.
A constexpr sampler's numbering is a placement like any other. Where a sampler state took the
index from it, a later pipeline state that numbers the constexpr sampler there took nothing back:
it sampled through the program's sampler. Now it places the constexpr sampler there again with
every element it holds (Arrays::hold_samplers: under the grants' lock, the owner's additions where
it still owns the index, else a placement), and the constexpr sampler keeps its elements' samplers
to write them. The consumer chooses constexpr indices and keeps them from the program's sampler
states while a state numbering one lives; rt does not check it (rt README, compute pipeline
docs).
An object the program released while a command buffer that used it is pending is displaced like
a live one: a placement at its index takes it at once, and its teardown once the command buffer
retires touches nothing it no longer owns (one owner compare for both). Nothing empties an
element at the program's release: a committed command buffer still reads the object through its
index, which Metal allows. The owner's teardown nulls it. RESOURCE-ID.md states the duty (no work
in flight reads a displaced or released object through its ID) and what an element no object owns
holds: every element is written at device creation, a null descriptor (nullDescriptor, on the
floor) or the array's default sampler, and written back to that when its owner goes.
The replay player gave constexpr samplers the lowest free sampler index, the range the stream's
named sampler IDs come from, so a program's sampler state could take a constexpr sampler's index.
It now gives them the highest free one, outside that sequence (Indices::highest; REPLAY-STREAM.md).
Tests:
- sampling::every_device_gives_a_constexpr_sampler_s_index_to_the_object_placed_there_last: a
nearest sampler state over sample_up's linear constexpr sampler reads nearest; a later state
numbering it takes the index back (linear, for both states); the sampler state's going touches
nothing; the slot gauge counts the index once.
- sampling::every_device_gives_a_released_object_s_index_to_the_next_at_once: a command buffer
samples A through SA, signals and waits on the host; A and SA are released and B and SB made at
their indices while it is pending (asserted); another queue reads B through SB; after the first
command buffer retires, and A and SA with it, the index still reads B through SB. The writes are
valid under UPDATE_UNUSED_WHILE_PENDING with PARTIALLY_BOUND (vkspec: "as long as they are not
dynamically used by any shader invocations"): A's dispatch completed before its signal.
- replay a_constexpr_sampler_takes_no_index_of_the_sequence.
The consumer's program places a texture at an index a live texture of its own still holds, and
releases the older one later (179 placements in one recorded stream, 92 in another). Metal takes
it: the later texture takes the ID. rt refused it (IndexInUse).
Now Grants keeps one owner word per held index (a HashMap per class, the word given at placement
and never again on the device; no list of holders, no refcount, no second bitset). A placement at
a granted index always succeeds and makes the placed object the owner; a release vacates the index
and empties its elements only where the releaser still owns it, so a displaced object's going
touches nothing. Placement and element writes happen under the grants lock in one step
(Arrays::place_texture, place_samplers, add_samplers, vacate_texture, vacate_samplers), so the
elements always belong to the owner. Where a placement displaces another object, a texture with
no storage view writes its storage element null and a sampler writes the arrays it does not use
back to their defaults, so nothing stale answers. The descriptor-slot gauge counts held indices:
a displacing placement adds none.
The same occupancy serves textures, sampler states and constexpr samplers. Constexpr samplers are
kept by (index, state words), each with its owner word; a later pipeline state of the same words
adds its arrays where the constexpr sampler still owns the index. Refusal::IndexInUse is deleted:
nothing Metal refuses remains. A texture now takes its index after its image and views are made,
so an index not granted is refused after the image is made and freed at once.
The duty: no work in flight reads a displaced object through its ID, as Metal's. rt does not
check it. RESOURCE-ID.md and the rt README state the rule and the duty.
The harness takes the next index round each class's range (its workloads make far fewer objects
than a range holds). The replay player keeps the object placed last per index: a named index an
object holds is taken, and the earlier object's release leaves it; with no index free for a
constexpr sampler it answers IndicesNotGranted past the range.
Tests: grants' an_index_has_one_owner_the_object_placed_there_last (both classes);
sampling::every_device_gives_an_index_to_the_texture_placed_there_last (a storage-capable D at 3,
a sampled-only A over it, whose placement empties D's storage element: a write through 3 is
dropped and D keeps its texels; B storage-capable over A, A dropped; sampling through 3 reads B,
writing through 3 writes B; B dropped, sampling through D's ID reads zero; the slot gauge counts
3 once); the sampler states' test places a state over a live one; replay's indices test.
REFUSALS.md regenerated, api_signatures loses IndexInUse.
The consumer hands each guest process texture IDs from one pool (1 to 16,320) and places every
texture at its own ID whatever its usage. rt split textures into two index classes by usage
(StorageTexture 1..4095 with shader-write usage, Texture 4096..65535 without), so every named
sampled-only texture below 4,096 and every storage-capable one above it was refused
(IndicesNotGranted), where Metal takes them: 4,818 makings in one recorded stream and 5,707 in
another.
Now there is one texture class, IndexClass::Texture, 1 to 65,535, with one grant bitset and one
occupancy; IndexClass::StorageTexture is deleted. Set 1's storage-image array (binding 1) is as
long as the sampled-image array, 65,536 (floor::TEXTURES replaces SAMPLED_IMAGES and
STORAGE_IMAGES). A texture with a storage view writes both elements at its index; any other writes
its sampled element alone and its storage element stays null; a texture that goes writes both
null. Samplers keep their class.
Why every floor device holds it: Vulkan's Required Limits (vkspec 56.1, Table 75 and Table 76)
give maxPerStageDescriptorUpdateAfterBindStorageImages, maxDescriptorSetUpdateAfterBindStorageImages,
the two SampledImages limits, maxPerStageUpdateAfterBindResources and
maxUpdateAfterBindDescriptorsInAllPools a minimum of 500,000 on a device that supports
descriptorIndexing. The floor's own sums become 2 * 65,536 + maxColorAttachments (131,080 at 8)
and 2 * 65,536 + 3 * 4,000 = 143,072, both below 500,000. Every lab capture (2080, 3090, XTX,
780M x2, HawkPoint, RX 550, Iris Xe, UHD 630, lavapipe) reports descriptorIndexing and 1,015,808
or more for each of the six limits. The floor's limit check stays the one gate: no query-chosen
size, no second form.
Translator: link.rs's identity set 1 sizes binding 1 by IDENTITY_TEXTURES (65,536), the same
constant as binding 0, so rt's of_the_device check still matches it. Nothing else in the pipeline
interface, binding plan or resource-ID decode assumes a storage index below 4,096: the identity
handle is the low word (masked only of bit 31 where the alpha flag rides it), indexing each
array's runtime-array variable. The identity domains are reached only from Device::from_queries'
profile (rt sets PointerDomain::Identity; the old runtime never does), so Device::new's modules,
refusals and notes do not change. SEMANTICS_VERSION 2173: the identity set 1 layout is a
binding-plan fact that changed under unchanged keys.
Consumers in the tree: the harness and the replay player grant and place every texture in the
one class; the player reserves a texture ID in it.
Docs: RESOURCE-ID.md's class table (nil, texture, sampler), the rt README (set 1, grants,
textures, the fault paragraph, the floor's limits table), IndicesNotGranted's doc (an object at an
index not granted, as well as a release) and IndexRange's basis; REFUSALS.md regenerated;
api_signatures loses the variant.
Tests: sampling::every_device_makes_a_texture_of_any_usage_at_any_index grants the whole texture
range, makes a shader-read texture at 2 and a shader-write one at 5,000, and checks one
sample_down dispatch against the CPU mean. arrays' fill-past-capacity fills every texture index
(a storage texture at 1, views of it at 2..65,535, 128 made again).
They are generated from the whole case set, and the set grew on `development`
while this branch was in flight, so the copy committed here counted a smaller
one.
Verified: regenerating at this tip leaves no change beyond the `Generated at`
stamp.
The live system zeroes a heap's memory once when it is made, so a buffer
placed there reads zero where nothing wrote it. The runtime's take_block
leaves a block's bytes undefined, and a block it takes again holds a
released block's bytes: placed buffers read them where the program read
zeros, a resource ID among them. zero_block zeroes [from, len) of a new
block through buffers zeroed from their start; from is the extent the
runtime zeroed itself, none yet. The device test writes a placed buffer,
releases it and its block, and reads zeros from a buffer placed in a block
of the same length; the bytes zeroed show both blocks went through it.
The new runtime pushed its draw's 16 bytes before every vkCmdDraw of draw_2000: 2,000
vkCmdPushConstants of the same bytes (VK_SHADER_STAGE_ALL, offset 0), where the old runtime binds
once (api_dump of both runtimes on the RTX 2080, job m3-max-46567). The 16 bytes are the vertex
function's two buffer slots' addresses (positions and colours), which change only with a
set_vertex_buffer. wide_bindings' dispatches each pushed their 224 bytes the same way.
Every pipeline has the device's one layout and push range, so a push stays across pipeline binds
and both bind points: the command buffer's recording keeps the bytes its pushes left (Pushed,
reset with each segment's new command buffer), and a draw or dispatch whose push bytes are
already held records none. A filter on the bytes is less code than pushing at each bind: a
pipeline change moves every field (each pair's fields are dense by link), so a bind-time push
would still need the pipeline's own layout of fields at each change.
Counters::metrics gains pushes and pushes_held. The push-window device test asserts the 24-buffer
kernel's three dispatches of the same bindings push once, and the 30-buffer kernel's push each
(its parameter block's address changes); a unit test checks the record.
The planner closed the RX 550's attachment read as a known gap: a guest pays the pass, and a pass
that reads its target takes no longer under this runtime than under the old one, on the RX 550
and the RX 7900 XTX, at 3648 x 2038 and 1920 x 1080. The gap now gives both runtimes' passes,
reading the target and reading another texture, with the difference. The old runtime's increment
over its plain pass is the smaller on the RX 550 (417.3 against 606.4 us at 3648 x 2038) because
its plain pass there takes 1,135.7 us against 516.5.
Measured in the same exclusive runs, four rounds each, the median over rounds of each round's
median: jobs m3-max-46562 (RX 550, RADV, Mesa 26.2.6) and 46563 (RX 7900 XTX). This runtime's arm
is harness 14f80dd773 (rt at development's 1524689478); the old runtime's is the probe harness
cac97bbab3 --runtime old (the frozen old runtime of c459695b88), whose reading draw binds the
target as a fragment texture after a render-target barrier, fragment to fragment. Both probes
never land. The old runtime's CPU per draw in the reading row at 3648 x 2038 on the RX 550 was
327k ns against this runtime's 106k ns.