every_device_fills_a_zeroed_private_buffer_before_a_copy_into_it_in_the_next_command_buffer
failed at its last check on every device (3090 m3-max-44735, 2080 44736,
RX 550 44737, lavapipe 44738): it made its texture with no index, and a
texture shaders read or write takes one ("a texture shaders read or write
takes an index, and none was given"). Every ordering check before it had
passed on all four: the bytes zeroed for each zero_from, and every byte of
the span for the four cases of copies into [0, zero_from) and into the
zeroed tail in the command buffer after the buffer's making. The test now
grants one texture index and places the texture at it, and waits for the
gauges to fall after teardown, as the other tests that make textures do.
development brought three new_buffer callers written for the old zeroed
flag: the replay's staging copy (nothing zeroed: it writes the range
itself, so None), the upload bound test's second fill and the
buffer-to-buffer blit test (zeroed whole, as before: Some(0)). The mapping
is the one the zero_from change used everywhere: true is Some(0), false
is None.
Documented Metal promises zero only for a buffer from
newBufferWithLength:options:. It is silent on heap memory and on the
bytes a placed texture sees. rt zeroed more: every new allocation whole
(Shared by host writes through the mapping, Private by a GPU fill in a
submission of its own, waited for), every block given back on the
block-maker thread, and then the buffer's range again at new_buffer.
Measured raw call against fill, 16 MiB, at e34c0d0ed7:
- UHD 630: the Private fill is 9.8-11 ms against 0.08-0.10 ms for the
call. Iris Xe: 2.8-4.3 ms against 0.01-0.11 ms.
- NVIDIA: the call dominates (Shared 2.9-4.0 ms, Private 0.55 ms).
Both whole fills are gone. A taken block's bytes are undefined, new or
taken again. Device::new_buffer takes zero_from: Option<u64> in place
of zeroed: bool. Some(z) zeroes the buffer's bytes [z, length), through
the mapping for Shared, by the upload's fill for Private. None zeroes
nothing (heap buffers, or a range the consumer writes itself), and an
offset at or past the length zeroes nothing. reims's Managed device
copy passes zero_from and copies [0, zero_from) itself, so the head is
no longer filled and then overwritten. Metrics::bytes_zeroed counts the
bytes, a Managed device copy's zeroed tail among them.
With no fill of its own, the filler keeps only the zero source: its
command pool, command buffer and fence are gone, and make_allocation
reads the buffer requirements from the device instead of making and
binding a buffer.
Tests:
- A zeroed buffer zeroes exactly [zero_from, length), counted as the
buffer's bytes. Shared and Private, offsets of 0, 3, 5, 12, 4000, and
one past the length.
- A kept block taken again holds its bytes as written. A Private one
the GPU wrote holds the GPU's bytes, and reads zero only in a buffer
zeroed over a range of it.
- A zeroed Private buffer's fill lands before a copy into it encoded in
the same command buffer, for reims. The upload is the first command
buffer of the next submission and ends with an ALL_COMMANDS/
MEMORY_WRITE barrier. Cases: copies into [0, zero_from) and into the
zeroed tail, both holding.
- A texture placed in a block zeroes nothing.
- The harness gains create_private_16MiB: a Private buffer's creation
plus one command buffer that reads its ends, through to completion,
checked zero. That time holds the fill, wherever the runtime does it.
The replay's per-frame counters gain bytes_zeroed. README, REFUSALS and
api_signatures are regenerated or updated.
The upload bound test came to development (5b52afb17b, eb46c7fa2c) written
for the old pool: a Private block of 64 MiB, the upload's bound. Under the
range pool a Private block is 16 MiB, so the released block no longer
filled the bound alone and "a fill past the bound" kept 16 MiB and more
pending: upload.rs:265 on the 3090 (m3-max-44811) and the 2080 (44813),
at b261e44947. The released and filling blocks now ask for UPLOAD_BYTES,
the bound's length, which the test's comment already names; a take that
long makes an allocation of its own.
On lavapipe (44809) and the RX 550 (44814) the test timed out earlier,
waiting for the released textures' allocations to come back to the count
before them. A texture made while earlier ones are still being freed can
take a second 16 MiB texture block (64 textures of 256 KiB fill one); once
empty it goes back to the pool, which keeps the allocation idle for its
window, so the raw count of allocations stays one higher. The test now
counts the allocations in use (all of them less the idle ones, from the
idle-bytes gauges) for that wait and for the copies' ceiling, waits for the
textures and the allocations apart so a timeout names which, and prints
the gauges after the released textures.
every_device_frees_idle_allocations_as_the_window_s_peak_falls read the blocks
gauge as soon as the third hook had run and the Shared idle gauge had fallen.
The block-maker thread settles the idle gauge under the pool's lock, then, for
each allocation the idle rule takes out, runs the kept block's hook and only
then frees the allocation and lowers the blocks gauge. So the read raced the
third vkFreeMemory and saw one allocation too many (5 for 4) on the 3090
(m3-max-44731), the 2080 (44732) and lavapipe (44734); a 16 MiB system-memory
free on NVIDIA takes about 17-20 ms, so those legs read inside it every time,
while the RX 550's cheap frees passed (44733). Every assertion before it (the
three oldest unmapped in order, on the block-maker thread, and the idle gauge)
passed on those legs: the rule was right, the test's read order was not.
The test now waits for the blocks gauge to reach the zero source, the reserve,
the fourth and the Private allocation, then checks the three unmaps, their
order and the idle gauge, all final by then. A rule that made or kept an extra
allocation still fails it (the wait times out), and one that freed the wrong
allocations fails the order check.
The pool's returned blocks were a stack: blocks given back while the
block-maker thread was busy were taken newest first, so the emptied
stamps that order the idle rule's frees depended on when the thread
woke. On every device leg (3090, 2080, RX 550, lavapipe at b3dec72137)
every_device_frees_idle_allocations_as_the_window_s_peak_falls freed
block 5 first where it gave back 3, 4, 5, 6 in that order. A queue makes
the allocation emptied first the first freed, whatever the timing.
The texture-over-buffer test took a Shared block of 128 KiB and placed
a Managed buffer at 128 KiB in it: before 16 MiB allocations a small
take was a 16 MiB block, now it is the length asked, rounded to 64 KiB.
It takes the 192 KiB it uses.
Verified: the two tests' failures on lavapipe (44659) and the RX 550
(44663) name these causes; the legs run again on this commit.
A raw Private vkAllocateMemory on the UHD Graphics 630 (Intel's Windows driver 101.2145) took
0.08 to 0.20 ms at 16, 32 and 64 MiB, three trials each, and round trips on the queue during it
took as long as before it (0.32 to 0.48 ms against 0.36). The 0.4 to 0.75 ms per MiB that rt's
fresh Private take held submissions for is the making's zero fill, the memory's first use.
Verified: potluck job m3-max-44513 (the raw probe at d4a739dd7b, cross-built in m3-max-44352);
cargo fmt.
- The harness's rt heap takes a block of MemoryClass::block_len (16 MiB) when no block it holds
fits a buffer, the way a guest's allocator takes chunks of that length. Under the range pool, a
take of the span alone carved 64 KiB, which no consumer does.
- create_state's first now includes the creation of the 16-byte buffer its dispatch writes, so a
take of memory and the pipeline creation it may hold beside it are timed together, in both
runtimes.
- Each creation row prints the runtime's allocations on the caller's thread during the first
creation (count, time, the longest since the device was made), with matrix lines, where the
runtime counts them (rt: Metrics::consumer_allocations).
- rt counts each class's first allocation in Device::new with the block-maker thread's, as
allocations made ahead of need, so the consumer's figures start at zero.
Verified: cargo fmt; api_signatures --check passes. Clippy and the rows follow as potluck jobs.
Clippy (all features, and --cfg m2v_gpu) refused be6c48e94a: a drain into a new Vec, two
extend-from-drain moves, the unused Pool::allocations test helper, and a manual is_multiple_of in
the memory tests. Behaviour is unchanged.
Verified: cargo fmt; clippy follows as a potluck job.
The pool handed a take of up to a block length a whole pooled block and kept one ready block per
class, which the block-maker thread made again as soon as a take used it. A 16-byte Shared buffer
took the ready block, and the 16 MiB allocation that followed held the consumer's next pipeline
creation for its whole length on NVIDIA's driver.
Now each block is a range of one of its class's allocations, with its own VkBuffer:
- A take is a kept block of its length, else the first free range that fits, else the start of an
allocation made in the call: 16 MiB, or the block's own length where that is longer. Lengths
round up to 64 KiB (or bufferImageGranularity); a block starts at its length rounded up to a
power of two, up to 2 MiB.
- Device::new makes one 16 MiB allocation per class. After that, the block-maker thread makes
another only while the class's free bytes are under 8 MiB. A take never waits on it for memory.
- A take that no free range fits, while the class keeps blocks of other lengths, allocates at once.
It also asks the block-maker thread to give those blocks' bytes back, after the consumer's hook.
Only when its own allocation fails does it wait for those bytes, then look for a free range once
more.
- An allocation holding no live block is idle. A class keeps its idle allocations while their
bytes plus those of its allocations in use stay at or under the most bytes it had in use over the
last 10 seconds, and within an eighth of its memory type's heap. Past that it frees the oldest,
except the reserve that keeps 8 MiB free. The rule runs at takes and give-backs on an injectable
clock; there is no timer.
- Removed: the dedicated path, fits-and-fills-half, the 256 and 128 MiB idle bounds and the 64 MiB
Private block.
- Metrics: blocks_reused replaces dedicated_blocks_reused. New metrics: block_bytes_made, and the
vkAllocateMemory time on the consumer's threads (count, total, longest) apart from the
block-maker thread's.
Tests:
- Unit: rounding, base alignment, and the window and surplus rule.
- On device:
- the first allocations, and the trigger at 8 MiB free;
- kept blocks taken again with their number, address and mapping;
- an allocation beside kept blocks of other lengths, with their bytes given back;
- the failed-allocation path, at an answered maxMemoryAllocationCount;
- idle allocations following the window down, the reserve kept;
- a seeded 300-step stress of mixed takes and releases across both classes, each step under a
one-minute timeout.
- Tests that took a block of 1 byte and used more of it now take what they use.
- The replay's rt counters read the new metrics.
Verified: cargo fmt; api_signatures blessed; REFUSALS.md regenerated. Clippy, the suites and the
device legs follow as potluck jobs.
create() made its first buffer of the row's length untimed, so a runtime's
first take of memory for that length, which may allocate where later takes
reuse, was hidden in the steady times. The first creation and the second, the
first after the first buffer's release, are now timed and reported apart for
both runtimes: the row's line says 'first take X us, the next Y us', and the
matrix gets harness-<runtime>/<row>/first_take and next_take. Both are checked
zero at every 4th byte as before.
Verified: built by job (pending).
How a Managed buffer behaves depends on the recording device's hasUnifiedMemory: one copy where
it is true (a CPU write needs no didModifyRange), a GPU copy made at the buffer's making and
changed only by didModifyRange where it is false. The stream did not say which, and the rt backend
always made the runtime's Managed buffer: gb, recorded on a discrete GPU, wrote its no-copy
Managed buffers (#368205, #368202, #368214) once before first use with no didModifyRange, so their
GPU copies never got the bytes; b2, recorded with unified memory, relies on such writes legitimately.
The player now takes the form from the stream's new m2v.deviceIdentity record (it plays as nothing
and tells the backend hasUnifiedMemory through Backend::recorded_unified_memory), or for a stream
without one from command-replay's --managed one-copy|two-copy. One copy: every Managed buffer plays
as a Shared one. Two copies: the runtime's Managed buffer, its GPU copy from the bytes it was made
with: a copied buffer's, or the new create-time bytes a no-copy one's making now carries
(newBufferWithBytesNoCopy's first argument, a no-copy descriptor's contents). A stream with no
identity record gives none, so a no-copy buffer's GPU copy takes the writes recorded before its
first use (the commit of a command buffer whose encoder names it). With neither the record nor the
setting a Managed buffer stops the play with an error saying so. The report's managed line names
the form and its source, counts the Managed buffers and the no-copy ones with contents from first
use, not from create, and notes a two-copy recording played on a unified-memory device.
REPLAY-STREAM.md documents the identity record, the create-time bytes and the player's rule.
Verified: a replay test plays an identity record as nothing and sees the backend told
hasUnifiedMemory; the rt paths need a device play (gb on the 3090 next).
So the leg output shows the device-copy form ran where the Shared memory type
is not device-local, rather than leaving it expected (main's ask after the
b2b legs).
Verified: the legs print it.
Rebasing the render encoder over 3201e09737 put both sides' Refusal
variants after HeapTexturePlace; the resolution kept both but dropped the
closing "}," of BufferCopyOverlap and the ")," of its Display arm, which the
two sides shared outside the conflict. The file did not parse
(signatures.py --check fell back to the translator's Limit). REFUSALS.md is
regenerated from the repaired file; signatures.py --check passes.
Verified: signatures.py --check rc=0 and refusal_surface.py locally; the
lint job compiles it.
Lint m3-max-44560 at 619f22dc36 failed to build: the attachment descriptors
derived Debug over Texture, which has none; the stencil format check compared
the translator's ImageAspectFlags with ash's; the profile's limits are a
method; the action-mapping test printed ash enums, which carry no Debug here.
The color attachment descriptor's Default is now derived (its fields' defaults
are Metal's), the view lookup copies the kept view out before the push, and
the api_signatures table is re-blessed for the dropped derives.
Verified: the rerun lint is the check.
CommandBuffer::render_command_encoder(&RenderPassDescriptor) is
renderCommandEncoderWithDescriptor:. It begins one vkCmdBeginRendering (dynamic
rendering, in the floor: floor.rs requires vulkan13.dynamicRendering) into the
pass's attachments, and end_encoding ends it with vkCmdEndRendering. Load and
store actions map one to one (Load/Clear/DontCare, Store/DontCare). A clear
color is a float in a float, normalized or sRGB channel (the device converts
it), and an integer channel's is truncated toward zero and saturated, NaN 0,
as Metal's; rotated formats and A8Unorm held in R8_UNORM go through the
format's rotation; a clear stencil keeps its low 8 bits. The render area is the
smallest attachment's level, cut to renderTargetWidth/Height where set.
Each attachment is one level and slice of a 2D texture, 2D array, cube or cube
array of one sample: the texture keeps an identity-swizzled image view of that
level and layer, made at the first pass and freed with the texture through the
reaper (new gauge attachment_views). A pass orders itself as a blit copy does,
two barriers: the first after every earlier command, moving shader-read-only
homes to the attachment layout (general and attachment homes render in place)
and paying an owed barrier; the second after the rendering, moving them home
and making the writes visible to every later command.
Refused as Metal's validation stops them: Refusal::AttachmentUsage,
AttachmentPlace, AttachmentFormat; past maxColorAttachments,
Limit::ColorAttachments. Not built, Gap::RenderPass naming RenderPassKind: a
depth attachment, more than one sample, a resolve, a 1D or 3D attachment, the
Unknown and CustomSampleDepthStore store actions, a clear of a format only a
shader clears, a pass with no attachment. The replay streams' passes (pass
census over gb and b2, counts only): one or two color attachments plus a
stencil in 11,187 of them, every attachment a level of a 2D texture of one
sample, no depth, no resolve, loads Load/Clear/DontCare, stores Store/DontCare.
Tests: tests::pass's host tests pin the action mapping and the clear values;
on_device clears a mip level of a shader-read texture (moved and back), an
integer texture and a stencil, loads and keeps, cuts the area, clears one
slice of a 2D array, and counts one pass alone as one submission, three
barriers, one pass and no bytes copied; each view is made once and freed with
its texture; refusals leave the command buffer open. README render encoder
section and known gaps; REFUSALS.md and api_signatures regenerated.
Verified: the lint job and the device legs are the check.
A kernel indexes the heap arrays with the resource ID's index as given, with no
clamp, so an index past an array's length (a Texture-class index of 4,096 or
more through the 4,096-element storage-image array, for one) reads a descriptor
from past the array: undefined in Vulkan, as Metal leaves an ID naming no live
resource of the access undefined, and it can fault as a bad address does. The
planner ruled it a README gap in the bad-address class, with no clamp.
The block-maker thread's zero fills of the blocks it makes and is given back
are submissions too, and come when they come: on llvmpipe one came inside the
fill-at-the-bound step (check m3-max-44699: 15 submissions against 14). The
upload's pending bytes say what the step asks: the released block still counts
at the bound, and past it the send starts the count again.
The test released a Private block of 64 MiB, exactly UPLOAD_BYTES, after a zero fill, and expected
the next fill to send the upload. Upload::full sends only past the bound, and a zero fill stages
nothing, so the block alone keeps the upload pending: the test passed only where the 4 MiB texture
phase before it left released bytes in the upload. Readout (probe 9ada86cad0 on development
0c9a4ad558, the test alone): on the RX 550 the upload held 125829120 bytes after the release and
the block came back (m3-max-44685); on the Iris Xe it held exactly 67108864, no submission came,
and the block never came back in 40 s (m3-max-44686), the timeout the Iris legs saw on development
(m3-max-44629, 44561, 44577). Under B's texture blocks the leftover changes, which fits item-a's RX
550 timeout inside the suite.
The part now sends the upload first (a read of one texel), checks that the block alone is counted
at exactly its length and that a fill at the bound submits nothing and keeps the block, then
releases a small texture after a copy to take the upload past the bound: the next fill submits it
and the block comes back. The product is unchanged: the bound is at most UPLOAD_BYTES.
The shape rule (730c43e7d0) bumped SEMANTICS_VERSION to 2171 and ARTIFACT_FORMAT_VERSION to 535, so
every authored case's compiled artifact hash moved. Re-blessed on development 7fd80ec2b4 by the
census job on the M3 (m3-max-44753, census-exit=0). No case changed status: 2,369 rows before and
after, every row's status kinds equal; only artifact hashes and some refusal reasons' text differ.
The golden hash tables, engine inventory and air_input printouts re-blessed in m3-max-44752 with an
empty patch (no change).
Device::minimum_linear_texture_alignment answered the smallest power of two from 16 at which the
device lays every width's linear rows at the row rounded up to it, and 16 where none held. ANV
(Mesa 26.2.6) on the Iris Xe of RPL-P lays each linear row at the row itself, with the image's
memory aligned to the texel. Probe m3-max-44665 (never lands) asked R8Unorm, RGBA8Unorm, R32Float,
RGBA16Float and RGBA32Float at 15 widths from 1 to 1,920 texels under read, read+render and
read+write: every pitch was the row and every memory alignment the texel's bytes. So no power of
two from 16 held for texels under 16 bytes. The answer fell back to 16, and a texture over a
Shared buffer at a pitch the guest rounded to 16 was the counted copy wherever its row was not a
multiple of 16. That is the Iris failure of every_device_holds_a_texture_over_a_buffer_in_place at
width 1 (matrix leg m3-max-44561 at e886ee4c74).
The candidates now start at the format's texel bytes, rounded up to a power of two
(linear_rounding). ANV answers the texel (4 for RGBA8Unorm, 1 for R8Unorm). A guest that rounds
its pitch to the answer gets the device's own layout, and its texture is the linear image on the
buffer's memory. Devices that pad rows to 16 or more answer as before: RADV on the RX 550 still
answers 256 for 1- to 4-byte texels and 512 and 1,024 for 8- and 16-byte ones, in the same probe
(m3-max-44666). Metal on the M3 answers 16 for every format; a smaller answer is the device's, as
RADV's larger one is.
The device test asked an RGBA8Unorm texture at (row + 1) rounded up to the answer. That is the
device's pitch only where the answer is 32 or more, so it now asks the row rounded up to the
answer, which has rows longer than their texels on a device that pads. The test's range check
takes each format's texel bytes as its floor. The docs said a pitch that is any multiple of the
answer is in place; it is the row rounded up to the answer.
Verified: cargo fmt. the_linear_row_rounding_starts_at_the_texel (rt tests::texture, no device)
fails under the old floor of 16 for rows laid at the row itself, and pins RADV's padded answers
and a floored layout's none.
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.
The planner asked for the declared-at-tile form's first-dispatch wait in the consumer's terms
before it lands. An image-only kernel's first dispatch over a grid more than one deep, at a tile no
state of its content has run, makes that tile's VkPipeline on the calling thread. The thread waits
for it (Metrics::first_use_waits), and the pipeline comes from its file in the cache directory
where there is one.
The count comes from replay's job m3-max-44702, over both recorded streams whole: image-only
non-observer dispatches with threads z > 1, by (spec, grid_tile) pair.
- 49 pairs of tile depth 64 or less in each stream. Every pair's first dispatch is in one frame:
224 of one stream and 312 of the other.
- One more pair in each, of tile 1x1x256, runs in the remap's tiles where the device's
maxComputeWorkGroupSize is 64 deep, and makes a 50th pipeline elsewhere.
Metrics::first_use_waits's doc names the tile among the workgroup sizes a wait is for.
Verified: docs only; the counts are the job's output.
A known gap the planner asked for at landing: a kernel that does not observe its threadgroup
partition and is not image-only runs a grid more than one deep in the tiles its regions carry.
- RX 550 (RADV, Mesa 26.2.6): grid3_fill, one 4-byte store through a device address per thread,
took 2.6, 9.4 and 30.2 µs over 4x16x312, 24x24x252 and 256x256x8 grids in tiles. On a pipeline
that took the tile as a specialization constant (the deleted fold) it took 2.2, 8.6 and 25.0 µs.
Job m3-max-44507, probe a636c4175a, 6 rounds; every round within 0.4 µs.
- UHD 630 (Intel's Windows driver, 101.2145), 24x24x252: the tiles took 1.26 and 1.59 times the
old runtime's time by median: 93.6 vs 74.0 µs (m3-max-44604, 8 rounds) and 79.7 vs 50.0 µs
(m3-max-44506, 10 rounds). Within one job, one form's rounds ranged up to 2.8 times apart; the
modes differ between jobs.
- The old runtime's form in this runtime took 0.97 of the tiles' time in 44604, with its fastest
round 72.6 against old's 69.4 µs. That form is the guest's 8x8x4 threadgroup as the workgroup,
with the buffer through a pushed storage-buffer descriptor (probe arm f8x8x4+d).
- So the old runtime's form is not an untried one that wins here: neither the workgroup shape
nor the descriptor accounts for the ratio.
Verified: the numbers are the jobs' logs above. Docs only.
The planner's ruling makes the rule two lines. An image-only kernel that does not observe its
threadgroup partition is declared: 16x16x1 on a grid one deep, the grid's tile (grid_tile) on a
deeper one, at MultiRegion 0 with the extent test. Every other such kernel runs today's remap:
256-lane workgroups, each one tile the region carries. The fold no longer serves buffer-touching
kernels. Image-only kernels used it only where the grid's tile is past the device's
maxComputeWorkGroupSize, and that class is too small to keep a form for, so those dispatches take
the remap too.
The census (replay's job m3-max-44582, both recorded streams): image-only non-observer
dispatches whose tile is past a depth of 64 (NVIDIA's, the floor's limit) are 6 dispatches,
1,760 threads in each stream, one (spec, tile) pair of tile 1x1x256. That is 0.0004% of the
image-only non-observer threads in one stream and 0.0033% in the other. No tile is past a side of
1,024.
Deleted: SpecKey::FoldedTile and the select that took it in place of the region's tile
(lower::dispatch), its binder entry, codec tag, signature row and API guide sentence; rt's
Variant::fold, Constant::FoldedTile, Choice::fold and Last::fold. The cache versions stay at this
branch's single bump (SEMANTICS_VERSION 2171, ARTIFACT_FORMAT_VERSION 535, now for
KernelFacts::image_only and the edge test under MultiRegion 0 alone). An image-only kernel's
pipeline per tile stays: its workgroup is the tile, so a deeper grid's first dispatch at a tile
makes it, and waits once, as the square device test's two-deep dispatch checks.
Verified: cargo fmt; docs/REFUSALS.md regenerated (unchanged). The dispatch-choice tests pin a
tiling kernel's grids of every depth in the remap's tiles, and a 1,024-deep column in them past
a depth of 64. The translator's engine test runs the edge kernel at MultiRegion 0 in 16x16x1
workgroups and at the grid's tile.
A kernel that does not observe its threadgroup partition and is image-only (it reads an image and
does no addrspace(1) load, store or atomic) ran a grid one deep in declared 16x16x1 workgroups but a
deeper grid in folded tiles, workgroups of 256 lanes that decode the tile from a specialization
constant. It now runs a deeper grid at MultiRegion 0 in declared workgroups of the grid's tile
(grid_tile), the region carrying them and flagged where they do not divide the grid, so the
extent test returns the invocations past it. One VkPipeline per tile, made at the kernel's first
dispatch at that tile, as the folded one was. A tile past the device's maxComputeWorkGroupSize
(a column 1,024 deep tiles 1x1x256, past a depth of 64) still runs folded. Buffer-touching
kernels keep the folded tiles. Launched threads are unchanged: the workgroup is the rule's tile.
encoder::choose takes the device's maxComputeWorkGroupSize to hold the tile to it.
Why: the planner's 3-D row, declared at the tile against folded at the tile, on an image-only
kernel over 3-D grids (probe a636c4175a, never lands; rows 4x16x312, 24x24x252, 256x256x8).
Declared beats folded by more than 3% on the UHD 630 and loses nowhere by more than 3%:
declared at the tile over folded at the tile, each the median over rounds of the arm's GPU p50
against the rule's from the same job, one build per GPU at a636c4175a:
rows UHD 630 RX 550 RX 7900 XTX RTX 2080 RTX 3090
4x16x312 0.966 0.946 1.000 0.989 1.000
24x24x252 0.746 0.992 0.965 1.000 1.000
256x256x8 0.997 1.000 0.968 0.993 1.000
(m3-max-44506, 10 rounds; 44507, 44508, 44510, 6 rounds; XTX 44524, 12 rounds).
Verified: cargo fmt. The dispatch-choice tests (tests/choice.rs) pin an image-only kernel's
deeper grids at their tile, a tiling kernel's folded, and a column 1,024 deep folded past a depth of
64; the translator's engine test runs the edge kernel at the grid's tile at MultiRegion 0 over
ragged and whole 3-D grids; the square device test's two-deep dispatch now runs this form.
The old runtime's render descriptor key hashes SEMANTICS_VERSION, which this branch moved to 2171
for KernelFacts::image_only and SpecKey::FoldedTile, so the pinned key of the test descriptor
moves with it. The old runtime's cache entries under the earlier version are misses, as every
semantics bump makes them.
Verified: the_old_render_descriptor_key_keeps_its_value failed at fe31e5b618 (check job
m3-max-44493) with exactly this value on the left; the rest of that job was green (clippy
workspace, m2v_gpu and no-feature; rustdoc; rt lib 62/62; translator lib 3673/3674; signatures).
Both recordings' guest-RAM copies (gb 106 before frame 1095, b2 14 before frame 312) land in
Private buffers, and the rt backend skipped them, so the bytes and addresses they carry never
reached the GPU. A buffer-to-buffer copy now plays as rt's copy_from_buffer_to_buffer. A copy from
the guest's RAM, the recording's plumbing, plays as its pieces' bytes in a Shared staging place of
the backend's own, then a buffer copy into the target in the same blit encoder, so the GPU's order
holds. A buffer copy takes whole 4-byte words at 4-byte offsets: a piece's edge bytes up to whole
words come from the target's mapping where it has one; a piece with such edges into a buffer
with none is skipped and counted. The staging place is given back at the command buffer's commit
and is free once it completes, so the staging stays bounded by the work in flight
(staged_guest_ram_bytes counts it). The player times these copies in a column of its own
(`upload`), the recording's share and not the runtime's.
Both halves the planner asked for, in the fault gap's bullet:
- The hang ends at the device's next submission on any queue: that vkQueueSubmit returns
VK_ERROR_DEVICE_LOST (measured on the 2080 and 3090 for the same queue, the family's second
queue and another family; m3-max-44654, 44655), the runtime takes a failed submission as a
loss, and the completion thread's wait (any of the progress and wake semaphores) returns once
the wake semaphore is signalled from the host after the fault (same jobs). So with a submission
every frame it lasts about a frame; with none it lasts indefinitely.
- The old runtime took the faulting accesses without a fault (no raw addresses in its kernels);
under the new runtime a bad address ends the GPU's work for every guest process on NVIDIA and
RADV, the consequence of one device and direct addresses that the owner accepted.
The bullet reflowed to 100 columns.
The planner ruled the NVIDIA fault gap a known gap (ladder rung 3: repro, upstream report, README).
Measured with an opt-in repro: one compute dispatch storing through a buffer device address
nothing maps, then bounded probes (C program fault-wait.c, staged with the upstream draft):
- NVIDIA 620.70.06, RTX 3090 (m3-max-44640, 44655: Xid 109) and RTX 2080 (44643, 44654: Xid 13
MMU Fault): the semaphore never signals; 1 s waits return VK_TIMEOUT and the counter read
succeeds with the old value; an unbounded vkWaitSemaphores had not returned after 60 s. Every
later vkQueueSubmit of that device (same queue, the family's second queue, another family)
and vkDeviceWaitIdle return VK_ERROR_DEVICE_LOST; a second VkDevice runs. A wait for either
the faulted semaphore or a second one returns once the host signals the second, as the
completion thread's wake does, so a later submission's loss ends the hang.
- RADV Mesa 26.2.6, 780M Phoenix and RX 7900 XTX (44635, 44643): GPUVM fault and ring reset; the
semaphore signals after 2.0-2.1 s, later submits return VK_ERROR_DEVICE_LOST, a second device
runs.
- Intel Windows 1.3.215, UHD 630 (44620, 44642): the counter reads UINT64_MAX at once, the next
submit returns VK_ERROR_DEVICE_LOST, a second device runs.
- ANV Mesa 26.2.6, Iris Xe RPL-P (44641): no fault; the store completes.
- Through the harness (a described workload: a store through a pointer to 0x10000, and a store
64 TiB past a 16-byte buffer): old completed both without a fault or an error on all six GPUs;
new refuses the pointer kernel (the translator's IdentityDomains) and completed the other
without a fault.
The gb play's hang (replay, frame 1095) was this: its #382399 was submitted and its kernel hit
Xid 13 on the 3090 (readout m3-max-44566).
The replay's rt backend skips buffer-to-buffer copies and the guest-RAM
copies that need one, so their destinations are never written on rt: the lead
suspect for gb's hang and b2's device loss on the 780M. This builds the copy.
One vkCmdCopyBuffer region between the bytes shaders reach (a Managed buffer's
device copy where the device keeps one), between a fill's two barriers: the
first after every earlier command (paying an owed barrier, hazard sets start
again), the second making the write visible to every later command; a copy
into a Shared buffer marks the segment so its end reaches the host. The
command buffer keeps both buffers until it retires; textures over either
device copy are settled as the other copies settle them. A size of 0 records
nothing.
Refused: another device's buffer (OtherDevice); a range past either buffer's
end (new Refusal::BufferCopyRange, Metal's validation); an offset or size not a
multiple of 4 (new Refusal::BufferCopyUnaligned, Metal's documented macOS
rule); a source and destination sharing bytes, one buffer's overlapping ranges
or two buffers overlapping in one block (new Refusal::BufferCopyOverlap:
vkCmdCopyBuffer forbids it, VUID-vkCmdCopyBuffer-pRegions-00117, and the
runtime does not emulate it).
Tests: a host test pins the checks (offsets in the device buffer, adjacent
buffers of one block, size 0 anywhere, each refusal); on_device copies between
two buffers of one block and within one buffer, the bytes checked and
everything around kept, one copy alone one submission, three barriers, one
pass and no bytes copied; a copy into a Managed buffer lands in the bytes
shaders reach, brought to the host by a synchronize. README blit section;
REFUSALS.md and api_signatures regenerated.
Verified: the lint job and the device legs are the check.
The rt backend skipped every texture over a buffer, every texture view and every IOSurface
texture, and with them each dispatch and blit that bound one: words in the program's memory
then named textures the play never made. Textures over a buffer now play as the runtime's
(Buffer::new_texture) and views as its views (Texture::new_texture_view). An IOSurface texture,
a tiled texture over a buffer, and a texture or view the runtime answers with a typed gap become
an ordinary texture of the same descriptor, counted as a substitution (the recording's artefact,
not the runtime's). optimizeContentsForGPUAccess plays as nothing; the blits still not built are
counted by kind: buffer copies, guest-RAM copies in and out, texture syncs and mipmaps.
The report's second line says how far relocation reached: words relocated, words left at 4
past 8, address arguments, writes into objects with no recorded range, and the objects whose ID
differs from the recording's, which now make the play an error.
The relocation tests assert the writes of no address are counted.
pipeline::compile::tests::the_inputs_encoding_is_the_earlier_derived_debug
compares the key's inputs encoding with the derived Debug of the three
earliest fields, stripping each later field at its default. push_base is a
later field whose default the encoding leaves out (key.rs appends it only when
nonzero), so the derived Debug's ", push_base: 0" is stripped as unit_axes'
is. Failed in lint m3-max-44489 at 40b807c2f7; nothing else in the
translator suite failed there.
Verified: the rerun lint is the check.
Lint m3-max-44458 at e26434bca8 failed to build the translator's tests: the
serde round-trip literal of LoweringInputs lacked the new push_base field,
and the engine test's closure, with its parameter type inferred, held the
borrow of the fragment inputs past the push_base assignment. The literal now
sets push_base 24 so the round trip covers it; the closure names
&LoweringInputs, so each call borrows only for its own duration.
Verified: the rerun lint (full translator suite) is the check.
On Device::from_queries' profile (PushWindow::Floor) a vertex function's push window is [0, 256)
and a fragment function's [push_base, 256), where push_base (a new LoweringInputs field, keyed
only when set) is the vertex function's push end rounded up to 8
(CompiledFunction::fragment_push_base). compile_render_pipeline compiles the fragment from the
vertex it compiled; rt sets the base from the lowered vertex before lowering the fragment. Under
the identity domains a vertex or fragment function whose fields do not fit is refused,
Unsupported(IdentityDomains) with maxPushConstantsSize's limit, never spilled. Link refuses a
fragment whose fields start inside the vertex function's, InvalidDescriptor(PushBase). The fixed
windows of Device::new (vertex [0, 64), fragment [64, 128)) and a compute kernel's are unchanged;
a mesh pipeline's fragment keeps its start past the mesh window.
Why: the planner ruled the dense layout over the census of gb and b2 (job m3-max-44421, every
content's functions resolved at its creation): 267 and 259 translated pairs, at most 248 bytes,
none over 256; four fragment bases (8/16/24/40), and no fragment function meeting two, so the base
costs no extra lowering. A fixed 128/128 split loses 3 pairs in each stream; the old 64-byte
windows spilled 6 into a parameter block.
Tests: push.rs pins each kind's window on both profiles (a compute kernel's does not move with a
render base) and places a fragment from its base to the floor's end; engine_identity_render
compiles colored_vertex + sampled_fragment on from_queries with the fragment's fields at 16, and
refuses the fragment compiled apart at base 0 (PushBase) until it compiles under the vertex's base.
The floor already refuses a device under 256 bytes (tests::floor, maxPushConstantsSize 255 and 64).
Verified: cargo fmt; api_signatures blessed, REFUSALS.md regenerated. Lint and legs follow.
The step-1 docs said 1,641 render contents over gb and b2, 1,631 drawing only triangles. The census
behind them keyed contents on the recorded linked-function handles, which a stream reuses for later
objects once one is released, so one content counted many times. Resolved at each creation (job
m3-max-44425, render_cold over gb and b2): 537 contents drawn (gb 273, b2 264), 527 only triangles,
2 lines and triangles, 8 only lines, as before.
Verified: docs only; the counts are job m3-max-44425's.
The RTX 3090 with the split probe (b15b306d2f: development's merged entries plus per-command-buffer
timing, M2V_PROBE_IN_FLIGHT), IN_FLIGHT two against three:
- frame_5cb, eight alternating arms (m3-max-44546): mean commit-to-complete 183.2-187.9 us at two
against 152.2-164.8 us at three, 13% less; wall p50 124.8-125.6 us against 127.5-136.0 us,
+3.2% at the median, at the 3% line.
- long_4cb (m3-max-44525): mean commit-to-complete 44.3 and 67.2 ms at two against 32.6 and
32.9 ms at three; wall p50 37.0-37.4 ms on both.
- burst_160 (m3-max-44525): 2891.4 and 2914.4 us at two against 2894.8 and 2912.1 us at three.
With the UHD 630, RTX 2080 and RX 550 rows already in the doc (m3-max-44424, 44423, 44437), three
is ahead on commit-to-complete on every device, the burst flat on each. The constant's doc gains
the 3090's line. Doc only: the branch's check (m3-max-44521) and legs ran at 136442db7a.
The RX 550's split at three (m3-max-44437, b15b306d2f) kept burst_160 at 879.7-881.9 us against
880.9-881.9 us at two, and frame_5cb's wall at 65.9-66.0 us against 66.8-70.3 us. It saw
long_4cb's second command buffer 0.9-1.4 ms after its end at the median, against 14.9 ms.
Four in flight lost on two rows. On the UHD 630, burst_160 took 2768-2839 us against
1850-1860 us at three (m3-max-44443). On the RTX 2080, long_4cb's mean commit-to-complete was
78.1-78.2 ms against 42.8-43.2 ms (m3-max-44442). So three is where the count stops, and the
constant's doc says why. The README's known gap gives the lateness measured at three on the 2080
and the RX 550.
With two in flight, a queue's next command buffers wait in a group until a completion leaves
fewer than two. Whenever that completion comes late, the GPU idles between the group's end and
the next submission's start. Behind three it has one more submission queued.
Measured with the split probe (b15b306d2f: the merged entries plus per-command-buffer timing,
M2V_PROBE_IN_FLIGHT; order old, new, three, three, new, old; 200 runs a row):
- UHD 630 (m3-max-44424): frame_5cb 420-429 us of mean commit-to-complete against 895-1137 us
at two (old 318-951 us), wall p50 278-303 us against 647-793 us. burst_160 1834-1849 us
against 1840-1841 us. long_4cb's second command buffer seen complete 74.7 ms after its commit
against 99.2 ms.
- RTX 2080 (m3-max-44423): frame_5cb 161 us against 148-181 us, wall p50 124.8-126.8 us
against 124.7 us; burst_160 2814-2821 us against 2811-2820 us; long_4cb's second 76.5 ms
against 96.8 ms, the row's mean 42.3-42.8 ms against 57.8-58.5 ms (old 76.8-77.8 ms).
IN_FLIGHT is the crate's constant for that count, and the tests take it from there:
behind_busy (was behind_two) commits that many busy command buffers. The new test
every_device_keeps_three_submissions_in_flight_and_holds_the_fourth pins the count. Behind two
running command buffers a commit goes at once, alone, and the next is held, both seen before
the first busy one ends on the GPU. With two or four in flight the test fails.
Docs: the constant's doc, the README's queue paragraph, the CommandBufferStatus::Scheduled,
abandon and send_now docs, and the across-queue metrics' docs say three.
A spike frame's wall time needs a split by cause before two runtimes can be compared on it. The
player now times, on its own thread, each kind of work: reading and decoding the stream and its
blobs, writing bytes into the runtime's memory, reading back, waiting for command buffers, the
calls that make or release resources (with the longest one), the calls that make libraries,
functions and pipeline states (with the longest one), every other runtime call, and reading the
runtime's counters; what is left is the player's own work. Beside them, a frame's GPU busy time
is the union of the GPU intervals of the command buffers it waited for, which a new Backend
method gives: both runtimes' GPUStartTime and GPUEndTime. The end line carries them, and the old
runtime's counters add its vkCreate*Pipelines and shader-cache nanoseconds.
A test plays three command buffers, two of them overlapping on the GPU, and checks the frame's
GPU busy time counts the overlap once and the end line holds the times.
On the RX 7900 XTX (44448) the test timed out after 60 s waiting for a submission. With 16 fills
the busy work ended before the fill was staged, so the fill went alone and no group was held.
The empty or abandoned command buffer behind it then took no submission, as it should, and the
test waited for a rise that could not come. The test now reads whether the fill was held (two
submissions since the busy commits) before it commits the command buffer behind. Where the fill
was not held, the test waits for the fill and tries again with more busy work. The rise is
waited for only behind a held group, which goes at once under the rule and only after a
completion without it, so the test still fails without the rule.
Since 4eb40a7e9e, a command buffer with nothing for the GPU that finds its queue holding a group
sends the group at once. The merged-entries test, written before that rule, committed its empty
command buffer between the Shared fill and the signalling fill. Landed together (5345d32f34), the
empty one sent the held first and Shared fills as a submission of their own. So the mix passed
three submit infos in groups, not two, and the test failed on lavapipe (check m3-max-44453).
The empty command buffer now comes after the signal, which has already sent the group. It takes
no submission and joins no group, and the three fills share one info as the test means.
A command buffer with nothing for the GPU, or one ended with an error (an abandon, a commit
after its end), that found its queue holding a group joined that group and retired with it. The
group went only when a completion left fewer than two submissions in flight, or at a host wait
for one of its command buffers. So that command buffer's completion waited on something not yet
submitted: a later completion or a wait. The planner's rule: nothing on the completion path
waits on a condition that something already submitted does not guarantee. Such a command
buffer still joins the group and retires in its place, after the command buffers before it as
Metal orders them. The group now goes at once, as a host wait for it would send it
(Fifo::behind_held raises send_through to the group's first place), and abandon wakes the
submit thread to send it. Nothing changes for one that finds no group held. The 10,000 empty
commits still take no submission.
The timestamp read's contract is unchanged, and its doc says why it holds.
Pending::stamps_written counts the segments the submit thread staged into its queue's group.
That group is always submitted, before any later one. At a loss or a failed submission the
command buffer ends DeviceLost, and its timestamps are never read. So the completion thread's
waiting read of a command buffer that completed with both stamps counted only waits on queries
written by a submission it saw complete.
Tests: every_device_sends_the_held_group_a_command_buffer_without_a_submission_retires_behind.
Behind two busy submissions a fill is held. An empty command buffer, then one ended NotRun by
abandon while it waited behind the group on an event never set, each has the group submitted
before the first busy one ends on the GPU. Without the change the group goes only once that one
completes, so no try checks and the test fails.
every_device_retires_a_group_in_commit_order_each_with_its_own_times now commits the ended one
after the three it groups with, since it sends the group.
README: the queue section says so.
A play hung with the main thread in a wait and every rt thread idle, on a build with today's
empty-command-buffer path (59f4094a65), the two-value timestamp read (0383fdbded) and the fence
type (9a9135b4c9). This test commits the chains those paths take and waits for each with
wait_until_completed on a thread of its own, failing at PATIENCE where a wait does not return,
then reads the GPU times as a consumer does:
- an empty command buffer committed while its queue holds a group (behind_two);
- an empty one as the last commit before a wait;
- a fence-only one between two that fill (update, then a wait and a fill);
- two empty ones on a queue that never submitted, then behind work that completed;
- empty ones and a fence-only one with a second queue's commits between them;
- one ended NotRun after its first segment was submitted (an event wait the host never meets,
then abandon);
- one whose only segment signals an event, then one whose only segment waits on it.
Every completed handler must run.
Verified: on lavapipe and the device legs, in the jobs that follow.