Commit Graph
1660 Commits
Author SHA1 Message Date
Anees Iqbal c027cc2cfa replay: skipped render pipeline states are counted by the runtime's gap
The report gave one line for every skipped render pipeline state, its
total and the first one's answer, so a stream's states refused for a
depth attachment, for framebuffer fetch or by the translator read as one
number. The planner's census of what the new runtime refuses needs the
count of each kind per stream.

The backend now keeps the skipped states by the gap as Rust prints it
for debugging (Translation where the translator refused), with the
first one's object and answer, and the report gives a
"skipped render states GAP N, the first #ID: WHY" line for each, as it
does for render commands; skipped_render_states is their sum.
docs/REPLAY-STREAM.md describes the line.

Verified: see the check job (a new rt_replay device test: a state with
a Depth32Float depth attachment is counted under
RenderPipeline { kind: DepthAttachment }).
2026-11-18 16:57:09 -08:00
Anees Iqbal f9633bf18d rt: a pass's depth attachment is loaded, cleared and stored, untested; a pipeline state takes its depth format
The render-state lane's first feature. A replay stream's 478 depth passes (depth census
m3-max-48544, the one stream with any) are a shader-read Depth32Float texture with no stencil
attachment beside it, a Clear of 1 (476) or a Load (2) and a Store, drawn under Metal's default
depth-stencil state (compare Always, no write) by four pipeline states of depthAttachmentPixelFormat
Depth32Float. rt refused all of them: the pass by RenderPassKind::DepthAttachment, the states by
RenderPipelineKind::DepthAttachment.

- pass.rs: Pass holds the depth attachment as it holds the stencil one: a format with depth
  (else Refusal::AttachmentFormat, as Metal's validation stops it), the texture's view of the
  level and layer, Metal's load and store actions as for a colour, its clear depth a float.
  `vkCmdBeginRendering` takes it as pDepthAttachment. With a stencil attachment beside it the two
  are one view (VUID-VkRenderingInfo-pDepthAttachment-06085): two others are
  RenderPassKind::DepthStencilViews. A Clear outside [0, 1] or NaN is RenderPassKind::ClearDepth
  (VUID-VkClearDepthStencilValue-depth-00022; the floor has no VK_EXT_depth_range_unrestricted).
  Pass::targets yields each image once, so a combined texture's one view is moved, kept and
  barriered once.
- render.rs: the descriptor's depth format is no refusal. Fixed holds the translator's depth
  format (vk_format over the device's format query: a format the device does not render depth
  in is the translator's typed refusal), the VkPipeline renders into it, and renders_into holds
  it to the pass's depth attachment, as the colour and stencil formats are.
- The draw keeps DrawKind::DepthTest for a state that tests or writes depth; the encoder's
  dynamic depth state stays off, which is what the default state means.
- error.rs: RenderPassKind::DepthAttachment and RenderPipelineKind::DepthAttachment go;
  DepthStencilViews and ClearDepth come. Their docs, the bases and Refusal::AttachmentFormat's
  doc say what is built.
- README: the render pass and encoder sections and their known gaps.
- docs/REFUSALS.md regenerated; the API signature table blessed (two variants out, two in).
- tests:
  - draw.rs every_device_clears_loads_and_stores_a_depth_attachment_its_draws_do_not_test: a
    shader-read Depth32Float attachment cleared to 0.25, then loaded, each pass one submission,
    three barriers, one pass, no byte copied; the colour drawn; the depth read back 0.25; a state
    without the pass's depth format, one with it in a pass without depth, and a Less test are
    each their gap.
  - pass.rs: the depth refusal is replaced by a depth attachment of a colour format, a depth and
    a stencil of two textures, and a clear depth of 2 and of NaN.
  - render.rs: the depth attachment leaves the pipeline refusal list.

Verified: nothing yet; the next check job compiles and runs it.
2026-11-18 16:52:29 -08:00
Anees Iqbal a314b75ee6 replay: a play ends at the stream's recording range unless --past-range yes takes it past
A known-bad tail cost a ring timeout on a shared card and a wrongly
bounded play. The player now ends every play at the recording range by
default:
- the stream's sidecar, NAME.range beside NAME.0000.m2vr, one line:
  "last-frame F" or "whole";
- else the player's table RECORDED_RANGES for the streams recorded
  before sidecars, found by the first segment's file name and byte
  length: u2 1128, u3 1178, r3 1137, r4 1099, b3 whole;
- else the whole stream (the 3D streams until their ranges are stated).

--past-range yes plays past it; without it --until-frame F stops at the
earlier of F and the range. Every report says which range the play
used, where it came from and whether the play ends there, on a range
line after the completion mark; a sidecar of neither form is a harness
error (exit 2). docs/REPLAY-STREAM.md: section 1 names the sidecar,
section 10 the default, the flag and the report line.

Tests: replay::tests a_recording_range_comes_from_the_sidecar_then_the_table
(sidecar over table, table row by name and length, no row, bad sidecar);
integration replay_range runs the binary over a synthetic stream with no
sidecar, a last-frame sidecar, the flag and a bad sidecar (no device
opens); replay_completion_mark now expects the range line second.
2026-11-18 16:47:13 -08:00
Anees Iqbal 0a0ce8e29b rt: a cube array texture is a typed gap, so no view needs imageCubeArray
rt made VK_IMAGE_VIEW_TYPE_CUBE_ARRAY views without the imageCubeArray feature, which its floor
(Vulkan 1.3) does not require: the conformance whole set's layer leg on lavapipe (job
m3-max-48531) logged VUID-VkImageViewCreateInfo-viewType-01004 ten times once the rt side made the
cases' cube array textures. No replay stream makes a cube array texture or view (cube census over
every stream, jobs listed in the landing message), so by the planner's scope rule a cube array is
a typed gap until one does, and the floor is unchanged.

- error.rs: Gap::CubeArrayTexture, basis ours.
- texture.rs: prepare refuses a CubeArray descriptor, which every texture and every view of one
  passes through, so no cube array view is made; the descriptor's and new_texture's docs name it.
- README: the texture section's gaps.
- docs/REFUSALS.md regenerated; the API signature table blessed (one variant added).
- tests/texture.rs: a cube array texture is the gap on every device of the cfg.

Verified: nothing yet; the next check job compiles and runs it.
2026-11-18 16:39:42 -08:00
Anees Iqbal 5849a7f029 matrix: each runtime's creation rows run in a process of their own, cold against cold
The planner's rule: a cold first sample is compared cold against cold. The creation rows ran in
five processes that each timed both runtimes, the new runtime first, so the driver's
process-wide setup fell on the new runtime's first pipeline and the old runtime's first samples
came after it, warm. Measured on the Iris Xe (job 48650, ms01 alone, both runtimes from the
harness at cb25e3a83e, five processes each): the old runtime's create_state/first was 5265.8 us
behind the new runtime in one process and 16732.8 us in a process of its own (0.315x);
device_first 0.167x, first_call 0.099x. The one-process ratio new/old 1.302 at first was a
cold-against-warm ratio; cold against cold it is 0.410.

