rate_map_costs (ignored, report only): a one-layer map over a 3840 by 2160 screen
whose quality falls from 1 at the centre to 0.3 at the edges, 256 indexed draws of
small rectangles a frame (half encoded, half through an indirect command buffer),
against the same frame over no map. Prints the draws, viewports and scissors the
device recorded a frame, the draws a guest draw becomes, and the CPU per guest draw
and per recorded draw. Not yet run.
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.
Reverts the reorder of 6ac366a168 in BindState::has_shape_beside_used; is_of's class-first
comparison and its answer for an empty argument sampler list stay.
Why: with every other field compared before the stage tables, a kept shape that only the tables
tell apart (the scene's materials cycling three texture sizes, RecentShapes::find's usual
miss) paid every other comparison first, FunctionTablesShape::of and is_of among them, before the
first slot's shape set it apart. Job m3-max-22316 (gem10, lavapipe, release, base cea84c33c9 against
6ac366a168): instructions a draw 36450 -> 36878 in the scene and 40176 -> 40595 in the rebinds
scene, both up.
Verified: the measurement against cea84c33c9 follows in the landing message.
LiveBind::shape finds a reshaped state's shape among the shapes it took lately
(RecentShapes::find), comparing each with BindState::has_shape_beside_used, latest first. On
lavapipe, in a scene whose materials cycle three texture sizes, that comparison was 92% of
LiveBind::shape's instructions: the slots' shapes worked out as they are compared (a sampler
slot's BoundSampler::shape 18%), and ArgumentSamplersShape::is_of 15%, which filled a 64-entry
array of shapes before it compared the capacity class, also for a state with no argument
samplers (perf, job m3-max-22239).
- is_of compares the class first, and answers a list of no sampler at once: the shape of no
sampler is the one with no shapes, as ArgumentSamplersShape::of(&[]) makes it.
- has_shape_beside_used compares every other field before the stage tables, so a kept shape
another field tells apart (draws alternating a primitive type, which picks the viewport
compensation and the band) is passed over before any slot's shape is worked out. The answer is
the same conjunction of the same comparisons, none with a side effect.
tests/bind_shape_of.rs compares has_shape with shape() == over every pair of its states, an
empty argument sampler list among them.
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.
An Iris boot lost its VkDevice to one float written into an ANV batch buffer right after the
boot's one copied no-copy buffer was made. A copy's merge back writes exactly the bytes the GPU
changed into the caller's pages, one 4-byte store for one changed float, so a caller mapping
unmapped under a live no-copy buffer and reused for a batch mapping would show that symptom. The
memory log (METAL2VULKAN_LOG_MEMORY) placed only device addresses, so it could not test that.
With the log on, the copied registry (copied.rs) now says one line as each copy is made and one
as it goes: its number, the caller's pointer and length with the range's end, and the copy's
host address and end, the two ranges the runtime's comparisons write on the CPU. The going line
is said after the registry's lock is let go, as the consumer's sink takes it. Off, nothing is
formatted: the registry holds no log.
Verified: fmt only here; the new tests::memory line test, clippy and rustdoc run on a CPU node
next.
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.
What: tests::host_ram_copy_device::a_first_scatter_over_chunks_the_thread_imports_is_in_its_pages_once_it_completes
read one of the scatter's pages from a command buffer of another queue ordered after the scatter
by commit order alone. It now waits for an MTLEvent the scatter's command buffer signals after the
scatter and its later encoder, the order Metal gives a program across queues. host_ram/copy.rs's
staged-scatter paragraph said every command in a later command buffer runs after the CPU's copy;
it now says a later one that runs after it does, and names the give-way window.
Why: since b46459080d (a batch held for its host step before its gate gives way to later commits
of other queues), the scatter's first batch, held for ScatterStage's step (which waits for no GPU
work, so takes no gate), and the drain's batch after it on its line give way: a later commit of
another queue that shares no fence with them goes first. Where the reader's commit reached the
scheduler while the stage's step still ran, the reader went first and read the page's bytes from
before the scatter: msi lavapipe, m3-max-22289 at 21342840fe, line 1929. The test last passed
before b46459080d (m3-max-22001 at 892b1ac1e8, whose tree lacks it); m3-max-22087 and 22141 did
not run it. Reading first is inside Metal's range: conformance probes/cross_queue_surface_order.m
saw x86 Macs take a later commit of another queue first for one tracked buffer, and run two
no-copy buffers over one allocation unordered on every Mac measured; so the test's leg asked
more than Metal does, and the product is unchanged.
Verified: see the job in the landing message (one run of host_ram_copy_device on lavapipe).
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 commits before this one refuse a specialization whose present arguments of one table (buffers,
threadgroup memory, textures, samplers) take overlapping slots: canon::interface::entry() checks each
table's resolved ranges, skips arguments a constant removes, and binds no slot for a count of 0. The
refusal names the later argument, as Metal does (RequestError / DescriptorError::OverlappingArgument
{ param, index, count }). Metal on the M3 refuses such a specialization in
newFunctionWithName:constantValues: with "<kind> argument X has invalid location (<index,count>)",
measured for buffers, constant and argument buffers, visible and intersection function tables,
acceleration structures, textures, texture arrays, samplers and threadgroup memory; different tables
never conflict. Before, the translator went on and failed later (Lowering(Sampler) or
Lowering(Texture)), or translated a specialization Metal refuses.
Owned fixture engine/overlapping_slots (with its probe): dst at texture(1), src at texture(n); n=1 is
refused, n=0 samples as Metal does.
Verified:
- The M3 (m3-max-22104, 22106, 22107, 22112, 22255): Metal's wording per kind; the fixture's n=1 refused
("texture argument src has invalid location (<1,1>)"), n=0 writes 1 2 3 4.
- lavapipe, runtime_lane::overlapping_slots (m3-max-22257): n=1 refused with
Compile(InvalidDescriptor(OverlappingArgument)), n=0 writes 1 2 3 4, the validation layer silent.
- macOS 27's 590 MPS functions, every constant 0 (release, m3-max-22163): 42 rows move to
InvalidDescriptor(OverlappingArgument) (35 Lowering(Sampler), 2 Lowering(Texture), 5 that translated a
specialization Metal refuses), no other row changes; with the batch-size constant 1 all 42 translate
and pass spirv-val (m3-max-22170).
- The metal2vulkan suite (gem10, m3-max-22256): clippy clean; the failures are the golden tables' new
rows, re-blessed on development.
- tests::engine_function_constant_interface::two_textures_on_one_slot_are_an_invalid_request:
on every committed profile, overlapping_slots with n = 0 compiles and passes L3, or needs the
storage texture's format where the profile cannot write one without it. With n = 1 it is
InvalidDescriptor(OverlappingArgument { param: 1, index: 1, count: 1 }), which names src.
- runtime_lane::overlapping_slots: under the validation layer on the device, the runtime refuses
n = 1's compute pipeline state as Compile(InvalidDescriptor(OverlappingArgument)). With n = 0,
4 threads sample 1 2 3 4 through the default sampler state and write 1 2 3 4, Metal's words.
An owned fixture with a write texture at texture(1) and a sampled texture at texture(n), where n is
function constant 0. It has the shape the MPS kernels state through the static initializer.
n = 1 puts both on slot 1. n = 0, which is also what an undefined n reads, keeps them apart, so
the suites that compile every public fixture without constants get a kernel; it samples a 4 by 1
texture at each texel's centre and writes the sample out.
- engine/overlapping_slots.metal, its .ll and .air.ll companions and TOOLCHAIN line (regenerated
on the M3 Max, m3-max-22255).
- probes/overlapping_slots.m: on the M3 Max (macOS 27.0.1), n = 1 fails when Metal makes the
function ("texture argument src has invalid location (<1,1>)"), and n = 0 writes 1 2 3 4 for
texels 1 2 3 4.
Function constants can set an argument's slot ([[texture(c)]]; the frontend states the index as a
global the static initializer computes). Values that put two present arguments of one argument
table on overlapping slots make a specialization Metal refuses when it makes the function: "<kind>
argument X has invalid location (<index,count>)", naming the later argument. Measured on an M3 Max
(macOS 27.0.1) for:
- buffers, a constant buffer and an argument buffer;
- a visible and an intersection function table, and an acceleration structure;
- textures, and a texture array overlapping a range;
- samplers;
- threadgroup memory.
Arguments of two tables at one index (a buffer and a texture at 0) are made.
The translation took such a set as valid and went on. Where a write texture and a sampled one met
on slot 0, the slot plan gave the slot the write access and the sample was refused as
Unsupported(Lowering(Sampler)), NotImplemented: a gap that is not ours. Where the two arguments'
uses agreed, one resource stood for both, a pipeline Metal never makes.
The specialized entry now refuses it (canon::interface, beside the duplicate color output check),
as RequestError::OverlappingArgument { param, index, count } and
DescriptorError::OverlappingArgument. Only present arguments count (MPS keeps gated pairs on one
index), and a count of 0 binds no slot. past_table and the new check share one table map.
API.md, the runtime's new_function_with_name_constant_values doc (the runtime checks constants
when a pipeline compiles the function) and the specialization planner's doc say so. The
signatures table is re-blessed; REFUSALS.md is unchanged (this is a refusal Metal makes).
Verified: the canon test covers each table and the non-overlapping cases. The MPS census A/B
(590 rows, every constant 0, release CLI on msi, base 9c2635b430) moves 42 rows to
InvalidDescriptor(OverlappingArgument): the 35 Lowering(Sampler) rows, 2 Lowering(Texture) rows,
and 5 rows that translated a specialization Metal refuses. No other row changes. With constant 125
(the batch size that puts the sampled texture after the written one) set to 1, all 42 translate
and pass spirv-val.
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 commit before this one adds CommandBuffer::label/set_label and label/set_label on the blit, compute,
render and resource state encoders (MTLCommandBuffer.label, MTLCommandEncoder.label), each EndedEncoder
reporting its label (EndedEncoder is #[non_exhaustive]). The DeviceRecovered notice now names the hung
command buffer and its queue by label and lists its first 32 ended encoders by place, kind and label
(the places CommitFailure and the draw-dropped notices number), the kinds and places alone where nothing
is labelled. Why: an Iris boot's GpuHang (46 victims) left nothing to tell which work hung.
Verified (gem10, m3-max-22325): clippy -D warnings (default and --cfg m2v_cpu_icd), rustdoc -D warnings,
and lavapipe 11/11 for tests::labels (both render lowering policies) and all of tests::device_recovery,
the relayed-loss test asserting the whole labelled notice; signatures.py, metal-coverage and
conformance-coverage --check locally.
A lost VkDevice's recovery notice named its hang only as "a command buffer (of queue `Q`)",
so an Iris boot's GpuHang (46 victims) left nothing to tell which work hung. The runtime had
no label for a command buffer or an encoder at all.
CommandBuffer::label/set_label (MTLCommandBuffer.label) and label/set_label on the blit,
compute, render and resource state encoders (MTLCommandEncoder.label) now keep what the
program sets. A command buffer has one encoder open at a time, so the open encoder's label
lives on the command buffer's state, and the encoder's record takes it as it ends: each
EndedEncoder reports its label, in its place, a render encoder that ends on the lowering
thread included. The recovery names its culprit from the command buffer's state as it fails
the pending batches: its label and its queue's, then its first 32 ended encoders' places,
kinds and labels, counting the rest, e.g. "command buffer `busy` of queue `relayed` (its 1
encoder: 0 blit `copies`) failed as the hang (`GpuHang`)".
set_label and label are no calls in EncoderCall's numbering. The API table, the Metal and
conformance coverage maps, docs/API.md's DeviceRecovered entry and the runtime README say so.
The table's WorkCounts::spare_command_buffers_freed_past_recorded line moves to where the
script sorts it.
Verified: fmt only on this machine; tests::labels (both lowering policies) and
tests::device_recovery's relayed-loss test, which asserts the named notice, run on lavapipe next.
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.
A device test of the pipeline names: with a message sink, the compute state's variant names its
pipelines "scale_and_offset" (the kernel); without one, it works out no name. A test-only
accessor reads the name off the state's creation variant.
Where the instance reports messages (VK_EXT_debug_utils), each pipeline now carries a debug
name, which the layer prints after its handle. Until now only a raster-order pipeline was named,
so a synchronization report could not tell a program's kernel from one of the runtime's own.
- A program's pipelines are named by its Metal functions' names, in pipeline order, joined by
" + ". Each variant's objects keep them (`VariantObjects::name_pipelines`), set where a
compute variant is made (`pipeline/mod.rs`) and at each render variant's making
(`RenderVariant::of`). A pipeline library is named the same, with its part in parentheses.
An indirect-bindable replay pipeline takes its variant's names.
- The runtime's own pipelines are named "metal2vulkan: " and the kernel or step: each owned
kernel by its module (for example "metal2vulkan: PagesCopy(Gather)"), the split, merge,
resolve, copy and plane steps by their kind, the in-place check's draw, and the priming's
kernels beside its pipeline.
- A raster-order pipeline keeps its name alone, since the validation crate's lanes match it whole
(`raster_order_gap.rs`).
- A name is worked out only where the instance reports messages
(`DeviceShared::name_pipeline` takes a closure), and nothing reads it: it is a diagnostic,
and no translation or runtime path depends on it.
Why now: a sync-validation run on the XTX (SYNCVAL_SHADER_ACCESSES_HEURISTIC) reported 45
WRITE_AFTER_WRITE hazards. All were vkCmdDispatch after vkCmdDispatch, on one pipeline, at storage
binding 1 of a pushed set 0.
What the code points to, which the next run's names will confirm or not:
- The runtime's pushed kernels are RowsCopy, PagesCopy and the shadow copies and merges. Of
those, the ones whose binding 1 is a written storage buffer are PagesCopy(Gather), RowsCopy
and ShadowCopyBack.
- Only PagesCopy(Gather) records several dispatches in a row with one pipeline in one command:
one per guest RAM chunk the runs touch (`host_ram/copy.rs`). Every one of them binds the same
window of the destination buffer at binding 1.
- That path is taken only when no destination byte is written twice (`twice()`; a gather whose
runs share a buffer byte takes regions instead), so those dispatches write disjoint words.
The tracker orders the copy as one command over its whole span.
- The heuristic counts each dispatch as writing its whole bound range. So these would be
reports of disjoint writes, not a missing barrier.
- Guest kernels push set 0 too, so a program's kernel in a concurrent compute encoder is not
ruled out. That is what the names settle.
Docs: HOWTO section 8 says what the names are.
New rows and the printout for the owned fixture ipr_reads (RUNTIME_VERSION 2137's in-place reads): no
existing row moves.
Verified: bless on the M3 at cea84c33c9 (m3-max-22291): golden hashes, engine goldens, printouts and
inventory blessed, 99 lines added and none changed; merged check at the same sha on msi
(m3-max-22290): clippy every crate with --cfg m2v_gpu, api_signatures, api_surface, fast_paths,
rustdoc -D warnings.
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 commits before this one:
- Spares: a command buffer whose recordings (its host steps' included) reach spares::RECORDED (16,384
commands, about 0.6 MiB of ANV's dynamic state pool) frees every command buffer of each pool it gives
back, on the device's free thread, and the pool rejoins the spares stocked with a secondary. Rate-mapped
passes record each draw once per region; on ANV (Mesa 26.2.6, Iris Xe) each takes about 100 bytes of a
device-wide 1 GiB dynamic state pool, and the spare pools kept those recordings. A guest's core (rate maps,
ICB passes replayed at about 880k region draws a host step) held the whole pool: 2985 command buffers,
1023.7 MiB, 9 of them 92-112 MiB, the one recording 97.5 MiB with OUT_OF_DEVICE_MEMORY; ANV then wrote
SF_CLIP_VIEWPORT through a null state and QEMU took a SIGSEGV. Counted:
WorkCounts::spare_command_buffers_freed_past_recorded. FAST-PATHS records the gap left: about 200 MiB a
heavy guest command buffer with one draw per region, about five alive at once fill the pool.
- Heap uses: the heap's list holds Weak<Retain>; textures_from upgrades under its lock and builds the
handles outside it, so a heap use never lets go of a texture handle on a runtime thread (the latent drop
RUNTIME_VERSION 2128 left: a race between a program's last drop and the heap walk).
- Tests: the spares' fewest test begins a primary ahead in every spare before its small command buffer
takes one, so its take no longer depends on a gate wait's timing. The opt-in Iris probe
runtime_lane::rate_mapped_volume (m2v_gpu_hazards) prints each round's counts and DRM memory.
Verified:
- Iris Xe (ANV, Mesa 26.2.6), the probe (16 rounds x 2 heavy command buffers of about 811k region draws,
2304 regions), DRM memory high-water: without the fix 731 -> 751 MiB (m3-max-22221), with it 522 -> 534
MiB (m3-max-22260), spare_command_buffers_freed_past_recorded 222 then +190 a round. Neither reached 1
GiB; the guest's repro is the consumer's.
- lavapipe: spares 23/23 (m3-max-22076); heap and residency modules 112/112 (m3-max-22065); spares 22/22
with the fewest test (m3-max-22066). clippy default, --cfg m2v_gpu, --cfg m2v_cpu_icd and the hazards
config, rustdoc (m3-max-22018, 22060, 22074, 22075, 22279).
small_command_buffers_leave_the_pools_holding_the_most_to_the_large_ones failed once under load
on msi (m3-max-21956, tests/spares.rs:940): its small command buffer took a large command
buffer's pool of 199 command buffers. A taker takes a spare holding a primary begun ahead first
(take_command_pool). A settled pool given back begins one only where no thread waited on its
command buffer's gate as it completed. The test's run() waits on each command buffer in turn,
so which spares held a begun primary depended on when each completed. Where only a large pool
held one, the small command buffer took it, as designed.
The test now begins a primary ahead in every spare (Spares::begin_ahead) before it takes its
snapshot, so the spares differ only in what they hold, which is what the test is about. The
runtime's rule is unchanged.
Checked: the spares tests on lavapipe (job id in the report).
Heap::textures_from upgraded every texture of the heap's list under its lock, then let go,
with the lock free, of each one that no program handle held (Texture::for_heap_use, RV 2128).
If the command buffer that held such a texture completed in between, that let-go was the
texture's last handle, and the texture's release ran inside the heap use: on the encoding
thread, or on the scheduler's steps thread in a host step's sync_heaps, outside any passing
hold (resource_ids.rs).
The heap's list now holds each texture's Retain weakly. Retain(Weak<TextureShared>) is made
with the texture (Arc::new_cyclic). textures_from upgrades the retains, which only the
program's handles hold, and reaches each texture through its retain (Texture::heap_use). A
texture no program handle holds is never taken. A retain that outlives its texture's last
program handle drops holding the texture weakly, so it never releases the texture.
Behaviour is otherwise unchanged: the same textures are made resident. Checked by the existing
heap-use tests (tests::heap_use_released, the residency and heap suites) on lavapipe. No
deterministic test exists for the race itself: it is a let-go between two threads that the
structure now rules out.
The probe's docs said each round's heavy command buffers took pools no heavy one used. The
Iris runs show otherwise: without RECORDED's frees the spares were taken 4 a round after the
first (the heavy command buffers took the round before's pools, holding the most), and the
process's DRM memory reached 731 MiB in the first round and 751 MiB by the last; with them,
34 a round, 190 command buffers freed past their record a round, and 522 to 534 MiB. Neither
filled ANV's pool. The docs now say what the probe does and what it measured.
Verified: Iris Xe (Mesa 26.2.6) before m3-max-22221 (705c06813f), after m3-max-22260
(ad7c1e30c3, the tree of this branch before this commit's docs and the gap's wording).
ANV's block pools never shrink, so the DRM memory a round reports is the high-water mark of
what its command buffers held of the dynamic state pool at once, with their batches. A run
that does not crash still shows how near the pool's 1 GiB the recordings came, before and
after the spares free a pool's command buffers past RECORDED.
Verified: run on the Iris Xe as the before (705c06813f) and after (dynpool-after3) runs.
A scan of every ANV command buffer in the crashed guest's core found the 1 GiB dynamic state
pool held in full (1023.7 MiB over 2985 command buffers). Nine held 92 to 112 MiB each: the
crashing recording, and four earlier command buffers whose two passes (one vertex binding,
then four) each replayed an indirect command buffer over the rate map, two to a pool. So a
guest's command buffer of one draw per region holds 184 to 224 MiB, and about five alive at
once fill the pool. The gap says so as today's measure, not as a bound, since a route that
records fewer commands per region changes it.
Verified: docs only; the scan is m3-max-22188 (core read in place, streamed).
ANV takes about 110 bytes of its 1 GiB dynamic state pool for each region draw. A guest's host
step recorded about 880,000 region draws, and a command buffer of such steps held 97.5 MiB in
the core. A region draw counts three commands: its viewport, its scissor and its draw. A pool
whose command buffer recorded fewer than 16,384 commands therefore keeps at most about 0.6 MiB
of the pool, where 65,536 let it keep about 2.4 MiB. The spares device test draws 16,384.
A rate-mapped pass records each draw once per region of its map, each with its own viewport and
scissor. On ANV (Mesa 26.2.6, Iris Xe) every such draw takes about 100 bytes of a device-wide
dynamic state pool of 1 GiB. A command buffer holds what its recording took until it is begun
again, reset or freed, and spare pools kept their command buffers' recordings for later takers.
A guest's ICB passes over a rate map, replayed by host steps at about 880k draws a step, filled
the pool with four command buffers alive. The core showed the "dynamic pool" block pool at its
1 GiB maximum, one command buffer holding 97.5 MiB of it, and its batch status
VK_ERROR_OUT_OF_DEVICE_MEMORY. ANV then wrote the next SF_CLIP_VIEWPORT through a null state
inside vkCmdDrawIndexed, and QEMU took a SIGSEGV.
A command buffer now counts the draws its recordings record (its host steps' included) with the
state commands they set (CommandBuffer::recorded, counted at render.rs's draw loop). Where the
count reaches spares::RECORDED (65,536), each pool it gives back sheds every command buffer it
holds, freed on the device's free thread as an idle spare's are, and rejoins the spares stocked
with a secondary. Below the bound nothing changes. The rerun check's pool passes its command
buffer's count. A kept chunk's pool passes 0, since its draws count in the command buffer that
recorded them.
Counted: WorkCounts::spare_command_buffers_freed_past_recorded (api_signatures.tsv). FAST-PATHS
records the gap that remains: command buffers alive at once that record enough to fill the pool
by themselves.
Tests: tests::spares::device::a_command_buffer_that_recorded_much_frees_its_pools_command_buffers
(lavapipe). The opt-in Iris probe runtime_lane::rate_mapped_volume (m2v_gpu_hazards) prints the
new count per round.
Heavy command buffers (a pass of 96 executions of an ICB's indexed draws, replayed by a host
step, over a map of 32 zones a side alternating full and half quality) committed two at a time
into spare pools left by 48 light command buffers, 16 rounds. Opt-in (m2v_gpu_hazards). Not for
landing as is: a probe of what the spares keep on ANV.
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 commits before this one take a draw whose fragment function reads, at its own pixels alone, a texture
its render pass instance renders as a color, and whose pipeline writes no channel of that color, in place:
feedback loop layout, a by-region barrier before it (Vulkan 8.10.5) and a by-region execution barrier
after it, with no copy, snapshot or split, with a Metal barrier before it or without. The Macs disagree on
such a read without a barrier (the M3 answers the texels from before the pass; the 5300M and the UHD 630
the earlier draws' writes, racily without a barrier and always with one): under the owner's rule we take
the cheapest form, the x86 Macs' answer, an accepted difference in docs/API.md. The snapshot route's note
now says why the pass's store after a reader is ordered: its reads run before color output (B2), and the
drawing draw's fetch never executes; so the 37 WRITE_AFTER_READ reports of the consumer's sync-validation
run (ddsync2-xtx) are the layer's shader-access heuristic, not a race.
Verified:
- Radeon 780M (RADV, m3-max-22274, at these commits plus one ignored cost test): runtime_lane::in_place_reads,
a private target and an IOSurface plane over a no-copy buffer, each with and without a barrier: every cell
counts Moved { in_place: 1, snapshotted: 0, splits: 0, copies: 0 } (WorkCounts::reading_draws_in_place);
the reader reads the earlier draw's value, a later draw's write lands after it, the rest stays cleared;
without attachmentFeedbackLoopLayout the copy (no barrier) or the split (barrier) as before; in_place_reads,
snapshot_reads and attachment_reads 22/22; in_place_reads under the sync validation layer 2/2, silent.
- lavapipe (msi, debug and under sync, m3-max-22227): 33/34, the one a test expectation fixed in the next
commit (lavapipe's passes fetch colors as input attachments, so in place is refused there as the
snapshot is).
Running: lint (default, --cfg m2v_gpu, --cfg m2v_cpu_icd), rustdoc, api tables and the lavapipe rerun
(m3-max-22240). The golden tables and the compile census take the new fixture ipr_reads at the next bless.
The validation layer's synchronization checks count the drawing draw's fetch of the texture,
which its pipeline holds and never runs, as a read with nothing after it, and report the pass's
store of the color as a write after that read (SYNC-HAZARD-WRITE-AFTER-READ at
vkCmdEndRenderPass, 37 reports in a sync-validation run on the RX 7900 XTX). It is a false
positive: no data race comes of an instruction never executed (the memory model), and the reads
that run, the snapshot draw's at its own pixel, B2 orders before the color output, the stage of
color store operations (Load and Store Operations; 8.10.1 too). The comment at B2 says so, and
record_after's says B3 orders a draw in place's reads before the store too.
Verified: comment-only; spec quotes checked against the local vkspec.txt (1.4.366).
A pass on a device with rasterization-order color attachment access (lavapipe) or without the
pixel interlock (the RX 550) fetches its colors as input attachments, and in place, like the
snapshot, takes no such pass (its subpass would name the color in two layouts). The lane test
asserts the read in place only where the device's passes fetch no color, and API.md, FAST-PATHS.md
and render/snapshot.rs say which devices keep the copy.
Verified: lavapipe lane job m3-max-22227 (msi) at e83d75fe83: 33 of 34 attachment-read, snapshot
and in-place tests passed, debug and under METAL2VULKAN_LANE_VALIDATION=sync; the one failure was
this expectation (lavapipe fetches through inputs: copies 1, in place 0).
A draw whose fragment function reads, at its own pixels alone, a texture its own render pass
instance renders as a color, and whose pipeline writes no channel of that color, now reads the
attachment in place, with a memory barrier before it or without: no copy, snapshot or split.
The color is in the feedback loop layout for its instance, the pipeline is made with
VK_PIPELINE_CREATE_COLOR_ATTACHMENT_FEEDBACK_LOOP_BIT_EXT, and the slot binds the texture in that
layout. A by-region barrier before the draw (color writes to fragment shader reads) orders the
earlier draws' and the load's writes before its reads (Vulkan 8.10.5), and a by-region execution
barrier after it (fragment shader to color output) orders its reads before later draws' writes.
Its own writes go to other colors, so no fragment of the draw races another over the texels it
reads. It reuses the snapshot route's checks (pass shape, view format, pins, one image) and its
binding (render/snapshot.rs, in place), on a device that enabled attachmentFeedbackLoopLayout.
Why: the real Macs disagree on such a read without a barrier (probe ownread.m: the M3 Max
answers the texels from before the pass at every pixel; the 5300M answers the earlier draws'
writes at 98.6% of pixels and at all after a barrier; the UHD 630 at all but 0.01%). Under the
owner's rule for such disagreements we take the cheapest form, the x86 Macs' answer, recorded as
an accepted difference in docs/API.md. A compositor's backdrop reads paid a copy of the whole
target per draw before.
texture/attached_reads.rs now gives a color's image feedback loop usage wherever the device
enabled attachmentFeedbackLoopLayout, not only where it has the snapshot route's write-mask
command. New WorkCounts::reading_draws_in_place (api_signatures.tsv row). The draw-key and
graphics-key carry a feedback_loop bit for the pipeline flag.
render.rs (the draw's snapshot plumbing) is touched at: the draw's snapshot request, the phase
hole, the counts, the snapshot views, the pair base and phases, Recording::record (the barrier
after), and settle_draw's snapshot checks.
Lane test runtime_lane::in_place_reads with an owned fixture ipr_reads.metal (regenerated with
scripts/regen-air-fixtures). The golden tables and the compile census are re-blessed on
development.
Verified: not yet compiled; potluck build, lint and lavapipe lane jobs follow.
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 commit before this one cuts the per-bind sampler path. The bind memo keys a sampler's description by
the state's address (held weakly, as a kept view's texture is), the clamp bits, the address map and the
facts, instead of comparing every descriptor field; in debug builds each hit works the description out
again and asserts it matches. The state's sampler cache is keyed by a description hashed once
(sampler::HashedDesc). The state still answers every bind, so what it keeps and forgets is unchanged. In
the scene shape's profile, 57% of image_descriptor's instructions were this path (the memo walk's field
compares 29%, vk_sampler 27%, of which hashing the full SamplerDesc 12%).
Verified:
- Instructions per draw on lavapipe, Valley's scene shape (gem10, m3-max-22231): scene 36,858 -> 36,420,
rebinds 40,569 -> 40,101; work counts unchanged.
- The sampler-related runtime tests 120/120 and lane 62/62 (msi, lavapipe, m3-max-22232); clippy (all
features, --cfg m2v_gpu), rustdoc and api_signatures (m3-max-22233).
A render encoder's binds keep the sampler descriptions they worked out (`BindMemo`). Each bind of
a sampler slot built the slot's descriptor (the state's, with the bind's LOD clamps and the
textures' address-mode map), then walked the kept descriptions comparing every field of that
descriptor, then asked the state for its `VkSampler`, whose cache hashed the whole Vulkan
description (every field, through `SamplerDesc`'s key) at every bind. On lavapipe, in a scene of
material changes, 57% of `image_descriptor`'s instructions were this path: the walk's 29%, and
`vk_sampler`'s 27% of which the description's hash was 12% (perf, job m3-max-22200).
- The memo keeps a description by what it is a function of: the state, by its address and held
weakly as a kept view's texture is (its allocation, and so its address, stays its while the
memo holds it), the clamps by their bits, the map and the facts. A state's descriptor and LOD
bias are fixed as it is made, so this is the same answer the descriptor's comparison gave, by a
pointer and a few words. In debug builds every memo hit works the description out again and
asserts it is the one kept.
- The state's cache is keyed by a description hashed once (`sampler::HashedDesc`): the memo keeps
it hashed, so a bind that finds its description there hashes nothing. The other binds (an
argument buffer's samplers, a heap set's sampler array) hash it as they ask, as before.
The state still answers every bind, so what it keeps and forgets is unchanged.
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 commit before this one reads the pass's color attachments once per draw (AttachedColors: image key,
level, layers, clears), and each texture the draw samples compares against those; attached_in,
cleared_in and attached_span go through the same function, so their answers do not change. Before, each
sampled texture read every color attachment's image again: 8 textures in a pass of 4 colors made 32
image reads a draw. In the consumer's Valley profile that was the ColorTarget compares, about 3.6% of
walking CPU.
Verified:
- Instructions per draw on lavapipe, Valley's scene shape (gem10, m3-max-22175, deterministic): scene
38,672 -> 36,857 (-4.7%), rebinds 42,377 -> 40,584 (-4.2%).
- The attachment-related runtime tests 77/77 and the lane's attachment modules 48/48 (msi, lavapipe,
m3-max-22177); clippy (all features, --cfg m2v_gpu), rustdoc and api_signatures (m3-max-22178).
`recorded` dropped its states and its device at once, then its callers read the shader cache
directory: the kernel's library record, which the device's cache thread writes, was missing once
on a loaded host (warm::an_unread_record_is_announced_and_the_pass_goes_on, warm.rs:614,
"removed 0").
A render state's creation waits for the makings it hands the pool a bound at most
(`pipeline_creation_wait`, 4.5 s); a making past it runs on and holds the device. Dropped
meanwhile, the state's piece gives back to the reaper, whose release is then the device's last:
the teardown, which drains the cache thread's queue, runs there after the test's drop returned,
and the directory is read before the record is written. That is read from the code, not
reproduced (the failing run printed no creation counts).
`recorded` now keeps the states until the pool is idle (each piece's hold given back to its
state, so the states' drop lets go of it on the test's thread), then drops them and the device,
and asserts the device went in that drop.
Verified: the warm and teardown_threads modules on lavapipe, and clippy, in the jobs named in the
report.
RenderLowering::samples_attachment asked Texture::attached_in (and cleared_in) of each texture a
draw samples, and each asked every color attachment of the pass for its texture's image: a draw
that samples 8 textures in a pass of 4 colors read the colors' images 32 times. On a
lavapipe shape of many textures and colors (draw_costs scene) samples_attachment was 10% of the
rebound draw's samples (attached_in 6.8% self); the guest profile of the same walk showed the
comparison of the pass's ColorTargets among its hottest leaves.
Now the pass's color attachments are read once a draw into AttachedColors (each one's image
key, level, layers and whether it clears), and each texture compares its image with those:
Texture::attached_among / cleared_among. attached_in, cleared_in and attached_span take the same
path through AttachedColors::of, so every caller answers as before; a pass with no color of an
image answers none attached without looking at the textures.
a_ram_of_shared_memory_a_device_refuses_imports_no_chunk_and_copies_its_objects made its object
at once after use_host_ram, while the device's thread may still have had the RAM's first chunk's
import (refused) in flight. An object whose pages a chunk import in flight holds is a copy for
that import (CopiedBecause::OverRamChunk, counted in copied_over_live_imports), not for the
device's refusal of its pointer, so copied_host_buffers_device_refused read 0 once on the 780M
under nextest's parallel load (m3-max-22087), and 3 of 3 alone passed at the base and the tip
(m3-max-22094).
The test now waits until the thread's import of the first chunk failed
(host_ram_pointer_imports_failed moved) and the object's pages can be claimed (no chunk import in
flight over them, Device::claim_ram_pages), then makes the object; the thread tries a chunk it
failed no more. The fixed 300 ms sleep after the object goes. The assertion's message names the
over-import copies, should the other cause show again.
New rows and printouts for the owned fixtures nullable_private (SEMANTICS_VERSION 2056), pooled_cells
(2057) and tns_air29 (AIR 2.9 tensors): 12 expectation rows, 3 printouts.
213 existing golden-hash rows move, every column of each: the kernels whose accesses SEMANTICS_VERSION
2055's lockstep analysis now proves apart (guarded spans, carry-free ors, lattice anchors) lose lockstep
barriers. That change's own run (m3-max-21908) showed golden_hashes failing for them; 2056-2058 moved
only new rows (m3-max-21897, 22021, 22061).
Verified: bless on the M3 at 9c2635b430 (m3-max-22109): golden hashes, engine goldens, printouts and
inventory blessed; merged check at the same sha on msi (m3-max-22108): clippy every crate with
--cfg m2v_gpu, api_signatures, api_surface, fast_paths 43/43, rustdoc -D warnings.