Of the two forms the planner allowed, each runtime's own fresh process is the cheaper: the
harness does not change, and the extra five processes a leg runs take about a second each
(create_state's processes on the Iris ran in under one second). The other form, one unrelated
pipeline before either runtime in a shared process, would need harness code and leaves the
first samples process-warm, not cold. So each of the five rounds now runs `--runtime new` and
`--runtime old` in processes of their own, each on a fresh driver cache and store, the order
alternating from round to round (new first in rounds 1, 3 and 5); the first round's two outputs
are kept whole, the later rounds' first samples as before. The records, their names and the
budget's medians do not change.

Verified: the matrix's Python tests in the job named in the landing message (the harness-runs
test now pins the processes and their order).
2026-11-18 16:35:27 -08:00
Anees Iqbal 6605f18ddf harness, matrix: the frames' commit-to-complete row is gone after its one round
The planner's frame ruling showed the frames' old figure, their last command buffer's
commit-to-complete time (`<row>/commit_to_complete`), beside the new throughput row for one round,
unjudged, then deleted. The round at 5f2494bfc5 is that round. The harness no longer prints the
record, the matrix no longer has a shown-rows table (its one row was this), and the docs and
the frames test lose it. The frames' latency from idle stays a row of its own.

Verified: the harness gate in the job named in the landing message (clippy plain, m2v_gpu and
m2v_cpu_icd, rustdoc, unit tests, the matrix's Python tests).
2026-11-18 16:28:03 -08:00
Anees Iqbal ca92b2aa9e harness: a compute state row's first dispatches 64x1x1, the streams' commonest size; one thread beside it
The create_state row's first dispatched one thread (1x1x1), a size of few dispatches: 3.9% of the
compute dispatches in the discrete replay recordings (from 3 to 5 kernels) and at most 0.5% in the
unified ones, by identity's census of every stream's threadsPerThreadgroup. A runtime that
compiles its pipeline for the dispatch's size (the old runtime) compiled the first at 1x1x1, where
a program's first dispatch runs at its own size. The first now dispatches one threadgroup of
FIRST_THREADGROUP, 64x1x1: the commonest size over the five streams of record, 24.1% of their
compute dispatches (41.7% of the unified recordings', 7.1% of the discrete ones', where 128x1x1
leads with 39.3%; 128x1x1 is 23.3% overall). Each thread's 16 bytes are checked.

Today's form stays beside it, shown and never judged: another content's first (the kernel with
other constants) dispatched as one thread, create_state/first_one_thread
(CreateReport::one_thread_first_us; results.SHOWN_FIRST). The name has no digits so the matrix's
FIRST_KEEP keeps it from every creation process, which a results test holds. The warm-up stays at
one thread. docs/VALIDATION.md and the crate doc say it; the authored device test asserts the
compute row has the one-thread first.
2026-11-18 16:27:00 -08:00
Anees Iqbal c1bd2d46d6 replay: a report of a stream recorded before the completion fix says so on its first line
The recorder's completion fix marks a stream with header flag bit 1,
FLAG_COMPLETION_BYTES_RECORDED (value 2): at each command buffer's
completion the stream holds every chunk the buffer's work could store to
as the GPU left it, before any later CPU write, on all four late routes
(signalled event, final status read, refused hook, released command
buffer). Fixed streams read flags 3; every stream recorded so far reads 1.

- The reader takes bit 1 (it refused any bit but 0 before), so a fixed
  stream plays.
- command-replay play writes "recorded before the recorder's completion
  fix: the stream may differ from what the program did" by itself as the
  first line of report.txt for every stream without bit 1, so no table
  relayed from a report loses it. The stream is now read before the
  device type is parsed, so even a report that stops there carries it.
- docs/REPLAY-STREAM.md: section 1 names the bit, section 6 replaces the
  rule that described a stream without completion writes as allowed with
  the completion invariant and what a stream without the bit may miss,
  and section 10 names the line and its place in report.txt.

Tests: replay_completion_mark (integration) runs the player binary on a
one-call stream with flags 1 (the report begins with the line) and flags
3 (it does not), with a device type no device has so no device opens;
the header flags test now reads flags 3 and refuses bit 2.
2026-11-18 16:24:06 -08:00
Anees Iqbal f1f846e636 rt docs: the consumer's own drivers in the guide, the validation ladder and the surface table
`Instance::with_drivers` and `Error::NoDirectDriverLoading` are public: the runtime's guide
says what the call does, what it refuses and what it leaves to the consumer (loading the
library and keeping it loaded); docs/VALIDATION.md says how a job runs the device tests through
it (`M2V_DIRECT_DRIVER`) and what shows the path ran; the signature table takes the two records
(scripts/api-signatures/signatures.py --bless). docs/REFUSALS.md regenerated unchanged: the
variant refuses nothing Metal accepts, it says the host's loader lacks an extension.

Verified: the generators' output; the build and the tests in the jobs named in the landing
message.
2026-11-18 16:16:23 -08:00
Anees Iqbal d3bfe3815d harness, matrix: a frame row is its throughput, and its latency from idle a row of its own
The planner's metric for the frame rows. A frame row's time was its runs' last command buffer's
commit-to-complete time with two runs in flight, which mixes the time a frame adds with how long
it waits behind the one before. Now `frame` and `frame_5cb` (Plan::frames) carry two figures,
each the steady time (best window of ten) of the harness's own completed-handler times:

- THROUGHPUT, the row of record (matrix_time): two runs in flight, from one run's last completed
  handler to the next's. The pairs around the waits that read the gauges after runs 100 and 200
  (GAUGE_RUNS) are left out, as an untimed run sits between them.
- LATENCY FROM IDLE, the row `<row>_from_idle` (FROM_IDLE): as many runs again after the timed
  ones, one in flight, each committed once the one before it completed, from just before its first
  commit to its last completed handler.

The completed handlers now report the time of their commit and of their own run against one
origin (Completions, Handled), so the commit-to-complete times, the throughput and the latency
come from one record. The frames' commit-to-complete time is still printed, as
`<row>/commit_to_complete`, which the matrix shows and does not judge (SHOWN_ROWS) for one round.
Each latency row takes the ceiling and floor its workload's row has (listed_row), in the budget,
the over table and the re-time selection, and is re-timed through its workload's runs. Other
workloads are unchanged, long_4cb's commit-to-complete time included. The shape follows core's
one-run-in-flight probe (3eaec97076), without its environment gate.

Verified: test_results (a new test: a latency row past its workload's ceiling and the budget,
the commit-to-complete row shown and never judged, the over table and the re-time selection
choosing the latency rows); the harness's unit tests gain the throughput and latency arithmetic
(the gauge pairs left out) and matrix_time's frames case; the harness gate job named in the
landing message runs clippy, rustdoc, the unit tests and the authored workloads on lavapipe.
2026-11-18 15:51:27 -08:00
Anees Iqbal 6d4ca09039 translator: a render pipeline into a snorm attachment records SnormMinimumKept on Device::from_queries
metal2vulkan-rt's conformance side ran the six snorm-store cases on lavapipe (job 48051). Each
diverged where Metal's tile store writes a loaded minimum code (-128, or -32768) back as the code
above it, and the device's pass keeps the bytes. The old runtime announces that as
`snorm-minimum-kept` at the draw, from its encoder (render/tile_store.rs). The new runtime has no
such encoder step, and the translator recorded no note, so the answer went unannounced. A missing
static note is a bug (rule 1: a static note fixed per operation).

- `PrecisionNote::SnormMinimumKept` (appended): the note of a render pipeline that draws
  single-sampled into a color attachment of R8Snorm, RG8Snorm, RGBA8Snorm, R16Snorm, RG16Snorm
  or RGBA16Snorm.
- `pipeline::private_state::note_snorm_minimum` records it on the fragment stage (the vertex
  stage where there is none), whatever the pass loads. That is static, so it may over-announce
  a cleared pass.
- It is recorded only where the profile's new fact says `SnormMinimumNote::Noted`. That is
  `Device::from_queries` (ProfileFacts::EVERY); `Device::new` (ROWS) stays `Announced`.
  `Device::new`'s modules, keys and the old runtime's announcement are unchanged.
- The old runtime maps the note to its existing `Degradation::SnormMinimumKept` (an explicit
  `from_precision_note` arm). Validation's comparison allowance is Unbounded, as for the other
  device-answer notes. The codec takes the variant, and ARTIFACT_FORMAT_VERSION goes from 536 to
  537. fast_paths lists the note under Elsewhere. api_signatures gets the two variant rows and the
  macro row. docs/API.md's `snorm-minimum-kept` entry says where the static note is recorded.

Test: engine_private_render_state's
a_snorm_attachment_notes_the_minimum_code_metal_s_pass_rewrites. On lavapipe and moltenvk-m3, for
each of the six formats, the note is on the fragment stage alone through Device::from_queries and
on no stage through Device::new. No stage records it at four samples, or into RGBA8Unorm or
RGBA16Float. The six conformance cases on the rt side are the end-to-end test (the check job's
replay, named in the report).
2026-11-18 15:50:11 -08:00
Anees Iqbal 58229ccd71 replay: a copy back to the guest's RAM plays as buffer copies into a sink
The new runtime's backend skipped m2v.copyToGuestRam and counted it, so
every play's verdict ended at the first one (u2 frame 97, u3 frame 99),
though nothing in a play reads that RAM. The planner ruled it does not
end the played range, and that work the recording host did live plays
as the runtime's, cost included.

It now plays as the old backend's does: each run copied by the blit
encoder, in its order, into a Shared place of the play's own that
nothing reads, each run widened to the whole words it touches within
the buffer (a buffer copy takes whole 4-byte words). The place is given
back at the command buffer's commit, as a copy from the guest's RAM
gives back its staging. The report counts the bytes
(copied_back_guest_ram_bytes); skipped_guest_ram_reads is gone.

Verified: see the check job (a new rt_replay device test: nothing
skipped, the widened bytes counted, the buffer's bytes kept).
2026-11-18 15:47:00 -08:00
Anees Iqbal 02eaf89136 matrix: the report ends with one table of every row over its limit, with its status
Two legs of eleven passed and every red was known, so the reds were no longer read. The report
(`matrix run` and `matrix show`) now ends with one table: every harness row over its limit on every
leg (results.over_rows, the rows harness_budget fails or names as its card's variance), with its
kind (GPU time, host time, or count for the instructions gate), its ratio and limit, the frozen
arm's verdict (VOID, stands, rebased, no base) and its status. The status comes from
scripts/matrix/status.tsv, one typed entry per card and row (a `*` in the row matches any run):
an open record with its owner and first round, whose age the table counts in rounds; a known gap
with the place it was ruled; or a note alone. A row with neither reads NEW in the first round it
is over (not over in its leg's base) and UNOWNED after; a CARD_VARIANCE row reads as its card's
known gap. The table changes no verdict: the red rule waits for the planner's ruling.

Seeded from the rulings so far: NVIDIA create_64MiB/first_take, a known gap (the 2080 and the
3090); create_64MiB on AMD, a note that it is no known gap and is unjudged until the first
interleaved round; the Iris Xe's GPU-time rows, a note of one time-boxed investigation after that
round; the Iris row_cells, identity's open record (first over at 795c834ded); the 2080 and Iris
frame_5cb, core's open records (from 140714ceae), and both cards' frame and frame_5cb, the
planner's state of throughput and latency from idle.

Verified: test_results (three new tests: the stored table reads and a malformed entry is refused;
every row past its limit is listed with its kind and judged ratio, re-timed and shown rows
included; statuses NEW, UNOWNED, open with its age, gap, notes, an extra leg and the card's
variance). Against the stored notes of 795c834ded and 140714ceae, over_rows lists exactly the rows
the budget named past their limits on every leg (15 and 14 on the Iris Xe).
2026-11-18 15:20:12 -08:00
Anees Iqbal 65aac391c2 matrix: the frozen arm compares only rounds of one harness, one old runtime and one shape
The noise meter read the old runtime's move between two rounds as noise even where the harness or
the old runtime changed between them (ff4ce943c2 gave every workload command buffer a scheduled
and a completed handler, on both arms). Now the matrix compares the trees of
crates/metal2vulkan-harness and crates/metal2vulkan-runtime at the leg's commit and its base's,
a mechanical check: where either differs, every row but the creation rows reads `rebased` and
voids nothing, the creation rows timing creation calls and no command buffer of the harness's.
Each leg's note now keeps its timing shape (HARNESS_SHAPE, "one process, new then old"): against a
base timed in another shape, no row is compared, so the first round of the interleaved shape is
the base the meter starts from.

Verified: test_results (the void rule's test covers both rebases, the column and the void list);
`matrix show 140714ceae` against 99ec109264, whose harness and old runtime trees differ, reads
every command-buffer row rebased and voids only creation rows (Iris: create_private_16MiB's three
and create_render_state/device_first).
2026-11-18 15:13:16 -08:00
Anees Iqbal 3027cf9b68 matrix: each creation process times both runtimes, the new runtime first
The creation rows ran in five processes per runtime, all of the old runtime's before the new
runtime's, so a node or clock that moved between them moved one runtime's samples alone, an order
effect. Each of the five processes now times both runtimes, `--runtime new,old --only
'create_*'`, on its own fresh driver cache and store: a creation's first sample on the new runtime
is cold, and the old runtime's follows it on the same cache. FIRST_KEEP takes each sample's
runtime from its line. The median of five per runtime and every row, ceiling and floor stay.

Verified: test_matrix's harness-run test (five `new,old` creation processes, both runtimes'
samples kept once each) and test_results' creation test (FIRST_KEEP keeps the old runtime's
sample beside the new's and drops a GPU line); the Linux and Windows job scripts pass `bash -n`.
2026-11-18 15:13:16 -08:00
Anees Iqbal abf3d4133d matrix: both runtimes' rows are timed in one process, their passes alternating
Two cards showed the noise the old runtime's frozen arm measures: the Iris Xe's frame moved 2.8x
between rounds, the UHD 630's about 2x between passes of one process. The leg timed each
runtime in a process of its own, one after the other, so a clock or a co-runner that moved
between them moved one runtime's times and not the other's. Now one process times both,
`harness --runtime new,old`: each workload runs on the new runtime, then on the old, so their
passes alternate on the GPU and the node as they are at that moment. The new runtime runs first
in each workload, so its first uses, the judged cold ones, compile before the old runtime's of the
same workload, as cold as in a process of its own. The process is the leg's one suite, `harness`;
a failure still names its runtime (`M2V-FAILED harness-<runtime>/<row>`). The creation rows keep
their five fresh processes per runtime, now alternating old and new; rows over their limits are
re-timed alone as before. No row, ceiling or floor changes, and the deterministic records are
untouched. The frozen arm's column (FROZEN_DRIFT) stays the check on it.

Verified: test_matrix's new test runs the leg's timing script against a stand-in harness: one
`new,old` process, the new runtime's warm run, the creation processes alternating, one suite whose
records hold both runtimes' rows once each. The Linux and Windows job scripts render and pass
`bash -n`.
2026-11-18 15:13:16 -08:00
Anees Iqbal 06b940f810 matrix: the frozen arm is the noise meter: a row whose old time moved past 10% on the base is VOID
The old runtime takes regression fixes only, so its time of a harness row moves between rounds
with the node, the driver and the harness, not with the change under test. Each leg now compares,
per row, the old runtime's time the row is judged on (its GPU p50 where gpu_judged, the median of
the five processes for a creation row's first sample, else its time) with the same time in the
leg's base, the previous round. Past FROZEN_DRIFT (10%) either way, harness_budget names the row
VOID and judges nothing from it: its comparison comes from a re-time in one process with both
runtimes interleaved. The report (run and show) shows the move on every row the base has, and a
line per leg naming the void rows; show computes it from the notes, so a round already noted is
read with it.

Verified: test_results (47 tests, a new one for the void rule, the GPU and median-of-five forms,
no base, and the column). `matrix show 140714ceae` against its base 99ec109264 voids Iris frame
(-64.7%) and frame_5cb (-28.9%), and keeps UHD frame_5cb (+8.8%) and 2080 frame_5cb (+1.2%).
2026-11-18 15:06:36 -08:00
Anees Iqbal 40e135c308 replay: the new runtime's backend rounds each buffer's place to its recorded granule
The backend packed buffers first fit at Metal's 256-byte alignment, so a program's write past
a buffer's end landed in the next buffer. A recorded stream's program did that: an append
list of 4000 records took about 870 more on one play, and the overrun went 17340 bytes into
twelve 4-byte counters and the start of a 48000-byte buffer that the player had packed behind
it. The recording had given each of those buffers its own 32 KiB-granular range, so the same
overrun landed in the list's own slack there. The clobbered counters then feed the next
rounds; a 780M page fault past a 64 MB buffer and a hang on a 3090 follow them (expected, the proof plays pending).

Each buffer's place now spans its length rounded up to its recorded granule: the largest
power of two that divides its recorded gpuAddress, from 256 bytes to 64 KiB, and 256 bytes
where the stream records no address (the player's own staging included). Both copies of a
two-copy Managed buffer take it. A buffer past the class's block length takes a block of its
own of the rounded span. The backend's new "places by recorded granule" line counts the
places by granule and gives the most bytes of slack held at once.

Test: rt_replay's buffers_keep_the_slack_of_their_recorded_granule plays two 4-byte buffers
recorded at addresses of 32 KiB and 64 KiB granules and reads back their relocated addresses
from a third: they lie apart by at least the lower one's granule (256 bytes apart before).
docs/REPLAY-STREAM.md says how the backend places buffers.
2026-11-18 14:53:10 -08:00
Anees Iqbal 795c834ded Re-derive the generated documents at the landing tip
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.
2026-11-18 14:34:49 -08:00
Anees Iqbal d6a1a86d98 translator: the one-row variant leaves out the barriers of pairs apart in rows on every device; CompiledFunction says whether a kernel's lockstep barriers run in rows
LoweringInputs::one_row's lockstep order cleared the pairs that meet only where a SIMD group
spans two rows only where Lockstep::rows held, which needs maximal reconvergence on 32-lane
subgroups without the device's own lockstep: the old binder's condition for asking the variant.
On a device without that tier (lavapipe's 8-lane subgroups, the UHD 630 without the extension,
GCN's 64-lane waves) a one-row compile kept every barrier, though the clearing is exact there
too: in a threadgroup whose SIMD groups each lie within one row, those pairs never meet,
whatever runs the SIMD groups. The order now searches the pairs under the rows facts for every
one-row compile and clears them wherever every pair left wants a threadgroup barrier at most.
Lockstep::rows and RowLockstep keep their meaning, so Device::new's plans, and the old binder's
one-row compiles, which it asks only where rows holds, are unchanged.

CompiledFunction::runs_lockstep_barriers_in_rows (KernelFacts::lockstep_in_rows) says whether a
kernel's lockstep order inserted a barrier that runs where each SIMD group lies within one row:
any but the threadgroup barriers that order only pairs meeting across rows
(Lockstep::across_rows), which the module runs only where its local size lets a SIMD group span
two rows, a test the driver folds. Only where it holds can the one-row variant run fewer
barriers than the kernel's own module at a one-row size, so a runtime asks the variant only
there. It is decided from the plain compile's order and changes no module. docs/API.md states it;
the api_signatures table gains its row.

SEMANTICS_VERSION 2181 -> 2182: a one-row compile on a device without that tier changes. The old
runtime's render descriptor key is re-pinned under it (b3d05d42). ARTIFACT_FORMAT_VERSION 536 ->
537: KernelFacts gains lockstep_in_rows.

Test: a_one_row_variant_clears_the_pairs_apart_in_rows_without_a_32_lane_tier, on lavapipe's
from_queries profile under the identity domains. Three kernels, each with its stores in its entry
block and past a bounds test (six in all), keep lockstep barriers in their plain module and state
no RowLockstep:
- one storing the three words 3 cell + k of its cell y * stride + x in int arithmetic, as Apple
  compiles it (nsw on every step, the index sign-extended);
- the same in uint arithmetic, whose steps carry no flags;
- one whose threads store at x and x + 1.
In the one-row variant the first has none. It states OneRow, takes no simd class, does not
observe its partition with partial threadgroups (the variant without one_row does), and runs its
grid in tiles. The other two keep their barriers: the wrapping index is not proved apart in
rows, and the neighbours meet within one row. Every plain module runs its lockstep barriers in
rows but the unguarded int cells kernel's, whose barriers all order pairs across rows.

Verified:
- Check 48214 (msi) at this series' tip on development 50719da96b: clippy with -D warnings of
  metal2vulkan, metal2vulkan-rt and metal2vulkan-harness (default, --cfg m2v_gpu and, for the
  runtime, --cfg m2v_cpu_icd) and their Rustdoc are clean; their host suites pass 3,863 of
  3,867, and the 4 that fail all name engine/oor_texture_reads, a fixture development added
  (603634f9f9) without its golden-table and inventory rows, whose re-bless development owns; the
  runtime's device suite passes on lavapipe (275 run, 3 skipped).
- The translate probe (jobs 47932, 47952; lavapipe's from_queries profile and three device
  profiles): lcg_step's plain and partial-threadgroups modules are byte-identical before and after
  this change (SPIR-V 3226775232d06722, 649 words, and 991ee4501d037271, 1202 words), and
  runs_lockstep_barriers_in_rows is false for it. The harness fixture's row_cells holds two
  barrier.lockstep.simdgroup (barrier.lockstep.emulated.simdgroup on lavapipe), the kind the
  streams' four row-indexed kernels hold; it runs them in rows, and its one-row variant holds none.
2026-11-18 14:34:01 -08:00
Anees Iqbal 051236c0c2 replay: a placement over an equal sampler state's index does not wait, and one a held commit owes stops the play
u3 stopped at player frame 259: the placement of a sampler state at index 16 waited for commit
1614 (#20713), which rt held at Committed because it waits for event #35 to reach 309, which only
command buffer #20439 signals, encoded 20 records later. The program had released #10401 (index 16,
bound directly by #20713) and made #20822 with the same descriptor the next call; Metal gave it ID
16 again. Nothing changed for the work in flight, and the original run did not wait (it could not:
#20713's signal was not yet encoded).

- A sampler state whose recorded descriptor is the one placed last at its index takes the index
  without waiting, counted on the indices line; the index stays owed for another sampler state.
- The player tells the backend, at each look for command buffers to wait for, the committed ones
  no record played so far lets complete (Backend::held: their unmet event waits, or a held one
  ahead on their queue). A placement owing its index to one of those stops with PlayError::Held
  naming the chain, instead of waiting for ever.
- docs/REPLAY-STREAM.md says what record order does not promise (a committed buffer may wait on a
  later record's signal) and what the indices line and the stop say.

Tests: a unit test of the equal rule in Indices; rt_replay device tests of our own sequence: an
equal sampler state at an index a held commit owes plays through without a wait; another
descriptor there stops with Held naming #6 and its unmet wait. Check follows.
2026-11-18 14:25:12 -08:00
Anees Iqbal 4fbe03c3a0 rt: maxColorAttachments of 8 joins the floor, and the pass's colour-attachment limit goes
The floor now requires maxColorAttachments of at least 8, Metal's eight colour attachments
(MAX_COLOR_ATTACHMENTS, the render pass descriptor's slots). Vulkan 1.3 requires only 4: the
spec's Required Limits table (Table 76, vkspec 1.4.366) lists maxColorAttachments as "4 (Vulkan
Core) 7 (Vulkan Roadmap 2022) 8 (Vulkan Roadmap 2024, Vulkan 1.4)", min. A device below 8 is now
named below the floor at creation ("maxColorAttachments 7, below 8"), so a pass's colour
attachments, at most the descriptor's eight slots, never reach past the device's. The check in
pass.rs and its refusal, Limit::ColorAttachments, could no longer fire and are deleted.

Breaking, intended: the public variant metal2vulkan-rt::Limit::ColorAttachments { count, max } is
removed (api_signatures.tsv loses that one line, blessed). docs/REFUSALS.md is regenerated (the
new runtime's Limit goes from 10 to 9 variants). The README's limits table gains the row and the
Limits paragraph the spec's minimums; the render pass passage says a pass may use all eight.
The floor test's low-limit cases go from 16 to 17 with the maxColorAttachments case.
2026-11-18 14:06:15 -08:00
Anees Iqbal 518800af99 rt: a wait in a handler or a listener for what its own thread does next is a typed refusal
The completion thread runs a device's completed handlers and listeners, and it is the thread
that marks a command buffer completed, an event's GPU value observed, and a queue's place free.
A wait there for any of those not yet done could only end by that thread's next step, so it hung
by construction. Each is now Refusal::WaitOnOwnThread, and a wait already met answers at once:

- wait_until_completed: Ok for a command buffer completed or ended, the handler's own among
  them, else the refusal; nothing is sent.
- wait_until_scheduled: the refusal for one not yet scheduled.
- SharedEvent::wait_until_signaled_value: Ok(true) for a value reached, else the refusal.
- CommandQueue::command_buffer on a queue whose maximum count are made and not yet completed:
  the refusal on the completion thread and on the submit thread (a scheduled handler), whose
  next steps free the place.

The condition is the program's own state (what it committed, what has completed), never a
ring's fill. Outside a handler every wait answers as before.

Test: every_device_refuses_in_a_handler_each_wait_its_own_thread_would_have_to_end checks 15
answers in a scheduled handler, a completed handler and a listener. REFUSALS.md regenerated and
the signatures table blessed: Refusal gains WaitOnOwnThread (a new variant of a non-exhaustive
enum; no consumer breaks).
2026-11-18 14:04:45 -08:00
Anees Iqbal ea8e7843b7 rt: scheduled handlers run on the submit thread, before their submission, and wake no thread
The consumer adds a scheduled handler to every command buffer. The submit thread handed each
command buffer's scheduled handlers to the completion thread (Done::scheduled), and where that
thread waited on the GPU the hand-over was a host vkSignalSemaphore of its wake timeline, on
every submission. On NVIDIA a host signal per submission measured 103-117 us of CPU a command
buffer on an RTX 3090 (the waits probe's rt arm, job 47928), against 2.9-3.5 us for every single
wait form, rt's own steady-state WAIT_ANY included.

Now the submit thread, which already marks a command buffer scheduled as it joins a submission,
runs its scheduled handlers itself once it has dropped its lock, in queue order, before that
submission goes to the driver and before any of those command buffers is handed on as ended.
So the status reads Scheduled and the kernel times are set in the handler, a command buffer that
ends before it joins a submission runs none, as before, and the scheduled handlers run before the
completed ones by construction. Done::scheduled, its list and the completion thread's branch for
it are deleted.

A handler on the submit thread may not call what waits for that thread to submit. The four
internal sites that do (Work::room, Work::capture, Work::stage and the readback's flush and
Done::wait) give the public entries that reach them; each is now Refusal::InScheduledHandler in a
scheduled handler, on every device and whatever the runtime holds: commit; wait_until_scheduled,
wait_until_completed and SharedEvent::wait_until_signaled_value; replace_region, upload_region,
get_bytes and zero_block_range; new_managed_buffer, and new_buffer zeroing a buffer in a Private
block. The one consumer's scheduled handler makes none of these calls, and a guest's
addScheduledHandler block runs in the guest. Quiesce in a scheduled handler answers false at once
(neither the submit thread nor the completion thread, which the submit thread stops as it ends,
is waited for), and a device whose last handle drops there tears down on the reaper, as from a
completed handler.

For a consumer: CommandBuffer::wait_until_scheduled and wait_until_completed now return
Result<(), Error>, and SharedEvent::wait_until_signaled_value returns Result<bool, Error>
(api_signatures.tsv blessed); docs/REFUSALS.md regenerated; the README's contract says where each
kind of handler runs, what a scheduled handler may do, and that it holds its queue's later
submissions while it runs.

Tests: every_device_tears_down_from_a_scheduled_handler,
every_device_answers_false_to_a_quiesce_in_a_scheduled_handler, and
every_device_refuses_each_call_that_waits_for_the_submit_thread_in_a_scheduled_handler (each
refused entry by name, the allowed calls, the status and kernel times in the handler, and the same
calls answering once it has returned). Verified by the next jobs.
2026-11-18 13:36:21 -08:00
Anees Iqbal 99ec109264 harness: each creation row's first is a fresh object's on a device that has made one of its kind
A creation row's first sample was the first of its kind in a fresh process, so it held the
device's own first use (its first recorder, submission, upload, staging region, stamp pool)
together with the object's. A guest keeps one device for the machine's life, so what a device pays
once never reaches it. The planner ruled that every first row is judged on a new object's first use
on a warm device.

Each creation row now makes a warm-up of its kind first, made and used as the first is and kept
until the first is done, then the timed first on a fresh object:
- Shared and Private buffers: a buffer of the same length, kept, so the first takes memory the
  warm-up did not give back (a new 16 MiB Private block on rt's harness placement); the next take
  still follows the first's release.
- compute states: a state of another authored kernel (lcg_step, bound as signed_zero_products is),
  created and dispatched once, its word checked;
- render states: a state of another fragment function (sampled_fragment) with the row's vertex
  function and attachment.
The warm-up's time is its own record, `<row>/device_first`. The matrix shows it with the ratio of
its medians and never judges it (results.SHOWN_FIRST now names each shown sample with its reason).
time_states takes the first as its caller timed it; its other form had no caller left.

Tests: a host-buffer device shows the buffer row's order (the warm-up alone, the first and the
next beside it, the timed ones alone); the matrix shows a warm-up and judges the first it comes
before; the device test checks every row records its warm-up.
2026-11-18 13:06:31 -08:00
Anees Iqbal 4da77d8518 FAST-PATHS: what an NVIDIA host whose type 0 reads right loses to the Shared dma-buf refusal 2026-11-18 12:54:29 -08:00
Anees Iqbal 1d5226bef7 runtime: a Shared dma-buf import takes host-coherent types only, and none where its first is not
The old runtime imported a Shared no-copy buffer's dma-buf on NVIDIA as type 0 (system memory,
no property flag): its udmabuf order (system-memory types the host maps last) puts type 0
before type 4. A type without HOST_COHERENT promises nothing of what the caller's own mapping
of the pages and the device see of each other's writes, and Shared memory's bytes are exactly
that; the consumer's probe showed wrong bytes there.

The form, decided by the memory types' flags alone (no fact row, device check or switch):
today's order is computed unchanged (memory::dma_buf_order, the former dma_buf_candidates);
for MemoryClass::Shared, dma_buf_candidates then keeps only its host-coherent types, in its
order, where its first type is host-coherent, and none where it is not. An empty order tries no
import and refuses as ImportFailure::NoMemoryType, which callers already map to not_importable()
("host memory this device cannot import exactly"), so what it would back takes the refused
dma-buf's path, a copy of its pages. Type 4 is never tried: a refused import there breaks every
later exportable device-local allocation for the device's life (tests::export_after_dma_buf).
Private and the other classes keep the order whole (type 0 on NVIDIA as before).

Tests:
- tests::memory::a_shared_dma_buf_import_takes_host_coherent_types_or_none: over NVIDIA's,
  ANV's, RADV's (discrete) and lavapipe's types and udmabuf bits, the first type before and
  after is the same but NVIDIA's (0 before, refused after, no attempt), and every other class's
  order is unchanged. The order tests name dma_buf_order.
- tests::export_after_dma_buf::a_shared_dma_buf_import_is_host_coherent_or_refused_untried
  (device test): where the order is empty the import is refused and exportable Private buffers
  made after it still lie in device-local memory with no overflow; elsewhere it imports as a
  host-coherent type and a Shared buffer over it shares bytes both ways (the GPU's fill read
  through the caller's mapping; the CPU's writes there read by the GPU's copy).

docs/FAST-PATHS.md's known gap on NVIDIA's dma-buf imports says so. docs/REFUSALS.md
regenerates unchanged (the refusal is the existing one).
2026-11-18 12:54:29 -08:00
Anees Iqbal 0228641d79 rt: the encoders and a segment's begin borrow the core; the lock budget's bound is 0.25, and a node naming the event must measure it
The planner's rulings on the lock budget and the alternations:

- The bound is one value on every device, 0.25 locked instructions per added command, for
  draws, bound draws and dispatches: a site of rt's that runs per command adds 1 or more, and
  the drivers' own growth stays far below it (measured: Iris Xe 0.0195 / 0.1425 / 0.0285 at
  most, RX 7900 XTX 0.0000 / 0.0015 / 0.0050, RTX 2080 0.0005 / 0.0000 / 0.0175).
- Each budget test prints its measurement as a matrix record, `locks lock_budget/<kind>`, per
  million added commands (none below 0), beside its LOCKS line. The matrix fails a GPU leg
  missing any of the three where the node's setup names M2V_LOCK_EVENT (results.LOCK_BUDGET,
  names_lock_event, lock_budget_missing; keyed on the setup, not on a card), for a commit that
  has the budget; elsewhere the budget prints LOCKS-UNMEASURED and passes. The note carries the
  three values per leg. docs/VALIDATION.md's records table has the kind.
- Building::begin borrows the device's core where it took an Arc<Core> it dropped after the
  start timestamp; the compute and render encoders hold an uncounted borrow of the recording's
  core (kept::Uncounted, the kept handle's pattern for an Arc), valid while the encoder holds
  the recording, which it does until it ends. Two locked instructions fewer per encoder and one
  pair fewer per segment.

Verified: scripts/matrix's unittest suite (47 tests, a new one for the event and the missing
records).
2026-11-18 12:34:55 -08:00
Anees Iqbal 0afc54c573 rt tests: every instance runs under the validation layer, its log checked
Every instance rt's device tests open goes through one helper, crate::tests::validation. It
enables VK_LAYER_KHRONOS_validation for its own test process through the loader's and the
layer's own variables (VK_INSTANCE_LAYERS; report flags error,warn, debug action log, one log
file per process). It checks that every device of the cfg's kind lists an active validation
tool (vkGetPhysicalDeviceToolProperties), so a run whose loader found no layer fails. Once the
instance is gone, it reads the log, prints each line with the test's name and fails on any
message. The 41 sites that called Instance::new go through it; the exit-handler test reads its
child's log, since the child's instance never drops. One test makes a deliberately invalid
call (a buffer of size 0, refused by the layer) and checks that its log holds exactly
VUID-VkBufferCreateInfo-size-00912.

The product keeps no layer code and no variable read. Its one change is a visibility:
Instance's shared state is pub(crate), so the helper waits, bounded, on a weak handle of it
until the instance is gone, and only then reads the log.

scripts/validation-layer makes the layer's directory, one version (1.4.363.0) on every leg, as
a carry: Linux's copied from a node whose pacman package is that version and unaltered,
Windows's from MSYS2's clang64 packages checked against the package database's SHA-256, and
macOS's from a Homebrew install at that version. scripts/matrix carries it to every job that
runs rt's device tests (GPU legs, lavapipe, the Windows host), points VK_LAYER_PATH at it, and
puts the layer's version in the leg's note. A job without the layer says so and points the
loader at none. The harness's timing jobs run without it.

Verified: the matrix's unit tests (48, two new ones run the layer's shell for real) and the
layer carry made. Builds and legs follow.
2026-11-18 12:17:31 -08:00
Anees Iqbal 4b781a949c translator: a grid tile tests its edge only inside a branch on its region's ragged flag
On Device::from_queries' profile a kernel that runs its grid in tiles compared every
invocation's position with the grid's last thread before its body, on every dispatch. The
test now sits inside one uniform branch on the region's NONUNIFORM flag, which rt (and the
binder) already set for every region of a grid its workgroups do not divide: a ragged
dispatch runs today's test, and every other dispatch (a grid the workgroups divide, an
indirect dispatch) branches past it, its body deriving its position only where it reads it.
One pipeline serves both, so there is no added compile or first-use wait. Device::new's
profile has no grid tiles, so its modules are unchanged.

The branch is also what keeps a driver's scheduler from spreading a kernel's pushed-word
loads through its body: a form that dropped the branch lost 17-55% on a many-binding row on
RADV and the UHD 630.

SEMANTICS_VERSION 2180 -> 2181. The grid tile tests now run each grid flagged and
unflagged: flagged, no invocation past the grid stores; unflagged, a ragged grid's do, so
the flag alone guards the test.

Verified at the same change on 69af14bd22 (12f3602f1d): lint, the translator suite and rt on
lavapipe (m3-max-47411); rt's device tests 249/249 on the Iris (47443), the 7900 XTX and the
RTX 2080 (47498). Compiled code: the flag test is a wave-level scalar branch over the decode
and compare on RADV (7900 XTX, 47462) and a uniform branch on ANV (Iris, 47407); the
many-binding row's pushed-word loads stay together under one wait. Harness compute rows
against 69af14bd22, losses re-timed alone: UHD 630 (47436, 47449), Iris (47407), 7900 XTX
(47408, 47441), RTX 2080 (47408, 47441), RTX 3090 (47409, 47461), RX 550 and 780M (47406).
2026-11-18 11:13:29 -08:00
Anees Iqbal a914d524ea Re-derive the generated documents at the landing tip
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.
2026-11-18 11:05:35 -08:00
Anees Iqbal 1e8e5974fc REPLAY-STREAM: section 6 names the writes at a completion
The comparison point takes the GPU's bytes at a completion only for 4 KiB chunks wholly inside
GPU-only ranges, and a recorder may record what a command buffer's GPU work stored in memory the
CPU shares as writes after its commit: which chunks are compared, the Managed rule, why the
player's waits make them change nothing, and the restore they let a stream carry. The planner's
text, verbatim, for the recorder change that lands with it.

Doc only; no test reads this section.
2026-11-18 10:57:59 -08:00
Anees Iqbal 990328afe1 translator: from_queries' profile contains no threadgroup access, and an arena of whole float words is a float array
What: a new profile fact, device::profile::ThreadgroupMemory, says whether an access of
threadgroup memory is contained. Device::new's profile keeps Contained, byte for byte: a load past
an arena reads zero, a store past it is dropped, and a typed threadgroup object's dynamic index is
clamped to its level. Device::from_queries' profile takes Native: no threadgroup access is
contained, and an access past a kernel's threadgroup memory is undefined, as in Metal. One
predicate, lower::access::local's contained(), decides it at the six sites that contained one:
an arena's loads and stores, its atomics, memory intrinsics, pointer cells and imageblock, and a
typed threadgroup object's index. Device memory's containment is unchanged.

On the Native profile, a kernel's arena whose every access is a whole, aligned float word (a float
or a vector of 2 to 4, at an offset its alignment makes a multiple of 4, with no atomic, no memory
intrinsic and no access of another type: memory::Leaf::float_words) is a float array of its own
whole words, at least four (memory::arena::FLOAT_LEAST). Each access is one typed load or store per
lane at its word index, with no bounds compare, no select and no bitcast. Every other arena stays
the u32 array of composed words, unchecked on this profile. The census names the float form's
accesses access.threadgroup.load.floats and access.threadgroup.store.floats.
SpecOp::ISub, which only the contained arena's bound used, is deleted.

docs/API.md's threadgroup memory bullet says so. The runtime README's contract states that an
access past threadgroup memory is undefined, as in Metal, and that the runtime does not confine
it. SEMANTICS_VERSION 2180; the old render key's pin moves with it.

Why: Metal leaves an access past threadgroup memory undefined, so containing it changes nothing a
correct program observes. Containment cost GPU time on every card measured: each access paid a
bounds compare and a select, and each composed word paid its bitcasts.

Verified (A = before this change, D = this change, both on from_queries):
- GPU p50 of the harness rows whose kernels use threadgroup memory or SIMD-group operations,
  D over A, the median over 6 rounds of each. threadgroup_floats is a float scan that the probe
  harness adds. No other row's kernel declares threadgroup memory (workloads.metal).
  - UHD 630 (job 47289): threadgroup_scan 0.972, threadgroup_floats 0.892, simd_reduce 1.000,
    vote_loop 1.000.
  - Iris Xe (47290): threadgroup_scan 0.965, threadgroup_floats 0.919, simd_reduce 1.000,
    vote_loop 1.000.
  - Each arm's spread (its largest run over its smallest) is at most 1.013 on both cards.
- Driver compile per kernel on the UHD 630, the median of 5 cold processes per arm, each with a
  fresh store and driver cache and the module bytes salted (47319). Every process exited 0. D over
  A: the float scan 0.716, the typed scan 0.945, the SIMD reduce 0.951; the two kernels whose
  modules are the same in both arms 0.998 and 1.062.
- The same on the Iris Xe (47349): the float scan 0.678. The typed scan (1.108) and the SIMD
  reduce (1.19) are inside the run-to-run spread of 1.164 that a module equal in both arms shows.
- Cold plays of a replay stream up to frame 216, 4 per arm, with the arms alternated. Every
  threadgroup kernel matched by function identity, 16 of 16 in each arm.
  - RTX 2080 (47294): GPU 378.1 ms in A, 307.9 ms in D; driver 1154.8 ms against 1158.8 ms.
    The 128-wide kernels: 0.634 (18 dispatches) and 0.793 (65). The 64-wide kernels: 0.808 to
    0.959. The 1024-wide kernel: 0.933. The 395-dispatch kernel: p50 1.010, its total 0.996.
  - Radeon 780M (47295): GPU 127.8 ms in A, 116.8 ms in D; driver 234.7 ms against 202.6 ms.
    Every kernel's p50 is at or under A's: the 128-wide kernels 0.826 (18 dispatches), 0.799 (65)
    and 0.966 (5); the 64-wide kernels 0.815 to 0.938; the 1024-wide kernels 0.981 and 0.978;
    the 395-dispatch kernel p50 0.981, its total 1.006.
- Rebased on 11dc2d46d5: clippy with all features and with --cfg m2v_gpu clean; the translator's
  and the new runtime's whole suites 3831 of 3832, the one failure the old render key's pin, which
  SEMANTICS_VERSION 2180 moves; re-pinned here, it passes (47341). The golden-hash tests among them pass unchanged.
- No test of this change asserts what an access past threadgroup memory does. The containment
  tests of Device::new's profile stand.
2026-11-18 10:44:29 -08:00
Anees Iqbal f811e7cc2d replay: delete the unbound-buffer-read counter, whose reflection decoded each pipeline state's AIR again inside the play's pipeline time
The counter (74fe5e67ca) asked the translator for each pipeline state's reflection to learn its
used buffer arguments. From a Function source that reflection decodes and specializes the
kernel's AIR a second time, inside the backend call the player books as pipeline cost, so every
play paid it: on b3 on the 780M, pipeline time 11.9 s against 1.5 s at f0df30b6ba with the same
403 translations (exclusive A/B, 47329). Its follow-up is dropped, so the count, its report line,
its per-frame counter, its test and its paragraph in REPLAY-STREAM.md go.

Verified: see the exclusive A/B in the hand-over (b3, 780M, development's tip against this).
2026-11-18 10:15:38 -08:00
Anees Iqbal 11dc2d46d5 translator: a removed argument's read takes zero and writes no status on from_queries' profile
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).
2026-11-18 10:02:42 -08:00
Anees Iqbal 9be118cb5b rt: a take answers its zero mark, and the consumer asks for a Private range's zeros
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.
2026-11-18 09:49:56 -08:00
Anees Iqbal a47fc3e69d translator: an argument buffer's texture index is masked to the set-1 image arrays
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.
2026-11-18 09:37:25 -08:00
Anees Iqbal 0463eb6d2d replay: a placement waits for the commits that named its index's holders, which count once retired
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.
2026-11-18 09:01:28 -08:00
Anees Iqbal 74fe5e67ca replay: count the draws and dispatches whose pipeline reads a buffer argument nothing is bound to
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).
2026-11-18 09:01:28 -08:00
Anees Iqbal 71a22fc2be command-replay: a play that ends with differing IDs exits 3 with an ids line, apart from a stopped run
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.
2026-11-18 09:01:28 -08:00
Anees Iqbal 9f2ca244ff rt: attachment reads through a copy into a shadow, on a device without the feedback loop
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.
2026-11-18 08:57:13 -08:00
Anees Iqbal fe23decd1b rt: a constexpr sampler's index under the owner rule, and an object released with work pending
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.
2026-11-18 07:43:13 -08:00
Anees Iqbal fd916e7f99 rt: an index has one owner, the texture or sampler placed there last
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.
2026-11-18 07:43:13 -08:00
Anees Iqbal cc9ab54b86 rt: one texture index class, 1 to 65,535, and a storage array as long as the sampled
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).
2026-11-18 07:43:12 -08:00
Anees Iqbal da02260f2b Re-derive the generated documents at the landing tip
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.
2026-11-18 07:41:26 -08:00
Anees Iqbal 0c6d48aa7b replay: the player zeroes each block and heap of the stream once at its making
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.
2026-11-18 07:33:33 -08:00
Anees Iqbal b527ae9f68 rt, translator: a step above 1 on a device without supportsNonZeroFirstInstance runs from base instance 0
Vulkan's divisor needs firstInstance 0 where the device does not report supportsNonZeroFirstInstance
(VUID-vkCmdDraw-pNext-09461): lavapipe and the UHD 630 among the lab's devices. The translator
refused the step there under the identity domains, as a Metal draw may carry a base instance, so
those devices lost every draw through such a state, base instance 0 included. The WebGL divisor
stream draws 462 times through its two stepped states, every draw at base instance 0 (it calls no
baseInstance form and draws nothing indirectly).

Now, under the identity domains, fetch_as takes the divisor wherever the profile has
vertexAttributeInstanceRateDivisor and the rate is within maxVertexAttribDivisor; outside them the
step is pulled where the property is missing, as before, so the old runtime's path is unchanged.
divided() names the feature or the limit; its not-implemented arm had no caller left and is gone.
The new runtime marks such a state where the device lacks the property
(Draws::first_instance_zero) and refuses a draw through it at a base instance other than 0,
Gap::Draw { DividedBaseInstance }, before anything is recorded; a draw of no vertices or instances
still records nothing. Indirect draws are not built in the new runtime.

Tests: from_queries_divides_an_instance_step_where_the_divisor_feature_is_enabled (lavapipe and
moltenvk-m3 profiles, with and without the property: an instance-rate binding of divisor 2, both
modules L3-valid; rate 5 past a limit of 4 refused naming it). The device test
every_device_with_the_step_rates_fetches_per_instance_at_rate_2_from_the_base_instance draws from
base instance 0 on every device with the step rates (every texel the first mark) and from base
instance 1 where the property is reported (the second mark), expecting DividedBaseInstance where it
is not, and prints which path ran.

docs/REFUSALS.md regenerated (scripts/refusal-surface/refusal_surface.py): VertexStepRate has one
site. The rt README names the draw refusal on those devices; docs/API.md the identity-domain rule.
2026-11-18 07:20:24 -08:00
Anees Iqbal 6f8d3ebc14 conformance: record and time vertex-step-rate-instances on the M3 Max
Record mode (job m3-max-46378 at 37f73671dd, an Apple M3 Max, macOS 27.0.1 26A434) took the case's
Metal answer: plain Metal ran the pass with no error. Every instance fetched element
base + (iid - base) / rate, its count starting at the draw's base instance:
- rate 2 from base instance 0: elements 0, 0, 1, 1 (words 0x10, 0x10, 0x11, 0x11);
- rate 2 from base instance 5: 5, 5, 6, 6 (a count from instance 0 would read 2, 3, 3, 4);
- rate 3 from base instance 0: 0, 0, 0, 1;
- rate 3 from base instance 5: 5, 5, 5, 6 (from instance 0: 1, 2, 2, 2).
That is Vulkan's divisor, firstInstance + (instanceIndex - firstInstance) / divisor.
conformance times --runs 8 --write (same job) wrote both legs' figures: within the 10x margin, the
margin reported unjudged (the instrument's floor read 17.77 instrument costs on Metal's leg). The same
job's replay on the M3 Max (the old runtime over MoltenVK) reads exact.

docs/CONFORMANCE-COVERAGE.md regenerated (scripts/conformance-coverage/coverage.py).
2026-11-18 07:20:24 -08:00
Anees Iqbal cecc252f26 rt: refuse indirect arguments and indices a placement puts off Vulkan's multiple
The consumer places buffers at any byte of a block, so a buffer's place in its block's VkBuffer
plus a Metal-valid offset can miss the multiple Vulkan reads at. Metal's own rules (an indirect
offset a multiple of 4, an index offset a multiple of the index size) assume a buffer that starts
at an aligned address, as every Metal buffer does; here the absolute offset is what Vulkan sees:

- VUID-vkCmdDispatchIndirect-offset-02710: the offset in the VkBuffer is a multiple of 4.
- VUID-vkCmdBindIndexBuffer-offset-08783: the offset plus the base of the memory range backing
  the VkBuffer is a multiple of the index size. A block's VkBuffer is bound at a multiple of the
  pool's granule (64 KiB) or at 0 of its own allocation, so the place in the VkBuffer decides it.

dispatch_threadgroups_with_indirect_buffer and draw_indexed_primitives now check the place in the
block (the device copy's, for a Managed buffer with one, which is what the GPU reads) after
Metal's own checks and refuse with the new Refusal::ArgumentPlace { place, alignment }, basis
ours. Nothing is copied to an aligned place: a copy is not a design answer here.

Tests (device cfg): every_device_reads_indirect_arguments_only_at_a_multiple_of_4_of_their_block
places a buffer 2 bytes into a Shared block and shows offsets 0 and 16 refused at places 2 and 18,
then dispatches from a buffer placed at byte 4100 and checks the result;
every_device_takes_indices_only_at_a_multiple_of_their_size_in_their_block places indices 2
bytes into a block and shows 32-bit indices at offset 0 refused (place 2, alignment 4) before
anything is recorded, then draws 16-bit indices from there and checks the texels and the pass's
counts. README's placement contract names the rule; docs/REFUSALS.md regenerated; the API table
gains the variant.
2026-11-18 06:41:16 -08:00
Anees Iqbal c459695b88 rt: the consumer places a Managed buffer's device copy, in a Private block it holds, at any byte offset
new_managed_buffer(bytes, copy, length, copied) takes both placements from the consumer: the
bytes as (block, offset) in a block the host maps, and on a device that keeps a device copy
(has_unified_memory false) the copy as (block, offset) in a Private block the consumer holds, at
any byte offset; gpu_address is that block's address plus the offset. rt chooses no layout any
more: its copy blocks, COPY_ALIGN, the first fit and the device's copies place list are deleted,
and so is the Private block of the copy's own that the copy took where device-local memory had
no room. Placement, and so the slack past a buffer's length, is the consumer's: rt writes the
copy's length and no byte past it.

New typed refusals: ManagedCopyMissing (no copy where the device keeps one),
ManagedCopyOnUnified (a copy where it keeps none) and ManagedCopyNotPrivate (a copy in a block
that is not Private); a copy range past its block is BufferPastBlock, as for any buffer.
managed_spilled_bytes is now per buffer: a copy the consumer placed in a spilled Private block
counts its length while the buffer lives. new_buffer shares the range check (placed).

The harness places a Managed buffer's device copy as it places a Private buffer of its length
and frees both with the buffer. The player places the GPU copy through its places at their
current rule, as a Private buffer of the buffer's length: a buffer in a place of its own keeps
the copy's place beside its own and gives both back with the same users; a buffer in a stream's
block or heap holds the copy's place as its one place. REPLAY-STREAM.md says so.

Tests: the two-copy rule places its device copy 4 KiB into a Private block the consumer takes
and checks gpu_address there (and, under the spill test, in a consumer take that spills, counted
in managed_spilled_bytes); a new device test places the copy at byte 4099 of a Private block
filled with 0xA5 and checks the whole block after the copy's creation and after a copy-in of the
whole buffer: the copy's bytes at 4099..5099 alone, the consumer's slack write at 5100..5200 and
every other byte unchanged; and the four refusals. Every other Managed test places its copy at
the start of a Private block of its own (tests::managed::on_device::new_managed).

Regenerated docs/REFUSALS.md (scripts/refusal-surface); api_signatures.tsv by hand.
2026-11-18 06:16:37 -08:00