781 Commits
Author SHA1 Message Date
千川白浪 8fd7fb5d9c Merge pull request #3 from liuyaxuan123457-ctrl/fix/host-batch-queue-recording
Allow host-owned copy batches to record before FIFO submission
2026-12-05 13:43:28 +08:00
Xiaochi You b8f9629ba8 Merge pull request #5 from yxc0915/steelbrain/batch-fixed-offset-draws
Batch fixed-offset draws with direct Vulkan commands
2026-12-04 18:13:58 +08:00
YXC0915 1dd4e970c0 🐎 Batch fixed-offset draws with direct Vulkan commands
Reuse the ordinary draw state across a fixed binding without submitting indirect commands. RX 6500M timing showed the indirect command path still took 0.909 ms against 0.351 ms for the same direct workload, even with the ordinary shader.
2026-12-04 18:02:14 +08:00
YXC0915 acb2f3756b 🐎 Keep fixed-offset multi-draw on the ordinary pipeline
Combine repeated vertex bindings without uploading a draw table or switching the shader. Preserve the table path for changing offsets, and exclude modules that can observe DrawIndex. Add a pixel parity and pipeline reuse regression test.
2026-12-04 17:48:08 +08:00
Xiaochi You 8edd5cd27a Merge pull request #4 from yxc0915/steelbrain/sync-metal2vulkan-865592b
Merge the upstream Vulkan runtime into development
2026-12-04 16:10:31 +08:00
YXC0915 7b3aedb5fa Sync upstream metal2vulkan for the Reims runtime
Preserve GPU suspend and replay, Places allocation isolation, and multi-draw indirect. Use the upstream render-offset deltas, static attachment feedback, and 64-bit device-address arithmetic.
2026-12-04 16:07:39 +08:00
designgears 865592b96b Merge pull request #27 from celebratedfox9185/metal2vulkan-upstream-b 2026-12-03 16:10:19 -08:00
designgears de89bc41f2 Merge pull request #26 from celebratedfox9185/metal2vulkan-upstream 2026-12-03 16:10:19 -08:00
Anees Iqbal d70e728f4c Pin W bless: the golden cells and the census differences by the commit that moved them
The bless commit b4d134337b left its attribution pending on the M3's jobs. This commit carries it and changes
no file.

The authored compile census at 458b5420d2 differs from pin V's in 45 cells. Every one goes from refused
(IdentityDomains) to compiled, and none is unexplained: 5 cases on 9 profiles, all sparse-residency cases
(0d627fc4, 2f94ada2, 667f44ce, 88e8c1ea, b8fd5c9e), compiled once a texture's observed residency is the
constant resident word (619e977d63, SEMANTICS 2368). The same commit moves the artifact digest of 6 more
cases (30 moved artifacts). Each commit of the range was checked out on the M3 and its census blessed alone
(m3-max-85975); every later step moves only the artifacts_at product line, and the last table equals the one
b4d134337b commits.

The golden hash table moves from pin V's (133c992dad) to the blessed one by these commits. Each version
mover between the two was checked out on the M3 and blessed alone (m3-max-85922), and the tables were diffed
in history order. The last table equals the one b4d134337b commits.
- 619e977d63, SEMANTICS 2368, a texture's observed residency is the constant resident word: 294 cells in 20
  rows (the sparse fixtures' .ll and .air.ll rows: a27_spse_write_barrier, a2_sparse_status,
  kernel_block_read's br_sparse, sps2_residency_probes and the spse_* probes).
- 2ec06b93e1 (the sparse path goes), c20024991d, 7c65d9875e and 458b5420d2 move no cell.
- b4f3ef18de (SEMANTICS 2369) and e9e52050d0 (SEMANTICS 2370) move the semantics line alone.
In all, 294 cell moves, no row added or removed.
2026-12-03 16:10:19 -08:00
Anees Iqbal b4d134337b Pin W bless: golden hashes, engine inventory and the authored compile census at 458b5420d2
Re-blessed on the Apple M3 Max at 458b5420d2 (job m3-max-85891: inventory=0, golden=0,
printouts=0, linkhalf=0) and the authored compile census (m3-max-85892: cases=2390,
cells=21510, failed=0, regressions=0, differences=45).

- golden_hashes.tsv: the semantics line moves 2367 -> 2370 and 20 rows change cells.
  Attribution per commit: PENDING m3-max-85922.
- public_fixture_expectations_engine.tsv: 10 .air.ll rows of the sparse fixtures (a2's
  deletion of the sparse path) move from Unsupported{IdentityDomains; NotImplemented} to ok,
  as their .ll rows already read: on all 15 profiles for 7, and on 14 of 15 for
  a27_spse_write_barrier, spse_write_barrier and spse_write_probes, whose last profile stays
  Unsupported as their .ll rows do.
- authored-compile.tsv: 5 cases move from not_supported (IdentityDomains) to compiled on all
  9 profiles (0d627fc4, 2f94ada2, 667f44ce, 88e8c1ea, b8fd5c9e); 6 more change only their
  artifact digest; 0 failed, 0 regressions.
2026-12-03 15:30:08 -08:00
Anees Iqbal 458b5420d2 Conformance probe: the viewport depth range's values row, Clamp mode, Depth16Unorm and the depth test
The probe takes a table of cases: each a range, a depth attachment (none,
Depth32Float or Depth16Unorm), a fragment (plain, or one that writes
[[depth(any)]] = [[position]].z), a depth clip mode, five quads' clip z, a
clear depth and a compare function. Each column prints whether a fragment
landed, the position.z and .w it read, and the stored depth.

Recorded on the Apple M3 Max, macOS 27.0.1 (job m3-max-85617), plain and
under API validation, byte for byte alike, in the probe's header:
- Clip mode: position.z is never clamped; clip space's 0 <= z <= w holds
  whatever the range; Depth32Float, Depth16Unorm and a [[depth]] output
  store the z clamped to [0, 1]; the depth test compares that clamped
  value on both sides of 0 and of 1.
- Clamp mode: no z clip; position.z is never clamped; the stored depth is
  clamped to the range's part in [0, 1] ([0.5, 2] stores 0.5 to 1).
2026-12-03 15:15:17 -08:00
Anees Iqbal 1d6054b189 Runtime: a viewport depth range past [0, 1] draws where nothing reads the depth
Metal and its API validation take a viewport whose znear and zfar lie past
[0, 1] (OpenGL's [-1, 1]). The M3 Max (macOS 27.0.1, job m3-max-85541, the
probe in the commit before) reads [[position]].z = znear + z * (zfar - znear)
unclamped and stores that, and a [[depth]] output, clamped to [0, 1]. The
runtime refused such a viewport at set_viewport wherever it covered a pixel,
because VkViewport takes depths in [0, 1] alone without
VK_EXT_depth_range_unrestricted, which the runtime does not enable.

The cause is the depth range alone: clipping is in clip space on both APIs,
so the range shows only where something reads the window z. That is a depth
attachment, or a fragment function that reads [[position]]'s z or w. The fix
takes the range everywhere else:
- set_viewport and set_viewports keep the range; vk_viewport records it cut
  to [0, 1].
- Whether a range is past [0, 1] is found once, when the viewports are set
  (viewports_set).
- Whether draws are refused is found when the viewports or the pipeline
  state are set (draws_refused, into the encoder's `refused` field).
  AttachmentFormats comes first, then Viewport where the pass has a depth
  attachment or the state's fragment function may read [[position]] z or w.
- A draw reads that one Option<DrawKind> where it read the renders_into
  bool, so the usual path adds no per-draw instruction. The other draws
  under such a range are refused there (Gap::Draw, DrawKind::Viewport), not
  at the set.
- metal2vulkan: CompiledFunction::reads_position_depth (the stage's
  position_depth with its FragCoord builtin), public, with its row in
  api_signatures.tsv. No encoding change.
- metal2vulkan-runtime: RenderCompiled::reads_position_depth.

DrawKind::Viewport's doc, set_viewport's, depth_stencil's note and the
runtime README (the viewport paragraph, a known-gap paragraph for the range,
and the Gap::Draw list) say what is taken and what is refused.
docs/REFUSALS.md regenerated: no change (the refusal's sites are the same
two functions). RUNTIME_VERSION 2571 (renumbered at landing): a run that refused at
set_viewport now draws or refuses at the draw. The runtime-sources pin does
not move (no listed input changed).

Verified: see the READY's job lines (red at the commit before, this commit
green, clippy in three configurations, rustdoc, the runtime suite on
lavapipe).
2026-12-03 15:15:17 -08:00
Anees Iqbal 379d2414df Conformance probe: what Metal does with a viewport depth range past [0, 1]
A probe of setViewport: with znear -1, zfar 1 beside the control [0, 1]:
five quads at clip z 0 to 1 into an RGBA32Float target, with and without
a Depth32Float attachment, through a plain fragment and one that writes
[[depth(any)]] = [[position]].z. Each prints the position.z and .w the
fragment read and the depth the attachment stored, plain and under
Metal's API validation layer.

Recorded on the Apple M3 Max, macOS 27.0.1 (job m3-max-85541), in the
probe's header: Metal and its validation take the range; position.z is
znear + z * (zfar - znear) unclamped; the stored depth and a [[depth]]
output are clamped to [0, 1].
2026-12-03 15:15:11 -08:00
Anees Iqbal 948f47bfff Runtime tests: a viewport depth range past [0, 1] draws where nothing reads the depth (red)
Metal takes a viewport whose znear and zfar lie past [0, 1] (OpenGL's
[-1, 1]); its API validation takes it too. The runtime refuses it at
set_viewport wherever it covers a pixel (Gap::Draw, DrawKind::Viewport).

The new device test sets [-1, 1] over the whole target and expects:
- set_viewport and set_viewports take it;
- a draw whose pass has no depth attachment and whose fragment function
  reads no [[position]] z or w draws, as Metal draws it (clipping is in
  clip space, so the range shows nowhere);
- a draw whose fragment function reads [[position]].z is refused at the
  draw, alone or with the range as the second of two viewports, and
  draws once the range is in [0, 1];
- a draw into a Depth32Float attachment is refused at the draw, and
  draws once the range is in [0, 1];
- the refusal follows the state set: from the reading function to the
  plain one and back.

Red here: set_viewport refuses the range. The fix follows.
2026-12-03 15:15:11 -08:00
Anees Iqbal e9e52050d0 Runtime and translator: a compute encoder binds a buffer with its attribute stride, and a dynamic stage-in layout fetches at it
What:
- ComputeCommandEncoder gains three methods:
  set_buffer_with_attribute_stride (setBuffer:offset:attributeStride:atIndex:;
  setBuffers:offsets:attributeStrides:withRange: is a loop of it, as every
  other range call of the runtime is), set_buffer_offset_with_attribute_stride
  (setBufferOffset:attributeStride:atIndex:) and
  set_bytes_with_attribute_stride (setBytes:length:attributeStride:atIndex:).
- Each buffer slot's binding (Slot::Buffer, Slot::Bytes) keeps the stride's
  low 32 bits, so MTLAttributeStrideStatic is 2^32 - 1. A new
  FieldValue::StageInStride(slot) pushes it. It is mapped from the
  translator's PushField::StageInStride, and the interface accepts
  RuntimeFact::StageInStride.
- set_buffer, set_buffer_offset and set_bytes bind a stride of 0, which
  clears an earlier one. That includes set_buffer of the buffer and offset
  the slot already holds, which used to return early.
- Translator: the identity domains accept PushField::StageInStride
  (lower/select.rs), as they accept the vertex analogue
  PushField::VertexBufferStride. Before, a dynamic layout was their typed
  refusal, EncoderValue "StageInStride(1)". The translator test
  a_fixed_layout_records_no_stride_and_a_dynamic_one_records_its_own now
  makes the pipeline, which records RuntimeFact::StageInStride of layouts 1
  and 2 and none for layout 3, the constant step.
- Deleted: StageInKind::DynamicStride, unbuilt_stage_in and its call at
  state creation. Gap::StageIn now names only IndirectRegion.
- Conformance:
  - The runtime side plays the four attributeStride steps and
    setStageInRegion:.
  - The four DynamicStride ledger rows of attribute-stride-buffer,
    -buffer-offset, -inline-bytes and -plural-buffers are replaced by each
    case's dispatchType row (case/outcome/dispatch_type, the consumer's own),
    which every compute-pass case carries.
  - CONFORMANCE-COVERAGE.md is regenerated.
- Regenerated:
  - REFUSALS.md and error/basis.rs;
  - METAL-COVERAGE.md and coverage.tsv (the four setters are implemented);
  - api_signatures.tsv (three methods added, one variant removed).
- Docs:
  - The runtime README's compute section and its known gaps.
  - Validation's ToolingRequirement::DynamicStageInStride doc: the runtime
    builds the layout, and the engine's candidate does not yet bind with the
    stride form. Its classification is unchanged.
- Versions, renumbered at landing: RUNTIME_VERSION 2570 and
  SEMANTICS_VERSION 2370, because the
  translator's refusal becomes a pipeline. runtime-sources.sha256 does not
  move: lower/select.rs, cache/mod.rs and the runtime crate are not among
  its inputs.

Why: the planner ruled DynamicStride BUILD. The translator already lowered
the fetch at PushField::StageInStride. The runtime refused the state because
its compute encoder had no attributeStride setter and no field that pushed
the stride, and the identity domains refused that encoder value.

What a plain bind reads: Metal documents no answer for a plain bind of a
slot that a dynamic layout reads, and the debug layer answers differently.
Probe dynamic_stride_plain_binds.m, job m3-max-85456 (Apple M3 Max, macOS
27.0.1), read stride 0 for every plain bind, alone and after a stride bind
(setBuffer:offset:atIndex:, setBufferOffset:atIndex:,
setBytes:length:atIndex:). Its stride-8 control read stride 8. The planner
ruled to build that answer without pinning it against Metal: there is no
conformance row for it. The setter's doc says Metal documents no answer, and
the runtime device test below holds the runtime's own behaviour.

Consumer search (git grep -n -w DynamicStride in the consumer's checkout at
a34e93e4fa): 8 hits.
- Code that will no longer compile:
  - rt_platform/diag.rs:3077 and :3085 name rt::StageInKind::DynamicStride
    in a test.
- Tests that will fail:
  - rt_platform/compute.rs:1394 expects the dynamic-stride state to be
    refused (StageIn-DynamicStride).
- Docs and comments:
  - rt_platform/compute.rs:18 and :1246.
  - rt_platform/diag.rs:7 and :3081.
  - docs/accuracy-ledger.md:129.
Per compute.rs:14, the consumer binds the attributeStride selectors as the
calls without them. It can now call these setters.

Tests: every_device_fetches_a_dynamic_stride_layout_at_the_stride_each_bind_gives
makes ten binds and dispatches:
- strides 40 and 80, 2^32 + 40 (reads at 40), and MTLAttributeStrideStatic
  (thread 0's element, then zeros);
- set_buffer of the same buffer and offset after a stride bind (stride 0);
- set_buffer_offset after a stride bind (stride 0, one element on);
- set_buffer_offset_with_attribute_stride;
- set_bytes_with_attribute_stride;
- set_bytes after a bytes stride bind, and after a buffer stride bind
  (stride 0).

Verified, at this tree (2f654e598c before the fold):
- Device tests, filtered test(stage_in) | test(dynamic_stride), 8 tests
  each, every one passed; each card printed the dynamic-stride test's line:
  - lavapipe, job m3-max-85611 (998 skipped);
  - RX 7900 XTX (RADV, Mesa 26.2.6), job m3-max-85587, --cfg m2v_gpu;
  - RTX 3090 (NVIDIA 620.70.06), job m3-max-85588, --cfg m2v_gpu;
  - Iris Xe (ANV, Mesa 26.2.6), job m3-max-85601, --cfg m2v_gpu.
- Conformance replay of attribute-stride-buffer, -buffer-offset,
  -inline-bytes and -plural-buffers on the same four devices, same jobs:
  EXIT=0. Each case's one refusal is its dispatchType ledger row, with no
  divergence, so every stride slot read the words the M3 recorded,
  MTLAttributeStrideStatic and the 2^32-truncated strides included.
- Suites, job m3-max-85586:
  - product: 3471 passed, 4 failed, 24 skipped. One failure is
    golden_hashes_match_the_table (the SEMANTICS placeholder; golden tables
    are re-blessed on development). The other three are the fixture tables
    inventory_lists_every_fixture_in_order,
    engine_fixtures_match_their_golden_printout and llvm_as::part_5_of_8.
    All three fail on engine/dvw_depth_views, which development's
    aedc38190f added without rows in public_fixture_expectations_engine.tsv
    or an air_input printout. No file of this change touches them.
  - validation: 1344 passed, 2 skipped.
  - conformance: 1059 passed, 0 skipped.
  - doctests: EXIT=0.
- clippy: plain m3-max-85592, --cfg m2v_gpu m3-max-85593 and
  --cfg m2v_cpu_icd m3-max-85602, each EXIT=0.
- rustdoc, api-docs and rustdoc --document-private-items: job m3-max-85599,
  EXIT=0.
- refusal_surface, metal-coverage, conformance-coverage and api-signatures
  --check: current.
2026-12-03 15:15:11 -08:00
Anees Iqbal c41b6649d7 Runtime tests: a thread-position stage-in layout of a dynamic stride makes its state (red)
What: every_device_refuses_each_unbuilt_stage_in_form_by_its_kind no longer
expects Gap::StageIn of DynamicStride for a [[stage_in]] attribute the kernel
reads through a thread-position layout of MTLBufferLayoutStrideDynamic. That
descriptor joins the constant step and the unread attribute in the list of
descriptors whose state is made. The indirect stage-in region
(IndirectRegion) stays refused at its call.

Why: the planner ruled DynamicStride BUILD. The translator already fetches
such a layout at the stride the binder pushes (PushField::StageInStride,
RuntimeFact::StageInStride). The runtime refuses it at creation only because
the compute encoder has no attributeStride setter and no field that pushes
the stride. This commit is the red half; the fix adds the setters and the
field.

Verified: on lavapipe (llvmpipe, Mesa 26.2.4, LLVM 23.1.1), job m3-max-85611, this tree fails
every_device_refuses_each_unbuilt_stage_in_form_by_its_kind with "a thread-position step of a
dynamic layout: a kernel's stage input of a form not built yet: DynamicStride" (filtered
test(stage_in) | test(dynamic_stride): 7 tests run, 6 passed, 1 failed, 998 skipped); with the fix
it passes.
2026-12-03 15:15:04 -08:00
Anees Iqbal 9b7f8f983f Conformance probe: what a dynamic-stride stage-in reads when its buffer is bound without a stride
A kernel reads one uint [[stage_in]] attribute through a thread-position
layout of MTLBufferLayoutStrideDynamic. Six rows bind its buffer:
- plain setBuffer:offset:atIndex: alone;
- setBuffer:offset:attributeStride:8 alone, the control;
- the stride bind followed by a plain setBuffer, by a plain
  setBufferOffset, or by a plain setBytes;
- plain setBytes alone.
Each row prints the eight words its threads read and the stride those
words imply. Metal's headers name the stride setters as the ones to call
for such a layout and say nothing of what a plain bind reads, so the
runtime's binding of a plain setter's stride follows this reading.

Verified: the M3 oracle job that reads it follows. Here, xcrun clang
-fsyntax-only only.
2026-12-03 15:15:03 -08:00
Anees Iqbal 34b4888fcf Translator: a pointer cell stores a constant getelementptr into a blob global as its blob offset
cell::constant, the form of a constant pointer stored into a pointer cell, took a blob global's
address through blob::blob_ptr but matched Const::GlobalAddr alone. So it refused a constant
getelementptr or cast of the global (ConstantOperand), which blob_ptr takes since the commit
before last. It now matches Const::Expr too and stores the offset blob_ptr gives.
a_stored_constant_getelementptr_into_a_blob_global_is_its_blob_offset passes with this commit.
The SEMANTICS_VERSION placeholder of this series covers it.
2026-12-03 15:15:03 -08:00
Anees Iqbal 2850eda8f4 Translator tests: a constant getelementptr into a blob global stored in a pointer cell (red)
A slot is written with a constant getelementptr into the constant table @k on odd threads and
with @k's address on even ones, then read back and indexed. @k is stored, so it is placed in
the blob, and the slot holds a blob offset either way. Run on every committed profile, each
thread reads its table word.

This fails here: the cell's constant form (cell::constant) takes a blob global's address but
refuses a constant getelementptr of one (ConstantOperand), the same defect as blob_ptr's before
the previous commit.
2026-12-03 15:15:03 -08:00
Anees Iqbal 4aa0fe9388 Translator: a constant getelementptr into a blob global is its blob offset and displacement
blob_ptr is the operand form every blob strategy takes for a pointer: a getelementptr's base, a
copy's source, a select's arms, a load's pointer, a memcpy endpoint, a pointer compare and a
fat-pointer select's blob side. It took a blob global's address as the global's blob offset, but
it refused a constant getelementptr or same-space cast of one (ConstantOperand). The arena
family's local_ptr already takes those at their exact displacement from the memory plan. blob_ptr
now does the same: the constant's addressed global (local::addressed_global, now visible to the
access family) gives the blob offset, and the plan's exact offset of the constant is added.
Like a getelementptr's constant, the sum wraps modulo 2^32, and a load through it is contained.

This is the same defect as the select's: a blob global's address as an operand was not taken in
the blob's operand form. a_constant_getelementptr_into_a_blob_global_is_its_blob_offset_and_
displacement (a select arm and a getelementptr base) passes with this commit. The
SEMANTICS_VERSION placeholder of the previous commit covers it.
2026-12-03 15:15:03 -08:00
Anees Iqbal b4f3ef18de Translator: a select of two blob pointers takes a constant arm as its blob offset
BlobStrategy::Select read its arms through operand(), which refuses any constant other than
null. So a select between two constant globals' addresses was refused (ConstantOperand), even
though both arms are blob addresses. The arms are now LocalPtrs taken through blob_ptr at
selection and emitted through ptr_value, the same way the Gep base, the Copy source and the Load
pointer already take theirs. A global's address is now its blob offset.

That was the cause: the strategy did not take its pointer operands through the blob's operand
form. This commit checks every other site that can take a blob global's address as an operand:
- getelementptr base, bitcast/addrspacecast/freeze source, load pointer: blob_ptr (handled).
- a fat-pointer select's blob side (access::select_side): blob_ptr (handled).
- a memcpy endpoint (copy.rs) and a pointer stored as a value (cell.rs, which matches
  Const::GlobalAddr itself): blob_ptr (handled).
- icmp of two blob pointers (pointer::compare): blob_ptr (handled). A blob pointer against null
  or a fat pointer is refused (PointerCompare), typed.
- a store through a blob pointer: refused (ReadOnlyStore), typed. The blob is constant.
- ptrtoint of a blob pointer: not the static form, so it goes to the dynamic family, as before.
- a pointer phi with a constant incoming value: refused (ConstantOperand), typed and documented,
  as for the arena families (blob::lowered_pointer).
- blob_ptr itself refuses a constant getelementptr or cast of a blob global, which the next
  commit takes.

SEMANTICS_VERSION 2369 (renumbered at landing): a module refused before now
compiles. a_select_of_blob_globals_selects_their_blob_offsets passes with this commit;
a_constant_getelementptr_into_a_blob_global_is_its_blob_offset_and_displacement still fails here
and passes with the next.
2026-12-03 15:15:03 -08:00
Anees Iqbal cf5c952c6d Translator tests: a select of blob globals' addresses, and a constant getelementptr into one (red)
Two kernels read two constant globals, @a and @b. A select between their addresses merges
them, so both are placed in the constant blob. The first test selects between the two
globals' addresses. The second takes a constant getelementptr into one global, once as a
select's arm and once as a dynamic getelementptr's base. Each test checks the census for the
blob pointer select, then runs on every committed profile and checks every thread's two words
on both runs.

Both fail here: BlobStrategy::Select reads its arms as plain operands, which refuse a constant
(ConstantOperand). blob_ptr takes a global's address as its blob offset but refuses a constant
getelementptr or cast of it, while the arena family's local_ptr takes one at its exact
displacement.
2026-12-03 15:14:56 -08:00
Anees Iqbal 03b5cff006 Runtime README: KosmicKrisp's answer for a texture over host memory with render-target usage
A texture over a buffer in host memory's import, on an integrated or CPU device, lies in place
where the device's external image query for host memory's handle answers a linear image of the
texture's format, usage and flags; otherwise it is the counted copy at each use. On the Apple M3
Max (KosmicKrisp, Mesa 26.3.1), the textures with render-target usage in a consumer's walk
were the copy. The known gap of memory blocks said why in one clause (the Mac driver makes no
linear colour attachment with or without a handle); it now names the query's answer and the
shapes it was asked for, and says the copy is chosen by that query alone. The ruling: the copy is
the device's form under rule 2 (a missing feature of the driver, not a bug), with no code change.

The answer, asked of KosmicKrisp with the runtime's own parameters for each of the four kinds of
texture with render-target usage the walk made over host memory (R8Unorm 1920 by 1080 and RG8Unorm
960 by 540, ShaderRead and RenderTarget; RGBA8Unorm at 18, 24, 36 and 48 pixels, ShaderRead,
ShaderWrite and RenderTarget; RGBA16Float at 16 to 1024 pixels, ShaderRead and RenderTarget):
vkGetPhysicalDeviceImageFormatProperties2 for linear tiling, usage transfer source and destination,
sampled and colour attachment (and storage for the written one), mutable format with the sRGB
sibling's format list where the format has one, and
VK_EXTERNAL_MEMORY_HANDLE_TYPE_HOST_ALLOCATION_BIT_EXT answers VK_ERROR_FORMAT_NOT_SUPPORTED for
each, and so it does without the handle and without the format list. Without colour-attachment
usage (transfer source and destination and sampled), it answers each format importable,
compatible (0x180), not dedicated-only, up to 16384 by 16384 and one layer; dropping sampled
instead leaves it refused.

The README's prose carries no lab job id (scripts/api-docs refuses one), so the job is cited here
alone. runtime-sources.sha256 does not move: the README is not among its inputs.

Verified:
- m3-max-85644, the Apple M3 Max (KosmicKrisp, Mesa 26.3.1, Vulkan 1.4.363, an integrated device
  with VK_EXT_external_memory_host): a query program (no test) asked the answers above.
- On the CPU with no device, at this commit: scripts/api-docs's prose check (its job-id grep over
  the runtime README, API.md, REPLAY-STREAM.md and VALIDATION.md) finds nothing; the runtime-sources
  hash computed from the validation build's input list equals the pinned one; the README's readers
  in the tests (its Floor section, its Enabled, not stated table, and its section of what the
  consumer implements) read sections this change does not touch.
2026-12-03 15:14:52 -08:00
Anees Iqbal 9d841ca7d4 Runtime: OPTIONAL_EXTENSIONS' doc links no private item
The public doc of OPTIONAL_EXTENSIONS linked the private EXTENDED_DYNAMIC_STATE, which rustdoc
refuses under -D warnings (job m3-max-85463: STEP doc and privdoc_metal2vulkan-runtime EXIT=101;
signatures and clippy in three configurations EXIT=0). The sentence now says what the extension
adds in words.
2026-12-03 15:14:52 -08:00
Anees Iqbal e9c39b1507 Runtime: VK_EXT_extended_dynamic_state enabled where listed, its feature where reported
Device creation enables VK_EXT_extended_dynamic_state where the device lists it, and
extendedDynamicState where the device also reports it, and the translator's description states
each that is enabled. This is a form that is right on every device, taken unconditionally: no
vendor, driver or version is read, and nothing else changes. The runtime takes no state through
it, because every render pipeline's dynamic state is Vulkan 1.3's. At Vulkan 1.3 the translator
already counts extendedDynamicState as present, so no translation answer moves. The profile
fingerprint does move on a device that lists the extension, since the description's enabled set
is part of the profile: one cold compile per such device.

The cause is in the driver. RADV in Mesa 26.3.1 (released 2026-11-18; 26.3.2 is not out, so no
26.3.x release has a fix) creates device->ps_epilogs only when graphicsPipelineLibrary,
shaderObject, extendedDynamicState or one of five extendedDynamicState3 features is enabled
(radv_device.c:1706-1715). A pipeline whose depth or stencil test enable is dynamic, and whose pass
may have a depth or stencil attachment, marks a fragment shader's depth or stencil output as
needing an epilog (radv_pipeline_graphics.c:1604-1611 and 1784-1789; radv_shader_info.c:882-888).
At the draw, radv_before_draw goes through radv_emit_all_graphics_states and radv_bind_ps_epilog
(radv_cmd_buffer.c:14148-14149) to lookup_ps_epilog and radv_shader_part_cache_get
(radv_cmd_buffer.c:6832). That calls cache->ops->hash with ops still null (radv_shader.c:3312).
Every render VkPipeline of the runtime takes DEPTH_TEST_ENABLE and STENCIL_TEST_ENABLE as dynamic
state, so on that driver a fragment function writing [[depth]] or [[stencil]] into a pass with
such an attachment faults at its first draw.

Every RADV epilog goes through that one cache: colour outputs, depth, stencil, the sample mask and
an unknown alpha-to-coverage (radv_shader_info.c:882-888). So enabling the feature covers all of
them. The other shader-part cache, vs_prologs, is created only with vertexInputDynamicState,
graphics pipeline libraries or shader objects (radv_device.c:1700-1705). It is reached only by a
dynamic vertex input or a vertex stage without vertex input state
(radv_pipeline_graphics.c:1637-1646), and the runtime makes neither. Mesa 26.2.6's RADV, the lab's,
creates its epilog cache without the feature terms, and its epilogs serve colour outputs alone
(radv_device.c:1679-1684, radv_shader_info.c:850), so it never takes this path. This was read in
the release's source, not reproduced in the lab: no lab node carries RADV from Mesa 26.3.1.

The README has the extension row and an "Extended dynamic state" section with its feature table,
which the README test holds to EXTENDED_DYNAMIC_STATE. Under a device cfg, the every-device floor
test prints whether each card was created with the extension and its feature. The signatures table
takes OPTIONAL_EXTENSIONS' new entry.
2026-12-03 15:14:52 -08:00
Anees Iqbal 0a2519180f Runtime tests: a device that lists VK_EXT_extended_dynamic_state is given it, red
The floor reads VkPhysicalDeviceExtendedDynamicStateFeaturesEXT where the device lists
VK_EXT_extended_dynamic_state, and device creation chains it where the extension is enabled;
nothing enables either yet. The new floor test asks for the four combinations of listed and
reported: the extension where listed, extendedDynamicState where also reported, and the
translator told of each that is enabled. It fails here at "listed and reported", which the next
commit makes pass.

RADV in Mesa 26.3.1 creates its fragment-epilog cache only on a device that enables
extendedDynamicState, graphics pipeline libraries, shader objects or one of five extended dynamic
state 3 features (radv_device.c:1706-1715 in the release). Every render VkPipeline of the runtime
takes Vulkan 1.3's dynamic depth and stencil test enables, under which RADV 26.3.1 draws a
fragment function's depth or stencil output through such an epilog. With the cache missing, the
draw's epilog lookup calls through a null pointer (radv_shader.c:3312). This was read in the
release's source, not reproduced in the lab: the lab's RADV is Mesa 26.2.6, whose epilogs cover
colour outputs alone.

The signatures table takes the new public field of floor::Features.
2026-12-03 15:14:52 -08:00
Anees Iqbal 7c65d9875e Translator tests: the per-thread count's doc sits on its static
The doc comment above the thread_local! macro was an unused doc comment, which clippy
refuses under -D warnings in every configuration (lint job m3-max-85529). It moves inside
the macro, onto the static it describes. The runtime-sources pin moves with the file.
2026-12-03 15:14:52 -08:00
Anees Iqbal c20024991d Translator tests: the profile fingerprint count is per thread
a_run_of_compiles_derives_no_profile_fingerprint reads a count of profile fingerprint
derivations. The count was process-wide, so when cargo test ran another test as a thread of the
same process and that test made a device between the two readings, this test failed. The count
is now thread-local. The device's making and the compiles the test counts run on the test's own
thread: compile_stage spawns no thread, and the translator's one scoped thread only hashes a
large metallib's bytes. So the count still sees every derivation the test asks about.

The change is in a cfg(test) item of device/profile.rs, so no run behaves differently.
runtime-sources.sha256 takes the file's new hash. It was computed with the build's hashing over
the working tree, which reproduced development's pin before the edit.
2026-12-03 15:14:51 -08:00
Anees Iqbal 0801320a59 Translator tests: a device made on another thread moves this thread's fingerprint count by nothing (red)
a_run_of_compiles_derives_no_profile_fingerprint reads a count of profile fingerprint
derivations before and after a device's making and its compiles. The count is process-wide, so
under a harness that runs tests as threads of one process (cargo test), a device another test
makes between the two readings fails it. The new test makes a device on a spawned thread and
asks that this thread's count not move, then makes one here and asks it to move by one. It fails
here, where the count is the process's; the next commit makes it the thread's.
2026-12-03 15:14:44 -08:00
Anees Iqbal 2ec06b93e1 Translator: the sparse path goes
The translator kept a second form for a function that observes a texture's residency: a slot's
sparse arm (OpImageSparse* and OpImageSparseTexelsResident under shaderResourceResidency) or its
tile map (a storage buffer of tile bits the consumer would mirror from each mapping), selected by
SpecKey::SparseTexture from the bound texture's MTLTexture.isSparse, with Metal's measured
footprint rule for a sample or gather, writes dropped under the same constant, and
PrecisionNote::SparseResidency where the device answered. With the observed residency now the
constant resident word, nothing builds either form, and nothing can need one: the runtime has no
sparse heap or sparse texture API, and the consumer tells no guest it has sparse textures (every
Apple family's supportsFamily NO, sparseTileSizeInBytes 0, isSparse NO; a sparse heap refused at
newHeapWithDescriptor:). So the path is deleted (rule 4).

Public items deleted, each searched for in the consumer's checkout at 76e6c90369 (0 hits for every
name):
- RuntimeFact::SparseTexture { slot, sparse_arm, tile_map } and its mechanism; the 12-03 cleanup
  ruling that kept it in the produced-then-refused group is reversed for it alone;
- SpecKey::SparseTexture;
- ResourceKind::TileMap and BindingSource::TileMap, with pipeline::tile_map, the map's format;
- PrecisionNote::SparseResidency (metal2vulkan-degrade-sparse-residency), with its API.md
  catalogue entry, the conformance Degradation and validation's C3 deferred near-equivalent;
- error::Feature::SparseTexture, which nothing constructed;
- bind::TextureFacts::sparse and TextureShape::Texture's sparse, which no binder set.

Crate-internal, gone with them: the texture family's residency use flags, sparse_arm, tile_map and
sparse_writes on a slot plan, their spec constants and tile-map views, resident_access, the tile
decoding (TileLevel), the read's sparse and tile-map arms, the census's ".resident" suffix and
RESIDENCY_WORDS; the sampler's residency and footprint fields and lower::sampler::footprint (Metal's
measured footprint rule, read only to answer from a tile map), the sparse arm in sample, gather and
pixel fetch emission, and lower::texture::residency (every caller sits behind the texture family's
own refusal of a word with another bit observed). The SPIR-V layer loses what only those built:
the builder's sparse_sample, sparse_fetch, sparse_gather, sparse_dref_gather, sparse_read and
texels_resident, the sparse flag of SampleForm and of the fetch, gather and read instructions,
Inst::ImageSparseTexelsResident, its serialization, requirement (SparseResidency, and with it
shaderResourceResidency) and the interpreter's unmapped texels. VkFeature::ShaderResourceResidency
stays: profiles and the device queries name it.

Nothing compiled changes: no module held a sparse instruction or the constant since the previous
commit, so SEMANTICS_VERSION stays. ARTIFACT_FORMAT_VERSION 608 -> 609 (renumbered at landing):
the codec's ResourceKind, SpecKey, RuntimeFact, PrecisionNote and BindingSource lose variants,
which moves later tags. runtime-sources.sha256 moves for bind/state.rs, bind/heap.rs and the
deleted pipeline/tile_map.rs; no run of an unchanged artifact changes. docs/REFUSALS.md, the
runtime's error/basis.rs and tests/api_signatures.tsv are regenerated.

Tests deleted with what they tested: the serializer's sparse sweep, the builder's sparse read
under texel operands, the mechanism table's three SparseTexture rows (the variant indices close
up), C3's SparseResidency deferral (the deferred-row tests now use CubeGradientFootprint).

Verified, on the CPU with no device:
- m3-max-85203, at this change on ec56957c00, after the previous commit's own run in the same
  job: the golden table's cells are the previous commit's, cell for cell (237 at each, every cell
  listed at both, the two lists equal); the refusal surface's check, fmt, signatures, clippy
  (plain, --cfg m2v_gpu, --cfg m2v_cpu_icd), Rustdoc, private docs, doctests and scripts/api-docs
  pass; the metal2vulkan suites ran 3,495 tests: 3,494 passed, 24 skipped, and the failure is
  golden_hashes_match_the_table, whose table is blessed at the next pin; validation ran 1,343
  tests, all passed, 2 skipped; conformance ran 1,054 tests, all passed.
- m3-max-85366, at this commit, rebased onto development past the deletions of the anisotropic
  emulation and RowLockstep (select.rs's anisotropic call and sampler/anisotropic.rs go with
  development's side; the mechanism table is development's without SparseTexture, its indices closed
  up to 0..60): the refusal surface's, conformance coverage's and signatures' checks, fmt and clippy
  (plain, --cfg m2v_gpu, --cfg m2v_cpu_icd) pass; 185 tests (the mechanism, cache, SPIR-V serializer
  and builder, bind::heap and sample-coordinate tests, the two sparse tests and the engine
  inventory's llvm_as parts) all passed. The golden cells are the previous commit's, cell for cell
  (237 at each, the two lists equal).
2026-12-03 15:14:41 -08:00
Anees Iqbal 619e977d63 Translator: a texture's observed residency is the constant resident word
A sparse_sample, sparse_gather or sparse_read (and a sparse block read) whose function observes
bit 0 of its status word (sparse_color::resident()) was refused under the identity domains:
the observed residency made the slot's RuntimeFact::SparseTexture, a texture state the identity
domains do not source (Unsupported{IdentityDomains; NotImplemented}, IdentityCause::TextureState).
The golden table and the engine inventory held the refusal for engine/a2_sparse_status, and the
runtime's README listed it as a known gap.

Metal's answer over a texture that is not sparse, measured with this kernel plain and under
Metal's validation layer (which reported nothing): every residency resident on the Apple M3 Max
(macOS 27.0.1) and on the AMD Radeon Pro 5300M (macOS 26.7.1), not resident on the Intel UHD
Graphics 630 of the same MacBook (macOS 26.7.1), with the same colours on all three. Both answers
are Metal's. The runtime makes no sparse texture: it has no sparse heap or sparse texture API, and
the consumer tells no guest it has sparse textures (every Apple family's supportsFamily NO,
sparseTileSizeInBytes 0, isSparse NO, and a sparse heap refused at newHeapWithDescriptor:).

So the word is the M3 Max's and the 5300M's answer, a constant: an observed residency is 0,
resident, of a slot and a heap element alike, with no query, no precision note and no second
form. lower::texture::residency answers false wherever the word's other bits are not observed (a
word with another bit observed stays refused), so no access marks its slot's residency and no
slot states a SparseTexture fact. The extended-range sample, which refused an observed residency,
takes the constant word too.

Tests:
- engine_identity's a_sparse_access_of_a_texture_slot_is_resident compiles a2_sparse_status on
  every identity profile and moltenvk-m3 without robustImageAccess2: L3 passes, the interface
  states no specialization constant but the dispatch's, the plan no SparseTexture fact, and the
  module holds no OpImageSparse* instruction.
- engine_texture_oob's block_reads_read_their_texels_as_reads_do runs br_sparse (a sparse block
  read storing 2.0 where resident) on every profile and class, where it asserted the refusal:
  its alpha lane reads 2.0 at every point, inside the texture and outside.
- The conformance case sparse-status-plain (cases/sparse_status.rs, the a2_sparse_status kernel
  over two 4x4 RGBA32Float textures, 16 threads) records the M3 Max's colours and residencies,
  and Metal's times; its module docs state all three Macs' answers.

Docs: the runtime README's known gap for this residency goes, with the sparse residency in the
list of texture state the identity domains do not source; API.md's texture paragraph says an
observed residency reads resident, with the Macs' answers, and PixelSamplerScaling's entry (here
and on PrecisionNote) loses its observed-residency case.

Engine inventory (public_fixture_expectations_engine.tsv): 147 .ll cells move from
Unsupported{IdentityDomains; NotImplemented} to ok, every profile's of a2_sparse_status,
kernel_block_read's br_sparse, sps2_residency_probes, spse_address_probes, spse_array_probes,
spse_level_probes and spse_volume_probes (15 each), and every profile's but runtime-floor's of
spse_write_probes, spse_write_barrier and a27_spse_write_barrier (14 each; runtime-floor's stays
Unsupported{IdentityDomains; NotImplemented}). Their .air.ll twins, which only macOS assembles,
move at the M3 bless.

SEMANTICS_VERSION 2367 -> 2368 (renumbered at landing): the residency-observing fixtures' golden
cells change from the refusal to modules. The golden table is blessed at the next pin.

Verified:
- m3-max-85059, on the CPU with no device, at this change on an earlier development
  (004f68b48f; rebased since onto ec56957c00, cleanly, then onto 6459eaa946, which deleted the
  anisotropic emulation: this change's doc edits to sampler/anisotropic.rs and
  PrecisionNote::DeviceAnisotropicFilter went with it). Red: the three tests below with
  lower::texture, sampler/select.rs and sampler/anisotropic.rs at the base fail, with the engine
  inventory's eight llvm_as parts (EXIT 100). fmt, signatures, clippy (plain, --cfg m2v_gpu,
  --cfg m2v_cpu_icd), Rustdoc, private docs, doctests and scripts/api-docs pass. The metal2vulkan
  suites ran 3,496 tests: 3,493 passed, and the failures are golden_hashes_match_the_table and
  inventory parts 1 and 4, whose rows a27_memory_order, a4_device_fence and dispatch_builtins
  that base had not blessed (ec56957c00 blesses them). Validation ran 1,344 tests, all passed, 2
  skipped. Conformance ran 1,054: every_case_carries_its_timing failed, the new recording having
  no times; they were taken on the M3 Max (conformance times --runs 8 --write) and are in this
  commit.
- m3-max-85203, on the CPU with no device, at this change on ec56957c00:
  a_sparse_access_of_a_texture_slot_is_resident, block_reads_read_their_texels_as_reads_do and the
  engine inventory's eight llvm_as parts pass (10 tests run, 10 passed). The golden table's cells at
  this commit, each listed: 237 change from Unsupported{IdentityDomains; NotImplemented} to a
  module, 147 of them this commit's (a2_sparse_status, br_sparse, sps2_residency_probes and
  spse_address_probes, spse_array_probes, spse_level_probes and spse_volume_probes, 15 each;
  spse_write_probes, spse_write_barrier and a27_spse_write_barrier, 14 each) and 90 development's,
  not yet blessed (a27_memory_order, a4_device_fence, dispatch_builtins's device_fence_store and
  kernel_read_through's rt_heap_arg, rt_heap_ow and rt_heap_zero, 15 each). In the same job, at
  the next commit's tree (this one and the sparse path's deletion), conformance ran 1,054 tests,
  all passed, every_case_carries_its_timing among them.
- m3-max-85366, on the CPU with no device, at this commit on development (past the anisotropic
  emulation's deletion): the same 10 tests, 10 passed, and the same 237 golden cells, 147 of them
  this commit's; at the next commit's tree, the refusal surface's, conformance coverage's and
  signatures' checks, fmt and clippy (plain, --cfg m2v_gpu, --cfg m2v_cpu_icd) pass.
- m3-max-84877 and m3-max-85200, the Apple M3 Max (macOS 27.0.1): the recording of
  sparse-status-plain, plain and under Metal's validation layer, and its times.
- m3-max-84885, the Iris Xe (Mesa 26.2.6), at this change before its rebases and the times: the
  conformance replay of sparse-status-plain differs from the recording only by announcing the
  notice metal2vulkan-degrade-native-nan-encoding, which it justifies (EXIT 0).
- m3-max-84712, the MacBook Pro's Radeon Pro 5300M and UHD Graphics 630 (macOS 26.7.1): the
  fixture's kernel, plain and under the validation layer.
2026-12-03 15:14:41 -08:00
Anees Iqbal 5b68f2d05b Translator: an argument buffer's sampler's estimate and docs drop the cubic test it no longer emits
Since the resident core's deletion (0ce2f39b71) an argument buffer's sampler is read through the
identity arrays, and since a sampler of Metal's undeclared filter 2 filters as nearest
(6706d5b97f) nothing tests the sampler's word for a cubic filter: no mask, no selection, no status
mark. Three places still described that test:

- lower/sampler/mod.rs: CUBIC_REACH_WORDS (64), an upper estimate of the test's words, was still
  added to Sampling::words for Source::HeapSampler. It is deleted (crate-private: lower is
  pub(crate)), and the comment above the estimate names what is left.
- lower/sampler/emit.rs: sampled_value's doc said "before an argument buffer's sampler's cubic
  test"; it now says what it is: sampling_value of a sampling that is not Sampling::swizzle's,
  before a constexpr sampler array's null select.
- tests/engine_identity.rs: the doc of
  an_argument_buffers_sampler_samples_through_the_identity_arrays_by_its_resource_id named a
  RuntimeFact::CubicArgumentSampler that no longer exists.

What moves: the estimated words of the sampler.argument_sampler.* strategies, 64 fewer a use. They
are only reported, in the artifact's StrategyCensus; no budget or decision reads them. The emitted
SPIR-V is unchanged, so the golden hashes do not move. No test reads those words: the census tests
read uses, and engine_texture's partition check is relative. runtime-sources.sha256 is unchanged
(no pinned file is touched).
2026-12-03 15:14:41 -08:00
Anees Iqbal 5e3d867358 Runtime tests: a partial-threadgroups cause without a cache marker fails the test
The runtime keeps each refusal of a kernel's partial-threadgroups variant under a marker of its
cause in the cache directory (cache::REFUSALS), and refusal_marker answers the plain refused
marker for a structure the table does not hold, which reads back as VariantRefusal::Translator:
the cause is lost. The translator's PartialThreadgroupsCause is non_exhaustive, so no match in
the runtime can name every cause, and a_variant_refusal_keeps_the_translator_s_cause listed the
four structures by hand: a cause the translator adds without a marker passed it.

The test now reads the enum's variants from the translator's source (error/mod.rs), as
translator_fields reads the linked state's fields, and requires each to be kept under exactly
one marker, the vote word's or its structure's, and the table's structures to be those causes
but the vote word. Its other checks are unchanged, over the table's structures.

Verified (m3-max-85468, on the CPU with no device):
- green: the test passes at this commit (1 run, 1 passed);
- red: with a sixth cause added to the translator's PartialThreadgroupsCause and no marker, it
  fails at that cause (kept under no marker: left 0, right 1);
- the hole: development's hand-listed test with the same sixth cause passes;
- fmt and clippy (plain, --cfg m2v_gpu, --cfg m2v_cpu_icd) pass.
2026-12-03 15:14:40 -08:00
Anees Iqbal 3758e468a7 Runtime: TextureCopyMismatch rests on Apple's documented rule, with the Macs' measured answers
Refusal::TextureCopyMismatch (BlitCommandEncoder::copy_from_texture between textures of two pixel
formats or two sample counts) stated a metal-measured basis: the probe blit_copy_format_pairs.m on
the M3 Max under Metal's validation layer alone, which stops every pair of two formats. A
consumer's probe on a MacBook's Radeon Pro 5300M (macOS 26.7.1) had Metal take ten pairs of one
texel size and copy their bytes, plainly and under the validation layer, so the basis was re-read
and measured on all three Macs.

Apple's page for the region copy says of the destination texture: "The pixel format is the same as
`sourceTexture`. The sample count is the same as `sourceTexture`." Outside that rule the Macs
answer apart (the probe, rewritten to run each pair plainly and under the validation layer, with
the bytes checked):
- Apple M3 Max, macOS 27.0.1, Shared and Private: plain Metal copies the bytes as they are; the
  validation layer stops every pair of two formats ("[sourceTexture pixelFormat](...) must equal
  [destinationTexture pixelFormat](...)") and two sample counts.
- AMD Radeon Pro 5300M, macOS 26.7.1, Private: Metal copies the bytes as they are, plainly and
  under the validation layer, which takes the pairs of one texel or block size (depth and BC1
  among them) and stops two texel sizes ("must be compatible with") and two sample counts.
- Intel UHD Graphics 630 of the same MacBook, macOS 26.7.1, Private: the copy completes, plainly
  and under the validation layer, and leaves the destination unwritten; the layer answers as on
  the 5300M.
So the refusal stays, and its basis is metal-documented, quoting the page; its doc carries the
rows above. Nothing it refuses changes.

The probe now holds every leg that ran: the ten pairs of one texel size and R32Uint into R32Float,
each with Shared and Private textures, plainly and under the layer, with the bytes compared; the
earlier depth, BC1 and sample-count cases and a pair of two texel sizes (the negative control)
under the layer alone, where plain Metal has no defined answer; a device index for a Mac of two
GPUs. Its header states what each Mac answered.

docs/REFUSALS.md and the runtime's error/basis.rs are regenerated (one Refusal moves from
metal-measured to metal-documented). The runtime README's blit paragraph names the documented
rule. The conformance rows whose refusals Justification::MetalValidation documents are unchanged.

Verified:
- m3-max-85147, the Apple M3 Max (macOS 27.0.1), and m3-max-85148, the MacBook Pro's Radeon Pro
  5300M and UHD Graphics 630 (macOS 26.7.1): the probe as committed, every leg (the rows above).
- m3-max-85410, on the CPU with no device, at this commit: fmt, the workspace's Rustdoc, the
  runtime's private Rustdoc, the refusal surface's check and scripts/api-docs pass; the runtime's
  suite ran 230 tests, all passed, 2 skipped.
2026-12-03 15:14:40 -08:00
charlysound 133c992dad Merge pull request #25 from charlysound/contrib/native-mesh-runtime 2026-12-03 14:16:10 -08:00
Anees Iqbal d2f8f386c0 Pin V bless: the golden cells and the census differences by the commit that moved them
The bless commit 292331c613 left its attribution pending on the M3's job. This commit carries it and changes
no file.

The authored compile census at 8f04734a97 differs from pin U's in 216 cells. Every one goes from refused to
compiled, and none is unexplained:
- 144 cells, 16 bicubic cases on 9 profiles, were refused as IdentityDomains. A 1D texture's bicubic sample
  lowering under the identity domains (94adea1c61, SEMANTICS 2365 at 0a3a4fe911) compiles them.
- 72 cells, 8 cases on 9 profiles, were refused for the seq_cst_fence tooling requirement. The seq_cst fence
  taking the device's fence word (3fbbadbc6e) compiles them.

The golden hash table moves from pin U's (b531238180) to the blessed one by these commits. Each version
mover between the two was checked out on the M3 and blessed alone (m3-max-85499), and the tables were diffed in
order. The last table equals the one 292331c613 commits.
- 3fbbadbc6e, SEMANTICS 2360, the seq_cst fence: 90 cells in 6 rows (a27_memory_order, a4_device_fence and
  dispatch_builtins' device_fence_store, .ll and .air.ll).
- e5b7498833, SEMANTICS 2361, an argument buffer's texture read through a sampler takes its border texels from
  its resource ID's word: 90 cells in 6 rows (kernel_read_through's rt_heap_arg, rt_heap_ow and rt_heap_zero).
- 0a3a4fe911, SEMANTICS 2365, the 1D bicubic sample: 60 cells in 4 rows (bcu_forms and bcx_rules).
- ddfc3a6da4's range, SEMANTICS 2366: 10 rows added (150 cells), the fixture dvw_depth_views that aedc38190f adds.
  No existing cell moves.
- 5dc5ea3315, SEMANTICS 2367, a seq_cst atomic operation takes the sequentially consistent fence: 86 cells in 6
  rows (a27_memory_order's a27_fragment_atomics, a27_memory_order and a27_wide_and_float).
- 0ce2f39b71, 31d8a874f1 and fa5d051b64 move the 15 profile fingerprint lines and no cell. 71a5393966,
  722503da23, 2d63c60193, 9886324e31, aa15ad6b5b, 09b6d0fb89, 6459eaa946 and 8f04734a97 move no cell.
In all, 326 cell moves over the steps. Some cells move twice: a27_memory_order moves at the fence and again at
the atomic operation. Net, 296 cells change, plus the 10 new rows.
2026-12-03 14:16:04 -08:00
Anees Iqbal 292331c613 Pin V bless: golden hashes, engine inventory and the authored compile census at 8f04734a97
Re-blessed on the Apple M3 Max at 8f04734a97 (job m3-max-85487: inventory=0, golden=0,
printouts=0, linkhalf=0) and the authored compile census (m3-max-85488: cases=2390,
cells=21510, failed=0, regressions=0, differences=216).

- golden_hashes.tsv: 36 rows out, 46 rows in. The 28,950 cells under changed profile
  fingerprints and the 75 new cells found by m3-max-85323 at 48a22a206f, plus the cells the
  later landings moved. Attribution per commit: PENDING m3-max-85499.
- public_fixture_expectations_engine.tsv: bcu_forms.air.ll and bcx_rules.air.ll move from
  Unsupported{IdentityDomains} to ok on all 15 profiles (30 cells, the 1D bicubic's .air.ll
  twins). dvw_depth_views.ll and .air.ll add 10 rows, ok on all 15 profiles (the
  depth-colour-reads fixture).
- authored-compile.tsv: 1,625 rows re-blessed, 0 failed, 0 regressions.
2026-12-03 14:00:11 -08:00
Anees Iqbal 8f04734a97 Translator docs: slice_cells' link names the function slice(), not the primitive
The SSW doc comment on slice_cells linked [`slice`], which rustdoc resolves both
to the function lower::texture::emit::slice and to the primitive type, so the
private-items Rustdoc of metal2vulkan failed (merged check m3-max-85364, STEP
privdoc: "`slice` is both a function and a primitive type"). The link now names
the function. Docs only; runtime-sources.sha256 unchanged (pin-compute equal).
2026-12-03 13:47:40 -08:00
Anees Iqbal 5dc5ea3315 Translator: a seq_cst atomic operation takes the sequentially consistent fence
A seq_cst atomic operation on memory another thread reaches (an AIR 2.9 air.atomic.* buffer
atomic of order 5, its success order for a compare-exchange; an LLVM atomic load, store,
atomicrmw or cmpxchg of seq_cst) now takes the fence the landed seq_cst fence lowers to: an
acquire-release memory barrier at the operation's scope over the memories its order applies to,
then lower::sync::barrier's add of 1 on the device's fence word at Device scope with the
barrier's semantics. A store, a read-modify-write and a compare-exchange take it after the
operation; a load takes it before. Thread memory's atomics take none (no other invocation
observes their order); texture atomics of any order but relaxed stay refused; relaxed, acquire,
release and acq_rel operations are unchanged.

The fence before a load, derived: the stores' fences alone order every pair of fenced stores and
forbid store buffering and the R and 2+2W shapes, but two readers may still see two independent
seq_cst stores in opposite orders (IRIW), since a reader's two acquire loads synchronize with
nothing between them. MSL's single total order forbids that outcome. With an add on the one
fence word before each load, the two readers' second adds are ordered on that word; the earlier
reader's first load acquired its store, which then happens before the later reader's add and so
its second load, which must see it. A fence after a load would order nothing more.

Each such operation now costs one contended add on the device word: the runtime README's fence
known-gap line says so (every non-explicit atomic of MSL 4.1 is one), read from the fence's
measured rows. msl_4_1_orders_reach_spirv expects the fence's add after a27_wide_and_float's
float add and after each of a27_fragment_atomics' three atomics. reach.tsv drops the SeqCstFence
row, whose refusal no longer exists. The identity harness maps the device's fence word
(with_fence_word: its 4 bytes past the zero range, the rest still unmapped), and
engine_atomics' run_orders binds every kernel with it: the interpreter trapped on the fence's
add in the two contention tests whose kernels hold LLVM seq_cst atomics. SEMANTICS_VERSION
2367 (renumbered at landing; 2363-2366 went to arm 9, the blob move, the 1D bicubic and
the shared slice): a module holding a seq_cst atomic operation changes.

Verified:
- red 389e7cf44e, job m3-max-85066: a_seq_cst_atomic_operation_takes_the_fence fails at "a
  fence's barrier" (no add follows the store); the fence tests and msl_4_1_orders_reach_spirv
  pass. Green there: 4 passed.
- the product suite at the fix without the harness's fence word (85066): 3495 passed, 3 failed,
  24 skipped. The failures were golden_hashes_match_the_table (re-blessed on development) and
  engine_atomics' llvm_ and narrow_atomics_are_exact_under_contention, whose interpreter trapped
  on the unmapped fence word. With it (85271): engine_atomics, engine_seq_cst and
  engine_air_2_9 28 passed.
- validation 1344 passed, 2 skipped; conformance 1053 passed, 0 skipped; doctests EXIT=0
  (85066).
- clippy plain 85270, m2v_gpu 85269 and m2v_cpu_icd 85268 EXIT=0 at this tree. Rustdoc and
  api-docs 85093 EXIT=0 at the fix without the harness change, which adds test code only.
2026-12-03 13:12:57 -08:00
Anees Iqbal 7463025bc2 Translator tests: a seq_cst atomic operation takes the sequentially consistent fence (red)
The planner ruled a seq_cst atomic operation a bug to build on the landed fence (owner order
3406). MSL 4.1, section 6.16 read whole: Table 6.26 gives memory_order_seq_cst as "Same as
memory_order_acq_rel, plus a single total order exists in which all threads observe all
modifications in the same order." (All OS: Metal 4 and later); 6.16.1 says "In Metal 4.1 and
later, you can specify memory_order values for atomic operations, atomic_thread_fence,
threadgroup_barrier, and simdgroup_barrier." (before it, "For atomic operations other than
atomic_thread_fence, memory_order_relaxed is the only enumeration value."); and 6.16.1.3 says
"Atomic operations that use memory_order_seq_cst order memory the same way as release-acquire
ordering — everything that happened before a store operation in one thread becomes visible to
the thread that performed the load. They also establish a single total modification order of
all atomic operations." Apple's compiler gives MSL 4.1's non-explicit atomics (atomic_store,
atomic_load, atomic_fetch_add) order 5, seq_cst, over every memory (mem_flags 31): our fixture
a27_memory_order, compiled at metal4.1. Today such an operation lowers to its acquire-release
half alone, which Vulkan does not order totally.

Count (structural: the order immediate of each air.atomic.* buffer atomic, load, store,
read-modify-write and compare-exchange success and failure, each texture atomic, and each LLVM
atomic load, store, atomicrmw and cmpxchg, in the functions each entry reaches by direct calls):
- the kept streams (the replay streams' blobs and two recordings; 659 distinct libraries, their
  17831 functions through llvm-dis): 0 functions with a seq_cst operation (job m3-max-84869);
- the other kept streams (369 distinct libraries, 14758 functions): 0 (job m3-max-84888);
- the census's corpus (its local/sources and local/library-modules shards: 15378 and 14068
  entries): 0 entries with a seq_cst operation, the positive control finding them in
  a27_memory_order's three kernels (job m3-max-85277).

a_seq_cst_atomic_operation_takes_the_fence: on every committed profile, the store-buffering
litmus kernel with its store (or exchange) and its load in AIR 2.9's ordered form on device
memory. A seq_cst store or exchange is followed by the fence (a Device-scope memory barrier of
acquire-release semantics over the operation's memory, then a Device-scope add of 1 with those
semantics on the device's fence word, the function reading PushField::ZeroAddress); a seq_cst
load is preceded by it. Store-side fences alone forbid store buffering, but not two readers that
see two independent stores in opposite orders (IRIW), which the single total order forbids; the
fence before each load puts an add on the one fence word between a reader's two loads, so the
two readers' adds are ordered and the first reader's acquired stores happen before the second
reader's later load. A relaxed, release, acquire or acq_rel operation takes no fence and reads
no zero range. Every module passes L3.

Red at this commit: each case with a seq_cst operation has no fence.
Verified: the red/green job of the fix commit.
2026-12-03 13:12:46 -08:00
Anees Iqbal c57492c129 Translator docs: the cooperative slice's zero past the grid names its conformance case
A comment only: cooperative.rs's paragraph on a partial threadgroup's
shared slice now names the case that carries the M3's recording
(compute-imageblock-slice-past-the-grid) beside the probe. The runtime
sources hash is unchanged (cooperative.rs is not one of its inputs).
2026-12-03 13:12:41 -08:00
Anees Iqbal 0ae54b7ec4 Conformance: the M3's recording of the imageblock slice past the grid
Recorded on the Apple M3 Max (macOS 27.0.1) by job m3-max-85134
(record, three runs, one outcome, the validated leg ran without a stop;
times --runs 8 --write). Every grid thread's texel holds its own value,
(1 + x + 8y) / 64 and three zeros, and every one of the 22 cells past
the grid holds zero, neither the -1 sentinel nor any thread's value: the
answer the case's test pins, read from these bytes.

docs/CONFORMANCE-COVERAGE.md regenerated (coverage.py) for the case and
its dispatchThreads step.
2026-12-03 13:12:41 -08:00
Anees Iqbal 6cd358bafb Conformance: a partial threadgroup's imageblock slice, past the grid
A compute pass can now state dispatchThreads:threadsPerThreadgroup: as a
step (ComputeStep::DispatchThreads), on both sides: the runtime's
dispatch_threads and Metal's own call. The fixed Side::dispatch_threads
sets no imageblock size, so a kernel with an explicit imageblock could
not run a non-uniform grid through it.

The case compute-imageblock-slice-past-the-grid runs the owned fixture
tib_imageblock_slices's tib_slot_half_slice over a 6 by 7 grid in 4 by 4
threadgroups with a 4 by 4 imageblock, so three of its four threadgroups
are partial (x, y and the corner), and compares the whole 8 by 8
RGBA16Float texture, made holding -1 in every channel, with Metal's.
Metal's documentation says nothing of a slice's cells past the grid; the
case carries what the M3 records and claims no more. Its test pins that
recording to the grid threads' own values and zero past the grid.

The ledger row for the encoder's dispatchType is the one every compute
pass case holds (the runtime keeps no getter).

The recording follows in the next commit, from one record job on the M3.

Verified:
- the recording (next commit): M3 job m3-max-85134.
- replay, job m3-max-85149: on llvmpipe (Mesa 26.2.6, LLVM 23.1.4) and on the RX 7900 XTX
  (RADV), the case's texels equal the M3's. Its one ledger row (dispatchType) holds on both, as
  compute-imageblock-sizes' does.
- conformance suite 1055 passed, 0 skipped (m3-max-85298); clippy x3 and rustdoc as the change
  before it.
- macOS: the M3 job's release build of the Metal side compiled without a warning. Clippy was
  not run on macOS, since pd sends no build to the Macs.
2026-12-03 13:12:41 -08:00
Anees Iqbal ddfc3a6da4 Translator and runtime: a kernel's partial threadgroup writes its shared slice among Metal's threads
The partial-threadgroups variant refused a kernel with an imageblock slice write every
invocation shares (texture::cooperative), as SharedSliceWrite. The walk guarded the shared
write like any other instruction, so its trailing workgroup barrier stood under `if live`,
and the walked invocations past Metal's threads skipped their shares. It now takes the shared
slice as one of the walk's synchronizations, on every tier (texture::shared_slice, in
SyncSet::WorkgroupBarriers and divergent::is_sync):

- every invocation reaches the slice's barrier;
- the invocations live at the slice write the slice's cells among them. In a partial
  threadgroup those are Metal's threads: the first EmitCx::entry_threads invocations by lin.
  The step of the shared loop is now that count rather than the workgroup's size, so Metal's
  threads write every cell;
- a cell no thread of Metal's stored holds zero, the threadgroup arena's null initializer;
- the walked invocations store nothing in their cells before the barrier (the predicated walk).

The M3 Max recorded the same for Metal's own partial threadgroup, so this matches the
measurement rather than any documented rule. Probe imageblock_slice_past_the_grid, job
m3-max-85078: each cell of a thread past the grid lands zero, in two runs of two dispatches.
No MSL or Metal text says what such a cell holds, and the docs claim nothing beyond the
recording.

The shared slice is never by itself a reason to walk. Its guard's branch, at a
workgroup-uniform point, is taken by every invocation, so a kernel whose only non-uniform
synchronization is a shared slice keeps its unwalked module. Outside a walk the shared loop is
unchanged.

- error: PartialThreadgroupsCause::SharedSliceWrite goes, since nothing else raises it.
  mesh::plan_partial_groups no longer refuses the variant for it. Feature::PartialThreadgroups'
  and LoweringInputs::partial_threadgroups' docs drop it and say what the slice writes.
- runtime: its cache's refusal markers drop m2v-refused-slice (cache::REFUSALS has 5 entries).
  PartialThreadgroupsSite::Structure's doc and the README's gap paragraph drop the slice.
  Caches::refused now reads a variant's translation file in one lookup (the planner's
  read-back of the cause table). It asked the store once per marker, and each Store::holds
  opened the file in young and then old, and read it whole where its length was the marker's.
  Three markers are 16 bytes, so one 16-byte file was read up to three times. Store::holds_one
  takes the markers with their tags, opens the file once a generation, reads it only where its
  length is a marker's, and matches the bytes against each. Store::holds is holds_one of one
  marker. A hit in old still moves into young. Lookups count their opens under the tests
  (Store::file_opens).
- tests:
  - the red test turns green;
  - each_structure_the_variant_does_not_take_names_its_cause keeps compute derivatives and
    the tile function;
  - the runtime's marker test drops the cause;
  - api_signatures.tsv loses the two variant rows. REFUSALS.md and basis.rs regenerate
    unchanged.
  - a_variant_refusal_is_read_back_in_one_lookup_of_its_file writes each marker of REFUSALS
    under a key of its own and reads each back with exactly one open. A missing key opens at
    most twice, and a lowering of a marker's length is no refusal.
- SEMANTICS_VERSION 2366 (renumbered at landing: 2363-2365 went to arm 9, the blob move and the 1D bicubic): a partial-threadgroups
  variant with a shared slice now compiles. RUNTIME_VERSION stays: no run of an unchanged
  artifact differs, and the runtime-source fingerprint's inputs are untouched.

Verified:
- red d1d4b5cc9c, job m3-max-85298: a_partial_threadgroup_s_shared_slice_holds_zero_past_its_threads
  fails at its compile ("unsupported: PartialThreadgroups: SharedSliceWrite"), and the filter's
  other 20 tests pass. With Caches::refused asking once per marker, as before, the same job's
  a_variant_refusal_is_read_back_in_one_lookup_of_its_file fails at 2 opens for
  Structure(ComputeDerivatives). Green: 23 passed.
- suites (85298): product 3498 passed, 1 failed (golden_hashes_match_the_table, re-blessed on
  development), 24 skipped; validation 1344 passed, 2 skipped; conformance 1055 passed,
  0 skipped; doctests EXIT=0.
- clippy plain 85194, m2v_gpu 85193 and m2v_cpu_icd 85197 EXIT=0; rustdoc and api-docs 85195
  EXIT=0, all at the tree of this change and the case that follows it.
- the guest's kernels, job m3-max-85164 (release, a Ryzen 7 7840HS): the two kernels this
  refusal held in a recording's libraries lower and pass spirv-val on all 15 committed profiles,
  under the plain module and both partial-threadgroups variants. The slowest row is moltenvk-m3's
  emulated variant at 0.017 s, and the peak resident set is 32.6 MiB a process. Before this
  change both variants were refused as SharedSliceWrite (job m3-max-85052).
- Metal's own answer, in the conformance case that follows (compute-imageblock-slice-past-the-
  grid): recorded on the M3 (m3-max-85134), and equal on llvmpipe and on the RX 7900 XTX
  (m3-max-85149).
2026-12-03 13:12:41 -08:00
Anees Iqbal 7e1ca1af89 Translator tests: a partial threadgroup's shared slice holds zero past its threads (red)
The planner ruled the shared slice write in a partial threadgroup built (owner order 3406): the
walk's guest library 5ba5f694ad0576ff refuses the partial-threadgroups variant of kernels #81 and
#83 as SharedSliceWrite. The M3 Max recorded what Metal does (the probe
imageblock_slice_past_the_grid, job m3-max-85078, two runs of two dispatches each): the slice
write in a partial threadgroup writes every cell of the imageblock, and the cells of threads past
the grid land zero in every run.

a_partial_threadgroup_s_shared_slice_holds_zero_past_its_threads runs engine_imageblock's
shared_slice (4x4 threadgroups, a 4x4 imageblock, each thread storing (x, y, 7, 9) in its cell
before the barrier, the slice written by local id 0 at its threadgroup's origin) as the
partial-threadgroups variant over a 6x7 grid. Of its 2x2 threadgroups, one is partial in x, one in
y and one in the corner. The test uses the interpreter with the region flagged NONUNIFORM, on every
committed profile that lowers the plain kernel, in both scheduling orders. Each cell of a Metal
thread must land its (x, y, 7, 9), and every other cell of the slice must land zero. That pins the
reason as well as the result: an invocation past Metal's threads would store a nonzero cell if the
walk let it. engine_imageblock's texel helpers become visible to the test.

Red at this commit: the variant is refused Unsupported{PartialThreadgroups} SharedSliceWrite.
Verified: job m3-max-85298 fails it at its compile with that refusal, on the first committed
profile (amd-780m-hawkpoint-radv).
2026-12-03 13:11:16 -08:00
Anees Iqbal 15d6344523 Conformance probe: what a slice write holds for the cells past a partial threadgroup's grid
A kernel with an explicit imageblock stores each thread's grid position in its cell, takes a
threadgroup barrier on imageblock memory, and writes the slice from the thread at local (0, 0),
the shape the translator's cooperative slice write takes. It is dispatched with dispatchThreads
on a 21 by 13 grid of 8 by 8 threadgroups, so threadgroups at the x edge, the y edge and the
corner are partial. The probe prints, for each kind of edge, what the texels of the cells past
the grid hold after the write (the sentinel set before, a stored pattern, zero or other) and a
hash of them, over two dispatches a run. It is the reading the partial-threadgroups variant's
SharedSliceWrite form is checked against.

What it measured, job m3-max-85078 (the Apple M3 Max, macOS 27.0.1; two runs of two
dispatches, sentinels -1 and -2): every cell past the grid holds zero, 24 at the x edge, 48 at
the y edge and 39 in the corner, with no sentinel, no as-if-ran value and no other thread's
value; every grid thread's texel holds its own value; each command buffer completed, and the
hashes are equal across the runs and sentinels.
2026-12-03 13:11:16 -08:00
Anees Iqbal 7d1dba5df0 RUNTIME_VERSION 2569: a sampler of Metal's undeclared filter 2 is made and filters as nearest
A Cubic sampler state is now made where the runtime refused it, so
RUNTIME_VERSION moves 2568 -> 2569 at landing. SEMANTICS_VERSION stays at
2365: no module's words change. runtime-sources.sha256 is unchanged
(cache/mod.rs is not one of its inputs; pin-compute equal).
2026-12-03 13:06:14 -08:00
Anees Iqbal 6706d5b97f rt and translator: a sampler of Metal's undeclared filter 2 is made and filters as nearest
MTLSamplerMinMagFilter's raw value 2 (SamplerMinMagFilter::Cubic) is
declared by no SDK header, Apple page or Metal Shading Language text, and
nothing a program asks tells it about the value, so it is undocumented
Metal and is not emulated. Metal makes the state on every Mac measured. An
Apple M3 Max filters it over a footprint wider than one texel, and a Radeon
Pro 5300M and an Intel UHD Graphics 630 read the nearest texel (the
conformance case's own inputs: jobs m3-max-85003 and m3-max-85004). The
runtime now makes such a state and filters it as nearest on every device:
no shader arm, no second pipeline, no query, no note.

- rt Device::new_sampler_state no longer refuses a Cubic min or mag
  filter. Nothing raises Gap::CubicSampler now; the variant stays,
  documented so, because the consumer names it.
- translator: SamplerWord::of sets no bit for a Cubic filter, so its word
  is the nearest filter's. SamplerWord::CUBIC (bit 30) is deleted (its
  one reader, the anisotropic word path, is gone on development). SamplerWord::FIELDS is now (1 << 30) - 1.
  unnormalized_reads compares the two filters as the device's (a Cubic
  filter's is NEAREST) rather than refusing Cubic. vk_sampler already
  made NEAREST of Cubic.
- SamplerMinMagFilter::Cubic stays, because the consumer converts a
  guest's raw 2 to it. It is documented through regen_metal_enums.py's
  PRIVATE_DOCS as Metal's undeclared raw value 2, which the M3 Max filters
  and the x86 Macs read as nearest, and whose device sampler and word here
  are the nearest filter's. generated.rs is regenerated against the
  macOS 27.2 SDK.
- docs: the runtime README's sampler line, RESOURCE-ID.md (the word's bit
  30 is now 0, and the consumer makes a Cubic state as nearest),
  resource_words.tsv's three Cubic lines (bit 30 cleared:
  0x40000000 -> 0x00000000 twice, 0x58f6ab53 -> 0x18f6ab53), and the
  comments in select.rs and extended.rs that said the runtime makes no
  cubic sampler.
- reach.tsv's SamplerBicubicFilter row no longer names a runtime cubic
  sampler as its reach. REFUSALS.md and error/basis.rs regenerated
  (refusal_surface.py: Gap::CubicSampler has no raise site);
  api_signatures.tsv blessed (SamplerWord::CUBIC removed, FIELDS changed).
- RUNTIME_VERSION: a Cubic state is made where it was refused, so it
  takes a bump, set at staging (left at development's 2568 here).
  SEMANTICS_VERSION stays, since no module's words change.
  runtime-sources.sha256 re-pinned.

Consumer search (reims-vgpu development 1913fcbc15 and the steelbrain/*
refs from the last day): Gap::CubicSampler, 2 hits (development
crates/reims-vgpu-vulkan/src/rt_platform/diag.rs:3071 and :3109, a test
that counts the gap's name), kept. SamplerWord::CUBIC, SamplerWord::FIELDS
and SamplerMinMagFilter::Cubic by name: 0 hits. The consumer's
rt_platform::state::tests::states_on_vulkan, which expects None for
min_filter 2, now gets a sampler.
2026-12-03 13:06:04 -08:00
Anees Iqbal c43c130d1a Tests: a sampler of Metal's undeclared filter 2 is made and filters as nearest (red)
MTLSamplerMinMagFilter's raw value 2 (MTLSamplerMinMagFilterCubic) is
declared by no SDK header, by Apple's page, or by the Metal Shading
Language, and nothing a program can ask tells it about the value. Metal
makes a sampler state of it on every Mac measured. The case's own inputs
read a footprint wider than one texel on an Apple M3 Max (macOS 27.0.1,
job m3-max-85004) and the nearest texel on a Radeon Pro 5300M and an Intel
UHD Graphics 630 (macOS 26.7.1, job m3-max-85003). Undocumented Metal is not
emulated, so the runtime is to make the state and filter it as nearest, the
x86 Macs' answer, on every device.

The tests that hold that:
- rt every_device_shares_sampler_states_device_samplers: a state with a
  Cubic min and mag filter is made (no Gap::CubicSampler), its word is the
  nearest state's, and it takes no device sampler of its own.
- translator a_cubic_filter_is_the_nearest_filters: a Cubic min filter,
  mag filter or both is the nearest filter's word, device sampler of each
  use, and unnormalized reading, at normalized and pixel coordinates; and
  a_sampler_word_holds_each_field_at_its_bits: a Cubic filter's word is 0.
- conformance sampler-cubic-filter: its ledger row (refused on every
  venue) goes. The case drops its bicubic-filter-arithmetic declaration and
  lets each lane's runtime red hold its own texel where the M3 Max's
  recording differs (every lane but lane 0), under the new accepted
  difference in docs/API.md. the_cubic_allowances_are_the_lanes_nearest_moves
  pins those lanes to the recording.

docs/CONFORMANCE-COVERAGE.md regenerated (coverage.py): one ledger row
fewer, one tolerance more.
2026-12-03 13:06:04 -08:00
Anees Iqbal 48a22a206f Runtime tests: the early member's fed run is checked exactly, not by a wall-clock ratio
every_device_feeds_an_early_members_run_to_its_queue_as_the_last_retires asserted l_run * 3 < a_run:
that after A's handler the expected run fell by more than a third. The run falls by the GPU runs it
takes (QueueInner::ran halves it toward each shorter one, queue::next_run), so the bound held only
while A's and L's timestamped fill runs stayed short beside the run A's handler saw. Alone on
lavapipe at 256 bits the ratio is about 4 (125M ns at A's handler, 31M at L's). It failed once in
a full-suite run of the merged-tree check (m3-max-85067, llvmpipe LLVM 23.1.1 at 256 bits, the
test 0.94 s there against 0.11 s alone), where the CPU ICD's fills ran long.

The check is now exact: from the run A's handler saw, the run L's handler sees is next_run of A's
GPU run, then of L's, each its command buffer's gpu_end_time minus gpu_start_time. Those are the
spans the runtime fed (complete.rs feeds an early member's deferred span, and command.rs L's own,
from the same placed times it stores). Nothing in it depends on how long the runs took. With the
retirement count's +2 between the handlers, it says the queue took exactly A's run and then L's
after A's handler. The bound is not widened; the ratio is gone.
2026-12-03 12:57:21 -08:00
Anees Iqbal 6af0aa8c9b Conformance: depth-colour-reads carries Metal's times; coverage regenerated
The suite's every_case_carries_its_timing failed on the new case (job
m3-max-84879). `conformance times --runs 8 --write depth-colour-reads` on
the Apple M3 Max (macOS 27.0.1, 26A434; job m3-max-85057) kept its figures
in the recording; its answers are unchanged.

docs/CONFORMANCE-COVERAGE.md regenerated (coverage.py): one module more
declaring a notice, from the depth notices the case now declares.
2026-12-03 12:51:33 -08:00
Anees Iqbal 556ed46e41 Conformance: the depth colour reads declare the depth notices; API.md's border cell is the runtime's
The case's replay on lavapipe (job m3-max-84879) announced
restricted-depth-range and restricted-depth-upload: the comparing stage's
note and the 32-bit float depth upload's. Every texel is 0.25 or 0.75,
inside [0, 1], and the notices site was the whole of their difference, so
the case declares both, as sampler_filtering's compare rows do.

The same job's replay with the colour allowances dropped printed the
runtime's own answers: a sample past the edge under an opaque white border
reads (1, 0, 0, 1), which fills the accepted difference's table.
2026-12-03 12:51:33 -08:00
Anees Iqbal a894a90293 Conformance: the depth colour reads' module docs name their accepted difference without a private link
Rustdoc refuses a public module's docs that link to a private item
(job m3-max-84879's doc step, EXIT=101): DEPTH_AS_COLOUR is the case's
own constant, so the docs name it in code and do not link it.
2026-12-03 12:51:33 -08:00
Anees Iqbal 8e2ae4e702 CONFORMANCE-COVERAGE.md: regenerated for depth-colour-reads 2026-12-03 12:51:32 -08:00
Anees Iqbal 2da77dd27a depth-colour-reads: the Apple M3 Max's recording (macOS 27.0.1, job m3-max-84868)
Recorded by conformance record on the M3 Max at bac637972d, three runs alike, the validated leg
taken. Every read answers as the probe did (m3-max-84755): (d, d, d, 1), the white border
(1, 1, 1, 1), the gather of green the depth taps and of alpha 1, the swizzled view (d, d, 1, 0),
and the depth2d reads (d, 0, 0, 0) and the comparison at quarter weights exactly.
2026-12-03 12:51:32 -08:00
Anees Iqbal 91da6ebe3d depth-colour-reads: an 8-wide texture, so every lane's weights are quarters 2026-12-03 12:51:32 -08:00
Anees Iqbal e30d2409e2 depth-colour-reads: the view's swizzle made at run time (its constructor is not const) 2026-12-03 12:51:32 -08:00
Anees Iqbal 8cff38ab42 Conformance: depth-colour-reads, a depth texture read through a colour slot (unrecorded)
The planner ruled that the runtime keeps Vulkan's (d, 0, 0, 1) for a depth texture read through
a texture2d<float> slot: the three Mac families answer three ways (M3 Max (d, d, d, 1), m3-max-84755;
Radeon Pro 5300M (d, d, d, d) and UHD Graphics 630 (d, 0, 0, 1), m3-max-84762), and the 630's is
Vulkan's. The case pins that answer: the owned fixture dvw_depth_views's five kernels over a 6x5
Depth32Float texture, thirteen reads (samples nearest and linear, at the edge and past it under
an opaque white border, gathers of green and alpha, a view swizzled (G, R, One, Zero), and the
depth2d sample and comparison). It is recorded on the M3 Max; each element where the 630's answer
differs from the M3 Max's may hold the 630's value as well (0), under docs/API.md's new accepted
difference, and everything else compares exactly. Lanes sit at exact coordinates, so a linear
weight is the same on every device.

docs/API.md section 10 gains the entry (its runtime border cell follows the replay). The recording
and the coverage regeneration follow in their own commits.

Verified: cargo fmt. Build, record and replay follow in their jobs.
2026-12-03 12:51:32 -08:00
Anees Iqbal aedc38190f Fixture dvw_depth_views: a depth texture through a texture2d slot beside its depth2d read and comparison
An owned MSL fixture: texture2d<float> sample and gathers of green and alpha, and depth2d sample
and comparison, each through the runtime sampler at slot 0, one float4 per lane.
2026-12-03 12:51:32 -08:00
Anees Iqbal cc28d38674 Runtime tests: bicubic_line's zero texels and output fill are arrays 2026-12-03 12:37:31 -08:00
Anees Iqbal 7941badd0b docs/API.md: a 1D texture's bicubic sample is the M3's measured answer, as the 2D one is
API.md now says the bicubic filter is not documented Metal, in 1D or 2D, and that what the
sample does is Metal's measured answer on an Apple M3 Max. For 1D that is the bilinear filter of
taps i and i + 1 in every format, at the fraction of q = floor(256 (x - 1/2) + 1/2) rounded half
up, with the taps clamped at both ends under clamp_to_edge. The 2D sample has the same status.

The basis, from Metal's own texts:
- The Metal Shading Language Specification 4.1 (2026-06-04), section 6.13.1 "1D Texture": "This
  member function samples from a 1D texture. Tv sample(sampler s, float coord) const", and
  "Because mipmaps are not supported for 1D textures, lod needs to be 0". Its Table 2.7 (sampler
  state enumeration values) lists filter, mag_filter and min_filter as "nearest (default),
  linear" only. "bicubic" appears nowhere in the specification or the feature-set tables.
- The Metal toolchain's header metal/__bits/metal_texture_common declares the enumerator
  `bicubic` in `mag_filter`, `min_filter` and `filter` only under
  `#if defined(__HAVE_BICUBIC_FILTERING__)`.

Metal's answer comes from an Apple M3 Max on macOS 27.0.1, job m3-max-85106: bcu_forms.metal's
1D lane over an 8-texel texture at 16 points, in RGBA32Float, RGBA16Float and RGBA8Unorm. At
x = 3.0, between texels 4 and 9, it reads 6.5, where a Catmull-Rom sum reads 6.25.
2026-12-03 12:37:30 -08:00
Anees Iqbal 47a4455db1 Runtime tests: a 1D texture's bicubic sample against Metal's answer
tests::bicubic_line (device cfg) runs the owned fixture bcu_forms through the runtime on every
device of the cfg's kind and compares its 1D lane (l.sample(bicubic_edge, uv.x), clamp to edge,
normalized coordinates) with Metal's answer for the same textures and points: an 8-texel 1D
texture of RGBA32Float, RGBA16Float and RGBA8Unorm, sampled at 16 points (fractions k / 256 between
two texels, the half-up rounding of the fraction at 1/512 and 1/1024 past a centre, and points
before and past both ends). The pipeline pushes the 1D slot's BicubicTexels word and carries
PrecisionNote::BicubicFilterArithmetic; the float formats' samples equal Metal's, and RGBA8Unorm's
lie within 1/4080 of Metal's, the note's bound at 8 bits.

Metal's answer: an Apple M3 Max, macOS 27.0.1, running bcu_forms.metal's metallib (job
m3-max-85106). It is the bilinear filter of taps i and i + 1 at the fraction k / 256 in every
format: at x = 3.0, 6.5 between texels 4 and 9, where a Catmull-Rom sum reads 6.25.
2026-12-03 12:37:30 -08:00
Anees Iqbal 0a3a4fe911 Cache: SEMANTICS_VERSION 2365, a 1D texture's bicubic sample lowers under the identity domains
Functions that sample a 1D texture through a bicubic constexpr sampler moved from a refusal to a
module under the identity domains (the previous commit). Renumbered at landing: 2362-2364 went to
the partial-threadgroups cause, arm 9 and the blob move.
2026-12-03 12:37:30 -08:00
Anees Iqbal 94adea1c61 Identity domains: a bicubic sample of a 1D texture
The identity domains refused every function that samples a 1D texture through a bicubic
constexpr sampler ("a bicubic filter of a 1D texture", IdentityCause::SamplerState), though its
lowering reads nothing the identity domains do not source. It is the 2D sample's on one axis: the
same footprint (lower::sampler::bicubic::footprint_on, q = floor(256 (x - 1/2) + 1/2)), the
level-0 size by OpImageQuerySizeLod of the bound image (the slot's set-1 element), the taps by
OpImageFetch of that image, and the bound format's treatment from the slot's
PushField::BicubicTexels word (bicubic::format_bits, which takes no dimension), summed by the
module's Routine::Line, which the default domains already emit: the device's FMix of taps i and
i + 1 at the fraction k / 256, then the normalized formats' clamps. Metal filters a 1D texture
bilinearly over those two taps whatever its format (the module docs; the committed M3 observations
of the bcu_forms and bcx_rules cases). The runtime writes the field per slot from the bound
texture whatever its type, so it needs no change. The refusal and BICUBIC_LINE_FORM go.

The sample keeps PrecisionNote::BicubicFilterArithmetic. No new form, query or copy.

The fixture inventory's bcu_forms.ll and bcx_rules.ll rows move to ok on all 15 profiles (30
cells); their .air.ll twins move at the next M3 bless. docs/API.md, the runtime README (its bicubic
paragraph and the identity domains' known gaps) and IdentityCause::SamplerState's doc no longer
list the form. docs/REFUSALS.md regenerated: unchanged. No public item changes.

Test: tests::engine_identity::a_bicubic_kernel_reads_each_slots_format_treatment_from_its_pushed_field
(red at 74dd91398f).
2026-12-03 12:37:20 -08:00
Anees Iqbal 34d3c8d0c0 Identity domains test: a bicubic kernel that samples 1D textures pushes each slot's field (red)
The identity bicubic test asserted that bcu_forms, which samples a 1D texture through a bicubic
constexpr sampler, is refused under the identity domains ("a bicubic filter of a 1D texture").
It now asserts what the 1D form should give: bcu_forms (a 2D texture, a 2D array and a 1D texture
at normalized coordinates) and bcx_rules (twelve 2D and four 1D texture slots at pixel coordinates)
compile, pass L3, push PushField::BicubicTexels for every texture slot, the 1D slots included, and
keep PrecisionNote::BicubicFilterArithmetic, on every profile. It fails until the refusal goes.
2026-12-03 12:36:49 -08:00
designgearsandClaude 5.5 6e25c20f6d Translator: a select of two constant globals' addresses selects their blob offsets
Both arms of such a select are blob addresses, and the strategy held them as plain operands, so
the case was refused (Apple's PVRTC decoder in MTLSimDriver's default.metallib picks its modulation
table this way). BlobStrategy::Select now holds the arms as LocalPtrs, each taken through blob_ptr
at selection and emitted through ptr_value, as BlobStrategy::Copy already does.

SEMANTICS_VERSION 2355: a module that refused before now compiles, with the select over the two
globals' blob offsets. Test a_select_of_constant_globals_selects_their_blob_offsets: a kernel
selecting between two 4-byte constant globals and loading through the result, run on every
committed profile.

Taken from x86sim/metal2vulkan's a980409cd, whose other parts are either already here (program
scope buffer bindings, 058fd25a7; an i8 [[front_facing]] argument, 7c6e9d1fc) or a consumer's
preference (memory::leaf's vector units).

Not run here: this port was made in an environment without the tree's Rust 1.98 toolchain, so
cargo fmt/clippy and the tests still have to run before it lands.

(cherry picked from x86sim/metal2vulkan commit a980409cd)

Co-Authored-By: Claude 5.5 <noreply@anthropic.com>
2026-12-03 21:08:29 +01:00
designgearsandClaude 5.5 77226504f0 Runtime: VK_EXT_extended_dynamic_state and its feature enabled where listed, for RADV's fragment epilogs
RADV of Mesa 26.3.1 draws a fragment function's depth or stencil output under a dynamic depth or
stencil test enable (Vulkan 1.3 core state, which every render pipeline takes) through a fragment
epilog, but makes the device's epilog cache only where the device enables extendedDynamicState,
graphics pipeline libraries, shader objects or a few extended dynamic state 3 features. With none
enabled, the first such draw dereferenced the cache's null operations in vkCmdDraw*: the guest died
in RenderCommandEncoder::draw at first app launch on a Radeon 610M, and the runtime's
stencil_export, depth_stencil_route and opengl_mode device tests segfaulted on that GPU. Mesa's
main makes the cache on every device since its commit 108edde0 (2026-11-24).

The extension is one of OPTIONAL_EXTENSIONS, its feature enabled where reported
(DYNAMIC_STATE_EPILOGS); the translator is told of both, which it already counts on every 1.3
device, so no answer changes. README tables and a floor test.

Not run here: this port was made in an environment without the tree's Rust 1.98 toolchain, so
cargo fmt/clippy and the tests still have to run before it lands.

(cherry picked from x86sim/metal2vulkan commit 584f3ad52)

Co-Authored-By: Claude 5.5 <noreply@anthropic.com>
2026-12-03 21:07:20 +01:00
Anees Iqbal 6459eaa946 Translator: a constant blob past the module's bound is refused at its first read through memory
What: the refusal of a constant blob past memory::blob::MODULE_BYTES moves from the identity
domains' check after planning (select::identity_refusal) to lower::access::blob::use_blob, where
selection first meets a read of the blob. The refusal keeps its cause (IdentityCause::ConstantBlob),
its class (Unsupported{IdentityDomains}, not implemented) and its words ("constant data of N bytes
read through memory").

Why: the plan only holds a blob that use_blob recorded, so the check after planning tested what
selection already knew at the read; refusing there names the cause where the translator meets it,
with no second pass over the plan.

SEMANTICS_VERSION 2364 (renumbered at landing: 2363 went to arm 9): a kernel that reads such a blob
and meets another refusal later in selection now gets the blob's refusal, where it got the other
one before.

Public items: none change (IdentityCause::ConstantBlob stays, and api_signatures.tsv and
docs/REFUSALS.md do not move; refusal_surface.py --check passes). The refusal-pin test is
engine_identity's a_constant_blob_past_the_modules_bound_is_refused_naming_its_size (cause, class
and words on every committed profile); engine_arena's struct DAG case of 128 KiB of blob keeps its
refusal check. runtime-sources.sha256 is re-pinned.

Verified: see the jobs named below.
2026-12-03 12:06:16 -08:00
Anees Iqbal 6ba3572cbe Translator: the lockstep pass only finds pairs; its barrier insertion, rows mode and RowLockstep deleted
What: the lockstep pass (lower::simd::lockstep) keeps one job: find whether an entry holds a pair
of accesses only a SIMD-group's lockstep orders, which sets Lockstep::unordered and the static
note PrecisionNote::SimdgroupAccessOrder. Everything that ordered such a pair is deleted: the
order key (OrderKey, Order::Rows, Decision), the barrier placement (stab, points, insert,
rewritten, the barrier declarations), the rows mode (Basis::Position, Lockstep::rows,
across_rows, orders_across_rows, dispatch's rows_may_split, RuntimeFact::RowLockstep and the
barrier plan's rows_only), the inserted barriers' own forms (barrier::Origin, the barrier's rows
guard, lockstep_class, BarrierPlan::uniform_placed and lockstep_simdgroup, the reconverges
helper), Lockstep's barriers, emulated and inserted, and the select arm that emulated SIMD groups
for a lockstep pair. The census names barrier.lockstep.* go; a program barrier keeps
barrier.simdgroup or barrier.threadgroup.

Why: the identity domains, which every state is translated under, take the key that orders
nothing, so no barrier was ever inserted and every arm deleted here was unreachable.

Public items removed (api_signatures.tsv): metal2vulkan-air Lockstep's across_rows, barriers,
emulated and rows fields and its inserted and orders_across_rows methods, and
RuntimeFact::RowLockstep. Consumer search: reims-vgpu development 76e6c90369 plus its 203 refs
younger than a day: 0 hits each for lockstep, Lockstep, RowLockstep, orders_across_rows,
across_rows and .inserted(.

Tests: the census checks that asserted no barrier.lockstep name are gone with the names (the
value checks of engine_simd_lockstep's kernels stay; its two tests that held only census checks,
the branch arms and the texture calls, go with their kernels); engine_quad_ops drops its
always-false lockstep_emulated; engine_store_quad, engine_ray_tracing and engine_simd_matrix drop
their reads of the deleted fields; the mechanism table loses RowLockstep (62 variants). The
test helper pipeline::testing::specialized_entry takes no profile, since the entry no longer
depends on one: engine_store_quad checks sst_lanes' entry once, and engine_texture_unit_bit_test,
engine_generic_pointers and engine_linking drop the profile they no longer pass.

No module word moves: the deleted arms never ran. SEMANTICS_VERSION and ARTIFACT_FORMAT_VERSION do
not move (the codec tags a fact by its name, and no artifact held RowLockstep). docs/API.md, the
runtime's error and test docs, the simd module docs, lockstep.rs's title and the engine
fixtures README's row_lockstep_tree row lose the clauses about inserted barriers;
runtime-sources.sha256 is re-pinned.

Verified: see the jobs named below.
2026-12-03 12:06:07 -08:00
Anees Iqbal fa5d051b64 Translator: the two-word 64-bit integer forms deleted; every profile holds 64-bit integers in u64s
What: the arithmetic family's word form of 64-bit integers is deleted: Held::Wide and every
arm on it, lower/arith/wide.rs (its word arithmetic, division, casts and lane moves) with its
tests, ArithStrategy::Wide and ArithPlan's wide and divides, the profile's wide forms
(wide_form_on, wide_demote, widen, widen_const, holds_wide), the two-word switch selector
(SelectorForm::Words), the chunked vector's two-word lanes, the ulong texel's word form
(TexelConv::U64Words loses its flag), the matrix descriptor's word form, and in the access
family the two-word address (pointer.rs's Address enum and its helpers, the handle table's
word entries and HandleIds, psb.rs's word base). The helpers the u64 paths still use move to
arith/ops.rs (low_word, zext_word) and access/psb.rs (Pair, split). Every !int64 refusal goes
with them: Feature::Int64Arithmetic, and Feature::PointerCompare, whose one producer was the
static guest plan's !int64 arm. LeafCaps::int64 is deleted, and the mesh fold no longer asks
for shaderInt64. BinOp::ISubBorrow, which only the word subtraction built, goes with its
interpreter and builder arms (the grammar's Op::ISubBorrow stays in spv.rs).

Why: Device::from_queries refuses a device without bufferDeviceAddress and shaderInt64
(IdentityDomains), and it is the only way to make a profile, so every profile has
shaderInt64 and every arm deleted here was unreachable. This commit's parent is the last that
holds the word form.

Consumer search: reims-vgpu development cadac770c2 plus its steelbrain refs younger than a
day (190 refs): 0 hits each for Int64Arithmetic, PointerCompare, LeafCaps and leaf.int64.

The profile's fingerprint changes on every device (the field leaves the profile's Debug
text), so the golden cells read "profile changed" until the table is re-blessed; no key
stays unchanged, so SEMANTICS_VERSION does not move. The module words do not move: the u64
paths emit the same instructions in the same order (the uvec2 the slot offset builds is the
same type the word form's type helper made).

Tests: chunk.rs keeps the chunked lane-move and fragment-shuffle bound tests, on 64-bit and
32-bit lanes held whole; the selector test drops the word cases; the tests that asserted or
filtered on the int64 field or Int64Arithmetic drop those lines; the dynamic move between
slots runs L3 on every profile.

docs/API.md (the object grid's needs), docs/REFUSALS.md, scripts/refusal-surface/reach.tsv
and tests/api_signatures.tsv are updated; runtime-sources.sha256 is re-pinned.

Verified: job m3-max-84770 at this commit (CPU only; the device steps on
lavapipe): clippy plain, --cfg m2v_gpu and --cfg m2v_cpu_icd EXIT=0;
rustdoc EXIT=0 and private-item docs of five crates with 0 diagnostics;
the translator's suite 2,594 of 2,595 passed, 20 skipped, the one failure
golden_hashes_match_the_table (28,950 cells under a changed profile
fingerprint, 0 changed under an unchanged key); air, runtime, devtools
and harness 872 passed, 4 skipped; validation 1,348 passed, 2 skipped;
conformance 1,053 passed; doctests passed; the conformance replay on
lavapipe EXIT=0 with 0 ledger drift lines; the refusal-surface and
signatures checks EXIT=0. The golden and engine inventory lists at the
parent and at this commit show 0 computed cells moved and no inventory
line.
2026-12-03 11:57:03 -08:00
Anees Iqbal 31d8a874f1 Translator: the Floor buffer access deleted; every profile reaches buffers by address
What: BufferAccess and ProfileFields::buffer_access are deleted with every Floor arm:
the refusals that named addressed_needs (the Floor arms of DereferenceLoadedPointer,
Int64Atomics, GpuEncodedIndirectCommands in the indirect-command, replay and execution-range
paths, the de-indexed and private list forms, and the addressed function tables), the
memory planner's addressed flag and its loaded-pointer refusal, the plan's needs (MemNeeds:
that refusal read its dynamic_roots, and the handle classes beside it had no reader since the
handle table went), provenance's dynamic_deref field, the Floor mechanism of
RuntimeFact::FunctionTableRange, the Floor values of MetalDeviceProperties (argument buffers
tier, max buffer length), and the null pointer's static escape that only a profile without
device addresses took. Public items gone:
DeviceProfile::addressed_needs and Feature::{ArgumentBufferPointers, PointerToInteger,
BufferRange}, whose only producers were those arms.

Why: Device::from_queries refuses a device without bufferDeviceAddress and shaderInt64
(IdentityDomains), and it is the only way to make a profile, so no profile is Floor: every
arm deleted here was unreachable. This commit's parent is the last that holds the Floor form.

Consumer search: reims-vgpu development f054ad57c1 plus its steelbrain refs younger than a
day (188 refs): 0 hits each for addressed_needs, ArgumentBufferPointers, PointerToInteger
and BufferRange.

The profile's fingerprint changes on every device (the field leaves the profile's Debug
text), so every golden cell reads "profile changed" until the table is re-blessed; no key
stays unchanged, so SEMANTICS_VERSION does not move.

Devtools: the fuzz Target loses its addressed flag; the pointer-select generator draws the
loaded form on every target, the same draw a target with device addresses made.

Tests: the memory plan tests ask whether a buffer pointer is wide in place of the needs, and
drop the handle-table asserts; the profile tests drop the field's asserts (the max buffer
length test keeps its allocation-limit arm); the pointer-cell tests no longer accept
PointerToInteger; the atomic, kernel stage-in and tessellation tests no longer filter on the
field.

docs/REFUSALS.md, scripts/refusal-surface/reach.tsv and tests/api_signatures.tsv are
regenerated; runtime-sources.sha256 is re-pinned.

Verified: job m3-max-84770 (CPU only, no card): the golden and engine
inventory lists at the parent and at this commit show 0 computed cells
moved of 28,950 (every cell re-keyed by the profile fingerprint, which
this commit moves) and no inventory line. The stack's tip ran the whole
gate (see its message).
2026-12-03 11:57:02 -08:00
Anees Iqbal 09b6d0fb89 Translator: the anisotropic emulation deleted; a device without samplerAnisotropy refuses an anisotropic sampler
What: lower/sampler/anisotropic.rs and its tests, the emulated filter's
routine arm, SpecKey::SamplerAnisotropy, LoweringInputs and VariantKey's
anisotropic samplers, and PrecisionNote::AnisotropicFilter and
DeviceAnisotropicFilter (no producer is left) are deleted.
metal::sampler::check_sampler refuses a sampler of maxAnisotropy above 1
for a use that filters on a device without samplerAnisotropy
(Feature::SamplerAnisotropy, needing the feature): a constexpr sampler
where the function that samples through it compiles, a runtime or
argument buffer's sampler where it is made. A runtime slot's sample
compiles as the plain sample.

docs/API.md's precision-note catalogue loses the two notes,
docs/REFUSALS.md and scripts/refusal-surface/reach.tsv are regenerated
(SamplerAnisotropy is now a device refusal), api_signatures.tsv loses
the deleted items, and the runtime README line on the emulation goes.
SEMANTICS_VERSION 2363 (renumbered at landing: 2360, 2361 and 2362 went to
the seq_cst fence, the argument buffer border texels and the
partial-threadgroups cause). runtime-sources.sha256
is pinned at this tree.

Consumer search (read only), reims-vgpu development 4bb5db49fc and every
steelbrain/* branch younger than a day, 184 refs, git grep over *.rs,
*.toml and *.md: AnisotropicFilter, DeviceAnisotropicFilter,
anisotropic_samplers, SpecKey::SamplerAnisotropy and both degrade ids:
0 hits each.

Why: the planner ruled the emulation deleted directly after G1: under the
one form it is reached only on a device without samplerAnisotropy, where
Metal's anisotropic filter is not the device's, and the refusal names
the feature that device lacks.

Verified: job m3-max-84770 (CPU only, no card): the previous commit's red
test passes at this commit (1 run, 1 passed); the golden and engine
inventory lists at 9886324e31 and at this commit show 0 computed cells
moved of 28,950 and no inventory line (the table's 28,950 cells are
re-keyed by development's own profile changes, waiting for the pin's
bless). The stack's tip ran the whole gate (see its message).
2026-12-03 11:57:02 -08:00
Anees Iqbal c347ac4287 Tests: a device without samplerAnisotropy refuses an anisotropic sampler by name (red)
What: engine_sampler_anisotropy.rs, on committed profiles with
samplerAnisotropy removed. A fragment function sampling at its implicit
level through a constexpr sampler of maxAnisotropy 2, 8 or 16 is refused
at compile as Unsupported{SamplerAnisotropy} needing the feature; one
through an isotropic constexpr sampler or a runtime sampler slot
compiles and links; and a runtime sampler of maxAnisotropy above 1 is
refused where it is made (metal::sampler::vk_sampler) for a float and a
depth-comparison use, while an integer texture's use, which filters
nothing, is made.

Why: under the one form the anisotropic emulation is reached only on a
device without samplerAnisotropy, and there a constexpr anisotropic
sampler ends in an internal error instead of a typed refusal.

Verified: red at this commit in job m3-max-84770 (CPU only, no card): the
test panics at engine_sampler_anisotropy.rs:132 (1 run, 1 failed).
2026-12-03 11:56:45 -08:00
Anees Iqbal 74bdc655a3 RUNTIME_VERSION 2568: uploads the host waits for that use shared memory go as a part of their own
A run in which a restoring make, a read of a texture's bytes, a ready
wait or a wait for room flushes uploads that use memory another API
shares while a group goes now submits those uploads as a part of their
own ahead of the group's first part, in the same vkQueueSubmit2, with
the hand-over of what they alone use, and the host's wait ends before the
group's command buffers. RUNTIME_VERSION 2566 -> 2568 (renumbered at
landing: 2567 went to the partial-threadgroups cause, which landed first).
SEMANTICS_VERSION is unchanged.
2026-12-03 11:37:43 -08:00
Anees Iqbal 07ec04e0d4 Runtime: memory both the waited uploads' part and the group's first part use stays acquired between them
The own part for uploads the host waits for (a6dda529a6) released all it
used at its end and the group's first part acquired all it used again:
where both use one block, one more release and acquire than the single
part before. On the RX 7900 XTX (RADV) that pair put the group's GPU end
97 us later in the scratch probe (a 256 MiB fill touching the export the
waited zero fill is in; group GPU end from the resume, median of 8
alternated runs: 799 us red, 896 us green, run ranges apart; job
m3-max-84216), while the Iris Xe (84176, 1.001) and the RTX 3090 (84191,
0.976) showed none.

parts() now takes what each part acquires and what it releases as two
lists. Where the uploads go as a part of their own, submit() gives that
part an acquire of all they use and a release only of what the group's
first part does not use; that part acquires only what they did not and
releases all it uses. A block both use is so acquired once and released
once, as in one part; one the uploads alone use is still the other API's
again when the host's wait returns, and the uploads' value is signalled
at their last upload where they release nothing. Handed::is is now
pub(crate) for the difference. Every other part's two lists are the same
list, as before.

Docs (Work::flush, submit's, parts', the counters' external_acquires,
external_releases and restoring_makes_shared, Keep::Restore, RestoreFence,
Block and Surface wait_until_ready, the runtime README) say so. The
plane_parts test gains the shape of both lists.

Verified: jobs to follow.
2026-12-03 11:37:20 -08:00
Anees Iqbal e14ee65c7b Runtime: uploads the host waits for that use shared memory go as a part of their own
An awaited flush (Work::flush and the other flush_awaited callers: a
restoring make, Texture::get_bytes of a texture without named bytes, a
ready wait of an exported block or surface whose making is not yet
submitted, and a call's wait for room in the uploads or the staging
ring) whose uploads go with a group signal the value below the group's
in a batch of their own. Where those uploads used memory another API
shares (a new buffer's zero fill in an exported block, a surface
plane's image an upload holds, a block a copy into a texture's image
reads), they signalled nothing: the wait ended at the release after the
group's first part, so it waited for that part's command buffers, for
as long as they ran.

submit() now gathers what the uploads use of such memory apart from
what the group uses. Where the host waits for them and they use any,
they are a part of their own: leads gains a 0 ahead of the group's
(prepended to the member-by-member leads where the group goes apart),
handed gains their list at its head, and parts() gives that part an
acquire at its head and a release at its end that signals the value the
flush gave (close() already numbers it below the group's first part).
That part goes in the same vkQueueSubmit2 as the part after it, so no
call is added; where the group goes member by member it rides the first
member's call. The group's first part hands its own memory over after
it, acquiring again what both use. Uploads the host does not wait for
are as before. Direct3D 11 plane submissions are now counted per call
from the acquires each call holds, so the call with two parts counts
once. restoring_makes_shared keeps its condition and now counts the
makes that took the own part; its docs, restoring_make_wait_nanos',
external_acquires', external_releases' and d3d11_plane_submissions'
say so, as do Work::flush, the RestoreFence docs, Block and Surface
wait_until_ready, and the runtime README (the restore, the fence
paragraph, the exported block's hand-over, Direct3D 11 planes and the
fence's known gap).

Cost on every awaited flush that rides a group and uses shared memory:
one more acquire and release pair (two runtime command buffers, two
hand-over barriers and one global barrier) and one more VkSubmitInfo2
in the same call.

The plane_parts test gains the own part's shape, as one part and
member by member. Verified: jobs to follow (red e8dbe38dc8 against this
on lavapipe and the Iris Xe).
2026-12-03 11:37:20 -08:00
Anees Iqbal 9b71a1a097 Runtime tests: a restoring make whose uploads share memory returns ahead of a held group (red)
restore_batch's scenario becomes a helper with a switch: where it is on, a
new buffer in an exported block (Device::new_exported_block) takes a GPU
zero fill between the held fill's commit and the restoring make, so the
uploads the make's flush awaits use memory another API shares. Today
those uploads signal no value of their own: the wait ends at the group's
part, past its release, so the make waits for the held fill and the test
fails after ten seconds. The existing test runs the same body unchanged.

Red: expected to fail on every device that imports host memory in place
and exports a handle; jobs to follow.
2026-12-03 11:37:20 -08:00
Anees Iqbal aa15ad6b5b Translator and runtime: a refusal of the partial-threadgroups variant names its cause
The translator refuses a kernel's partial-threadgroups variant for five structures, and
the refusal named none, so a walk could not tell them apart (a guest library's kernels
5ba5f694ad0576ff #81 and #83 refuse it with no cause) and the runtime reported each as
Gap::PartialThreadgroups at site Translator.

- error: PartialThreadgroupsCause (ComputeDerivatives, OtherForm, SharedSliceWrite,
  TileFunction, VoteWord), Cause::PartialThreadgroups and Unsupported::partial_threadgroups.
  Each site names its cause: compile.rs's analyze_one (the variant beside another form),
  mesh::plan_partial_groups (a tile function, compute derivatives, an imageblock slice write
  every invocation shares) and simd::divergent's barriers (the vote word, still needing the
  maxComputeSharedMemorySize limit). Feature::PartialThreadgroups' doc lists today's causes
  (the stage-input region and the emulated SIMD-group tier are no longer refused).
- runtime: VariantRefusal reads the cause (the vote word's, a structure's, or none) instead of
  the needs; PartialThreadgroupsSite gains Structure { cause }, the translator's type
  re-exported; Translator stays for a refusal that names no structure. The cache directory
  keeps each refusal under a marker of its own (cache::REFUSALS: the old two plus one a
  structure), so a refusal read back names the same cause.
- Tests: the red test, and a runtime unit test that every cause maps to its refusal and its
  marker and back. README: the gap's sites. REFUSALS.md and basis.rs regenerated;
  api_surface row; api_signatures.tsv blessed.
- SEMANTICS_VERSION 2362 and RUNTIME_VERSION 2567: the refusal and the dispatch's gap say
  more (renumbered at landing: SEMANTICS 2360 and 2361 went to the seq_cst fence and the
  argument buffer border texels, RUNTIME 2566 to the seq_cst fence).

Verified (jobs m3-max-84834, -84836, -84838, -84839, -85025):
- red, the red commit's crates over this commit's target: 3 tests run, 0 passed, 3 failed,
  each refusal PartialThreadgroups with no cause; green: 4 tests run, 4 passed (the three and
  a_variant_refusal_keeps_the_translator_s_cause).
- product suites: 3495 tests run, 3494 passed, 1 failed, 24 skipped; the failure is
  golden_hashes_match_the_table, whose table is re-blessed on development. Validation: 1348
  passed, 2 skipped. Conformance: 1053 passed, 0 skipped. Doctests pass.
- clippy --workspace --all-targets --all-features -D warnings: plain, --cfg m2v_gpu and
  --cfg m2v_cpu_icd, each EXIT=0. Rustdoc with -D warnings and scripts/api-docs: EXIT=0.
Not verified here: which cause the walk's kernels #81 and #83 name (a probe on the walk's
library, reported apart).
2026-12-03 11:37:12 -08:00
Anees Iqbal 706eb4b12f Translator tests: each refusal of the partial-threadgroups variant names its cause (red)
A kernel's partial-threadgroups variant is refused as Unsupported{PartialThreadgroups} for
five structures (an imageblock slice write every invocation shares, compute derivatives, a
tile function, the variant asked beside another form, and a vote word past the shared
memory limit), and the refusal names none of them: a walk's probe of a guest library's
two kernels that refuse it (5ba5f694ad0576ff #81 and #83, both with imageblock barriers)
could not tell which. The tests now read each refusal's cause from its text:
SharedSliceWrite, ComputeDerivatives and TileFunction in a new test over every committed
profile that lowers the plain kernel, OtherForm and VoteWord in the two existing ones. The
imageblock and dispatch tests' kernels the new test reuses are visible to it.

Red: no refusal names a cause yet. Verified: the run follows.
2026-12-03 11:37:12 -08:00
Anees Iqbal ec56957c00 Engine inventory: re-blessed on the M3 after the seq_cst fence and the argument buffer border texels
The inventory's cells follow the translator, and only the M3 blesses its .air.ll twins. The seq_cst
fence (6113e89e0c) and the argument buffer border texels (e5b7498833) moved nine rows from refused
to compiled on all 15 profiles: a27_memory_order, a4_device_fence and dispatch_builtins (.ll and
.air.ll each), and three kernel_read_through.air.ll entries. No other row moved.

Verified: job m3-max-85040 on the Apple M3 Max at 004f68b48f, bless_engine_inventory 1 passed,
2642 skipped, STEP inventory EXIT=0; this commit is that job's patch applied as is (9 lines in,
9 out of tests/public_fixture_expectations_engine.tsv).
2026-12-03 11:34:55 -08:00
Anees Iqbal 004f68b48f Runtime tests: the fenced host writer meets the gate by a handshake, not by chance
host_in_place's each_device_fences_a_host_writer_around_the_restore_alone
asserted held > 0 (the writer found the fence's gate held) on one fenced
make, which holds only where the writer's thread is scheduled inside the
span. On the Radeon 780M (pin T's round, job m3-max-84449) the writer
missed it: the make lost no word and kept its bytes, and held was 0.

The writer now tells a Handshake when it first finds the gate held,
before it waits there, and when it ends; the fenced make's Gate
(Gate::meeting) keeps the gate in after() until the writer has found it
held or ended. The writer stamps from before the make to after it
returns and needs about 130 ms to stamp every word, so it meets the gate
inside the span by structure, and lost == 0 still checks that the stamp
it then writes lands after the write-back. The other Gates (the refusing
one, in place alone, the timed makes) wait for no writer, as before.

The unfenced half keeps its four makes: its witness is a stamp between
the GPU's save and its write-back, which run in one batch with no host
call between them, so no handshake reaches it; the test's doc says so.

The runtime-sources pin is unchanged (pin-compute.py: the hash equals
the committed one). Test only, no version. Verified: jobs to follow.
2026-12-03 10:58:56 -08:00
designgearsandClaude 5.5 6754926f5e Runtime: a viewport depth range past [0, 1] draws where nothing reads the depth
Metal takes a viewport whose znear/zfar lie past [0, 1] (OpenGL's [-1, 1]; NanoTimeKit's
Metal watch faces set it, so x86Sim's Face Gallery drew Nike Bounce black). Its API
validation takes it too. Measured on an Apple M1 under macOS 27: a fragment reads
[[position]].z = znear + z * (zfar - znear) unclamped, and a depth attachment, Depth16Unorm
or Depth32Float, stores that clamped to [0, 1]; a fragment's [[depth]] output is clamped to
[0, 1] whatever the range.

Vulkan takes such a range only with VK_EXT_depth_range_unrestricted, which would also store
a float fragment depth unclamped, unlike Metal, so no runtime enables it. Instead
set_viewport takes the range, and a draw through it whose pass has no depth attachment and
whose fragment function reads no [[position]] z or w records the range clamped to [0, 1]:
there the depth shows nowhere (clipping is in clip space). Any other draw under such a range
is refused as before (Gap::Draw Viewport), now at the draw.

- metal2vulkan: CompiledFunction::reads_position_depth (StageIo::position_depth with the
  FragCoord builtin), its row in api_signatures.tsv; no encoding change.
- metal2vulkan-runtime: RenderCompiled::reads_position_depth; set_viewport and checked take
  the range; a draw refuses it as above; vk_viewport clamps the depth range. RUNTIME_VERSION
  2563: a range past [0, 1] is refused at the draw that reads it, not at the set.
- test every_device_draws_through_a_depth_range_past_zero_to_one_where_nothing_reads_the_depth:
  draws through [-1, 1] without a depth attachment; refuses a fragment function that reads
  [[position]].z, and a draw into a Depth32Float attachment; draws again in [0, 1].

Not run here: this port was made in an environment without the tree's Rust 1.98 toolchain,
so cargo fmt/clippy and the device tests still have to run before it lands.

(cherry picked from x86sim/metal2vulkan commit 633ffbad4)

Co-Authored-By: Claude 5.5 <noreply@anthropic.com>
2026-12-03 19:58:39 +01:00
designgearsandClaude 5.5 386670e0be Translator tests: the profile fingerprint count is per thread
profile_fingerprint_derived read a process-wide count that tests running at the same time
also raised, so it failed whenever another test made a device between its two readings
(both full runs on 2026-11-28; alone it passed). The count is per thread now.

The x86sim/metal2vulkan commit this is taken from also changed
vec16_answers_metal_bound_at_a_multiple_of_4 for a consumer whose leaf selection never
uses uvec4 units; that half is left out, as this tree's leaf selection is already decided
by proven alignment (memory/leaf.rs).

(cherry picked from x86sim/metal2vulkan commit 335a6d717)

Co-Authored-By: Claude 5.5 <noreply@anthropic.com>
2026-12-03 19:54:09 +01:00
designgearsandClaude 5.5 c0b1b9e55d AIR: a texture call whose access immediate is outside 0..=3 binds with no access
Older or upgraded AIR carries other constants in the access position; the call stayed
unknown and sample_texture_2d failed as UnknownIntrinsic. Known values still decode, and
the one reader of the intrinsic's access (unbound storage reads) treats none as storage.
SEMANTICS_VERSION 2354: such calls refused before now compile.

(cherry picked from x86sim/metal2vulkan commit b19d45320)

Co-Authored-By: Claude 5.5 <noreply@anthropic.com>
2026-12-03 19:53:44 +01:00
Anees Iqbal e5b7498833 Translator: an argument buffer's texture read through a sampler takes its border texels from its resource ID's word
Metal 4.1's read(sampler, coord) of a texture an argument buffer holds was refused as
Unsupported{IdentityDomains} with cause HeapResource ("a texture handle that reads its table
entry beyond its element (Indexed ...)"): a read that may hand back the border texels made the
handle search's indexed form (Lookup::Indexed), whose uses read the border texels from a
handle-table entry, and the one form has no table. Metal gives the read to every guest device,
so it is built. The golden table's engine/kernel_read_through rt_heap_zero, rt_heap_ow and
rt_heap_arg, and the conformance cases read-through-a8, -heap-border, -heap-sampler, -r32f,
-rgba8 and -rgba8-swizzled, were refused.

The form is the slot's. Bits 0-11 of the texture's resource ID's word hold its border texels
(docs/RESOURCE-ID.md), and an argument buffer's member holds the whole ID, word included:
- AccessPlan::lookup no longer has an indexed form; a function with heap_border yields Element or
  Flagged (alpha) as any other, which the admission takes;
- emit_identity_handle carries the word's low 14 bits (HANDLE_WORD, above the 16-bit element) in
  every texture handle of such a function, ungated (the texture-buffer words keep their
  TexelBufferWords gate where they alone need them);
- heap_element_index masks such a handle to its element at every use;
- heap_border_texels takes bits 0-11 of the carried word, and for a texture buffer whose word
  holds a word layout's fields there, its format's border texels from its code, as a slot's read
  does (words::slot_border_texels). It was an error stub;
- the read's words estimate counts that extraction (32 words) in place of two indexed flag reads.
Nothing builds Lookup::Indexed now, so it goes, with what only it used: HANDLE_ENTRY,
FLAG_BORDER_TEXELS, INDEXED_FLAGS_WORDS, heap_flags (a check for the indexed form; its two
callers wrap the handle themselves), the search's indexed arm and its test rows.

Test: engine_identity's
an_argument_buffer_textures_read_through_a_sampler_takes_its_border_texels_from_its_word compiles
rt_heap_zero, rt_heap_ow and rt_heap_arg on lavapipe, moltenvk-m3 and moltenvk-m3 without
robustImageAccess2. Each passes L3, plans heap_border, states no BorderTexels fact and no
specialization constant but the dispatch's, and on the CPU interpreter reads Metal's border
texels (metal::sampler::border_texel) of R32Float, RGBA8Unorm, A8Unorm and a swizzled RGBA8Unorm
for each entry's border colors, and the texel inside the texture. engine_texture_oob's
every_read_through_a_sampler_validates_or_is_refused_typed now validates the three entries where
it counted their refusal.

Conformance ledger (known-gaps-rt.tsv): the six `*` rows of those cases' rt_heap pipelines go.
With the pipelines made, each case runs whole, and llvmpipe's answers at 96 sites that a refusal
had left uncompared differ from Metal's by one f32 ulp in A8Unorm, RGBA8Unorm and swizzled
RGBA8Unorm texels. Those are the device's own 8-bit conversion (rule 1, note
device-texel-conversion), and each gets an llvmpipe row. docs/CONFORMANCE-COVERAGE.md is
regenerated.

Docs: the runtime README's forms list loses the entry for this read. API.md's identity paragraph
and RESOURCE-ID.md say an argument buffer's texture reads its border texels as a slot's does.

Engine inventory (public_fixture_expectations_engine.tsv): the 45 cells of
engine/kernel_read_through.ll's rt_heap_zero, rt_heap_ow and rt_heap_arg move from
Unsupported{IdentityDomains; NotImplemented} back to ok. Their .air.ll twins, which only macOS
assembles, move at the M3 bless.

SEMANTICS_VERSION 2360 -> 2361 (renumbered at landing: 2359 and 2360 went to checked naming and the seq_cst fence): the rt_heap cells of the golden table change from the refusal to
modules. The golden table is blessed at the next pin, not here. runtime-sources.sha256 moves for
memory/handles.rs alone: the deleted indexed form is translation code, and no run of an
unchanged artifact changes.

Verified, at this commit's tree:
- m3-max-84730, on the CPU with no device. Red: the new test and the read-through validation test
  with the lowering and memory/handles.rs at the base fail (EXIT 100). Green: both pass, with the
  search's tests (EXIT 0). fmt, signatures, clippy (plain, --cfg m2v_gpu, --cfg m2v_cpu_icd),
  Rustdoc, private docs, doctests and scripts/api-docs pass. The metal2vulkan suites ran 3,494
  tests, 3,493 passed, and the one failure is golden_hashes_match_the_table; the engine inventory
  parts pass. Validation ran 1,348 tests, all passed, 2 skipped; conformance ran 1,053, all passed.
- m3-max-84829, on the CPU with no device: of the golden table's 28,950 changed lines, all are
  "profile changed" lines of the table not yet blessed since the resident core's deletion, and 45
  change a cell, every one an rt_heap cell of engine/kernel_read_through.ll, from the refusal to a
  module.
- m3-max-84715, the pinned lavapipe image (llvmpipe, LLVM 23.1.1, 256 bits): the conformance
  replay of the 13 read-through cases ends EXIT 0 with "the 96 row(s) above are exactly the open
  gaps known-gaps-rt.tsv expects on this venue".
- m3-max-84619, on the Iris Xe (Mesa 26.2.6), at the same change on the base before the inventory
  bless: the 13 read-through cases report 0 gap rows, EXIT 0.
2026-12-03 10:53:26 -08:00
Anees Iqbal 6113e89e0c API surface: the pipeline module's SEQ_CST_FENCE_WORD has its row
The seq_cst fence build made pipeline::SEQ_CST_FENCE_WORD public without its
api_surface row, so api_surface and api_signatures (which counts the table's names
against the parsed surface) failed.

Verified: m3-max-84728 failed the_table_matches_the_source and
the_public_signatures_are_the_committed_table at f42ed033e3; signatures.py --check now
prints 491 names in the table, 491 parsed, and exits 0; refusal_surface.py --check exits 0.
2026-12-03 10:51:24 -08:00
Anees Iqbal 61562e9de2 Runtime README: the fence word's add counts as the function's memory write
The seq_cst fence's add on the device's fence word is a store the translator's
writes_memory scan sees like any other, so a function whose only write is that add is
taken for one that writes memory: its kernel's dispatches are recorded, a fragment
function of a multisampled pipeline carries DeviceFragmentRuns and the writer's sample
mask, and a device that draws [[stencil]] by bits refuses its pipeline. The known-gap
bullet of the seq_cst fence says so. No behaviour change.

Verified: read from spirv/requirements/writes.rs (every Atomic on a
PhysicalStorageBuffer pointer counts), pipeline/compile.rs (the StencilBitDraws
refusal), pipeline/private_state.rs (observes_sample_mask) and the runtime's
encoder.rs (a dispatch of a kernel without writes records nothing).
2026-12-03 10:51:24 -08:00
Anees Iqbal 247a1b0263 Translator tests: the fence word's placement is asserted at compile time
Clippy (assertions_on_constants) refused the runtime assert! of two constants in
the_fence_word_lies_past_the_zero_range_s_reads; both are const blocks now, the word's
alignment through is_multiple_of.

Verified: clippy --cfg m2v_gpu at f42ed033e3, job m3-max-84724, named this one error;
the three configurations rerun at this commit.
2026-12-03 10:51:24 -08:00
Anees Iqbal 572cc17a70 Cache: RUNTIME_VERSION 2566, above development's 2565 after the byte copies
The seq_cst fence build moved RUNTIME_VERSION from 2564 to 2565 for the zero chunk's
fence word, a word of the runtime's ring that pipelines now add to; development took
2565 for the byte copies meanwhile, so this rebased branch takes the next number. The
runtime-sources hash is unchanged (no runtime input file of the product changed; the
build script's hash recomputed over this tree equals runtime-sources.sha256).
2026-12-03 10:51:23 -08:00
Anees Iqbal 291b0de28f Translator tests: the seq_cst test declares the MSL 4.1 barrier; validation lists 40 requirements
The store-buffering litmus declares air.atomic.fence alone, so llvm-as refused the
seq_cst test's MSL 4.1 barrier case (an undefined @air.wg.barrier) at both the red and
the fixed commit, before any assertion ran: the test now appends the three-operand
barrier's declaration for that case. ToolingRequirement::ALL kept its old length of 41
after SeqCstFence left it, which stopped the validation crate compiling; it lists 40.
The barrier selection's comment still said a device-scope seq_cst barrier is refused;
it now says it adds to the device's fence word.

Verified: m3-max-84697 showed both failures (llvm-as "use of undefined value
'@air.wg.barrier'"; requirement.rs:276 E0308); the rerun follows on the rebased tip.
2026-12-03 10:51:23 -08:00
Anees Iqbal 3fbbadbc6e Translator: a seq_cst fence adds to the device's fence word, so seq_cst fences are totally ordered
Vulkan has no sequentially consistent order ("SequentiallyConsistent memory semantics is not
supported and must not be used", vkspec 1.4.366, Memory Semantics), and an acquire-release fence
lets two threads that each store and then load the other's word both read the old values, which
Metal's seq_cst fence forbids: it "establishes a single total modification order of all tagged
atomic operations" (MSL 6.16.1). Such a fence was refused, Unsupported{IdentityDomains}
SeqCstFence; five kernels of the first-setup walk's library aa5e72671a992cea meet it, each with
four air.atomic.fence(mem_device, seq_cst, device) (probe m3-max-84688).

The planner's ruled form, one for every device: a seq_cst air.atomic.fence at any scope beyond
the thread, an LLVM fence seq_cst, and a program's seq_cst barrier whose memory scope is the
device keep the acquire-release barrier they had at their own scope, then add 1 with
OpAtomicIAdd at Device scope, with the barrier's semantics, to the device's fence word. Adds to one
word are totally ordered and each reads the one before it, so the earlier fence's add (a release)
synchronizes with the later's (an acquire). Threadgroup and simdgroup fences take the device word
too (planner, option A): a stronger order than Metal names, with no workgroup memory and no
change to the threadgroup memory limit.

The word: pipeline::SEQ_CST_FENCE_WORD (256) bytes past PushField::ZeroAddress, in the runtime's
zero chunk: one per device (Core holds one Ring; the chunk is kept for the device's life and never
given back), made with every buffer usage, read only in its first 16 bytes (a checked load's unit
at ZeroAddress, psb::ZERO_RANGE_READ, and an indirect command buffer reset's index token of 0
bytes), its value never read. A function with such a fence reads ZeroAddress whether or not it
checks an access (access::place_zero_address keeps it). No new push field.

- lower::sync::barrier: total_order (selection: notes device scope, places ZeroAddress) and
  add_to_fence_word (emission); Fence and Barrier carry `total`; require_seq_cst and
  SEQ_CST_FORM deleted. lower::sync::memory_model: the LLVM fence's `total`.
- error: IdentityCause::SeqCstFence deleted (the consumer names it nowhere: git grep -n
  'SeqCstFence\|SEQ_CST\|seq_cst_fence' at reims-vgpu f054ad57c1 finds only C __ATOMIC_SEQ_CST).
- Guards: psb.rs asserts ZERO_RANGE_READ <= SEQ_CST_FENCE_WORD at compile time; ring.rs asserts
  the word fits its chunk; the_fence_word_lies_past_the_zero_range_s_reads checks both readers.
- Tests: the red test's threadgroup and simdgroup rows take the device add (option A); the
  identity, dispatch and MSL 4.1 tests compile a4_device_fence, device_fence_store and
  a27_memory_order where they asserted the refusal.
- Validation: ToolingRequirement::SeqCstFence and executor_contract::seq_cst_fence retired, as the
  runtime runs the fence; a_seq_cst_fence_runs_through_the_runtime replaces the refusal test.
- Docs: the runtime README moves the fence from the identity refusals to a known gap with the
  add's cost (RTX 3090 m3-max-84667, RX 7900 XTX m3-max-84666, Iris Xe m3-max-84668; device
  fences, standing for threadgroup and simdgroup ones too); docs/API.md and ring.rs say where the
  word lies. api_signatures.tsv blessed; REFUSALS.md regenerated, unchanged.
- SEMANTICS_VERSION 2360 (2359 went to checked naming, which landed first), RUNTIME_VERSION 2565 (a runtime word added; renumbered 2566 below).

Verified, potluck jobs on this branch rebased onto development 436dd1045e, each at a commit of
the branch (whose later commits declare the MSL 4.1 barrier in the test, count 40 requirements,
take RUNTIME 2566, satisfy clippy's assertions_on_constants and add the api_surface row):
- m3-max-84728: the red test at the red commit, with the barrier declared, fails on the
  IdentityDomains SeqCstFence refusal (RED EXIT=100); validation 1344 passed, 2 skipped;
  conformance 1053 passed, 0 skipped; doctests EXIT=0.
- m3-max-84778, at the tree of the branch's last commit: clippy plain EXIT=0; metal2vulkan,
  air, runtime, devtools and harness 3494 run, 3491 passed, 24 skipped, 3 failed: golden_hashes
  and the fixture inventory's parts 1 and 4, whose 45 moved cells are a27_memory_order,
  a4_device_fence and device_fence_store on each of 15 profiles,
  Unsupported{IdentityDomains} -> ok (re-blessed on development). The seq_cst test validates
  every module with spirv-val on every profile.
- clippy -D warnings with the const assertions: plain m3-max-84758, --cfg m2v_gpu
  m3-max-84759, --cfg m2v_cpu_icd m3-max-84761, each EXIT=0; rustdoc and api-docs at the last
  commit's tree, m3-max-84817, EXIT=0.
- Cells against the M3 Max's committed Metal observations: a4_device_fence (8ebbfe8893f9) and
  a27_memory_order (914fc7fd4040) Match on lavapipe (m3-max-84766) and on the Radeon 780M under
  its venue amd-780m-radv (m3-max-84772); a_seq_cst_fence_runs_through_the_runtime and
  a_fence_of_another_order_is_made_through_the_runtime pass on both.
2026-12-03 10:51:23 -08:00
Anees Iqbal fd291a3a6a Translator tests: a seq_cst fence adds to its scope's word, and no other fence does (red)
The planner ruled the sequentially consistent fence built (owner order 3406; the walk's library
aa5e72671a992cea holds five guest kernels refused SeqCstFence today, L157 count m3-max-84638):
each seq_cst fence keeps the acquire-release barrier its order maps to and adds one
acquire-release atomic add of 1, with the barrier's semantics, on one word its scope's fences
share, so any two such fences are totally ordered and store buffering is forbidden.

a_seq_cst_fence_adds_to_its_scope_s_word_and_no_other_fence_does replaces
a_seq_cst_fence_is_refused_and_an_acq_rel_fence_is_a_barrier. On every committed profile, the
store-buffering litmus kernel with each fence form: an air.atomic.fence of seq_cst at device
scope, an LLVM fence seq_cst, and a seq_cst MSL 4.1 barrier whose memory scope is the device
each carry two adds at Device scope through a PhysicalStorageBuffer pointer and read
PushField::ZeroAddress; a seq_cst fence at threadgroup or simdgroup scope carries two adds at
Workgroup scope on a Workgroup word; acq_rel, acquire and release fences carry none and read no
zero range. Each add's semantics equal its barrier's and it adds 1; every module passes L3.

Red at this commit: every seq_cst case is refused Unsupported{IdentityDomains} SeqCstFence.
Verified: the red/green job of the fix commit.
2026-12-03 10:51:23 -08:00
Anees Iqbal 9886324e31 Translator: a device-address access checked against its pushed length is named checked
What: AccessPlan gains bounded, the memory-plan slots reached by their
device address that read their PushField::SlotBounds (place_slots puts a
device-address slot there where AccessPlan::variable holds it), and
AccessPlan::check names a target of one checked. A load, store, quad
store or buffer atomic of such a slot carries .checked in its census
name, as a view's does. Copies' names are unchanged (they carry no
check). SEMANTICS 2359: census names change, no module word does.

Why: emit::prepare checks an access of such a slot whose emitted offset
is not a constant against the slot's pushed length, so the name now
says the check the module runs.

Verified (lavapipe and CPU interpreter, job m3-max-84692 at a8256703d8,
the same patches before the rebase onto 436dd1045e): the two flipped
tests fail at the red commit and pass here; clippy plain, m2v_gpu and
m2v_cpu_icd exit 0; translator 2620 of 2621 passed, 20 skipped, the
one failure golden_hashes with all 28950 cells under a changed profile
fingerprint (the table awaits its bless since the device policy went);
validation 1348 passed, 2 skipped; rustdoc and private rustdoc of the
seven crates clean; the lavapipe conformance replay exits 0 with no
ledger drift. Job m3-max-84598 (the same change on 848acada38): air,
runtime, devtools and harness 872 passed, 4 skipped; conformance 1053
passed; doctests 2 passed; the full golden and inventory lists at the
base and here move 0 values (28950 and 1233 cells).
2026-12-03 10:37:03 -08:00
Anees Iqbal 413194659d Tests: a device-address access checked against its pushed length is named checked (red)
What: two census assertions move to the checked name. The round trip in
a_compile_records_the_containment_it_compiled_under expects its store at
the thread's index as access.store.psb.checked (its load at a constant
offset stays access.load.psb), and int64_buffer_atomics_are_exact_through_
device_addresses expects access.atomic.buffer.cas.psb.checked.

Why: under the identity domains a device-address slot that an access
reaches at a run-time offset reads its PushField::SlotBounds, and each
such access whose emitted offset is not a constant is checked against it
(emit::prepare). The census names a view's checked access .checked but
not a device address's, so the name hides a check the module runs.

Verified: red at this commit before the fix, by the next commit's job.
2026-12-03 10:23:53 -08:00
Anees Iqbal 436dd1045e Conformance ledger: the buffer-depth-samples rows of the Apple M3 Max go
KosmicKrisp (Mesa 26.3.1) on the M3 Max runs the family's five cases at 760b5f7de2 (job
m3-max-84640): the stencil cases exact, the 16-bit depth cases announcing their declared note.
Every row of the venue for them now matches, so each goes. CONFORMANCE-COVERAGE.md regenerated.
2026-12-03 10:01:16 -08:00
Anees Iqbal 760b5f7de2 Runtime metrics: count the render states that interpolate at a sample
Where a render pipeline state's compiled content is made, beside the RenderContents gauge's rise,
a content whose translated pipeline interpolates at a sample (GraphicsState::interpolates_at_sample)
counts in Metrics::sample_interpolating_states. Red before it on lavapipe: job m3-max-84629.
2026-12-03 09:59:40 -08:00
Anees Iqbal 2545400e0d Runtime metrics: render pipeline states that interpolate at a sample, counted (red)
The planner asks a replay to answer whether any guest interpolates at a sample without a probe
build: Metrics::sample_interpolating_states, the render pipeline states made whose fragment module
interpolates an input at a sample (GraphicsState::interpolates_at_sample), in the replay's
per-frame metrics beside sample_copies. This commit adds the field, its replay entry, the README's
counters line and the device test (pm_sample_id counts 1, pm_center 0); nothing counts it yet, so
the test is red. It rides RUNTIME_VERSION 2565.
2026-12-03 09:59:40 -08:00
Anees Iqbal 439a45aa2e Conformance ledger: the buffer-depth-samples rows the runtime now copies, on five venues
Each of the family's five cases now runs where it refused (Gap::TextureBytes): the stencil cases
compare exact and the 16-bit depth cases announce their note (rounded-sample-depth-copy), which
they declare, on the RTX 3090 (NVIDIA 620.70.06, job m3-max-84576), the RX 550 (RADV, Mesa 26.2.6,
84577) and the RX 7900 XTX (RADV, Mesa 26.2.6, 84578), at d81831ad09, the change's tip before its
rebase. Their rows go, and so do the 780M's and the Iris Xe's, whose device test copies every row
bit for bit on the same runs (their conformance replays are next). On lavapipe (job m3-max-84579)
the 4-sample stencil cases are exact, and the 4-sample 16-bit depth case differs only in its
samples site, where the device's decode of a 16-bit depth to float is one ulp from Metal's, as
depth16-texel-reads records: a row of the device's own answer. The 2-sample rows there stay (no
texture of 2 samples). The three every-venue rows narrow to the Apple M3 Max, whose KosmicKrisp
venue is not yet run. CONFORMANCE-COVERAGE.md regenerated.
2026-12-03 09:59:40 -08:00
Anees Iqbal fa59fd319e Byte copies test: the rows' buffers take a block of their size
The all-codes row's 128 KiB of units did not fit the 64 KiB block the helper takes by default
(lavapipe job m3-max-84567... 84570: BufferPastBlock); the 8 x 8 rows passed there, stencil and
16-bit depth, whole and the region at (2, 1).
2026-12-03 09:59:40 -08:00
Anees Iqbal 960030016b Byte copies: a helper invocation outside the region reads its first unit
Lavapipe job m3-max-84567 ended in SIGSEGV at the row whose region starts at (2, 1): a quad the
region's edge cuts runs helper invocations outside it, whose pixel below the origin wraps the
offset, and lavapipe performs their loads. The fragment now reads the region's first unit where its
pixel lies outside the region (the block gains the region's rows, SampleBytes::HEIGHT_AT; BYTES
40 -> 48), so no invocation reads outside the region's bytes on any device.
2026-12-03 09:59:40 -08:00
Anees Iqbal b8c560adb9 Byte copies test: name each row as it starts
Lavapipe job m3-max-84564 ended in SIGSEGV after the first row; the next run says which row.
2026-12-03 09:59:40 -08:00
Anees Iqbal bcd605b407 Byte copies test: read the counts before the command buffer records
The copies count as they record, so the count taken between recording and commit missed them
(lavapipe job m3-max-84558: the Stencil8 row copied back bit for bit, its count read 0).
2026-12-03 09:59:40 -08:00
Anees Iqbal 2d63c60193 Byte copies: ARTIFACT_FORMAT_VERSION 608, past the 607 another change holds
The orchestrator gives 607 to a change landing first; this branch's codec member takes the next.
2026-12-03 09:59:40 -08:00
Anees Iqbal fa2598d76f Byte copies: ARTIFACT_FORMAT_VERSION 606 -> 607, RUNTIME_VERSION 2564 -> 2565
The codec gains a PrecisionNote member (RoundedSampleDepthCopy), and a run of an unchanged artifact
now copies a buffer into and out of a multisample texture's stencil or 16-bit depth where it was
refused (Gap::TextureBytes, which now also carries a cause).
2026-12-03 09:59:39 -08:00
Anees Iqbal 4ccbde14e0 Byte copies: the sample enums are exhaustive, the draw key derives no Debug; REFUSALS.md, basis and signatures regenerated; the replay counts the copies; the conformance case declares the note
The second build (lavapipe job m3-max-84547) stopped on a match over SampleAspect in the runtime,
which #[non_exhaustive] forbids across crates, and on a Debug derive over ash's Format, which has
none without its debug feature. SampleAspect and SampleWrite become exhaustive (class E in
api_surface): a runtime handles each aspect and makes a draw of each write. The replay's per-frame
metrics gain stencil_bit_draws and sample_copies. The conformance side announces
Texture::SAMPLE_DEPTH_COPY_NOTE for a copy into a multisample Depth16Unorm, which the
buffer-depth-samples d16 rows declare; the case's doc states the current form and its refusal of a
32-bit float depth instead of the old form's -0 difference.
2026-12-03 09:59:39 -08:00
Anees Iqbal b337c83e25 Byte copies: the kernel's heap slot is the kernel stage's; the draw's docs, the README's and API.md's lines, and the device test's all-codes row and counts
The translator's sample kernel named its heap slot under a stage that does not exist (Stage::Kernel
is the compute stage's); fixed with the other error the first build (lavapipe job m3-max-84536)
reported. The runtime README states the measured layout, the form, the refusals left with their
causes, and names this caller on the stencil-export known gap; API.md documents own_draw and
SamplesToBytes and catalogues PrecisionNote::RoundedSampleDepthCopy. The device test gains a
128 x 128 Depth16Unorm row at 4 samples whose 65,536 units are every code once, checks every unit
of the copy back out, and asserts the counts: 2 sample copies a row, and 8 stencil bit draws for a
stencil row on a device without stencil export, else none.
2026-12-03 09:59:39 -08:00
Anees Iqbal cfe1e81775 Byte copies: a blit copy between a buffer and a multisample texture's stencil or 16-bit depth, as the runtime's own draw and kernel (first build)
The form the planner approved: into the texture, one rendering of its attachment view over the
region (load, store) of the runtime's own draw, every sample shaded, each fragment reading its unit
at the buffer's device address and writing it (FragDepth for a 16-bit depth, FragStencilRefEXT
where the device exports stencil, else 9 draws by bits); out of it, one dispatch of the runtime's
own kernel reading each sample through the texture's element of set 1's sampled-image array. No
intermediate image and no staging buffer either way. Gap::TextureBytes carries a typed cause
(TextureBytesCause); the new static note PrecisionNote::RoundedSampleDepthCopy
(Texture::SAMPLE_DEPTH_COPY_NOTE); Metrics::sample_copies.

Not yet compiled: this commit is the first build's input; the next commits fix forward what the
build and the red test report.
2026-12-03 09:59:39 -08:00
Anees Iqbal 73eaffdaaa Runtime test: the multisample byte-copy test grants its texture indices
What. The test made its textures at indices 4096 onward without granting them, so on lavapipe it
stopped at "Texture index 4096 is not granted" before reaching the copy it is red on (job
m3-max-84432). It now grants ROWS.len() texture indices from 4096 on each device, as the other
device tests that name an index do.

Verified: the red run named in the hand-off stops at the copy in.
2026-12-03 09:59:39 -08:00
Anees Iqbal 8f67854ca0 Runtime test: a buffer copied into and out of each sample of a multisample depth or stencil texture
What. A device test (tests/multisample_bytes.rs, under --cfg m2v_gpu or m2v_cpu_icd), red on
every device today. On each device it copies a buffer into a Private 8 x 8 multisample texture
through the plane option, Stencil8 with StencilFromDepthStencil and Depth16Unorm with
DepthFromDepthStencil. The rows are the whole texture at 4 and at 2 samples, where the device
makes a texture of that count, and a 4 x 3 region at (2, 1) at 4. The owned rt6_samples kernels
then read every sample, and the texture is copied back out into a buffer that holds 0xee. The test
asserts Metal's answer: copy unit i lands at texel (x, y) of the region, sample s, where
i = (y * width + x) * samples + s, rows bytesPerRow apart; samples outside the region keep the
clear; and the copy back out returns the buffer bit for bit. Today the runtime refuses the copy in
on every device (Gap::TextureBytes: "bytes are not copied to or from this texture of Stencil8"),
so the test fails at its first copy.

Why. Plain Metal does this copy, and a program has no way to ask whether it may, so a guest can
meet our refusal. The planner ranked this row BUILD.

What Metal does here is measured, not documented. Apple's pages for
copyFromBuffer:...toTexture:...options:, copyFromTexture:...toBuffer:...options:, MTLBlitOption and
its two plane options, and MTLBlitCommandEncoder.h say nothing of a multisample texture or of a
sample layout. The options' pages name only a combined format: depthFromDepthStencil "copies the
depth portion of a combined depth and stencil texture to or from a buffer", and
stencilFromDepthStencil "...the stencil portion...". bytesPerRow "needs to be: A multiple of the
source texture's pixel size, in bytes", and no page says what a pixel is at several samples. The
documentation is silent here, which is not the same as calling the result undefined. The answer
was measured:
- The conformance recordings buffer-depth-samples-s8-54-4, -s8-54-2, -s8-part-4, -d16-54-4 and
  -d16-54-2 (Apple M3 Max, macOS 27.0.1, 3 runs each). Their validated field is "ran": Metal's API
  validation let each case run. A script checked all five against the rule above with 0 samples
  off it, the copy back equal to the input, and the part-4 row's other samples at 0x5a.
- A probe of our own (one Objective-C file of plain Metal on our own data, 54 x 54 at 4 samples,
  each of the two formats and options), run plainly and under MTL_DEBUG_LAYER=1, with no
  validation message, command buffer status completed and no error:
  - Apple M3 Max, macOS 27.0.1: job m3-max-84400.
  - Radeon Pro 5300M and Intel UHD Graphics 630, macOS 26.7.1 (25G241), run by the consumer: job
    m3-max-84413.
  All three devices agree exactly: 0 of 11664 (s8) and 23328 (d16) bytes differ on the copy back,
  11664 of 11664 kernel reads follow the layout above (sample-minor), the copy back's sha256 is
  the input's (42384bfd... s8, 852b4489... d16), and the reads' sha256 are the same on the three
  devices (e63212e0... s8, 6d3cc97c... d16).

Verified: red on the job named in the hand-off.
2026-12-03 09:59:39 -08:00
Anees Iqbal 27c53f0b06 Translator tests: the imageblock tests no longer import LowerFamily
The red commit's expectation of Imageblocks in the_imageblock_parameter_value_is_refused_where_it_is_read
took away the module's last use of LowerFamily, and -D warnings then failed the build on the unused
import (clippy, job m3-max-84479).

Verified: the next job's clippy and test lines.
2026-12-03 09:53:05 -08:00
Anees Iqbal 722503da23 Translator: the imageblock parameter's value is refused as Imageblocks(ParameterValue) where the planner meets it
The memory planner refused every read of the imageblock parameter's value before
access::select_param's ParameterValue arm, as Lowering(Access) PointerSource or PointerStore, so
that cause was never named. The planner now decides by the root, the parameter whose ABI role is
ParamRole::Imageblock, at its two sites:

- A pointer read out of an argument's aggregate (provenance resolve_walk): the imageblock
  parameter's value is Imageblocks(ParameterValue). Any other argument's aggregate stays
  PointerSource.
- A store of an aggregate that holds a pointer: when the stored value is built from the imageblock
  parameter (through insertvalue, extractvalue, freeze, select and phi, each value visited once,
  metered), Imageblocks(ParameterValue). Otherwise it stays PointerStore.

The PointerSource, PointerStore and ParameterValue docs say so. SEMANTICS_VERSION 2358: a
refusal's kind changes. REFUSALS.md regenerated, unchanged. No public type changes.

Verified, CPU-only potluck jobs at the pair's tip before its rebase onto development:
- m3-max-84488: the two red tests at the red commit, 0 of 2 passed (RED EXIT=100), and at the
  tip 2 of 2 passed; metal2vulkan and metal2vulkan-air 3480 tests run, 3480 passed, 22 skipped;
  metal2vulkan-validation 1349 passed, 3 skipped; conformance and runtime 1280 passed, 2
  skipped; each EXIT=0.
- clippy --workspace --all-targets --all-features -D warnings: plain m3-max-84494, --cfg m2v_gpu
  m3-max-84493, --cfg m2v_cpu_icd m3-max-84495, each EXIT=0.
- m3-max-84482: rustdoc -D warnings EXIT=0, the API reference check EXIT=0.
2026-12-03 09:53:05 -08:00
Anees Iqbal 742e497f4b Translator tests: every read of the imageblock parameter's value names ParameterValue (red)
The planner's ruling for a multi-cause refusal: name its typed cause. The imageblock parameter's
value is refused by the memory planner before access::select_param's ParameterValue arm, as
Lowering(Access) PointerSource or PointerStore (job m3-max-84446), so a walk's counts could not
tell it from any other pointer source or store.

every_read_of_the_imageblock_parameter_s_value_names_it covers the six shapes that job read,
each checked by Unsupported::cause on every committed profile:
- extractvalue of the parameter;
- extractvalue through a freeze;
- the extracted pointer through ptrtoint;
- a store of the struct;
- a round trip through an alloca;
- insertvalue on the struct, then a store.

the_imageblock_parameter_value_is_refused_where_it_is_read now expects Imageblocks with that
cause, at the same place.

Expected red: all six give Access PointerSource or PointerStore today.
2026-12-03 09:53:05 -08:00
Anees Iqbal f7b02f917a Engine inventory: re-blessed on the M3 after the resident core's deletion
G1 (0ce2f39b71 and the stack through 848acada38) deleted the resident tables,
so every fixture now compiles under the one form the runtime ships. The
inventory still held the resident policy's answers. This bless records the one
form's: 252 rows, 2405 cells.

- ok -> refused: 1581 cells (forms only the resident tables built)
- refused -> ok: 588
- NeedsInput -> ok: 169
- NeedsInput -> refused: 67

The .ll rows match the moves devpolicy's comparison listed before the land
(job m3-max-84210). The .air.ll twins, which need metal-as, only the M3 covers.
Spot check against the golden table: the intersect kernels it already
refuses under IdentityDomains, and the ICB encode it already compiles, now
read the same here.

Verified: job m3-max-84596 (Apple M3 Max, macOS) ran bless_engine_inventory
at 848acada38: 1 passed, EXIT 0; the patch is this commit's whole diff.
2026-12-03 09:51:42 -08:00
Anees Iqbal 848acada38 Conformance ledger: the read-through heap rows hold the refusal G1 names with its cause
What: the six read-through rows of known-gaps-rt.tsv (a8, heap-border,
heap-sampler, r32f, rgba8, rgba8-swizzled; venue *) take the answer the
translator now gives at their pipeline site, the identity refusal with
its cause: "...unreadable: false })): HeapResource; needs
NotImplemented" where the rows held "...unreadable: false })); needs
NotImplemented". Each row's gap names the cause too (IdentityDomains,
cause HeapResource: a texture handle that reads its table entry beyond
its element). No other file holds the old text (grep over the tree's
.tsv, .md, .rs and .json files). docs/CONFORMANCE-COVERAGE.md does not
move (coverage.py --check: as derived).

Why: G0 makes an identity-domains refusal name the form it met
(IdentityCause), so the six rows no longer matched the replay: the
lavapipe replay at da29ee6b55 (job m3-max-84580) reported 12 ledger
drift lines, each of the six "refused ... does not list it" and "no
longer refuses ... still lists it", and EXIT=1.

Verified by job m3-max-84585 at this commit's tree, on lavapipe
(llvmpipe, LLVM 23.1.1, 256 bits; Mesa 26.2.4): the conformance binary
builds (EXIT=0), and `LP_NUM_THREADS=1 conformance replay --cpu` reports
0 ledger drift lines and EXIT=0.
2026-12-03 09:46:56 -08:00
Anees Iqbal da29ee6b55 Translator docs: the nine private links G1 left unresolved say what the one form does
What: rustdoc's private pass (cargo doc -p metal2vulkan --all-features
--no-deps --document-private-items, -D warnings) found nine links to items
G1 deleted. Each sentence is rewritten to what is true now; nothing is
re-added or re-exported.
- lower/access/dynamic.rs: the module doc's wide pointers are the device
  address they hold (a u64, their Metal address), a wide parameter its
  slot's address read where it is needed; the root table, resident-set
  search, sink and containment paragraphs go, and loads, stores, compares,
  null constants, atomics and memory intrinsics through a wide pointer are
  described at the address, unchecked. param_value's doc says it reads the
  slot's address (emit_entry is gone).
- lower/access/handle.rs: a heap texture handle is the resource ID's index
  masked below the set-1 arrays' length, with the alpha flag and the
  texture-buffer word bits where the function uses them, and a heap
  sampler handle is its resource ID with an out-of-range index replaced by
  0; no handle or sampler table is searched (HandleTable::lookup is gone).
- lower/access/psb.rs: Reach::Rounded is the 4-aligned address PsbMem::at
  takes, for a wide pointer's access and a function table's entry
  (psb::prepare is gone).
- lower/sampler/bicubic.rs: an 8-bit sRGB texture's bicubic taps are the
  device's decode through the slot's sRGB view (the raw-code path behind
  Bicubic::raw is gone).
- lower/texture/emit.rs: the three swizzle helpers name swizzle_lanes,
  whose doc now states the swizzle word's fields (swizzled is gone).

runtime-sources.sha256 does not move: none of these files is a pinned
runtime source.

Verified by job m3-max-84530 at this commit's tree: the private pass
(RUSTDOCFLAGS=-Dwarnings, CARGO_TERM_COLOR=never, cargo doc -p <crate>
--all-features --no-deps --document-private-items) is EXIT=0 with 0
diagnostics for each of metal2vulkan, metal2vulkan-air,
metal2vulkan-runtime, metal2vulkan-validation, metal2vulkan-conformance,
metal2vulkan-devtools and metal2vulkan-harness, and the public rustdoc
(cargo doc --workspace --all-features --no-deps, -D warnings) is EXIT=0.
At the parent, job m3-max-84501 listed the nine (metal2vulkan EXIT=101,
9 diagnostics; every other crate 0).
2026-12-03 09:35:53 -08:00
Anees Iqbal 7e0f98c09d Runtime tests: the typed-atomic select test takes the device's answer for 64-bit buffer atomics
every_device_loads_through_a_select_of_a_typed_atomic_s_slot_and_another made the
ADDRESSED_AND_VIEWED state on every device, but its `ulong` add is a 64-bit buffer atomic, which
Vulkan's shaderBufferInt64Atomics answers (a rule 2 query). KosmicKrisp on the M3 Max does not
offer the feature, so the translator refuses the state there, Int64Atomics needing
ShaderBufferInt64Atomics, and the test panicked in its state helper (pin T's Mac leg, job
m3-max-84350: "Apple M3 Max: plain: refused: unsupported: Int64Atomics; needs
AnyOf([[Feature(ShaderBufferInt64Atomics)]])", then "the translator made no pipeline of
addressed_and_viewed").

The test now reads the feature from the translator's profile (what device creation enabled).
Without it, it asserts the state's refusal, Error::Translation of Unsupported Int64Atomics needing
AnyOf([[Feature(ShaderBufferInt64Atomics)]]), and runs nothing; with it, it runs today's value
checks. The 64-bit add stays: a typed atomic (a u64 one, or a native f32 add, which needs a feature
too) is what moves its slot to its device address, the shape under test. A third leg opens each
device without shaderBufferInt64Atomics (without_int64_atomics), so every device, lavapipe in CI
included, runs the refusal branch, and each device that has the feature runs the value checks in
its own form and in the address form.

The same assumption elsewhere: no other device test in the runtime, harness or conformance crates
uses a 64-bit atomic (searched for `atomicrmw ... i64`, `air.atomic.*.i64`, `atomic_ulong` and
`atomic<ulong>` in their sources, and in the 58 engine and example fixtures their tests load).

Verified: the observed red is pin T's Mac leg, job m3-max-84350 (KosmicKrisp 26.3.1 on the M3
Max), quoted above. Green on lavapipe (llvmpipe, LLVM 23.1.4, 256 bits), job m3-max-84503: the
test passed, printing its own form and the address form reading both slots, and the leg without
shaderBufferInt64Atomics "the state is refused, Int64Atomics". Green on the Iris Xe (RPL-P, ANV),
job m3-max-84505: the same, its own form the bound form. The M3's proof comes from the next
round's Mac leg.
2026-12-03 09:29:02 -08:00
Anees Iqbal 4ec2663ba9 Translator tests: the Layout and CellPointer imageblock causes, and the front end's multisample names
Three tests check refusals by Unsupported::cause, the field, not the text:

- an_imageblock_of_no_cell_layout_is_refused_naming_its_layout: a kernel's explicit imageblock
  whose air.arg_type_align_size is 3, not a power of two, is Imageblocks(Layout) on every
  committed profile.
- a_cell_pointer_not_made_by_imageblock_data_is_refused_naming_it: an imageblock-space pointer
  made by inttoptr in a kernel is Imageblocks(CellPointer).
- the_front_end_s_imageblock_refusals_are_the_multisample_operations: the front end refuses by
  the Imageblocks feature exactly four undecoded names (air.get_imageblock_samples,
  air.get_imageblock_num_colors, air.get_color_coverage_mask, air.store.implicit_imageblock.mask.),
  and the translator names each MultisampleOperation. A name outside that list
  (air.get_imageblock_coverage) is already a refusal of its own, Feature::UnknownIntrinsic with
  no cause. So the test asserts that, and no fix is needed. A fifth name added to the list fails
  the test, so its cause is decided then.

ParameterValue has no test here. Six IR shapes that read the imageblock parameter's value were
each refused first by the memory planner as Lowering(Access) PointerSource or PointerStore:
extractvalue, freeze, ptrtoint, a store of the struct, a round trip through an alloca, and
insertvalue. None reached access::select_param's ParameterValue arm.

Evidence for two commits already on development:
- 71a5393966 (its body says "Verified: pending"): job m3-max-84253 (CPU). In the red tree, all
  crates at 97426a89e4, 3 tests ran and 3 failed; at the tip c5affc2ae8, 3 passed.
- e498cbaa54 ("the field check's run follows"): the same job, m3-max-84253, and the audit lane's
  m3-max-84368 (94 tests, nextest exit 0).

Verified: job m3-max-84446 (CPU) passed the three tests at the same test code, and printed each
probed shape's refusal.
2026-12-03 09:25:15 -08:00
Anees Iqbal 5715c0a161 Tests: three pointer tests take the one form's answer
What, in tests only:
- a_slot_bound_inside_an_allocation_stores_its_metal_address keeps its
  form assertion on all three profiles and runs its allocation arm only
  where slot 0 is at its device address. The harness places a slot
  inside an allocation only there; a bound view's buffer is the binder's
  to place.
- stored_pointers_are_guest_addresses_that_resolve_back tests the null
  pointer it reads back before reading through it. Under the one form a
  loaded pointer is used as given, so a read through null is Metal's
  undefined read; development's zero came from the resident tables. Its
  volatile counts follow b2's planned form: two words through a view,
  one u64 at a device address.
- static_pointers_convert_to_their_metal_addresses counts each stored
  address the same way, by b0's planned form.

Why: each was hidden in the G1 runs by an earlier census assertion in the
same test, and failed in its translator suite once those were ported.

Verified by job m3-max-84364 at this commit, on G1's stack over
development ed75c57d5d: the three tests fail at the commit before (3 of
3) and pass here (3 of 3); clippy plain, m2v_gpu and m2v_cpu_icd EXIT=0;
translator 2617 run, 2608 passed, 9 failed (the golden table and the 8
inventory parts, which wait for their bless), 20 skipped;
air/rt/devtools/harness 872 passed, 4 skipped; validation 1348 passed,
2 skipped; conformance 1053 passed; doctests 2 passed; rustdoc clean.
2026-12-03 09:15:34 -08:00
Anees Iqbal 6dd147bafb Translator: the store sink weighs its work as the rest of a lowering, whoever asks
Under the one form every order key orders nothing, so order_specialized runs
lower::access::quad::sink after the lockstep pass. The lockstep pass and the
specialization weigh their work explicitly (weights::LOCKSTEP, ::SPECIALIZE);
the sink took the weight of its caller. A compile asks for the order under
compile_bounded's weights::REST (10 sixteenths a unit); a creation's partition
check (kernel_observes_partition) asks outside it, at a whole unit a tick. The
check's StageEntries keeps the order with what it charged, and the compile that
finds it spends that charge, so the shared compile paid the sink's work at 16
where its own compile pays 10: library_entries_decode_once's
a_partition_check_and_the_kernels_compile_order_its_entry_once read 30535 work
units through the kept order against 30510 alone (job m3-max-83989, moltenvk-m3).
On development the resident form ordered, the sink did not run, and the two
agreed.

The sink now weighs weights::REST wherever it runs: a lone compile's charge is
unchanged, and a check's sink is charged as a compile's. No output changes, so
no SEMANTICS bump.

Verified: pending (the test above, in the next G1 job).
2026-12-03 09:15:34 -08:00
Anees Iqbal 53175c937e Translator: a coherent access at a device address needs the Vulkan memory model
lower::sync::memory_model's contract says a coherent access through a device address has no
variable to decorate, so it needs the Vulkan model on every profile. A wide pointer's coherent
access selected the model itself, and an interlocked body that reaches a slot at its device address
did once the slots were placed (finish_interlock), but a function whose `*_coherent` accesses took
the GLSL450 form on a profile without vulkanMemoryModel and its device scope, and that reaches a slot
at its device address, kept GLSL450: its storage buffers decorated Coherent and its device-address
accesses plain, with no coherence at all.

The slot rule now covers both: finish_coherent_slots (finish_interlock renamed) selects the Vulkan
model for an interlocked body or a function whose coherent accesses took the GLSL450 form, where a
slot is reached at its device address, and check refuses it on a device without the model,
Unsupported{CoherentMemory, AnyOf[[VulkanMemoryModel]]}, as for the interlocked body. One rule, the
documented one; no decoration form beside it. Floor devices are unchanged: the floor requires
vulkanMemoryModel and its device scope, where coherent_access already takes the Vulkan model.

The refusal is an existing variant and text: refusal_surface.py --check passes with no change
(run locally). The stack's SEMANTICS 2351 covers the changed outcome.

Verified: (jobs named in the READY).
2026-12-03 09:15:33 -08:00
Anees Iqbal 047638e250 Tests: a coherent access at a device address needs the Vulkan memory model (red)
Without the Vulkan memory model a function's coherent accesses take the GLSL450 form: plain
operands through resources decorated Coherent. A PhysicalStorageBuffer access has no variable to
decorate, so where a kernel reaches its buffers at their device addresses (every buffer argument
of a kernel without the bound form) such an access had no coherence and still compiled, though
lower::sync::memory_model's contract says it needs the Vulkan model on every profile, as an
interlocked body that reaches a device address does (finish_interlock).

volatile_under_the_vulkan_model_adds_only_volatile runs its GLSL450 arm on a below-floor profile
whose kernel binds its buffers (amd-780m-hawkpoint-radv without vulkanMemoryModel and its device
scope; lavapipe binds none, its maxStorageBufferRange) and now asserts that one reaching its
buffers at their addresses ("runtime-floor without vulkanMemoryModel") is refused,
Unsupported{CoherentMemory, AnyOf[[VulkanMemoryModel]]}.

Red at this commit: the runtime-floor arm compiles (job m3-max-83747, before the change, met it
as "Load through %86: not Coherent under GLSL450"; the run at this commit is named in the READY).
2026-12-03 09:15:33 -08:00
Anees Iqbal 4c903ea617 Translator: a switch over texture buffers is named by the check its arms take
Switch::name named a switch-at-use by its first arm's strategy, matching only the plain read,
write, atomic, query, null test, sampling and absent-argument strategies. Under the identity
domains a texture buffer's read, write and width query are lower::texture::words accesses
(TextureStrategy::Words), so a switch over texture buffers fell to "texture.null.switch", a name
that says nothing of the check its arms take. It now looks through a Words arm to its access
through its own view (Words::native), whose check it takes: texture.read_clamped.switch,
texture.write_guarded.switch and the others as for a plain texture buffer. One form: no words
family of switch names.

What the name reaches: the census only (FunctionArtifact::strategies, the validation coverage
report's strategy names). No SPIR-V word and no cache key carries it, so golden hashes do not
move; a cached artifact carries its census, and the (a) landing's SEMANTICS and ARTIFACT_FORMAT
bumps already invalidate every cached artifact, so no bump of its own. Coverage moves
texture.null.switch counts of texture-buffer switches to their read and write names.

Verified: (job ids added at the READY).
2026-12-03 09:15:33 -08:00
Anees Iqbal 14d99c8e48 Tests: a switch over texture buffers is named by the check its arms take (red)
Under the identity domains a texture buffer's read, write and width query are
lower::texture::words accesses (TextureStrategy::Words), and Switch::name matches only the
plain strategies on its first arm, so a switch-at-use over texture buffers falls to
"texture.null.switch". a_switch_is_named_by_the_check_its_arms_take now collects every wrong
name before it fails, so its TexelRead and TexelWrite rows both show, and its doc says a texture
buffer's access is named by its access through its own view.

Red at this commit: the TexelRead row on runtime-floor without image robustness reads
[("texture.null.switch", 1)], not texture.read_clamped.switch (job m3-max-83747, lavapipe ICD,
compile only, the row the test met first before this change).
2026-12-03 09:15:33 -08:00
Anees Iqbal 0ce2f39b71 Translator: the resident core deleted; every device compiles the one form, and the tests run it
Every device now compiles the identity domains, the one form: a kernel's
buffer arguments are bound as storage buffers of set 0 where the device
binds them (DeviceProfile::binds_kernel_buffers) and are reached at their
device addresses elsewhere, as every other stage's are; vertex attributes
are fetched by fixed-function vertex input; textures and samplers are
elements of the identity arrays of set 1, named by their resource IDs.
What the one form does not lower is a typed refusal,
Unsupported{IdentityDomains, NotImplemented} with the IdentityCause the
previous commit names.

Deleted, with everything only they reached:
- the device policy (device/policy.rs) that chose the resident-table
  domains, and the resident root table, handle table and their facts;
- the heap raw reads (lower/sampler/heap_raw.rs, lower/texture/heap_raw.rs),
  sampler footprints, bind/texel_parts.rs and bind/status.rs;
- the lockstep orders' barrier tiers, which no order key adds now
  (OrderKey::of orders nothing).

Tests: 274 tests that only the resident-table policy compiled (development's
DevicePolicy::RESIDENT_TABLES, which only tests built) are deleted, among
them 15 whole files (argument tables, cross-class, device replay, dynamic
roots, two extended-range files, image shapes, mesh barriers, profile F,
separate samplers, sparse unmapped, tile, wide, sweep and the footprint
tests); each deletion's reason is listed with the READY. The others are
ported to what the one form compiles and names today: census names,
push fields, refusals with their causes, and run values. A new interpreter
harness (tests/identity_harness.rs) binds a dispatch's buffers at device
addresses and its textures as identity-array elements. Census naming is
unchanged. The validation tests that read compiled modules (coverage,
companions, the authored compile census, specialization) assert the one
form's present strings. The extended-range levels and volume tests, whose
mip filters development built under the resident tables, become two tests
of the one form's answer, which is development's default policy's: a 2D or
3D sample of an extended-range slot texture is refused, TextureState
(lower::texture::identity_class holds no class for it); a padded form's 3D
sample stays the lowering's NotImplemented(Format). Development's new
thread-local test binds through the one form's harness, and its
handle-web test (every_handle_web_an_instruction_observes_is_refused)
compiles on the default profile.

SEMANTICS_VERSION 2355 and ARTIFACT_FORMAT_VERSION 607 (cached
translations and artifacts change). docs/REFUSALS.md is regenerated and
runtime-sources.sha256 is pinned at this tree.

Verified at the stack's tip, which differs from this commit only by the
five commits after it; the jobs and their results are named in the READY.
2026-12-03 09:15:33 -08:00
Anees Iqbal dec0ca173a Interpreter: a sampler is a stateless value, and OpSampledImage is its image
The one form samples through the identity domains' sampler arrays: a
function loads a sampler (or an element of a sampler array) and combines
it with an image by OpSampledImage, which the interpreter reported as
unmodelled, so no test could run such a module. The image model reads no
sampler state, so a sampler global (or an array of them) is now
GRoot::Sampler / Root::Sampler: loading it or indexing it yields the
stateless sampler, a byte access to it is malformed, and OpSampledImage
of an image and a sampler is the image, as OpImage of a combined image
sampler already was. Sampling itself is still not modelled; an exact
fetch through a sampled image runs.

Test-only (crate::spirv::interp); no product output moves. Verified by the
G1 suites that run the sampled modules through it (jobs m3-max-83989,
m3-max-84055, translator nextest).
2026-12-03 09:13:23 -08:00
Anees Iqbal a8ccda7cc6 Translator: an identity-domains refusal names the form it met
Feature::IdentityDomains with Needs::NotImplemented covered every form the
identity domains do not lower behind one name; only a diagnostic symbol
said which, and slot.rs's refusal of a storage texture access without its
bound format named nothing. An identity refusal now carries
Cause::Identity(IdentityCause), one variant per refused family, the way an
access or tessellation refusal names its cause; sites that refuse the same
family share a variant, none is named by a file, a line or a string of its
own:

- ObjectOrMeshStage: a function of a stage other than a kernel, vertex or
  fragment function (select.rs identity_refusal).
- Descriptor: a buffer argument not reached through its device address, or
  a descriptor beyond a bound kernel's storage views (identity_refusal).
- EncoderValue: a push field the identity window does not carry
  (identity_refusal).
- HeapResource: an argument buffer's texture of a type or handle class the
  identity arrays hold no element for, read as raw extended-range texels,
  decoded, read through another numeric type, or through a handle that
  reads its table entry beyond its element (identity_refusal; link.rs's
  handle-class binding).
- TextureState: a texture argument of a type the identity arrays hold no
  element of, or state of a bound texture or sampler beyond its resource
  ID (identity_refusal; sampler/mod.rs's identity sampling of a type with
  no identity class).
- SamplerState: a sampler the identity sampling does not take, a minimum
  level or emulated filter the function specializes, a 1D bicubic filter
  (identity_refusal), and a reached anisotropic slot sample
  (sampler/anisotropic.rs).
- ConstantBlob: constant data past the module's bound read through memory.
- SeqCstFence: a sequentially consistent fence (sync/barrier.rs).
- StorageTextureFormat: a storage texture access the device takes only
  with a declared format, whose bound format no input names
  (texture/slot.rs, which named no form before).

The diagnostic symbols stay. The device-level refusal of a device without
bufferDeviceAddress and shaderInt64 (derive.rs) names its needs and no
cause. Feature stays IdentityDomains, so validation's outcome key and the
census are unchanged, and the golden and engine table cells (feature and
needs only) do not move; no version bump.

Tests: the error module's Display test of an identity refusal with and
without a symbol; the cause asserted at the 1D bicubic, the storage texture
without its format, the constant blob, the seq_cst fence and the texture
argument refusals (engine_identity) and the replay variant's encoder value
(pipeline/compile tests).

api_signatures blessed (IdentityCause, Cause::Identity), api_surface lists
the enum, REFUSALS.md regenerated (the sites are built through
error/mod.rs's Unsupported::identity), docs/API.md's error table and the
identity domains' paragraph name the cause. runtime-sources.sha256
unchanged: no runtime input is edited.

Consumer uses (consumer-uses.sh, read-only, over the consumer's
development 90214271ed and its lane tips of the last day): IdentityCause,
Cause and IdentityDomains, 0 hits. The consumer reads Unsupported::cause
only through its Display (rt_platform diag.rs refusal_name, unbuilt.rs),
so an identity refusal's name there now carries its cause.
2026-12-03 09:13:23 -08:00
Anees Iqbal c708eaa754 Runtime docs: the identity domains' known gaps name a tile memory fragment function, a sparse status on a plain texture, an extended-range bicubic repeat offset and a 4.1 sampler read of an argument buffer's texture
The README's list of the forms the identity domains do not lower named none of four structures the
golden table refuses with Unsupported{IdentityDomains} on every profile, so a reader of the known
gaps could not tell they are refused. Each now has its entry, beside the form it is nearest:

- a fragment function over its tile's threadgroup memory (`engine/cfit_fragment_tile_memory`, four
  entries). Its entry says no guest of the consumer's can ask for one: Metal's feature set tables
  give tile shaders and imageblocks from the Apple4 family, and the consumer's guest device answers
  no Apple family on both its guests (reims-vgpu's graphics/device_info.rs at bb8738f7eb:
  `cap_apple_families`, "today no for every one", and `supportsTileShaders` and
  `supportsImageBlocks` answered no);
- the residency of a sparse operation on a texture that is not sparse (`engine/a2_sparse_status`);
- a bicubic sample of an extended-range texture through repeat with a constant texel offset
  (`engine/xr_bicubic`'s `xrb_repeat_offset`, the only refused entry of that fixture);
- Metal 4.1's read(sampler, coord) of an argument buffer's texture (`engine/kernel_read_through`'s
  `rt_heap_zero`, `rt_heap_ow` and `rt_heap_arg`).

The refusals are the golden table's cells at this commit's parent (15 of 15 profiles for each
entry). Which form each one's symbol names is not asserted here, so each entry cites the golden
table and quotes no symbol.

Verified on the CPU with no device, job m3-max-84445 at this commit's tree: cargo fmt --check 0
and the workspace's rustdoc with -D warnings 0. The golden cells are read from
crates/metal2vulkan/tests/golden_hashes.tsv at the parent; the consumer's answers from its
development branch, read-only.
2026-12-03 09:11:46 -08:00
Anees Iqbal ed55748644 Docs: the runtime README, API.md, REPLAY-STREAM.md and VALIDATION.md state each measurement by its card and driver, not by our job id
The planner widened the job-id rule from the published crates' rustdoc to the four prose docs a
reader takes measurements from. Each lab job id (m3-max-NNNN, and the bare job numbers beside
them) and each commit sha comes out; the ids stay in the commit messages that already carry them.
A measurement keeps the card, driver and OS its sentence names. Where an id was the only basis a
sentence named, the sentence now says what was measured and on what:

- the runtime README's identity-domains paragraph cited five plays of recorded streams; it now
  states what the states-only plays of the 26 kept replay streams on lavapipe show: each makes
  every pipeline state its stream makes, and none of their render or compute states is refused,
  a refusal under the identity domains among them (the plays of jobs m3-max-83458, -83494, -83695,
  -83889 and -83954, each printing refused 0);
- the probe lists name the cards ("probes on the RTX 3090, the Iris Xe, lavapipe and the RX 7900
  XTX"; "probes on a Radeon Pro 5300M and a UHD Graphics 630, both macOS 26.7.1");
- sentences that compared runs by id compare them by order ("failed in one run and passed in two
  others"), and "the same job" is "the same run";
- "rt at <sha>" and "players built from <sha>" become what that build was ("a build of the runtime
  that copied a texture over any import"), or go where the card and driver already say it;
- VALIDATION.md's harness count reads "the harness on lavapipe".

Two README tables lose their Job column (the import-cost table and the guest-buffers table). The
edited paragraphs are rewrapped at 100 columns; a token diff against the parent shows only the
ids, the shas, the two columns and the rewordings above.

submit.rs's three citations of two probe commits (06860a3848 and b15b306d2f) become "measured
with a probe build of the runtime" (and, for the split probe, "that timed each command buffer");
the IN_FLIGHT and infos comments are rewrapped at 100 columns.

So it does not grow back, scripts/api-docs first fails when the four docs name a job id
(`m3-max-NNNN`, or `job NNNN`); CONTRIBUTING.md, API.md's description of the script and ci.yml's
comment on its step say so.

docs/CONFORMANCE-COVERAGE.md is unchanged: its generator has no job column. Its 1772 lines with an
id are all in its last section, The ledger, which quotes the last field of known-gaps-rt.tsv; the
ids are in the ledger's own sentences, which the ruling keeps out.

Not widened, per the ruling: the ledger, known-gaps-rt.tsv, results.py, test comments and the
unpublished crates. The OS is not added to measurements whose sentence named a card and driver
but no OS.

Verified on the CPU with no device, job m3-max-84430 at this commit's tree: cargo fmt --check 0;
the workspace's rustdoc with -D warnings 0; scripts/api-docs 0, and 1 with a job id planted in
docs/VALIDATION.md, naming the planted line (the tree clean after its restore); the refusal
surface's --check 0; the 13 tests that read these docs passed (feature_enables, the floor, the
accepted differences, the precision-note catalogue, the consumer's objects and the guide's
example). Before the commit, no line of the four docs matched the check's pattern, and rustfmt
--check passed on submit.rs.
2026-12-03 09:10:35 -08:00
Anees Iqbal a14a6e362b Translator tests: the observed-webs test counts the analysis's webs, so it is red without the fix
What: every_handle_web_an_instruction_observes_is_refused
(src/tests/engine_handle_words.rs) also counts the word webs the memory
analysis finds (`memory::plan::analyze_memory`'s `words`, through a new
helper `webs`, built as engine_word_phases.rs's `proven` builds its
plan): two in the control, where no instruction observes the two webs,
and none in each form that observes them (a compare of the two words
either way round, their difference, one web's word compared with a raw
resource ID).

Why: the test b5f7a1b805 added passes with and without that commit's
fix (its own message: 8 of 8 both ways), as AGENTS.md's "add a test or
a measurable check that fails without the fix" asks otherwise. The
refusal cannot tell one web spoiled from both: whichever web the old
loop left planned, the other's sink refuses the module with the same
Lowering(Access) / HandleUse. The analysis's count can: the old loop
spoiled only the web of an instruction's last operand, so each
two-web form left one web.

Verified on the CPU with no device. Job m3-max-84234, at this commit
on its first base (c887b9b7e9): the test at the fix's parent's
memory/provenance/words.rs red (1 failed, EXIT 100), green at this
commit (the 8 engine_handle_words tests passed); fmt, signatures, clippy
in the three configurations, rustdoc, private rustdoc, api-docs and the
refusal surface 0; the product suites 3756 passed, 24 skipped, 1 failed:
the golden table, which that base's blessed table did not match before
pin U's bless (this commit changes no product source); validation 1349
passed, 3 skipped; conformance 1053 passed; doctests 0. Job
m3-max-84368, at this commit rebased onto ed75c57d5d: the observed-webs
test, the L156 tests and the golden table, 94 tests, none failed. No
product source changes, so no SEMANTICS_VERSION bump and
runtime-sources.sha256 is unchanged.
2026-12-03 09:06:46 -08:00
Anees Iqbal 5db315e226 Conformance ledger: a pixel sampler under mirrored repeat is undefined in Metal
What. The 28 rows of pixel-samplers-rgba8-linear-mirror and -rgba16f-linear-mirror at their
`slot` and `arg` sites (four sites on each of the seven venues) gain one sentence: Metal leaves
the sample undefined, so the difference is no wrong answer against documented Metal (rule 1).

Why. Apple's MTLSamplerDescriptor normalizedCoordinates page, as fetched: non-normalized
coordinates "should only be used with 1D and 2D textures with the following conditions;
otherwise, the results of sampling are undefined": the clampToEdge or clampToZero address mode,
the notMipmapped mip filter, equal minFilter and magFilter, and a maxAnisotropy of 1. MTLSampler.h
names ClampToEdge alone. These cases sample a pixel sampler under mirrored repeat. Of group C's 22
KosmicKrisp sites, the 18 pixel-downscales sites (clamp to edge, linear, not mipmapped) stay a
wrong answer of ours; these 4 are not one.

docs/CONFORMANCE-COVERAGE.md re-run with coverage.py: unchanged (its table shows each row's first
words).

Verified: 28 rows changed by script, 4 a venue on seven venues; the conformance suite runs on this
commit (job named in the hand-off).
2026-12-03 08:50:41 -08:00
Anees Iqbal 6521f16ed5 Conformance ledger: the pixel-sampler quotient at group C's sites is ours on the six other venues
What. The KosmicKrisp venue (Apple M3 Max) reads 22 sites as ours, not the device's
(5eeeb8d752): pixel-downscales frac/slot head, tail and digest at seven sizes (18), and
pixel-samplers-rgba8/rgba16f-linear-mirror slot and arg (4). The texture slot's runtime pixel
sampler hands the device's normalized sampler the pixel coordinate over the size, and that
quotient's rounding moves the linear filter's weights. KosmicKrisp's filter is Metal's, so its
controls isolate the quotient: `norm` (and `const`) give Metal's answer there, `slot` (and `arg`)
do not. The same 22 sites on lavapipe, NVIDIA, the RX 7900 XTX, the 780M, the RX 550 and the Iris
Xe still said "The device's own answer (rule 1)". This commit rewrites those 132 rows' words; no
row's case, venue, verdict, site or answer changes.

- pixel-downscales, 18 sites a venue (108 rows): "Ours, on top of the device's filter". On every
  one of the six venues `slot`'s frac digest is not `norm`'s, where Metal answers the two alike,
  and `norm` differs from Metal's by the device's own filter. Each venue keeps its own bounds
  (lavapipe 2/255; NVIDIA 1.19/255 slot, 0.83/255 norm; RADV 0.88/255 slot, 0.031/255 norm; Iris
  Xe 0.95/255 slot, 0.031/255 norm, and its grid/ulp one-ulp element).
- linear-mirror on the three RADV venues (12 rows): ours, on top of the device's filter; there
  `arg` and `slot` share one digest and `norm` has its own.
- linear-mirror on lavapipe, NVIDIA and the Iris Xe (12 rows): left the device's answer, with one
  sentence added. On those venues `slot` and `arg` answer `norm`'s digest, so the controls show
  nothing of ours there; the quotient KosmicKrisp shows to be ours does not move these devices'
  answers. Calling these rows ours would claim more than the controls show.

The frac/slot sites KosmicKrisp answers as Metal does (1000x1080 tail, 1366x1080 head and tail)
are not group C's and keep their words.

Why. A row's words say whose difference it is; a stale reading hid that this one is a wrong
answer of ours against documented Metal (planner, L371 group C: first the truth, then the fix).

docs/CONFORMANCE-COVERAGE.md regenerated (scripts/conformance-coverage/coverage.py); --check
reports it as derived.

Verified: the 132 rows found by case and site from the KosmicKrisp replay's 22 lines (job
m3-max-82685's kept output) and rewritten by script, 22 a venue; the conformance suite runs on
this commit (job named in the hand-off).
2026-12-03 08:50:41 -08:00
Anees Iqbal b54d8d46bc Docs: the published crates' rustdoc states each measurement by its card and OS, not by our job id
What: every lab job id (m3-max-N) in a doc comment of the three
published crates' product sources is removed: 91 ids, and one list
written as a range and bare numbers, on 72 lines over 17 files. The
card, driver, OS and probe each sentence already names stay. Each
changed sentence is rewrapped at 100 columns from the id's line to its
paragraph's end. docs/REFUSALS.md is regenerated: its Basis column
carries those doc lines' evidence (14 rows).

Why: the planner's rule. Docs say the measurement (card, OS), not our
job numbers. The ids stay in the commit messages that already carry
them. A token comparison of each file against its parent shows only id
phrases removed: "(job m3-max-N)", ", job m3-max-N", "potluck job
m3-max-N", "(m3-max-N)" and id lists of the same forms. One line that
held only "(job m3-max-49358)." in submit.rs is folded into the line
above it.

Not changed here: the runtime README (217 lines with ids), docs/API.md
(20), docs/REPLAY-STREAM.md (2), docs/VALIDATION.md (1),
docs/CONFORMANCE-COVERAGE.md (1772, generated from the conformance
ledger), plain // comments (blit.rs 3, conformance cases 3, tests 5),
test modules' and unpublished crates' doc comments.

Verified: refusal_surface.py --check passes. basis.rs regenerates
unchanged. runtime-sources.sha256 is unchanged (44066e69...): none of
the files is its input. rustfmt --check passes on each file. Rustdoc,
private rustdoc and api-docs in the job the READY names.
2026-12-03 08:50:04 -08:00
Anees Iqbal ed75c57d5d Runtime docs: a heap texture in an imported block is Gap::HeapTexture with unified memory, an image of its own without
What: new_heap_texture's Err list, heap_source's, and Gap::HeapTexture's
own doc name imported blocks (Device::import_host_memory, and on Unix
the dma-buf imports) beside exported ones, by form. On a device with
unified memory a texture in an imported block is Gap::HeapTexture. On
one without it, an imported block is Shared, so its texture is an image
of its own, as in any Shared heap.

Why: heap_source makes a Shared block's texture an image of its own on
a device without unified memory before it tests whether the block's
memory is its own. An import is a Shared block with memory of its own
(memory.rs: Own::Import is MemoryClass::Shared). So since 71b5a07856 an
imported heap's texture is made on a discrete card and refused on an
integrated one. The docs named only exported blocks for
Gap::HeapTexture, which left the import case unsaid in both forms. The
consumer makes heaps over the host's memory.

Verified: docs only; job m3-max-84317, on the CPU with no device: fmt,
workspace rustdoc, the runtime's private rustdoc, scripts/api-docs and
refusal_surface.py --check, all EXIT=0. docs/REFUSALS.md and basis.rs
regenerate unchanged. runtime-sources.sha256 is unchanged (44066e69...):
texture.rs and error.rs are not its inputs.
2026-12-03 08:41:16 -08:00
Anees Iqbal bac1ab1bd9 Docs: metal-measured covers Metal's validation stop; the bound form's evidence is the real cards
What: the `metal-measured` basis (refusal_surface.py's vocabulary, and
`RefusalBasis::MetalMeasured`'s doc, which states it for the API) now
says that Metal's API validation stopping the call counts: documented
Metal then defines no answer to it, whatever plain Metal does without
the validation. docs/REFUSALS.md is regenerated with it.
docs/VALIDATION.md's device-test part gains one sentence: the bound form
of a compute function's buffer arguments has its evidence in the device
tests on real cards whose query takes it (each test's `M2V-FORM` line,
`tests::pool_reach`'s assertion of the form the query chose), and CI's
lavapipe legs take the address form, since lavapipe's
`maxStorageBufferRange` of 128 MiB is below the 2 GiB and 15 bytes the
query needs there.

Why: the definition said "Metal itself refuses the input", while
runtime refusals declare `metal-measured` on the strength of Metal's
validation layer stopping the call (in error.rs, among them
IndexedPatchDrawWithoutIndexType, PatchIndexBufferOffset,
ViewportNotFinite and StencilAttachment), and the
conformance allowances say a validation stop "is not Metal refusing it"
for their own verdict. The two answer different questions; the
definition now says which one the basis answers. The lavapipe sentence
records that CI's lavapipe legs never run the bound form, so a reader
of a green lavapipe leg does not take it as that form's evidence.

The numbers: job m3-max-84123 (lavapipe, release, three runs a
workload) printed `bound_dispatches_per_run` 0 for all 48 harness
workloads, and `address_dispatches_per_run` above 0 for the 43 that
dispatch. lavapipe's limits are those of the committed lavapipe
profiles (maxStorageBufferRange 134217728, minStorageBufferOffsetAlignment
16, so the query needs 2^31 + 15).

Verified: refusal_surface.py --check passes, and the regenerated
basis.rs is unchanged; runtime-sources.sha256 unchanged (error/mod.rs is
not an input: 44066e69...). Rustdoc in the docs job the READY names.
2026-12-03 08:41:16 -08:00
Anees Iqbal e498cbaa54 Translator tests: the integer heap slice's refusal is checked by its cause field
an_imageblock_slice_writes_an_argument_buffer_texture checked for the text "Imageblocks:
SliceWrite;", but a refusal that names its intrinsic prints it after the feature ("Imageblocks
(air.write_imageblock_slice_to_texture_2d.i16.v4i16): SliceWrite; needs NotImplemented"), so
the text check failed on a refusal whose cause was SliceWrite. The test now compares
Unsupported::cause with Cause::Imageblocks(ImageblockCause::SliceWrite).

Verified: job m3-max-84245 (CPU) printed the refusal above, cause SliceWrite, with the text check
failing; the field check's run follows.
2026-12-03 08:40:39 -08:00
Anees Iqbal 71a5393966 Translator: an imageblock refusal names its cause (ImageblockCause)
Feature::Imageblocks covered about ten structures with one untyped refusal, so a walk's counts
could not tell them apart. Each site now names the structure it met, in Unsupported::cause
(Cause::Imageblocks), as Cause::Access and Cause::Tessellation do:

- MultisampleOperation: the front end's undecoded multisample operations (get_imageblock_samples,
  get_imageblock_num_colors, get_color_coverage_mask, the masked implicit store), set where the
  front end's refusal converts;
- Stage: an explicit imageblock or an imageblock intrinsic outside a kernel or tile function, or
  an imageblock view outside a fragment function (param_family, use_imageblock);
- TwoImageblocks, DataSize, Layout: why the planner gives the kernel's explicit imageblock no
  region (more than one; no or zero data size; an alignment that is not a power of two, cells past
  4 GiB, or an unaliased explicit one beside the implicit one). The planner's imageblock() returns
  the cause and ArenaLayout keeps it (imageblock_refused) for use_imageblock to refuse with;
  Missing where the kernel declares no imageblock at all;
- DataOperands: air.imageblock_data operands other than (coord, 0, 0);
- ParameterValue: the imageblock parameter's value selected (access::select_param);
- CellPointer: an imageblock-space pointer that air.imageblock_data does not make, outside a tile
  function (the planner);
- FragmentData: a fragment function's [[imageblock_data]] input (fragment::select_param) or
  output (stage_io);
- SliceWrite: a slice write of a shape not modelled (texture::select, texture::slice).

Golden tables are unchanged (their outcome text names no cause). REFUSALS.md regenerated, the
signatures table blessed (ImageblockCause, Cause::Imageblocks), the api_surface list and
docs/API.md's Unsupported row name the new enum. SEMANTICS_VERSION 2354 (main renumbers at
landing): a refusal's text changes. runtime-sources.sha256 follows from the job.
Verified: pending (the red tests and the suites).
2026-12-03 08:40:39 -08:00
Anees Iqbal b0afeddc79 Translator tests: each imageblock refusal names its cause (red)
The planner's rule for a refusal kind of several causes: it carries a typed cause, by the
structure met, so a walk's counts tell them apart. Feature::Imageblocks covers about ten.

each_imageblock_refusal_names_its_cause reads the cause from the refusal's Display (the form the
consumer's counts line keys on): a kernel's explicit imageblock of data size 0 (DataSize), two
explicit imageblocks (TwoImageblocks), an air.imageblock_data index operand of 1 (DataOperands),
air.get_imageblock_samples (MultisampleOperation), and the owned fixture's fragment imageblock
entries (FragmentData). imageblocks_are_refused expects Missing (a query with no imageblock), and
the integer heap slice SliceWrite.

Expected red: no Imageblocks refusal names a cause yet.
2026-12-03 08:40:39 -08:00
Anees Iqbal b19bb1bd50 Runtime README: the Iris Xe's Shared heap texture stays in its heap
The known-gaps row of Shared heap textures gains the integrated card's line beside the RX 7900 XTX
and RTX 3090 lines: on a device with unified memory the form is unchanged, the texture placed in
its heap.

Verified: Iris Xe Graphics (Mesa 26.2.6) job m3-max-84238, the build before the form alternated
with this one: the shared-heap device test fails before (the two-copies view) and passes with it,
in both views; the texture-buffer heap test passes in both trees; sampling a 4096x4096
RGBA16Float texture took 24.697 and 28.540 ms in a Shared heap against 24.673 and 28.533 ms in a
Private heap (before, 31.107 and 24.650 against 31.164 and 24.671), each a median of 7 command
buffers.
2026-12-03 08:40:29 -08:00
Anees Iqbal 22335aaa56 Runtime README: a Shared heap's own image measured on the RX 7900 XTX and the RTX 3090
The known-gaps row of Shared heap textures gains the form's measured speed beside the earlier
system-memory row: the same 4096x4096 RGBA16Float sampling kernel, Shared heap against Private
heap, the build before the form alternated with this one in one job.

Verified: RX 7900 XTX (RADV, Mesa 26.2.6) job m3-max-84221: before 203.355 and 203.266 ms against
2.093 and 2.096 ms (97x); with it 2.107 and 2.104 against 2.108 and 2.106 ms. RTX 3090 (NVIDIA
620.70.06) job m3-max-84144: before Gap::HeapTexture; with it 1.907 and 1.913 against 1.912 and
1.912 ms. Each a median of 7 command buffers, two rounds.
2026-12-03 08:40:29 -08:00
Anees Iqbal 69033afcd4 rt: a Shared heap's texture on a device without unified memory is an image of its own
The L21 ruling, the third use of rule 2's unified-memory query (Vulkan's device type). On an
integrated or CPU device a Shared heap's image texture lies in its heap, as before. Elsewhere it is
an optimal image of its own in device memory, made as new_texture makes one but not zeroed (Metal's
heap textures are not), and its heap range is left unused. Before, a discrete device either
refused the placement (Gap::HeapTexture where its optimal images take no Shared type: the RTX 2080
and 3090 on NVIDIA 620.70.06) or bound the image in system memory, which every read crossed the
link for (97 times a Private heap's time on an RX 7900 XTX, job m3-max-79841).

How: heap_source decides by core.unified_memory() and the block's class. The own form checks the
placement against heap_texture_size_and_align's answers by the same rule the in-heap form uses
(heap_place, factored out of make: a heap range past its block, a texture past the heap's end, a
byte off the alignment are Refusal::HeapTexturePlace), then makes Source::HeapOwn: Bind::Pooled
(a place in a texture block or an allocation of its own, which spills as a texture's does), the
heap's hazard id kept, no alias Placement, and Under::Heap with at None, so use_heap still covers
it (heap_block) and blits see no shared span (bound). Texture buffers and textures over heap
buffers are untouched.

Docs: AGENTS.md rule 2's unified sentence gains the clause (the count stays fourteen); the
runtime README's heap text and known gaps (the device memory sum beside the heap's block, where it
runs out, and the earlier speed row); new_heap_texture(_for_views), heap_texture_size_and_align,
has_unified_memory and Gap::HeapTexture docs; docs/API.md and the conformance heap-size side's
step 2; docs/REFUSALS.md regenerated (HeapTexturePlace's site is heap_place).

RUNTIME_VERSION 2564 (renumbered at landing: development held 2563). runtime-sources.sha256 unchanged (guard PASS, m3-max-84127).
Verified: red FAIL / new PASS on the RTX 3090 (build m3-max-84138, run 84144), the RX 7900 XTX (84137, 84221; rt suite under m2v_gpu 993 passed, 4 skipped, 84222) and the Iris Xe (84227, 84238); CPU suites 84127 (conformance + rt 1279 passed, 2 skipped); clippy plain 84180, m2v_gpu 84172, m2v_cpu_icd 84181, rustdoc + api-docs 84182, all EXIT=0; states-only play on lavapipe 84256 equal to the base (gb-3090-r2 10643 render / 15299 compute, windrag-780m-b4-um790 8972 / 225, 0 refused). The consumer's arm64 guest walk on the RTX 3090 at pin S (m3-max-84046) asked for no texture on a Shared heap, so the evidence is the device tests and timing.
2026-12-03 08:40:29 -08:00
Anees Iqbal d35283294c rt test: a Shared heap's texture on a device without unified memory is an image of its own (red)
The L21 ruling: rule 2's unified-memory query picks the form of a Shared heap's image texture.
On an integrated or CPU device it lies in its heap, as today; elsewhere it is an optimal image of
its own in device memory, its heap range left unused. Today a discrete device either refuses the
placement (Gap::HeapTexture where the image does not take the Shared type, an RTX 2080) or
binds the image in system memory, which every read crosses the link for (97 times a Private
heap's time on an RX 7900 XTX).

every_device_samples_textures_placed_in_a_shared_heap now runs in both forms (the two-copy view
answers no unified memory). Without unified memory it expects each texture made whatever the
Shared-type query answers, in no alias placement and in the heap's use_heap block, the heap's
placement refusals at the size query's answers, and the source's texels kept after the host
writes 0xff over its heap range through a buffer placed there. In both forms: the size query
answers alike (what the consumer's heap accounting reads), and a linear texture over a buffer
placed in the Shared heap reads the host's bytes there. The heap texture-buffer test runs in both
forms too, unchanged.

Expected red: the two-copy run on an integrated device finds the image placed in the heap, and a
device whose image does not take the Shared type is refused Gap::HeapTexture.
2026-12-03 08:40:29 -08:00
Anees Iqbal f0a229f143 Translator: every handle web an instruction observes is spoiled, not only its last
What: Search::run's last loop (memory/provenance/words.rs) collects every
web whose integer an instruction reads otherwise than as a merge or a
sink, and spoils each one. It kept one Option that each operand
overwrote, so an instruction that read two webs (an icmp eq of two
joined handle words, or their sub) spoiled only the web of its last such
operand, and the other stayed a web: planned as handle indices while an
integer instruction read its words. The collection is one working
vector for the loop, grown through grow_working and charged to the
meter, as the loop above charges its operands.

Why: an analysis that marks a web usable while an integer instruction
reads its words is wrong where it stands. Today no output shows it: the
spoiled web "is no web, and stays refused" (lower/access/handle.rs), so
its handle use refuses the module whichever web was left planned. That
rests on a property nothing states, which the next refusal change could
remove.

Test: every_handle_web_an_instruction_observes_is_refused edits
sampler_word_select of the owned fixture kernel_handle_word_joins (as
the other refusal tests there do, so the fixture's AIR, which four
authored cases name by hash, is unchanged): a second web of the same
class beside the first, whose sampler samples too (its sink), then an
icmp eq of the two words either way round, their sub, and one web's word
compared with a raw resource ID. Each is refused: Lowering(Access) with
the cause HandleUse. A control compiles the same two webs with no
instruction observing them, so each refusal is the observation's and
both webs are webs. It guards that a module whose instruction observes
a web stays refused.

No SEMANTICS_VERSION bump: no module's output changes (the test is 8 of
8 with and without the fix). runtime-sources.sha256 unchanged
(pin-compute, 44066e69...).

Verified: job m3-max-84060 (msi): engine_handle_words 8 of 8 at the test
alone and 8 of 8 with the fix; clippy in the three configurations,
rustdoc and the suites as the lane's READY names.
2026-12-03 08:40:29 -08:00
Anees Iqbal e730fbddbb Runtime: AttachmentPlace's basis is Metal's own refusal, measured on the M3 Max
What: Refusal::AttachmentPlace's Basis line said `ours`. It now says
`metal-measured` and cites the committed probe resolve_depth_planes.m
(conformance crate, Apple M3 Max, macOS 27.0.1, job m3-max-73495). With
Metal's validation layer on, a resolve into slice 3 of a 2D texture ends
the process at the encoder ("Slice is 3, but the texture has only 1
slices"), and so does a resolve at depth plane 3 of one ("depth plane is
3, but the texture has a depth of 1 at mip level 0"). With the layer off,
plain Metal writes slice and plane 0 instead. A level past the texture's
was not run, and the line says that part is ours. docs/REFUSALS.md and
error/basis.rs are regenerated by scripts/refusal-surface/refusal_surface.py.
AttachmentPlace's basis() now answers MetalMeasured, and the Refusal
table's counts move one row from ours to metal-measured.

Why: the bug row said plain Metal (layer off) takes resolveSlice 3 into a
2D texture, and the planner's 11-25 ruling was that it needed a read
first, with rule 1 applying if Metal's layer refuses it. The read is the
probe above: the layer refuses it, so the refusal stands under rule 1,
and its basis now cites that evidence. Behaviour is unchanged.

Verified: refusal_surface.py --check exits 0 on this tree. The
runtime-sources fingerprint, recomputed from the tree, is unchanged
(44066e69): the runtime crate's sources are not inputs to it. No
signature changes, so api_signatures.tsv is untouched.
2026-12-03 08:40:29 -08:00
Anees Iqbal 16ab60e417 Runtime docs: the floor's public items, Limit and HOST_DOMAIN say they have no Metal counterpart
AGENTS.md asks every public runtime item's doc to name its Metal counterpart and what differs or is
refused. These public items named neither a counterpart nor its absence: floor::VERSION,
INSTANCE_EXTENSIONS, OPTIONAL_INSTANCE_EXTENSIONS, TIME_DOMAINS, MAINTENANCE8, BUFFER_USAGE,
IndirectCommandLimits, Features and Missing; Limit; and HOST_DOMAIN (its three cfg forms). Each is
Vulkan's side or the runtime's own, so each now opens "No Metal counterpart:", as the runtime's
other such items do (IndexClass, BlockId, DeviceExtension).

Found by the audit lane's read of the public runtime items' docs (392 pub items in non-test
sources; the rest name a Metal selector or type, or say they have no counterpart, on the item or
its type). Doc comments only: the API signature table and the runtime-sources pin do not move.
2026-12-03 08:40:28 -08:00
Anees Iqbal ce7d6a1c87 Runtime docs: shadows and their copies arise on every device for an in-place texture without the feedback usage
Metrics::attachment_read_copies and Gauges::shadows said they arise on a device without the
attachment feedback loop. A texture in place over a buffer, a surface plane among them, reads its
own pass's attachment through a shadow on every device where its linear image took no feedback
usage: Texture's making takes the loop from the plan's linear_loop for an image laid over a buffer
and from the device for one of its own (texture.rs, the looped match before Shadowing), and every
shadowed read's copies count in attachment_read_copies (render_encoder.rs, shadow_copies). The
runtime README's render encoder section already says so ("Through a copy, on a device without the
feedback loop, and for a surface plane or a texture in place over a buffer whose image took no
feedback usage"). The two fields' docs now say the same, so a reader of a nonzero count on a
device with the loop knows it is that case.

Found by the audit lane reading the counts the consumer folds. Doc comments only; the
runtime-sources pin does not move (counters.rs is not among its inputs).
2026-12-03 08:40:28 -08:00
Anees Iqbal 4a36a54747 Runtime README: the 780M's in-place frame at one draw is 536 us, its median of six
The host-memory texture row for the Radeon 780M (job m3-max-81673) read 696 against 537 us a
frame at one draw. The job's six alternating runs put the in-place arm's frame p50 at 529.3,
534.0, 536.1, 536.8, 537.9 and 542.9 us, a median of 536.45, so 536; the copy arm's median is
696.25, and the stated ratio 0.770 is 536.45 / 696.25, which stands. The four-draw pair (1025
against 793) and its 0.774 match the job.

Found by an audit of the docs' cited job numbers against the jobs' logs. Docs only.
2026-12-03 08:40:28 -08:00
Anees Iqbal 3142bd9ac6 Runtime: an over-copy of a kind the counters did not keep counts under its cause
Once the counters hold their 256 over-copy kinds, a copy of a new kind counted only in
Metrics::over_copies_unkept_kind, one number for every cause, so a consumer reading it (138 in
one arm of four of a walk on the Radeon 780M) could not say which cause's kinds went unnamed.
Such a copy now counts in its cause's field, over_copies_unkept_kind_<cause>, one for each of the
14 causes, named as the cause's pair is: host_memory, host_memory_restore, dma_buf, dma_bufs,
dedicated, surface, spilled, linear, linear_features, view_storage, pitch, render_reach,
alignment and image_memory. The aggregate stays and is now the causes' sum, read from the same
counters, so it cannot disagree with them. The kinds the counters keep, and their bound, are
unchanged.

The runtime README's over-copy paragraph names the fields. RUNTIME_VERSION 2563: what a run
records moves (the per-cause fields). The runtime-sources pin does not move (counters.rs is not
among its inputs).

Red: the_counters_name_each_copied_kind_once_up_to_their_bound, which the commit before this one
extended, read 0 for every cause against 2, 1 and 1; green with this.
2026-12-03 08:40:28 -08:00
Anees Iqbal 269e501b4f Runtime test: an unkept over-copy kind counts under its cause too (red)
Metrics::over_copies_unkept_kind counts the over-copies whose kind the counters did not keep,
the 256 kinds being full, as one number, so a reader cannot say which cause those copies had:
a consumer's walk on the Radeon 780M showed 138 of them in one arm of four, and nothing named
their cause.

This adds one field a cause, over_copies_unkept_kind_<cause>, beside the cause's pair
(over_copies_<cause> and over_copy_bytes_<cause>), and extends
the_counters_name_each_copied_kind_once_up_to_their_bound: filled past the bound with kinds of
the causes in turn, the three unkept kinds (dedicated twice, surface and spilled once each) must
count under their causes, and the causes must sum to the aggregate. The fields are read from
counters that nothing moves yet, so the test fails: every cause reads 0 against 2, 1 and 1.

The API signature table is blessed for the 14 fields. The runtime-sources pin does not move
(counters.rs is not among its inputs).
2026-12-03 08:40:28 -08:00
Anees Iqbal b531238180 Tables: pin U's golden hashes and authored compile census, blessed at c6a7995260
The golden table (bless job m3-max-84114, on the M3 Max) and the authored compile census
(m3-max-84121, census at c6a7995260: 2390 cases, 9 profiles, 0 failed, 161 differences, 0
regressions) at the pin's tip. Every moved cell is attributed to its commit.

Golden (blesses at each SEMANTICS step, cell by cell per profile):
- 180 cells, 12 rows x 15 profiles, from Unsupported{IdentityDomains; NotImplemented} to
  hashes: rfs_kernel_lod's lod_2d, lod_2d_array, lod_3d, lod_cube and lod_vertex, and
  sampling_completion's lod_query_kernel, in both fixture forms (.air.ll and .ll). All moved at
  c04212227d (red) and 5b3bd800c0 (a runtime sampler's LOD query outside a fragment function
  compiles under the identity domains).
- 60 cells in 4 new rows: coherent_texture_handoff and coherent_texture_handoff_seen in both
  forms, from the fixture commits 3994ea73dc, 5410866d9a and 18e8600cbb; all hashes.
- The semantics line, 2347 to 2353. No other cell moves.

Census (cold blesses at each step; T's committed table equals a cold bless at T, 0 changes):
- 36 cells, 4 cases x 9 profiles, from not_supported{unsupported:not_implemented
  IdentityDomains} to compiled at 5b3bd800c0, the same LOD query fix (m3-max-84197).
- 16 new cases from c5f979d985 and df54afeef2, the LOD clamp cases qualified on the M3 Max
  (m3-max-84198); 1 new case from 8e912a905d, coherent_texture_handoff.
- No compiled artifact's digest moves in the steps read so far; the remaining steps read after
  the push and are fixed forward.

States-only plays at T and at U are equal (m3-max-84116, 84117). Merge legs at c6a7995260:
m3-max-84110 (signatures, clippy plain, m2v_gpu and m2v_cpu_icd, rustdoc, translator suite 3459
passed 37 skipped, lavapipe rt 993 passed 4 skipped at its own width and at 128 bits,
validation 1349 passed 3 skipped, lavapipe validation 1477 passed 3 skipped, conformance build
and lavapipe conformance EXIT=0, all steps EXIT=0) and m3-max-84111 (copy form on the RTX 5080
Laptop, 41 passed).
2026-12-03 08:39:06 -08:00
Anees Iqbal c6a7995260 RUNTIME_VERSION 2562: a restoring make counts its waits in the metrics
The brief for this change asks for the bump at READY. A run of an unchanged artifact now adds to
six more Metrics fields (restoring_makes and the five after it) at each make of a texture in place
over host memory's import; its answers, refusals and submissions are unchanged. Main renumbers at
landing.
2026-12-03 07:47:39 -08:00
Anees Iqbal 4d88ded1c6 Runtime tests: restore_waits' make thread borrows the buffer alone
Over holds the import's host mapping, a NonNull that is not Sync, so the scoped thread could not
borrow the whole Over: the lib test did not compile (lavapipe build, job m3-max-84045). The thread
now borrows the buffer and the descriptor and sends back whether the texture is in place, as
restore_batch's does.
2026-12-03 07:47:34 -08:00
Anees Iqbal 66a1665f51 Runtime: a restoring make counts its two waits, and whether its restore rode shared uploads
The consumer's walk on the Iris Xe reads one long restore span a walk (57.3 and 57.9 ms at pin S),
in a HEIC step whose VA-API decodes write rt's exported blocks, and nothing in the runtime splits
a restoring make's wait, so the walk cannot say what the span waited for. A fenced make waits
twice: for the GPU work already submitted, before the fence's before, then for the progress value
its flush gave, inside the span. That second wait holds the batch that carries the restore (every
upload of any thread not yet submitted, and a group's copies into its textures' images), the GPU
work submitted ahead of it on the one queue and, where an upload of the batch uses memory another
API shares (an exported block's zero fill, a copy from one), the group's first part, since such
uploads signal no value of their own.

Metrics counts, with nothing run beside the work:
- restoring_makes, once each make's wait returned;
- restoring_make_drain_nanos, the fenced make's first wait;
- restoring_make_wait_nanos, the wait for the restore, and restoring_make_wait_submissions, the
  submissions the completion thread had not yet seen complete as it began (more than one: work
  submitted ahead of the restore's batch);
- restoring_makes_shared and restoring_make_shared_wait_nanos, the makes whose restore went ahead
  of a group's command buffers in uploads that use memory another API shares. Each restore's
  upload carries its make's flag (Keep::Restore's, through Restoring), which submit() sets before
  the vkQueueSubmit2 where it sends awaited uploads that share memory with no signal of their own;
  the make reads it once its wait returned.

The runtime README's fence paragraph names the fields. The signature table gains them.
2026-12-03 07:47:34 -08:00
Anees Iqbal 46ae50e00f Runtime tests: a restoring make's two waits and its shared uploads in the metrics
restore_waits.rs checks the six restore-wait fields the next commit counts, on every device of the
cfg's kind whose texture over host memory's import is in place:
- a make without a fence counts one restoring make, its restore wait and the submissions it
  waited for, and no drain;
- a fenced make counts its drain (the wait for the GPU work already submitted, before the fence's
  before) as well;
- neither counts among the shared makes;
- a make whose restore goes ahead of a group's command buffer with a new buffer's zero fill in an
  exported block (an upload that uses memory another API shares, which signals no value of its
  own) counts among the shared makes, its wait in theirs.

Metrics gains the six fields, read from atomics nothing adds to yet, so both tests fail here: the
red for the counting that follows.

Verified: red on the venues the next commit names (this commit's run is in its body).
2026-12-03 07:47:34 -08:00
Anees Iqbal 75e28a1ac5 API signatures: metal2vulkan-air's Global gains thread_local
Blessed with scripts/api-signatures/signatures.py --bless: one record added, the new field.
2026-12-03 07:47:10 -08:00
Anees Iqbal b63295b0bb Translator: the thread-local test's kernel reads its thread's index in its threadgroup
Its one threadgroup's index is the thread's grid position, which Metal's run read; the grid
position takes a push field of its own, which the test's interpreter run does not fill.
2026-12-03 07:47:10 -08:00
Anees Iqbal 0daff51641 Translator: a thread-local global of the thread address space is each thread's own, from its initializer
The AIR reader refused every thread-local global (ModuleRecord{code: 7}). Metal runs one of the
thread address space as an object each thread holds, starting at the initializer in every dispatch
and reached through the functions the thread calls (M3 Max, Metal toolchain 32023.922, macOS 27:
128 of 128 threads read the initializer, then their own 3t+1 after a barrier, in each of two
dispatches of one pipeline). That is SPIR-V's Private storage class with an initializer.

- metal2vulkan-air: Global gains thread_local; the reader reads it on a thread-space global and still
  refuses it on any other space (ModuleRecord{code: 7}), as it refuses comdats.
- metal2vulkan: the memory plan places a thread-local global as the typed Private form a closed
  constant global takes (ConstGlobalForm::Private), its writes its thread's own; one the typed form
  cannot hold is refused (GlobalVariable), as the constant blob is shared and read-only. Its
  thread-space pointers take that form, and a typed store into it is allowed where a constant's is
  ReadOnlyStore.
- SEMANTICS_VERSION 2352 -> 2353: modules with such a global now translate.

Verified: see the job lines in the lane's READY report (red at 364ad75207, green here).
2026-12-03 07:47:10 -08:00
Anees Iqbal 06c17330c9 Translator: a thread-local global of the thread address space is each thread's own, from its initializer (red)
Metal runs a module with `@g = internal thread_local unnamed_addr global i32 <init>` in the thread
address space: on an Apple M3 Max (Metal toolchain 32023.922, macOS 27) each of 128 threads read the
initializer first and, after storing 3t+1 and crossing a threadgroup barrier, read its own 3t+1 back
through a helper function, in each of two dispatches of one pipeline; the same global without
thread_local is refused at pipeline creation ("Undefined symbols: g"). The AIR reader refuses every
thread-local global (ModuleRecord{code: 7}).

Red: the reader test now expects a thread-space thread-local global to read and one of the
threadgroup space to stay refused; engine_thread_local expects the kernel to translate on every
committed profile and to leave Metal's words in the interpreter. Both fail at this commit.
2026-12-03 07:47:03 -08:00
Anees Iqbal cbd3c1f170 Conformance: stage-in-region-clamps recorded with its indexed rows at rates 2 and 3
Recorded on the M3 Max (macOS 27.0.1) by `conformance record
stage-in-region-clamps`, job m3-max-83929, RECORD EXIT=0: the three new
rows' sites (pipeline, buffers, region, dispatch, status, read-back) are
added, and the earlier rows' answers are unchanged (351 lines added, 1
changed). The recording's times half is carried as recorded.
2026-12-03 07:46:11 -08:00
Anees Iqbal 070fc2ab57 Conformance: stage-in-region-clamps gains indexed steps at rates 2 and 3
The case compared an indexed step at rate 1 only. The runtime now
fetches an indexed step at any rate, as an M3 Max read it in job
m3-max-68668, so the case now holds three rows of it:
- xi_rate2_o1_r3_g8: x at rate 2, a region of 3 from origin 1, so the
  last threads clamp
- xi_rate3_o2_r4_g12: x at rate 3, a region of 4 from origin 2, over
  12 threads
- yi_rate2_o1_r2_g2x8: y at rate 2, a region of 2 from origin 1

Unrecorded here: the M3 Max record job that follows writes the
recording in its own commit.
2026-12-03 07:46:11 -08:00
Anees Iqbal d1814ec396 Translator: SpecKey::StageInReach goes; every stage-in fetch keeps its reach check
What: the kernel stage-in fetch's specialization constant StageInReach,
its select over a thread-position step's reach check, its word estimate,
the runtime's arm that skipped it, and the codec's tag are deleted, with
tests/stage_in_element_bytes.rs, a doc-only module about the binder
that set the key and is gone. A thread-position step's reach check now
runs unconditionally, as an indexed step's already did.

Why: nothing set the key to false. The runtime kept it at its default
(true) for every dispatch (pipeline.rs, `SpecKey::StageInReach =>
continue`), so every module carried a constant and a select that always
chose the check. Consumer search: `git grep -n -w StageInReach
development -- '*.rs'` in the consumer's checkout at 40c2b1abeb has 0
hits.

Also: SEMANTICS_VERSION 2351 -> 2352 (a thread-position fetch's module
loses the constant and the select). ARTIFACT_FORMAT_VERSION unchanged:
the codec tags by name and the removed tag stays unused, which its doc
says needs no bump. The signature table blessed (one variant out);
docs/REFUSALS.md regenerates unchanged; runtime-sources.sha256
unchanged (pin-compute, a92fe0a8...).

Verified here: signatures.py --bless moved only that variant; no
StageInReach, reach_key or REACH_KEY_WORDS is left in crates/. Clippy,
rustdoc and the suites run in the jobs the lane's report names.
2026-12-03 07:46:11 -08:00
Anees Iqbal ad09d74961 Stage input: an indexed step fetches at any step rate, as Metal reads it
What: a kernel [[stage_in]] layout of an indexed step
(ThreadPositionInGridXIndexed or ...YIndexed) at a step rate past 1 is
now fetched: the thread's position on the axis divided by the rate,
clamped to the stage-in region's last element, looked up in the index
buffer, plus the region's origin. Step::Indexed carries its rate, and
the grid and indexed steps share stepped_position, the one division.

Why: an M3 Max read index[min(x / rate, size - 1)] plus the origin at
rates 2 and 3 (job m3-max-68668), so the refusal guarded a measured
answer. The runtime's Gap::StageIn of IndexedStepRate and the
translator's Feature::KernelStageIn refused it; both had no other site,
so both variants are deleted. Consumer search for the runtime variant:
`git grep -n -w IndexedStepRate development -- '*.rs'` in the consumer's
checkout at 40c2b1abeb has 6 hits, all in its refusal-label table and
the test that expects this refusal (rt_platform/diag.rs 8, 3079, 3088,
3094; rt_platform/compute.rs 1246, 1382), which change with this
answer; Feature::KernelStageIn has 0 hits there.

Also: SEMANTICS_VERSION 2350 -> 2351 (the modules of an indexed fetch
past rate 1, and a refusal gone). docs/REFUSALS.md regenerated
(refusal_surface.py) after reach.tsv lost the feature's row; the
signature table blessed (two variants out). The runtime README, the
encoder's and pipeline's docs and the gap's docs say the indexed
element at any rate. runtime-sources.sha256 unchanged (pin-compute,
a92fe0a8...).

Verified here: signatures.py --bless moved only the two variants; the
refusal surface regenerated with 0 variants unmarked. The red tests of
the commit before this one, and clippy, rustdoc and the suites, run in
the jobs the lane's report names.
2026-12-03 07:46:03 -08:00
Anees Iqbal 09eb927433 Stage input: an indexed step at rates 2 and 3 fetches Metal's element (red)
The runtime refuses a kernel [[stage_in]] layout of an indexed step at a
step rate past 1 (Gap::StageIn of IndexedStepRate), and the translator
refuses it as not implemented, though Metal's answer is measured: an M3
Max read index[min(x / rate, size - 1)] plus the region's origin at
rates 2 and 3 (job m3-max-68668).

The runtime's fetch test gains two indexed rows, at rate 2 under a region
of 3 (so threads past it clamp) and at rate 3 under a region of 8, and
its element rule divides the position by the rate before the clamp. The
unbuilt-forms test keeps DynamicStride and IndirectRegion. The
translator's refusal test expects rates 2 and 3 to compile, and the
every-profile validation and region tests take indexed rows past rate 1.

Red here: both runtime and translator tests meet the refusal. The fix
follows.
2026-12-03 07:45:48 -08:00
Anees Iqbal 1d92b18252 rt: a texture of the private bit BlockWritesOnly takes an index, as one shaders write does
usage_taken reads the bit as ShaderWrite, so reached, which decides
whether new_texture takes an index, holds for a texture of the bit alone
(0x10000): it takes an index, and one made without is
Refusal::TextureIndex. Metal's kernel write to such a texture lands
(block-writes-only-writes, recorded on an Apple M3 Max under macOS
27.0.1, job m3-max-83930). The conformance rt side gave the texture no
index, so the lavapipe replay refused it at creation (job m3-max-83976);
its texture_index now counts the bit as the runtime does. The docs of
reached, Refusal::TextureIndex and the runtime README say so;
docs/REFUSALS.md regenerates unchanged.

A consumer that decides a texture's index by its usage counts
TextureUsage::BLOCK_WRITES_ONLY as a shader write.
2026-12-03 07:45:41 -08:00
Anees Iqbal 6967f341b3 Conformance: block-writes-only-writes quotes Metal's validation message as code
Rustdoc read the message's t[1] as an intra-doc link and failed under
-D warnings (job m3-max-83944: unresolved link to 1). The message is now
a code span. Nothing else changes.
2026-12-03 07:45:41 -08:00
Anees Iqbal e97eb82941 Conformance: block-writes-only-writes carries its Metal timing
The suite's test every_case_carries_its_timing needs every case's
recording to hold a timing leg. This one's Metal leg, eight rounds, was
measured on an Apple M3 Max under macOS 27.0.1 (job m3-max-83967, with
conformance times --runs 8 --write). The recorded answers are unchanged.
The coverage table regenerates unchanged.
2026-12-03 07:45:41 -08:00
Anees Iqbal dbc0f04ef3 Conformance: block-writes-only-writes recorded on Metal
The case's Metal answer, recorded on an Apple M3 Max under macOS 27.0.1
(job m3-max-83930): for both usages, ShaderRead | RenderTarget |
BlockWritesOnly (0x10005) and the bit alone (0x10000), the dispatch
completes and every texel holds its four codes (00 ff 00 ff, 10 ef 25
fe, ...), with no notice announced. The coverage table is regenerated
with scripts/conformance-coverage/coverage.py.
2026-12-03 07:45:41 -08:00
Anees Iqbal eb049e248b Conformance: block-writes-only-writes, a kernel's write to a texture of the private bit BlockWritesOnly
The case writes buffer 0's float4s, each a code over 255, through the owned fixture
fpv_srgb_storage's fpv_srgb_write (an access::write slot) into a 16 x 1 Shared RGBA8Unorm texture
of usage ShaderRead | RenderTarget | BlockWritesOnly (0x10005, the guest's) and of the bit alone
(0x10000). It records each dispatch's status and the stored bytes.

The public MTLTexture.h of macOS 27.0.1 does not define the bit. On the M3 Max under macOS
27.0.1 (job m3-max-83917), a write to 0x10005 lands and Metal's validation passes it. The
recording is taken by the next commit's job.
2026-12-03 07:45:40 -08:00
Anees Iqbal fd07d85922 rt: a texture of the private usage bit BlockWritesOnly takes a kernel's write, as ShaderWrite does
usage_taken, the one place a descriptor's usage is read as Metal takes it, now reads the private
bit BlockWritesOnly (0x10000) as also ShaderWrite. That feeds the slot check
(Refusal::TextureUsageAtSlot), the image plan (the storage element, its view formats and the 8-bit
sRGB write twin), texture buffers, and the storage-element gap's test of a written texture.

Why: the public MTLTexture.h of macOS 27.0.1 does not define the bit. Its writes were measured
on an Apple M3 Max under macOS 27.0.1, job m3-max-83917. A kernel's access::write to an
RGBA8Unorm texture of ShaderRead | RenderTarget | BlockWritesOnly (0x10005) lands, Shared and
Private, plain and under MTL_DEBUG_LAYER=1 with no assertion. A texture of 0x5 asserts there
("writes texture (t[1]) whose usage (0x05) doesn't specify MTLTextureUsageShaderWrite (0x02)"),
and 0x7 is silent. The runtime refused the dispatch, and planned no storage element for such a
texture, so the write would have been dropped. An arm64 guest walk met the refusal 8,662 times,
at one kernel's slot 1 for 8,624 of them. The translator's heap binder already takes the bit so
(bind/heap.rs), so both crates now read it one way.

RUNTIME_VERSION 2561: a run may answer differently (a dispatch that was refused now runs).
docs/REFUSALS.md regenerates unchanged (its table carries the refusal's first line alone). The runtime-sources fingerprint does not move
(pin-compute.py: a92fe0a8... before and after); the runtime crate's sources are not among its
inputs. The runtime README's texture slot paragraph says the same.

Verified by the red test of the commit before: on lavapipe (llvmpipe, LLVM 23.1.1), job
m3-max-83922 at that commit fails it with Some(TextureUsageAtSlot) for the new row; the green run
is named in the lane's report.
2026-12-03 07:45:40 -08:00
Anees Iqbal 257c4a4f26 Tests: a kernel's write to a texture of ShaderRead | RenderTarget | BlockWritesOnly runs (red)
slot_usage's sample_down gains a destination of usage 0x10005: ShaderRead, RenderTarget and
Apple's private bit 0x10000, which the public MTLTexture.h of macOS 27.0.1 does not define. On an
Apple M3 Max under macOS 27.0.1 (job m3-max-83917), a kernel's access::write slot 1 bound to an
RGBA8Unorm texture of that usage takes the write, Shared and Private, plain and under
MTL_DEBUG_LAYER=1 with no assertion, where usage 0x5 asserts "writes texture (t[1]) whose usage
(0x05) doesn't specify MTLTextureUsageShaderWrite (0x02)" and 0x7 is silent.

The runtime refuses the dispatch today (Refusal::TextureUsageAtSlot): it reads only ShaderWrite as
granting a write, and plans no storage element without it. A guest walk on an arm64 guest met the
refusal 8,662 times, at one kernel's slot 1 for most of them.

Red: expected to fail on every device until the usage is read as granting the write.
2026-12-03 07:45:40 -08:00
Anees Iqbal 2f93c0bd04 Harness: a workload's line names its buffers' and textures' storage modes
Before a plan workload's rows, the harness now prints one line naming each of its buffers'
storage mode and length and each of its textures' storage mode, in its plan's order, for authored
and described workloads alike:

    burst_160_shared  storage: buffer 0 private 1024 bytes, buffer 1 shared 16 bytes

On a discrete card a kernel's reads of a Shared buffer cross the bus at every dispatch (the
runtime README's known gaps of memory blocks: 75 against 2.4 us a dispatch for 512 KiB on the
RX 7900 XTX), so a row's time cannot be read without knowing where its data lives.

No committed kernel workload gains a Private arm, because each one's bulk data is already
Private, as a real app would keep it: bandwidth, alu, long_4cb, threadgroup_scan, simd_reduce's
input and partials, image_filter, row_cells, dispatch_chain, wide_bindings, waves, vote_loop,
narrow_ints, zero_products, texture_read, the sampling rows, the texel buffer rows,
constant_private and the draws. The Shared buffers that remain are the ones an app keeps Shared,
or already have a Private twin:
- simd_reduce's buffer 2, the 16-byte total the CPU reads back;
- burst_160_shared's 16-byte increment, a constant argument the CPU writes, kept for the record
  beside burst_160's Managed one, as the recordings bind such arguments from Shared memory;
- row_tail_224, row_tail_27730 and row_tail_49, whose outputs are Shared, each already beside
  its _private twin.
The kernel behind the known gap was a described workload of the audit's own, never in the tree.

A test in the command's own tests checks the line for burst_160_shared, burst_160 and draw_2000.
2026-12-03 07:39:50 -08:00
Anees Iqbal e42f5e9c41 Runtime README: on a discrete card a kernel's reads of a Shared buffer cross the bus, a known gap
On the RX 7900 XTX (RADV, Mesa 26.2.6) the Shared type, the first host-visible, host-cached
type a buffer can use, lies in the host's 14.58 GiB heap, so every dispatch's reads of a Shared
buffer cross the bus. A half-precision sum reduction reading 512 KiB of a Shared buffer took
7,475 us a run of 100 dispatches, 75 us a dispatch, against 236 us a run, 2.4 us a dispatch, with
the same buffer Private, alternated three times at the card's full shader clock (about 3.07 GHz
in both arms, sampled every 20 ms; job m3-max-84013).

Ruled a recorded known gap (rung 4) rather than a second Shared type: Shared is the memory the
program's CPU reads and writes directly, and the card's device-local, host-visible types are not
host-cached, so each CPU read of a Shared buffer there would be an uncached read, which costs
more and comes more often than a kernel's reads over the bus. Metal's Shared is one memory the
CPU and the device both use (MTLResource.h), on a discrete Mac too, where a program that wants
the card's read speed keeps its data Private or Managed.

Docs only. The memory types and heaps are the job's vulkaninfo on that card.
2026-12-03 07:39:50 -08:00
Anees Iqbal 62e9d045c3 Validation player: command-replay refuses an option a subcommand does not take
Each subcommand names the options it takes beside its required ones, and
options() refuses any other with "--NAME is not an option of
SUBCOMMAND" before anything runs: exit status 2, the usage printed, as
for any bad command line. Before, an unknown --name VALUE pair went into
the map and was never read, so a mistyped or retired option played as
if absent.

The sets are what each subcommand reads: play its four required options
and blobs, managed, until-frame, past-range, states-only, state-log,
state-threads, state-keys, state-digests, gpu-wait-timeout (the
wait module's flag), video-handle, check-presents, read-device-copies,
prepass-width, dump-command-buffers and dump-dir; dump and shapes
--stream and --blobs (their stream reader reads it; the usage and the
module doc now show it); compare-dumps --a and --b; compare-plays --a,
--b and --frame; snippet video-surfaces --out and --handle. The module
doc and docs/REPLAY-STREAM.md section 10 say so.

The audit in the red commit's message found no caller passing an option
outside these sets except --probe-dump in two lab probe scripts of one
carry, which no commit here ever read.

Verified by the job named in the lane's report: the red test at the
parent and green here, clippy x3, rustdoc, the validation suite.
2026-12-03 07:28:55 -08:00
Anees Iqbal 34d0a859ee Validation test: every command-replay subcommand refuses an option it does not take (red)
command-replay's options() takes any --name VALUE pair into its map, and
each subcommand reads only the names it knows, so an option a subcommand
does not take is dropped in silence: `play --name run` plays as if no
--name were given. A mistyped or retired option should be a bad command
line instead.

replay_options::every_subcommand_refuses_an_option_it_does_not_take runs
play (--name), dump (--frame), shapes (--until-frame), snippet
video-surfaces (--stream) and compare-plays (--until-frame), each with
its required options plus one it does not take, and expects exit status
2, a standard error line "--X is not an option of SUBCOMMAND", no play
report and no snippet written.

Red here: play runs on (its report is written), and dump, shapes and the
snippet run to exit 0. The fix follows.

Callers audited before refusing (development 6a7b159d95): the in-tree
tests and docs, sched/round.py and every orchestration job script that
names command-replay (54 files), the scripts in every carry repository
(136, 35 that play), and the consumer's tree (development fdc1ecbbb5: no
caller). Every option they pass is one the subcommand takes, except
--probe-dump in two 11-27 probe scripts of one lab carry (probe-424.sh,
probe-reduce.sh), an option no commit of this repository ever had: it
was dropped in silence there, and would now stop those scripts with exit
status 2.
2026-12-03 07:28:55 -08:00
Anees Iqbal 3d191a2d66 Validation tests: the two callers 98435ae812 missed pass compute_case the entry's interface
98435ae812 gave compute_case the checked entry's AirInterface as a
second argument but left two test callers on one, so the validation
crate's lib tests and integration tests did not compile (job
m3-max-83945: E0061 at case/tests/indirect_commands.rs:107 and
tests/integration/engine_linked_cases.rs:123; clippy in all three
configurations and the validation suite failed on it).

- indirect_commands' assert_engine_refuses: the refusal comes before
  compute_case reads the interface, so a synthetic kernel interface of
  no parameters stands in.
- engine_linked_cases: the admitted case's own interface,
  checked.primary.interface.

Verified by the job that follows (clippy x3, rustdoc, the validation
suite). The same job's case runs on lavapipe at 98435ae812 (the bins
built) matched 7 of the 8 authored stage-input cases whose AIR is here;
the eighth is private.
2026-12-03 07:26:59 -08:00
Anees Iqbal 98435ae812 Validation: the engine candidate runs a kernel case's stage inputs through the runtime
What: a kernel case's stage inputs of a fixed stride, and its dispatch's
stage-in region, now run on the engine candidate as the Metal oracle runs
them (executor_contract::stage_inputs, the derivation both executors
share):
- compute_case takes the checked entry's AIR-layer interface and maps
  each input's data to its own buffer at the slot its location takes;
- ComputeCase carries the stage-input descriptor, the region (the
  dispatch's, or the grid's from the origin) and each slot's location;
- the run through the runtime makes its state with that descriptor, sets
  the region before the dispatch, and guards a stage input's data as its
  OutOfBoundsResource::AttributeBuffer target (guards::buffer_resource);
- the authored compile census compiles the kernel under it
  (PipelineRequest::Kernel::stage_input, variants::compile_kernel).

ToolingRequirement::KernelStageInput ("kernel_stage_input") becomes
DynamicStageInStride ("dynamic_stage_in_stride"): it now fires only for
an input of a dynamic stride. The runtime refuses that layout (Gap::StageIn
of DynamicStride), since its compute encoder has no
setBuffer:offset:attributeStride:atIndex:. Docs say the same:
docs/VALIDATION.md, the requirement's, case_requirements' and
compute_case's. A neighbouring line now says the implicit imageblock is
the runtime's limit, where it said explicit; the code already said so.

Why: the runtime has fetched stage inputs at every step function since
a916e61185 and sets the region (set_stage_in_region), but the candidate
built its state without the descriptor and set no region. So twelve
authored cases stayed Metal-only, the twelve the authored compile census
holds as not_supported{tooling_requirement:kernel_stage_input}.

Also: AUTHORED_COMPILE_CENSUS_VERSION 9 -> 10. Its table is re-blessed
on development. ENGINE_EXECUTOR_ABI unchanged: every case this lets run
was refused before, which its doc says needs no bump.

Verified here: cargo fmt; signatures --check. Tests:
engine_case_families_follow_the_case_literals (red at the commit
before) and stage_inputs_map_onto_their_slots_descriptor_and_region.
Clippy, rustdoc, the validation suite and the cases' runs on a device go
in the jobs the lane's report names.
2026-12-03 07:26:52 -08:00
Anees Iqbal 3015b115dd Validation: a kernel case's stage inputs and stage-in region stop no executor but a dynamic stride (red)
A kernel case with stage inputs, or a dispatch with a stage-in region,
carries ToolingRequirement::KernelStageInput, which stops the engine
candidate: its run through the runtime makes its pipeline state without
the case's stage-input descriptor and sets no region. The runtime fetches
stage inputs at every step function since a916e61185 and sets the region
(set_stage_in_region); it refuses only a layout of a dynamic stride
(Gap::StageIn of DynamicStride), as its compute encoder has no
setBuffer:offset:attributeStride:atIndex:.

engine_case_families_follow_the_case_literals now expects no requirement
for stage inputs of a fixed stride, with or without a region, and the
requirement for a dynamic one. Red here: both fixed-stride cases still
carry KernelStageInput. The candidate's run, the requirement's narrowing
and the doc follow.
2026-12-03 07:26:52 -08:00
Anees Iqbal 23193c9bf1 Translator: the padded forms' linear mip filter blends two levels, a bfloat form's reads one
Two measured changes to an extended-range sample's level, each from the M3 Max on macOS 27.0.1:

- A padded form's linear mip filter (R10Unorm_X6, RG10Unorm_X12 and their _sRGB twins) now
  blends its two levels as BGR10_XR's and BGRA10_XR's do, through a constexpr sampler and through
  a runtime one, and records PrecisionNote::BicubicFilterArithmetic. Before, a constexpr sampler's
  was refused NotImplemented(Format), and a runtime sampler's read one level with no refusal. The
  probe extended_linear_mip_blends (job m3-max-82967; 16,384 lanes per form and filter, 2D, five
  levels, random codes) puts Metal's sample within 0.0157 of its own two levels' samples blended
  by mix at the fraction truncated onto sixty-fourths. The note's doc and its docs/API.md
  catalogue line gain that bound.
- A bfloat form's linear mip filter (R16Bfloat, RG16Bfloat, RGBA16Bfloat) is now its nearest mip
  filter, which Metal's equals on every lane whose two levels differ (4,096, 8,192 and 16,384
  lanes, nearest and linear filters). Before, a constexpr sampler's was refused. A runtime
  sampler's already read that level.

What stays refused through a constexpr sampler:
- A two-plane form's linear mip filter (not measured). The probe only shows that a five-level
  texture is made.
- RGB10A2Unorm_sRGB's linear mip filter (not measured). Jobs m3-max-83026 and m3-max-83029
  explain why. A texture of five levels holds each level's own code, which a blit reads back per
  level. Yet the M3 samples level 0's code at every explicit level, at gradients under a nearest
  mip filter, at every level under a linear one, and in a 2D array's layer 1. RGB10A2Unorm, the
  control, samples each level's code. Documented Metal samples the level asked for. So this is a
  driver defect, which is not emulated (an Apple bug report is drafted), and the format's samples
  keep reading the level the mip filter names. No conformance case samples that format's levels
  today.

Docs: three comments named binder refusals that no code makes, and none of the three exists
(ResourcePlanner is gone):
- a runtime sampler word that states mixed filters;
- a runtime linear mip filter's clamp maximum below the last level;
- a runtime linear mip filter of an unmeasured form.
The comments sat in lower/sampler/extended.rs, select.rs and the extended-range tests'
module docs. They now state what happens: the word samples as nearest, the maximum is not read,
and a two-plane form's or RGB10A2Unorm_sRGB's runtime linear mip filter reads the nearest mip
filter's level. They also say this is an open gap that no consumer meets while the runtime makes
no texture of these formats (the runtime's Gap::TextureFormat).

The probe crates/metal2vulkan-conformance/probes/extended_linear_mip_blends.m gains the nearest
mip filter at the point's level, the two-plane question and each texture's level count.
SEMANTICS_VERSION moves to the next number, because refusals are removed and samples' answers
change. runtime-sources.sha256 is re-pinned because metal/format/mod.rs is a runtime input.

Tests (tests/engine_extended_range/levels.rs):
- unmeasured_linear_mip_filters_are_refused now builds a padded and a bfloat linear mip filter,
  and still refuses a two-plane and an RGB10A2Unorm_sRGB one.
- measured_linear_mip_filters_blend_or_read_one_level: every padded and bfloat form's constexpr
  sampler compiles, valid, under either mip filter, with the note on a padded linear one alone.
  On the CPU interpreter, at 64 levels between two, through a constexpr and a runtime sampler, a
  padded form's sample lies between its two levels' nearest-mip samples on every lane and
  strictly between on some. A bfloat form's equals its nearest mip filter's, bit for bit.

Verified on the CPU with no device (job m3-max-83908): with metal/format/mod.rs,
lower/sampler/extended.rs and select.rs at 8e912a905d the two changed level tests fail, and here
the extended-range tests pass; the golden table differs from development's (semantics 2346) in 90
cells here and at 8e912a905d, so the change moves no existing cell by count; the refusal surface
check passes; cargo fmt, clippy (plain, --cfg m2v_gpu, --cfg m2v_cpu_icd), Rustdoc, the API
reference check and the doctests pass; the suites pass 3753 of 3754 (24 skipped), the one failure
golden_hashes_match_the_table, bless due as at 8e912a905d; the validation suite passes 1346 (3
skipped) and the conformance suite 1052. The states-only plays of this tree (m3-max-83910) make
what 8e912a905d's make (m3-max-83909): the gb-3090-r2 stream 10643 render and 15299 compute
states, the 780M windrag stream 8972 and 225, none refused.
2026-12-03 07:25:45 -08:00
charlysound ef6a42c895 Refresh complete golden hashes with genuine Apple tools
Regenerate and verify all 3660 rows across 15 profiles on hosted macOS for semantics 2347. Source: 14536cadaa. Evidence: https://github.com/charlysound/metal2vulkan/actions/runs/47133887425. The full Linux software suite passes the identified software cases before this test-only table refresh; twelve CPU mesh cases, all Clippy configurations, device-gated compilation and Rustdoc pass.
2026-12-03 16:24:40 +01:00
Anees Iqbal 2c29742e2d Runtime README: a Mac's resolve writes the band past Metal's render area, as ours
The known gaps of render encoders said what a Mac's resolve writes into
the resolve texture past Metal's render area was unmeasured. The probe
resolve_band_past_render_area measured it on the M3 Max (job
m3-max-83924, with and without the debug layer, every command buffer
completed): a Load pass of a 300 by 300 render area that encodes no
draw, over a 600 by 600 4-sample attachment, resolved its area and the
band to 320 texels a side (90,000 and 12,400 texels changed) and left
the 257,600 texels past them untouched. The runtime's Vulkan render area
is Metal's rounded up to 32 texels a side, so it resolves the same band.
Under Clear the same pass resolved the clear value into the whole 600 by
600 texture, which the README's whole-level clear of a pass that draws
nothing already records as a known gap; the entry now says the resolve
follows it. The probe's header records the rows.

Doc and probe only: no Rust source changes.
2026-12-03 07:22:46 -08:00
Anees Iqbal 430a2a8241 Conformance probe: whether Metal's resolve writes past the pass's render area
The runtime's Vulkan render area is Metal's rounded up to 32 texels a
side, so a 300x300 pass resolves 320x320. What a Mac's
MultisampleResolve writes into the resolve texture past Metal's area is
not measured (the runtime README's known gaps say so). This probe
resolves a 600x600 4-sample attachment into a resolve texture first set
to 0xee bytes, with a render area of 300x300 under Load and under Clear,
and without one as the control, and counts the texels that changed in
the area, in the band to 320 and past it.

Not run yet: the M3 Max job that runs it follows, and its rows go in
the README with the run named.
2026-12-03 07:22:46 -08:00
Anees Iqbal 2201f23e9f linux-gate-ci: the 128-bit runtime step checks the width took, as ci.yml's does
cpu_icd_tests_128 ran the runtime's tests with LP_NATIVE_VECTOR_WIDTH=128 but never showed that
llvmpipe took the width, so a green run proved nothing about 128 bits. It now runs ci.yml's check
first, with the same greps: vulkaninfo at that width, its deviceName and subgroup-size lines printed,
and the step fails unless the device name says 128 bits and maxSubgroupSize is 4. It also takes
ci.yml's --no-fail-fast, keeping the function in step with ci.yml's run text as the file's header asks.

Verified: bash -n; and the step end to end on a host lavapipe, not in the gate's container: job
m3-max-83977 defined step() and cpu_icd_tests_128 from this file and called the step on Mesa 26.2.4
lavapipe (LLVM 23.1.1). The device line read 'llvmpipe (LLVM 23.1.1, 128 bits)' with
maxSubgroupSize 4; Summary 991 tests run: 991 passed, 4 skipped; step ok. The container run is
unverified, and METAL2VULKAN_TEST_REQUIRE_PINNED_LLVM, which the script exports at its top, was not
set (the host's LLVM is not the pin).
2026-12-03 07:20:32 -08:00
Anees Iqbal 4b68322b79 Conformance ledger: the Iris Xe's rgb10a2unorm texture-buffer write matches Metal now
What: drops the known-gaps-rt.tsv row norm-storage-codes-rgb10a2unorm | Iris(R) Xe | divergent |
case/hsw_buffer/texels, and regenerates docs/CONFORMANCE-COVERAGE.md from it.

Why: pin S's real-card round replayed the ledger on the Iris Xe (RPL-P, Mesa 26.2.6) and reported
"now matches: 1": that case no longer diverges there, and the ledger must not outlive the gap it
stands for. Pin R's round passed the same leg (job m3-max-83399), so the change came between R and
S: there a read-write texture buffer whose format's own view reads none without a format became
words (1c68dd10f4), and a texture-buffer storage slot is declared without a format (1ae0e3c302), so
the Iris's RGB10A2Unorm texture buffer is written through the shader's own conversion, which gives
Metal's codes. The other Iris rows of the case (hsw_read_write, hsw_write, hsw_held) still diverge
there, and llvmpipe's and NVIDIA's rows are unchanged.

Verified: the conformance replay on the Iris Xe at 14c37cc76d (job m3-max-83990) listed this row as
its only surprise; coverage.py --check reads the document as derived. The replay after this commit
runs in the next pin's round.
2026-12-03 07:19:29 -08:00
Anees Iqbal 6a7b159d95 Runtime README: no kept replay stream reaches a fetching draw as translated
The fetch known gap (UnorderedFetchWithinDraw: overlapping read-modify-writes of one draw may
leave one application) now says whether real work meets it. In every one of the 26 replay
streams counted, each colour input ([[color(n)]]) a fragment function declares is gated by a
function constant that the stream's pipeline states set off, so no state fetches.

Counted states-only on lavapipe, with a fresh shader cache per stream, every MODE line "mode
states-only". Probe on a never-landed branch:
- For each render state made, the runtime's own Draws::fetched (empty for all) and its notes (no
  UnorderedFetchWithinDraw).
- The validation checker's evaluation of each colour input's predicate under the state's
  constants (AirInterface::new): 0 live, 0 unevaluated, and 0 states whose input is live while
  fetched is empty.

| Stream | Render states | Fetching | Declaring a colour input, all gated off | Job |
|---|---|---|---|---|
| windrag-780m-b2 | 8262 | 0 | 6313 | m3-max-83458 |
| windrag-780m-b4-um790 | 8972 | 0 | 6957 | m3-max-83458 |
| webdiv-780m-2 | 9014 | 0 | 6977 | m3-max-83458 |
| webdiv-780m-3 | 9645 | 0 | 7424 | m3-max-83458 |
| gb-3090-r2 | 10643 | 0 | 8177 | m3-max-83458 |
| glbench-3090-r4 | 9834 | 0 | 7492 | m3-max-83494 |
| bB-c1 | 494 | 0 | 392 | m3-max-83494 |
| boot-idle-780m-1 | 6817 | 0 | 5172 | m3-max-83494 |
| gb-3090-r3 | 10040 | 0 | 7752 | m3-max-83494 |
| gb-780m-u2 | 9038 | 0 | 6923 | m3-max-83494 |
| gb-780m-u3 | 8269 | 0 | 6339 | m3-max-83494 |
| gb-780m-u4 | 5850 | 0 | 4487 | m3-max-83494 |
| glbench-780m-r1 | 7435 | 0 | 5566 | m3-max-83494 |
| glbench-780m-r2 | 8538 | 0 | 6437 | m3-max-83494 |
| syncview-4k-780m | 1952 | 0 | 1585 | m3-max-83695 |
| windrag-780m-b4 | 8154 | 0 | 6252 | m3-max-83889 |
| windrag-780m-b3 | 8082 | 0 | 6256 | m3-max-83889 |
| web3d-780m-r1 | 8587 | 0 | 6593 | m3-max-83889 |
| web3d-780m-r2 | 8438 | 0 | 6478 | m3-max-83889 |
| web3d-780m-esc1 | 7253 | 0 | 5538 | m3-max-83889 |
| rtdesk-780m-rtrec1 | 7584 | 0 | 5850 | m3-max-83889 |
| rtdesk-780m-rtrec3 | 7636 | 0 | 5888 | m3-max-83889 |
| rtdesk-780m-rtrec4 | 10118 | 0 | 7784 | m3-max-83889 |
| vaapi-780m | 8604 | 0 | 6591 | m3-max-83889 |
| vaapi-780m-wd | 8403 | 0 | 6466 | m3-max-83889 |
| glbench-780m-r4-recnil | 3756 | 0 | 2669 | m3-max-83954 |

One windrag-780m-b2 function shows the gate (job m3-max-83522):
- It declares 3 used colour inputs and 60 function constants, and its state supplies all 60.
- Each input's predicate is a global computed from the constants.
- The gate opens only with constant index 4 set to 1 together with one of indices 0, 35, 55 or
  56; the state gives index 4 the value 0.

The runtime translates under the identity domains, so a surviving fetch would be
PushField::FetchedColor, which fills Draws::fetched.

Values plays on one Radeon 780M (RADV) agree with this:
- glbench-780m-r2 (job m3-max-83322) and windrag-780m-b4-um790 (job m3-max-83381).
- In each, development twice (A, A2) and a build that splits every fetching draw per primitive
  (B): 0 draws split, and every compared frame equal.

Docs only: the runtime README is not a runtime-sources input.
2026-12-03 07:12:10 -08:00
Anees Iqbal 2549c339c6 CI: the runtime's device tests again on lavapipe at 128-bit vectors, with a Mesa shader cache of their own
What: a Linux step after the CPU ICD step runs the runtime's device tests from that step's archive
with LP_NATIVE_VECTOR_WIDTH=128 (lavapipe's subgroups of 4, the width arm64 lavapipe runs at) and
MESA_SHADER_CACHE_DIR set to a directory of the leg's own in the workspace. It prints vulkaninfo's
device name and subgroup sizes first and fails unless they show 128 bits and subgroups of 4, so a
green step shows the width ran. scripts/lavapipe-image's nextest command takes --write and --env as
run does, so the leg's cache directory and variables reach the container. scripts/linux-gate-ci
gets the same step, as docs/VALIDATION.md asks of every Linux step. AGENTS.md's CI line and
VALIDATION.md's note on the width name the leg and the cache rule. Nothing in product code reads
either variable.

Why: the planner wants a stand-in for a device whose SIMD group is 4 wide (tile GPUs are a target).
The lab's 128-bit runs failed because of llvmpipe's disk cache, not our lowering. llvmpipe keys its
texture functions (lp_texture_handle.c) and its cache id (lp_screen.c) without
lp_native_vector_width (Mesa 26.2.4), so a cache that 256-bit runs filled gave a 128-bit shader an
8-wide texture function. A cache of the leg's own cannot collide with the 256-bit one.

Verified on lavapipe (Mesa 26.2.4, LLVM 23.1.1, 128 bits, subgroups 4), at aeb0ca9560, the
runtime's whole cpu_icd suite:
- shared default cache: 989 tests run: 887 passed, 102 failed, 4 skipped (job m3-max-83853);
- the cache off: 989 tests run: 989 passed (2 slow), 4 skipped (job m3-max-83888);
- gdb on two of the crashes stops at the same JIT store, vmovaps of a ymm register, the 4th of
  four plus a byte at 0x80: an 8-wide texel struct written into a 4-wide caller (job m3-max-83878).
The step itself ran in the lab from ci.yml's step text, in the pinned lavapipe image (Mesa
26.2.4-arch1.1, LLVM 23.1.1): deviceName = llvmpipe (LLVM 23.1.1, 128 bits), subgroupSize 4 (min
and max 4); 764 runtime device tests listed; Summary 762 tests run: 762 passed, 231 skipped; job
exit 0 (job m3-max-83928, on the RTX 5080 Laptop machine's lavapipe). scripts/linux-gate-ci's
new step passed bash -n only; it has not run end to end. No Rust changed, so clippy, Rustdoc and
the suites have the inputs they had.
2026-12-03 07:03:08 -08:00
charlysound 14536cadaa Merge master pin T into native mesh runtime
Preserve texture view-storage fixes, ZeroAddress placement and handle-word joins alongside native mesh stages. Advance cache versions to semantics 2347, artifact 608 and runtime 2561. The runtime input fingerprint is unchanged; runtime crate changes remain versioned independently. Complete golden regeneration and combined-source validation follow on this exact merge.
2026-12-03 16:02:26 +01:00
charlysound 7e6efdaffa Refresh complete golden hashes with genuine Apple tools
Regenerate and verify all 3652 rows across 15 profiles on hosted macOS for semantics 2343. Source: 2c297ad7bf. Evidence: https://github.com/charlysound/metal2vulkan/actions/runs/47127204415. The full Linux software suite passes 6141 cases before this test-only table refresh; twelve CPU mesh cases, all Clippy configurations, device-gated compilation and Rustdoc pass.
2026-12-03 15:58:32 +01:00
Anees Iqbal b9f3210e24 Translator docs: the instance count and object arena paragraphs name no stage table
lower/raytracing/mod.rs and pipeline/facts.rs still named
StageTable::acceleration_structures, StageTable::threadgroup_lengths and
bind::BoundAccelerationStructure, which went with the binder's cut
(b5916b2f7b and the cut before it; the runtime binds through no stage table,
46a9a57522). The paragraphs now say what the binder writes without them.

Comments only. Neither file is a runtime input the validation guard hashes
(build.rs's list), so runtime-sources.sha256 stays a92fe0a8, recomputed with
no build; grep finds no other StageTable or BoundAccelerationStructure in
crates/ or docs/.
2026-12-03 06:52:49 -08:00
Anees Iqbal b3908325dd Fixture: gsm2_vertex_quad_permutes' header says its quads lower to shuffles on every device
The header said the translation emits Vulkan's quad instructions where the
vertex stage takes them. It lowers every vertex function's quad broadcast and
shuffle-xor to a subgroup shuffle through the ballot of the live lanes on
every device, as the fixture README's row and the engine test
vertex_quad_permutes_shuffle_through_the_live_lanes say, since a vertex quad
may lack a lane past the draw's vertex count.

Comment only: the generated .ll and .air.ll carry no comment of the source and
are unchanged (regen-air-fixtures not needed), and the corpus cases key on the
AIR's hash, not the source's.
2026-12-03 06:52:49 -08:00
Anees Iqbal faa76cc8af Validation: the tiled and linear textures over a buffer reach the cover rule's texture branch
Covers::saw took a call as a texture's making only where its selector starts
with newTexture, so newTiledTextureWithDescriptor:offset:bytesPerRow: and
newLinearTextureWithDescriptor:offset:bytesPerRow:bytesPerImage: never
reached it: the rule held such a texture as no texture at all, neither over
its buffer nor written with it, and the linear selector's arm there was never
taken. The branch now also takes every selector makes_texture_over_buffer
names.

Found by the previous commits' test, which failed at the fix commit too (the
RTX 5080 laptop's node, job m3-max-83777: the tiled and linear textures read
uncovered).
2026-12-03 06:52:49 -08:00
Anees Iqbal 5f1686fb55 Validation: a texture over a heap buffer is covered where its buffer is
The cover rule held a buffer's cover on the buffer alone, so a texture made
over a covered heap buffer read as uncovered: its check was compared and its
dump carried no cover, and compare-dumps could report as a difference the
bytes Metal leaves undefined once a heap texture's write aliased them.

Covers::covered now maps an object to the one whose bytes it holds (a view to
its texture, a texture over a buffer to that buffer), the same mapping the
rule already used to decide whether a texture's write is tracked. The rule
also takes the player's own list of the selectors that make a texture over a
buffer (makes_texture_over_buffer), which adds the tiled form
(newTiledTextureWithDescriptor:offset:bytesPerRow:) the rule had missed.
docs/REPLAY-STREAM.md and dumps.rs say a texture's cover follows its buffer's.

Verified by the test the previous commit added (red there, green here); the
jobs are in the lane's report.
2026-12-03 06:52:49 -08:00
Anees Iqbal 33b55b26a4 Validation: a texture over a covered heap buffer is covered with it (red)
The replay player's cover rule (covers.rs) covers a heap-placed buffer that a
heap texture's write meets, but a texture made over that buffer
(newTextureWithDescriptor:offset:bytesPerRow: and its tiled and linear forms)
holds the buffer's bytes and is not marked covered, so a check or a dump of it
carries no cover and compare-dumps can report the bytes the cover rule leaves
undefined as a difference.

This test makes one texture over a heap buffer by each of the three selectors,
covers the buffer by a dispatch that writes a heap texture placed over it, and
expects each to be checked as covered until the buffer is written whole. It
fails at this commit; the fix follows.
2026-12-03 06:52:48 -08:00
Anees Iqbal 599da8cacf REFUSALS: regenerate after the coherent-image landing
The coherent access beside a storage image no longer refuses (d0665778b7), so
lower/sync/memory_model.rs's not_implemented site of feature::Lowering is gone: 31 sites
become 30. Generated by scripts/refusal-surface/refusal_surface.py at 8e912a905d; the
runtime's error/basis.rs comes out unchanged. Found by lane lowrows's regeneration at that
tip.
2026-12-03 06:52:41 -08:00
Anees Iqbal 8e912a905d Validation cases: a device-coherent texture handed between threadgroups, Metal's answer
One authored case over engine/coherent_texture_handoff's coherent_texture_handoff: 128 threads in
threadgroups of 64, a 64 x 1 r32_uint texture of zeros, a zero flag and an output of 64 words
filled with 0xAB. It is authored_bounded: the reader's one loop runs at most 4096 loads, a constant
of the kernel. Installed with corpus-case-check and qualified on Metal on the Apple M3 Max, three
executions (m3-max-83673): every word is 1 (output sha256 08f4ad0b..., the hash of 64 words of 1),
so no read on Metal that saw all 64 writers' flag read the texel's earlier value.

scripts/qualify-public-cases with this case in its list exits 0 on lavapipe (job m3-max-83707), and
the case's Vulkan candidate on the Intel Iris Xe (RPL-P) under its venue intel-irisxe-rplp-anv
prints Match (m3-max-83680).
2026-12-03 06:47:18 -08:00
Anees Iqbal 5c42c16e7b Runtime tests: a device-coherent texture handed between threadgroups, its reads that saw the flag counted
tests::coherent_texels gains each_device_hands_a_device_coherent_texture_between_threadgroups,
under a device cfg on every device: engine/coherent_texture_handoff's coherent_texture_handoff_seen
from the fixture's .ll, through the runtime's identity route, dispatched as two threadgroups of 64
threads over a 64 x 1 R32Uint Shared texture of zeros, its flag and output in one Shared block
(new_buffer zeroes the flag). Of threadgroup 1's 64 reads it counts those that saw all 64
writers' flag and, of those, the ones that read the written texel, prints both, and fails where a
read that saw the flag read anything else. A device that ends the bounded wait before
threadgroup 0 runs shows no flag; its line says so, and its run then proves only the barrier
test's ordering within a threadgroup.

Counts:
- Intel Iris Xe (RPL-P): of 64 reads, 64 saw every writer's flag, and of those 64 read the written
  texel (m3-max-83672); the barrier test beside it: 1024 of 1024 threads read their neighbour's
  write;
- lavapipe (llvmpipe, LLVM 23.1.1): of 64 reads, 64 saw every writer's flag, and of those 64 read
  the written texel (m3-max-83707); the barrier test beside it: 1024 of 1024.
2026-12-03 06:47:13 -08:00
Anees Iqbal 18e8600cbb Tables: coherent_texture_handoff's golden printout, and its inventory rows confirmed by the bless
bless_engine_goldens under the pinned LLVM 21 (Homebrew 21.1.8) on the M3 (m3-max-83664) writes the
fixture's printout: its four texture calls decoded with device_coherent: true.
bless_engine_inventory in the same job, with every assembler, leaves the table as the previous
commit wrote it: the four coherent_texture_handoff rows stand, and no other row moved. Both bless
tests passed.
2026-12-03 06:47:13 -08:00
Anees Iqbal 5410866d9a Fixtures: coherent_texture_handoff's companions, and its inventory rows
The typed .air.ll and the opaque .ll from scripts/regen-air-fixtures on the M3 (m3-max-83664:
Metal 32023.922, SDK 27.2 26B118), and the fixture's TOOLCHAIN line. Apple's compiler names the
texture's read and write air.read_texture_2d.device_coherent.u.v4i32 and
air.write_texture_2d.device_coherent.u.v4i32, the writer's fence air.atomic.fence(i32 4, i32 3,
i32 2) and the reader's air.atomic.fence(i32 4, i32 2, i32 2) (texture memory, release or acquire,
device scope), and the flag's add and load air.atomic.global.add.u.i32 and
air.atomic.global.load.i32 at relaxed order and device scope.

The engine inventory gets four rows, the two kernels from each text. Each reads and writes a uint
texture2d declared read_write, as format_scout's scout_read_write_u does, and takes its row: ok on
every profile but the three Intel profiles and the runtime floor, which have no storage-image read
without a format and need the texture's format (NeedsInput StorageTextureFormat at texture 0).
2026-12-03 06:47:13 -08:00
Anees Iqbal 3994ea73dc Fixtures: coherent_texture_handoff, a device-coherent texture handed between threadgroups (source)
Our own MSL (metal4.1, macOS 27.0): two kernels over a texture2d<uint, access::read_write,
memory_coherence_device>, a device atomic_uint flag and an output buffer, dispatched as two
threadgroups of 64 threads. Each thread of threadgroup 0 writes its texel (1000 + i), fences
texture memory at device scope with release order and adds 1 to the flag (relaxed); each thread
of threadgroup 1 loads the flag until it reads 64 or for at most 4096 loads, fences texture memory
at device scope with acquire order and reads the texel of its index.

coherent_texture_handoff stores 2 where a reader saw all 64 writers' flag and read anything but
the written texel, else 1: its words are 1 whatever the scheduling, so the case stays
deterministic for Metal qualification. coherent_texture_handoff_seen stores each reader's flag
value and texel, for the runtime's device test to count the reads that saw the flag.

The fences are MSL 4.1's release and acquire, not seq_cst: the runtime refuses a seq_cst fence
beyond the thread under the identity domains (IdentityDomains, "a sequentially consistent fence",
a known gap in its README), which a first form of this fixture met on the Iris Xe (m3-max-83655).
2026-12-03 06:47:13 -08:00
Anees Iqbal 611a37ff04 Translator: a device-coherent texture's reads and writes are coherent at device scope
MSL 3.2's memory_coherence_device texture is read and written through members of the read and
write families named device_coherent, first after the stem and before .i16: Apple's compiler
(macOS 27.0.1, metal 32023.922) names a 2D uint texture's read and write
air.read_texture_2d.device_coherent.u.v4i32 and air.write_texture_2d.device_coherent.u.v4i32
(job m3-max-83533), a 2D half texture's at 16-bit coordinates
air.{read,write}_texture_2d.device_coherent.i16.v4f16, a texture buffer's
air.{read,write}_texture_buffer_1d.device_coherent.u.v4i32 and a 3D float texture's
air.{read,write}_texture_3d.device_coherent.v4f32 (job m3-max-83599), each with the operands of
the same access to a texture of the default threadgroup coherence and the same argument metadata.
The SDK's metal_texture headers pass the coherence to every read, sparse read, block read and
write; atomics take none. The translator refused each as UnknownIntrinsic.

Now:
- metal2vulkan-air: Texture::device_coherent holds the token, which Texture::parse reads first after
  the stem for a read, block read or write and refuses for any other operation (a name the
  grammar does not know stays unknown). Block-read canonicalization keeps it on the reads it
  makes. The module doc gives the token's place.
- metal2vulkan: such a read or write takes its coherence as a buffer's *_coherent access does
  (sync::memory_model::coherent_access, texture::device_coherent): under the Vulkan memory model,
  where the profile has vulkanMemoryModel and its device scope, a read carries NonPrivateTexel
  with MakeTexelVisible and a write with MakeTexelAvailable, at Device (Read::coherent,
  Write::coherent, emit::texel_memory); elsewhere the function keeps GLSL450 and every storage
  image is Coherent. A texture buffer held as words reads and writes through routines of their
  own made at Device scope (words::Routine's coherent), under the Vulkan model only.

Public surface: metal2vulkan-air's intrinsics::Texture gains the public field device_coherent
(api_signatures.tsv blessed). A consumer that builds a Texture with a struct literal must set it;
the Debug form of a Texture prints it, so the engine fixtures' AIR input snapshots
(crates/metal2vulkan/tests/air_input/*.txt) print device_coherent: false on every texture call.

SEMANTICS_VERSION moves above development's: a refusal becomes a module.

Verified (job m3-max-83707): the command line on that kernel gives, for lavapipe and moltenvk-m3,
OpImageRead with MakeTexelVisible|NonPrivateTexel|VolatileTexel and OpImageWrite with
MakeTexelAvailable|NonPrivateTexel|VolatileTexel at scope Device (%uint_1), each module valid under
spirv-val at vulkan1.2, 1.3 and 1.4; the engine_atomics, engine_handles and air_input tests pass
(84); cargo fmt, clippy (plain, --cfg m2v_gpu, --cfg m2v_cpu_icd), Rustdoc, the API reference check
and the doctests pass; the suites pass 3742 of 3743 (24 skipped), the one failure
golden_hashes_match_the_table, bless due as at 011540217d; the validation suite passes 1343 (3
skipped) and the conformance suite 1052. The states-only plays of the branch's tree
(m3-max-83739) make what 011540217d's make (m3-max-83738): the gb-3090-r2 stream 10643 render and
15299 compute states, the 780M windrag stream 8972 and 225, none refused.

Landed with SEMANTICS_VERSION 2349 (renumbered above development's 2348: written 2347 on its base).
2026-12-03 06:47:10 -08:00
Anees Iqbal 3b85893447 Translator tests: a device-coherent texture's texels made available and visible at device scope
A texture declared with MSL 3.2's memory_coherence_device (texture2d<uint, access::read_write,
memory_coherence_device>) compiles, under macOS 27.0.1's metal 32023.922 at the default -std and at
-std=metal3.2, to the same argument metadata and type as a texture of the default threadgroup
coherence; only its reads and writes change, to members of the read and write families named
device_coherent: air.read_texture_2d.device_coherent.u.v4i32 and
air.write_texture_2d.device_coherent.u.v4i32 (job m3-max-83533). The SDK's metal_texture headers pass
the coherence to every read, sparse read, block read and write of every texture type, the texture
buffer's included; atomics take none. The translator parses no such member: Texture::parse finds
three tokens after the stem and answers None, so the function is refused as UnknownIntrinsic.

This adds a no-device test: engine_atomics
a_device_coherent_textures_texels_are_made_available_and_visible_at_device_scope compiles the
coherent_image kernel with its read and write renamed to the device_coherent members on every
profile of the file and on lavapipe without the memory model, and passes L3. Under the Vulkan model
each read must carry NonPrivateTexel with MakeTexelVisible and each write with MakeTexelAvailable,
at Device; under GLSL450 the storage image must be Coherent.

At this commit the test fails: the function is refused as UnknownIntrinsic.

Verified on the CPU (job m3-max-83707, red leg 2): with the crates at this commit the test fails at
its compile, and the command line on the kernel prints FALLBACK, UnknownIntrinsic
(air.read_texture_2d.device_coherent.u.v4i32), for moltenvk-m3 and lavapipe.
2026-12-03 06:47:03 -08:00
Anees Iqbal d0665778b7 Translator: a coherent access beside a storage image compiles, its texels non-private
lower/sync/memory_model.rs's finish refused a function with a coherent access, or anything else
that selects the Vulkan memory model, beside a storage image outside an interlocked body
(NotImplemented{Lowering(MemoryModel)}), its module doc saying the image's NonPrivateTexel
accesses were not measured. The accesses were already right: a storage image's read and write
take the function's coherence (texture::emit::texel_memory), NonPrivateTexel under the Vulkan
model, so a barrier orders them with other invocations' accesses as GLSL450 does; under GLSL450
the module decorates every storage image Coherent beside the coherent accesses. Under the identity
domains, the runtime's route, the refusal never fired for a texture slot.

Now the refusal is gone, and with it texture::TexturePlan::heap_storage_images, which only it
called. The module doc says what a storage-image access takes and names the runtime test that
measures it.

SEMANTICS_VERSION moves above development's: a refusal becomes a module.

Verified on the CPU (job m3-max-83707): the two translator tests pass; the golden table differs from
development's (semantics 2342) in 72 cells here, as at 011540217d and at the tip, so the change
moves no existing cell by count; the refusal surface check passes.

Landed with SEMANTICS_VERSION 2348 (renumbered above development's 2347: written 2346 on its base 011540217d).
2026-12-03 06:46:59 -08:00
Anees Iqbal 1ba2517654 Translator tests: a coherent access beside a storage image orders the image's texels
lower/sync/memory_model.rs refuses a function with a coherent access and a storage image
(NotImplemented{Lowering(MemoryModel)}) outside an interlock, its module doc saying the image's
NonPrivateTexel accesses "are not measured". The translator does emit them: a storage image's read
and write take memory_model::coherence(plan).texel(), NonPrivateTexel under the Vulkan model, as
every word access of shared memory takes NonPrivatePointer, so a barrier orders them with other
invocations' accesses as GLSL450 does. Under the identity domains the refusal does not fire for a
texture slot (finish counts cx.descriptors.storage_images, which a slot adds to only off identity),
and the command line on engine_atomics' coherent_image kernel for moltenvk-m3 and lavapipe (no
lowering inputs, the runtime's route) gives OpMemoryModel PhysicalStorageBuffer64 Vulkan,
OpImageRead and OpImageWrite with NonPrivateTexel|VolatileTexel, and the coherent OpStore with
MakePointerAvailable|NonPrivatePointer at Device; a variant with a threadgroup barrier over device
and texture memory between the write and a neighbour's read gives OpControlBarrier Workgroup
Workgroup with AcquireRelease|UniformMemory|ImageMemory|MakeAvailable|MakeVisible. Each module
passes spirv-val at vulkan1.2, 1.3 and 1.4 (job m3-max-83520).

This ports the refusal's two tests to the answer and adds a device test:
- engine_atomics a_coherent_access_beside_a_storage_image_orders_its_texels: the kernel with the
  coherent store compiles on every committed profile of the file and on lavapipe without the
  memory model, and passes L3. Under the Vulkan model its texture's every read and write carries
  NonPrivateTexel and no MakeTexel* (the texture has Metal's default threadgroup coherence); under
  GLSL450 its storage image is Coherent (pipeline::testing::interlocked_coherence). The kernel with
  a plain store keeps plain texel operands.
- engine_handles a_coherent_access_beside_a_heap_storage_image_compiles: a heap storage class read
  and written beside a coherent store compiles and passes L3, with and without image robustness.
- metal2vulkan-runtime tests::coherent_texels, under a device cfg on every device: a kernel reads
  its texel of a read_write texture2d<uint>, writes it plus one, crosses a threadgroup barrier over
  device and texture memory, reads its neighbour's texel and stores it with
  air.store.device_coherent, over 64x16 threads in threadgroups of 8x8; every thread must read
  its neighbour's write, never the texel's earlier value. It prints the counts before it checks
  them.

At this commit the two translator tests fail: the function is refused. The device test runs
through the runtime's identity route, which the refusal does not reach, so it passes here.

Verified on the CPU (job m3-max-83707, red leg 1): with the crates at this commit the two translator
tests fail, each at its compile.
2026-12-03 06:46:42 -08:00
Anees Iqbal df54afeef2 Cases: LOD queries through a sampler bound with LOD clamps of its own, qualified on the M3 Max
Six authored cases over the owned fixture rfs_kernel_lod: five of the kernel lod_2d and one of
the vertex function lod_vertex, each through a runtime sampler bound with
set*SamplerState:lodMinClamp:lodMaxClamp:atIndex: with a pair that differs from its
descriptor's, so the answer says which pair the query reads. The M3 Max (macOS 27.0.1, job
m3-max-83804) answers the bind's pair in every one:

- nearest mip, default clamps, bound (2.7, 4): 3 (the descriptor's pair reads 0);
- nearest mip, clamps (3, 4), bound (1.2, 4): 1 (3);
- linear mip, default clamps, bound (2, 3): 2 (0);
- nearest mip, clamps (2.7, 4), bound (0, FLT_MAX): 0 (3);
- nearest mip, default clamps, bound inverted (3, 1): 1, as under (1, 1);
- the vertex function, default clamps, bound (2.7, 4): 3 (0).

Each unclamped level is 0. The ids join scripts/qualify-public-cases, CI's lavapipe step.

Why: under the identity domains the query reads the minimum level from the word of the
resource ID the slot pushes, and a bind with clamps pushes the ID of the state's variant of
the pair; these cases check that variant's word against Metal.
2026-12-03 06:46:39 -08:00
Anees Iqbal 2fe71c4a25 Validation: a sampler bound with LOD clamps of its own, honoured by the Metal oracle and the Vulkan candidate
A case's sampler gains bind_lod_clamps, the [lodMinClamp, lodMaxClamp] pair it is bound with.
The Metal oracle binds it through the stage's set*SamplerState:lodMinClamp:lodMaxClamp:atIndex:
(compute, vertex, fragment, tile, object and mesh); the Vulkan candidate through the runtime's
set_sampler_state_with_lod_clamps and its vertex and fragment forms, which bind the state's
variant of the pair. Absent, the field is left out of the case's JSON, so every existing case
keeps its identity; a NaN bound is refused, as Metal documents no answer for one, and an
inverted pair is allowed.

Why: the runtime's bind-time variant carries its own resource ID word, which a kernel's LOD
query reads under the identity domains; only an authored case of that bind checks its answer
against Metal.

Verified: the identity tests cover the field's absence, its presence and its NaN refusal; the
cases and their runs are in the next commit.
2026-12-03 06:46:39 -08:00
Anees Iqbal c5f979d985 Cases: kernel and vertex LOD queries through runtime samplers with LOD clamps, qualified on the M3 Max
Ten authored cases over the owned fixture engine/rfs_kernel_lod. Each comes from the committed
runtime-sampler case of its entry with the sampler's mip filter and LOD clamps set (no new AIR):
- lod_2d: nearest (2.7, 4) reads 3; nearest (1.5, 3) reads 1; no mip filter (2.5, 4) reads 0;
  linear (2, 3) reads 2; linear (10, 20) reads 4 (the last level); nearest (6, 9) reads 4;
- lod_2d_array: nearest (0.6, 4) reads 1;
- lod_3d: linear (1, 2) reads 1;
- lod_cube: nearest (2.2, 3) reads 2;
- lod_vertex: nearest (2.7, 4) reads 3, 64 points with no rasterization.
Every unclamped level is 0. These are exact rows only: a linear mip filter with an lodMinClamp
between whole levels, which the identity domains answer by the word's nearest level, has no case
(the planner's ruling; docs/API.md's accepted differences).

Installed with corpus-case-check and qualified with corpus-metal on the Apple M3 Max (macOS
27.0.1, environment apple-m3-max-macos27.0.1), job m3-max-83473. Each observation decodes to the
levels above, which metal::sampler::query_min_level gives. scripts/qualify-public-cases (CI's
lavapipe step) now runs these ten and the four existing runtime-sampler cases of the fixture.
Before this branch's translator fix those four were not_supported under the identity domains
(lavapipe, m3-max-83452: refusal=4); at the fix they match=4.
2026-12-03 06:46:39 -08:00
Anees Iqbal afe186c41e Validation: an authored sampler's LOD clamps, honoured by the Metal oracle and the Vulkan candidate
A case's sampler (SamplerResource) gains lodMinClamp and lodMaxClamp, each optional and left out
of the case's JSON when absent, so every case written before them keeps its identity. The Metal
oracle sets them on its MTLSamplerDescriptor (metal::platform::samplers), and the Vulkan candidate
on the descriptor its runtime sampler state is made of (candidate::engine::resources::
sampler_descriptor, the one source of the kernel, render and argument-buffer paths); an absent
clamp is Metal's default, 0 and FLT_MAX. The checker refuses a NaN or inverted pair. A clamp is
part of the identity where authored. No executor answer changes for a case without one, so no
executor version moves.

Tests: sampler_descriptor takes the clamps; absent clamps leave the JSON and the identity alone and
authored ones change it; an inverted or NaN pair is refused; every committed case (corpus/cases,
read by name) still computes to its stored case_id under the new schema. The last test is the
evidence that no existing identity moved; it runs in the lane's validation suite job.
2026-12-03 06:46:39 -08:00
Anees Iqbal 5b3bd800c0 Translator: under the identity domains a runtime sampler's LOD query outside a fragment function reads its minimum level from the sampler's word
A clamped calculate_clamped_lod in a kernel or a vertex function through a runtime sampler
argument was refused on every profile under the identity domains ("a sampler argument whose
minimum level or emulated filter the function specializes"): the query read the slot's
SamplerMinLevel specialization, which no binder chooses there.

The query now reads the word of the resource ID the sampler slot already pushes (SlotGuestBase):
0 where the word states no mip filter, else SamplerWord::LEVEL_MIN, the level a nearest mip
filter reads at lodMinClamp, bounded by the texture's last level as before. A bind-time clamp
(setSamplerState:lodMinClamp:lodMaxClamp:) binds a variant whose word is made of the clamped
descriptor, so it is read too. That is the M3 Max's and M4's measured answer
(metal::sampler::query_min_level) for no mip filter and a nearest one, and for a linear one where
lodMinClamp is a whole level or past the texture's last level. Under a linear mip filter with a
clamp between whole levels Metal answers the clamp on its sixty-fourths grid, which the word does
not hold. MSL 4.1 section 6.13 leaves both queries undefined outside a fragment function ("Only
call the calculate_unclamped_lod and calculate_clamped_lod functions from a fragment function or
a function you call with a fragment function; otherwise, the behavior is undefined."). So, per
the planner's ruling, there is no precision note; docs/API.md's accepted differences states the
answer. The resident-table path keeps its specialization.

SEMANTICS_VERSION 2347. The runtime-sources pin does not move: pin-compute.py gives a92fe0a8...
for this tree, the same as before. docs/REFUSALS.md does not move either: the refusal text
remains for an extended-range sample's linear-mip blend. The runtime README's known-gap entry
names the lowered query. Verified by the lane's red/green job, named in the lane's report.

Landed with SEMANTICS_VERSION 2347 (renumbered above development's 2346: written 2343 on its base,
then 2346 at the lane's rebase onto 0f4114c882, which development's HandleUse also took).
2026-12-03 06:46:38 -08:00
Anees Iqbal c04212227d Tests: a runtime sampler's LOD query outside a fragment function compiles under the identity domains (red)
Under the identity domains (the runtime's policy) a clamped calculate_clamped_lod in a kernel or a
vertex function through a runtime sampler argument is refused on every profile, "a sampler
argument whose minimum level or emulated filter the function specializes": the query wants the
slot's SamplerMinLevel specialization, which no binder chooses there.

The two tests compile rfs_kernel_lod's runtime-sampler entries (lod_2d, lod_2d_array, lod_3d,
lod_cube, lod_vertex) and sampling_completion's lod_query_kernel under the identity policy on the
lavapipe and moltenvk-m3 profiles, and require L3 to pass, no SamplerMinLevel or SamplerState
specialization, the sampler slot's resource ID pushed, one OpImageQueryLevels and no
OpImageQueryLod. Red at this commit: each compile is the IdentityDomains refusal. The red run is
the lane's next potluck job.
2026-12-03 06:46:38 -08:00
charlysound 2c297ad7bf Merge current master into native mesh runtime
Preserve the native object/mesh path alongside upstream texture-buffer and restore-batch changes. Advance semantics, artifact and runtime versions beyond both parents (2343/607/2560) and refresh the runtime source guard. Workspace all-target all-feature Clippy passes. The complete golden table is retained from upstream pending its genuine Apple-assembler refresh in hosted CI.
2026-12-03 15:28:30 +01:00
Anees Iqbal dfbc157464 Bless at pin T: the golden hash table and the authored compile census
The golden hash table moves 18 rows, 133 cells, every one a hash before and after, and gains 8
rows: kernel_handle_word_joins's four entries in both fixture forms, which compile on all 15
profiles. Its semantics line goes from 2342 to 2346. The golden bless at each translator commit
since pin S (job m3-max-83753) puts every moved cell on one of two commits:
- 423fbce843 (ZeroAddress placed where a read may be checked on a device-address slot): 29 cells,
  fragment_discard_hoist:hoisted_written_read in both forms on 12 profiles and
  kernel_dynamic_cursor_across_a_call on 5 (lavapipe x3, moltenvk-m3, runtime-floor);
- aa2355716b (a half-float or RG11B10Float texel held as words converts only values in range):
  104 cells, the texture-buffer subjects of a8r_buffers, hsw_storage_writes, tb_word_formats,
  texture_ops and tob_renders on the 7 profiles that hold a texture buffer as words, and
  kernel_texture_variant_leftovers on 6 of them.
The mode-2 rounding commit (011540217d) and HandleUse move no existing cell. The engine inventory
and the air_input printouts bless unchanged, and the metallib half of
committed_air_fixtures_parse_and_link passes on the M3's SDK (bless job m3-max-83730, at
f27b62c05a).

The authored compile census recompiled every cell: 2373 cases, 9 profiles, 21,357 cells, 0
cached; 19,142 compiled, 2,215 refused, 0 failed, 0 regressions (census job m3-max-83810, wall
65.7 s, slowest compile 450 ms). Its four differences are kernel_handle_word_joins's four new
cases, all compiled on every profile; 9 rows move only their artifact digests (30 digests), and
the artifacts_at line moves to this build.
2026-12-03 06:24:51 -08:00
Anees Iqbal f27b62c05a Validation: Metal qualifies kernel_handle_word_joins's four cases
corpus-metal ran the four authored cases on the M3 Max (apple-m3-max-macos27.0.1, the primary
reference environment), from the Metal twin kernel_handle_word_joins.air.ll, and qualified all four
(job m3-max-83499, at 1d88e9bd64).

The three sampler cases record one output (they spell the same choice three ways): even threads
read the texel clamp to edge names, odd threads the texel repeat names, and the two differ at
every shared out-of-range coordinate, so a thread that took the other branch's sampler would read
another texel. The texture case records each odd thread reading element slot[g] & 3 of the
texture array and each even thread the other texture.
2026-12-03 05:57:30 -08:00
Anees Iqbal 2fb00a15ae CI: qualify kernel_handle_word_joins's four cases on lavapipe
The public case step now runs the four authored cases of the owned fixture kernel_handle_word_joins
(a sampler or a texture taken from a branch merged at a join, as integer words in a phi and in a
select, and as pointers in a phi) against their Metal observations.

Verified: syntax only (bash -n); the cases' Metal observations and the step's run come next.
2026-12-03 05:57:30 -08:00
Anees Iqbal 4457fd001f Validation: authored cases for kernel_handle_word_joins's four entries
Four cases, one for each entry of the owned fixture kernel_handle_word_joins: sixteen threads
take a sampler or a texture from a branch merged at a join (as integer words in a phi, as words in
a select, and as pointers in a phi) and write what it samples or reads.

The sampler entries read element slot[gid] & 3 of an array<sampler, 1> through a run-time GEP
index; slot holds 4g, so the index is always the array's one element. The case checker binds only
the first slot of a sampler array (the case schema has no sampler-array resource), which is why
the array has one element; engine_handle_words compiles the same entries over an
array<sampler, 8>. The texture entry reads element slot[gid] & 3 of an array<texture2d, 4>.

Installed by corpus-case-check --install at c5bbdb25b7 (job m3-max-83477, msi), which also
translated the fixture's Metal twin (kernel_handle_word_joins.air.ll through metal-as) for all four
entries (spirv-val PASS) and ran engine_handle_words, 7 of 7 passed.
2026-12-03 05:57:29 -08:00
Anees Iqbal 2b45afa2ab Fixture: kernel_handle_word_joins's sampler entries load the element at a run-time index
The sampler entries read samplers[slot[gid] & 3] again, the structure under test: a word loaded
from a sampler-array element at a run-time index (a GEP whose index is a value, not element 0)
meets the constexpr sampler's bits at a join. The array stays an array<sampler, 1>: the authored
case checker binds only the first slot of a sampler array (the case schema has no sampler-array
resource), so the cases' slot values make the index 0 and Metal reads the one element.

engine_handle_words compiles the same three sampler entries over an array<sampler, 8>, a text edit
of the fixture's byval, GEP and argument metadata types, on every committed profile under both
policies, and checks the element's load is the clamped load over its run-time index range.

Verified: nothing yet at this commit; the next job runs the tests and llvm-dis of the twin.
2026-12-03 05:57:29 -08:00
Anees Iqbal 6bd7161ae7 Fixture: kernel_handle_word_joins's sampler entries read a one-element sampler array
The authored cases bind a sampler array's parameter at its first slot
only (the case schema has no sampler-array resource; the checker
refuses samplers 1-3 of an array<sampler, 4> as bound to nothing), so
the sampler entries now read the one element of an array<sampler, 1>
at a constant index, and their unused slot parameter is gone. The
texture entry keeps its four-element array read at a run-time index,
the same element lowering for either class. The typed twin follows
(reassembled with metal-as and linked with metallib on the M3), and
merged_handle_words_are_handle_indices expects the sampler entries'
static element load.
2026-12-03 05:57:29 -08:00
Anees Iqbal 3dbea580f1 Translator: SEMANTICS_VERSION 2346 for handle words merged at a join; their docs
Handle words merged at a join now compile where they were refused
(Lowering(Access) HandleUse), and a handle phi of a constant with one
candidate of its class where it was ConstantOperand: the output for an
unchanged key changes, so the version moves above development's 2342 (2343, which the audit lane's item also targets; renumbered at landing).

lower::access::handle's module doc says what the word webs are and
when they lower; AccessCause::ConstantOperand's doc says a handle phi's
constant is refused only without one candidate of its class.

The runtime guard's inputs are untouched (the build's hash over them,
recomputed the way build.rs does, is the committed
runtime-sources.sha256), and docs/REFUSALS.md regenerates unchanged.

Landed with SEMANTICS_VERSION 2346 (renumbered above development's 2345: ZeroAddress 2343, finding 1 2344 and 2345). runtime-sources.sha256 recomputed on development, unchanged (a92fe0a8).
2026-12-03 05:57:20 -08:00
Anees Iqbal 0367a0607a Tests: handle words merged at a join, their refusal edges, and the fixture's Metal twin
The fixture kernel_handle_word_joins.ll states in its header that it is
written from our own source and today's compiler's output for it;
kernel_handle_word_joins.air.ll is its typed-pointer twin, which xcrun
metal-as assembles for the Metal oracle (assembled and linked with
metal-as and metallib on the M3).

engine_handle_words adds:
- merged_handle_words_are_handle_indices: each entry's element load is
  the clamped element, the select merge a handle select, and each
  inttoptr (and the texture parameter's ptrtoint) a handle copy;
- an_observed_handle_word_is_refused: a merged integer with an
  arithmetic use, or stored, keeps Lowering(Access) HandleUse;
- a_handle_word_of_another_class_is_refused: a web merging a sampler's
  bits with a texture's, and one whose inttoptr makes a texture of a
  sampler's bits, are HandleAsPointer;
- a_handle_phi_of_a_constant_that_is_no_handle_of_its_class_is_refused:
  a sampler phi of a constant GEP of the sampler state is
  HandleAsPointer (provenance's class conflict refuses it before
  lowering's ConstantOperand);
- a_handle_phi_of_null_is_the_null_handle.

The fixture inventory gains the pair's eight rows, ok on every profile
(the .ll rows as the red test's run at e32daf9d9b compiled them; the
.air.ll rows expected, taken from the expectations off macOS).
2026-12-03 05:57:19 -08:00
Anees Iqbal 9e6b0df231 Translator: handles copied as integers and merged at a join are the handle of the branch taken
An older Metal frontend spells `cond ? samplers[i] : constexpr_sampler`
by copying each branch's handle as a 64-bit integer (an element of a
handle array as a plain integer load through its address, a constexpr
sampler or a handle parameter as the ptrtoint of its pointer), merging
the integers in a phi or select, and turning the merged integer back
into a handle with inttoptr. Lowering refused the integer load
(Lowering(Access), HandleUse), and the same merge of the pointers
themselves, today's form, was refused for its constant incoming value
(ConstantOperand).

Provenance now finds these word webs by structure alone
(memory::provenance::words): integers merged by phi, select, or freeze,
each a plain integer load, a ptrtoint of a pointer, a ptrtoint
constant expression, or another merge, all as wide as the pointer, and
every use another merge or an inttoptr as wide (a sink). Any other use
of an integer (arithmetic, a compare, a store, a call) or any other
operand of a merge leaves the web out, and its inttoptrs stay pointers
made from an integer. A sink of a merge joins its sources' facts while
each is a handle (a load through a handle-array element, the bits of a
handle parameter, a constexpr sampler, or null), so its candidates are
the same merge's of the handles; its class is seeded from the arrays
and merged with the converted pointers, so a web mixing classes is a
class conflict. The bits of a handle such a web carries are not an
escape.

Lowering plans each web whose sinks, loads, ptrtoints and constants all
hold one class's handles (each constant with exactly one candidate):
its integers are handle indices (HandleWord::Joined), its selects and
freezes routed to the access family, and each constant its handle
index. A handle phi takes a constant incoming value in only when the
constant has exactly one candidate of the phi's class (the null handle
or a constexpr sampler's; under the identity domains an argument
buffer's sampler takes only null, as its nil ID); any other keeps the
ConstantOperand refusal.
2026-12-03 05:57:19 -08:00
Anees Iqbal 5a6495e57c Red: name every refused entry and profile 2026-12-03 05:57:19 -08:00
Anees Iqbal 6f4090a5e0 Red: handles copied as integers and merged at a join (kernel_handle_word_joins), refused today 2026-12-03 05:57:18 -08:00
Anees Iqbal 0f4114c882 Tests: every public fixture compiles on every profile without a translator bug, at every landing
The merge check passes over golden_hashes_match_the_table and the public fixtures' inventory
tests, which are often due for a bless, so the one sweep that compiles every public fixture's
subjects on every committed profile under the runtime's policy, and refuses a translator bug (an
internal error, such as a strategy's read of an unplaced push field), ran at no landing. This
test builds the same table with the golden check's own builder and compares no hash: it fails
only on a translator bug, and its name is outside the bless-due filter.
2026-12-03 05:55:31 -08:00
Anees Iqbal 011540217d Translator: a mode-2 fragment write to a texture buffer held as words rounds half and small floats to nearest even
A texture buffer of a format a device holds as words is written by lower/texture/words.rs's
write_texel, which rounded a half-float or RG11B10Float channel toward zero at either
textureWriteRoundingMode. Metal's texture buffer rounds those to nearest even at mode 2, as its
storage texture does (the probe below). So a fragment function in a mode-2 pipeline that wrote a
half-float or RG11B10Float texture buffer on a device holding that format as words stored a code
one below Metal's on 36% to 44% of the probe's channels, and 65504 where Metal stores the infinity.

Now, where Write::half_up marks the write (a fragment function's, in a pipeline of mode 2):
- a half-float channel (R16Float and RG16Float, the half-float formats a device may hold as
  words) takes ChannelWrite::FloatNearestEven, a finite value past the largest to the infinity, as
  Metal's RGBA16Float texture buffer stores it;
- an RG11B10Float channel takes nearest even too, and a lane that rounds to the infinity from a
  finite value is held at its format's largest finite value (65024 for the 11-bit channels, 64512
  for the 10-bit one), as Metal's stores it; an infinity stays, and a NaN is the quiet NaN still.
The RGB9E5Float word's half-up rounding is unchanged; the probe shows Metal's texture buffer
storing the same bytes as its storage texture there. A write at mode 0 or 1, and every kernel's
write, still rounds toward zero.

The probe is committed as crates/metal2vulkan-conformance/probes/texture_buffer_write_rounding.m:
texture_write_rounding_storage.m with texture_buffer<T, access::write> targets, made from a Shared
buffer with MTLTextureTypeTextureBuffer and written at texel y * 256 + x, over the same 65,536
texels. On an Apple M3 Max under macOS 27.0.1 (job m3-max-83395), mode 0 matched toward zero on
every channel, and mode 2 matched nearest even on every channel that is not a NaN: RGBA16Float
float texels 262,112 of 262,112 (to the infinity past the largest), RG11B10Float float and half
texels 196,583 of 196,583 each (held at the largest), and RGB9E5Float 65,536 of 65,536 at both
texel types (half up, its hashes equal to the storage texture's).

Docs: words.rs's module doc, Write::half_up and write_texel; API.md's words line names mode 2.

SEMANTICS_VERSION moves above development's: a texture buffer write's answer changes.

Verified on the CPU with no device (job m3-max-83575): the color_write and words tests pass (79), the
golden table differs from development's (semantics 2334) in 109 cells, as at a535f1dc17, and the
refusal surface is unchanged; cargo fmt, clippy (plain, --cfg m2v_gpu, --cfg m2v_cpu_icd),
Rustdoc, the API reference check and the doctests pass; the suites pass 3740 of 3741 (24 skipped),
the one failure golden_hashes_match_the_table, bless due; the validation suite passes 1340 (3
skipped) and the conformance suite 1052. The states-only plays of this tree (m3-max-83669) make
what 126ee4fdf5's make (m3-max-83443): the gb-3090-r2 stream 10643 render and 15299 compute
states, the 780M windrag stream 8972 and 225, none refused.
2026-12-03 05:55:06 -08:00
Anees Iqbal 9aa7d9e7b0 Translator tests: a texture buffer's half-float and RG11B10Float words against Metal's at either mode
A texture buffer of a format a device holds as words (an R32_UINT view whose texels shaders convert)
is written by lower/texture/words.rs's write_texel. Write::half_up marks a fragment function's write
in a pipeline of textureWriteRoundingMode 2, but write_texel applies it to the RGB9E5Float word
alone: a half-float or RG11B10Float channel is rounded toward zero at either mode. Metal's texture
buffer rounds those to nearest even at mode 2, as its storage texture does: the conformance probe
texture_write_rounding_storage with texture buffers for targets, on an Apple M3 Max under macOS
27.0.1 (job m3-max-83395), matched toward zero on every channel at mode 0, and at mode 2 nearest
even on every channel that is not a NaN: an RGBA16Float channel past the largest finite value to the
infinity (262,112 of 262,112), an RG11B10Float one held at the largest finite value (196,583 of
196,583, for float texels and for texels rounded to half).

This adds a no-device test of the words against the probe's hashes, the way
rgb9e5_words_are_metals_at_either_mode holds the RGB9E5Float word, through the test hook
texture::written_words: lower/arith/tests/color_write.rs
half_and_small_float_words_are_metals_at_either_mode runs the words on the interpreter over the
probe's 65,536 texels and compares the FNV-1a hash of the words with Metal's at each mode:
RGBA16Float's texel (float texels) as RG16Float's words of red and green and of blue and alpha,
since RG16Float and R16Float are the half-float formats a device may hold as words and RGBA16Float
is not one, and RG11B10Float's (float texels and texels rounded to half).

At this commit the test fails at mode 2; mode 0 matches Metal.

Verified on the CPU with no device (job m3-max-83575): with words.rs at this commit the test fails
at mode 2, and half_and_small_float_words_convert_only_values_in_range passes.
2026-12-03 05:55:06 -08:00
Anees Iqbal aa2355716b Translator: a half-float or RG11B10Float texel held as words converts only values in range
lower/texture/words.rs's small_float_bits, which gives the codes of a half-float or RG11B10Float
texel a texture buffer held as words stores, computed every lane's denormal code (the lane's
value times 2^(14 + m), converted by OpConvertFToU) before a select kept it only for a denormal
lane. A normal lane of 2^(18 - m) or more (256 for a half float, 4096 for an 11-bit float, 8192
for a 10-bit one), and every infinity or NaN, reached the conversion past u32, which SPIR-V leaves
undefined; the select dropped what it gave, so no device was seen to store a wrong code, but the
module relied on an undefined operation for every such write.

Now a normal lane (an infinity and a NaN included) converts zero: the lane's magnitude bits are
selected to zero before the multiply, so every conversion takes a value below 2^m. A denormal
lane's code is unchanged, and the select still takes a normal lane's code from its exponent and
fraction. One select more per texel write.

SEMANTICS_VERSION moves above development's: the module of a write to a texture buffer held as
words changes.

Verified on the CPU with no device (job m3-max-83575): with words.rs at 16777dc811 the test
half_and_small_float_words_convert_only_values_in_range fails, the interpreter trapping
ConversionOutOfRange, and with this commit's words.rs it passes. The golden table differs from
development's (semantics 2334) in 109 cells at this commit and in 80 at 126ee4fdf5.
2026-12-03 05:55:05 -08:00
Anees Iqbal 5458510f15 Translator tests: a half-float or RG11B10Float texel held as words converts only values in range
A texture buffer of a format a device holds as words (an R32_UINT view whose texels shaders
convert) is written by lower/texture/words.rs's write_texel, whose half-float and RG11B10Float
codes come from small_float_bits. That function computes every lane's denormal code, the lane's
value times 2^(14 + m) converted by OpConvertFToU, before a select keeps it only for a denormal
lane. A normal lane of 2^(18 - m) or more (256 for a half float, 4096 for an 11-bit float, 8192
for a 10-bit one), and every infinity or NaN, reaches that conversion past u32, and SPIR-V leaves
OpConvertFToU of a value its result type cannot hold undefined, whatever a device returns for it.

This adds a no-device test and the hook it needs (texture::written_words, a write_texel of a
format held as words, under cfg(test) alone): lower/arith/tests/color_write.rs
half_and_small_float_words_convert_only_values_in_range writes RG16Float and RG11B10Float texels
of normal, past-largest, infinite and denormal lanes on the interpreter, which traps an
out-of-range conversion, and checks each texel's words against the format's codes.

At this commit the test fails: the interpreter traps ConversionOutOfRange on RG16Float's first
texel (256, -65504).
2026-12-03 05:55:05 -08:00
Anees Iqbal 7e8d556729 Translator: place_zero_address says where it places ZeroAddress unread
A read at an offset the memory plan proves one value is checked at emission only where its
emitted offset is not a constant, which placement cannot know, so the field follows every read
of a checked device-address slot and is placed unread where each such read's emitted offset is a
constant: 17 golden cells on Linux's profiles move for that (fragment_discard_hoist's
hoisted_written_read on 12, kernel_dynamic_cursor_across_a_call on 5; job m3-max-83594).

Moving the check decision into the plan (an access the memory plan proves fixed is not checked)
places the field exactly, but drops the in-shader check from every such access whose emitted
offset is not a constant: 90 golden cells moved (job m3-max-83613). That widens containment's
behaviour beyond this fix and is not taken here.
2026-12-03 05:54:55 -08:00
Anees Iqbal ba12a233ef Tests: the mixed-load sweep says why it covers every push field a strategy reads
The plan lists the fields it places; its strategies read theirs at emission, which refuses a read
of any field the plan did not place, so a compile that succeeds read none: the sweep checks every
field for its kernel, not ZeroAddress alone.
2026-12-03 05:54:55 -08:00
Anees Iqbal d27d09854d Runtime tests: the select load runs in the address form too, on every device
A device's description without pipelineRobustness makes its translator reach a kernel's buffers
at their device addresses, the form the unplaced ZeroAddress broke; the test asserts the form
and names it beside the device, so a run on a card that binds its kernels' buffers shows both.
2026-12-03 05:54:55 -08:00
Anees Iqbal b13f800a04 Tests: the mixed-load sweep takes a profile's typed refusal of the 64-bit atomic as its answer
moltenvk-m3 and runtime-floor lack shaderBufferInt64Atomics and refuse the kernel's typed
atomic, a typed refusal and not a placement failure (job m3-max-83546).
2026-12-03 05:54:54 -08:00
Anees Iqbal 237ed8d8c5 Runtime tests: a load through a select of a typed atomic's slot and another reads both slots on every device
The translator's ADDRESSED_AND_VIEWED kernel in one threadgroup of 64 through the runtime: the
atomics are exact, each load reads its slot's memory (1 to 64 for words[0], at most the sum for
wide's low word), and nothing past the last thread's word changes.
2026-12-03 05:54:54 -08:00
Anees Iqbal 423fbce843 Translator: ZeroAddress is placed where a read may be checked on a device-address slot
Under the identity domains a kernel whose load reaches a typed atomic's device-address slot or
another slot through one pointer select ended in the invariant 'a strategy reads the unplaced
push field ZeroAddress' on every committed profile in the address form (lavapipe, RADV, ANV,
NVIDIA's address form): the select's load is at an offset the memory plan proves constant, so it
noted no variable read and placed no ZeroAddress, but a store at a variable offset made its slot
checked, and the emitted load, whose offset is not a constant there, took the check and read
the zero range outside.

Placement now follows use. note_variable records every read's slot at any offset
(AccessPlan::read) and no longer places the field; place_zero_address decides it once the slots'
forms are final: placed where a slot of variable that a read reaches is in the device-address
form (a memory-plan slot or a pulled fetch's own source), and removed elsewhere, which subsumes
the bound form's removal where no checked slot was left.

SEMANTICS_VERSION 2342 -> 2343: the push layout of a kernel with such a read moves.
2026-12-03 05:54:54 -08:00
Anees Iqbal 2bd4f51c59 Tests: every push field a load through an address or a view reads is placed, on every identity profile (red)
Under the identity domains a kernel whose load may reach a typed atomic's device-address slot
or another slot ends in the invariant 'a strategy reads the unplaced push field ZeroAddress'
on some profiles. The test compiles and links ADDRESSED_AND_VIEWED on every committed profile
in the address form and the bound form and lists each that fails.
2026-12-03 05:54:54 -08:00
Anees Iqbal b5b1be55e0 Runtime: the device tests' failed allocation is no seam in the product
Core::fails_private stood in the product build as a method that always
returned false, called on every allocation; only its field was gated to the
device tests. The method now carries the field's cfg
(all(test, any(m2v_gpu, m2v_cpu_icd))), and allocate_spilling calls it only
in that cfg: the product build's first allocation is the plain allocate
call.

Verified in job m3-max-83684 (lavapipe): clippy of metal2vulkan-runtime with
all features (lib, bins, examples) and, under --cfg m2v_cpu_icd and
--cfg m2v_gpu, all targets, each EXIT=0; the product build's expanded source
(cargo rustc --lib -Zunpretty=expanded, 70,849 lines) holds neither
fails_private nor fail_private; the device tests that set the field,
tests::spill::on_device::every_device_spills_private_memory_out_of_device_memory
and tests::sites::on_device::every_device_counts_each_allocation_site_apart,
2 passed.
2026-12-03 05:54:54 -08:00
Anees Iqbal b01c896bf8 rt README: the RX 7900 XTX makes the extended linear image of a texture written through a view
The view-storage known gap lists the cards whose own linear query makes the extended image of a
2 by 2 RGBA8Unorm_sRGB texture written through its RGBA8Unorm view. The RX 7900 XTX (RADV NAVI31)
now answers too, from job m3-max-83587 at 13c13835b0, run through the device tests in
storage_element and copy_cause, all 5 passed:
- over a Shared block of the runtime's, None for both the viewed and the written texture, so it is
  made in place;
- over host memory's import, HostMemory, the copy every discrete card makes there;
- over a dma-buf's import, DmaBuf, as the RX 550 and the 780M answer;
- under the stand-in that refuses the extended image, ViewStorage, with the copy pair moving
  (2, 32), and in place refused for ViewStorage.

Docs only. The README is no runtime-sources input.
2026-12-03 05:54:54 -08:00
Anees Iqbal e28e41be55 rt README: which cards make the extended linear image of a texture written through a view
The known gap for OverCause::ViewStorage now names what the lab's cards answered, read from
every_device_lands_a_write_through_a_view_of_a_texture_over_a_buffer's own-query arm at 13c13835b0
for a 2 by 2 RGBA8Unorm_sRGB texture written through its RGBA8Unorm view, with PixelFormatView
usage and without:

- RTX 3090 (NVIDIA 620.70.06, job m3-max-83540) and RTX 2080 (job m3-max-83541): in place over a
  Shared block; HostMemory over host memory's import (discrete, so the external query is never
  asked); no memory type taken for a udmabuf.
- RX 550 (RADV, Mesa 26.2.6, job m3-max-83542): in place over a Shared block; HostMemory over host
  memory; DmaBuf over a dma-buf, with the stand-in and without, so not a refusal of the extended
  plan.
- Radeon 780M Phoenix (job m3-max-83545) and Hawk Point (job m3-max-83560): in place over a Shared
  block and over host memory's import; DmaBuf over a dma-buf as on the RX 550.
- Iris Xe (ANV, Mesa 26.2.6, job m3-max-83544) and lavapipe (job m3-max-83537): in place over all
  three.

So no lab card reached makes the plain linear image and refuses the extended one. The RX 7900 XTX
waited behind the consumer's GPU job, the RTX 5080 Laptop was held for a pin's round legs, and the
UHD 630 (Windows) was not reached; the README already records that the UHD 630's optimal query
makes no extended image, so its plan is never extended and this copy cannot arise there.
2026-12-03 05:54:54 -08:00
Anees Iqbal 440a65cddf Tests: the view-storage make test names its memories' type
Clippy's type_complexity under --cfg m2v_gpu and --cfg m2v_cpu_icd (job m3-max-83521) refused the
memories' inline tuple type; it is the alias Memory now.
2026-12-03 05:54:54 -08:00
Anees Iqbal b927c5c38a Tests: the view-storage make test asks a dma-buf's import too; the in-place test keeps its probes
every_device_lands_a_write_through_a_view_of_a_texture_over_a_buffer now also makes both textures
over a dma-buf's one import (Linux, through /dev/udmabuf, where the device imports dma-bufs and takes
a type for it), whose linear image the device's external query answers for the dma-buf's handle: the
answer it prints for each card is whether that query makes the image extended for the views'
storage. Under the stand-in the expected cause now follows the device's own answer over the same
memory: ViewStorage where its own was in place or ViewStorage, its own elsewhere (HostMemory over
host memory on a discrete device, a dma-buf's on a device without the foreign queue family).

every_device_refuses_in_place_alone_a_texture_whose_linear_image_stores_no_view failed on the RTX
2080 (job m3-max-83526): it compared the textures gauge across the refusals while the texture it had
just made to read the optimal image's usage was being freed by the reaper, which lowers the gauge
when it frees it. It now keeps each such texture until every make is refused, as copy_cause's test
keeps its textures. The same test passed on the RTX 3090 (job m3-max-83525) and lavapipe (job
m3-max-83492), where the free had landed first.
2026-12-03 05:54:53 -08:00
Anees Iqbal 52d9228512 RUNTIME_VERSION 2560: a texture over a buffer whose linear image is made plain alone for its views' storage is the counted copy
A run of an unchanged artifact may now do something else: where a texture over a buffer, planned
extended for its views' storage, had a linear image the device makes plain alone, the write through
the view that was Gap::StorageElement (Unextended) at dispatch now runs and lands through the counted
copy (OverCause::ViewStorage), and new_texture_in_place refuses that texture
(TextureNotInPlace { cause: ViewStorage }) where it made it plain in place. Main renumbers at
landing.
2026-12-03 05:54:53 -08:00
Anees Iqbal f1347e5d1f rt: a texture over a buffer whose linear image is made plain alone for its views' storage is the counted copy
Where a texture over a buffer was planned extended for its views' storage (Plan::extended: shader
writes, an own format the device does not store, and a listed view format it does, which the
optimal image format query took), and the linear image query (for the buffer's import handle where
it has one) refused the extended linear image or a listed format's linear tiling lacked the storage
features while the plain linear image held, check_over made the texture plain in place. A write
through the stored view then had no storage element: Gap::StorageElement,
StorageElementCase::Unextended at dispatch, and the guest's write did not land. Metal keeps it.

check_over now answers OverCause::ViewStorage there (Spilled where the block spilled), whatever made
the plan extended (PixelFormatView with ShaderWrite, or an 8-bit sRGB texture's unorm sibling with
ShaderWrite alone), and the plain-in-place fallback is gone. One decision serves all three calls:
Buffer::new_texture makes the counted copy (rule 3's existing clause for a format query that offers
no linear image for the format and usage), whose optimal image keeps the extended plan, so the write
lands and its copies count in over_copies_view_storage; new_texture_in_place and its fenced form
refuse with TextureNotInPlace { cause: ViewStorage }; texture_copy_cause answers ViewStorage. No new
form and no rule 2 clause. Over a buffer, Unextended is now reachable only where the optimal query
itself refuses the extended image (the copy's image takes that plan too), as for Device::new_texture.

Docs: the runtime README's extended-usage entry, the over-copy cause list, texture_copy_cause's
descriptor-only causes and a known gap naming ViewStorage's copies and their two counters; the
public docs of new_texture, new_texture_in_place and texture_copy_cause; View's unextended.
docs/REFUSALS.md and api_signatures.tsv regenerated, no change here; runtime-sources fingerprint
unchanged (pin-compute).
2026-12-03 05:54:53 -08:00
Anees Iqbal b9eb93c4c0 Tests: a write through a view of a texture over a buffer whose linear image is not extended lands (red)
A texture over a buffer that shaders write through a view of another format (PixelFormatView with
ShaderWrite, or an 8-bit sRGB texture's unorm sibling with ShaderWrite alone), whose own format the
device does not store, needs its image extended for that view's storage. Where the device's linear
image query refuses the extended image but makes the plain one, check_over makes the texture plain
in place, its view has no storage element, and the guest's write is Gap::StorageElement
(StorageElementCase::Unextended) at dispatch and does not land. Metal keeps it.

This commit adds what the fix needs to name and the tests that fail without it:

- OverCause::ViewStorage, with Metrics::over_copies_view_storage and
  over_copy_bytes_view_storage, counted like every other cause (the device-free over_causes test
  covers its pair; the replay player's metric list, its over-frames own-image part and the
  stream test's decline list name it). No code answers it yet.
- A device-test stand-in, Core's extended_linear_refused, which makes linear_extent answer no
  image for an extended plan, as a device whose linear tiling or external image query makes the
  plain image alone does. The field and its read exist only under
  cfg(all(test, any(m2v_gpu, m2v_cpu_icd))), as fail_private's field does.
- storage_element.rs: every_device_lands_a_write_through_a_view_of_a_texture_over_a_buffer (both
  textures, over a Shared block and host memory's import, with the device's own query, which it
  prints, and with the stand-in: the cause answered, the form made equal to it, the view-storage
  pair counted, the write through the RGBA8Unorm view landing in the buffer's bytes);
  every_device_refuses_in_place_alone_a_texture_whose_linear_image_stores_no_view
  (new_texture_in_place, without an index, and fenced: TextureNotInPlace naming the cause, no
  texture, no copy, no fence call); every_device_keeps_in_place_a_texture_over_a_buffer_that_
  shaders_do_not_write (PixelFormatView without ShaderWrite stays in place).

api_signatures.tsv blessed for the new variant and fields; docs/REFUSALS.md regenerated (no
change); the runtime-sources fingerprint is unchanged (pin-compute).
2026-12-03 05:54:53 -08:00
Anees Iqbal 14c37cc76d Bless at pin S: the golden hash table and the authored compile census
The golden hash table moves 50 rows, 154 cells, and its semantics line goes from 2334 to 2342.
150 of the cells are in the three ANV profiles that hold a texture buffer as words
(intel-irisxe-anv, intel-irisxe-rplp-anv and intel-uhd770-rpls-anv, 50 each), and 4 in
runtime-floor (a8r_buffers and tb_word_formats). Every moved subject reaches a texture buffer, as the
usage-keyed words (1c68dd10f4) do; ARL and every other profile are unchanged. The engine inventory
and the air_input printouts bless unchanged, and the metallib half of
committed_air_fixtures_parse_and_link passes on the M3's SDK (bless job m3-max-83447, at
126ee4fdf5; the commits after it touch only the validation crate's word scan).

The authored compile census recompiled every cell: 2369 cases, 9 profiles, 21,321 cells, 0 cached;
19,106 compiled, 2,215 refused, 0 failed, 0 regressions (census job m3-max-83675, on a Linux lab node
that holds a copy of the private corpus; its run at pin R, m3-max-83628, gave the M3's table at R
exactly, every artifact digest included). Its two differences are the helper-thread case's
new identity, f03c5415 replaced by aa05a38c3b41 (31b2964425); 111 rows move only their artifact
digests, and the artifacts_at line moves to this build.

The census's first run at 126ee4fdf5 (m3-max-83448) stopped 432 cells, the 48 linked
quantized-matrix-multiply cases on every profile, at the case worker's deadline: the output-word
scan hung at admission, which the three commits before this one fix.
2026-12-03 05:43:42 -08:00
Anees Iqbal 579badf5c9 Validation tests: the loop-carried pointer's phi lists its two steps before the buffer
What: the phi of a_pointer_a_loop_carries_on_two_paths_is_answered_once lists the pointers its
two steps carry before the buffer argument.

Why: the old recursion stopped reading a phi's arms at the first whose object differs from its
first arm's. With the buffer first, the first step's answer (the cut, through the cycle) differed
at once and the second step was never read, so the test passed on the old scan (red-green job
m3-max-83650, Linux: 2 of the 3 bounded tests failed red). With the steps first, the first two
arms both answer the cut, each read in full, and the old walk answers about 2^32 values.

Verified: nothing run at this commit yet; its red run puts output_words.rs at 6a2870813f.
2026-12-03 05:33:50 -08:00
Anees Iqbal 6de0ea00f9 Validation: the output-word scan answers each value once in base, address and affine
What: the scan's three recursive analyses (the object a pointer points into, a store's offset
from its buffer argument, and an integer affine in a grid component) each keep one answer per
instruction of the entry, filled by one iterative walk (solve) that reads each operand's answer
once. A value is answered from the module once a scan instead of once for every path to it.

Why: each analysis recursed into every operand with no memo, bounded only by depth 64. A select
or phi reads both arms and an add both operands, so a shared chain cost 2^depth answers, and a
pointer a loop carries on two paths through one phi cost about 2^32 per call. The 48 quantized
matrix-multiply cases of pin S's authored-compile census (432 cells) stopped at their 380 s
ceiling in the scan's admission, before any compile: a model of base() over the bisected case's
AIR counts about 1.8e11 answers in writes() alone, from eight calls through its loop-carried
pointer phis.

How the answers stay the same: the old cut (depth > 64 answers Base::Other or None) is absorbing
in every combination (a GEP or cast passes its operand's answer on, a select or phi of differing
objects is Other, and every affine and address step is None where an operand is), so the old
answer at depth 0 is the cut exactly where a chain of more than 64 links lies below the value,
and otherwise the uncut combination. The memo keeps each value's longest chain below it (capped
at 65) and answers the cut past 64. A value read again while it is being answered lies on a
cycle, whose chain has no end: it answers the cut, as the old recursion did where it ended. An
affine operator other than +, -, *, << and | is None without reading its operands, as before. No
version moves: the scan's answers are unchanged.

The visit counter (cfg(test)) counts one visit for each value an analysis answers from the
module; the three tests of the previous commit bound it at 1,000.
2026-12-03 05:30:46 -08:00
Anees Iqbal 6a2870813f Validation tests: the output-word scan answers each value of shared index and pointer chains within a counted bound
What: a cfg(test) counter of the values the scan's three recursive analyses (base, address,
affine) answer, which panics past the bound a test sets, and three tests over synthetic kernels
of our own: a GEP index built from 40 adds of the last link to itself, a store pointer through
40 and through 70 selects of one pointer, and a pointer a loop carries on two paths through one
phi. Each asserts the scan's answer (the placed store at 2^42 * tid bytes, the store into the
buffer, the unrooted pointer past 64 links and on the cycle) within 1,000 answered values.

Why: pin S's authored-compile census stopped 432 cells (the 48 quantized matrix-multiply cases
on all 9 profiles) at their 380 s ceiling with no compile, first bad commit e31bc61172 (main's
bisect). The scan's recursions answer a shared operand again for every path to it, bounded only
by depth 64: a model of base() over the bisected case's loop-carried pointer phis counts about
1.8e11 answers in writes() alone. These tests are red at this commit (the old walk passes the
bound) and turn green with the memo that follows.

Verified: nothing run yet at this commit; the red and green run is one Linux potluck job.
2026-12-03 05:27:03 -08:00
charlysound 9dd319e8f5 Use four-stage masks in device-gated runtime tests
The m2v_gpu clippy configuration exposed two test-only two-stage arrays. Match the encoder dirty mask and content-key sRGB mask to RENDER_STAGES; the library code and shader outputs are unchanged.
2026-12-03 13:56:57 +01:00
charlysound fdc6328454 Refresh mesh profile goldens and runtime source guards
Regenerate the complete owned-fixture table on GitHub hosted macOS 26 with Apple metal-as (run 47105329017, artifact 15720563051). The translator sources match ae1ea9f19 exactly. SEMANTICS_VERSION 2335 and RUNTIME_VERSION 2558 cover the queried mesh features and stage changes. The Linux suite passed 6118 of 6119 tests; its sole failure was this expected table refresh. Update the opened Vulkan feature-chain records and runtime source fingerprint for the same source.
2026-12-03 13:50:11 +01:00
Anees Iqbal 126ee4fdf5 Runtime: a restoring make waits for its restore's batch, not for a group's command buffers
A texture made in place over host memory's import on a unified device restores the bytes under
its image inside the make, and waits for the progress value Work::flush gives: the submit thread's
next submission's. Where a group goes at that turn, the flushed uploads went ahead of the group's
command buffers in the same batch, with one signal at the batch's end, so the make waited for the
guest's command buffers too. The consumer's walk on the Iris Xe saw restoring makes take up to
63.9 ms (9 spans of one photo-decode step, 67.4 ms in all) where the runtime's own makes take
about 3.5 ms.

Now a flush the host waits for (Work::flush, the staging waits, the surface and block ready
waits) marks its uploads awaited. Where a group's submission takes them, WorkState::close gives
them the progress value below the group's first, the value the flush returned, and submit has the
last of them signal it: their batch ends there, ahead of the group's, in the same vkQueueSubmit2.
The make waits for that batch alone. The pre-wait for the work already submitted is unchanged, so
a group submitted between that wait and the flush still lands ahead of the restore on the queue,
and the make still waits for it.

Two cases keep the group's signal:
- uploads that use memory another API shares (a surface plane or an exported block, held or read
  by the uploads' copies) signal no value of their own: that memory is the other API's again only
  at the first part's release, after the part's command buffers, so the wait is for the part's
  value, as before;
- a batch signals a timeline semaphore once (Vulkan 1.4, section 7.2), so where nothing follows
  the uploads in their part, parts gives the part's value in place of theirs.

A flush nobody waits for (the half-region staging flush, the release of held bytes) adds no batch:
its uploads go with the group's command buffers as before.

Docs: submit.rs's module doc and the flush docs; texture.rs's restore comment, RestoreFence and
Buffer::new_texture; Block::wait_until_ready and Surface::wait_until_ready; the runtime README's
restore paragraph, the fence's span, the known gap's span sentence and the two ready waits.

RUNTIME_VERSION moves to the next number above development's: a restoring make, a getBytes read
and the ready waits now end at the uploads' own batch.

Tests:
- restore_batch.rs each_device_returns_from_a_restoring_make_ahead_of_a_groups_command_buffers
  (the commit before this one) passes;
- plane_parts.rs uploads_with_a_value_of_their_own_end_a_batch_that_signals_it_once: uploads that
  signal their own value end a batch of their own ahead of the group's segment, and alone in their
  part they signal the part's value once.

runtime-sources.sha256 is unchanged (a92fe0a8): it covers none of the files this edits.

Verified:
- red, submit.rs at the commit before this one: restore_batch hangs and fails after 10 s, and
  plane_parts' new test fails (the uploads' value and the part's in one batch), on lavapipe
  (llvmpipe, LLVM 23.1.1, job m3-max-83370) and on the Iris Xe (RPL-P, ANV, job m3-max-83373);
- green: restore_batch passes, the make returning with the fill's command buffer Scheduled, and
  plane_parts 4 of 4, on both; the runtime's suite on lavapipe 985 passed (4 skipped), job
  m3-max-83370, and on the Iris Xe 987 passed (4 skipped), job m3-max-83383;
- job m3-max-83370: fmt, the signatures, clippy plain, with --cfg m2v_gpu and with
  --cfg m2v_cpu_icd, rustdoc, the private rustdoc and the API reference check passed; the suites
  3738 of 3739 passed (24 skipped), the one failure the golden table, a bless due on development;
  validation 1337 passed (3 skipped); conformance 1052 passed; the doctests passed.
2026-12-03 04:41:35 -08:00
Anees Iqbal b975709ed0 Runtime tests: a restoring make whose restore goes with a group's command buffers
A texture made in place over host memory's import on a unified device restores the bytes under
its image inside the make: the make flushes the upload that saves them, moves the image home and
writes them back, and waits for the progress value the flush gives (texture.rs). That value is the
submit thread's next submission's. Where a group goes at that turn, its command buffers ride in the
same batch behind the upload, with one signal at their end, so the make waits for them too. The
consumer's walk on the Iris Xe saw restoring makes take up to 63.9 ms where the runtime's own
makes take about 3.5 ms.

This adds a device test that puts the restore and a group's command buffer in one submission and
holds the group's batch back on the GPU, and the test hooks it needs, under the device cfgs alone:
- Work::pause and Work::resume hold the submit thread between passes;
- Work::flushing says whether a flush waits for the thread to send the uploads;
- Work::hold_next has the first segment of the next submission of a group's command buffers wait
  on the GPU for a timeline semaphore the test signals.

restore_batch.rs each_device_returns_from_a_restoring_make_ahead_of_a_groups_command_buffers: on
a unified device whose texture over the import is in place, the test pauses the submit thread,
commits a fill of a buffer of its own, makes the texture on a thread of its own until its restore
is flushed, holds the fill's segment behind the test's semaphore and lets the thread pass. The make
must return while the fill's command buffer has not completed. Ten seconds after the thread passes
again, the test signals the semaphore and fails.

At this commit the test fails: the make waits for the fill's command buffer. Verified with
submit.rs at this commit under the next commit's tests:
- on lavapipe (llvmpipe, LLVM 23.1.1), job m3-max-83370: "the make did not return within 10s
  while the fill's command buffer, in the same submission as its restore, waited for the test's
  semaphore";
- on the Iris Xe (RPL-P, ANV), job m3-max-83373: the same.
2026-12-03 04:41:35 -08:00
Anees Iqbal 4b328ca9e2 Validation: a fragment function's render-target words are fed by the colour it returns
What: the word scan (check::output_words) now follows a fragment case's render target to the
colour its entry returns for that attachment, as it already followed a kernel's output buffer to
its stores. Before, every render-target word was fed by Family::Unknown, so every recorded note
reached every word of every fragment case by fall-back.

How:
- The scan records a fragment entry's returned value by field (Stores::returned): the
  families of each lane of each field, joined over its returns. Where a return or a
  air.discard_fragment sits in a block that does not post-dominate the entry, every lane is also
  fed by every branch condition, as a conditional store is.
- A render target's words (render_target_words): each channel of a texel takes the families of
  the lane of the returned colour it holds (every lane where the colour has fewer lanes than the
  format has channels), with those of the entry's other live outputs that decide whether or how
  the write lands: a depth, a sample mask, a stencil reference, the second blend source. The
  facts repeat every texel (every word for a texel under four bytes); the word's lanes still come
  from the target's format. A target with no live colour from the entry (an imageblock writes
  it), an attachment index that is not a constant, a vertex case's observed render target, and a
  returned value the scan does not follow keep the fall-back.
- air.quad_is_helper_thread and air.simd_is_helper_thread feed Family::Group: whether a thread is
  a helper is its place in its quad, which FragmentSimdgroupGrouping and QuadsSplitByClipping
  concern. They fed Family::Unknown before.

Tests (check::output_words::tests): a_render_targets_words_take_the_returned_colours_operations
(the public case unclamped-and-clamped-lod-of-a-texture-selected-per-quad: red and green fed by
the texture queries and the position, blue and alpha by nothing, so a texture note reaches the
first two words of a texel and NativeDot none) and
a_helper_query_and_a_discard_feed_a_render_targets_words (helper queries and quad ballots feed
Group alone; a discard the position decides adds the position and its arithmetic). Both read
every word as Unknown without the change.

ENGINE_EXECUTOR_ABI is v216: rows record different word facts for fragment render targets, and
how their differing words are judged changed.

Verified (at 33873ab651, this commit's tree):
- Gate: fmt, clippy with --workspace --all-targets --all-features -D warnings plain, under
  --cfg m2v_gpu and under --cfg m2v_cpu_icd, and rustdoc -D warnings, all exit 0 (job
  m3-max-83339). Validation suite: 1339 passed, 3 skipped (job m3-max-83340); in the same job the
  two new tests pass, and both fail with output_words.rs and words.rs put back to the parent.
- The public cases (1,168), noted / matched only within bounds / mismatch cases (batch-words),
  before at 31b2964425 and after:
  - lavapipe (x86): 156 / 27 / 10 before (job m3-max-83318) and after (job m3-max-83341); every
    row keeps its outcome and gap; 15 rows lose their fall-back words. Cases with a word on the
    fall-back: 571 to 488; with a differing one: 37 to 22.
  - AMD Radeon 780M (RADV PHOENIX, Mesa 26.2.6): 171 / 24 / 16 before (job m3-max-83332), 170 /
    24 / 17 after (job m3-max-83385). Every mismatch is held by a gap, before (21) and after (22):
    no new mismatch. One row moves: three-color-inputs-tag-attachment (c261f487), from a noted
    difference to a mismatch held as ordered_fetch_within_draw. Its target is the r32_uint tag,
    tag * 5 + as_type<uint>(color.x) of the attachments it fetches: no half conversion feeds it,
    so NativeHalfConversion, which reached its 16 differing words only by fall-back, no longer
    excuses them; UnorderedFetchWithinDraw reaches them. Cases with a word on the fall-back: 605
    to 515; with a differing one: 58 to 33.

Landed with ENGINE_EXECUTOR_ABI vulkan-engine-v217 (renumbered above development's v216, the half-arithmetic family); docs/VALIDATION.md merged by hand with that change's half family wording. runtime-sources.sha256 unchanged (a92fe0a8).
2026-12-03 04:36:37 -08:00
Anees Iqbal a3c5682883 AGENTS.md: rule 3's first exception is a texture over a buffer of any storage mode
The planner's wording ruling of 12-03. Rule 3 named the linear-image exception for "a texture
over a Shared buffer", but the runtime takes the device's linear image in place over a buffer of
every storage mode (texture.rs check_over and over_descriptor; the runtime README's
Buffer::new_texture entry): Private, Managed (its device copy), Shared and the imports. Metal's
newTextureWithDescriptor:offset:bytesPerRow: aliases the buffer's bytes in every mode, and an
optimal image there would need a copy per use, which rule 3 forbids. So the code is right and
the sentence was narrower than meant. This is a wording correction, not a growth: still two
exceptions, no new form, no new copy. Rule 2's unified-memory clause is unchanged.

Found by the audit lane's read of rule 3 against the code at 6e83de343d; the planner read the
same sites at 9211eb3c10.
2026-12-03 04:29:37 -08:00
charlysound ae1ea9f199 Merge current master and preserve mesh stage binding variants
Resolve the upstream texture-buffer, render-offset and typed-refusal interfaces. Keep mesh metadata when pass attachments or stage bindings change; independent object and mesh masks cover all four render stages. The added CPU Vulkan regression exercises attachment removal and unaligned object/mesh buffers with direct and indirect draws. Twelve CPU mesh tests pass with private Lavapipe 26.2.6. Full merged-tree gates follow on the isolated fork development branch.
2026-12-03 13:22:15 +01:00
Anees Iqbal 9211eb3c10 Translator: half +, -, *, / and fma on the 16-bit instructions record NativeHalfConversion
Under the 16-bit float controls, a half +, -, * or / and a half fused multiply-add run on the
device's 16-bit instructions, between exact conversions. By the Vulkan spec their results are
Metal's. A driver's compiler may still compute them in float and leave them unrounded. Intel's
Windows driver 101.2145 on a UHD Graphics 630 does:

- A standalone tree of three 16-bit OpFAdds, or Fmas of a product, each decorated NoContraction
  under all three 16-bit controls, ran on 4,096 invocations. 2,284 sums and 4,080 products
  matched neither the half tree nor the float tree rounded once (job m3-max-83092).
- The Iris Xe under Mesa ANV 26.2.6 gave the half tree on every invocation (job m3-max-83093).
- In the runtime's quad test on the UHD, 112 of the 1,536 compared halves are the float chain
  rounded once at the store (job m3-max-82918).

Per the planner's ruling, the operation carries the static note on every device, with no device
check. narrow::computes_half_arithmetic looks in the emitted module for a 16-bit OpFAdd, OpFSub,
OpFMul, OpVectorTimesScalar or OpFDiv, or a GLSL.std.450 Fma. Where it finds one, the pipeline
records NativeHalfConversion, beside the conversion pair's existing cases. A Sqrt alone records
nothing, and neither does the simdgroup half tree's ClusteredReduce.

The note's reach in validation narrows to half arithmetic. Until now it reached every word fed by
any float family. The AIR word scan now feeds a new family, HalfArithmetic, beside the
operation's own family, from these operations:
- an fadd, fsub, fmul, fdiv, frem or fneg with a half result;
- a float cast whose result or operand is a half;
- a call of a modelled family whose result or an argument is a half.
NativeHalfConversion reaches only that family. A half word that only float arithmetic fed,
through a move, is no longer reached. The note stays unbounded at the word, now on the
comparison's stay-unbounded list with its reason. A driver may leave the chain unrounded and
round it once at the store, and with cancellation the two answers differ by more than the stored
value's ulps (40 codes measured on the UHD). How far rests on the operands, which a word does
not carry.

Docs:
- The note's API.md catalogue entry and its PrecisionNote doc said those operations "take no such
  rounding". They now say the operations record the note, and give the UHD 630 measurement beside
  NVIDIA's fold and RADV's fusion.
- The DeviceHalfDenormals entry points to it.
- VALIDATION.md names the half family among those the word scan reads.

Tests:
- engine_native_half: the controlled-conversion test's sum kernel now records the note, as every
  kernel there does.
- engine_float_call_notes sets the module-level note aside for 16-bit arithmetic, as it does for
  the conversion pair.
- half_simd_reductions accepts, where the quad pipeline records the note, a quad word whose
  every half is Metal's or the float operations rounded once. The model is the new devtools
  quads_once.
- In validation:
  - the scan's packed-halves test expects HalfArithmetic on the half word alone;
  - a words test shows the note reaching a half word only when half arithmetic feeds it;
  - the reach row is pinned.

SEMANTICS_VERSION 2340 -> 2341 (precision notes added).
ENGINE_EXECUTOR_ABI vulkan-engine-v215 -> v216 (the word scan feeds HalfArithmetic, and the
note's reach narrows to it).

Golden hashes: no cell moves. The cells hash the final SPIR-V, which the note does not touch.
Job m3-max-83293 (Linux) ran golden_hashes_match_the_table twice: at this change, and with
compile.rs and cache/mod.rs at f42e61aa84. Both failed with the same 2 changed-cell lines, 0
lines differing between them: development's table is due its own bless. The fixtures that need
metal-as were skipped on Linux.

runtime-sources.sha256 is unchanged: no edited file is a fingerprint input.

Note-bounds figures (noted / matched within bounds / mismatches over the 1,168 public cases),
each arm built in one job, at 702916d9d3 and at this change on it (6edabebff2):
- lavapipe (Mesa 26.2.4, LLVM 23.1.1; job m3-max-83272): 151 / 27 / 15 before and after;
- Radeon 780M (RADV PHOENIX; job m3-max-83273): 166 / 24 / 21 before and after.
Every case's outcome and bounded line is the same in both arms, so no row is new. Only the per-note
word attribution moves: NativeHalfConversion's noted words fall from 3,267 to 1,168 on lavapipe and
from 3,558 to 1,276 on the 780M, as other notes reaching those words now take them.

Verified, at the probe db2bceb3f6, whose tree is this commit's (gate job m3-max-83293):
- the four red tests pass here and three fail with compile.rs at f42e61aa84 (EXIT=100);
- STEP clippy_plain EXIT=0, clippy_gpu EXIT=0, clippy_cpu EXIT=0;
- doc EXIT=0, privdoc EXIT=0;
- the translator's and AIR's suites minus the bless-due tables: EXIT=0;
- on lavapipe (host Mesa 26.2.6):
  - runtime: 983 passed, 4 skipped; half_simd_reductions 0 differ in all three pipelines;
  - validation: 1338 passed, 3 skipped, the runtime-sources guard among them.
- The conformance replay in the pinned lavapipe image (CI's venue, LLVM 23.1.1), at f42e61aa84
  and at this change (job m3-max-83337): 0 ledger drift in both arms, 4661 rows as expected.
  On the gate job's host lavapipe (Mesa 26.2.6, LLVM 23.1.4) its replay printed 12 drift lines,
  the bicubic-texel-classes rows among them. That run has no base arm.

The device legs of the half test:
- UHD Graphics 630, Intel's Windows driver 101.2145, at 6edabebff2 (this change on 702916d9d3;
  job m3-max-83288): every_device_sums_and_multiplies_half_simdgroups_as_metal passed.
  - The quad pipeline records NativeHalfConversion. 0 of 768 words differ from Metal's, and 96
    more are the float result rounded once.
  - The simd and masked pipelines: 0 differ.
- Apple M3 Max, KosmicKrisp (Mesa 26.3.1), at db2bceb3f6 (archive m3-max-83294, run
  m3-max-83297): passed. 0 words differ in each pipeline and none takes the rounded-once
  admission.

Landed with SEMANTICS_VERSION 2342 (renumbered above development's 2341); runtime-sources.sha256 recomputed on development, unchanged (a92fe0a8). States-only plays at the change (job 83345): gb-3090-r2 render 10643 and compute 15299 made, 0 refused; windrag-780m-b4 render 8972 and compute 225 made, 0 refused, equal to pin R.
2026-12-03 04:14:29 -08:00
Anees Iqbal e87fdd5a23 Tests: a half +, - or * on the 16-bit instructions records NativeHalfConversion (red)
Under the 16-bit float controls a half sum, product or chain is the device's 16-bit OpFAdd or
OpFMul between exact conversions. Intel's Windows driver 101.2145 on a UHD Graphics 630 computes
such operations in float and leaves them unrounded: a standalone tree of three of them came back
at float precision (jobs m3-max-83092 on the UHD 630 and m3-max-83093, the Iris Xe under Mesa ANV
26.2.6, as the control). The planner ruled that the operation carries the static note,
NativeHalfConversion, on every device.

The tests now expect that note:
- native_half_rounding_records_its_kind: on the half sum, on lavapipe and on RADV;
- nvidia_computes_half_on_16_bit_floats_under_the_float_controls: on each of the 16-bit
  kernels.

Red until the product records it.
2026-12-03 04:14:21 -08:00
Anees Iqbal 6e83de343d Translator: under the identity domains a slot's element of its set-1 array is its own-pixel binding
StageModule::own_pixel_textures lists the fragment function's texture slots whose every texel
read is at the fragment's own pixel. The runtime reads it for the copy form of attachment reads:
on a device without the attachment feedback loop, a draw that reads its own pass's target
through such a slot copies the rectangle of its scissor, a pixel wider each way, into the
target's shadow, and through any other slot the whole level and layer (crate::shadow).

The analysis seeded the slots from their descriptor variables. Under the identity domains, which
the runtime ships, no variable holds one slot's image: the image is the element of its class's
set-1 array at the low word of the resource ID that PushField::SlotGuestBase pushes. So the list
was empty for every function, and every such draw copied the whole level and layer, beyond what
Metal copies (rule 3).

Now the analysis also seeds a slot from each access chain into a set-1 image array whose first
index is the slot's ID's low word: OpAccessChain(array, CompositeExtract(OpLoad(OpAccessChain(push
block, member)), 0)), the member being the slot's SlotGuestBase. The ID's parts may go nowhere
else: the member's pointer only to its load, the ID only to an extract of its low or high word,
and the low word only to such an access chain's first index or to an equality test (the nil
test). Any other use leaves the slot out (a store, arithmetic, a phi, a select, a call, an access
chain into the member's words). So does a slot whose ID the stage reads from its parameter block,
or whose levels a run of the array holds (TextureLevelBase), since those reads reach the array
through no binding the analysis follows. The analysis takes the stage's push placement for this.

SEMANTICS_VERSION moves to the next number above development's: a stage's interface answers
differently.

Tests:
- pipeline/compile/tests.rs the_interface_states_the_textures_read_at_the_fragments_own_pixel
  now runs every profile under the identity domains too, the clamped form included: tob_read
  states slot 0, and tob_sample, tob_read_buffer and tob_solid state none. At the base, under
  identity, tob_read stated none.
- spirv/requirements/own_pixel/tests.rs under_the_identity_domains_a_slots_element_is_its_binding,
  on hand-built modules: an own-pixel fetch through a slot's element qualifies; an element only
  size-queried reads no texel; the ID stored, its low word plus one indexing another element, its
  low word loaded through an access chain into its member, a TextureLevelBase field and an ID in
  the parameter block each leave the slot out.

Verified on the CPU with no device and on lavapipe (llvmpipe, LLVM 23.1.4), job m3-max-83281 at
this commit:
- red, own_pixel.rs, its tests and compile.rs at the base: the compile test fails at its
  identity rows;
- green: the compile test, the own_pixel, compile and link tests, 142 of 142; the runtime's
  attachment-read, over-read, held-loop, shadow and translator-field tests on lavapipe, 18 of 18
  (lavapipe reads through the feedback loop, so its copy form is not exercised there);
- the refusal surface check, fmt, the signatures, clippy plain, with --cfg m2v_gpu and with
  --cfg m2v_cpu_icd, rustdoc, the private rustdoc and the API reference check passed; the suites
  3737 of 3738 passed (24 skipped), the one failure the golden table, which fails at the base on
  the same 80 cells (a bless due on development); validation 1337 passed (3 skipped);
  conformance 1052 passed; the doctests passed.
The change in copied bytes on a device without the feedback loop is not measured: no runtime
test draws under a scissor smaller than the target there.
2026-12-03 04:13:32 -08:00
Anees Iqbal d0fb4f3381 Translator: delete StageModule::level_reads, which nothing reads
StageInterface::level_reads and StageModule::level_reads stated, per texture slot, the levels of
its bound view the stage's reads reach (LevelReads, SampledLevels, SamplerLevels and the
structural analysis spirv::requirements::level_reads). Nothing reads them:
- the runtime: git grep -nw -e level_reads -e LevelReads -e SampledLevels -e SamplerLevels
  -e finite_texels -e highest_lod -e lowest_lod at 401d9d5949 over every crate but the translator
  finds one hit, the runtime's translator_fields test, which lists the field as a fact the runtime
  does not apply;
- the consumer: the same search at a20576e1fd finds 0 hits.
Under the identity domains, which the runtime ships, the analysis also seeded nothing, since no
variable holds one slot's image there. Rule 4: deleted rather than seeded.

Removed: the two fields, the three public types with their methods, the analysis and its tests,
their codec entries and footprint, their rows in tests/api_signatures.tsv and the api_surface
table, the API guide's "Levels a slot reads" section and HOWTO's mention of it, and the runtime
test's listing. own_pixel's helpers that the analysis shared are private again.

ARTIFACT_FORMAT_VERSION moves to the next number above development's: StageInterface's and
StageModule's encodings lose a field. No translation answer changes, so SEMANTICS_VERSION stays.

Verified on the CPU with no device and on lavapipe (llvmpipe, LLVM 23.1.4), job m3-max-83281 at
the next commit, which holds this one: fmt, the signatures, clippy plain, with --cfg m2v_gpu and
with --cfg m2v_cpu_icd, rustdoc, the private rustdoc, the refusal surface check and the API
reference check passed; the suites 3737 of 3738 passed (24 skipped), the one failure the golden
table, which fails at the base on the same 80 cells (a bless due on development); validation 1337
passed (3 skipped); conformance 1052 passed; the doctests passed.
2026-12-03 04:13:32 -08:00
Anees Iqbal 31b2964425 Validation observation: Metal's row of the simdgroup fills over a 7x7 target's cut quads
Qualified on the Apple M3 Max under macOS 27.0.1, three executions (job m3-max-83312):
aa05a38c3b41, output sha256 de1a61a9.

Every word is a real lane's: all 196 words (49 pixels, four fills each) equal what the packing
model reads from an active lane (8x4 blocks from (0, 0), quads row by row, a quad's lanes row by
row; a lane runs when its quad holds a covered pixel), and no fill reads an inactive lane. Each
value is one of those lanes' x + 64y or its filling data, 10000 more. Over the old 7x5 target, the
same model read lane 31 of the lower block, which ran no thread, for (0, 4)'s fill up by 1.
2026-12-03 04:02:13 -08:00
Anees Iqbal d071e32f79 Validation case: the simdgroup fills over cut quads draw a 7x7 target, whose every fill reads an active lane
The case simdgroup-fills-in-a-fragment-function-over-cut-quads (engine/gsm2_quad_ops,
fragment_simd_fills) drew a 7x5 target. On the M3 Max a simdgroup holds an 8x4 pixel block,
its quads row by row; the lower block's rows 4 and 5 fill lanes 0 to 15, and lanes 16 to 31 run
no thread. simd_shuffle_and_fill_up by 1 at pixel (0, 4), lane 0, reads lane 31's filling data:
a read of an inactive lane, which MSL 4.1 section 6.10.2 leaves undefined ("A thread needs to
only read data from another active thread in the SIMD-group"). Metal answered 0.0 there, which no
lane holds; lavapipe and the Radeon 780M answered the pixel's own fill, 10256. It was the one
differing word of the ten helper-thread cases that none of the four mechanisms explains.

At 7x7 the last column and row are still quads the target cuts, and each 8x4 block holds a
covered pixel in every quad, so all 32 lanes of both blocks run. A model of the M3's packing
(8x4 blocks from (0, 0), quads row by row, a quad's lanes row by row), checked against the
committed Metal rows, reproduces every word of the 8x8 case (256 of 256) and every word but
(0, 4)'s first of the 7x5 one (139 of 140); over a 7x7 target it reads no inactive lane in any
of the four fills, where the 7x5 target read one. The case's rationale states the undefined read.

Installed with corpus-case-check (job m3-max-83299): the new identity is
aa05a38c3b411ed862539df3e52691addc8e8b612e1d80e4b8425284cb73045d, and the old identity's Metal
row is removed. Its Metal qualification follows in the next commit. The authored compile census
still lists the old identity, for the next bless.
2026-12-03 03:55:29 -08:00
Anees Iqbal f42e61aa84 Docs: the helper-thread words' four mechanisms, and what a split quad's helper query answers
The read of the ten cases held as helper_thread_words (lavapipe, job 83263; Radeon 780M, jobs
83264 and 83267) explained 454 of their 455 differing words by four mechanisms: Apple's partial
quads, lavapipe's clip seam, RADV's lane order and x86 lavapipe's 8-lane subgroup. The docs said
otherwise in two places:

- QuadsSplitByClipping said each run of a split quad combines fewer active lanes than Metal's.
  Each piece's run keeps all four lanes; what differs is the helper query, which names the other
  piece's covered pixels as helpers where Metal's quad, shaded once, names none. The note's doc
  comment, its API.md catalogue entry and the validation gap's doc now say that.
- FragmentSimdgroupGrouping gains the fill past a subgroup under 32 lanes: it reads an inactive
  lane, which MSL 4.1 section 6.10.2 leaves undefined, and the device reads the calling lane in its
  place (lower::simd's PartialFragment read).

docs/VALIDATION.md's verdict section names the four mechanisms and what lavapipe and the 780M do
under each, where the next reader of a held case looks. The gap's doc in c3.rs no longer says the
cause is unread.

Docs and doc comments only. pin-compute.py over the tree gives the committed runtime-sources
fingerprint (artifact.rs is not one of its inputs), so no re-pin. cargo fmt --all is clean.
2026-12-03 03:48:23 -08:00
Anees Iqbal f0077ea01b Translator: an identity fetch of an A8Unorm colour held in red reads Metal's alpha through its view
Under the identity domains, a fragment function reads a colour attachment through the
sampled-texture array's element pushed for it (PushField::FetchedColor). That element is the
texture's own view, the shadow's or the feedback loop's. On a device without an A8_UNORM image,
an A8Unorm texture is held in R8_UNORM, and its view has the components (ZERO, ZERO, ZERO, R)
(metal::format, the A8Unorm candidate). Vulkan's Component Swizzle applies them to every texel
input instruction, a fetch included. So the element already reads Metal's (0, 0, 0, a).

lower/fragment/color.rs still applied the input attachment's alpha-in-red conversion to that
read, (0, 0, 0, texel.r), and recorded the colour in StageIo::alpha_in_red_colors. A guest saw
two things on such a device (lavapipe, intel-arl-anv, intel-irisxe-anv, amd-rdna2-apu-radv,
nvidia-pascal-linux, nvidia-rtx50-linux and runtime-floor among the committed profiles; the device
check below prints how the device it runs on holds the format):
- A function that reads an A8Unorm colour and also writes it read (0, 0, 0, texel.r), and the
  view's red is 0: alpha 0, a wrong value (on lavapipe at the base, the device check below read
  (0, 0, 0, 0) at texel (0, 0)).
- A function that reads one and never writes it was refused at link with
  NeedsInput(ColorWrites), which nothing answers. color_writes::wanted_alpha_in_red counts
  written colours and input attachments, and an identity fetch is neither.

Now the identity read takes no conversion and records nothing (ColorInput::alpha_red is false
under the identity domains). The input-attachment read of the resident domains keeps its
conversion, since an input attachment's view takes no swizzle. Link's set and the function's then
agree, and link is unchanged.

The extended-range half of the same link check is a docs line: an identity fetch of an
extended-range attachment is refused by the lowering and by link, so no shader reaches
wanted_extended_range's omission of FetchedColor colours. color_writes' docs of both wanted_*
functions now say why a FetchedColor read is in neither set.

SEMANTICS_VERSION moves to the next number above development's: a refusal goes and a fetch's
answer changes.

Tests:
- pipeline/compile/tests.rs an_identity_fetch_of_an_alpha_held_in_red_reads_through_the_view: on
  lavapipe's profile (no A8_UNORM image), without the pixel interlock, under the identity policy,
  fetch_blend with an A8Unorm colour 2 that it reads and never writes links. Colour 2 is read
  through FetchedColor, no input attachment is used, and every stage passes spirv-val. At the base
  it is refused NeedsInput(ColorWrites).
- metal2vulkan-runtime tests/fetch.rs every_device_fetches_an_a8unorm_attachment_as_metals_alpha
  (device check): a pass clears an A8Unorm target to alpha 51/255. a8r_fill writes 204/255 over
  the lower left half. a8r_fetch reads the attachment at every texel and stores what it read, and
  every texel must read (0, 0, 0, a) of its own alpha.

Verified on lavapipe (llvmpipe, LLVM 23.1.1), which holds A8Unorm in R8_UNORM (the check prints
"A8Unorm held as Ok(AlphaInRed)"), job m3-max-83219 at this commit:
- red, lower/fragment/color.rs at the base: the structural test refused
  NeedsInput(ColorWrites); the device check read (0, 0, 0, 0) at texel (0, 0).
- green: the structural test, the compile tests and engine_fragment passed; the runtime's fetch
  tests on lavapipe, 7 of 7, the device check reading Metal's (0, 0, 0, a) at every texel.
- the refusal surface check, fmt, the signatures, clippy plain, with --cfg m2v_gpu and with
  --cfg m2v_cpu_icd, rustdoc and the private rustdoc passed; the suites 3738 of 3739 passed (24
  skipped), the one failure the golden table below; validation 1323 passed (3 skipped);
  conformance 1052 passed; the doctests and the API reference check passed.
- the golden table fails at this commit and at its base alike, on the same two cells
  (a8r_buffer_read_write and tb_word_formats on runtime-floor): a bless due on development, none
  of it this change's.

Landed with SEMANTICS_VERSION 2340 (renumbered above development's 2339); runtime-sources.sha256 recomputed on development, unchanged (a92fe0a8).
2026-12-03 03:43:38 -08:00
Anees Iqbal f683293b4b Docs: a fetch may read the texel from before its draw, so overlapping read-modify-writes leave one
UnorderedFetchWithinDraw's words said a pixel that overlapping fragments of one draw fetch and
write "holds the result of some order of the draw's fragments", "not necessarily Metal's". The
Radeon 780M (RADV, Mesa 26.2.6) shows otherwise. Job m3-max-83259 ran the eight authored cases
the ordered_fetch_within_draw gap holds (n instances of the companion's fullscreen triangle in
one draw, so n identical fragments at every pixel or sample) five times at 702916d9d3. All five
outputs were identical. Every differing word is the fragment function applied once to the
texel as it stood before the draw. Each case's chain f^k(initial), computed from its own inputs,
gives Metal's stored output at k = n on every word, and the 780M's at k = 1 on every word that
differs, all four lanes of each texel alike. All n fragments are identical, so every order of
them gives Metal's value: the 780M's value is no order's result. Lavapipe matches Metal on the
seven cases it runs (job m3-max-83255).

The note now says what a fetch can observe there: it may read the texel from before its draw,
so overlapping read-modify-writes of one draw may leave one application. Changed in docs/API.md's
precision-note catalogue, PrecisionNote::UnorderedFetchWithinDraw's doc comment and the runtime
README's known gap. Docs only, no behaviour change. The runtime-sources pin is unchanged
(pin-compute.py gives a92fe0a8...).

Verified: cargo fmt --all; nothing built.
2026-12-03 03:35:47 -08:00
Anees Iqbal 702916d9d3 Validation: helper-thread words and ordered fetch are answer gaps a row's words decide
FragmentSimdgroupGrouping, QuadsSplitByClipping and
UnorderedFetchWithinDraw only record a device behaviour now: none of
them excuses a word. The cases whose differing words they reach turned
from noted differences into mismatches, and nothing held them open, so
a round's public leg would read them as new mismatches. Two answer
gaps now hold them open. Both are decided by structure (the note and
the words its operations reach), never by case id:

- HelperThreadWords (helper_thread_words): every unexcused word is
  reached by FragmentSimdgroupGrouping, or every one by
  QuadsSplitByClipping.
- OrderedFetchWithinDraw (ordered_fetch_within_draw): every unexcused
  word is reached by UnorderedFetchWithinDraw.

How:
- For each only-recorded note, the word judge counts the unexcused
  words that note reaches (Judgement::recorded).
- AnswerGap::held_by_words picks the gap one of whose notes reaches
  every unexcused word of a mismatch, where both outputs have one
  length. The engine's difference_status calls it for a mismatching
  verdict, and the batch-run line names the gap (held_open_by=).
- Every device has both gaps, since why the device's words differ is
  not read yet. The reviewed list refuses an entry under either gap.
- A row's content check accepts such a gap only on differing bytes from
  a run that recorded one of its notes, and status_holds re-derives the
  gap from the row's words.
- C3 names a word gap as a mismatch's reason after a deferral and after
  a listed gap.
- docs/VALIDATION.md states both gaps.

ENGINE_EXECUTOR_ABI stays vulkan-engine-v215, above development's v214.

The three figures, public cases (1,168): noted cases / cases that
match only within bounds / mismatches, then how many mismatches an
answer gap holds and how many are new.
- lavapipe (Mesa 26.2.4 image):
  - before, development 965e707277, job m3-max-83220: 188 / 0 / 5;
    5 held, 0 new.
  - after, job m3-max-83166: 151 / 27 / 15; 15 held (5
    clipped_primitive_split, 10 helper_thread_words), 0 new.
- Radeon 780M (RADV PHOENIX, Mesa 26.2.6, the device pinned alone):
  - before, development 22861fde72, jobs m3-max-82940 and
    m3-max-82966: 206 / 0 / 5; 5 held, 0 new.
  - after, job m3-max-83177: 166 / 24 / 21; 21 held (5
    clipped_primitive_split, 8 helper_thread_words, 8
    ordered_fetch_within_draw), 0 new.

The after runs ran this commit's library code. Only a C3 test changed
after them.

Verified (tests at this tree):
- gate A, m3-max-83232: fmt check, clippy plain, --cfg m2v_gpu and
  --cfg m2v_cpu_icd, and rustdoc each exit 0.
- gate B, m3-max-83236: the validation suite exits 0, 1337 passed,
  3 skipped. Each red check exits 100 with its fix reverted: the
  engine's word-gap hold, the judge's recorded-note count, the
  denormal boundary, the note reach, the recorded rule-5 notes and the
  recorded review notes.
2026-12-03 03:27:51 -08:00
Anees Iqbal 41712a1ec5 Translator docs: NativeNanEncoding covers a NaN's payload moved through loads, stores and selects
What: NativeNanEncoding's rustdoc and its docs/API.md catalogue entry say what validation now
reads it as covering: a NaN's payload moved through loads, stores and selects as well as one an
operation computes. Validation excuses a word in any float lane only where Metal's answer and
the device's are both NaNs of the lane's format.

Why: the planner accepted reading the note as reaching every float lane, bounded to two NaNs.
The public case nan-model-loads-stores-and-selects-of-nan-halves differs on lavapipe only in
half NaN payloads its entry moves without an operation (e.g. Metal 0x7e01 against 0x7e00,
m3-max-82836), which the note's own text already records at every read of a half from its bits.

Text only: no output and no recorded note changes, so SEMANTICS_VERSION stays; artifact.rs is
not a runtime source input.
2026-12-03 03:27:51 -08:00
Anees Iqbal 0def48a4f6 Validation: every note whose doc keeps a difference a mismatch for review is only recorded
What: the notes whose rustdoc says "a difference stays a mismatch for review" are Recorded in
the allowance table, as rule 5 made QuadsSplitByClipping and DeviceInterpolation:
ExtrapolatedInterpolation, FragmentSimdgroupGrouping, BlendedWriteRounding,
CoverageReadsRoundedAlpha, DeviceAlphaCoverage, RotatedBlendRounding, HalfOutputPrecision,
DevicePointSize, LoopedSampleOutputs, NativeLogicOperation and UnorderedFetchWithinDraw (whose
doc says it without "and no explanation"). ViewBaseTexelOffset, DeviceColorConversion,
LinkedSamplerNumbering and DeviceInterpolationOffset already were. A word they reach that
differs is a mismatch unless another note excuses it.

C3's deferral of a near-equivalent (FragmentSimdgroupGrouping, BlendedWriteRounding,
CoverageReadsRoundedAlpha, RotatedBlendRounding among them) reads the run's recorded notes
(ExecutedCensus::all_notes) rather than the unbounded class, which no longer names a recorded
note: a row that ran one stays open as before.

The review-sentence lines of the note docs drop their design citation ("deferred in C3", "which
C3 names"), and the table's rows say what each note records. The NativeNanEncoding row says it
covers a payload moved through loads, stores and selects (the reach the previous commits gave
it), and the DeviceDenormals row lists the operations measured to keep a denormal.

Why: the planner ruled that rule 5 applies to every note carrying the sentence; the code read
them as unbounded, so a difference they reached was a noted difference against their docs.
ClippedCoverageSplit says "no tolerance and no explanation" but not "a mismatch for review", and
its cases are held open through it; it is unchanged.

Verified on lavapipe (Mesa 26.2.4, the lavapipe image), the 1,168 public cases, job
m3-max-82941 (this tree with the next commit's doc text) against m3-max-82873 (rule 5 alone):
ten cases are mismatches, every differing word of each on the fall-back; eight of them were
noted differences that FragmentSimdgroupGrouping explained: 1daf00c7, 243237a9, 8926b0e1, aa65ed07, b1f22cbf, c8195f48 (helper threads),
8aac224c and f03c5415 (simdgroup fills); 524be944 and 60db147e are rule 5's. Two runs
of that job ended in a device wait timeout under the host's load (2e81b17c, 35d576e0) and are
rerun at the tip. Each note's row is tested (every_precision_note_has_its_table_row), and a red
check that turns NativeLogicOperation back to Unbounded fails it.
2026-12-03 03:27:51 -08:00
Anees Iqbal 31231e3d67 Validation: QuadsSplitByClipping and DeviceInterpolation keep a difference a mismatch
What: both notes' rows of the allowance table are Recorded, as their rustdoc states
("Validation derives no tolerance and no explanation from it: a difference stays a mismatch for
review"): a word they reach that differs is a mismatch unless another note excuses it. The
table's doc rows, its test rows, the C3 test of a DeviceInterpolation row (its class is the
census's, Exact) and a word test of both notes follow.

Why: the code read both as unbounded, so a difference they reached was a noted difference,
against the documented contract.

Verified on lavapipe (Mesa 26.2.4, the lavapipe image), the 1,168 public cases, job
m3-max-82873 (this tree) against m3-max-82854 (the tree before it): match 773 -> 773,
noted_difference 161 -> 159, mismatch 5 -> 7. Red, both render targets whose words every note
reaches (the fall-back), where only QuadsSplitByClipping explained them:
- 524be944 helper-threads-in-a-fragment-function-over-full-quads: 32 of 256 words, Metal 0
  against the device's 0xe or 1 (25:00000000/0000000e, 29:00000000/00000001, ...);
- 60db147e helper-threads-in-a-fragment-function-over-cut-quads: 20 of 140 words
  (17:00000000/00000008, 49:00000000/00000007, 113:0000000c/0000000e, ...).
The other seven cases these two notes excused first stay noted under another note that reaches
the same words: six helper-thread cases under FragmentSimdgroupGrouping, and
memory-write-per-sample-4x under NativeHalfConversion. Tests: m3-max-82874 (137 passed, the
touched modules).
2026-12-03 03:27:51 -08:00
Anees Iqbal 2c61e4fc52 Translator docs: NativeFma states that an unfused half product can overflow
What: NativeFma's rustdoc and its docs/API.md catalogue entry state the one case its recorded
bound does not cover: an unfused product can overflow where Metal's fused result is finite, and
the overflow stays the device's answer. A 16-bit product of magnitude 65520 or more rounds to
the infinity of its sign, so the result is that infinity where Metal's is finite, or a NaN
where the addend is the infinity of the other sign and Metal's result is that infinity.

Why: the bound (half an ulp of the product plus half an ulp of the result) read as covering
every input; the public cases fused-multiply-add-rounding-and-fmuladd-without-fast-math and
fused-multiply-add-rounding-and-contraction-under-fast-math show the other answer on lavapipe:
fma(256.0h, 256.0h, -65504.0h) is inf where Metal answers 32, and fma(65504.0h, 65504.0h,
-inf) a NaN where Metal answers -inf (job m3-max-82667's rows against the committed Metal rows
of the Apple M3 Max). No lowering changes; the note stays unbounded in validation.

Text only: no output and no recorded note changes, so SEMANTICS_VERSION stays. artifact.rs is
not a runtime source input, so runtime-sources.sha256 stays.
2026-12-03 03:27:51 -08:00
Anees Iqbal e31bc61172 Validation: a precision note excuses only the words its operations feed, within its bound
What: a candidate's output is judged against Metal's one 32-bit word at a time
(observation_contract::words). An equal word matches. A differing word is excused only by a
recorded note that reaches it: a note with a bound makes a word within it a match, a note with
no bound makes it a noted word, and a word no reaching note excuses is a mismatch.

- Reach is read from the case's AIR (check::output_words): for each output word, the float
  lanes it holds and the operation families whose results feed it, followed byte by byte
  through bitcasts, lane moves and the zext/shl/or that pack two halves. A store placed at
  A * thread_position_in_grid + B bytes gives each thread's words their own facts. A note of the
  module that writes the output reaches the words its operations feed; a note of another module
  reaches every word, and so does every note of a word the scan cannot follow (a load of memory
  the entry writes, a call outside the intrinsic families).
- Bounds a word can carry are checked there, and a word within one matches: DeviceDenormals
  only where Metal's and the device's lanes both lie at or below the smallest normal (2^-126,
  2^-14 for half), of one sign unless one is a zero; NativeNanEncoding only two NaNs of the
  lane's format (it reaches every float lane: a half read from its bits is no operation);
  HalfTexelConversion its recorded one half ulp, or +-65504 beside the infinity; the lane
  tables and the reassociation bound as before.
- NativeFma, NativeDot, NativeMix and NativeDivision keep no value bound (each states its bound
  over the operands, which a word does not carry) and reach only the words their operations
  feed. The fixture knows its inputs, so a per-case bound from the operands is a later form.
- SimdgroupAccessOrder reaches only a word another thread of the kernel may write: one a store
  the scan cannot place in its own thread's bytes writes.
- Rows record the output's word facts (census output_words). The batch report prints, per case
  and in total, the words matched exactly, within each note's bound and only noted, by note,
  the unexcused words, and the cases with a word on the fall-back.
- DeviceDenormals's rustdoc states Metal's measured answer per operation: it flushes before
  rounding on some (a product, fma, dot and mix just below 2^-126 answer a zero) and keeps a
  denormal on others (sin, tan, asin, sinh, asinh, atanh of a denormal), from the public cases
  float-products-flushed-before-rounding and nan-model-float-denormals-per-operation. Its
  recording rule already covers plain multiplies; no rule changed.

ENGINE_EXECUTOR_ABI is v215: how a match is decided changed and rows record word facts.

Why: a noted difference was excused whole by any recorded note, so a note that could not cause
a word's difference (a division's note beside a product, an access-order note on a kernel whose
threads write disjoint words) hid it, and a bounded note never matched.

Verified on lavapipe (Mesa 26.2.4, the lavapipe image), the 1,168 public cases, job
m3-max-82854 (this tree with the next commit's doc text) against m3-max-82667 at b3d7464945: match 746 -> 773, noted_difference
188 -> 161, mismatch 5 -> 5 (each held open by clipped_primitive_split, as before); words
2,859,015 exact, 30,212 within a bound, 352,820 noted, 0 unexcused. Of the 188 cases noted
before, 34 have an output word on the fall-back (26 every word) and 32 a differing one.
Tests: the validation suite at an earlier tree, m3-max-82839 (1,331 passed, 3 failed; the three
are fixed here), and the touched modules at the same tree as m3-max-82854, m3-max-82855 (136
passed).
2026-12-03 03:27:51 -08:00
Anees Iqbal 1c68dd10f4 Texture buffers: a read-write one is words where its format's own view reads none without a format
A texture buffer's form (rule 2's texture buffer formats, metal::format::texel_buffer_form) asked
three accesses of a format's own view: a uniform texel buffer, a storage texel buffer, and a storage
texel buffer written without a format. A function that reads a texture buffer through
access::read_write reads its storage element without a format, which Vulkan asks of the view's
format (VK_FORMAT_FEATURE_2_STORAGE_READ_WITHOUT_FORMAT_BIT, VUID-vkCmdDispatch-OpTypeImage-07030),
so on a device whose own view of a format lacks that bit the runtime refused the draw or dispatch
(Gap::StorageElement, ReadWithoutFormat). ANV on the Iris Xe (RPL-P) lacks it for BGRA8Unorm,
B5G6R5Unorm, BGR5A1Unorm and BGR10A2Unorm (jobs m3-max-81883, m3-max-82116); its committed profile
(intel-irisxe-rplp-anv) answers the same for RG11B10Float, RGB10A2Unorm and RGB10A2Uint, and so do
intel-irisxe-anv and intel-uhd770-rpls-anv for all seven (job m3-max-82025). Holding those formats
as words for every texture buffer would cost one made to be read 31.6% and 31.7% on that Iris
(texel_buffer_bgra8_read and texel_buffer_b5g6r5_read, job m3-max-82136).

The form now asks a fourth access, the storage read without a format, only of a texture buffer
whose usage, fixed at its making, holds both MTLTextureUsageShaderRead and
MTLTextureUsageShaderWrite, or is MTLTextureUsageUnknown (metal::format::texel_buffer_read_write):
Metal lets a function reach a texture buffer through access::read_write only where its usage holds
both. texel_buffer_form(pf, usage, profile) is one answer per format and usage per device; one made
to be read or written alone keeps the three-access answer. On the three ANV profiles the seven
formats move to words for such a texture buffer and nowhere else. AGENTS.md's rule 2 says so in
the same commit: the three accesses, plus the storage read without a format for a texture buffer
made with both usages, one answer per format and usage per device; it is still one query-chosen
form, and the count of fourteen is unchanged.

The word says the usage, as it says the format, so a shader that meets a texture buffer through a
handle, as one at a slot, tells which answer holds: bit 11 of a texture buffer word of a format
with a word layout, TextureWord::TEXEL_BUFFER_READ_WRITE, is set where it was made both to be read
and to be written. It lies within the 14 low bits an argument buffer's handle carries
(HANDLE_WORD), and the word stays the same on every device. The translator holds the codes a
profile holds as words per usage (WordCodes: alone, read_write); the words twin's held test tests
bit 11 beside the code only where some format is words for the one usage and not the other
(read_write & !alone), and where the two sets are equal the test and the module are what they
were. The runtime asks texel_form of the texture's usage at its making, and
Device::minimum_texture_buffer_alignment, Metal's query of a format alone, answers the larger of
the two forms' alignments: on the three ANV profiles (uniform offset alignment 1, storage 16, a
single texel enough for both) B5G6R5Unorm and BGR5A1Unorm go from 2 to 4 bytes (a word against a
2-byte texel), and BGRA8Unorm, BGR10A2Unorm, RG11B10Float, RGB10A2Unorm and RGB10A2Uint stay 4;
every other profile's two forms are equal, so its answer is unchanged (computed from the committed
profiles' limits, not measured apart).

Public contract, in this commit: TextureWord::of_texture_buffer(pixel_format, width, usage),
texel_buffer_form(pf, usage, profile), the new texel_buffer_read_write and
TextureWord::TEXEL_BUFFER_READ_WRITE (api_surface, api_signatures.tsv); docs/RESOURCE-ID.md's bit 11
row, its texture buffer word section and its test vectors: tests/resource_words.tsv gains a usage
column, each format with a word at read (1) and read-write (3) usage with its widths, and at write
(2) and unknown (0) at width 1. Consumer search: reims-vgpu at 4f46e27e3b (main's) and at its
current e447795571 (mine): no guest computation of words; of_texture_buffer, texel_buffer_form,
TEXEL_BUFFER_ and resource_words have no hit, and TextureWord's one hit is link-order.txt, a symbol
order list naming TextureWord::of. The runtime README's known gap now says the read is served for a
texture buffer made with both usages, and keeps the measured words' cost scoped to those; its form,
alignment and words-cost paragraphs, docs/API.md and docs/REPLAY-STREAM.md name the usage.

The zero for amd-rdna2-apu-radv, intel-arl-anv and nvidia-pascal-linux is unaudited: those
committed profiles report all 39 word formats as words, so no format can move there by this rule
(main opens a row to re-record them).

SEMANTICS_VERSION 2339 (development holds 2338): the words twin's module on the three ANV profiles
and the form's answers move. RUNTIME_VERSION 2558: a texture buffer's form, its word and the
alignment the runtime answers move. runtime-sources.sha256 re-pinned (metal/format/texel_words.rs
and metal/format/mod.rs are runtime inputs). docs/REFUSALS.md does not move (refusal_surface.py
--check passed).

Verified at 0cbe4dfc70, a commit of this same tree on a try branch (tree dd16b6a2f7):
- red: the test before this one (rebased here as 5900eb8642), at ed24bac82a, job m3-max-83041 on
  the Iris Xe (RPL-P, Mesa 26.2.6): every_device_runs_texture_buffers_made_to_be_read_and_written_at_every_slot
  failed with B5G6R5Unorm, BGR5A1Unorm and BGR10A2Unorm "not dispatched", the read-written slot's
  ReadWithoutFormat refusal;
- the Iris Xe (RPL-P, Mesa 26.2.6), the runtime's texture buffer tests (--cfg m2v_gpu, filter
  test(texture_buffer)), job m3-max-83121: 12 run, 12 passed; the new test alone, job m3-max-83127,
  passed, every one of the 15 formats answering the CPU's at every slot. It asserts, per texture
  buffer made, that the words gauge (Gauges::word_texture_buffers) moved exactly where the form
  answers words for its usage, and that the words twin ran once per dispatch where one bound is
  words; every_device_reads_and_writes_texture_buffers_of_formats_held_as_words printed
  B5G6R5Unorm, BGR5A1Unorm and BGR10A2Unorm "own view; made to be read and written, words: every
  answer the CPU's", where they were refused before;
- the Iris Xe, rt_replay's texture_buffers_play_with_their_recorded_ids_and_the_cpu_s_texels
  (--cfg m2v_gpu), job m3-max-83115 (at 9eb68e9c2c, which differs from this tree by a test
  helper's name in the runtime's texture_buffer_words.rs alone): BGRA8Unorm and B5G6R5Unorm play
  as "own view, read_write words" with the recorded IDs (each word with bit 11 where made to be
  read and written), the CPU's texels and values, where the play ended in the refusal before;
- the Intel UHD 630 (Windows driver 101.2145, validation layer 1.4.363.0), job m3-max-83145 (the
  win-cross build m3-max-83134): the runtime's whole suite, 985 run: 984 passed, 1 failed, 4
  skipped; every_device_runs_texture_buffers_made_to_be_read_and_written_at_every_slot and
  every_device_reads_and_writes_texture_buffers_of_formats_held_as_words passed. The one failure,
  half_simd_reductions' every_device_sums_and_multiplies_half_simdgroups_as_metal, fails the same
  way at pin Q (m3-max-82853) and at 2e9f9866be (m3-max-83061) and is outside this change;
- job m3-max-83128 (Linux): the runtime's, devtools' and harness's suites 280 run, 280 passed, 2
  skipped; validation 1323 run, 1323 passed, 3 skipped; conformance 1052 run, 1052 passed;
  doctests; on lavapipe (--cfg m2v_cpu_icd) the runtime's texture buffer tests 12 run, 12 passed,
  and rt_replay's texture buffer play passed, every format the same form for both usages there;
- the Linux gate, job m3-max-83122: cargo fmt --check, signatures --check, refusal_surface.py
  --check, clippy -D warnings (plain, --cfg m2v_gpu, --cfg m2v_cpu_icd) and rustdoc all clean;
  the translator's and AIR suites 3459 run: 3458 passed, 1 failed, 22 skipped, the one failure
  golden_hashes_match_the_table, a bless due of 80 cells under 2339 (the 78 below and
  development's own 2); the runtime guard (the_runtime_sources_are_the_committed_ones) passed;
- golden cells (job m3-max-83165: the golden test's every changed cell at this tree and at
  development's 401d9d5949, the same build, listed in full): 26 cells move on each of
  intel-irisxe-anv, intel-irisxe-rplp-anv and intel-uhd770-rpls-anv (every fixture that reaches a
  texture buffer: a8r_buffers, abt_descriptor_sets, hlf_half_buffer, hsw_storage_writes,
  kernel_read_through, ob1_texel_buffer, rlm_runtime_limits, tb_word_formats, texture_ops'
  texel_buffers, tob_renders, trh_forward, unk_size_queries,
  kernel_texture_variant_leftovers, kernel_write_one_dimensional_textures), and 0 on each of the
  other twelve committed profiles (amd-780m-hawkpoint-radv, amd-780m-radv, amd-rdna2-apu-radv,
  gate-lavapipe, gate-lavapipe-x86_64, intel-arl-anv, lavapipe, moltenvk-m3, nvidia-pascal-linux,
  nvidia-rtx50-linux, nvidia-rtx5080-laptop, runtime-floor): there the two code sets are equal and
  the module is what it was. Development's own two due cells (runtime-floor's a8r_buffer_read_write
  and tb_word_formats) are the same at both. The .air.ll rows need macOS's metal-as and were not
  compared. The table is re-blessed on development;
- the authored compile census (jobs m3-max-83117 at 9eb68e9c2c and m3-max-83118 at
  401d9d5949, checks; m3-max-83148, a bless in its own workspace at this tree, diffed): 0
  differences and 0 failures at both, 21321 cells; 14 artifact digests move, every one on
  intel-irisxe-rplp-anv (a C3 venue), 0 on gate-lavapipe and amd-780m-radv, against 0 at
  401d9d5949;
- the bit test's cost where nothing moves, on the Iris Xe (exclusive, job m3-max-83168): the
  release harness of 401d9d5949 (before, and a copy of it, before2) against this tree's (after),
  built by job m3-max-83124, 8 rounds of 500 runs each, the arms' order rotating: the read-only
  own views texel_buffer_bgra8_read and texel_buffer_b5g6r5_read take a GPU p50 (median of the 8
  rounds) of 9009.0 us and 9215.8 us after against 9009.0 us and 9215.6 us before, +0.00% each,
  before2 against before -0.01% and 0.00%; every run matched its CPU reference.
2026-12-03 03:22:23 -08:00
Anees Iqbal 53c5fde63f rt test: texture buffers made to be read and written run at every slot on every device (red)
A texture buffer made with both ShaderRead and ShaderWrite usage, of each of the 15 formats a
device may hold as words, at each of tb_word_formats' slots (read, written, read and written),
must run on every device and answer the CPU's decode: where its format's own view reads none
without a format (the buffer features lack STORAGE_READ_WITHOUT_FORMAT), such a texture buffer
is to be held as words. Then texture buffers made to be read alone and written alone over the
same bytes must agree with it: the read-alone one reads what the read-written usage wrote, the
write-alone one writes the codes. The words twin must run exactly where a bound texture buffer
is held as words, read from Gauges::word_texture_buffers at each making.

Expected red on ANV's Iris Xe: B5G6R5Unorm, BGR5A1Unorm and BGR10A2Unorm are held as their own
views there, whose read through access::read_write is Gap::StorageElement (ReadWithoutFormat), so
the first dispatch is refused. Expected green on the UHD 630's Windows driver, which already
holds every one of them as words.

run() takes the thread values from the shared thread_values.
2026-12-03 03:22:23 -08:00
Anees Iqbal efb6f79cba Conformance ledger: the KosmicKrisp venue's blend rows say the blend is in the shader there
On the Apple M3 Max venue (KosmicKrisp, Mesa 26.3.1), 82 blend rows carried the other venues'
text: that metal2vulkan-runtime "leaves the blend to the device's fixed-function unit". These are
the 73 half-output-blends-* rows (1mdc-one, ba-1mba, bc-1mbc and the rest) and the 9 argb8-targets-*
rows.

KosmicKrisp has no fixed-function step there: it blends in the fragment shader itself.
kk_lower_fs_blend runs NIR's nir_lower_blend (kk_shader.c), and Metal compiles the result under
fast math. Each row now says so. Its answer, count and bound are unchanged, and so is its note,
device-color-conversion.

docs/CONFORMANCE-COVERAGE.md was regenerated with coverage.py and did not change.

The KosmicKrisp replay at this commit (Apple M3 Max, job 83202) reports 0 unexpected lines.
2026-12-03 03:14:44 -08:00
Anees Iqbal 5eeeb8d752 Conformance ledger: the KosmicKrisp venue's 30 held lines, each under its read cause
The Apple M3 Max venue (KosmicKrisp, Mesa 26.3.1) held 30 lines after its re-record, kept back
until their causes were read. Each now has a row whose text names that cause:

- a2c and a2one, 8 texel sites: KosmicKrisp computes alpha-to-coverage in the fragment shader with
  NIR's nir_lower_alpha_to_coverage (kk_shader.c, msl_nir_lower_common.c). The mask is Mesa's
  mapping, not Metal's. Note device-alpha-coverage.
- half-output-blends-r32f sa-1msa: KosmicKrisp blends in the fragment shader (kk_lower_fs_blend,
  nir_lower_blend), compiled under Metal's fast math, so the products round in Mesa's order.
  Note device-color-conversion.
- pixel-downscales frac/slot digests, 7 sites: ours, not the device's. The slot's pixel
  coordinate goes to the normalized sampler as coordinate over size (pixel-sampler-scaling). The
  norm control matches Metal on this venue.
- The venue's 11 downscale frac/slot head and tail rows, landed with the earlier re-record, now
  carry the same "ours" text in place of "the device's own answer".
- pixel-samplers rgba8 and rgba16f linear-mirror, slot and arg, 4 sites: ours, the same scaling
  under mirrored repeat. KosmicKrisp maps mirrored repeat to Metal's own mode, and norm and const
  give Metal's digest.
- texture-buffer-fill-groups, -fill-streams and -long-fills: KosmicKrisp's
  minTexelBufferOffsetAlignment of 16 (KK_MIN_TEXEL_BUFFER_ALIGNMENT) refuses the offset-4 texture
  buffer typed (Refusal::TextureBufferAlignment), before the fillTexture step.
- texture-fills-41: A1BGR5Unorm is not made on this venue.
- texture-fills-236: KosmicKrisp offers ASTC HDR, so the case reaches fillTexture (Unavailable).

Those five cases' every-venue rows split into llvmpipe, NVIDIA, RADV and Intel rows, since
KosmicKrisp answers otherwise there. In the split texture-fills-236 rows, "on any venue" now
reads "on this venue". docs/CONFORMANCE-COVERAGE.md is regenerated (coverage.py).

Answers taken from the KosmicKrisp replay of job m3-max-82902. The KosmicKrisp replay at this commit
(Apple M3 Max, job 83133) reports 0 unexpected lines. docs/CONFORMANCE-COVERAGE.md re-run with
coverage.py on development: unchanged.
2026-12-03 03:06:36 -08:00
Anees Iqbal 401d9d5949 Translator: an extended-range 3D texture's linear mip filter blends its two levels, under BicubicFilterArithmetic
A BGR10_XR or BGRA10_XR form's (or _sRGB twin's) 3D sample under a linear mip filter now blends
its two levels' 3D filters as a 2D sample blends its levels: the device's FMix at the clamped
level's f32 fraction, through a constexpr sampler and through a runtime sampler whose word states
the filter. It records PrecisionNote::BicubicFilterArithmetic, as every level blend does
(the runtime sampler's under its linear-mip clause). Metal's blend of a 3D texture's two levels
fits no rule tried; the XR mip probe (an Apple M3 Max on macOS 27.0.1) put the closest 284 of
8,192 samples apart. The note's doc and its catalogue line in docs/API.md now state this, with a
new measure committed as crates/metal2vulkan-conformance/probes/extended_linear_mip_blends.m (the
M3 Max, macOS 27.0.1, job m3-max-82944). At 16,384 lanes per form, filter (nearest, linear) and
shape, Metal's own two levels' samples blended by mix at the fraction truncated onto
sixty-fourths lie within 0.033 of Metal's 3D linear-mip sample of BGR10_XR, BGRA10_XR and their
twins, and within 0.031 of its 2D sample, the blend the module has shipped. The module blends at
the f32 fraction instead, which moves its blend by under 1/64 of the two levels' difference from
that rule.

The select_extended doc no longer lists a 3D texture's linear mip filter among the refusals.

Before this change:
- A constexpr sampler's linear mip filter on such a 3D texture was refused
  NotImplemented(Format).
- A runtime sampler's linear mip filter on one had no refusal at all. The emitted sample read the
  nearest level, and its comment named "the binder's refusal", which no binder or runtime code
  makes (ResourcePlanner::extended_sampler no longer exists).

The same gap holds for a 2D sample of a form whose levels' blend is not built (another XR form,
ExtendedRange::blends_levels false) through a runtime sampler that states a linear mip filter. That
case is left to the oracle measure that will build it.

Red test: tests/engine_extended_range/volumes.rs volume_linear_mip_filters_blend_two_levels
replaces volume_linear_mip_filters_and_padded_forms_are_refused. A constexpr linear mip filter
compiles, valid, with the note. On the CPU interpreter, a runtime sampler's linear-mip sample at
64 levels between two lies, on every lane, between the nearest mip filter's samples of those two
levels, and strictly between on some. A padded form's 3D sample stays refused. At the base, the
constexpr case is refused, and the runtime sampler's sample is one level's.

SEMANTICS_VERSION moves to the next number: a refusal is removed and a sample's words change.

Landed with SEMANTICS_VERSION 2338 (renumbered above development's) and runtime-sources.sha256 4361761c, recomputed on development.
2026-12-03 02:55:10 -08:00
Anees Iqbal 6191bf763d Translator: mode-2 fragment storage writes run: Metal's RGB9E5Float word, the device's half and RG11B10 rounding
Under TextureWriteRoundingMode::NearestEven (Apple's textureWriteRoundingMode 2) every fragment
storage write now runs; the refusal NotImplemented(PrivateRenderState(TextureWriteRounding)) and
the facts RuntimeFact::StorageTextureWriteRounding and HeapWriteRounding are deleted.

Measured first, by the probe committed here as
crates/metal2vulkan-conformance/probes/texture_write_rounding_storage.m (an Apple M3 Max under
macOS 27.0.1, jobs m3-max-82793 and m3-max-82824): a fragment function writes 65,536 texels of
float and of half texels into RGBA16Float, RG11B10Float and RGB9E5Float storage textures, once in
a pipeline of mode 0 and once of mode 2. Mode 0 rounds every channel toward zero. Mode 2 rounds
a half-float channel to nearest even, a value past the midpoint above 65504 to the infinity
(262,112 of 262,112 non-NaN channels); an RG11B10Float channel to nearest even, held at the largest
finite value (196,583 of 196,583, float and half texels alike); and an RGB9E5Float texel's
mantissas half up under the largest clamped channel's exponent, moved up where that mantissa
rounds to 512, which is Vulkan's own rule for the format (65,536 of 65,536 texels, float and half
alike). Every mode-2 code lies within one unit of mode 0's.

- RGB9E5Float: the word is the module's own arithmetic (texture::rgb9e5_word), so under mode 2 it
  is now Metal's mode-2 word exactly: the product times 2^(25 - e) converted toward zero keeps the
  half's bit, one added and a shift right round half up, and a largest mantissa of 512 moves the
  exponent up before every mantissa is rounded again. Write::half_up carries it to a
  SharedExponentBits slot's write (emit::to_image) and WordsPlan::half_up to the texture-buffer
  words' write routine. A kernel, tile or other function, a word attachment and the default mode
  keep the truncation.
- RG11B10Float, float and half texels: the device's conversion as at the default mode, recorded
  as PrecisionNote::DeviceColorConversion (unconditionally for a declared format, under
  small_float_storage's clauses for a formatless slot or a heap). A half-float channel's note for a
  float texel stays half_storage_facts's. The note's storage clause and its catalogue line in
  docs/API.md state the measured counts.

Red tests:
- lower/arith/tests/color_write.rs rgb9e5_words_are_metals_at_either_mode: the emitted word, run
  in the SPIR-V interpreter over the probe's 65,536 texels (probe_texels rebuilds them from the
  probe's SplitMix64; its input and half hashes are checked against the probe's), hashes (FNV-1a)
  to the texture Metal wrote, bit for bit, for float and half texels at either mode. It is red with
  the half-up arm disabled.
- tests/engine_link.rs mode_two_fragment_texture_writes_round_as_metal_or_the_device replaces
  mode_two_refuses_fragment_texture_writes_it_would_round. It draws over an RGBA32Float attachment,
  whose output records no note (the previous test's RGBA8Unorm attachment recorded
  DeviceColorConversion itself, which made the earlier commit's note check vacuous). Every case
  compiles and links valid at either mode. A declared R16G16B16A16 slot records
  DeviceColorConversion at both modes, a B10G11R11 slot under mode 2 alone, and an RGB9E5 word
  slot at neither. It is red with the product files at the base, which refuse.

Public surface: PrivateRenderField::TextureWriteRounding and the two RuntimeFact variants are
removed (api_signatures.tsv rows). The consumer's checkout at a20576e1fd has 0 hits for
PrivateRenderField, StorageTextureWriteRounding or HeapWriteRounding (git grep). The mechanism
test's variant indices move StencilBitDraws and RobustStorageBuffers into the two freed places.
docs/REFUSALS.md is regenerated.

Not in scope, a follow-up: a texture buffer of half-float or RG11B10Float held as words
(texel_buffer_form) converts by the module's own toward-zero routine, recorded under the same note.

SEMANTICS_VERSION (refusal removed, notes and words under mode 2) and ARTIFACT_FORMAT_VERSION (two
RuntimeFact variants removed from the codec) each move to the next number.

runtime-sources.sha256 re-pinned (4361761c): the edited translator sources are runtime inputs.

Landed with SEMANTICS_VERSION 2337 (renumbered above development's) and runtime-sources.sha256 4361761c, recomputed on development.
2026-12-03 02:55:10 -08:00
Anees Iqbal a03b74c95c Translator: a fragment float write to a half-float or RG11B10Float storage texture under mode 2 is the device's conversion
Under TextureWriteRoundingMode::NearestEven (Apple's textureWriteRoundingMode 2), a fragment
function's float texel written to a storage texture whose slot declares a half-float or
RG11B10Float format was refused NotImplemented(PrivateRenderState(TextureWriteRounding)). It now
runs with the device's conversion, as at the default mode, and records
PrecisionNote::DeviceColorConversion: Metal's mode 2 rounds such a channel to nearest even
(RG11B10Float held at the largest finite value), the device's store toward zero on every measured
driver. The half-float note comes from half_storage_facts, which every float write runs; the
RG11B10Float note from mode_rounded_write, under the clauses of small_float_storage (unconditional
for a declared format, by the bound format for a formatless slot, by the heap's small-float family
for a heap element). The note's storage clause in artifact.rs and its catalogue line in docs/API.md
state the mode-2 case.

The writes whose mode-2 rounding was not measured keep the refusal: a float texel into
RGB9E5Float, and a half texel into RG11B10Float or RGB9E5Float. RuntimeFact::
StorageTextureWriteRounding and HeapWriteRounding stay for a slot whose bound texture decides and a
heap handle, their docs narrowed to those cases; their field `halves` (a float texel, which also
refused half-float textures) is renamed `float`, since a half-float texture no longer refuses
(api_signatures.tsv's two variant rows follow). The consumer's checkout at a20576e1fd has 0 hits
for StorageTextureWriteRounding or HeapWriteRounding (git grep).

Fixed with it: a slot declaring RGB9E5Float through its word alias (R32_UINT,
StorageImageClass::SharedExponentBits, the choice every profile makes for the format) was not
seen as a mode-2 target at all, so under NearestEven it compiled with the default's word, no
refusal and no mode recorded. It now records the mode and is refused under NearestEven, as a
declared E5B9G9R9_UFLOAT_PACK32 was.

SEMANTICS_VERSION 2333 -> 2334: a refusal class changes (mode-2 storage writes), and a fragment
stage writing an RGB9E5Float word slot now records the mode in StageIo.

Red test: engine_link's mode_two_refuses_fragment_texture_writes_it_would_round gains a
SharedExponentBits case (refused under mode 2) and expects the declared R16G16B16A16_SFLOAT and
B10G11R11_UFLOAT_PACK32 cases to compile under mode 2 with DeviceColorConversion, no fact, and to
link valid.

runtime-sources.sha256 re-pinned (2ac17122): lower/texture/mod.rs and the other edited sources
are runtime inputs.

Landed with SEMANTICS_VERSION 2336 (renumbered above development's) and runtime-sources.sha256 2ac17122, recomputed on development.
2026-12-03 02:55:02 -08:00
charlysound ee0737b246 Implement native task and mesh execution with bounded indirect grids
Publish the locally validated source tree on a dedicated experimental branch.
Original validation source: d26b3cbe01669894959cdb96e8627a81d79d4b6a.
Base: 0b0ac58eb0.
Published with the account no-reply identity; local history is unchanged.
2026-12-03 11:53:34 +01:00
Anees Iqbal 965e707277 Conformance ledger: the Apple M3 Max venue (KosmicKrisp) re-recorded, but the sites still to be read
The M3's conformance replay on KosmicKrisp (Mesa 26.3.1) at 6989666062 (job m3-max-82902; the
product of development's 13c6ba8a91, which adds one rt test change) printed 269 lines the ledger
did not expect. The venue had 14 rows; every other row it held was another venue's or every
venue's. This commit records what is mechanical and leaves the rest as it is.

- 197 rows added at sites another venue already lists: 158 with that venue's answer, 39 with the
  same answer but for its numbers. Each takes that venue's gap text, except 18 whose text named
  another device:
  - 6 indirect-range cases: KosmicKrisp does not list VK_EXT_device_generated_commands;
  - 11 pixel-downscales frac sites: the device's sampler, within the 2/255 recorded on lavapipe;
  - 1 half-tanh site: the other venue's first-element values are dropped.
- 14 every-venue rows (astc-*-hdr zero-blocks/texture) split into llvmpipe, NVIDIA, RADV and Intel
  rows. KosmicKrisp makes ASTC HDR textures (textureCompressionASTC_HDR in kk_physical_device.c),
  so the M3 now matches Metal there.
- 1 M3 row removed: discard-quad-sum-placement hoisted_known/pipeline, which the venue now reads as
  lacking the feature.
- 15 rows added for refusals no venue listed, each from a device query:
  - 10 surface-textures cases: KosmicKrisp exports no dma-buf, opaque fd or Win32 memory;
  - 2 lines and facing draws: no fillModeNonSolid;
  - 3 A1BGR5Unorm textures (fresh-pattern-41, extended-swizzles-a1bgr5unorm,
    texture-round-trip-41): not made for the usage.
- 6 bicubic-texel-classes M3 rows: the answer is the one the 780M, RX 550, RTX 5080, RX 7900 XTX
  and Iris Xe rows record. The M3 answers it since the Converted half pair is decorated
  NoContraction (699f1167d6).

Left as they are, to be read first (30 lines):
- alpha-to-coverage texels: a2c-* and a2one-*, 8;
- pixel-downscales frac digests, 7;
- pixel-samplers linear-mirror sites, 4;
- texture-buffer fills refused off KosmicKrisp's 16-byte texture-buffer alignment, with
  texture-fills-41 and -236 (5), plus the 5 every-venue rows they no longer hold;
- half-output-blends-r32f sa-1msa, 1.

docs/CONFORMANCE-COVERAGE.md regenerated (scripts/conformance-coverage/coverage.py).
Verified: the edit is derived from that replay's lines; the conformance suite and a replay on the
M3 with this ledger are in the READY note.
2026-12-03 02:50:42 -08:00
Anees Iqbal edb02c7f38 Translator: SEMANTICS_VERSION 2335 for texture-buffer slots declared without a format
Rebased onto development 13c6ba8a91, where 699f1167d6 (a Converted half rounding's conversion
pair decorated NoContraction) took 2334. The previous commit's own bump, 2333 to 2334, is
upstream's line now, so the rebase left it out; this change, a refusal that becomes a module
(Unsupported{IdentityDomains} for a texture buffer's slot without a format), takes 2335.

The previous commit's jobs ran at 1db43f3bd8, the same change on development 22861fde72 under
2334: red m3-max-82957, Iris Xe m3-max-82971, UHD 630 m3-max-82977, Linux gate m3-max-82968,
golden diff m3-max-83023. This tip's own gate and UHD 630 leg are named in the lane's report.
2026-12-03 02:50:42 -08:00
Anees Iqbal 1ae0e3c302 Translator: under the identity domains a texture-buffer storage slot is declared without a format
Under the identity domains no input names a storage slot's bound format. storage_format declared
a slot without a format only where shaderStorageImage{Read,Write}WithoutFormat grant its
accesses, or where the formats' own bits grant its read (reads_by_format_bits: the neutral
R32_SFLOAT and every read-write tier format's view carry STORAGE_READ_WITHOUT_FORMAT), and
refused anything else as Unsupported{IdentityDomains}, not implemented, with no symbol. Intel's
Windows driver 101.2145 on the UHD 630 lacks shaderStorageImageReadWithoutFormat and lists
neither WITHOUT_FORMAT bit in any format's buffer features (vulkaninfo there, jobs m3-max-82912
and m3-max-82917), so every function with an access::read_write texture buffer at a slot was
refused at the make: tb_word_formats for all 15 formats of
every_device_reads_and_writes_texture_buffers_of_formats_held_as_words (job m3-max-82853, pin Q
aed8b7eba3). The refusal is the own-view arm's declaration and took the words twin with it,
though that device holds every format with a word layout as words, which the twin reaches through
the R32ui words array and no formatless access.

A texture buffer's slot is now declared without a format wherever the profile reads and writes
storage so at all (texel_buffer_without_format: DeviceProfile::accesses_without_format, the
features, or Vulkan 1.3 or VK_KHR_format_feature_flags2, which enable the SPIR-V capabilities
StorageImageReadWithoutFormat and StorageImageWriteWithoutFormat). Vulkan asks the format's bits
of each view an access reaches (VUID-vkCmdDispatch-OpTypeImage-07029, -07030), and the runtime
already answers that per texture buffer at the draw or dispatch from the slot's interface
(declared_format false): an own view whose buffer features lack the access's bit is
Gap::StorageElement, a texture buffer held as words reads and writes true (texel_form). A nil
texture at the slot reads a null descriptor, which is no view: the floor's nullDescriptor
(runtime README, Floor, Features: `nullDescriptor`, VkPhysicalDeviceRobustness2FeaturesEXT; the
floor also requires Vulkan 1.3, its first line). Decided by the profile's Vulkan answers alone.
Images keep reads_by_format_bits; its texture buffer arm goes, as the new rule takes every
profile it took.

The refusal narrows from every state over such a function to the bindings the runtime README
already records: on a device whose buffer features lack STORAGE_READ_WITHOUT_FORMAT for a format
held as its own view, a read of that format's texture buffer through access::read_write at a
slot is refused at the draw or dispatch. The README's paragraph now says that the slot's
declaration is made on every device and the refusal is the dispatch's, per texture buffer, that
a nil texture there reads the floor's null descriptor, and that the UHD 630 reads and writes its
word formats through access::read_write; the refusal list's no-symbol item is now a storage
texture's alone, not a texture buffer's.

SEMANTICS_VERSION 2334 (development held 2333): a refusal becomes a module. No RUNTIME_VERSION
bump: a run of an unchanged artifact does nothing else. runtime-sources.sha256 is unchanged:
neither lower/texture/slot.rs nor cache/mod.rs is a runtime input (validation's build.rs list),
and the guard test passed at this tree (below). docs/REFUSALS.md does not move: storage_format
stays an IdentityDomains site (refusal_surface.py --check passed below).

Verified at 1db43f3bd8, a commit of this same tree (tree 569677eeac) on a try branch:
- red: the test before this one (849c883ab3), job m3-max-82957: refused as
  "unsupported: IdentityDomains; needs NotImplemented", the UHD 630's text;
- Intel Iris Xe (RPL-P, Mesa 26.2.6), job m3-max-82971: the runtime's texture buffer tests
  (--cfg m2v_gpu, filter test(texture_buffer)), 11 run, 11 passed; its word formats every answer
  the CPU's, and B5G6R5Unorm, BGR5A1Unorm and BGR10A2Unorm (own views) refused read_write by name;
- Intel UHD 630 (Windows driver 101.2145, validation layer 1.4.363.0), job m3-max-82977 (the
  win-cross build m3-max-82970): the runtime's whole suite, 984 run: 983 passed, 1 failed, 4 skipped;
  every_device_reads_and_writes_texture_buffers_of_formats_held_as_words passed (it asserts the
  words twin ran once per dispatch where the format is held as words, all 15 formats there), as
  did one_path's the_scan_reads_the_translators_product_sources_alone and
  the_product_sources_take_one_path_for_every_device. The one failure,
  half_simd_reductions' every_device_sums_and_multiplies_half_simdgroups_as_metal, failed the
  same way at pin Q (job m3-max-82853) and is outside this change;
- the Linux gate, job m3-max-82968: cargo fmt --check, signatures --check,
  refusal_surface.py --check, clippy -D warnings (plain, --cfg m2v_gpu, --cfg m2v_cpu_icd) and
  rustdoc all clean; the translator's and AIR suites 3457 run: 3456 passed, 1 failed, 22 skipped; the
  runtime guard (the_runtime_sources_are_the_committed_ones) passed. The one failure is
  golden_hashes_match_the_table, a bless due under 2334 (job m3-max-83023): exactly two cells
  changed, both refusals that became modules on the runtime-floor profile,
  engine/a8r_buffers.ll a8r_buffer_read_write and engine/tb_word_formats.ll tb_word_formats,
  Unsupported{IdentityDomains; NotImplemented} to modules; the .air.ll rows need macOS's metal-as
  and were not compared. The table is re-blessed on development.
2026-12-03 02:50:42 -08:00
Anees Iqbal aa51aeb7f4 Translator test: a read-written texture buffer slot is formatless where no buffer format reads so (red)
On the UHD 630 under Intel's Windows driver 101.2145 (job m3-max-82853, pin Q aed8b7eba3) the
runtime test every_device_reads_and_writes_texture_buffers_of_formats_held_as_words made no
pipeline of tb_word_formats for any of its 15 formats: Unsupported{IdentityDomains}, not
implemented, with no symbol. That device lacks shaderStorageImageReadWithoutFormat and lists
neither STORAGE_READ_WITHOUT_FORMAT nor STORAGE_WRITE_WITHOUT_FORMAT in any format's buffer
features (vulkaninfo there, jobs m3-max-82912 and m3-max-82917), so storage_format refuses the
kernel's access::read_write texture buffer slot under the identity domains: the slot's read is
granted neither by the feature nor by the neutral R32_SFLOAT's buffer read bit
(reads_by_format_bits). The refusal takes the whole make, the words twin with it, though every
format the test reads is held as words there and reached through the R32ui words array.

This test builds that device's answers device-free: the Iris Xe's profile
(intel-irisxe-rplp-anv, which lacks the feature too) with both bits cleared from every format's
buffer features. It asserts that tb_word_formats compiles under the identity domains and passes
L3, requires the StorageImageReadWithoutFormat capability and not the feature, plans the words'
routines, and states its written and read-written texture buffer slots as storage slots without
a declared format. Expected red until the fix: the compile is refused as IdentityDomains.
2026-12-03 02:50:42 -08:00
Anees Iqbal 0959445d39 Bless at pin R: the golden hash table and the authored compile census
The golden hash table moves 399 rows and its semantics line goes to 2334:
the Converted half rounding's NoContraction pair (699f1167d6) changes the
module wherever that form is emitted. The engine inventory and the air_input
printouts bless unchanged, and the metallib half of
committed_air_fixtures_parse_and_link passes on the M3's SDK (bless job
m3-max-83055; the first bless job, 82992, gave the same 400-line change, but
its workspace was released before its patch was read).

The authored compile census recompiled every cell: 2369 cases, 9 profiles,
21,321 cells, 0 cached; 19,106 compiled, 2,215 refused, 0 failed,
0 differences, 0 regressions (census job m3-max-82993). Only its
artifacts_at product fingerprint line moves.
2026-12-03 02:46:11 -08:00
Anees Iqbal 13c6ba8a91 Tests: the half rounding test names its partition's element type
7d9aa2207f's partition left its element type to inference, which rustc could not settle
(E0282, job m3-max-82776). It is now the conversion triple's reference. Test only.
2026-12-03 02:10:26 -08:00
Anees Iqbal 7d9aa2207f Tests: the half rounding test holds the rounding's pair to NoContraction, apart from the store's narrowing
converted_half_rounding_is_the_exactly_rounded_half (red two commits back) asserted that every
OpFConvert in its kernel is decorated NoContraction in both forms. Its kernel also stores the half
result, and that store's narrowing to bits (narrow::to_bits) is no pair: it is decorated under the
float controls alone, which a_half_encode_is_the_devices_narrowing_in_every_form holds and the fix
keeps. So the assertion also failed at the fix, on the store's narrowing ("round Converted:
[Allowed, Allowed, Allowed]" before the fix, job m3-max-82752).

The test now finds the pair by structure (a narrowing of an f32 to 16 bits and a widening of its
result back to 32 bits), asserts both are NoContraction in both forms, and asserts every other
conversion takes its form's decoration: NoContraction under the float controls, none in
Converted. Test only; no translation output changes.
2026-12-03 02:10:22 -08:00
Anees Iqbal 699f1167d6 Translator: a Converted half rounding's conversion pair is decorated NoContraction, as the Controlled one is
A `half` rounding in `QuantizeForm::Converted` (a profile with shaderFloat16 whose float
controls do not make the conversion Metal's) was an undecorated OpFConvert to 16 bits and
its widening. Vulkan assumes AllowTransform on every operation not decorated
NoContraction ("Precision and Operation of SPIR-V Instructions"), and Mesa's NIR folds
`~f2f32(f2f16(a))` into `a` wherever the instruction is not exact (nir_opt_algebraic.py;
vtn marks NoContraction exact), so the value went on unrounded. On KosmicKrisp (Mesa
26.3.1, Apple M3 Max) that broke half_simd_reductions: each round of the half tree kept
float precision, and 224 of 256 words differed from Metal's (job m3-max-82540, pin P's
leg). The MSL KosmicKrisp emits showed no half() between rounds; with the pair decorated,
0 words differ (job m3-max-82662).

`narrow::converted` now emits each conversion with `convert_no_contraction`, as
`narrow::controlled` does. The pair relies on Vulkan's environment rule, which reaches a
conversion, where the SPIR-V specification words NoContraction for an arithmetic
instruction only; the docs state that reliance at the Controlled pair's (narrow.rs), on
QuantizeForm::Converted, and in docs/API.md's native-half-conversion entry, and that a
driver which folds a decorated pair leaves the device's own answer, within
PrecisionNote::NativeHalfConversion, which a Converted module already records. NVIDIA's
measured fold of the decorated Controlled pair stays as recorded. SEMANTICS_VERSION 2333
-> 2334: every Converted module's words change (moltenvk-m3 is the committed profile on
that form; KosmicKrisp takes it at run time).

Evidence, all on the arms of this change before the ruling:
- KosmicKrisp conformance replay on the Apple M3 Max: 53 sites that differed from Metal
  at the base now match, none added (job m3-max-82685).
- Cost: +0.46% host wall on half_mix on the M3 under KosmicKrisp, job 82685, three
  alternated rounds of 200, spread 0.03%.
- Golden tables: 216 moltenvk-m3 cells change, no other profile's (job m3-max-82679).
  They re-bless at the next named pin.

The red test (the commit before) asserts both forms' conversions are NoContraction;
it fails before this change and passes with it (the gate's jobs are in the READY note).
2026-12-03 02:10:22 -08:00
Anees Iqbal 720753ca9d Tests: a Converted half rounding's conversion pair is decorated NoContraction, as the Controlled one is (red)
The Converted form (shaderFloat16 without the 16-bit float controls) rounds an f32 to half by an
OpFConvert to 16 bits and its widening, undecorated. Vulkan assumes AllowTransform on an
operation not decorated NoContraction, and Mesa's NIR folds the widening of a narrowing under it
(nir_opt_algebraic.py, Mesa 26.3.1, line 1271: ~f2f32(f2f(a)) -> f2f32(a), then x2xN(a@N) -> a).
So on every Mesa driver on a Converted profile the value is never rounded. On the Apple M3 Max
under KosmicKrisp (Mesa 26.3.1), the runtime's half_simd_reductions device test read the f32 sum
rounded once at the store in 224 of 256 words, not Metal's tree of rounded halves (0x3c10 for
Metal's 0x3c0f on the first sum; job m3-max-82540). The MSL KosmicKrisp emits for that kernel has
no half conversion between the tree's rounds (MESA_KK_DEBUG=msl, m3-max-82662).

converted_half_rounding_is_the_exactly_rounded_half now asserts that both forms' conversions are
NoContraction. It fails on the Converted form until the next commit decorates the pair.

Verified: cargo fmt only. The red run is the next commit's base arm.
2026-12-03 02:10:22 -08:00
Anees Iqbal 22861fde72 rt test: rule 2's scan labels each source with / on every host
The scan labelled each product source by Path::display, which joins its
components with `\` on Windows. The labels the tests name and the allowances
key on are written with `/`, so on the UHD 630 under Windows (job
m3-max-82853, at aed8b7eba3) the_scan_reads_the_translators_product_sources_alone
found no "metal2vulkan/src/device/description.rs". And
the_product_sources_take_one_path_for_every_device reported allowed lines,
such as "metal2vulkan/src/ash_interop\convert.rs:36 DriverId", as findings.
The label now joins the path's components with `/`. Test-only:
runtime-sources.sha256 is unchanged (recomputed: 3ec63863).
2026-12-03 01:47:02 -08:00
Anees Iqbal cd356da852 Docs: a state's precision notes are recorded at its creation, never announced at a draw
Rule 1 fixes a precision note per operation and never decides it at run
time. metal2vulkan-runtime follows that: each state carries its stages'
whole precision_notes from its creation (pipeline.rs, render.rs) and
reads no specialized note at a draw or dispatch (0 hits for
specialized_notes or precision_notes_bound in its sources). Its README
says the same ("fixed at creation and never decided at dispatch").
Several translator docs said otherwise:

- Ten said the runtime announces or reads a note at a draw or dispatch that binds
  a texture, or only while a sampler state of pixel coordinates lives:
  pipeline/artifact.rs (DeviceNanEncoding, ArgumentPixelSamplerScaling),
  lower/sampler/select.rs (three), lower/texture/heap_raw.rs,
  lower/texture/mod.rs (four, stored_where's "the runtime reads ... at
  each draw or dispatch" among them). They now say the note holds under the
  bound value and is among the stage's notes, which the runtime records
  whole at the state's creation.
- Two named announcements with no runtime code: artifact.rs's
  `non-strict-residency` and facts.rs's PlanDiagnostic::CrossClassHeapNeutral
  ("which the runtime announces"; the runtime reads no PlanDiagnostic).
  Both claims go.

The same class beyond those eleven, so the docs agree with README.md
(the caller announces a note; the runtime records it): metal/state.rs
named an announcement `unorm-depth-bias`, which no code has (the render
encoder's note is PrecisionNote::DeviceDepthBias); artifact.rs's
SrgbTexelDecode said the runtime reads the bound format at a draw;
"the runtime announces" becomes "records" at artifact.rs (three),
compile/numbered.rs,
link/band.rs, the runtime README (DevicePackConversion) and validation's
c3.rs; three test docs drop the run-time claim (engine_spec_bits,
engine_sampler, engine_cross_class); validation's coverage.rs said an
executed module's notes are its bound ones (precision_notes_bound),
where every executor records the state's whole notes; and the runtime's
translator_fields row says "records".

Comments and docs only. metal/state.rs is a runtime input, so
runtime-sources.sha256 takes the inputs' new hash; no run changes.

Verified: rustfmt --check on every .rs file changed; the job named in
the handover.
2026-12-03 01:35:27 -08:00
Anees Iqbal 333ae1b40f Translator: PrecisionNote::code states each note's stable degrade code
A precision note's stable code, `metal2vulkan-degrade-` and the note's
name in kebab case, was written only in the conformance crate
(degradation.rs), which is unpublished. So no published item gave a
caller the code to announce a note by, and README.md said the runtime
announces each note once with a stable code, which it does not: the
runtime records each state's notes when the state is made, exposes them
through its getters, and prints and sends none (docs/API.md section 9
says so).

- PrecisionNote::code (pipeline/artifact.rs) returns the code, one arm a
  note, as docs/API.md's catalogue names it.
- The conformance crate reads it from there: Degradation::code is its
  note's code, through Degradation::note, the inverse of
  from_precision_note. Each kind's doc names its note, not a second copy
  of the string.
- README.md's "Recorded differences" says what is true: the runtime
  records each state's notes at creation and exposes them with a stable
  code; the caller announces them. docs/API.md's catalogue lead names
  PrecisionNote::code.
- The signature table takes the method under both crates that export
  PrecisionNote.

The 83 codes are unchanged: each equals the conformance crate's string
before this commit (checked by script against its code() table), and
every_kind_is_a_catalogued_precision_note still finds each in the
catalogue. New tests: every_precision_note_code_is_its_name_in_kebab_case
(translator, serde feature: every variant read from the enum's source,
its code the kebab rule, no code twice) and every_kind_is_its_notes_kind
(conformance: note() takes from_precision_note back for every kind).
No translation, runtime or refusal changes; no runtime input changes, so
runtime-sources.sha256 stays.

Verified: rustfmt --check on the four .rs files; the job named in the
handover.
2026-12-03 01:35:25 -08:00
Anees Iqbal aed8b7eba3 Bless at pin Q: the golden hash table and the authored compile census
The golden hash table moves 16 rows. The profile fingerprint moved at
a4491c1436 and the translator changed since pin P. The engine inventory and the
air_input printouts bless unchanged, and the metallib half of
committed_air_fixtures_parse_and_link passes on the M3's SDK (bless job
m3-max-82822).

The authored compile census recompiled every cell: 2369 cases, 9 profiles,
21,321 cells, 0 cached. 19,106 compiled, 2,215 refused, 0 failed, 0
regressions, and 6 new cases blessed (census job m3-max-82823, 97.6 s wall).
Its slowest compile was 1.67 s and its largest worker 232 MiB RSS, inside
the 20 s and 500 MiB ceilings.

The first bless and census jobs (82767, 82768) lost their compiles when the
build cache's daemon died: the daemon belongs to the job that starts it and
went with that job when it ended. Nothing in this tree changed between
those jobs and the reruns.
2026-12-03 01:34:29 -08:00
liuyaxuan123457-ctrl 0776937c90 Document host batch ownership and keep queue tests after implementation 2026-12-03 17:23:26 +08:00
Anees Iqbal e79864f16f Runtime README: the fenced span's measured length on the M3 Max, the 780M and the Iris Xe
What: the known gap of memory blocks (a texture in place over host memory's import) states how long
a RestoreFence holds its span: from before returning to after being called. In microseconds, the
median of 16 fenced makes and then the largest, without the validation layer:
- 1920x1080 BGRA8Unorm: Apple M3 Max (KosmicKrisp 26.3.1) 455 and 645; Radeon 780M (RADV PHOENIX,
  Mesa 26.2.6) 603 and 877; Iris Xe (ANV, Mesa 26.2.6) 3267 and 3504.
- 16x4 RGBA8Unorm: 328 and 396; 120 and 169; 507 and 934.
It also says the span holds the whole submission that carries the restore.

Why: the consumer picks its fence from these numbers.

Verified: printed by the new test (host_in_place's
each_device_fences_a_host_writer_around_the_restore_alone) at 7bc3d18e4e, with
METAL2VULKAN_TEST_UNVALIDATED=1, in jobs m3-max-82721 (M3 Max), m3-max-82720 (780M Phoenix) and
m3-max-82734 (Iris Xe). Under the validation layer, in the same jobs, the 1080p numbers were 478
and 591, 1240 and 1972, and 3731 and 3993; the 16x4 numbers were 350 and 444, 209 and 825, and
793 and 1411. Docs only.
2026-12-03 01:06:30 -08:00
Anees Iqbal 1ee4cd95d5 Runtime: the caller's RestoreFence is called around a restoring make's save, move and write-back
What: Device::texture takes the fence that Buffer::new_texture_fenced and
Buffer::new_texture_in_place_fenced pass. On a restored make alone (in place over host memory's
import, Keep::Restore), after the refusals ahead of the restore, the make runs on its own thread:
it waits for the progress already submitted (Work::progress), calls the fence's before, adds the
image's move home to the upload (Work::home), flushes, waits for that value, and calls after.
before comes ahead of home and not just ahead of flush because a commit from another thread can
carry the upload out as soon as the move is in it (take_uploads). after is called from a drop
guard (Fenced), so it runs on every exit once before returned Ok: the make done, Quiesced from
home, a lost device in the wait, or a panic unwinding. A before that answers Err(reason) refuses
the make with Refusal::RestoreFenceRefused { reason }. Then nothing is recorded, saved, moved or
written back, the texture made so far is dropped, nothing counts, and after is not called: before
undoes its own work, and after always pairs with a before that returned Ok. Every other make, and
every make with no fence, takes the match's other arm, so an unused seam costs one branch. The
make itself is unchanged.

Public shape: a trait object (&mut dyn RestoreFence, before -> Result<(), &'static str> and after)
on two new twins, not an Option argument on new_texture and new_texture_in_place. This tree has
about 90 four-argument calls of those two, and the consumer's development has 6, of which 2 need
the fence; the twins leave every other call unchanged. A &mut trait object lets before keep a guard
or a token in the fence for after to release. The reason is &'static str so that the refusal stays
Copy, as Refusal is.

Docs: the runtime README (Imported blocks, "The caller's fence"; the known gap of memory blocks;
the API list) states the contract. Between before and after the runtime saves, moves and writes
back the block's bytes, so a host write to them in that span is lost; the span holds the whole
submission that carries the upload, a group's included. A caller with such a writer fences it
there; one without passes nothing. Vulkan documents no form that keeps the bytes without the
write-back (sections 12.10.1 and 7.7.6: an acquire keeps bytes only after the other owner's
release; section 11.2.6: host-pointer memory is shared with the host under host access
synchronization). The rustdoc of the trait, the twins, the refusal and Buffer::new_texture says
Metal has no such span. Refusal::InScheduledHandler's doc names the twins. docs/REFUSALS.md is
regenerated (RestoreFenceRefused, one site). Not touched: RUNTIME_VERSION and runtime-sources.sha256,
whose inputs are the translator's listed files (metal2vulkan/src, metal2vulkan-air/src); this change
edits none of them.

Verified, red: at 4e941d8015 (the fence passed nowhere) the new test failed on lavapipe (llvmpipe,
LLVM 23.1.1, Mesa 26.2.4), job m3-max-82710. With no fence, 632 of 86,252 stamped words were lost.
With the unwired fence, 7,507 of 98,879 were lost, 0 writes found the gate held, and before and
after ran 0 times. Green runs and the gate follow in the lane's report.
2026-12-03 01:06:30 -08:00
Anees Iqbal 5c9d6c19a4 Runtime: RestoreFenceRefused's basis arm, and the seam's rows in the signatures table (red, fixed forward)
6b8b3af925 added Refusal::RestoreFenceRefused without regenerating error/basis.rs, so the runtime
did not compile (non-exhaustive match in Refusal::basis; job m3-max-82706, lavapipe). basis.rs is
regenerated by scripts/refusal-surface/refusal_surface.py from the variant's Basis line. The
signatures table takes the five new public items and the new variant
(scripts/api-signatures/signatures.py --bless). No behaviour changes: the fenced twins still drop
the fence, so the red test stays red.
2026-12-03 01:06:30 -08:00
Anees Iqbal 7034d61636 Runtime test: a host writer keeps its writes across a restoring make only behind the caller's fence (red)
What: the runtime's public seam on its one make that saves and writes back a buffer's bytes, a
texture in place over host memory's import on an integrated or CPU device. RestoreFence (before,
which may refuse with a reason, and after), Buffer::new_texture_fenced and
Buffer::new_texture_in_place_fenced, and Refusal::RestoreFenceRefused { reason }. In this commit
the twins take the fence and Device::texture drops it: neither method is called.

The test, host_in_place's each_device_fences_a_host_writer_around_the_restore_alone, puts a host
writer on a 1920x1080 BGRA8Unorm frame over its own import. The writer stamps one word every 64
bytes, one a microsecond, each through a mutex gate, starting before the make and stopping after
it returns. With no fence (new_texture, up to four makes) some stamped words hold their old bytes:
the write-back reverted writes that landed between the save and the write-back. With a fence whose
before takes the gate and whose after gives it back, the writer must find the gate held at least
once and lose no word. The fence runs once each way. The restore pair (OverCause::HostMemoryRestore)
is the same as the unfenced make's, and every word not stamped holds the bytes written before the
make. A before that refuses ("unsettled") must give RestoreFenceRefused with that reason, no after,
no copy and no texture counted. The in-place-alone twin runs the fence the same way. Sixteen fenced
makes each of 1080p BGRA8 and 16x4 RGBA8 print the span between before and after and the make's
time (median and largest). Off unified memory (a discrete or virtual device, or the two-copy view),
neither method runs, and the in-place-alone twin is refused as not in place.

At this commit the fenced arm fails: the writer loses words behind the fence, and before never
runs. Red runs are named in the next commit's message.
2026-12-03 01:06:29 -08:00
Anees Iqbal 096742809b Runtime docs: a restored make's upload goes in the next submission, its own or a group's
What: the runtime README (Imported blocks, and the known gap of memory blocks), the rustdoc of
Buffer::new_texture, Metrics::over_copies_host_memory_restore and the make's comment said that a
texture in place over host memory's import has its restore (save, move, write-back) go "alone, in
a submission of the runtime's own". They now say what the code does: the make seals the upload
and flushes it (Work::flush), and the submit thread's next submission carries it. Where no
queue's group goes at that turn, that is a submission of the runtime's own (submit.rs, the flush
branch after the group loop); otherwise a group's close takes it (WorkState::close calls
take_uploads, which takes every flushed upload), and submit() puts it ahead of the group's
command buffers, in the first part where the group goes member by member. The make waits for that
submission's value, so it waits for those command buffers too.

Why: the consumer reads these sections to decide how to fence its host writers around the make;
"alone" told it the span holds nothing of its own.

Verified: read against submit.rs (Work::flush, WorkState::flush, WorkState::close, take_uploads,
submit, parts). Docs and comments only; no code changes.
2026-12-03 01:06:29 -08:00
Codex 728b4701d0 Separate host batch recording from Metal queue admission 2026-12-03 16:50:43 +08:00
Anees Iqbal a4491c1436 Translator: drop LeafCaps::zero_initialize_workgroup_memory and a dead anisotropy test
Two pieces of dead code go (rule 4).

LeafCaps::zero_initialize_workgroup_memory was set from the
shaderZeroInitializeWorkgroupMemory query in device::derive and read
nowhere. Lowering and the verifier read the enabled feature set instead
(lower/access/local.rs, spirv/verify/rules.rs), so no answer changes.
The field is not public: device::profile is pub(crate) and LeafCaps is
not re-exported. A git grep of the consumer's checkout at eadc8b4a0d
finds 0 hits for the field or LeafCaps.

The profile's fingerprint is a hash of the fields' Debug text, so every
profile's fingerprint moves with this commit. Cache keys miss once and
recompute; there is no false hit, so no SEMANTICS_VERSION bump. The
golden table goes stale by key alone and re-blesses at the next pin: at
this tree 28,860 cells (1,924 rows x 15 profiles) are "under a changed
profile", with 0 new, 0 gone, 0 under a changed fixture source and none
changed under an unchanged key. Stored observations name the field in
their environment/profile Debug text: 12 shard files, 55 lines (4 under
observations/refusals/vulkan, 8 under observations/vulkan). They are
left as stored; their text already differs from today's profile shape.

lower::sampler::anisotropic::select returns as soon as the profile has
samplerAnisotropy, so its later `if anisotropy && !reached` test could
never be true. It goes with its comment. Behaviour is unchanged on every
profile.

runtime-sources.sha256 takes the runtime inputs' new hash. derive.rs and
profile.rs are inputs, and this change alters no behaviour of a run.
The hash also covers two earlier comment-only edits to inputs that left
the guard red on development: b07b697aac (device/metal.rs) and
7be9f00a3f (device/policy.rs, device/profile.rs). Their .rs diffs change
comment lines alone. At 7be9f00a3f the guard test fails and names
5aa066e0..., against the pinned 36ba0695... (job m3-max-82683).

Verified on the CPU with no device:
- m3-max-82633, the gate at 2523fe20c6 (this change before the hash update):
  signatures, clippy (plain, m2v_gpu, m2v_cpu_icd), rustdoc and private
  rustdoc of metal2vulkan all exit 0; conformance 1051/1051; doctests 0.
  Product suites: 3734 of 3735 passed, 24 skipped; the failure was
  golden_hashes (stale, above). Validation: 1321 of 1322 passed, 3
  skipped; the failure was the runtime guard, which this hash fixes.
- m3-max-82683 at 413a1db3f9 (this tree): the runtime guard passes; golden_hashes is
  stale by profile key alone (above). With the four files at 7be9f00a3f:
  the guard fails (development's red), and golden_hashes passes (1,924
  rows x 15 profiles match).
- rustfmt --check on the three .rs files.
2026-12-03 00:50:00 -08:00
Anees Iqbal 16ce2c2070 Runtime README: KosmicKrisp's indirect patch draws of two instances name the three tests and their runs
The known gap said the runtime's two device tests of it "fail there". The bug is a race (the
driver's indirect tessellation grids are thread counts dispatched as threadgroup counts, so one
instance's extra vertex work overwrites the next instance's), and the tests' results on
KosmicKrisp vary by run:
- every_device_reads_a_patch_draw_s_base_instance_after_tessellation and
  every_device_reads_a_patch_s_position_as_its_primitive_id_under_a_patch_index_buffer failed in
  m3-max-81082 and passed in m3-max-81774 and m3-max-82540, with no change to patch.rs between
  those runs;
- every_device_reads_control_points_and_patch_indices_through_their_index_buffers (indirect,
  no index type, no patch index buffer) passed in m3-max-81774 and failed in m3-max-82540: the
  second instance's slots for positions 2 and 3 read 0, and slots for positions 5 and 6 read the
  first instance's id, 3. That is the first instance's vertex threads past its 3 patches writing
  positions 4 to 6 over the second instance's 3 vertex slots, with position 4 culled.
The bullet now says it is a race, that a draw can be right, what the failed draw showed, and the
runs of all three tests on the Apple M3 Max under KosmicKrisp (Mesa 26.3.1), plus the third
test's passes on RADV on the RX 7900 XTX (m3-max-82574) and the Radeon 780M (m3-max-82583) in
the same round.

Verified: docs only; the results are read from those jobs' logs. The driver's grids were read in
Mesa 26.3.1's kk_tessellation.cl (libkk_tess_setup_indirect) and kk_cmd_draw.c
(kk_dispatch_compute), not instrumented.
2026-12-03 00:32:38 -08:00
Anees Iqbal b3d7464945 Validation: a threadgroup target is checked nowhere, so its case is refused before it runs
What: executor_contract::out_of_bounds::containment() reports a threadgroup target as the arena
unchecked (Check::Unchecked), on every profile and under either domains. out_of_bounds_run then
refuses the case before anything is made, as not_supported{uncontained:unchecked threadgroup},
as it refuses a loaded pointer under the identity domains. The read rule's in-shader arm no
longer names the arena. The module docs, the Unchecked variant, ContainmentForm::Threadgroup,
the coverage note on which accesses the encodings govern, and docs/VALIDATION.md say so.
ENGINE_EXECUTOR_ABI moves to vulkan-engine-v214: the executor records a refusal for a case it
ran before.

Why: since 990328afe1 no profile checks a threadgroup access (lower::access::local::contained;
docs/API.md, "Threadgroup memory": one past the memory is undefined, as in Metal; the runtime
README states it too). The contract still reported the arena as checked in the shader, so the
candidate ran the only authored case with a threadgroup target, tg-twice (7efae163,
loads-and-stores-past-a-threadgroup-allocation), and read what the device held past the
allocation. On the Radeon 780M (RADV, Mesa 26.2.6) job m3-max-82582 ran it 10 times at
f606e43b30 and got 10 different output hashes: word 6, a load of tg[40], which no thread
writes, held a different value each run. The kernel's SimdgroupAccessOrder note made the failed
zero rule a NotedDifference. Vulkan does not define an access past a Workgroup array either, so
no part of that run is evidence.

What else moves: no other authored case declares a threadgroup target (all case shards
searched for "form":"threadgroup": one hit), so only tg-twice moves from noted_difference to a
refusal. The case, its AIR and its Metal row are unchanged. No classifier input changes
(executor_contract/out_of_bounds.rs, coverage.rs and case/out_of_bounds.rs are not in
build.rs's classifier list), and the authored compile census compiles the case as before
(case_compile reads no containment), so neither census version moves.

Verified: see the green job named with this commit's READY.
2026-12-03 00:30:04 -08:00
Anees Iqbal 576d9384ec Validation test: a threadgroup target is checked nowhere and its case is refused (red)
What: the out-of-bounds contract's tests now state what the product does with threadgroup
memory. threadgroup_memory_is_checked_nowhere_and_its_case_is_refused asks containment() for a
threadgroup target on every committed profile, under either domains: the arena unchecked
(arena:unchecked), read rule Any, and out_of_bounds_run refuses the run as
not_supported{uncontained:unchecked threadgroup}. The coverage test of the ob1 fixtures expects
ob1_threadgroup's compiled target to be arena:unchecked.

Why: since 990328afe1 no profile checks a threadgroup access (lower::access::local::contained;
docs/API.md, "Threadgroup memory": one past the memory is undefined, as in Metal), but
containment() still reports the arena checked in the shader, so the candidate runs the
tg-twice case (7efae163, loads-and-stores-past-a-threadgroup-allocation) and judges its reads
past the allocation by the zero rule. On the Radeon 780M (RADV, Mesa 26.2.6) job m3-max-82582
ran it 10 times at f606e43b30: 10 different output hashes, all NotedDifference. Words 0 to 3
equal Metal's; words 4, 5 and 7 are the values threads 4, 5 and 7 stored past the allocation;
word 6, the load of tg[40], which no thread writes, differs in every run (9a2e1730, 982ec630,
9a2e4632, ...). The kernel's SimdgroupAccessOrder note made the failed zero rule a
NotedDifference.

Verified: red expected; the job that runs these tests at this commit is named in the fix's
commit.
2026-12-03 00:30:04 -08:00
Anees Iqbal 7be9f00a3f Docs: only tests build the resident-table domains
The docs of DevicePolicy::RESIDENT_TABLES, PointerDomain::ResidentTable,
HandleDomain::Table, the lockstep module, docs/API.md and three test
comments said the resident form was the validation executor's alone and
that the executor builds the resident root and handle table itself, or
called it "the old runtime's, until the cutover deletes it". Neither is
true: the validation executor (engine.rs), the runtime, the command line
and the compile worker all build their device under
DevicePolicy::default(), and every RESIDENT_TABLES in the tree sits in a
test (the translator's src/tests and device tests, the validation
crate's #[cfg(test)] modules including coverage::tier_table, the
harness's tests and the validation integration tests).

The comments now say that: nothing outside tests builds the form, and
the runtime, the tools and the validation executor take the default.
Comments and docs only; no code changes.

Verified: git grep of RESIDENT_TABLES, PointerDomain::ResidentTable and
HandleDomain::Table at 8140229b9c, each hit outside the translator's own
tests read for its #[cfg(test)] scope; cargo fmt --all; the workspace
rustdoc check with -D warnings, doc 0 and private-items doc 0 on all seven crates (job
m3-max-82621).
2026-12-03 00:23:31 -08:00
Anees Iqbal 8140229b9c Docs: a new texture reads zero for a stated reason, and its cost stays counted
The runtime README called the zero clear of a new texture the runtime's choice. It now gives the
reasons the answer stands on: Metal leaves a new texture's contents undefined, programs read
textures they never wrote, an Apple M3 Max answered zero for new Shared and Managed textures, and
zero is the one answer that cannot show a program bytes something else left in the device's
memory. The clear is counted by Metrics::texture_clears and texture_clear_bytes. No behaviour
changes.

Verified: the paragraph reads as one, and no other doc states the old reason.
2026-12-03 00:17:20 -08:00
Anees Iqbal cb09012f99 rt test: capture's lists for a commit stay bounded when Managed buffers go uncommitted
capture::Changes holds two lists that wait for a commit, both of weak entries:
- the ranges that didModifyRange named, with their index by buffer;
- the bytes of each Managed buffer made since the last commit.
Each list drops the entries of buffers that are gone once it doubles, starting from SWEEP_FLOOR
(64) entries. Nothing tested that bound. A program that makes, names and drops Managed buffers
without committing would grow the lists without limit if the sweep broke.

every_device_bounds_what_managed_buffers_gone_left_for_a_commit makes, names and drops four times
SWEEP_FLOOR Managed buffers, each with its bytes, and commits nothing. With a device copy, each
list and the index fill to the floor and never hold more. With one copy, nothing is listed. The
test reaches the lists through two accessors that exist only for the device tests
(Changes::entries, Work::changes). SWEEP_FLOOR becomes pub(crate) so the test can name it.

Verified in job m3-max-82584, at a commit with the same tree (c3ea874a68):
- with both sweeps disabled in a probe copy of capture.rs, on lavapipe in its two-copy view:
  "after 65 Managed buffers gone, [named, indexed, made] are [65, 65, 65], past 64", red;
- as committed, on lavapipe: one copy [0, 0, 0], two copies [64, 64, 64] at most, green;
- the RTX 5080 Laptop (two copies), under --cfg m2v_gpu: [64, 64, 64] at most, green;
- managed.rs's 37 tests on lavapipe, green;
- signatures, clippy plain, m2v_gpu and m2v_cpu_icd, doc and privdoc, all 0.
2026-12-03 00:13:19 -08:00
Anees Iqbal b07b697aac Docs: the M3's and the 5300M's supportsTextureSampleCount: answers cite their jobs
The translator's TEXTURE_SAMPLE_COUNTS comment and the conformance sample-position family's module
doc stated the Apple M3 Max's answer for 8 samples with no measurement behind it. Job 82550 asked
an Apple M3 Max under macOS 27.0.1: yes for 1, 2 and 4, no for 3, 5, 8, 16 and 32. Job 82204 asked
an AMD Radeon Pro 5300M under macOS 26.7.1: yes for 1, 2, 4 and 8, no for 16. Both comments now
cite them. Comments only; the recorded EIGHT_NEVER_RE_RECORD text, which the 8x recordings carry,
is unchanged.

Verified: both jobs' SAMPLES and P8 lines read from their logs; cargo fmt --all leaves the tree
unchanged.
2026-12-03 00:12:44 -08:00
Anees Iqbal 0912a69508 rt test: rule 2's scan reads the translator's product sources, and the identity spellings it missed
the_product_sources_take_one_path_for_every_device (rt's tests::one_path) enforces rule 2: product
code names no vendor, device or driver identity, reads no environment variable and declares no
policy type. Until now it read only the runtime's sources and missed several spellings. It now
reads the translator's two crates too, and it catches:
- driver_version, conformance_version, the device, driver and pipeline-cache UUIDs and
  PhysicalDeviceIDProperties;
- ash's device_name_as_c_str, driver_name_as_c_str and driver_info_as_c_str accessors, and
  vk::VendorId;
- the vendor IDs written in decimal;
- getenv;
- the device type, which rule 2 lets decide unified memory alone.

The translator's tests are left out: its tests directories, its tests.rs and *_tests.rs files, the
modules it declares under #[cfg(test)], and its inline #[cfg(test)] modules. A test checks that
exclusion.

The lines the scan may find something on are listed in ALLOWED, by file and text, each with its
reason:
- the device type where unified memory is decided;
- the stage cache's key;
- the translator's DeviceDescription and its two readers;
- DevicePolicy;
- Vulkan's driver enum, mirrored;
- the environment variables' registry;
- the command line's device file;
- three table and grammar numbers that equal a vendor's ID.
A listed line that no longer holds a finding fails the test, so the list cannot go stale. The
module docs say what a scan cannot see: a policy switch spelled as a bool field, a constant or a
cfg(feature) gate, and code after a // inside a string literal.

from_queries_derives_one_profile_whatever_the_identity now also varies the device's name and the
driver's version, and the profile stays the same.

Verified on the CPU with no device, in job m3-max-82544. Probe files were put beside the product
sources; no module declares them, so they were never compiled. They hold one line of each new
form (nine in the runtime's src, one in the translator's):
- the scan at a0d2d2efdd passes over them, which is the gap;
- this change's scan fails, naming all ten lines;
- without the probes, the four one_path tests and the identity test pass;
- the runtime's and the translator's suites: 3091 passed, 22 skipped.
Gate A ran in job m3-max-82570 at a commit of this tree (0339453fe7): signatures, clippy plain,
m2v_gpu and m2v_cpu_icd, doc and privdoc, and the one_path tests again after the one clippy fix
(an explicit auto-deref).
2026-12-03 00:05:10 -08:00
Anees Iqbal c3d37b4fd3 Runtime: a commit looks up only the Managed buffers with a device copy its encoders named
Changes::take used to look up, at every commit, each buffer the command buffer keeps and the
buffer under each texture it keeps, in the hash map of the Managed ranges named. Only a Managed
buffer with a device copy can have a range named, so every other lookup was wasted. The command
buffer now lists those buffers as its encoders keep each object for the first time
(ByKind::managed): a buffer kept by a slot, a declaration, a blit or any other way, and the buffer
under a texture kept. The take visits only that list. The list is cleared with the recording's
other lists, keeps its room up to KEPT_BOUND, and holds at most one entry for each buffer and
texture kept. Lending a buffer for a slot learns whether the buffer is new from the same set
insert it already made (Kept::keep_first). The commit order and the rule for which commit takes a
range do not change.

Red: the previous commit's test fails at 52d871017b, its parent, on lavapipe (llvmpipe, LLVM
23.1.1; job m3-max-82510). In the one-copy form the commit looks up 7 buffers where none is
wanted. An earlier run, m3-max-82505, failed on the test's own setup, since fixed.

Verified, before the re-lay onto development, at the same change on 1a84985dd4:
- lavapipe (job m3-max-82510): the test passes in both forms (the two-copy view); the runtime's
  whole suite reads 976 passed, 4 skipped; clippy plain, --cfg m2v_gpu and --cfg m2v_cpu_icd exit
  0; Rustdoc and the runtime's private-items Rustdoc exit 0.
- RX 7900 XTX, RADV of Mesa 26.2.6 (job m3-max-82512): the runtime's 36 Managed tests pass under
  --cfg m2v_gpu, among them the first-naming test that guards the frame-396 crash fix.

Counted, on the RX 7900 XTX (job m3-max-82512): one whole glbench-3090-r4 play per arm, 1,050
frames, release players, with a diagnostic (never landed) counting the user-space instructions of
the take at each of the 24,883 commits:
- before (development plus the diagnostic): 34,299 instructions a commit, 812,822 a frame;
- after: 5,301 a commit, 125,635 a frame. That is 687,188 fewer a frame, 84.5% of the take.
- The committing thread retired about 850 million user-space instructions a frame in both arms,
  so the take was 0.096% of them before and 0.015% after.
- Runtime command buffers (20,195), upload barriers (35,025), barriers (522,991), submissions
  (24,886), passes, bytes copied (432,472,763) and Managed bytes captured (7,215,718,372) are
  equal in both arms.
Lavapipe keeps one copy of a Managed buffer, so no range is named there and the take does no
lookup; the count was read on the XTX alone.
2026-12-02 23:58:07 -08:00
Anees Iqbal ed307c3e1e Runtime test: a commit looks up only the Managed buffers with a device copy it names (red)
At every commit, Changes::take looks up each buffer the command buffer keeps, and the buffer under
each texture it keeps, in the hash map of the Managed ranges named. That walk came with the
first-naming rule (51ac48c788). On a recorded play on an RTX 3090 it cost 35,453 user-space
instructions per commit, about 840,000 per frame, on the committing thread (job m3-max-82470, a
diagnostic build). It visits every Shared buffer and texture of the command buffer, though only a
Managed buffer with a device copy can have a range named.

The walk now sits in capture::Names::addresses, which the take uses, so a test can read what a
commit would look up (CommandBuffer::capture_lookups, test-only). The test's command buffer
dispatches over a Managed buffer and two Shared ones, and copies out of a texture over another
Managed buffer and out of one over a Shared buffer. The test expects the commit to look up the two
Managed buffers, once each, where the device keeps a copy, and nothing where it keeps one. Today
it also looks up the Shared buffers and the Shared texture's buffer, so it fails in both forms.
No behaviour changes.

Red runs follow in the next commit's message.
2026-12-02 23:58:06 -08:00
Anees Iqbal 08b4bf6020 Translator: SEMANTICS_VERSION 2333 for an unknown runtime-library routine refused as its family
4a96499072 refuses a surviving call to an unmodeled body-less ___metal_* routine as
UnknownIntrinsic, and a __tensorops_impl_* function in air.externally_defined outside the
matmul2d ABI as Tensors, where both were refused as Linking. A refusal's class is part of the
semantics key, so a cached FALLBACK of such a kernel names the wrong class under an unchanged key.
The golden tables are re-blessed on development.

Verified: the one line changed; 4a96499072's own checks are in its body (m3-max-82525,
m3-max-82527).
2026-12-02 23:57:47 -08:00
Anees Iqbal 4a96499072 Translator: an unknown runtime-library routine is refused as its family, and AGENTS.md allows the families
AGENTS.md's name rule now also allows the body-less runtime-library routines Metal's compiler
links by symbol: the ___metal_* maths routines and the __tensorops_impl_* family. Their
declarations have no body, so the symbol is the only thing that says what the routine is. An
unknown member of such a family is a typed refusal.

Both families were already gated on that structure. The bitcode reader classifies a routine
name only on a declaration, and the matmul2d lowering takes a __tensorops_impl_matmul2d_op_*
function only when it has no body and is in air.externally_defined. Two tests now show that a
defined function of either name is the module's own:
- a_defined_function_named_as_a_runtime_routine_is_the_modules_own (bitcode, through llvm-as);
- a_defined_function_named_as_a_tensor_op_is_the_modules_own (canon).
Both tests pass at the base as well.

An unknown member used to be refused as Linking, the refusal for an undefined function that
linking could supply, which these never are. Now the post-check refuses a surviving call to a
body-less declaration as its family:
- an unmodeled ___metal_* routine as an unknown intrinsic, the same refusal an unknown air.* name
  gets;
- a __tensorops_impl_* function in air.externally_defined, outside the matmul2d ABI, as Tensors,
  which is how the matmul2d lowering already refuses its own unmodeled functions.
The same name outside that section is not a family member, and still needs linking.
intrinsics::is_routine_family and tensor_ops::in_family state the two families. docs/REFUSALS.md
lists the new Tensors site.

Verified on the CPU with no device, in job m3-max-82525 at a commit of the same tree
(4974c671a8):
- an_unknown_runtime_library_routine_is_refused_as_its_family is red with this change's product
  files at a0d2d2efdd (___metal_ldexp_float: Linking, expected UnknownIntrinsic) and green with
  them;
- the two look-alike tests and surviving_calls_are_refused_by_family_naming_the_callee pass in
  both runs;
- the refusal surface regenerates to these files exactly, and its --check passes;
- the metal2vulkan-air and metal2vulkan suites: 3455 passed, 22 skipped.
2026-12-02 23:56:01 -08:00
Anees Iqbal a0d2d2efdd rt: a failed wake of the completion thread is owed to the next wake, and a failed host wait is made again
vkSignalSemaphore fails only for want of memory or with VK_ERROR_UNKNOWN,
never with a loss. The wake ignored the failure and marked the thread woken,
under a comment that said a failure is a loss. The thread stayed in its GPU
wait with nothing to end it, and every later flight-only wake returned early,
because the thread already waited for the progress semaphore. With work in
flight, a listener or an end then waited for the front batch to complete.
That is a deadlock where that batch waits on a host signal the listener
would give.

The form (the planner's ruling, which withdrew its "next wait is bounded"
form, a record the wait in progress cannot read):
- A failed signal leaves the wake owed. The thread stays marked waiting on
  the GPU, and the next wake from any thread signals again at a higher
  value, flight-only wakes included. The thread clears the debt as it next
  reads the state.
- There is no polling: tests/event_values.rs's thread-does-not-spin
  assertion holds as before.
- The limit, stated in the code: a failed wake that no later wake follows
  waits for the wait's other semaphores.

vkWaitSemaphores (the dma-bufs import's bind wait before vkDestroyBuffer)
and vkDeviceWaitIdle ignored every failure under a comment that named loss
alone. Both now go through complete::wait_through:
- success, a loss the call reports, or a loss the runtime has seen ends the
  wait;
- an out-of-memory or unknown result, which says nothing of what is
  pending, is called again 100 ms (LOSS_POLL) later.
So a lasting out-of-memory result on a live device waits, and no buffer
whose bind may still be pending is destroyed. On a lost device,
vkDeviceWaitIdle returns success or VK_ERROR_DEVICE_LOST in finite time
(Lost Device), so a teardown does not spin on a dead device.

The two tests of the previous commit, failed_waits.rs, turn green here
through the same seams (fail_wakes, fail_waits).
2026-12-02 23:36:31 -08:00
Anees Iqbal ed23a06f5f rt test: a failed wake and a failed idle wait, red before their fix
Two device tests through two test seams on Core, in fail_begins' style:
fail_wakes fails the completion thread's next wakes as vkSignalSemaphore out of
host memory, and fail_waits fails the device's next idle waits before the
driver is called. Each seam is wired into today's path unchanged: the wake
still ignores the failure and marks the thread woken, and the idle wait still
returns.

- a_failed_wake_is_owed_to_the_next_wake: a fill is in flight behind the Busy
  gate, a listener is posted at a value the host already set, and its wake
  fails. The test expects a second fill's commit, a flight-only wake, to
  deliver the owed wake while the gate still holds both fills. Today that
  wake returns early, so the listener waits for the gate.
- a_failed_idle_wait_is_made_again: a fill is in flight behind the gate and
  the idle wait's first call fails. The test expects the idle wait not to
  return while the gate holds the fill. Today it returns at once.

Both are expected to fail at this commit. The next commit is the fix.
2026-12-02 23:36:31 -08:00
Anees Iqbal f606e43b30 Tests: re-bless the golden tables at pin P
The engine inventory, the golden hash table and the air_input printouts, re-blessed at
1a84985dd4 on the M3 (potluck job m3-max-82483: inventory=0, golden=0, printouts=0, and the
metallib half of committed_air_fixtures_parse_and_link un-skipped, linkhalf=0). The texture
buffer words, sRGB draw writes and mul24 work since the last bless added the tb_word_formats,
fpv_srgb_draw_storage and int24_products fixtures and moved SEMANTICS_VERSION to 2332, so the
bless-due tests (engine_fixtures_match_their_golden_printout, inventory_lists_every_fixture_in_order,
golden_hashes_match_the_table, llvm_as parts 4 and 8) read red until this commit.

Files: golden_hashes.tsv, public_fixture_expectations_engine.tsv, and the two new printouts
air_input/tb_word_formats.txt and air_input/fpv_srgb_draw_storage.txt. Nothing else.
2026-12-02 23:35:58 -08:00
Anees Iqbal 1a84985dd4 Validation test: a texture over a no-copy import asserts the copies of the form the run reports
The test a_bytes_form_no_copy_buffer_is_an_import_and_a_descriptor_form_one_a_pool_buffer
asserted one imported over copy: the copy at use of a texture over host memory's import held in
an image of its own. A texture over host memory's import is now in place on an integrated or CPU
device whose external image query takes a linear image for that handle, its bytes saved and
written back once around its move home, so it counts that restore pair: two imported copies and
none at use. On the 780M (Phoenix, RADV, job m3-max-82442) the test read 2 and failed; its line
was "textures over buffers 2: 2 in place, 0 in an image of their own", with 2048 bytes of
host-memory restore. The product's count is the documented one; the test's expectation was
stale.

The test now reads each texture's form from what the run reports and asserts the copies that
form makes:
- #6, the one texture over an import, is in place where the device counts one texture in place
  over an import (textures_in_place_over_imports). Then it takes the restore pair: two imported
  copies and two host-memory restores of equal bytes, each at least the 784 bytes under the
  texture's rows, and none at use. Else it takes one imported copy of its 64 bytes at use, for
  host memory's cause or a linear-image decline.
- #13, over pool buffer #4, is in place where the textures-over line's in-place count, less #6,
  says so, with no copy. Else it takes one pool-side copy of 64 bytes at use.
- The at-use copies by cause sum to the textures in images of their own.
The test prints each texture's form and, where declined, its cause.

Verified on the fix's first form, the same assertions:
- 780M (Phoenix), m3-max-82451: both in place, #6 by its restore pair (2048 bytes), passed.
- Iris Xe, m3-max-82452: both declined for pitch (the linear image's row pitch or start is not
  the texture's 256), one copy each at use, passed. That is why the Iris read 1 before.
- RTX 2080, m3-max-82453: #6 for host memory (a discrete device), #13 for pitch, passed.

Product code is unchanged.
2026-12-02 23:25:26 -08:00
Anees Iqbal 28e4da1f17 Docs: Metal's resolve rounds a tie as its GPU does, and the alpha-to-coverage note's devices at 8 samples
The planner's ruling on resolve rounding: rule 1 counts a resolve among the device's own answers,
and two Macs round an average that lies exactly halfway between two codes differently, so Metal
fixes no answer there for a guest. An Apple M3 Max (macOS 27.0.1) rounds the tie up, as the
conformance recordings sample-positions-default-2x and -4x hold (red 1/255 over half the samples
resolves to 1); an AMD Radeon Pro 5300M (macOS 26.7.1) rounds it to the even code (red 0 at 1 of
2, 2 of 4 and 4 of 8 samples, an alpha of 127.5 to 128; m3-max-82284). The device's own rounding
stands; no behaviour changes and neither Mac's rounding is emulated.

- PrecisionNote::DeviceRoundedResolve's doc and docs/API.md's catalogue entry name both measured
  answers with their sources.
- The seven known-gaps-rt.tsv rows of sample-positions-default-2x and -4x (Iris Xe, RADV, NVIDIA,
  llvmpipe) say they differ only by how a tie rounds, and why that stands;
  docs/CONFORMANCE-COVERAGE.md regenerated from them.
- PrecisionNote::DeviceAlphaCoverage's doc and its catalogue entry say exactly which devices are
  measured at 8 samples: the 5300M (m3-max-82239); the M3 Max, which renders no 8 samples and so
  has no answer there; no device the runtime runs on. They said before both that the 5300M was
  measured at 8 and that 8 was unmeasured on every device.
2026-12-02 23:19:49 -08:00
Anees Iqbal e54cf61edd Translator: SEMANTICS_VERSION 2332 for mul24 and mad24
12cd7bc987 lowers air.mul24 and air.mad24 (both signs, i32 and 2 to 4 of its lanes), which the
translator refused as UnknownIntrinsic, so a kernel that calls one translates under an unchanged
key where it refused before: a cached FALLBACK of it is stale. The golden tables are re-blessed on
development.

Metal's answer: the product of the operands' low 24 bits, zero-extended for u and sign-extended for
s, and for mad24 its 32-bit sum with z, in the specification's range and outside it, at every word
of int24-products-in-range and int24-products-outside-24-bits on the Apple M3 Max under macOS
27.0.1 (m3-max-82247); the AMD Radeon Pro 5300M under macOS 26.7.1 answers both cases with the same
output sha256 as the M3's, 5bf881c0 and f8cce5fb (the fixture compiled at run time, the cases'
buffers; m3-max-82284).

Verified: at this change on ee6911e100 (cab2e25131), clippy plain, --cfg m2v_gpu and
--cfg m2v_cpu_icd and Rustdoc clean; the core suites 3715 passed, 39 skipped; validation 1322
passed, 3 skipped; conformance 1050 passed; doctests 2 passed; both cases Match Metal's rows on
lavapipe (m3-max-82325) and on the AMD Radeon RX 7900 XTX (m3-max-82350); the guest's kernel that
was refused compiles, PASS on the RADV and lavapipe profiles (m3-max-82349). At this change on
86190052f5 (68e8a17200): fmt --check and clippy plain clean, the translator and AIR suites 3437 passed, 37
skipped, both cases Match Metal's rows on lavapipe (m3-max-82408).
Before that: the int24_products kernel PASS with spirv-val clean on all fifteen profiles (m3-max-82287); a states-only play of glbench-780m-r4-recnil on lavapipe, 3756 render and
484 compute states made, 0 refused (m3-max-82292).

Re-laid onto d12395fc12, whose new commits touch no file of this change but the version file's
RUNTIME_VERSION line.
2026-12-02 23:17:29 -08:00
Anees Iqbal 5150424104 Translator: the math sweep takes mul24 and mad24 at 32-bit lanes alone; the signature table's two variants
every_math_entry_decodes_and_checks spells every table entry at every integer width, and read
air.mul24.s.i8 as unknown, which 12cd7bc987 means: mul24 and mad24 are of i32 lanes alone. The
sweep now skips their other widths, as it skips dot's scalars; the decode test of 12cd7bc987
holds those widths unknown.

api_signatures.tsv gets the two variants 12cd7bc987 adds to the published
metal2vulkan-air::intrinsics::MathFn, Mul24(Sign) and Mad24(Sign)
(scripts/api-signatures/signatures.py --bless): an addition, nothing removed or changed.

Both failed in the gate at 12cd7bc987 (m3-max-82287), whose other 3431 translator and AIR tests
passed, the arith sweep's mul24 and mad24 kernels and the new decode test among them.
2026-12-02 23:17:08 -08:00
Anees Iqbal 0d4295e5f6 Tables: int24_products's golden printout, and its inventory rows confirmed by the bless
bless_engine_goldens under the pinned LLVM 21 on the M3 (m3-max-82288) writes the fixture's
printout, its sixteen calls decoded as Mul24 and Mad24 of both signs at 1 to 4 lanes.
bless_engine_inventory in the same job leaves the two int24_products rows of 617853c57b as they
are: the kernel translates on all fifteen profiles from the opaque and the typed text.

The same bless also wrote rows and a printout for engine/tb_word_formats, another change's fixture
already on development; they are left to development's bless, as are the golden hashes.
2026-12-02 23:17:08 -08:00
Anees Iqbal 12cd7bc987 Translator: mul24 and mad24 are the 32-bit product of their operands' low 24 bits
A guest's screen-sharing encoder makes a compute pipeline whose kernel calls air.mul24.u.i32, and
the translator refused it as UnknownIntrinsic. The guest's module declares four of the family
(air.mul24 and air.mad24, s and u, of i32); Apple's compiler spells sixteen
(air.{mul24,mad24}.{s,u}.{i32,v2i32,v3i32,v4i32}, m3-max-82233). All sixteen decode now.

The Metal Shading Language specification (4.1, section 6.4, Table 6.2): mul24 "multiplies two
24-bit integer values x and y and returns the 32-bit integer result. x and y are 32-bit integers
but only the low 24 bits perform the multiplication"; mad24 "uses mul24 ... adds the 32-bit
integer result to the 32-bit integer z". Below the table the product is defined for x and y in
[-2^23, 2^23 - 1] signed and [0, 2^24 - 1] unsigned and implementation-defined outside them.
The Apple M3 Max (macOS 27.0.1) answers outside that range too with the product of the operands'
low 24 bits, zero-extended for u and sign-extended for s: 480 of 480 words of
int24-products-outside-24-bits, where the 32-bit product of the whole operands differs at 386
(m3-max-82247). That outside-range equality is measured on the M3 only.

Now:
- intrinsics::math decodes air.mul24.<s|u>.<T> and air.mad24.<s|u>.<T> as MathFn::Mul24 and
  MathFn::Mad24, for T i32 or a vector of it; any other element width stays undecoded.
- canon::routine replaces each call, after SCCP as it does OpenCL C's mad, by plain AIR in T's
  shape: each operand's low 24 bits (and 0xffffff for u; shl 8 then ashr 8 for s), their 32-bit
  mul, and for mad24 the 32-bit add of c, all without nsw or nuw. One form on every device and no
  precision note: it is the table's own wording, and it equals Metal at every word measured.
- Lowering takes them as it takes any such instructions; a Mul24 or Mad24 call that survived
  canonicalization is an invariant failure, as a mad call is.

Tests: mul24_and_mad24_decode_on_32_bit_lanes_alone (the sixteen names; i16, i64, i8 lanes, a
float, no sign and a prefix stay unknown). The arith sweep's five mul24 and mad24 kernels
(cc5adc7e7c), the int24_products inventory rows (617853c57b) and its two validation cases
(7fcd661645) are the red tests this turns green.
2026-12-02 23:17:08 -08:00
Anees Iqbal cc5adc7e7c Translator test: mul24 and mad24 multiply their operands' low 24 bits on every profile (red)
Five kernels of the arith sweep, each validated and interpreted on every profile:
air.mul24.u.i32 of 0x01FFFFFF and 0x00FFFFFF (0xFE000001, where the 32-bit product of the whole
operands is 0xFD000001), air.mul24.s.i32 of 0x00800000 and 0x7F000003 (bit 23 sign-extends:
0xFE800000, not 0x01800000), air.mad24.u.i32 adding all 32 bits of -1, and per-lane
air.mad24.s.v4i32 and air.mul24.u.v3i32 of operands with bits above bit 23. The expected values
are the product of the operands' low 24 bits, zero-extended for u and sign-extended for s, then the
32-bit sum, as the M3 Max answers the int24_products cases in and outside the specification's
range (m3-max-82247).

Red: the translator refuses each as UnknownIntrinsic.
2026-12-02 23:17:08 -08:00
Anees Iqbal 7fcd661645 Validation cases: Metal's answer for mul24 and mad24 in and outside their 24-bit range (red)
Two authored cases over engine/int24_products, 12 threads, out filled with 0xAB: operands in the
range the Metal Shading Language specification gives mul24 (section 6.4, after Table 6.2:
[0, 2^24 - 1] unsigned, [-2^23, 2^23 - 1] signed), and operands outside it, each beside small
in-range partners, where the specification calls the product implementation-defined. The addends
are full 32-bit words in both. Installed with corpus-case-check (m3-max-82243) and qualified on
Metal on the Apple M3 Max, three executions each (m3-max-82247).

Metal's outputs against the kernel computed on the CPU, word for word (480 words each):
- in range: equal to the 32-bit product of the operands, and equal to the product of their low
  24 bits (zero-extended unsigned, sign-extended signed), which agree there;
- outside the range: equal to the product of the operands' low 24 bits at all 480 words; the
  32-bit product of the whole operands differs at 386 of them.

scripts/qualify-public-cases runs both on lavapipe against those rows. They are red until the
family is lowered: today the translator refuses the kernel as UnknownIntrinsic.
2026-12-02 23:17:08 -08:00
Anees Iqbal 617853c57b Fixtures: int24_products's companions, and its inventory rows written as ok on every profile (red)
The companions come from scripts/regen-air-fixtures on the M3 (job m3-max-82233: Metal 32023.922,
SDK 27.2). Apple's compiler spells the family as sixteen intrinsics, air.mul24.<s|u>.<T>(T, T)
and air.mad24.<s|u>.<T>(T, T, T) for T in i32, v2i32, v3i32 and v4i32, and the fixture's module
declares all sixteen. MSL on macOS spells no wider form: the header's 8- and 16-lane overloads sit
behind __HAVE_NATIVE_WIDE_VECTORS__, which is not defined there, and uint8 and int16 are reserved
names (the same job).

The engine inventory's two rows expect the kernel to translate on every profile. They are red
until the family is lowered: today each profile refuses it as UnknownIntrinsic. The golden
printout under tests/air_input follows the decoder's change.
2026-12-02 23:17:08 -08:00
Anees Iqbal 2c8f839869 Fixtures: int24_products, mul24 and mad24 of both signs at every width MSL spells them (source)
Our own MSL for the air.mul24/air.mad24 family the translator refuses as UnknownIntrinsic (a
guest's screen-sharing encoder meets air.mul24.u.i32 in a compute pipeline). One kernel calls
mul24 and mad24, unsigned and signed, as a scalar and at 2, 3 and 4 lanes, over 12-value operand
rows of each sign rotated per thread, with full 32-bit addends, and stores every lane's bits:
40 words a thread. The companions come from scripts/regen-air-fixtures in the next commit.
2026-12-02 23:17:08 -08:00
Anees Iqbal d12395fc12 Versions: runtime 2557 for supportsTextureSampleCount: answering 8
RUNTIME_VERSION 2556 -> 2557: a device whose framebuffer colour, depth and stencil sample counts
hold 8 answers yes for 8 to supportsTextureSampleCount:, answers getDefaultSamplePositions:count:
at 8 with Vulkan's standard 8 locations instead of refusing it, and a pass at 8 samples takes
custom positions where its answer to programmableSamplePositionsSupported is yes.

runtime-sources.sha256 holds the inputs' new hash, computed as the build script computes it (the
same computation gives development e0fe34be0c's committed 70aa1707cd...).
2026-12-02 23:13:13 -08:00
Anees Iqbal efe893738c Translator, runtime: supportsTextureSampleCount: answers 8 where the device renders it into a colour, a depth and a stencil attachment
The planner's ruling: raster_sample_counts, which supportsTextureSampleCount:,
getDefaultSamplePositions:count: and programmableSamplePositionsSupported read, is the device's
framebufferColorSampleCounts, framebufferDepthSampleCounts and framebufferStencilSampleCounts,
intersected with 1, 2, 4 and 8. A query answer, not a second form: a device that renders 8 into
all three attachments answers yes for 8, as a Mac's AMD GPU does (an AMD Radeon Pro 5300M under
macOS 26.7.1, job 82204) and Apple10 does, where the Apple9 table answered 1, 2 and 4 alone.
TEXTURE_SAMPLE_COUNTS leaves the apple_gpu table, whose other answers are Apple9's.

Nothing else capped at 4: a texture's samples are its format's own (Limit::TextureSamples), the
pipeline link maps 8, the sample mask takes a word, Vulkan's standard locations hold 8, and
interpolate_at_sample reads index & (n - 1).

Metal at 8, measured on the 5300M (job 82239), and where ours can differ:
- interpolate_at_sample: indices 0 to 9, 15, 16, 100, 2^31 - 1 and 2^32 - 1 read sample
  index mod 8, the runtime's answer; InterpolantAt::Sample's doc says so.
- Alpha to coverage: the 5300M covers a pixel at one sample at an alpha of 1/2 or above, every
  pixel alike, and at two, four and eight samples floor(alpha * n + 1 - t), t 1/8 and 3/8 at even
  and odd x of an even row, 5/8 and 3/8 of an odd one; every pixel floor(alpha * n) or
  ceil(alpha * n). The device's own mapping may differ: PrecisionNote::DeviceAlphaCoverage (and
  docs/API.md's catalogue) now states the 5300M's rule beside the M3 Max's and that eight
  samples are unmeasured on every device.
- Default positions at 8: the 5300M's answer is Vulkan's standard 8 locations.

Docs that said 1, 2 and 4: Device::supports_texture_sample_count and default_sample_positions,
the floor's standardSampleLocations line, RenderPassDescriptor::sample_positions, positions.rs,
the runtime README (default positions, the floor table) and metal_properties' field.

Verified: the stacked gate (m3-max-82337, this change on the (i)+(b) hand-over): fmt, clippy in
three configurations, rustdoc, doctests, the validation suite 1322 passed (3 skipped), the
product suite 3725 passed with the five reds development's next bless takes (none of this
change's), the runtime's lavapipe suite 974 passed (4 skipped); the red commit's tests green on
lavapipe (2 translator, 9 runtime). On an RTX 3090 (m3-max-82314), an RX 7900 XTX and a 780M
(m3-max-82315) and an Iris Xe (m3-max-82316), the same patch on 8a2acc84fb: the runtime's 9
sample-count and sample-position tests pass, each device answers yes for 8 with Vulkan's
standard 8 default positions and answers programmableSamplePositionsSupported yes.
2026-12-02 23:12:42 -08:00
Anees Iqbal fda1e3602e Tests: supportsTextureSampleCount: answers Metal's 1, 2, 4 and 8 a device renders into a colour, a depth and a stencil attachment (red)
The planner's ruling: a device answers each of Metal's sample counts, 1, 2, 4 and 8, that its
framebufferColorSampleCounts, framebufferDepthSampleCounts and framebufferStencilSampleCounts all
hold. A Mac with an AMD GPU renders 8 samples (an AMD Radeon Pro 5300M under macOS 26.7.1 answers
supportsTextureSampleCount: yes for 1, 2, 4 and 8 and no for 16, job 82204), as Apple10 does
("Maximum sample count in render passes with MSAA" 8); the runtime answers an Apple9 GPU's 1, 2
and 4 alone today.

- The translator's metal_properties tests hold raster_sample_counts to the three framebuffer
  counts and {1, 2, 4, 8} on every committed profile: lavapipe 1, 4 and 8, moltenvk-m3 1, 2 and 4.
- The runtime's four-sample draw test holds the device's answer at every count from 0 to 64 to
  the same rule from the device's own limits.
- Metal's default positions at 8 samples, the 5300M's getDefaultSamplePositions:count: answer
  (job 82204, Vulkan's standard 8 locations), join the table the runtime's default-positions test
  compares with, which now reaches 8 wherever the device answers yes.

Red until the answer changes: today every profile and device that renders 8 answers no for it.
Verified red at this commit on 8a2acc84fb (m3-max-82304): both translator tests fail (lavapipe's
answer 1 | 2 | 4 where the rule gives 1 | 2 | 4 | 8, and the like on every profile that renders 8),
and the runtime's draw test fails on llvmpipe at 8 samples (framebuffer counts 0xd).
2026-12-02 23:12:41 -08:00
Anees Iqbal c1e6805526 Conformance: the sample positions family at 8 samples, carried from an AMD Radeon Pro 5300M
The oracle, an Apple M3 Max, renders no 8 samples (supportsTextureSampleCount: answers no for 8),
and a Mac with an AMD GPU does. Three rows run the family's pass at 8 samples: the device's own
positions against an edge at 5/8 of the pixel (5 of 8 samples), eight positions at x 0.25 (8 of
8) and one at 0.25 with seven at 0.75 (1 of 8). Their Metal answer is carried from an AMD Radeon
Pro 5300M under macOS 26.7.1, plain and under Metal's API validation layer, which passed the
passes (job 82284, the usage-edges probe sample_positions_8.m): the resolved texels
01 00 00 9f, 01 00 00 ff and 00 00 00 20, record mode forbidden on the oracle.

Each row's coverage avoids a resolve halfway between two codes: there the 5300M rounds to the
even code (4 of 8: red 0, alpha 128; and 1 of 2 and 2 of 4: red 0) where the M3 Max rounds a half
up (red 1), which is the device's own rounding (PrecisionNote::DeviceRoundedResolve), not where
the samples are. The probe's sweep of the default positions, an edge at each even sixteenth,
covered 0 to 8 samples in order, as Vulkan's standard 8 locations do.

The rows are sample-positions-8x-default, -8x-custom-left and -8x-custom-mixed, one prefix that
tests::a_carried_answer_taken_on_another_chip_names_it lists beside managed-named-* as the 5300M's.
Their recordings were written on the oracle by record mode's carried path, which runs no Metal,
with the timing record `times --write` keeps for a case whose Metal leg is forbidden
(m3-max-82412).

Verified: the conformance suite and its clippy (m3-max-82421); the rows replayed through the
runtime on lavapipe (m3-max-82337, m3-max-82421), an RTX 3090 (m3-max-82314), an RX 7900 XTX
(m3-max-82315) and an Iris Xe (m3-max-82316): every byte equal to the 5300M's, each row announced
only by the device's own colour conversion or point size notes. The 2x and 4x default rows, whose
resolve halves a code, stay the known gaps the ledger holds on those cards.
2026-12-02 23:12:41 -08:00
Anees Iqbal febb227781 Conformance probes: a discrete GPU's single-sample readback through Managed textures
alpha_coverage_sweep.m and pull_model_interpolation.m read their single-sample textures through
Shared storage, which a Mac with a discrete GPU does not take for a texture: there the read
texture was never made and every word read zero. On such a Mac (hasUnifiedMemory false) the
single-sample textures are Managed, and a blit synchronizes them before the CPU reads them.

Verified: both probes ran on an AMD Radeon Pro 5300M (macOS 26.7.1, job 82239) and read the
alpha-to-coverage pattern at 1, 2, 4 and 8 samples and interpolate_at_sample at every index of 8
samples, where the Shared form read zero (job 82204).
2026-12-02 23:12:41 -08:00
Anees Iqbal e0fe34be0c Runtime README: a Managed copy-in's own command buffer and barrier, per commit that takes one
On a device that keeps a device copy of a Managed buffer, every commit that takes a copy-in
records its copies into a command buffer of the runtime's own, with one barrier after them (a pair
where textures over the ranges in images of their own take copies in). Since a commit takes only
the ranges of the buffers its own encoders name, plus the first bytes of buffers made since the
last commit, a program that names ranges of several buffers and spreads their uses over several
command buffers pays that command buffer and barrier at each such commit. The known gaps of memory
blocks now say so, with the counters that count them (Metrics::runtime_command_buffers and
Metrics::upload_barriers).

Docs only. The text follows the code at development's tip: capture::copy_in records one
vkCmdCopyBuffer per buffer and record::barrier counted as UploadBarriers, or over::record_side's
pair where textures over the ranges take copies in; Changes::take takes the named ranges of the
buffers the committing command buffer keeps and every buffer made since the last commit. It names
no figure.
2026-12-02 23:08:56 -08:00
Anees Iqbal 86190052f5 Versions: semantics 2331, artifact format 604, runtime 2556 for a texture buffer read through a sampler by its words
SEMANTICS_VERSION 2330 -> 2331: a read through a sampler of a texture buffer held as words is
built by the words (the sampler's addressing, the words' width and the border texel by code), and
no texture buffer access records RuntimeFact::TexelBufferOwnView, which goes.

ARTIFACT_FORMAT_VERSION 603 -> 604: RuntimeFact loses the TexelBufferOwnView variant
(cache/codec.rs).

RUNTIME_VERSION 2555 -> 2556: the runtime no longer refuses a draw or dispatch that binds a
texture buffer held as words where an own-view access reaches it (Gap::TexelBufferOwnView and
its plumbing go).

runtime-sources.sha256 holds the inputs' new hash (device/mechanism.rs, an input, loses the
fact's mechanism row), computed as the build script computes it (the same computation gives
development 13d511cfe9's committed a929dd9581...).
2026-12-02 23:06:13 -08:00
Anees Iqbal 11c211ca64 Translator, runtime: no texture buffer access takes an own view a texture buffer held as words lacks; the own-view fact and gap go
The planner's ruling (b) after (i): with a read through a sampler built by the words, no access
MSL writes leaves a texture buffer on its own view on a device that holds some format as words,
so the runtime's Gap::TexelBufferOwnView and its plumbing (the kernel interface's own views, the
render content's, the encoders' checks before binds_words) go, and with them
RuntimeFact::TexelBufferOwnView, which nothing produces now.

Each access the words do not build now has an outcome that is not wrong output:
- A read that observes its residency is the words': its status word is 0, Metal's for a texture
  that is not sparse, as a texture buffer never is (with_word's 0); words::wrap no longer sends it
  to the own view.
- A read of an sRGB texture's codes is never a texture buffer's: srgb_texels answers false for a
  buffer's shape, so Read::raw is false there. Were one met, the compile refuses it.
- A read or write in another numeric class (LoweringInputs::cross_class): the runtime never sets
  it, and under the identity domains no variant is chosen; on a profile that holds some format
  as words the compile refuses such an access (Feature::Format, not implemented).
- A write of fewer than four lanes: the AIR front end takes a colour texture's write of four lanes
  alone (texture.rs, texel_ok), so such a call is an unknown intrinsic on every profile. The new
  authored case a_texture_buffer_write_of_two_lanes_is_refused_on_every_profile (an inline .ll of
  a8r_buffer_write narrowed to <2 x float>) checks Feature::UnknownIntrinsic on lavapipe and
  moltenvk-m3 under the identity domains.

Docs: words.rs module docs and wrap's doc, the runtime README's known gap rewritten as the
refusals; REFUSALS.md and the error basis regenerated (Gap 32 -> 31); api_signatures drops the
fact's and the gap's variants. The mechanism test's variant count returns to 87.

The fixture census at (i)'s tip, the condition the ruling set before this deletion (scratch job
m3-max-81238, steelbrain/scratch-tb-census): 18 fixtures naming texture buffers, 1477
compilations, no own-view fact on any profile that holds a format as words.

Verified with (i) at 355c902082 (gate m3-max-82186): fmt, clippy in three configurations, rustdoc,
the validation suite 1322 passed (3 skipped), the conformance suite 1050 passed, doctests; the
product suite 3723 passed with four reds a bless clears (the golden printout, the golden hashes,
the inventory, and llvm_as part_3_of_8 for tb_word_formats.ll, which has no rows until then),
the new authored case among them passing; the card legs as (i) lists them.
2026-12-02 23:05:54 -08:00
Anees Iqbal c56000f9e4 Translator: a texture buffer held as words is read through a sampler by the words
A read through a sampler (MSL 4.1's read(sampler, coord)) of a texture buffer took the texture's
own view alone, and where the device held the bound format as words the runtime refused the
draw or dispatch (Gap::TexelBufferOwnView). The words now build it: the site reads the
sampler's state (through::state), addresses the index against the words' width the way the own
view's read addresses it against its size (through::buffer_index, which address() now calls for
a texture buffer: the first texel outside, the nearest where a runtime slot sampler's s mode is
clamp_to_edge, the border where the t mode is clamp_to_zero or clamp_to_border), calls the read
routine at the addressed index, and where it reads the border hands back the border texel of
the format the word's code names (words::border_texels), the alpha 1 of a format without alpha
included. Such a read no longer records RuntimeFact::TexelBufferOwnView; the remaining own-view
accesses are a read that observes residency, a read or write of another numeric class, a read of
an sRGB texture's codes and a write of fewer than four lanes.

The site's word estimate adds the sampler's addressing again and THROUGH_WORDS (the view's size,
the width, the border texels by code).

Tests: engine_identity's read-through test now asserts no own-view fact and a words routine
where the profile holds formats as words. The runtime test reads rt_buffer (mirrored_repeat),
rt_buffer_ow (clamp_to_border, opaque white) and rt_arg_buffer through three runtime sampler
states (clamp_to_edge; t clamp_to_zero; t clamp_to_border opaque black) over six formats in
either form, against Metal's texel in bounds and outside.

Docs: words.rs module docs, the fact's and the gap's docs and Display, the runtime README's known
gap, RESOURCE-ID.md; REFUSALS.md regenerated.

Verified at the hand-over tip 355c902082, with (b), on development 8a2acc84fb: clippy in the
three configurations and the translator's tests (gate m3-max-82186; the read-through and words
tests 120 passed, m3-max-82186's focused step); on lavapipe the runtime's texture buffer tests 13
passed and the stream test passed, and the runtime's whole suite 972 passed, 4 skipped; the
read-through test over the three sampler states and six formats on an Iris Xe (m3-max-82187), an
RTX 3090 (m3-max-82193) and an RX 7900 XTX and a 780M (RADV, m3-max-82282), each format in its
form there (B5G6R5Unorm as words on the 3090, the XTX and the 780M); the read-through-buffer
conformance replay on lavapipe, base 8a2acc84fb against the tip, 0 of 1 cases differ
(m3-max-82188).
2026-12-02 23:05:54 -08:00
Anees Iqbal 13d511cfe9 Docs: unorm_values names its test as text, which a private-items doc build cannot link
The doc comment of lower/texture/words.rs's unorm_values linked `tests::unorm_mirror`, an item of a
cfg(test) module that no doc build has, so `cargo doc -p metal2vulkan --all-features --no-deps
--document-private-items` under -D warnings stopped on rustdoc::broken-intra-doc-links. The test is
named as code text instead. The public doc build, which the gate runs, did not see the link.

Verified: m3-max-82334, fmt --check and the private-items doc build of metal2vulkan EXIT=0.
2026-12-02 22:48:10 -08:00
Anees Iqbal fd93d1695f rt test: a render state's sRGB variant is kept in the bounded map of contents
The draw-side sRGB form keeps each render state's sRGB variant in the device's map of contents
beside its content, under the descriptor's key with its slots. The kernel's variant had a
fill-past-capacity test and the render variant had none, so this adds it: at a cap of 2, the float
fragment writer's content and its variant fill the map, a reuse onto the other twin or an
RGBA8Unorm texture makes nothing, the half writer's content and variant push both out, and the
float writer's next draw onto a twin makes its variant again (translations_at_encode 1, 1, 2, 3;
kernel_entries 2 throughout). each_device's settle then waits for every gauge, render_contents and
kernel_entries among them, to read zero once the device drops. The runtime README's paragraph on
makes at encode is re-wrapped, its words unchanged.
2026-12-02 22:44:30 -08:00
Anees Iqbal ee6911e100 Runtime README: the half simdgroup tree's four forms and their cost on three cards, as a known gap
The gap named the float route alone, measured by forcing it on an RTX 2080 with the shuffle tree
since deleted. It now states the tree's four forms and their two choosers: the SIMD-group
operations query (a subgroup tier takes one clustered reduction per round, the emulated tier its
workgroup tree) and the 16-bit floats query (16 bits under the 16-bit float controls, float
rounded to half each round elsewhere). It also states what the tree costs against the device's
reduction of the float values rounded once, which was faster and not Metal's answer.

Rows: a kernel of two simd_sum of half4 on the subgroup tier at 16 bits, GPU time at the 50th
percentile over three alternated rounds with a same-arm pair (carry bin/hsum2: base 7fe0a001 =
development e1e6f52848's product, clus 8cb0caa5 = the clustered tree, eaf11e5c63 before this
series' rebase), exclusive, a device line in every run:
- Iris Xe (RPL-P, ANV), m3-max-81581: 1274.5-1317.9 us against 825.7-880.9 us, medians 1275.2
  and 827.8, +54.0%.
- RTX 2080, m3-max-81598: 805.0-808.3 us against 660.1-665.0 us, medians 807.5 and 662.6,
  +21.9%.
- RX 7900 XTX (RADV NAVI31), m3-max-81839: 7525.8-7538.0 us against 7474.9-7478.9 us, medians
  7526.85 and 7475.55, +0.7%.
The Iris is the slowest GPU, and the clustered form is the fastest right form on it; the 16-bit
shuffle tree ran 2278 us there. The loss on the others is this gap, as ruled.

Verified: docs only; the rows are those jobs'.
2026-12-02 22:40:58 -08:00
Anees Iqbal 3457e092cb Translator: SEMANTICS_VERSION 2330 for Metal's half simdgroup and quad trees
The series lowers a half simd_sum and simd_product as Metal's tree of rounded half operations
(clustered reductions on the subgroup tiers, the workgroup tree on the emulated tier) and an
emulated or quad half step as the 16-bit instruction under the 16-bit float controls, so a module
with any of them translates to other words under an unchanged key. Its first commit's
"SEMANTICS_VERSION 2325 -> 2326" was taken at development by other changes; development reads
2329 at this rebase, so this series takes 2330. The golden tables are re-blessed on development.
2026-12-02 22:40:58 -08:00
Anees Iqbal 4d44991351 Translator: a half simdgroup tree's rounds are clustered reductions, as fast as Metal's tree goes on the slowest GPU
The tree of xor shuffles (16-bit, two halves to a word, or in f32) ran a real kernel of two
simd_sum of half4 2.76 times as long as the device's reduction on an Iris Xe (ANV): Mesa's Intel
backend moves a shuffled lane by indirect addressing, about 150 us of that run per packed word a
round, where a clustered reduction's step is a register-region operation. Round d (1, 2, 4, 8,
16) is now one OpGroupNonUniformFAdd or FMul ClusteredReduce over clusters of 2d lanes in which
the first lane of each d-lane block that takes part brings its block's partial and every other
lane the identity (-0 for a sum, 1 for a product). Each cluster so combines exactly its two
blocks' partials in one rounded operation whatever order the device's reduction takes, and every
lane of it holds the result: Metal's tree. A lane that takes no part adds nothing, so a block
with none leaves the other's partial, as Metal counts such a lane as the identity. In a block
every lane executes a block's first lane is the lane whose index is a multiple of d; where the
group may be partly live it is the lowest set bit of the ballot of the active lanes in the
block. The shuffle code (pack, unpack, the xor and ballot rounds, HalfTree::step) is deleted,
and ops::f16_binary is whole again.

The partials are held as before: at 16 bits under the 16-bit float controls (half_controls, the
16-bit floats query), a 16-bit reduction whose rounding a driver that folds a conversion's round
trip keeps (shaderSubgroupExtendedTypes is in the runtime's floor); elsewhere in f32, each
round's result rounded to half, where the f32 product of two halves is exact and their f32 sum
rounds to the half their sum does (24 >= 2 x 11 + 2). The identity is an f32 constant there, so
a module without 16-bit floats declares none.

Forms of a half simdgroup sum or product in a kernel: 4, two choosers, both in the owner's rule
2 list. The subgroup tier (Direct or Cluster32, the SIMD-group operations query; the class is now
CLUSTERED where it was SHUFFLE) takes these clustered rounds, at 16 bits or in f32 by the 16-bit
floats query; the Emulated tier (the same query finds no subgroup tier, as on runtime-floor,
which offers BASIC alone, or ANV's widest-pin rule) takes its workgroup-memory tree, at 16 bits
or in f32 by the same query.

Verified: rows in the runtime README's known gap and the hand-over (Iris, RTX 2080, RX 7900
XTX, exclusive, three alternated rounds); the engine tests of Metal's half trees and the device
test of full, masked and quad words, named with their jobs in the hand-over.
2026-12-02 22:40:50 -08:00
Anees Iqbal 0cd07d6612 Docs: API.md states the local size contract of a kernel on subgroups, which its shuffles rely on
A translator consumer that is not metal2vulkan-runtime read nowhere in docs/API.md that a
kernel stating RuntimeFact::LocalSizeConstraint runs only threadgroups whose size is a multiple
of it, and that a dispatch at any other size runs the kernel's EmulatedSimdgroups variant. A
half simdgroup sum or product on the Direct and Cluster32 tiers now reads its sibling lanes by
xor shuffles in a block every lane executes, which name an inactive lane in a partial subgroup.
Section 6 now says so, and that the emulated variant gives Metal's answers for the partial
simdgroup, as the runtime's variant choice does (pipeline.rs: a module with multiples gets
KernelVariant::EmulatedSimdgroups).

Verified: docs only; the contract read from device::subgroup::requirement and the runtime's
variant choice.
2026-12-02 22:40:50 -08:00
Anees Iqbal 06ee627760 Tests: the simdgroup products fixture runs each tier at the threadgroup sizes its variant runs at
engine_simd_products ran the Direct variant (32 lanes) and the Cluster32 variant (64 lanes) at
a threadgroup of 40 threads, and Cluster32 at 96 as well. Neither variant is ever dispatched at
those sizes: subgroup::requirement gives both full subgroups and a local size that is a
multiple of the subgroup size (RuntimeFact::LocalSizeConstraint), and the runtime gives such a
kernel its emulated variant (KernelVariant::EmulatedSimdgroups), which runs every other size.
The group instructions the half product used before tolerated the partial subgroup on the
interpreter. The half tree's xor shuffles name lane L ^ d, and the interpreter traps on an
inactive lane (InactiveLane { lane: 8 } at Direct, { lane: 40 } at Cluster32), as SPIR-V makes
that read poison. The runtime's variant choice is the guarantee: Direct and Cluster32 need
full subgroups (LocalSizeConstraint), and any other threadgroup size takes EmulatedSimdgroups,
so a 40-thread dispatch keeps Metal's partial-simdgroup answer through the emulated tier. So the
fixture now runs each tier at the sizes its requirement admits, and the partial simdgroup (40
threads) keeps its run on the Emulated tier at 8, 16, 32 and 64 lanes.

Verified: the gate's suites (81303, at 501f2c0b16) failed these two tests with those
traps and nothing else but the golden table; this commit's run of engine_simd_products and
clippy is recorded in the hand-over.
2026-12-02 22:40:49 -08:00
Anees Iqbal fd97053681 Tests: the runtime half reductions test's model type named, for clippy's type_complexity
Under --cfg m2v_gpu and --cfg m2v_cpu_icd, clippy's type_complexity rejected the cases' array
type in the runtime's half_simd_reductions device test (a tuple holding a function pointer).
The model's type is now the alias `Model`; the cases are unchanged.

Verified: the gate's clippy steps (plain, m2v_gpu, m2v_cpu_icd) rerun on this commit.
2026-12-02 22:40:49 -08:00
Anees Iqbal 7364fcd49b Tests: the half quad model's operation type named, for clippy's type_complexity
Clippy's type_complexity rejected the pair of function-pointer types in the quad model
(`quads`), so the gate's three clippy configurations failed in metal2vulkan-devtools. The
operation type is now the private alias `Operation`; the model is unchanged.

Verified: the gate's clippy steps (plain, m2v_gpu, m2v_cpu_icd) rerun on this commit.
2026-12-02 22:40:49 -08:00
Anees Iqbal faf822ee57 Runtime README: the half simdgroup tree held in float, on devices outside the 16-bit float controls, as a known gap
A half simdgroup sum or product is Metal's tree of rounded half operations on every device.
Which form the tree takes is the 16-bit floats query (narrow::half_controls, read through
group::sixteen_bit_half by HalfTree and workgroup::combine): a module that computes half under
the 16-bit float controls holds the tree at 16 bits; every other module holds it in float and
rounds each step to half. Of the committed profiles, moltenvk-m3 (shaderFloat16 but controls the
module cannot declare), nvidia-pascal-linux (no shaderFloat16) and runtime-floor (no
shaderFloat16) take the float route (engine_native_half's
a_controlled_conversion_rounds_half_where_the_float_controls_allow asserts the split); the ANV,
RADV, RTX 50 series and lavapipe profiles take the 16-bit one. It is that query's existing second
form, not a new one: a module under the controls never reaches the float tree, since both
callers test the same predicate.

The float route's cost goes in the pipeline states' known gaps with its rows, the closest
measure: that form forced on an RTX 2080 (which itself takes the 16-bit route) for a real kernel
of two simd_sum of half4, GPU time at the 50th percentile over three alternated rounds,
m3-max-81173: 691.6-695.4 us against 659.1-660.7 us for the reduction it replaces (+5.1%), where
the 16-bit tree ran 613.3-614.1 us (-7.0%). The line says it applies to that route alone.

Verified: docs only; the rows are m3-max-81173's.
2026-12-02 22:40:49 -08:00
Anees Iqbal c35952d868 Translator: an emulated or quad half sum or product step is the 16-bit instruction under the 16-bit float controls
The emulated tier's tree (workgroup::tree_fold), its prefix sums and the quad tree (quad_tree, on
every tier) combine their half values by workgroup::combine, which ran the f32 operation and
rounded it to half by narrow::round. Where the module computes half under the 16-bit float
controls that rounding is the controlled conversion pair, which a driver's compiler may fold
into the f32 value it started from (NVIDIA's does, narrow.rs), leaving the step unrounded; and
the module records NativeHalfConversion for the pair.

combine now takes the device's 16-bit instruction, kept apart, for a half sum or product where
the module computes half on it (group::sixteen_bit_half, which HalfTree uses too): the choice
half + and * make there (ops::f16_binary), whose rounding a folding driver keeps. Elsewhere it
is the f32 operation rounded by narrow::round, as before. Each step rounds the same exact result
once, so where the pair rounds the values are unchanged. Quad prefix operations on the subgroup
tiers (group::lane_scan) keep their own step.

The engine test of the emulated tier asserts that lavapipe's profile computes half under the
controls and the runtime floor's does not, so the 16-bit step and the rounded f32 step are both
checked against Metal's 64 answers at every subgroup width on the CPU interpreter.

lavapipe (8-lane subgroups, the emulated tier) gives Metal's simdgroup sums and products both
without this commit and with it once T3 is underneath (m3-max-81129: 0 of 256 and 0 of 768 words
differ in each arm); what changes there is that the pipelines no longer round through the pair
and no longer record NativeHalfConversion (notes [NativeHalfConversion, NativeNanEncoding,
DeviceHalfDenormals] before, [DeviceHalfDenormals] after). The quad kernel of the previous commit
is the device check of the quad step on the RTX 2080 and the 780M.

Verified: m3-max-81129 (CPU only, at this series' f32-held arm and at this commit): the
engine tests 5 passed; lavapipe as above.
2026-12-02 22:40:49 -08:00
Anees Iqbal e79b8d0fed Tests: Metal's half quad sums, products and quad prefix operations, on every device
Metal's quad_sum and quad_product of half operands are (x0 op x1) op (x2 op x3) with each
operation rounded to half, and its quad prefix sums and products the lane-order chain over the
quad's lanes with each operation rounded, the empty exclusive sum -0 and product 1. Measured on
the M3 Max (macOS 27.0.1), fast math on and off alike, over the operands of
metal2vulkan_devtools::half_simd_reductions, all 256 threads (m3-max-81130, our own MSL): those
models match every thread; the float result rounded once misses 48 of the quad sums, 64 of the
products and 6 to 25 of each prefix operation.

half_simd_reductions gains a third kernel, QUADS: thread t takes entry t of SUM_OPERANDS and
PRODUCT_OPERANDS and writes five words, its quad reductions, its quad prefix sums and its quad
prefix products, then its simdgroup prefix sums and products. devtools::half_simd_reductions::quads
answers the first three words from those models (a small exact half rounding of an f64 sum or
product). Metal's simdgroup half prefix order matches none of the models (the lane-order chain,
Hillis and Steele, and the float result rounded once miss 60 to 137 threads each), so those two
words are written, not compared: they make the kernel a simdgroup user, which a device with
subgroups narrower than 32 lanes (lavapipe's 8) runs on the emulated tier, quad operations
included.

The runtime's device test runs the kernel on every device beside the two simdgroup kernels and
prints how many of the compared words differ. This is the test of the quad half step the next
commit moves to the 16-bit instruction under the 16-bit float controls.

Verified: cargo fmt only (this Mac runs no builds); the device runs are the timing job's
correctness leg on the RTX 2080, the 780M and lavapipe.
2026-12-02 22:40:49 -08:00
Anees Iqbal 91279f4c7f Translator: a half simdgroup tree under the 16-bit float controls holds its partials at 16 bits
The half simdgroup sum and product tree (group::half_fold) held its partials in f32 on every
route: each of its five rounds shuffled the f32 lanes, narrowed the sibling's partial, ran the
16-bit instruction and widened the result. On the RTX 2080 that form costs 4.7% GPU time on a
real two-simd_sum(half4) kernel against the native f32 reduction it replaces (m3-max-81045,
three alternating rounds, p50 662.5/663.6/664.5 us old against 693.4/696.3/694.7 new),
above the 3% bar.

Where the module computes half under the 16-bit float controls the tree now holds its partials
at 16 bits: the operand narrowed once and the result widened once (both exact, they are half
values), each step the device's 16-bit instruction (ops::f16_instruction, split out of
ops::f16_binary, the same instruction and NoContraction / fma-with--0 form half + and * take
there), and each shuffle moving the partial's lanes two to a 32-bit word, an odd lane count
padded with a zero lane the tree drops. A half4 round is two 32-bit shuffles and the 16-bit
instruction, where the f32 tree took four shuffles and the conversions. The values are the same
bits: each step rounds the same exact result once. Without the controls the tree is the f32
operation rounded by the module's rounding, as before.

The engine test runs the full and masked kernels on NVIDIA's Linux profile too, which computes
half under the controls, so the 16-bit tree is checked against Metal's 64 answers on the CPU
interpreter beside the f32 tree on MoltenVK's and the wave64 profile.

Verified: cargo fmt only so far (this Mac runs no builds). The engine tests, the device test on
the 2080 and the 780M, and the old/f32-tree/16-bit-tree timing on the 2080 are the next job.
2026-12-02 22:40:49 -08:00
Anees Iqbal a1f82878ff Translator: a half simdgroup sum or product is Metal's tree of rounded half operations on every tier
Metal's simd_sum and simd_product of half operands work as a tree. In round d (1, 2, 4, 8, 16),
each aligned block of 2d lanes holds its lower and upper halves' results, combined and rounded
to half. A lane that takes no part counts as the identity. Measured on an M3 Max, macOS 27.0.1,
our own MSL, fast math on and off alike:
- sums: m3-max-80839;
- products: m3-max-80879;
- three masks of active lanes: m3-max-80890.

The Direct and Cluster32 tiers folded the f32-held values with OpGroupNonUniformFAdd or FMul and
rounded once. Rounding once misses five of the eight measured sums (0x3c10 where Metal answers
0x3c0f), four of the eight products, and ten of the 48 masked results. The emulated tier's
exchange rounds already were the tree.

group::half_fold:
- New form. Five rounds; each combines the lane's partial with its sibling block's partial
  through half_step.
- In a block every lane executes, the sibling partial comes from OpGroupNonUniformShuffleXor
  by d. A mask below 32 stays inside a Cluster32 cluster.
- Where the group may be partly live, the sibling partial is the first active lane of the
  sibling block, read with the live lanes' ballot. A block with none leaves the lane's own
  partial: the identity, as the masked probe measured.

half_step:
- On a module that computes half under the 16-bit float controls, it is ops::f16_binary. That
  is the device's 16-bit instruction, whose rounding survives a driver that folds a
  conversion's round trip (NVIDIA's does).
- Elsewhere it is ops::float_binary.
- This is the same choice half + and * make.

There is no 16-bit route for group operations: half group ops run on f32-held values on every
profile, so this covers every route.

Other changes in this commit:
- reads_lanes is true for these operations, so partly_live tracks them.
- direct_ops and cluster_ops need the shuffle class; partly_live adds the ballot.
- words() bounds the five rounds.
- A half simdgroup sum or product no longer records PrecisionNote::ReductionOrder. float and
  double sums and products, every float prefix sum or product, and the matrix and AGX
  multiply-adds still record it.
- The note's doc and docs/API.md's catalogue entry say this per route. They also record that
  Metal's half prefix-sum order is not measured: it matches none of f32 rounded once per lane,
  a lane-order chain of half additions, or a Hillis-Steele scan of them (m3-max-80839).
- Validation's REDUCTIONS table drops simd.reduce.fadd.half and simd.reduce.fmul.half, so a
  comparison holds them exactly. Its tests now name the half scan.
- bfloat has no group operations: decode refuses them.

SEMANTICS_VERSION 2325 -> 2326.

Tests:
- lower::simd::tests::half_sums_and_products_are_shuffle_trees covers the classes and the
  lane reads.
- engine_simd's float_sums_record_their_precision now holds that a float sum records the note
  and a half sum does not.
- The red tests of the previous commit carry Metal's bits.

Verified: cargo fmt only on this host. The red and green device jobs, and the timing on a real
half-reduction kernel, follow before landing.
2026-12-02 22:40:48 -08:00
Anees Iqbal 2695dca124 Tests: Metal's half simdgroup sums and products are trees of rounded half operations (red)
Metal's simd_sum and simd_product of half operands combine the lanes as a tree. In round d
(1, 2, 4, 8, 16), each aligned block of 2d lanes holds its two halves' results combined and
rounded to half, and a lane that takes no part counts as the identity. Measured on an M3 Max
(macOS 27.0.1, our own MSL, fast math on and off alike):
- sums: potluck job m3-max-80839;
- products: m3-max-80879;
- sums and products over three masks of active lanes: m3-max-80890.
The tree matches every answer. The float result rounded once misses five of the eight sums,
four of the eight products and ten of the 48 masked results. The tree over the active lanes
packed together misses three masked sums.

metal2vulkan-devtools' half_simd_reductions holds two kernels of our own AIR, the operands and
Metal's answers:
- half_simd_reductions: eight simdgroups summing and multiplying their lanes in a uniform block;
- half_simd_reductions_masked: the same in blocks only a mask of lanes executes.

Three tests run them:
- engine_simd: the Direct tier at 32 lanes and the Cluster32 tier at 64, on the CPU
  interpreter. Red: those tiers fold the f32-held values with OpGroupNonUniformFAdd or FMul
  and round once.
- engine_simd_emulated: the emulated tier's pairwise tree at every width, on lavapipe's and
  the floor's profiles. Its rounded combine is Metal's tree, so this test is expected green.
- the runtime's half_simd_reductions: under a device cfg, every device of the cfg's kind. It
  prints the kernel subgroup sizes and each pipeline's precision notes.

Verified: none of these tests has run yet; their jobs follow. cargo fmt only on this host.
2026-12-02 22:40:48 -08:00
Anees Iqbal fac3e9cfc0 Runtime: a draw writing an 8-bit sRGB texture runs the render state's sRGB variant
A vertex or fragment function that writes, at a slot it does not read, a texture whose storage
element is its UNORM twin's view was Gap::StorageElement at the draw. It now takes the form the
kernel took: the render encoder finds the texture slots each function the state lowers from its
AIR writes and does not read that hold a twin (TextureObject::encodes) beside the buffer slots it
holds to 4, and draws through the state's content for both (RenderPipelineState::for_draws, made
at the first such draw and kept in the device's map of contents under the descriptor's key with
the slots), which lowers those slots under LoweringInputs::srgb_storage, so each write there is
encoded by the MSL transfer through the device's conversion. KernelKey's srgb is a mask per stage
(the kernel's or the vertex function's, then the fragment function's). The facts skip a slot the
content encodes; read_write stays refused, and so does a twin at a slot of a function the
consumer compiled, which has no variant. A render state whose vertex or fragment function writes
a texture slot it does not read announces PrecisionNote::DevicePackConversion from its creation.
No new query and no second form: the twin's view and its query are the kernel's.

The runtime's README moves the draw out of the sRGB texture's known gap and names the content
among the makes at encode; docs/REFUSALS.md regenerated with no change (the StorageElement sites
are the same; refusal_surface.py --check exit 0). Proof jobs follow.
2026-12-02 22:21:38 -08:00
Anees Iqbal cb98ac0cb5 Conformance: srgb-storage-fragment-writes recorded on Metal, the coverage regenerated
Metal's run on an Apple M3 Max with its validation layer (job m3-max-82183, record then times
--runs 8 --write): each fragment's write stores the same bytes the kernel case's writes store, all
four stored sites equal to srgb-storage-writes' recording. On the runtime at development's tip the
case's draw is Gap::StorageElement; the runtime's draw test is red on lavapipe (job m3-max-82181,
filtered, 3 tests: 2 passed, 1 failed, the new one, refused StorageElement Absent).
2026-12-02 22:21:37 -08:00
Anees Iqbal ea5b786eb4 Red: draw-side writes to an 8-bit sRGB texture, the conformance case and the runtime's test
fpv_srgb_draw_storage's companions (regen-air-fixtures on the Mac, job m3-max-82169). The
conformance case srgb-storage-fragment-writes is the fragment twin of srgb-storage-writes: the same
values, formats, texture and layout, written by fpv_srgb_fragment_write and its half form behind
one triangle over a 256 by 2 RGBA8Unorm attachment. The runtime's test draws the fragment writers
and the vertex writer (rasterization off) onto RGBA8Unorm_sRGB and BGRA8Unorm_sRGB textures with
their twins' storage views, and expects the draw to run through the render state's sRGB variant:
the encode in the bytes, one make at encode, and the state's DevicePackConversion note. At
development's tip the draw is Gap::StorageElement, so the test is red; the Metal recording and the
lavapipe run follow.
2026-12-02 22:21:37 -08:00
Anees Iqbal 8a735791c4 Fixtures: fpv_srgb_draw_storage, vertex and fragment functions writing an 8-bit sRGB texture
Owned MSL for the draw-side sRGB storage lane: a cover vertex function, fragment writers of
float4 and half4 at their pixel, and a vertex writer at its vertex ID's place, each from buffer 0
in a row buffer 1 wide. The companions follow from regen-air-fixtures on the Mac.
2026-12-02 22:21:37 -08:00
Anees Iqbal 8a2acc84fb Runtime README: the Iris's read_write refusal beside the words' measured cost there
The planner closed holding a format as words where its own view lacks the read without a
format (a whole-format move): on the Iris Xe it serves read_write but slows every other read of
those formats, and trades the refusal for another (a read through a sampler would be
Gap::TexelBufferOwnView). The read_write refusal stays the typed known gap
(Gap::StorageElement, ReadWithoutFormat).

The row now records, so nobody times it again:
- job m3-max-82136, Iris Xe (RPL-P), ANV (Mesa 26.2.6, read on the node by job
  m3-max-82150): GPU p50 of texel_buffer_bgra8_read 11857.1 us as words against 9007.0 us as
  its own view (+31.6%), texel_buffer_b5g6r5_read 12133.8 us against 9215.2 us (+31.7%); the
  median of 8 rounds of 500 runs, the two builds alternating, the own view's build against
  itself within 0.1%, every run's values checked against the CPU references;
- job m3-max-82025's listing: the committed ANV profiles (irisxe-rplp, irisxe, uhd770) answer
  the same for seven formats (adding RG11B10Float, RGB10A2Unorm and RGB10A2Uint), and no other
  committed profile does;
- the trigger: no further form is built; that changes on a guest's run or stream that meets the
  refusal.
2026-12-02 22:11:56 -08:00
Anees Iqbal 6589b1df9d Texture buffers: an own view that reads none without a format refuses read_write by name
On the Iris Xe (RPL-P, ANV) the buffer features of BGRA8Unorm, B5G6R5Unorm,
BGR5A1Unorm and BGR10A2Unorm take a uniform texel buffer, a storage texel
buffer and the storage write without a format, so texel_buffer_form holds
them as their own views, but lack VK_FORMAT_FEATURE_2_STORAGE_READ_WITHOUT_FORMAT_BIT.
A dispatch reading one through access::read_write is Gap::StorageElement
(ReadWithoutFormat): job m3-max-81883 failed the runtime test on B5G6R5Unorm,
BGR5A1Unorm and BGR10A2Unorm and the stream test on BGRA8Unorm there.

With that dispatch refused, the runtime test's reads and writes through handles now run on the
Iris for B5G6R5Unorm and BGR5A1Unorm as their own views, whose values are ANV's conversion: it
widens a 5- or 6-bit field by replicating its bits (job m3-max-82043: B5G6R5Unorm's texel 2 read
0.5176471 against the CPU's 16/31). The test takes a normalized format held as its own view within
PrecisionNote::DeviceTexelConversion's recorded bound (docs/API.md's catalogue: one f32 ulp, or
0.18 of a code of a 5- or 6-bit field and 0.015 of a code of a 10-bit one the device widens by
replicating its bits), as the stream test already did.

The ruled query stays. The runtime test and the replay stream test now expect
that refusal by name wherever the device's own view of the format lacks the
read without a format, and the runtime test still checks the format's reads
and writes through handles there. The runtime README records the refusal on
those four formats on the Iris as a known gap, naming the missing feature.
The predicate's docs name the three uses its checks cover (a read through the
uniform texel buffer, the storage texel buffer the view's usage takes, a write
through it without a format) instead of "every access".

runtime-sources.sha256 takes the runtime inputs' new hash: texel_words.rs, an input, changed in
its doc comments alone, which change no behaviour of a run.

Verified with this change on development ece306e521 (its tip then, ee46e48714):
- Iris Xe, job m3-max-82058: the stream test passed (BGRA8Unorm and B5G6R5Unorm play
  their recorded IDs, then the read-written one is refused by name at the dispatch;
  RGBA8Unorm, R8Unorm and RGBA16Unorm the CPU's texels and values); the runtime's
  texture buffer tests 11 of 11 (B5G6R5Unorm, BGR5A1Unorm and BGR10A2Unorm answer
  within the bound, their read_write refused by name);
- RTX 3090, job m3-max-82043 (976685a17e, before the bound, which its words do not
  take): stream passed, runtime texture buffer tests 11 of 11;
- lavapipe and CPU, job m3-max-82057: clippy in the three configurations, rustdoc,
  validation 1320 passed, conformance 1048 passed, the runtime's suite 964 passed
  (4 skipped), texture buffer tests 13 of 13, the stream test passed.
2026-12-02 22:11:27 -08:00
Anees Iqbal 58f2768bae Runtime README: the words twin's B5G6R5Unorm read against the same words with no stage constant
The planner accepted the twin's read of a B5G6R5Unorm texture buffer held as words at 2.3% more
GPU time than the same words compiled with no stage constant (the per-format query's form) on
the RTX 3090, and let the known gap carry the row. The words-cost known gap now gives it, with
the RX 7900 XTX's 2.1%:

- RTX 3090, exclusive job m3-max-81336, 4 rounds rotating the arms, median of each round's GPU
  p50: read 167.6 us (spread 1.01%) against 163.8 us (1.16%); write 312.0 us against 310.9 us.
- RX 7900 XTX (RADV), exclusive job m3-max-81364, the same: read 93.1 us (1.07%) against
  91.2 us (0.88%); write 85.9 us against 86.0 us.

On both cards the device's profile holds B5G6R5Unorm as words; base refuses the format there.
Documentation only.
2026-12-02 22:11:27 -08:00
Anees Iqbal 0573a6fe47 Versions: semantics 2329, artifact format 603, runtime 2555 for texture buffers held as words
SEMANTICS_VERSION 2328 -> 2329: on a profile that holds a colour format's texture buffers as
words, a function reaching a texture buffer emits the words routines and declares
SpecKey::TexelBufferWords (its words twin), records RuntimeFact::TexelBufferWords and, for an
access the words do not build, RuntimeFact::TexelBufferOwnView, and records
DeviceTexelConversion, SrgbTexelDecode and DevicePackConversion where the words convert so; a
texture buffer's word keeps its border texels unless its format has a word layout.

ARTIFACT_FORMAT_VERSION 602 -> 603: RuntimeFact gains the TexelBufferWords and
TexelBufferOwnView variants (cache/codec.rs).

RUNTIME_VERSION 2554 -> 2555: the runtime holds a texture buffer of a format the device lacks for
one of its accesses as an R32_UINT view whose texels the shaders convert, runs a content's words
twin where a draw or dispatch binds one, sizes an indirect execution's shape per pipeline, and
refuses a texture buffer held as words at a slot an own-view access reaches (the runtime gap).

The validation crate's runtime inputs take metal/format/texel_words.rs (build.rs): the runtime
decides each texture buffer's form and word layout through it (texel_buffer_form), and the
runtime-sources guard found metal/format/mod.rs, an input, reaching it unlisted.
runtime-sources.sha256 holds the inputs' new hash, computed as the build script computes it (the
same computation gives development 3ecfe8f034's committed b5a8df0e75...).

The golden tables, the engine fixture inventory and its llvm_as part, are blessed on
development: the semantics bump and the new fixture tb_word_formats move them.
2026-12-02 22:11:27 -08:00
Anees Iqbal 7cb1fd23b5 rt test: an indirect execution of patch draws through the words twin sizes its own shape too
The pipeline-keyed shape (the previous fix) holds for every layout the execution draws with: a
content of patch draws (DRAW PATCHES' CommandDraw::Patches, a post-tessellation vertex function,
PATCH_LIST) has a words twin beside its patch pipeline where a stage reaches a texture buffer, and
an execution through the twin takes the preprocess requirements of the twin.

The shape test now sizes both pipelines of two contents, each with tb_word_fragment: plain
draws (TRIANGLE_LIST, CommandDraw::Plain) as before, and patch draws (icb_merged_patch_vertex,
PATCH_LIST, CommandDraw::Patches) on a device whose executions run tessellation stages, saying
so where they do not.
2026-12-02 22:11:27 -08:00
Anees Iqbal 2ca533c65d rt: an indirect execution's shape is keyed on the pipeline it binds, the words twin apart
An execution shape holds the preprocess requirements vkGetGeneratedCommandsMemoryRequirementsEXT
answers for the pipeline the execution binds, and VUID-VkGeneratedCommandsInfoEXT-preprocessSize-
11071 asks an execution's preprocess size of the requirements of its matching inputs, that
pipeline among them. The shape cache keyed a shape on the content's id and the raster state, which
chose the content's pipeline until the words twin: under one raster state a content now has two,
the plain one and its twin, and an execution that ran the twin took the shape the plain pipeline
sized.

The key now holds the pipeline itself in place of the raster state: one per class and raster
state, the twin's apart from the plain one's. A content's pipelines live as long as it does and
its id is never another's, so no stale shape matches. Indirect::shape takes (content, pipeline);
the draw and the execution part pass the pipeline they bind. The runtime README's line on the
shapes the device keeps says so.

Red/green: the test of the previous commit asks for two shapes from the plain pipeline and the
twin of a content that reads a texture buffer; the device run is in the hand-over checks.
2026-12-02 22:11:27 -08:00
Anees Iqbal 4f3bbdfa94 rt test: an indirect execution through the words twin sizes its own shape (red)
An indirect command buffer's execution shape (indirect::Shape) holds its command layout and the
preprocess requirements vkGetGeneratedCommandsMemoryRequirementsEXT answers for the pipeline the
execution binds, and VUID-VkGeneratedCommandsInfoEXT-preprocessSize-11071 asks the execution's
preprocess size of the requirements of the matching inputs, the pipeline's among them. The shape
cache keys a shape on the content's id and the raster state, so an execution that runs a
content's words twin reuses the shape the plain pipeline of the same raster state sized.

The test makes a content whose fragment function reads a texture buffer (tb_word_fragment), for
indirect command buffers, takes its plain pipeline and its words twin at the default raster
state, and sizes a shape for each: it asks for two. Red here on a device with indirect command
buffers that holds a format as words (one shape); it skips, saying so, on a device without them.
2026-12-02 22:11:26 -08:00
Anees Iqbal a43933062e Harness: a B5G6R5Unorm texture buffer read's sum takes DeviceTexelConversion's recorded bound
On the Iris Xe (ANV, Mesa 26.2.6; job m3-max-81344, and its diagnostic m3-max-81378),
texel_buffer_b5g6r5_read failed its check in every arm, base 2bfb9b5bd3 included, which holds
B5G6R5Unorm through its own view there: "buffer 1: 959978 values differ; the first, [0], is
41.34902, not 41.343575 +- 0.0009765625". The row sums 16 texels' four channels against the
CPU's c / (2^b - 1) within 1/1024, but ANV widens a 5- or 6-bit channel by replicating its bits,
which the translator records as PrecisionNote::DeviceTexelConversion with a recorded bound of 0.18
of a code (docs/API.md). The row's tolerance now adds that bound for each 5- or 6-bit channel of
the 16 texels a sum reads: 16 x 0.18 x (2/31 + 1/63), about 0.23. Other formats' rows keep 1/1024
(an 8- or 16-bit code's one ulp is inside it). On the RTX 3090 and the RX 7900 XTX the row runs
through the words (base refuses the format there), bit for bit, and passed.

Verification pending: the row on the Iris Xe with this harness.
2026-12-02 22:11:26 -08:00
Anees Iqbal 5701c1a4b5 Tests: the indirect tests' draws literal names the own views
The runtime's Draws gained own_views in 5f5a42681f; the indirect tests' literal lacked it (E0063,
job m3-max-81152's clippy). It names none, as the content reads nothing else.

Verified: not yet built; job of the next dispatch.
2026-12-02 22:11:26 -08:00
Anees Iqbal c06f7e89db Translator, runtime: a texture buffer access the words do not build keeps its own view; a texture buffer held as words there is a gap at the draw or dispatch
The planner's ruling on (A)'s read-through loss, option (ii). Under the identity domains on a
profile that holds some format's texture buffers as words, words::wrap refused the whole module
for a texture buffer access its routines do not build: a read through a sampler, one that
observes residency, one in another numeric class, an sRGB code read, a write of another class or
of fewer than four lanes. The ceilings run (job m3-max-81042) lost three fixture rows that compile
on the base, development 530fb4ea4c: kernel_read_through's rt_buffer, rt_buffer_ow and
rt_arg_buffer, on lavapipe and on the runtime floor.

Such an access now keeps its strategy, the texture's own view, as on a profile that holds no
format as words, and the stage records RuntimeFact::TexelBufferOwnView { stage, texture }: the
slot, or None for a texture buffer reached through a handle. The fact's mechanism is a plan-time
check. The runtime's kernel interface and a render content's draws read it, and a dispatch or
draw that binds a texture buffer held as words at such a slot is Gap::TexelBufferOwnView of the
slot and its format; through a handle, any such dispatch or draw while a texture buffer held as
words is live (the gauge the words twin's handles test reads). Binding no texture buffer held as
words there changes nothing.

Tests: engine_identity's a_read_through_a_sampler_of_a_texture_buffer_takes_its_own_view compiles
the three entries under the identity domains on lavapipe and moltenvk-m3, passes L3, and checks
the fact where the profile holds a format as words and nowhere else (red before this: lavapipe's
compile refused). The runtime's a_read_through_a_sampler_refuses_a_texture_buffer_held_as_words
runs rt_buffer_ow over six formats. Each held directly answers its texels and Metal's white
border: three without a word layout, and three with one, whose border comes from the code. Each
held as words is refused at its dispatch with the gap of slot 0 and its format, and the same
state's next dispatch runs.

docs/REFUSALS.md and the error basis are regenerated. The runtime README's known gaps state the
refusal. api_signatures gains the fact's and the gap's variants.

Verified: not yet built; the ceilings, the gate, lavapipe device tests and the read-through-buffer
conformance replay follow.
2026-12-02 22:11:26 -08:00
Anees Iqbal e46643db97 Translator: a texture buffer's word keeps its border texels unless its format has a word layout
The words change cleared bits 0-11 of every texture buffer's word, on the premise that no texture
buffer is read through a sampler. Metal 4.1 reads one so (`read(sampler, x)`, the fixture
kernel_read_through's rt_buffer, rt_buffer_ow and rt_arg_buffer, the conformance case
read-through-buffer), and under the identity domains such a read takes the border texel from
those bits. So every texture buffer read through a bordered sampler read a zero border on every
device, and one of a format with a word layout read its fields as border texels. The base,
development 530fb4ea4c, kept the bits; found by reading, before any run.

Now TextureWord::of_texture_buffer is the texture word, border texels included, for a format
without a word layout, which is the base's word. A format with a word layout sets bit 13
(TextureWord::TEXEL_BUFFER_LAYOUT, 0 in every other word) and carries its fields in bits 0-10 on
every device. The words' held test requires bit 13, since a plain word's bits 2-7 are border
texels; a handle carries 14 bits of the word (HANDLE_WORD 0x3fff). A slot's read through a
sampler of a texture buffer takes the border texels from bits 0-11 where bit 13 is clear, else
from its format's code (words::border_texels, a choice among the values the word layouts'
formats have, grouped from WORD_FORMATS and metal::sampler::border_texels).

RESOURCE-ID.md and resource_words.tsv state the new word: the texture buffer lines of a word
layout gain bit 13, the others carry their border texels (the texture line's word at the default
swizzle).

Consumer search, the consumer's development 2221a41c20 (git grep -w over *.rs, *.c, *.h, *.m,
*.mm, *.cpp, *.py, *.tsv, *.md): TextureWord, of_texture_buffer, resource_word, resource_words,
BORDER_TEXELS, TEXEL_BUFFER, border_texels, OUT_OF_BOUNDS_ALPHA_ONE, PIXEL_FORMAT_SHIFT: 0 hits
each. The consumer takes each texture's ID from the runtime's gpu_resource_id.

Verified: not yet built. The unit test words::each_code_takes_its_format_s_border_texels holds
each code to its format's border texels; the runtime test and the lavapipe replay of
read-through-buffer come with the next commit.
2026-12-02 22:11:26 -08:00
Anees Iqbal 9240821e85 Docs: texel_buffer_form's doc names the uses it checks, not private constants
The public function's doc linked VIEW_USES and NATIVE_USES, which are private: rustdoc with
-D warnings failed on the three links (the rebased branch's gate, job m3-max-81050, doc step
EXIT=101). The doc now states the uses in words: a uniform texel buffer, a storage texel buffer
and a storage texel buffer written without a format.

Verified: not yet built; the next gate's doc step checks it.
2026-12-02 22:11:26 -08:00
Anees Iqbal 5a933f58cf Docs: REFUSALS.md regenerated: the render content's stage_module builds RenderPipeline refusals
The words twin moved the stage-module refusals of RenderCompiled::of into stage_module
(python3 scripts/refusal-surface/refusal_surface.py).
2026-12-02 22:11:26 -08:00
Anees Iqbal 72288eb2d5 Runtime README: the words twin's compile cost per state, measured on lavapipe
The planner's ruling for (A): the twin's per-state compile cost is the form's known gap for a
program that binds a texture buffer. On lavapipe (job m3-max-80997, the texture buffer stream
test's tb_word_formats state over five formats) the twin's make took 16.9 to 23.5 ms
(Metrics::word_pipeline_nanos) and the plain pipeline's create at least 2.9 to 5.3 ms
(pipeline_creation_nanos less the twin's), about 4 to 7 times. The five recorded guest streams
declare the constant in no state (job m3-max-80975): 0% of their boots' compile time.
2026-12-02 22:11:26 -08:00
Anees Iqbal e318736ceb Texture buffer stream test: an own view's tolerance is DeviceTexelConversion's recorded bound
The test took an own view's values within one ulp with nothing behind the number. The value
is the device's conversion of each code, which the translator records as
PrecisionNote::DeviceTexelConversion; the test now asserts the fixture's state records that
note, and takes an own view's values within the note's recorded bound (docs/API.md): an 8- or
16-bit code within one f32 ulp, a channel of 6 bits or fewer within one ulp or 0.18 of a code
where the device replicates its bits (ANV, NVIDIA). Words stay bit for bit.

Not yet rerun.
2026-12-02 22:11:25 -08:00
Anees Iqbal 674b837fa7 Texture buffer tests: the handles dispatch binds a buffer at slot 2; an own view's values within one ulp
The handles dispatch passed the read-written values (a Vec<f32> by then) at slot 2, which the
kernel does not use, so the runtime's device tests did not build (job m3-max-80971 on
lavapipe, E0308); it binds the values buffer there. The texture buffer stream compared an own
view's values bit for bit with the CPU's c / (2^n - 1); lavapipe's conversion multiplies by
the reciprocal and lands one f32 ulp off for RGBA8Unorm, R8Unorm and BGRA8Unorm (80971). The
device's own conversion is the answer (the owner's rule 1), so an own view's values are taken
within one ulp; words, our own decode, stay bit for bit (B5G6R5Unorm matched exactly).

Not yet rerun.
2026-12-02 22:11:25 -08:00
Anees Iqbal b8b43ccbaf rt test: the compute tests' Interface names no texture buffer words
Interface gained `words` (the kernel's reach of word-held texture buffers) with the words
twin; the device tests' hand-made Interface (tests/compute.rs, compiled only under m2v_gpu or
m2v_cpu_icd) still lacked it, so the runtime's device tests did not build (job m3-max-80900,
nextest exit 101). Its kernels declare no texture buffer: None.

Not yet built: the lavapipe check reruns as a potluck job.
2026-12-02 22:11:25 -08:00
Anees Iqbal e9ef4503e1 Harness: WORKLOADS holds 47; the texture buffer stream records its descriptors as objects
The two B5G6R5Unorm rows grew the harness's list past its declared 45, which stopped the
harness from compiling (the XTX arms build, job m3-max-80896, E0308). The texture buffer
replay stream passed each descriptor inline, which the player refuses for
newTextureWithDescriptor:offset:bytesPerRow: (job m3-max-80900 on lavapipe: "argument 0 ...
not an object"); it now records each with m2v.textureDescriptor first, as the other
texture-over-buffer streams do.

Not yet built: both checks rerun as potluck jobs.
2026-12-02 22:11:25 -08:00
Anees Iqbal 41b415911e Docs: the runtime's README names Metrics::word_contents 2026-12-02 22:11:25 -08:00
Anees Iqbal bef488e4da Texture buffers: a draw reads a texture buffer through the render content's words twin where the device holds the format as words
The owned fixture tb_word_formats gains tb_word_fragment, which colours the pixel at x with texel
x % 5 of its texture buffer (regenerated with the macOS Metal toolchain and LLVM 21). The
runtime's draw test reads an R8Unorm and a B5G6R5Unorm texture buffer through it, checks every
pixel against the CPU's decode within one code, and that the draw ran the twin exactly where the
device holds the format as words.

Not built yet.
2026-12-02 22:11:25 -08:00
Anees Iqbal 443c614c5e Texture buffers: contents with a words twin counted, a test-only count of twin runs, and the words test through slots and handles
Metrics::word_contents counts the compute and render contents whose module declares
SpecKey::TexelBufferWords; the replay player prints it. A count of the dispatches and draws that
ran a words twin, for the device tests alone, shows which pipeline ran.

The owned fixture tb_word_formats gains tb_word_formats_args, which reads and writes the texture
buffers through an argument buffer's handles (regenerated with the macOS Metal toolchain and
LLVM 21). The runtime's words test runs it after the slots' kernel and checks its values, and
that the slots' dispatch ran the twin exactly where the device holds the format as words, and the
handles' dispatch there too.

Not built yet.
2026-12-02 22:11:25 -08:00
Anees Iqbal 740d12b3a6 Texture buffers: the twin's docs, the player's twin gauges and metrics, and B5G6R5Unorm harness rows
AGENTS rule 2's texture buffer form and the runtime's README name the stage constant, the words
twin made in the same make as each plain pipeline, what picks it, and its second compile and
memory as the form's known gap; docs/API.md and RESOURCE-ID.md name the gate.

The replay player prints the word pipelines' and word-held texture buffers' gauges and the
twins' makes and time beside pipeline_creation_nanos.

The harness's texel_buffer_b5g6r5_write and texel_buffer_b5g6r5_read rows time a format the lab's
cards hold as words, a 2-byte texel written by two atomics and read through the words' routine,
checked against the CPU's exact conversion and decode.

Not built yet.
2026-12-02 22:11:25 -08:00
Anees Iqbal 7a85d3f363 Texture buffers: the words are a stage constant's twin, made with the plain pipeline and picked by what a draw or dispatch binds
SpecKey::TexelBufferWords { stage, handles }, a bool, false by default, which a stage declares
under the identity domains on a profile that holds some format's texture buffer as words, where
it reads, writes or queries a texture buffer. It gates each site's word test, the word bits a
handle carries and the element mask that drops them: false, they are dead code at pipeline
creation and each access is its view's alone.

The runtime makes each kernel variant's and each render content's words twin in the same make
as its plain pipeline, and a dispatch or draw runs it where a texture buffer held as words is
bound at a texture buffer slot a function declares, or, for a stage that reaches one through a
handle, while one lives on the device. Twins and word-held texture buffers are gauged, the
twins' makes counted with their time.

This commit alone was not built; the series is checked at its tip.
2026-12-02 22:11:24 -08:00
Anees Iqbal 1b48008646 Tables: resource_words.tsv holds the texture buffer word's vectors
Blessed by job m3-max-80671 (bless_resource_words, then the resource_word tests: 2 passed): a
texturebuffer line for every pixel format with a texture buffer word at width 1, and at widths 2
to 4 where its padding changes the word, 251 lines; no texture or sampler line moved.
2026-12-02 22:11:24 -08:00
Anees Iqbal dc3e5ab673 Texture buffers: the site reads the profile's word codes from the plan; the player's word of a texture buffer; a replay stream of texture buffers
The site test read the codes from the module's declarations, which do not hold them; it reads
the plan's. The player compared a texture buffer's recorded ID with TextureWord::of, whose border
texels a texture buffer's word does not carry; it takes TextureWord::of_texture_buffer of the
descriptor's format and width, as RESOURCE-ID.md and REPLAY-STREAM.md now say. rt_replay gains a
stream of texture buffers of five formats (RGBA8Unorm, R8Unorm, BGRA8Unorm, B5G6R5Unorm,
RGBA16Unorm) over a Shared buffer, read, written and read-written by tb_word_formats with the IDs
the program saw recorded, each played on the cfg's device: no id line, the CPU's texels and
values, and each format's form on that device printed. Unbuilt.
2026-12-02 22:11:24 -08:00
Anees Iqbal b694489924 API: the surface table and the signatures name the texture buffer word items and texel_buffer_form
Additions only (50 signature records): metal::format's TexelWords, WordLayout, TexelField,
FieldKind, TexelBufferForm, WORD_FORMATS and its functions, and TextureWord's texture buffer
fields and of_texture_buffer. scripts/api-signatures/signatures.py --bless reports no record
removed or changed. The runtime's texture buffer words test reads each format's form from the
device's profile and names it on each line.
2026-12-02 22:11:24 -08:00
Anees Iqbal 7cdaa1cc3f Texture buffers: each device holds a format as words only where it lacks the format's own view for an access
metal::format::texel_buffer_form is the one place that decides, per format and device: the
format's own view where the device holds it directly as a uniform texel buffer, a storage texel
buffer and a storage texel buffer written without a format; else words where it has a word
layout; else its own view of the first two (whose writes the runtime refuses). The resource ID
word is unchanged and the same on every device; a module takes the codes its profile holds as
words (texel_buffer_word_codes) and tests a word's code against them, emitting nothing of the
words where the profile holds none so. The routines' cases and the precision notes follow those
codes. The runtime's texel_form takes the same answer. AGENTS.md rule 2 gains the fourteenth
form; the runtime's README records the words' cost (7.3x the own view's GPU time for an R8Unorm
texture buffer written on an RTX 3090, job m3-max-80580).

This commit alone was not built; the series is checked at its tip.
2026-12-02 22:11:24 -08:00
Anees Iqbal 0ad55e1468 Docs: the texture buffer word, the formats held as words, their notes; test vectors of the texture buffer word
RESOURCE-ID.md gains the texture buffer word (TextureWord::of_texture_buffer: bits 0-1 padding,
2-7 the code, 8-9 texels per word, 10 a texel of two words; the 39 codes in order) and drops its
stale line that a texture buffer has no index. The runtime's README says which formats a texture
buffer holds as words and which it still refuses; the KosmicKrisp BGRA8Unorm gap is gone. API.md
and PrecisionNote's docs say a texture buffer held as words records SrgbTexelDecode and
DevicePackConversion for its float reads and writes, and that its other conversions are exact.
tests/resource_words.rs writes texture buffer lines (format, width, word); the table is blessed
in a later commit. REFUSALS.md regenerated (one more TextureFormat site).
2026-12-02 22:11:24 -08:00
Anees Iqbal 4208d6ca84 Texture buffers of colour formats Vulkan does not require as storage texel buffers are held as words
A texture buffer of one of 39 colour formats with a word layout (metal::format::texel_words)
is viewed as R32_UINT over its bytes, and shaders convert each texel themselves: the translator's
words routines (lower/texture/words.rs) read, write and ask the width of such a texture buffer,
and a write of a texel of one or two bytes is an atomic AND then an atomic OR on its word, which
keep its neighbours' bits. The texture word of a texture buffer (TextureWord::of_texture_buffer)
carries the format's code, its packing and padding; a handle carries those bits, and the element
mask drops them. The runtime makes the R32_UINT view, its last word ending inside the buffer's
block, and the required-formats test names the formats Vulkan requires as storage texel buffers.

This commit alone was not built; the series is checked at its tip.
2026-12-02 22:11:24 -08:00
Anees Iqbal 22b951f2d1 harness: texture buffer workloads, an R8Unorm one written and four formats read
The harness makes a texture buffer over a plan buffer (plan::TextureSource::Buffer,
ComputeDevice::new_texture_buffer): texel_buffer_r8_write writes 2^24 R8Unorm texels, one a
thread, and texel_buffer_{r8,r16,rgba16,bgra8}_read read 2^24 texels, 16 a thread, each checked
against the CPU's decode. The workloads time a texture buffer's accesses, as the translation of
the formats the runtime holds as words is weighed against their own views.
2026-12-02 22:11:23 -08:00
Anees Iqbal 2ccf487171 rt test: texture buffers of the formats held as words answer the CPU's decode of their bytes
Metal makes texture buffers of A8Unorm, the four 8-bit sRGB formats, RGB9E5Float, the
four packed 16-bit formats, BGR10A2Unorm and the four extended-range formats, for reading,
writing and both (M3 Max, macOS 27.0.1, jobs m3-max-79872 and m3-max-79879). The runtime
refuses each as Gap::TextureFormat on some or all devices, because Vulkan offers no
texel-buffer format for them.

The owned fixture tb_word_formats reads, writes, and reads then writes texture buffers of
five texels with eight threads. The new device test checks each format's answers against
the CPU's decode of the bytes:
- reads in bounds, exact, or within 2^-12 through the sRGB transfer;
- writes of each texel's value store its code, with neighbouring texels in one word kept;
- past the width, the zero texel is read and nothing is written, the rest of the last
  word included;
- the widths are 5.

This is the red half: every format is expected to fail at Buffer::new_texture
(Gap::TextureFormat). The run that shows it is in the handover.
2026-12-02 22:11:23 -08:00
Anees Iqbal 432bbb0a60 Replay player: a noted word in a buffer reached only as texels plays as recorded
The player moved every written word whose value lies in a buffer noted
escaped (AddressMap::move_noted), whatever the buffer it was written into.
In rec-m3-max-80463 it moved 3 RG8 mask words of no-copy buffer #1960,
which the program reads only as texels through texture #1962 over it. Each
play wrote its own host address there, so two plays read different texels
(audit lane, m3-max-81898 and m3-max-81914).

Now the move is decided by the stream's structure:
- read_ahead, which already walks the whole stream, notes each buffer's
  life, keyed by the object and its making's position (as recorded_ids
  is):
  - whether a texture is made over it (it receives
    newTextureWithDescriptor:offset:bytesPerRow:, the tiled form or the
    linear form);
  - whether any call names it as an argument, at any depth of lists and
    maps, but a copy between a buffer and a texture (copyFromBuffer:...
    toTexture:..., copyFromTexture:...toBuffer:...), whose bytes are texels.
  A buffer with a texture over it and no such naming is reached only as
  texels.
- At an object's making the play marks it live as such, or unmarks the id.
- place_words takes the write's target (none for set*Bytes data). Into a
  buffer reached only as texels, the words move_noted would move play as
  recorded and are counted as texel_only_words (AddressMap::count_noted,
  which shares move_noted's pass). The census is unchanged.
- Unchanged: a buffer with no texture over it, including one the stream
  never names (the existing noted-word test), set*Bytes data, and any
  buffer bound, encoded, used, copied buffer to buffer or added to a
  residency set.

texel_only_words is a new stream counter: in FIXED, frame and group lines,
and the report's addresses line. Docs: REPLAY-STREAM.md section 5's
noted-word paragraph and section 10's counts and addresses line. The
counter lists the replay tests spell out gain it.
2026-12-02 21:56:36 -08:00
Anees Iqbal cdb0cad236 Replay test: a noted word in a buffer reached only through a texture over it plays as recorded
Two lavapipe plays of rec-m3-max-80463 differ (audit lane, jobs
m3-max-81898 and m3-max-81914). In frame 3 the player moves 3 words of the
stream's write into no-copy buffer #1960, at offsets 24344, 73104 and
74240. They are RG8 mask bytes whose value falls inside an escaped
buffer's recorded range, and AddressMap::move_noted rewrites them to each
play's own address. #1960 is read only as texels, through texture #1962
over it, so the texture reads other bytes in each play. A shader loads an
address only from memory its command reaches as a buffer: bound, encoded
into an argument or indirect command buffer, or made resident by
useResource:, useHeap: or a residency set. Each of those calls names the
buffer.

New test in replay/tests.rs,
a_noted_word_in_a_buffer_reached_only_through_a_texture_over_it_plays_as_recorded:
- An authored stream makes a buffer, a texture over it
  (newTextureWithDescriptor:offset:bytesPerRow:), notes the buffer escaped
  (kind 0) and writes into it a word inside its own range.
- Reached only through the texture, the word is to play as recorded, and
  be counted as texel_only_words, not noted_words.
- The same buffer also bound by setBuffer:offset:atIndex: still moves the
  word.

Expected red: today the word moves in both arms.
2026-12-02 21:56:36 -08:00
Anees Iqbal bb09d7bb06 Tests: re-bless the golden tables at pin O
The engine inventory, the golden hash table and the air_input printouts, re-blessed at
3ecfe8f034 on the M3 (potluck job m3-max-82095: inventory=0, golden=0, printouts=0, and the
metallib half of committed_air_fixtures_parse_and_link un-skipped, linkhalf=0). The draw
patches and indexed draw patches work since the last bless added the icb_merged_patches and
icb_merged_ipatches fixtures and moved SEMANTICS_VERSION to 2328, so the four bless-due tests
(engine_fixtures_match_their_golden_printout, inventory_lists_every_fixture_in_order,
golden_hashes_match_the_table, llvm_as part 8) read red until this commit.

Files: golden_hashes.tsv, public_fixture_expectations_engine.tsv, and the two new printouts
air_input/icb_merged_patches.txt and air_input/icb_merged_ipatches.txt. Nothing else.
2026-12-02 21:56:13 -08:00
Anees Iqbal 3ecfe8f034 Conformance ledger: the BGRA4Unorm texture buffer's rows follow the device's texel-buffer query
a3fb852de3 (a heap makes texture buffers in place) sizes a heap's texture buffer through the
format's texel form, which takes a format whose buffer features hold both the uniform and the
storage texel buffer. On the Iris Xe, whose ANV holds A4R4G4B4_UNORM_PACK16 so, the heap's size
and alignment of the format-footprints-plain-stragglers BGRA4Unorm texture buffer now answers
(Metal's 128 at 16), and the case reaches its makes-texture site, which the runtime's side refuses
as Refusal::TextureBufferNotOverBuffer, the consumer's contract. The ledger's one row for every
venue refused the size-and-align site, so the Iris's conformance replay went red at pin M
(m3-max-82006: an unlisted makes-texture refusal) while the RTX 3090's held (m3-max-82034).

Now:
- the size-and-align row is one per venue whose device lacks the storage texel buffer of both of
  the format's Vulkan formats (NVIDIA, RADV, llvmpipe, Apple M3 Max, UHD Graphics 630), naming
  a3fb852de3;
- the Iris Xe has a makes-texture row with the consumer's-contract reason the other texture
  buffers' rows carry, naming a3fb852de3;
- each says Metal's validation layer refuses this format for a texture buffer, so what such a
  texture reads is outside documented Metal and no value comparison is owed for it;
- the runtime's README says a texture buffer's answer, the heap's size included, follows the
  format's texel-buffer features: the devices differ by query, not by form.

docs/CONFORMANCE-COVERAGE.md regenerated (scripts/conformance-coverage/coverage.py; --check
clean), as are the metal-coverage and refusal-surface checks.
2026-12-02 21:47:08 -08:00
Anees Iqbal d4be06a10b Translator: RUNTIME_VERSION 2554 for a Managed range taken at the first commit that names its buffer
On a device that keeps two copies of a Managed buffer, the runtime now takes a range named by
didModifyRange to the device copy at the first commit whose encoders name the buffer (a slot, a
declaration, an indirect, index or other draw buffer, a blit's buffer, a texture over it), not at
the next commit, and a buffer's first bytes at the next commit whatever it names. A run of an
unchanged artifact may therefore submit and record other copies under an unchanged key. None of
the validation crate's runtime inputs changed, so runtime-sources.sha256 holds. SEMANTICS_VERSION
does not move: nothing compiled changed. 2553 is taken by another row landing beside this one.

Verified: the value alone changes; the gate at this tip follows.
2026-12-02 21:46:15 -08:00
Anees Iqbal 09ca2bcb00 Conformance: Metal's times for the five managed-named cases, kept in their recordings
`conformance times --runs 8 --write` over the five cases, built --release at a2f2cad217, on the
Apple M3 Max, macOS 27.0.1 (26A434), job m3-max-81954 (the build: job m3-max-81941). Each
recording gained one time record (native Metal, 8 rounds), a recorded hole whose stopped reason
is the cases' own: the oracle keeps one copy of a Managed buffer, so its leg is forbidden. A
comparison of the JSON before and after shows `times` the one key added and every other key
equal. This is what times::every_case_is_timed::every_case_carries_its_timing asked of the new
cases (it failed in m3-max-81916 at c098a9848e). docs/CONFORMANCE-COVERAGE.md, regenerated,
does not change.
2026-12-02 21:46:14 -08:00
Anees Iqbal bbdf8d4d90 Conformance recordings: the five managed-named cases, carried from the 5300M's measurement
Each recording holds the case's carried answer as record mode writes a carried case's: the
transcript of the reader's content as an AMD Radeon Pro 5300M under macOS 26.7.1 read it, 8
rounds a reader (jobs 81602 and 81644), measured_on amd-radeon-pro-5300m, validated not run. The
compute slot, the declaration, the vertex slot and the blit source read the bytes as of the
reader's commit; the reach through the address alone reads the bytes the GPU's copy last took.
The oracle's own run is forbidden by the cases (one copy), so nothing here ran on Metal.

They were written by record::carried and record::write, the calls record mode makes for a
carried case, through a scratch test of a CPU-only job's own workspace (job m3-max-81916, at
c098a9848e), never committed. docs/CONFORMANCE-COVERAGE.md is regenerated with them
(scripts/conformance-coverage/coverage.py): 192 case modules, 1347 recordings, 85 carried.

Verified: in the same job the conformance suite ran 1050 tests, 1048 passed; the two failures are
the coverage document, regenerated here, and the cases' missing Metal time records, which the
oracle's times run adds next.
2026-12-02 21:46:14 -08:00
Anees Iqbal 4ce4babc7f Conformance: managed_naming's compute reader reads its words as arrays, and takes no unused import
Clippy named the chunks_exact of a constant 4 (as_chunks reads each word as an array, with no
conversion that can fail) and the unused import of call.

Verified: clippy of the conformance crate in job m3-max-81909 (CPU-only build) failed on both;
the next job runs it again.
2026-12-02 21:46:14 -08:00
Anees Iqbal 6469bd9bc0 Runtime: a commit drains the buffers made since the last in place
Clippy's drain_collect named the collect of the made entries into a vector of their own; the loop
now drains them directly, its other borrows being of the change list's other fields.

Verified: clippy of the conformance crate's dependencies in job m3-max-81865 (CPU-only build)
failed on it; the clippy job follows.
2026-12-02 21:46:14 -08:00
Anees Iqbal 367f1f2313 Player: Seconds::named goes, as no commit asks it any more
A commit takes its named ranges through Seconds::take, which answers none where its command
buffer named no buffer with a range, so nothing calls named. The release build of the player warned
of it as dead code.

Verified: the warning is in the player's release build of the frame-396 play job m3-max-81847
(lavapipe); no caller in the tree (grep of seconds' calls). The clippy job follows.
2026-12-02 21:46:14 -08:00
Anees Iqbal 91325782b2 Conformance: managed_naming's reader makes its compute states through the side's stage helper
The reader's own helper took the name of the side's kernel stage helper, a duplicate definition
on RtSide. It is now compute_state, built on that helper, and the render reader takes its two
stages through it as well.

Verified: the recording job m3-max-81836 (a CPU-only build, at the commit before the rebase)
failed to compile the conformance crate on the duplicate; the next job compiles it.
2026-12-02 21:46:14 -08:00
Anees Iqbal 6652825031 Conformance: the watching side forwards managed_naming
Watching forwards every Side method, so a watched run of the managed-named cases answers what the
side it wraps answers rather than Unavailable. The suite's test that compares Side's methods with
Watching's forwards names the missing one without it.

Verified: expected from the forwarding test's name sets. The conformance suite run follows.
2026-12-02 21:46:14 -08:00
Anees Iqbal f77950bf75 rt test: the placed device copy's copy-in is read by a commit that names the Managed buffer
The test every_device_places_a_managed_buffer_s_device_copy_where_the_consumer_says named the
whole buffer, then read the block through a commit that kept only another buffer over the
Private block. Under the rule that a named range is taken at the first commit whose encoders
name the buffer, that commit takes nothing, so the two-copy form read the old bytes. The read's
commit now names the Managed buffer as well.

Verified: lavapipe rt suite job m3-max-81780 at f864a75d35 failed this test alone (958 of 959
passed, 4 skipped) at the copy-in assertion; the rerun follows.
2026-12-02 21:46:14 -08:00
Anees Iqbal bf6a072dd4 Conformance: managed_naming, which commit takes a Managed range to a second copy
Five cases, one a reader, each of the same sequence: a Managed buffer's red
contents written, named and taken by a blit; green written and named, then a
commit of a blit that fills another buffer; the reader encoded, blue written
with no second name, the reader's command buffer committed. The site holds
which of the three the reader read. Readers: a compute slot
(scale_and_offset), useResource: (ab_address), the address alone (ab_address,
no declaration), a vertex slot with a draw (colored_vertex), a blit copy's
source.

Metal's answer is carried from an AMD Radeon Pro 5300M table under macOS
26.7.1, 8 rounds a reader (jobs 81602 and 81644): the readers that name the
buffer read the bytes as of their commit (blue), the address-only reader the
bytes the GPU copy last took (red). The oracle keeps one copy, so record mode
may not replace the table (carried_only), and the case names the chip
(recording::AMD_RADEON_PRO_5300M; the known-families list in
a_carried_answer_taken_on_another_chip_names_it grows by managed-named-).

The runtime's side runs the sequence in the form the device's memory-type
query picks. On a device that keeps one copy the address-only row answers the
venue's gap (a device copy of each Managed buffer), as that row asks what a
second copy holds; the other rows read the bytes as of their commit in either
form, as the 5300M and the one-copy UHD Graphics 630 (jobs 81603, 81645) did.

Recordings follow from a record job on the oracle. Not yet compiled.
2026-12-02 21:46:14 -08:00
Anees Iqbal b7c59c9b9c Runtime: a Managed buffer's first bytes go at the next commit, whatever it names
The first-naming-commit rule (baf1c8a8c9) also held a new Managed buffer's
first `copied` bytes until a commit named the buffer, so a reach before then
read the device copy's old bytes. Metal's device copy holds a buffer's bytes
from its making. Those bytes now go in at the next commit whatever its encoders
name (Changes::made, taken by every commit, merged with the buffer's named
ranges where the same commit takes both); ranges did_modify_range names still
wait for a commit that names the buffer. The made entries are swept as the
named ones are.

Texture::image_bytes, a test helper, now commits a compute encoder that
declares the texture by use_resource, so its commit takes the named ranges of
the buffer the texture lies over.

Lavapipe's full runtime suite at baf1c8a8c9 (m3-max-81741: 957 passed, 2
failed, 4 skipped) failed managed::every_device_places_a_managed_buffer_s_
device_copy_where_the_consumer_says and over::every_device_holds_a_texture_
over_a_buffer_in_place on these two; this fixes both. Not yet compiled.
2026-12-02 21:46:13 -08:00
Anees Iqbal 8be5365553 Player: a two-copy stream's announcement is taken at the first commit that names the buffer
The runtime now takes a Managed range at the first commit whose encoders name
its buffer, as Metal on an AMD Radeon Pro 5300M does (jobs 81602, 81644). The
player's own second copy, which a two-copy stream's Managed buffers take on a
device with unified memory, took every range named at the next commit of any
command buffer; it now follows the runtime's rule.

- second.rs: Seconds keeps, for each command buffer not yet committed, the
  buffers with a second copy its encoders named, themselves or through a
  texture over one (made over the buffer, a tiled one, or a view of one), and
  a commit takes only those buffers' ranges. A released buffer with ranges
  pending stays only while a command buffer not yet committed that named it,
  or a texture over it, can take them; otherwise its place goes back at once.
  A command buffer released uncommitted takes nothing.
- mod.rs: each encoder call's named objects, a render pass's attachments,
  resolve textures and visibility result buffer at its encoder's making, and
  the textures and views made over a second copy feed it. render.rs keeps the
  pass's resolve textures and visibility result buffer by stream id.
- encoders.rs: copy_named takes the committing command buffer's ranges alone.
- stale.rs: a didModifyRange: is pending until a commit whose uses name the
  object takes it, with the bytes written by then (an indirect command
  buffer's command takes it where it is encoded); writes between the
  announcement and that commit are not stale.
- docs/REPLAY-STREAM.md says so.

Tests: rt_replay a_two_copy_stream_s_announcement_is_taken_at_the_first_
commit_that_names_the_buffer (zeros announced, a commit of another buffer, 7s
written with no announcement, a copy of the buffer reads the 7s); tests
an_announcement_is_taken_at_the_first_commit_that_names_its_buffer (the
census counts one stale use where it counted two). Not yet compiled.
2026-12-02 21:46:13 -08:00
Anees Iqbal 51ac48c788 Runtime: a Managed range is taken at the first commit that names its buffer
On a device that keeps a device copy, did_modify_range named a range and the
next commit of any command buffer took every range named since. A consumer
that names a range, commits a command buffer that does not use the buffer,
writes the range again with no second name, then commits the command buffer
that binds it had the GPU read the first bytes. Metal on an AMD Radeon Pro
5300M (macOS 26.7.1, 8 rounds each, jobs 81602 and 81644) takes a named range
at the first commit whose encoders bind the buffer (a compute slot, a vertex
slot with a draw), declare it by useResource: or read it in a blit copy, with
its bytes as of that commit; an unrelated commit takes nothing; a buffer named
to no encoder and reached by address keeps its last synced bytes. The Intel
UHD Graphics 630 keeps one copy (jobs 81603 and 81645).

A commit now takes only the ranges of the buffers its command buffer keeps,
which is every way an encoder names a buffer in the runtime:
- a slot of any stage: compute set_buffer, set_vertex_buffer,
  set_fragment_buffer;
- use_resource on a compute or a render encoder (the runtime has no
  use_resources);
- an index buffer; the indirect arguments of a draw, an indexed draw or a
  dispatch; a patch draw's index and control-point buffers and an indirect
  command buffer's range buffer, kept by the same line of the draw as the
  index buffer and the arguments;
- the tessellation factor buffer and the pass's visibility result buffer;
- a blit: a copy's source or destination, a fill, a copy into or out of a
  texture, a synchronize;
- a texture over the buffer, or a view of one, wherever the command buffer
  keeps it (a slot, use_resource, an attachment, a resolve, a blit).
A heap use names none: Metal refuses a Managed heap (jobs 81602, 81603).

A pending range holds its buffer weakly. The pending list sweeps the entries
of buffers gone once it holds twice the entries its last sweep left (at least
64), so it stays bounded by the live buffers with ranges pending.

Tests (tests::managed): the consumer's six calls (red at e1fbce1486 on
lavapipe's two-copy view, m3-max-81614, and on an RTX 2080, m3-max-81606);
each way above, through compute, render and blit encoders and a texture over
the buffer, with a reach by address alone taking nothing; a buffer no encoder
names keeps the bytes taken last; a narrow named range takes its own bytes
alone (unaudited on Metal); a declaration alone takes, a commit with no
commands takes nothing. over_texture's capture commit now names its buffer.

The did_modify_range doc and the runtime README state the rule and its jobs.
Not yet compiled; the green runs follow.
2026-12-02 21:46:13 -08:00
Anees Iqbal 698acffa48 Runtime test: a Managed range named, then written with no second name, read at the first commit that names its buffer (red)
A consumer writes zeros into a Managed buffer and names the range. It commits a command buffer that
does not name the buffer, and that command buffer completes. It encodes a kernel that reads the
buffer, writes a table over the zeros with no second didModifyRange:, and commits. The test expects
the kernel to read the table, in either form.

Metal on a discrete Mac GPU (an AMD Radeon Pro 5300M) takes a named range at the first commit whose
encoder binds its buffer (Buffer::did_modify_range's doc). The runtime takes it at the next commit of
any command buffer, so with a device copy the kernel reads the zeros. A guest's argument buffer
written this way held a null pointer in the device copy, and its vertex function read through that
pointer.

Red runs follow in the next commit's message.
2026-12-02 21:46:13 -08:00
Anees Iqbal 2b335a8174 rt docs: the memoryless refusal's basis says what is true now
Gap::MemorylessTexture's basis read "render passes are not built", which stopped being true
when render passes were built. It now names the reason the refusal stays: a memoryless
attachment keeps its contents for the whole render encoder, across the renderings the runtime
ends and restarts inside one encoder (barriers after writing draws, the feedback-loop barrier,
copies for textures over buffers and Managed copies, shadow copies), and the image that would
hold them is not built. docs/REFUSALS.md regenerated (scripts/refusal-surface).

Docs only: no behaviour changes. refusal_surface.py --check exits 0.
2026-12-02 21:43:32 -08:00
Anees Iqbal b7e1e435e3 rt docs: texture_copy_cause's causes that hold for every buffer of a kind of memory
Buffer::texture_copy_cause (and new_texture_in_place's TextureNotInPlace cause) now says
which of its answers come from the device's queries of the descriptor and the buffer's kind of
memory alone: HostMemory, DmaBuf, DmaBufs, Dedicated, Surface, Linear and LinearFeatures, all
decided in check_over before any place is read (memory_cause, the external or linear image
query, the linear tiling's features). Spilled, Pitch, Alignment, RenderReach and ImageMemory
depend on the buffer and its place (the block's spill, then in_place_fit's laid image). A
consumer may keep a kind-only answer per descriptor and kind of memory instead of importing
another buffer to ask again; the consumer's census meets four such refusals a run on the M3,
each paying a map and an import first.

Docs only: no behaviour changes. Verified by reading check_over, memory_cause and over_cause at
this commit's parent.
2026-12-02 21:41:48 -08:00
Anees Iqbal ece306e521 Runtime test: a vec16 argument bound 4 past a multiple of 16 beside one at 0, with its dispatches' forms
every_device_places_each_vector_access_at_its_own_address gains a run binding vwp_vec16's a 4
bytes past a multiple of 16 and b at 0: one argument of alignment 16 at a multiple of 4 below its
alignment beside one at its alignment, the shape a guest kernel's refused bind had (index 0 at
offset 1871700, 4 past a multiple of 16, alignment 16). Each run now prints how many of its two
dispatches ran with their buffers bound (Metrics::bound_dispatches) and how many at their
addresses (Metrics::address_dispatches), so a card run shows which form served the bind.

Verified: the test passes on lavapipe (llvmpipe, LLVM 23.1.1), job m3-max-81994, with clippy
-D warnings under --cfg m2v_cpu_icd clean: every run's two dispatches at addresses (lavapipe has
no bound form), the a-at-4, b-at-0 run included. On the RTX 3090, job m3-max-81997, the same run's
two dispatches both ran bound (a in the variant that keeps its address, b through its binding),
the a-at-4, b-at-8 run one bound and one at addresses, and every other run two bound; every
buffer held Metal's words on both.
2026-12-02 21:24:07 -08:00
Anees Iqbal e2ab03dc71 Translator: SEMANTICS_VERSION 2328 for a kernel's indexed patch draws and the records' new tail
dc126ab306 lowers render_command's draw_indexed_patches (it wrote a refusal before) and grows every
command's record tail by 8 bytes: the stride is index() + 48 (was + 40), the sequence index lies at
index() + 24 (was + 16) and the draw's arguments at index() + 28 (DRAW_AT, was 20). So a kernel that
writes, resets or reads any command of an indirect command buffer translates to other words under
an unchanged key. The golden tables are re-blessed on development.


Verified: lavapipe m3-max-81663 (red, then green); 2080 m3-max-81688, XTX and 780M m3-max-81689, lavapipe m3-max-81691 (engine, rt indirect and the 6 range rows against Metal's recording m3-max-81637 on the Apple M3 Max); Iris Xe m3-max-81890 (no VK_EXT_device_generated_commands: refused by name); states-only play m3-max-81856 0 refused; suites and lint m3-max-81855.
2026-12-02 21:14:39 -08:00
Anees Iqbal e4195ee560 Conformance recording: indirect-range-gpu-written-indexed-patch-draws on Metal
Metal's answer for the indexed-patch-draws range row, recorded on the Apple M3 Max (macOS 27.0.1,
26A434) by job m3-max-81637 at 992794d8bd (the AIR commit, d244877fb2 after the rebase onto
685bde8009, the same patch), with its times (8 rounds, the same job). The execution completes, and
commands 1 to 5 draw rows 2 to 11 whole: each command's quad, whose four corners are stored out of
order and named in order by its 16-bit control-point indices, covers its two rows. Each texel
holds the command's mark, the patch index i, the instance and the base instance i, the patch-draws
row's texels exactly.

The ledger's Iris Xe row is the Extension refusal, as for the other range rows: the Iris Xe lists
no VK_EXT_device_generated_commands. CONFORMANCE-COVERAGE.md is regenerated.
2026-12-02 21:09:01 -08:00
Anees Iqbal 39423d92f1 ICB: a kernel's indexed patch draws into an indirect command buffer, executed through a layout of indexed patch draws
The owner's 3406 order, the planner's next indirect command kind: MTLIndirectCommandTypeDrawIndexedPatches.

The records (pipeline::IndirectDrawLayout) grow by 8 bytes a command for every kind. The
control-point indices' address is a third u64 that an execution pushes, and VUID 11103 asks each
token's offset to be at or past the one before it, with the draw token last (VUID 11100). So the
address cannot go after the draw; it lies past the index token's 16 bytes, at index() + 16.
Every command's tail is now 16 + 8 + 4 + 20 = 48 bytes: the stride is index() + 48 (was + 40),
the sequence index's place index() + 24 (was + 16), and the draw's arguments index() + 28 (the
translator's DRAW_AT, was 20). The cost is 8 bytes a command in every buffer: 160 bytes for 7
vertex and 7 fragment slots (was 152, 5% more), 48 for none (was 40), 544 at most (was 536),
which the floor's stride and token-offset limits are checked against. One record shape for every
kind stays: a kernel cannot know a buffer's kind when it is translated, so it writes one shape
whatever buffer it reaches. The main lane accepted this on the condition that the
already-landed kinds' rows run again at the new layout.

Translator (lower/access/icb.rs): a render_command's draw_indexed_patches writes what
draw_patches writes (the draw's VkDrawIndirectCommand of patches, the factors' and the patch
indices' Metal addresses) and the control-point indices' Metal address at the new place
(CONTROL_POINTS_AT, IndirectDrawLayout::control_point_indices). Its operands are draw_patches's,
with the control-point indices at operand 6.

Runtime: Device::new_indirect_command_buffer takes DRAW_INDEXED_PATCHES alone
(CommandDraw::IndexedPatches), refused as patch draws are on a device whose executions run no
tessellation stage (TessellationStages). Its layout pushes the control-point indices' address
where the control stage reads it (FieldValue::ControlPointIndices), holds no index buffer token,
ends in TOKEN_DRAW and names the tessellation stages. An execution checks the state's
control-point index type against the buffer's kind, as a direct draw checks it against the call:
patch draws with a state of an index type are Refusal::PatchDrawWithIndexType, and indexed patch
draws with a state of none Refusal::IndexedPatchDrawWithoutIndexType. This replaces the patch
draws' check through an empty PatchReads.

Docs: the runtime README's ICB section (records, tokens, refusals, floor limits); the API guide's
section 1; METAL-COVERAGE (coverage.tsv); CONFORMANCE-COVERAGE and REFUSALS.md regenerated (the
two refusals gain the draw site); the API signature table blessed for control_point_indices.

Tests: the red commit's engine and runtime device tests; the layout's unit tests at the new
offsets, the reset command's control-point place among them; a unit test of the indexed patch
tokens.
2026-12-02 21:09:00 -08:00
Anees Iqbal 2f93ecaba5 Tests: a kernel's indexed patch draws into an indirect command buffer draw as their draws direct (red)
The engine test of a kernel's patch draws compiles and validates icb_merged_ipatches too, whose
kernel encodes indexed patch draws with 16-bit control-point indices of its own, on every profile.

The runtime's patch-draws device test becomes one body for both kinds. Its new arm,
every_device_draws_encoded_indexed_patch_draws_as_their_draws_direct, uses a state of
icb_merged_ipatches's functions: a float2 corner at attribute 0 of vertex buffer 2, stepped per
patch control point, under the UInt16 control-point index type. Each patch's corners are stored
out of order, and its indices name them in order. The arm asserts that four indexed patch draws
the kernel encodes draw what the same draws direct draw, in the four executions of the patch
draws' arm, and that indexed patch and patch draws together are CommandTypes.

Red: the translator refuses a render_command's draw_indexed_patches
(GpuEncodedIndirectCommands), and the runtime refuses a buffer of DRAW_INDEXED_PATCHES
(CommandTypes).
2026-12-02 21:09:00 -08:00
Anees Iqbal 2e9f37f0ec Fixture: icb_merged_ipatches's AIR companions
Regenerated by scripts/regen-air-fixtures icb_merged_ipatches on the Apple M3 Max (macOS 27.0.1,
Apple metal version 32023.922, macOS SDK 27.2), job m3-max-81619: the .ll and .air.ll of the owned
source, and the fixture's line in TOOLCHAIN. The engine inventory, the golden tables and the
air_input printouts take the fixture when they are re-blessed on development.
2026-12-02 21:09:00 -08:00
Anees Iqbal d0dedfb984 Tests: a kernel's indexed patch draws into an indirect command buffer, a range row of their own (source; red)
The next indirect command kind after patch draws: MTLIndirectCommandTypeDrawIndexedPatches.
icb_merged_ipatches is an owned fixture. Its kernel encodes command i as one quad patch of four
control points from patch i, with no patch index buffer, 16-bit control-point indices and
level-1 half factors, one instance for an even command and two for an odd one, from base
instance i, with vertex buffers 0 to 2 of its own. The post-tessellation vertex function reads its
four corners through a PerPatchControlPoint layout at vertex buffer 2. The points are stored out
of order and the indices name each corner, so a patch that covers its rectangle read its
indices. Each texel then holds its command's mark, the patch index, the instance and the base
instance.

indirect_ranges.rs gains the row indirect-range-gpu-written-indexed-patch-draws: commands 1 to 5,
written by a blit's copy before the pass, as the patch-draws row is. EncodedRange carries the
commands' pipeline's vertex descriptor and tessellation state where a row states them; both
sides set them on that pipeline (the Metal side's tessellation fields through one helper, the
runtime side's through the fields module's descriptors). The fixture's AIR, the Metal recording
and the ledger row follow in their own commits.
2026-12-02 21:09:00 -08:00
Anees Iqbal 8baa784961 rt: a release counts as waiting until the reaper or the block-maker thread has done it
Gauges::releases_waiting counted a release only while it waited for work
in flight. An object then handed to the reaper thread stopped counting
before the reaper freed it, and an imported or exported block or memory of
its own given back to the block-maker thread never counted. So a read of no
release waiting and no command buffer live could find objects still
counted, freed a moment later. The harness's churn rows, the replay
player's settled reads and the matrix take that read for every release
done. Round K's churn_all_day failed so on the RTX 2080 (m3-max-81680: an
iteration's plane stand-in, its export, 4 textures and 3 attachment views
still counted at the 200th read) and on the RTX 5080 (m3-max-81692: a
whole iteration's set counted at the 100th read).

Now a release counts until it is done:
- Reaper::give counts a free or a released image as it queues it, before
  the reaper can take it; the reaper's run and its drain at the core's drop
  count it done once its free ran. A teardown job is no release.
- Pool::give_back_own and give_back_loose count the block given back
  before the block-maker thread can take it; the block-maker thread and
  free_all count it done once it is freed and an import's release ran.
- A release that waited for work and goes on to the reaper rises at the
  give and falls for its wait after, so it counts without a gap.
No sleep and no retry: the settled read waits on the same gauge, which now
covers every queue a release passes through.

Docs: Gauges::releases_waiting and the runtime README's gauge list say what
it counts and that a read of 0 with no command buffer live comes after every
release made before it is done.

Test: argument_tier's every_device_holds_a_release_until_the_work_committed_before_it_retires
holds the reaper across the releases; it now waits for the index to be
vacated, expects the texture's image handed to the held reaper to still
count, and expects the gauge at 0 once the reaper goes on.
2026-12-02 21:06:55 -08:00
Anees Iqbal 9703e4d09e rt test: a release counts as waiting until the reaper or the block-maker thread has done it
Round K's 2080 leg (m3-max-81680) failed the harness's churn_all_day: from
the 100th iteration to the 200th, textures 0 -> 4, attachment_views 0 -> 3,
blocks 8 -> 9, exports 0 -> 1, plane_stand_ins 0 -> 1, and nothing live at
the device's drop. Round K's 5080 leg (m3-max-81692) failed it the other
way, a whole iteration's set read at the 100th and gone at the 200th. The
row's settled read waits for no release waiting, no command buffer live and
two reads 20 ms apart that agree. Gauges::releases_waiting stops counting an
object once the block-maker thread hands it to the reaper thread, before
the reaper frees it, and never counts an imported or exported block given
back, which the block-maker thread frees. A reaper busy with another job or
a look at the pipeline cache, or a block-maker thread busy with a free or a
make, leaves the read settled with the objects still counted.

New device tests, tests/releases_done.rs:
- every_device_counts_a_view_the_reaper_has_not_freed_as_a_release_waiting:
  with the reaper held in its look at the pipeline cache (Caches::look_hold),
  a texture view dropped with nothing in flight and nothing waiting is still
  counted in textures, and is to count as one release waiting; let go, both
  fall together.
- every_device_counts_an_import_the_block_maker_has_not_freed_as_a_release_waiting:
  with the block-maker thread parked before its first work
  (MakerTest::Park), a host import given back is still counted in imports
  and its release has not run, and it is to count as one release waiting;
  let go, the release runs and both fall together. A device that imports
  no host memory says so.

Expected red: today each reads no release waiting while the object is
still counted.
2026-12-02 21:06:55 -08:00
Anees Iqbal 70f3deefa8 Translator: SEMANTICS_VERSION 2327 for a kernel's patch draws into an indirect command buffer
b3ee209881 lowers render_command's draw_patches (it wrote a refusal before), and compiles a
post-tessellation vertex function of a state made for indirect command buffers under
LoweringInputs::indirect_range, so a kernel that encodes patch draws, and such a vertex function,
translate to other words under an unchanged key. The golden tables are re-blessed on development.
2026-12-02 21:06:55 -08:00
Anees Iqbal 03a87becb9 Runtime README: the floor's indirect command limits, the tessellation stages among them
Main's ask for the new public field IndirectCommandLimits::tessellation_stages: the ICB section
now states what the floor reads before it enables the two extensions, and each limit it keeps,
with the field that holds it. docs/API.md describes no indirect command limit (the translator's
guide), so it is unchanged. REFUSALS.md regenerated with no change: it lists Gap variants and
their sites, and the new kind is a value of Gap::IndirectCommandBuffers's kind at a site it
already lists (new_indirect_command_buffer).
2026-12-02 21:06:54 -08:00
Anees Iqbal 95ce83b599 Conformance: the patch-draws range row declares the tessellation notices
The 2080's replay of indirect-range-gpu-written-patch-draws (RTX 2080, NVIDIA 620.70.06, job
m3-max-81601 at 20105bb4bf) compared every texel with Metal's and diverged at case/notices alone:
the tessellating pipeline announced tessellation-winding, tessellation-factor-edge-cases and
tessellation-triangle-order, which every row that draws a patch declares. The row now declares
them through tessellation_sweeps::tessellation_notices. None moves a texel of a quad patch of
level 1, whose two triangles cover its rectangle in any order and winding.

The same job ran the runtime's indirect tests on the 2080, 27 passed, the patch draws' test
among them, and the four other range rows announced and justified as before.

CONFORMANCE-COVERAGE.md regenerated with no change.
2026-12-02 21:06:54 -08:00
Anees Iqbal 08447f8aff ICB: a kernel's patch draws into an indirect command buffer, executed through a layout of patch draws
The owner's 3406 order, the planner's next indirect command kind: MTLIndirectCommandTypeDrawPatches.

Translator (lower/access/icb.rs): a render_command's draw_patches writes VkDrawIndirectCommand (the
patch count, the instances, the patch start and the base instance) where a plain draw's goes, and
in the index token's 16 bytes, which a buffer of patch draws does not read as a token, the
tessellation factors' Metal address and the patch indices' (0 for the null pointer). The records
stay one shape for every kind (pipeline::IndirectDrawLayout::factors and ::patch_indices name the
two places). The control-point count is not read, as a direct patch draw does not read it; the
factors' instance stride and the factor scale are read only under a per-instance step function or
tessellationFactorScaleEnabled, which the runtime refuses at the pipeline state. A
post-tessellation vertex function of a state made for indirect command buffers is compiled under
LoweringInputs::indirect_range (pipeline/compile.rs), so each evaluation tests its command against
the execution range as a plain vertex function does.

Runtime: Device::new_indirect_command_buffer takes DRAW_PATCHES alone, the buffer's kind
CommandDraw::Patches. Its command layout pushes the factors' and patch indices' addresses where
the state's control stage reads them (FieldValue::TessellationFactors, FieldValue::PatchIndices),
holds no index buffer token and ends in TOKEN_DRAW; the layout and each execution name the
tessellation control and evaluation stages beside the vertex and fragment ones
(dgc::PATCH_STAGES). An execution of patch draws draws a patch list with a post-tessellation state
and reads no tessellation factor buffer of the encoder's; a state that is not post-tessellation
is Refusal::PatchDraw, as is a post-tessellation state with a buffer of other draws, and a state
of a control-point index type Refusal::PatchDrawWithIndexType, as for a direct patch draw.

VUID-vkCmdExecuteGeneratedCommandsEXT-supportedIndirectCommandsShaderStages-11060 requires the
bound stages in the device's supportedIndirectCommandsShaderStages, so the floor reads whether
they hold the tessellation stages (IndirectCommandLimits::tessellation_stages) and a buffer of
patch draws is refused without them, a new kind, IndirectCommandsKind::TessellationStages.
Mesa's source answers VK_SHADER_STAGE_ALL_GRAPHICS on RADV and VK_SHADER_STAGE_ALL on lavapipe.

Two draw kinds together, DRAW_INDEXED_PATCHES and the rest stay CommandTypes.

Docs: the runtime README's ICB section and refusal line; the API guide's section 1; METAL-COVERAGE
(coverage.tsv); CONFORMANCE-COVERAGE regenerated; the API signature table blessed for the new
field, methods and variant. REFUSALS.md regenerated with no change.

Tests: the red commit's engine test and runtime device test, with the device test's arm for the
TessellationStages refusal; a unit test of the patch tokens; the floor's limits test reads the
tessellation stages.
2026-12-02 21:06:54 -08:00
Anees Iqbal 3271596f64 Tests: a kernel's patch draws into an indirect command buffer draw as their draws direct (red)
The owner's 3406 order, next kind after plain draws: MTLIndirectCommandTypeDrawPatches. Today
the translator refuses a kernel's draw_patches (Unsupported{GpuEncodedIndirectCommands,
NotImplemented}), and the runtime refuses a descriptor of DRAW_PATCHES (Gap::IndirectCommandBuffers,
CommandTypes).

- Engine: icb_merged_patches compiles and validates under the identity domains on every
  profile. Red: refused today.
- Runtime, under a device cfg: four patch draws the kernel encodes draw what the same draws
  direct draw. Each has three vertex buffers, one quad patch of one control point from patch i,
  no patch index buffer, level-1 factors, one or two instances and its own base instance. The
  arms are all four commands, commands 1 and 2, the range 2 and 3 a buffer holds, and
  executions around a direct draw. A buffer of patch and plain draws together is refused,
  CommandTypes. Red: the buffer of DRAW_PATCHES is refused today.
- Conformance: the row indirect-range-gpu-written-patch-draws and its Metal recording are in
  a4dde5f4b0.

Jobs: the red runs are named in the hand-over.
2026-12-02 21:06:54 -08:00
Anees Iqbal 0539084768 Conformance recording: indirect-range-gpu-written-patch-draws on Metal (red still)
Metal's answer for the patch-draws range row, recorded on the Apple M3 Max (macOS 27.0.1,
26A434) at 0616460f73 by job m3-max-81499, with its times (8 rounds, the same job). The
execution completes, and commands 1 to 5 draw rows 2 to 11. Each texel holds the command's
mark, the patch index i, the instance and the base instance i. The instance a post-tessellation
vertex function reads counts from the base instance: an odd command's second instance reads
i + 1, an even command's only instance reads i.

The ledger's Iris Xe row is the Extension refusal, as for the other range rows: the Iris Xe
lists no VK_EXT_device_generated_commands. CONFORMANCE-COVERAGE.md is regenerated.

Red: the runtime refuses an indirect command buffer of DrawPatches (CommandTypes), so the
row's replay meets a refusal that the ledger does not list.
2026-12-02 21:06:53 -08:00
Anees Iqbal c550508a54 Fixture: icb_merged_patches's AIR companions
scripts/regen-air-fixtures/regen-air-fixtures.sh icb_merged_patches on the Apple M3 Max (Apple
metal version 32023.922, macOS SDK 27.2 26B118), job m3-max-81495: icb_merged_patches.ll and
.air.ll, and the fixture's TOOLCHAIN line. The engine inventory and the air_input printouts take
the fixture when they are re-blessed on development.
2026-12-02 21:06:53 -08:00
Anees Iqbal 2d759d7c13 Tests: a kernel's patch draws into an indirect command buffer, a range row of their own (source; red)
The next indirect command kind after plain draws: MTLIndirectCommandTypeDrawPatches.
icb_merged_patches is an owned fixture. Its kernel encodes command i as one quad patch of one
control point from patch i, with no patch index buffer and level-1 half factors, one instance
for an even command and two for an odd one, from base instance i, with vertex buffers 0 to 2
of its own. The post-tessellation vertex function lays patch p over the rectangle from xy[2p]
to xy[2p + 1]. Each texel then holds its command's mark, the patch index, the instance and the
base instance.

indirect_ranges.rs gains the row indirect-range-gpu-written-patch-draws: commands 1 to 5,
written by a blit's copy before the pass, as the plain-draws row is. The fixture's AIR, the
expectations, the Metal recording and the ledger row follow in their own commits.
2026-12-02 21:06:53 -08:00
Anees Iqbal dcf039d472 rt: a copy between two buffers whose bytes meet goes in chunks of the shift, as memmove
Owner 3406 follow-up to L212. A copy between two buffers whose ranges meet
in one block was refused (Refusal::BufferCopyOverlap, basis "ours"). Two
buffers placed over each other in a heap are aliases. Metal's validation
names copies between buffers among the defined copies between aliases in
a placement heap (job m3-max-81493), and plain Metal on an Apple M3 Max
gives memmove's bytes for them (probe overlapping_alias_copies.m, job
m3-max-81544).

Form (blit.rs):
- buffer_to_buffer takes whether the two are one buffer and answers
  BufferChunks.
- Ranges apart are one chunk.
- Two buffers' ranges whose bytes meet are chunks no longer than the shift
  |to - from|, the last chunk the rest. The chunk at the end the shift
  points to goes first: the last first where the destination lies past the
  source, else the first. So no command's source and destination share a
  byte (VUID-vkCmdCopyBuffer-pRegions-00117, which each one-region command
  meets on its own), and no chunk reads a byte an earlier one wrote.
- copy_from_buffer_to_buffer records one vkCmdCopyBuffer a chunk with the
  slabs' execution barrier (between) between two, each counted as a blit
  barrier. Every hazard between two chunks is a write after a read.
- Two ranges on the same bytes copy nothing.
- One buffer's overlapping ranges stay Refusal::BufferCopyOverlap. Its basis
  is now metal-documented: Apple's page for the copy allows the same buffer
  only "if size is less than the distance between sourceOffset and
  destinationOffset". The conformance case buffer-blit-overlapping-copies
  is one buffer, so its ledger row holds. Only its note's wording changed;
  coverage.py regenerated with no change.
- A shift of n bytes takes size/n commands, rounded up. That is the fewest
  any form without an intermediate takes.

Unit test a_copy_between_buffers_takes_ranges_inside_both_and_cuts_two_buffers_bytes_that_meet
(renamed) expects the chunk orders both ways, a partial last chunk, and
nothing for the same bytes. The rest of its cases are unchanged.

Docs: the copy's doc, BufferCopyOverlap (REFUSALS.md and basis.rs
regenerated), the runtime README's blit encoders, the tests' module doc.

Verified: refusal_surface.py --check exits 0. Green under the validation
layer, which fails a test on any message, so each one-region chunk met
VUID-vkCmdCopyBuffer-pRegions-00117 on these devices: the 27 blit tests pass
on lavapipe (llvmpipe, LLVM 23.1.4; job m3-max-81597), the AMD Radeon 780M
(RADV PHOENIX; m3-max-81592), the NVIDIA GeForce RTX 2080 (m3-max-81600) and
the AMD Radeon RX 7900 XTX (RADV NAVI31; m3-max-81671). The runs built the
series before its rebase onto development; the patches are the same.
2026-12-02 21:06:53 -08:00
Anees Iqbal 6bc49a3a8c rt test: a copy between two buffers whose bytes meet leaves memmove's bytes, as the M3 does
Owner 3406 follow-up to L212. The runtime refuses a copy between two
buffers whose ranges meet in one block (two buffers placed over each other
in a heap) as Refusal::BufferCopyOverlap, basis "ours". Metal's validation
names copies between buffers among the defined copies between aliases in
a placement heap ("blitting between aliasing resources is defined on a
placement heap only when using a blit method copying entire texture
surfaces, or when copying between buffers"; job m3-max-81493). Plain Metal
on an Apple M3 Max gives memmove's bytes for such copies (probe
overlapping_alias_copies.m, job m3-max-81544): 64 KiB, the destination 4
or 4096 bytes past the source, and the reverse.

New device test every_device_copies_between_buffers_whose_bytes_meet_as_memmove:
- Three heap buffers over one Shared block: two at offset 0, one at 256.
- Copies 4 bytes on and back (1024 bytes), and 256 bytes on and back (1024
  and 1000 bytes). Each expects the heap's bytes to be memmove's, every
  other byte kept.
- Each expects a blit barrier a chunk more than a copy's one: 256 chunks
  for the 4-byte shifts, 4 for the 256-byte ones. No byte is copied of the
  runtime's own.
- Two ranges on the same bytes copy nothing and record no barrier.
- One buffer's overlapping ranges stay Refusal::BufferCopyOverlap.

Red as expected: every meeting case is refused today. The test fails on
lavapipe (llvmpipe, LLVM 23.1.4; job m3-max-81597), the AMD Radeon 780M
(RADV PHOENIX; m3-max-81592), the NVIDIA GeForce RTX 2080 (m3-max-81600) and
the AMD Radeon RX 7900 XTX (RADV NAVI31; m3-max-81671), with "4 bytes on: a
copy of 1024 bytes from 0 to 4 reads bytes it writes". The runs built the
series before its rebase onto development; the patches are the same.
2026-12-02 21:06:42 -08:00
Anees Iqbal 8f017b6efe Conformance probe overlapping_alias_copies: what an M3 Max measured for buffers that alias
Owner 3406 follow-up to L212: copies between buffers that alias in a
placement heap. Job m3-max-81544, an Apple M3 Max, macOS 27.0.1.
- With the API validation off, every buf-* case gave memmove's bytes in 8
  of 8 rounds: two buffers at offset 0 of a Private placement heap, 64 KiB
  with the destination 4 or 4096 bytes past the source, and the reverse.
  One buffer into itself, 4 bytes on, gave the same.
- With MTL_DEBUG_LAYER=1, the one-buffer control runs with the same bytes.
  Every two-buffer case ends the process inside the layer's own aliasing
  check: "-[MTLDebugBuffer width]: unrecognized selector sent to instance",
  from validateResourceAliasing under -[MTLDebugBlitCommandEncoder
  copyFromBuffer:sourceOffset:toBuffer:destinationOffset:size:]. That is the
  layer's fault, not a refusal. The layer's own assertion text, quoted
  above it, names copies between buffers among the defined copies between
  aliases.

Verified: the job's log, read whole.
2026-12-02 21:06:41 -08:00
Anees Iqbal 517428b2ec Conformance probe overlapping_alias_copies: copies between two buffers that alias in a placement heap
Metal's API validation says a copy between aliasing resources in a placement
heap is defined "when copying between buffers". The runtime refuses two
buffers that overlap in one block as Refusal::BufferCopyOverlap.

The new buf-* cases measure Metal's answer:
- 64 KiB copied between two buffers at offset 0 of a Private placement
  heap, the destination 4 or 4096 bytes past the source, and the source
  past the destination;
- as a control, one buffer copied into itself 4 bytes on. Apple's page for
  the copy allows that only where the size is less than the offsets'
  distance.
A third buffer over the same bytes writes them first and reads them after.
Each round counts the bytes that hold memmove's answer.

Verified: xcrun clang -fsyntax-only -Wall -Wextra, no diagnostics.
2026-12-02 21:06:41 -08:00
Anees Iqbal 6d46a01d86 rt test: a surface's buffer and its own plane in the copy form too, against the M3's answer
Row L212. The test copies between Surface::buffer and its own plane, into
the plane and out of it from a row on. It ran only where the surface was in
place, so the copy form was not tested on any device.

The test now runs the copy form too, after the in-place form:
- A pitch multiple of 4096 asks every device for the copy form, as
  tests/surface.rs's "copy-form" row does. In that form the plane is a
  texture over the block's buffer in an image of its own, and crate::over
  carries the bytes between them.
- Each form expects every byte of the surface to be the source's from before
  the copy, every other byte kept.
- The copy form also expects no refusal and at least one counted over copy
  (Metrics::over_copies, every cause), so the run shows the path ran. Not
  Metrics::over_copies_surface: memory_cause gives that cause only where the
  memory's kind keeps the image from lying in place, and a plane at a pitch
  of a multiple of 4096 is in the copy form for its pitch
  (Copy(Pitch { plane: 0 })). An assertion on over_copies_surface failed on
  lavapipe (job m3-max-81576) after the bytes had matched.
- The line printed per device gives each case's submissions and copies.
- The in-place counts are unchanged.

The doc cites the M3 Max's answer from probe overlapping_alias_copies.m,
job m3-max-81486: the source's bytes from before the copy between an
IOSurface's no-copy buffer and its own plane, a row on each way and 8 texels
along, into and out of the plane, with the validation layer passing each.

No product change. Verified, device tests under the validation layer, each
printing OpaqueFd, Copy(Pitch { plane: 0 }), rows 4096 apart, (submissions,
copies) [(1, 2), (1, 1)], 27 of 27 blit tests passed:
- lavapipe (llvmpipe, LLVM 23.1.4): job m3-max-81597;
- AMD Radeon 780M (RADV PHOENIX): job m3-max-81592;
- NVIDIA GeForce RTX 2080: job m3-max-81600;
- AMD Radeon RX 7900 XTX (RADV NAVI31): job m3-max-81671.
The runs built the series before its rebase onto development, with this
assertion's fix as a commit of its own; the patches together are the same.
2026-12-02 21:06:41 -08:00
Anees Iqbal 2416a42d36 rt: copies between a heap texture and memory it aliases are Metal's own refusal, but a whole level between two heap textures
Row L212. Metal's API validation stops a copy between aliases in a placement
heap unless it copies between buffers, between linear textures of one row
stride, or entire texture surfaces. Source: probe overlapping_alias_copies.m
on an Apple M3 Max, macOS 27.0.1, jobs m3-max-81486 and m3-max-81493. The
runtime refused all of these as Gap::OverlappingCopy. It now refuses what
Metal stops as Refusal::AliasingCopy, and records nothing for it.

Form (blit.rs):
- buffer_copy: a region that meets a heap texture's memory, either way, is
  Refusal::AliasingCopy (Metal: "blitting between aliasing resources is
  defined on a placement heap only when using a blit method copying entire
  texture surfaces, or when copying between buffers").
- texture_copy: two textures whose memory meets, one placed in a heap, that
  are not both heap textures copying a whole level into a whole level
  (whole_level: origin 0, size the level's extent, the view's first level
  taken off) are Refusal::AliasingCopy. A texture in place over a heap
  buffer against a heap texture is refused even for a whole level (Metal:
  "... only when both textures are linear and have the same
  bufferBytesPerRow value").
- The whole level between two heap textures stays Gap::OverlappingCopy,
  counted, per the planner's ruling. That is how the consumer reaches
  copyFromTexture:toTexture:, which Metal's validation takes and the M3
  answers with the source's bytes at 0, 128 and 8320 bytes apart. No copy
  command and no cut reads no byte it writes
  (VUID-vkCmdCopyImage-pRegions-00124). The form through an image of the
  runtime's, counted, is built once a guest's run counts the gap.

Docs: blit.rs's module and copy method docs; error.rs's Gap::OverlappingCopy
(REFUSALS.md regenerated); Metrics::overlapping_copies_refused; the runtime
README's blit encoders and their known gaps, which carry the M3's answer
and the VUID. The README also cites the M3's answer for a surface's buffer
and its own plane (job m3-max-81486). No conformance ledger row covers
these shapes.

Verified: refusal_surface.py --check exits 0. Green under the validation
layer, which fails a test on any message: the three tests pass, with the
rest of the 27 blit tests, at the series' tip on lavapipe (llvmpipe, LLVM
23.1.4; job m3-max-81597), the AMD Radeon 780M (RADV PHOENIX; m3-max-81592),
the NVIDIA GeForce RTX 2080 (m3-max-81600) and the AMD Radeon RX 7900 XTX
(RADV NAVI31; m3-max-81671). The runs built the series before its rebase
onto development; the patches are the same.
2026-12-02 21:06:41 -08:00
Anees Iqbal 19d642612d Tests: copies between a heap texture and memory it aliases are Metal's own refusal, but a whole level between two heap textures
Row L212. These copies were all Gap::OverlappingCopy: a copy between a
texture placed in a heap and a resource whose memory meets it.

On an Apple M3 Max, macOS 27.0.1, the conformance probe
overlapping_alias_copies.m (jobs m3-max-81486 and m3-max-81493) shows that
Metal's API validation stops most of these shapes with
"blitting between aliasing resources is defined on a placement heap only
when using a blit method copying entire texture surfaces, or when copying
between buffers":
- a buffer and a texture over its bytes, either way;
- the region method between two heap textures that alias.
It stops a heap texture and a linear texture over a heap buffer at its
bytes with "... only when both textures are linear and have the same
bufferBytesPerRow value". It passes copyFromTexture:toTexture: between two
heap textures that alias. The consumer copies that as whole levels through
copy_from_texture.

The new Refusal::AliasingCopy (Basis: metal-measured) names the shapes
Metal stops. docs/REFUSALS.md, error/basis.rs and api_signatures.tsv are
regenerated. A whole level into a whole level between two heap textures
stays Gap::OverlappingCopy, per the planner's ruling. Nothing produces the
new variant yet.

Tests:
- textures_whose_memory_meets_where_one_is_laid_out_by_the_device_are_refused_or_copy_in_no_order
  (unit, renamed) expects the two heap textures' whole-level copy still to
  copy in no order. It expects part of a level, either way and at an offset,
  and a texture in place over the heap texture's bytes, either way, to be
  Refusal::AliasingCopy.
- a_buffer_copy_over_its_texture_s_own_bytes_copies_in_slabs_or_in_no_order
  (unit) expects a region meeting a heap texture's memory, into it and out
  of it, to be Refusal::AliasingCopy.
- every_device_refuses_a_copy_between_heap_resources_whose_memory_meets
  (device) expects the whole level onto its alias to be the counted gap,
  and part of a level onto its alias and the heap buffer either way to be
  Refusal::AliasingCopy. Nothing is recorded, and one refusal is counted.

Verified: refusal_surface.py --check exits 0, and signatures.py --bless adds
the one variant row. Red as expected, under the validation layer, on
lavapipe (llvmpipe, LLVM 23.1.4; job m3-max-81597), the AMD Radeon 780M
(RADV PHOENIX; m3-max-81592), the NVIDIA GeForce RTX 2080 (m3-max-81600) and
the AMD Radeon RX 7900 XTX (RADV NAVI31; m3-max-81671): the three tests
fail. The device test says "part of a level onto its alias:
Err(Unsupported(OverlappingCopy { pixel_format: RGBA8Unorm }))", the unit
tests "not a refusal: it was checked". The runs built the series before its
rebase onto development; the patches are the same.
2026-12-02 21:06:24 -08:00
Anees Iqbal dc3fc106c1 Conformance probe overlapping_alias_copies: what an M3 Max measured
Row L212. The probe header now records the two oracle jobs on an Apple M3
Max, macOS 27.0.1: m3-max-81486 (heap-* and surface-*) and m3-max-81493
(tex-*).

- With the API validation off, every copy between aliases gives the
  source's words from before the copy, in 8 of 8 rounds each.
- Metal's API validation ends the process at these copies:
  - a buffer and a heap texture over its bytes;
  - the region method between two heap textures that alias, over the whole
    level or a part of it;
  - copyFromTexture:toTexture: between a heap texture and a linear texture
    over a heap buffer at its bytes.
  The header quotes each assertion's text.
- Metal's API validation passes copyFromTexture:toTexture: between two heap
  textures that alias, and every copy between an IOSurface's no-copy buffer
  and its own plane.

Verified: the two jobs' logs, read whole.
2026-12-02 21:06:04 -08:00
Anees Iqbal 4026271b0c Conformance probe overlapping_alias_copies: texture to texture copies between aliases in a placement heap
Row L212. On an M3 Max, the first round (job m3-max-81486) found these
answers under Metal's API validation:
- A copy between a heap buffer and a heap texture over its bytes ends the
  process: "blitting between aliasing resources is defined on a placement
  heap only when using a blit method copying entire texture surfaces, or
  when copying between buffers."
- copyFromTexture:toTexture: between two identical textures at one offset
  passes the validation.

The new tex-* cases ask which texture-to-texture copies count as "entire
texture surfaces", and what the M3 gives for them:
- copyFromTexture:toTexture: with the second texture one alignment on, and
  half its bytes on;
- the region method over the whole level, at offset 0 and half on;
- the region method over a quarter of the level;
- a heap texture and a linear texture over a heap buffer at the same bytes,
  each way.

Verified: xcrun clang -fsyntax-only -Wall -Wextra, no diagnostics.
2026-12-02 21:06:04 -08:00
Anees Iqbal edb3cb9bea Conformance probe: what Metal answers for a blit copy between two resources over one memory
Row L212. Two copy shapes have no M3 answer on record:

- A texture placed in a placement heap and a buffer or texture of the heap
  placed over its bytes. The runtime refuses this as Gap::OverlappingCopy.
- An IOSurface plane's texture and a no-copy buffer over the surface's own
  bytes. The runtime copies this a row at a time from the source as it was
  before the copy (Surface::buffer and its plane).

overlapping_alias_copies.m runs each shape as one blit command alone, one
case a process, 8 rounds each. Each round prints, word by word, whether the
destination holds the source's bytes from before the copy, and for the
surface, the word an in-place copy front to back or back to front would
leave. It also has controls with the heap's second resource placed apart.

Verified: xcrun clang -fsyntax-only -Wall -Wextra, no diagnostics. No
measurement yet.
2026-12-02 21:06:03 -08:00
Anees Iqbal 4af57732db Translator: SEMANTICS_VERSION 2326 for a kernel's plain triangle draws into an indirect command buffer
85b8af89a4 lowers render_command's draw_primitives of triangles (it wrote a refusal before),
so a kernel that encodes plain draws translates to other words under an unchanged key. The golden
tables are re-blessed on development.
2026-12-02 21:06:03 -08:00
Anees Iqbal 62e3835aa1 Docs: CONFORMANCE-COVERAGE.md regenerated for the plain-draws row's notice
5781011f02 gave indirect-range-gpu-written-plain-draws its point-size notice allowance and left
docs/CONFORMANCE-COVERAGE.md one line behind it (coverage.py --check: not what the suite's
sources and recordings derive). Regenerated; --check now says as derived.
2026-12-02 21:06:03 -08:00
Anees Iqbal a0a4cb99e7 Conformance: Metal's times for indirect-range-gpu-written-plain-draws, kept in its recording
`conformance times --runs 8 --write indirect-range-gpu-written-plain-draws`, built --release
at 484725a4d4, on the Apple M3 Max, macOS 27.0.1 (26A434), job m3-max-81417. The recording
gained one time record (native Metal, 8 rounds) and nothing else: a comparison of the JSON
before and after shows `times` the one key added and every other key equal. This is what
times::every_case_is_timed::every_case_carries_its_timing asked of the new case (it failed in
m3-max-81226 at d14977bfcf).
2026-12-02 21:06:03 -08:00
Anees Iqbal 3d1eda17b1 ICB: the plain-draws range row declares the point-size notice; the shape key is a type
The lavapipe proof (llvmpipe, job m3-max-81225) compared the new row divergent at
case/notices alone: icb_merged_vertex writes [[point_size]], so the render state carries
the static note device-point-size on a device whose largest point is below Metal's
(llvmpipe's 256), and the case declared no notice. The plain row now declares it, as
render_draw_forms does for the same fixture; no value is loosened. The indexed rows'
vertex function writes no point size and declares nothing.

Clippy (job m3-max-81227) refused the shapes cache's key tuple as too complex; it is
now the ShapeKey alias. No behaviour changes.
2026-12-02 21:06:03 -08:00
Anees Iqbal 3f6967e92a API guide: a function's draw_primitives of triangles writes an indirect command's record too
docs/API.md section 1 listed the render_command operations a function writes under the identity
domains; draw_primitives of triangles joined them in d14977bfcf. Its arguments go where an indexed
draw's do. Docs only.
2026-12-02 21:06:03 -08:00
Anees Iqbal 21f0cae67b ICB: a kernel's plain triangle draws into an indirect command buffer, executed through a layout of plain draws
The owner's 3406 order, the planner's first indirect command kind: MTLIndirectCommandTypeDraw.

Translator (lower/access/icb.rs): a render_command's draw_primitives of the constant triangle type
writes VkDrawIndirectCommand (vertex count, instances, vertex start, base instance) where an
indexed draw's VkDrawIndexedIndirectCommand goes, 20 bytes past the index token's place, and
writes nothing else. Both kinds share the records (pipeline::IndirectDrawLayout), so an encoding
writes one shape whatever buffer it reaches. A kernel cannot know a buffer's kind when it is
translated, because it reaches the buffer through an argument buffer. A reset's draw of nothing
reads as either kind's. Points and lines stay refused, as for indexed draws, because an execution
draws one topology.

Runtime: Device::new_indirect_command_buffer takes DRAW alone as well as DRAW_INDEXED alone, and
the buffer keeps its kind (indirect::CommandDraw). An execution's command layout follows the
kind. A layout of plain draws holds no index buffer token, which
VUID-VkIndirectCommandsLayoutCreateInfoEXT-pTokens-11095 forbids there, and ends in TOKEN_DRAW.
Its tokens are one fewer. The execution shapes' cache keys on the kind, and the reset templates
serve both kinds.

DRAW together with DRAW_INDEXED stays a typed refusal, CommandTypes, until the planner rules. A
layout takes one draw token (VUID-...-11100), and no form found draws both kinds in command order
at a bounded cost: two executions reorder the commands, an execution per command costs two a
command, and identity indices hold only as many vertices as a bound buffer of them. The
CommandTypes doc, the runtime README's ICB section and its refusal line say so.

Docs: the README ICB section; METAL-COVERAGE (coverage.tsv: "plain or indexed triangle draws");
CONFORMANCE-COVERAGE regenerated for the new row's recording and ledger row. REFUSALS.md
regenerated with no change.

Not run on an Intel card: the Iris Xe lacks VK_EXT_device_generated_commands, so its ledger row
is the Extension refusal; the four-card proof jobs are named in the hand-over.
2026-12-02 21:06:03 -08:00
Anees Iqbal 5059796ee6 Conformance recording: indirect-range-gpu-written-plain-draws on Metal (red still)
Metal's answer for the plain-draws range row, recorded by job m3-max-81211 on the Apple M3 Max
(macOS 27.0.1, 26A434) at 873654c61e, plain and under Metal's validation layer: the execution
completes and commands 1 to 5 draw rows 2 to 11. Each texel holds the command's mark, the
provoking vertex's vid (6i or 6i + 3), the instance_id and the base instance i. The instance_id
counts from the base instance: an odd command's second instance reads i + 1, an even one's only
instance i.

Red at 873654c61e, job m3-max-81207 (msi, lavapipe): the engine test refuses
icb_merged_triangles (GpuEncodedIndirectCommands, NotImplemented), and the runtime's plain-draws
test meets 'indirect command buffers of CommandTypes are not built' on llvmpipe.
2026-12-02 21:06:03 -08:00
Anees Iqbal 2fe776acf3 rt test: the plain-draws test matches the mixed buffer's error alone, as the buffer is not Debug (red still)
Job m3-max-81201 (msi, lavapipe) at 2ce4455b36 did not compile the runtime's tests: the match on
new_indirect_command_buffer's Result printed its other arm with {:?}, and IndirectCommandBuffer
is not Debug. The check now matches the Result's error, an Option. The engine leg of that job
was red as meant: a_kernels_plain_triangle_draws_into_commands_compile_under_the_identity_domains
failed and the four other engine tests passed.
2026-12-02 21:06:02 -08:00
Anees Iqbal e9efa22405 Tests: a kernel's plain triangle draws into an indirect command buffer draw as their draws direct (red)
The owner's 3406 order: every unbuilt indirect command kind Metal gives every Mac device is a
refusal to build, and the planner ranked MTLIndirectCommandTypeDraw first. Today the translator
refuses a kernel's draw_primitives (Unsupported{GpuEncodedIndirectCommands, NotImplemented}) and
the runtime refuses a descriptor of DRAW (Gap::IndirectCommandBuffers, CommandTypes).

- Engine: icb_merged_draws's icb_merged_triangles compiles and validates under the identity
  domains on lavapipe and moltenvk-m3 (red: refused today). Its points and lines kernels stay
  refused, since an execution draws one topology.
- Runtime, under a device cfg: four plain triangle draws the kernel encodes (three vertex buffers
  each, their own vertex starts, one or two instances and base instances) draw what the same draws
  direct draw: all four, commands 1 and 2, the range 2 and 3 a buffer holds, and executions around
  a direct draw. A buffer of DRAW and DRAW_INDEXED together stays CommandTypes, until the planner
  rules on that mix. Red: the buffer of DRAW is refused today.
- Conformance: a fourth GPU-written range row, indirect-range-gpu-written-plain-draws: eight
  plain triangle draws the kernel encodes, commands 1 to 5 in a range a blit writes. The range
  rows now state their command type (EncodedRange::command_types); the three indexed rows keep
  their inputs byte for byte. The Iris Xe's ledger row is the same Extension refusal as the other
  three range rows. Metal's recording follows in its own commit, taken on the M3. Red: the
  runtime refuses the buffer, CommandTypes, a row the ledger does not hold.

Jobs: the red runs are named in the hand-over.
2026-12-02 21:06:02 -08:00
Anees Iqbal a6f34a7fbe Runtime README: the make's time on the Radeon 780M and the Iris Xe beside the M3's
The known gap's make time now names three integrated devices: a 1920 by 1080 BGRA8Unorm
texture in place over host memory takes, median and largest of 16 makes in microseconds, 848 and
1149 on the Apple M3 Max, 720 and 1426 on the Radeon 780M and 3499 and 3927 on the Iris Xe; a
16 by 4 one 436, 278 and 420; a make that is the counted copy 25 to 60.

Verified: host_make's lines from the seam test at the commit before, whose tree differs from this
one by this paragraph alone: Radeon 780M (RADV, Mesa 26.2.6) job m3-max-81798, 18 of 18 passed;
Iris Xe (ANV, Mesa 26.2.6) job m3-max-81801, 18 of 18 passed. The M3's figures are from job
m3-max-81753 at the RUNTIME_VERSION commit, 12 of 12 passed.
2026-12-02 20:38:26 -08:00
Anees Iqbal 105ab7b18f Runtime README: the make's measured time beside the host-memory known gap
The restore pair inside a make of a texture over host memory copies the texture's bytes out and
back, so the make's time grows with the texture's size. The known gap now gives the make's time on
the Apple M3 Max under KosmicKrisp 26.3.1: a 1920 by 1080 BGRA8Unorm texture in place, 848
microseconds (median of 16, largest 1149); 16 by 4 texels, 436; a make that is the counted copy,
25. The paragraph is reflowed to the README's width.

Verified: the figures are host_make's lines from the seam test at the commit before, job m3-max-81753
(12 tests run, 12 passed).
2026-12-02 20:20:22 -08:00
Anees Iqbal de200dc009 Translator: RUNTIME_VERSION 2552 for a texture over host memory restored inside its make
The runtime now makes a texture over host memory's import in place on an integrated or CPU
device, restores its bytes in a submission of its own inside the make, counts that pair under
OverCause::HostMemoryRestore, and offers Buffer::new_texture_in_place with its refusal
TextureNotInPlace. A run of an unchanged artifact may therefore submit and record something else,
and refuse something else, under an unchanged key. None of the validation crate's runtime inputs
changed, so runtime-sources.sha256 holds. SEMANTICS_VERSION does not move: nothing compiled
changed.

Verified: Gate job m3-max-81765 (clippy in three configurations, Rustdoc, the runtime's private
Rustdoc, and the runtime, translator, validation and conformance suites) passed with the series'
final code, the runtime guard among the validation suite's tests.
2026-12-02 20:17:48 -08:00
Anees Iqbal d10970077e Runtime test: the seam test times sixteen makes of a 1920x1080 BGRA8 texture over host memory
The restore pair inside a make copies the texture's bytes out and back, so a make's time grows
with the texture's size, and the 16x4 timing does not show it at a video frame's size. The test
now also makes a 1920x1080 BGRA8Unorm texture over an import of its own sixteen times, prints the
median and largest make, whether the frame was in place and the restore copies and bytes counted
across the sixteen, and asserts that an in-place frame's make counted its pair (32 copies) by its
return.

Verified: the 1080p make's median and largest, in microseconds: Apple M3 Max 848 and 1149 (job
m3-max-81753), Radeon 780M 720 and 1426 (m3-max-81798), Iris Xe 3499 and 3927 (m3-max-81801),
lavapipe 4249 and 14654 (m3-max-81750), each in place with 32 restore copies of 265,420,800 bytes in
all; the RTX 3090, the counted copy, 35 and 969 (m3-max-81792) with none.
2026-12-02 20:17:48 -08:00
Anees Iqbal 1e11b4e959 Runtime: new_texture_in_place with index None is reached through its views alone
The consumer makes a surface shape's image with no index of its own (Reach::Views), each guest
texture over it a view at the guest's index, and needs the in-place image made the same way. The
planner agreed that this rides N, one call: new_texture_in_place maps index None to Reach::Views
for any usage, as the crate-private Buffer::new_plane_texture does; Some(index) stays
Reach::Index, given exactly where shaders reach the texture, as new_texture takes it. The decision
whether the texture is in place is unchanged and still shared with new_texture.

Its doc says what None means against Metal: Metal gives every texture made from a buffer a
gpuResourceID of its own; one made with None has none (gpu_resource_id answers index 0, Metal's
nil texture to a shader, and a bind to a texture slot is Refusal::TextureWithoutIndex), and the
consumer answers the program through a view at the program's index. None is never
Refusal::TextureIndex. The runtime README says the same.

Verified on lavapipe, job m3-max-81750: tests/in_place_views.rs failed at the commit before (the
make in place alone with no index was refused) and passed two commits on, at the RUNTIME_VERSION
commit, with ShaderRead and with ShaderRead and PixelFormatView: views at an index in the image's
format, its sRGB sibling and R32Uint, retargets from it and onto it, and blits into and out of it.
With the series' final code (runs at its README commits, which change no code), the touched device
tests with in_place_views passed on the Apple M3 Max under KosmicKrisp 26.3.1 (job m3-max-81753, 12
of 12), the Radeon 780M (job m3-max-81798, 18 of 18), the Iris Xe (job m3-max-81801, 18 of 18) and
the RTX 3090 (job m3-max-81792, 18 of 18), each in both usages; gate job m3-max-81765 (clippy in
three configurations, Rustdoc, the runtime's private Rustdoc, and the runtime, translator,
validation and conformance suites) passed with the series' final code.
2026-12-02 20:14:11 -08:00
Anees Iqbal a87d4b0fd9 Runtime test: a texture made in place alone with no index is reached through its views (red)
The consumer (video2) makes a surface shape's image with Device::new_texture_for_views
(Reach::Views): it takes no resource index of its own, and each guest texture over it is a view
at the guest's own index. To make that image in place it needs new_texture_in_place to take
index None the same way, as the crate-private Buffer::new_plane_texture maps None to
Reach::Views; today None is Refusal::TextureIndex for any usage shaders reach, and an index of the
consumer's own would take one outside the guest's numbering.

The test (tests/in_place_views.rs), on every device: an RGBA8Unorm texture of 8 by 8 at the
device's pitch over a Shared buffer, made by new_texture_in_place with index None, with ShaderRead
usage and, where the device makes it in place, with PixelFormatView too. It is in place with no
index of its own, and takes what a shape's image takes today:
- a view at the guest's index in its own format, which a draw samples texel for texel, and views
  in its sRGB sibling and (PixelFormatView) R32Uint, whose blit copies out read the buffer's bytes;
- a retarget from it: a blit copies it into a Private image for views, whose view takes the
  index, and a draw sampling the index reads the copy;
- a retarget onto it: its view takes another Private image's view's index, and a draw sampling
  the index reads its texels;
- a blit copy into it writes the buffer's bytes at the pitch, read back by a copy out and a draw.

Expected red on every device: index None is refused with TextureIndex.
2026-12-02 20:13:03 -08:00
Anees Iqbal 16f7bc942e Runtime: a texture over host memory's import is restored inside its make, which waits for it
The planner ruled the seam (ii), for new_texture and new_texture_in_place alike, one form: the
restore pair of a texture in place over host memory's import runs in a submission of the
runtime's own inside the make, and the make returns after it completes. Metal touches no bytes at
a make, and a CPU write to a Shared buffer that no pending GPU command uses is fully defined.
Running the pair at the next submission on any queue let one thread's commit revert another
thread's write (reims: an app wrote its first frame into a fresh pool surface under a lock that
waits on nothing, and a later submission from another process ran the pair mid-write): a lost
write documented Metal never loses. The planner's earlier term (the pair in the texture's first
command buffer, held by an ordering test) is withdrawn. Discrete devices are untouched: they have
no pair.

Device::texture, for a texture whose image restores (Keep::Restore), has the upload that holds
its move home go at once, alone (WorkState::flush), and waits on the progress semaphore for it
(Done::wait), the pattern Texture::get_bytes and new_buffer's Private zeroing use. The upload's
barrier orders the save after the GPU work already submitted, so the make waits for that work
too. An encoded shared-event wait is held on the CPU and never submitted, so it never holds the
make's submission back. The make is refused in a scheduled handler (Refusal::InScheduledHandler),
which runs on the submit thread that the make waits for, as those calls are.

Docs: new_texture's and new_texture_in_place's, InScheduledHandler's list, the counters'
(HostMemoryRestore inside the make), check_over's and the homing comment; the runtime README's
Imported blocks paragraph and its known gap, which now says what remains (a host write from
another thread during the make) and carries the Radeon 780M row (Phoenix, RADV, job
m3-max-81673: 696 against 537 us a frame at one draw, 1025 against 793 at four);
docs/REPLAY-STREAM.md; AGENTS.md rule 2 ("after one counted copy pair at its making") and rule 3
("a counted copy pair at the texture's making restores the bytes"), in the planner's words.
Tests: host_in_place, over_causes and import count the pair at the make.

Verified on lavapipe, job m3-max-81704: the seam test failed at the commit before (exit 100) and
passed here (exit 0), with clippy under --cfg m2v_cpu_icd clean. With the series' final code (runs
at its README commits, which change no code), the touched device tests with in_place_views passed on
the Apple M3 Max under KosmicKrisp 26.3.1 (job m3-max-81753, 12 of 12), the Radeon 780M (job
m3-max-81798, 18 of 18), the Iris Xe (job m3-max-81801, 18 of 18) and the RTX 3090 (job
m3-max-81792, 18 of 18), the integrated three restoring in place inside the make (32 restore copies
over sixteen 1080p makes); gate job m3-max-81765 (clippy in three configurations, Rustdoc, the
runtime's private Rustdoc, and the runtime, translator, validation and conformance suites) passed
with the series' final code.
2026-12-02 20:07:40 -08:00
Anees Iqbal 0d7521a809 Runtime test: a texture over host memory is restored inside its make (red)
reims's case: an app makes a texture over a fresh pool surface and writes its first frame under a
lock that waits on nothing; a later submission from another process runs the save and write-back
of the in-place texture's bytes mid-write, and the bytes revert. The planner ruled the seam (ii),
for both calls, one form: the restore pair runs in a submission of the runtime's own inside the
make, which returns once it completed. Metal touches no bytes at a make, and a CPU write to a
Shared buffer that no pending GPU command uses is fully defined; running the pair at the next
submission on any queue lets one thread's commit revert another thread's write, a lost write
documented Metal never loses. The planner's earlier term (the pair in the texture's first
command buffer, held by an ordering test) is withdrawn.

The test, for new_texture and new_texture_in_place over host memory's import, each device in
both forms: the restore pair is counted by the make's return (in place: two copies; copied:
none), and no restore runs after it; bytes the CPU wrote before the make and after it returns
hold through a commit on another queue and a read; then, with another queue committing
throughout, bytes the CPU writes for 20 ms after the make returns hold. Off unified memory the
in-place-only make is refused for HostMemory. Sixteen timed makes print their median and
largest time.

Expected red on lavapipe and every integrated device: the pair is counted only at the next
submission, so none is counted by the make's return.
2026-12-02 20:07:40 -08:00
Anees Iqbal 3f573034e2 Runtime README: row 1's known gap carries census B's bound on host memory's remaining copies
The planner accepted main's reading of reims's census B on the Apple M3 Max at this form (job
m3-max-81507, against the base at job m3-max-81498): 29 textures over host memory lay in place;
host memory's 2,327 counted copies, 982.3 MB with the in-place textures' restore pairs among
them, are at least 906 MB (92%) of textures with render-target usage, which KosmicKrisp makes no
linear colour attachment for, and six kinds read by shaders alone, of at most 32 KB each, carry
the rest, at most 76 MB. The entry states that bound beside the KosmicKrisp render-target
sentence and claims no more than the census's kind lines show.

Docs only.
2026-12-02 20:07:40 -08:00
Anees Iqbal 2186bd04d1 Runtime: an in-place texture's restore pair counts under OverCause::HostMemoryRestore
A texture in place over host memory's import on an integrated or CPU device costs one save and
write-back of the bytes under its image around its move out of the undefined layout, once, at
its first use. Those two copies counted under OverCause::HostMemory, beside a copied texture's
copies at its uses, so a census could not tell an in-place texture's kind line from a copy's.
The planner ruled (row 1, pin N) that the pair stays counted, in count and bytes and in the
totals, under a cause that says what it is.

The upload's restore now counts under OverCause::HostMemoryRestore, in
Metrics::over_copies_host_memory_restore and over_copy_bytes_host_memory_restore, and still in
over_copies, over_copies_imported and bytes_copied; its OverCopyKind carries that cause.
over_copies_host_memory counts the per-use copies alone. Docs: new_texture's, the runtime
README's Imported blocks and over-copy paragraphs, docs/REPLAY-STREAM.md's over-copy causes (now
twelve beside host memory's) and the frame line's host_memory part, which carries the restore
pairs.

Verified on lavapipe before the rebase onto 9ce9960452, job m3-max-81616: the tests failed at the
commit before (3 of 12 failed) and passed here (12 of 12). Then gate job m3-max-81765 (clippy in
three configurations, Rustdoc, the runtime's private Rustdoc, and the runtime, translator,
validation and conformance suites) passed with the series' final code.
2026-12-02 20:07:40 -08:00
Anees Iqbal 047d853104 Runtime tests: an in-place texture's restore pair counts under a cause of its own (red)
The first-use save and write-back of a texture in place over host memory's import counts today
under OverCause::HostMemory, the cause of a copied texture's copies at its uses. A census then
reads an in-place texture's kind line as a host-memory copy: reims's census B on the M3 showed
six ShaderRead-only kinds under HostMemory that the code says are the in-place textures' pairs.
The planner ruled that the pair keeps being counted, in count and bytes, under a cause that says
what it is, so that HostMemory means the per-use copies alone again.

This commit adds OverCause::HostMemoryRestore and its Metrics pair
(over_copies_host_memory_restore, over_copy_bytes_host_memory_restore), with docs, the
api_signatures table blessed, and the replay's metrics list and its over-copies-by-frame
host_memory part carrying the pair. The tests now expect the pair there: host_in_place's first
test (the first use's restore pair alone, and no host-memory copy), its device-type test (in
place: the restore pair at the first read, nothing after; copied: one host-memory copy a read,
no restore), and over_causes's move home (two restore copies, no other cause).

Expected red on lavapipe and every integrated device: the pair is still counted under
HostMemory.
2026-12-02 20:07:40 -08:00
Anees Iqbal 5f9287e40e Runtime: Buffer::new_texture_in_place, a texture over a buffer in place or a typed refusal
The consumer keeps a texture of its own where the runtime would make the counted copy of a
texture over a buffer, and needs the runtime's in-place texture everywhere else. Buffer::
new_texture_in_place makes what Buffer::new_texture makes where that texture is in place, and
refuses with Refusal::TextureNotInPlace { cause } where new_texture would make the copy, naming
the OverCause its copies would count under. A refusal makes no texture and counts no copy.

One decision in one place: Source::Over carries what the making does with a texture it would not
make in place (Unplaced::Copy for new_texture and a surface plane's texture, Unplaced::Refuse for
the new call). Device::texture refuses at the same two points where it chooses the copy: where
check_over names a cause, and where the linear image made does not lie as the texture's bytes do
(Unmade::Unfit). No new form and no new query: over host memory's import the choice is still
row 1's unified-memory query alone. A texture buffer is a view, never copied, and is made as
new_texture makes it.

The doc comment names newTextureWithDescriptor:offset:bytesPerRow: and lists what is refused;
texture_copy_cause's doc and the runtime README name the new call. docs/REFUSALS.md regenerated
(the refusal's two sites in texture); api_signatures blessed at the red commit.

Verified on lavapipe before the rebase onto 9ce9960452, job m3-max-81616: copy_cause's test failed
at the commit before (1 of 12 failed) and passed two commits on (12 of 12). With the series' final
code (runs at its README commits, which change no code), the touched device tests with
in_place_views passed on the Apple M3 Max under KosmicKrisp 26.3.1 (job m3-max-81753, 12 of 12), the
Radeon 780M (job m3-max-81798, 18 of 18), the Iris Xe (job m3-max-81801, 18 of 18) and the RTX 3090
(job m3-max-81792, 18 of 18); gate job m3-max-81765 (clippy in three configurations, Rustdoc, the
runtime's private Rustdoc, and the runtime, translator, validation and conformance suites) passed
with the series' final code.
2026-12-02 20:07:40 -08:00
Anees Iqbal cbe89f239d Runtime tests: a texture over a buffer made in place alone agrees with the ordinary make (red)
The consumer asked for an in-place-only make of a texture over a buffer: the linear image in
place wherever Buffer::new_texture takes it, and a typed refusal naming the cause wherever
new_texture would take the counted copy, so that the consumer keeps those bytes in a texture of
its own and counts them.

This commit adds Refusal::TextureNotInPlace { cause: OverCause } (Basis: ours), its Display arm,
docs/REFUSALS.md and basis.rs regenerated, the api_signatures table blessed, and a stub
Buffer::new_texture_in_place that makes the ordinary texture. copy_cause's test now runs each
device in both forms (an integrated or CPU device through its two-copy view too), makes each
case in place alone beside the ordinary texture, and adds a render target over its texels alone,
an R8Unorm texture of 13 x 3 at the device's pitch, and RGBA8Unorm and R8Unorm textures over host
memory's import. It asserts that the in-place-only make is in place where texture_copy_cause
answers in place, and elsewhere refused for that cause with no texture made and no copy counted.

Expected red on every device: the stub makes the counted copy where the answer is a cause (the
pitch case at least, on every device).
2026-12-02 20:07:39 -08:00
Anees Iqbal 0703c09cdb Runtime: a texture over host memory's import in place on an integrated or CPU device alone, the counted copy at each use elsewhere
The planner's ruling on row 1 (a). The in-place form over a host-pointer import is chosen by rule 2's
unified-memory query, Vulkan's physical device type (Core::unified_memory, the query that keeps one
copy of a Managed buffer): in place on an integrated or CPU device, after one counted copy pair at its
first use; on a discrete or virtual device the per-use counted copy stays. The planner's earlier term
that deleted the per-use path is withdrawn by name: that path stays, for discrete devices alone. It
is the same query and the same form, widened, not a new one.

Grounds. On an integrated device a texture over Shared memory is already a linear image in place by
rule 3, on the ordinary Shared-buffer route and on the dma-buf import route, and pays the same linear
read; the host-pointer import was the one case still copying at each use. The speed pair (a scratch
timed test, never landed: a 1920x1080 RGBA8Unorm texture over host memory the CPU writes whole each
frame, read at every texel by a 1080p pass of 1 or 4 draws; base d69a0bda18, in place 99125586fb;
six alternating runs of 300 frames each, frame time in microseconds, per-use copy against in place):
- Apple M3 Max, KosmicKrisp 26.3.1, job m3-max-81356: 1016 against 843 (1 draw), 1043 against 888
  (4 draws).
- Intel Iris Xe (RPL-P), ANV Mesa 26.2.6, job m3-max-81425: 3069 against 2630 (1), 4810 against 5381
  (4): a full linear read costs about 360 more than an optimal one and the copy about 480 to 500,
  so in place costs more from about two full reads a frame. The planner: that loss is against the
  copy being removed, in a kernel built to be its worst case, a recorded cost of the linear form,
  not a guest-shown regression; reims's census B on the M3 is the real-workload row.
- AMD RX 7900 XTX on OCuLink, RADV Mesa 26.2.6, job m3-max-81416: 1602 against 1561 (1), 1743
  against 1579 (4), within the spread: in-place reads at the copy's own rate, about 6.7 GB/s.
- NVIDIA RTX 3090 behind Thunderbolt, 620.70.06, job m3-max-81379: 5219 against 12522 (1), 5291
  against 12564 (4): the copy at about 1.98 GB/s, in-place reads at about 0.72 GB/s.

check_over lays a texture over host memory's import in place only where core.unified_memory();
elsewhere memory_cause names OverCause::HostMemory, the counted copy at each use. AGENTS.md: rule 2's
unified-memory clause gains the planner's words verbatim ("and a texture over a host-pointer import
in place on an integrated or CPU device, after one counted copy pair at its first use, and through
its per-use counted copy elsewhere"), and rule 3's host-pointer-import clause is limited to an
integrated or CPU device. The runtime README's Imported blocks paragraph names the device type, and
its known gap of memory blocks is one entry with the four rows. Buffer::new_texture's doc, the
counters' docs (OverCause::HostMemory, over_copies_host_memory, textures_in_place_over_imports),
REPLAY-STREAM.md and the device tests' docs say the same.

Verified before its rebases, on adba2693a1: on lavapipe, job m3-max-81460, the device-type test
failed at the commit before (1 of 2 failed) and passed here (2 of 2); the touched device tests
passed 15 of 15 on the Apple M3 Max under KosmicKrisp (job m3-max-81454), the Iris Xe
(m3-max-81456), the RX 7900 XTX (m3-max-81503), the RTX 3090 (m3-max-81555, the per-use copy) and
the Radeon 780M (m3-max-81556, in place); gate m3-max-81446 passed. Then gate job m3-max-81765
(clippy in three configurations, Rustdoc, the runtime's private Rustdoc, and the runtime,
translator, validation and conformance suites) passed with the series' final code.
2026-12-02 20:07:39 -08:00
Anees Iqbal f53c47d120 Runtime test: a texture over host memory in place on an integrated or CPU device alone, the counted copy elsewhere (red)
The planner's ruling on row 1 (a): the in-place form over a host-pointer import is chosen by rule 2's
unified-memory query, Vulkan's physical device type, as one copy of a Managed buffer is: in place on
an integrated or CPU device, after one counted copy pair at its first use; through its per-use
counted copy on a discrete or virtual device. Grounds: on the RTX 3090 (job 81379) a 1080p texture
read in place across the card's link took 12522 us a frame against 5219 us for the per-use copy,
while on the M3 (job 81356) in place took 0.829 and 0.852 of the copy's frame time.

each_device_takes_a_texture_over_host_memory_in_place_by_its_device_type runs in both forms
(each_device_in_both_forms): on an integrated or CPU device it asks in place, counted once in
textures_in_place_over_imports, the pair at the first read and nothing at the second; through the
two-copy view, and on a discrete device, the counted copy, one copy in of the texels' bytes at each
read and nothing back, and no count of a texture in place. It prints both counters per card.

Expected red at this commit: the two-copy view on lavapipe takes the texture in place.
2026-12-02 20:07:39 -08:00
Anees Iqbal 4b7f935a80 Runtime: a texture over host memory's import in place, its bytes saved and written back once
A texture over a buffer in host memory's import (Device::import_host_memory) used to be the counted
copy at every use. Its bytes were copied into an image of its own before each submission that used
it, and back after each write. Now it is in place: the device's linear image, made for host
memory's handle, bound in the import's own memory. The condition is that the external image query
for VK_EXTERNAL_MEMORY_HANDLE_TYPE_HOST_ALLOCATION_BIT_EXT answers the linear image importable,
compatible and not dedicated-only, and that the image passes the tests of any texture over a
buffer in place.

This is not a new copy. It is the existing last form made smaller: one copy pair in the texture's
life, in place after it, on documented behaviour only.
- Created UNDEFINED: an image bound in imported memory names the import's handle type
  (VUID-vkBindImageMemory-memory-02989), so it starts undefined
  (VUID-VkImageCreateInfo-pNext-01443).
- Saved and written back around the one transition: a move out of the undefined layout may
  discard the bytes (Vulkan 1.4, section 7.1.1).
- Host access by memory-domain operations: host memory has no other side whose release an acquire
  could match (section 11.2.6).

The image's one move home is in the upload ahead of the first command buffer submitted after the
making, from any queue, in this order:
1. a barrier from every earlier command's writes, including earlier submissions on the one
   queue, to the save;
2. a copy of the bytes bound under the image into a Private block taken at the making;
3. the move, in a barrier that waits for the save's reads;
4. the write-back, with a barrier between write-backs, since two imports of the same pages may
   meet;
5. a barrier from the write-backs to every later command and the host.
The block goes back once the upload retires. A later use copies nothing. Where the query offers no
linear image of the format and usage, the texture stays the counted copy at each use. On the Mac
driver that is every render target, since it makes no linear colour attachment.

Counts:
- the two copies count in Metrics::over_copies_host_memory (and over_copies, over_copies_imported,
  bytes_copied), each of the bytes bound under the image;
- new: Metrics::textures_in_place_over_imports counts each texture in place over an import, host
  memory's or a dma-buf's, at its making;
- the replay's frame metrics carry it.

Docs, in this commit:
- AGENTS.md rule 3's first exception gains the planner's clause verbatim;
- the runtime README's Imported blocks gives the form, and states the two VUIDs' rule in plain
  words;
- its known gap gives the pair, the window while the upload runs (a host write may be lost, and a
  host read may see the bytes undefined), and which formats and usages keep the per-use form on
  which driver, by query;
- REPLAY-STREAM.md and Buffer::new_texture's doc follow.

Tests:
- host_in_place gains two checks: a fill submitted before the making and not waited for is in the
  first read, and the texture counts once at its making;
- over_causes, import's texture test and imported_aliases now take either form, asserting in
  place on lavapipe and the copy where the query refuses.

Verified on the system lavapipe (llvmpipe, LLVM 23.1.4), job m3-max-81271, filter host_in_place,
over_causes, import's texture test, imported_aliases, import_overs and layouts: 17 tests.
- Red at the commit before: host_in_place fails at its in-place assertion; the other 16 pass.
- Green, at a tree whose code equals this commit's: 17 of 17 pass. The restore pair is 2 copies,
  512 bytes. In imported_aliases, the Half textures are in place, two pairs for two textures over
  one import. Clippy -D warnings under --cfg m2v_cpu_icd is clean for the runtime and validation.
2026-12-02 20:07:39 -08:00
Anees Iqbal 8c831aea1b Runtime test: a texture over host memory's import in place, restored once (red)
A device test for row 1's form. Under a device cfg, on every device that imports host memory, it
makes an RGBA8Unorm texture of 16 by 4 texels over a buffer spanning the import, at the device's
linear pitch. Where the external image query offers the linear image for host memory's handle
(lavapipe: Mesa's lvp_formats.c answers that handle importable), the texture is to be in place,
and three command buffers are each read exact:

- the CPU wrote the pages before the making and after it, before the commit; a blit reads both
  writes through the texture, and one save and write-back pair (over_copies_host_memory 2, its
  bytes between the texels' span and the import, each) are the command buffer's only copies;
- the CPU writes again; a blit reads the new bytes with no copy;
- a blit writes the texture; the pages hold its texels at the pitch, every other byte as the CPU
  wrote it, with no copy back.

No command names the image preinitialized, and the moves keep their order. Where the query offers
no such image, the texture is the counted copy, printed, and the same reads hold.

Red at this commit: every texture over host memory's import is the counted copy, so on lavapipe
the in-place assertion fails.
2026-12-02 20:07:39 -08:00
Anees Iqbal 9ce9960452 Conformance tests: record mode reads the host's macOS release from the side, so its tests run on any Mac
CI run 47018745061 (at 9186e2fe46) passes macOS's validation suite. Its next
step, "Test the conformance suite", fails 2 of 1054 on the macos-26 runner
(macOS 26.7.2, 25G332):
- record_mode_counts_the_outcomes_it_saw_with_their_runs unwraps
  Err(HostMoved { found: "macOS 26.7.2 (25G332)", named: "apple-m3-max on
  macOS 27.0.1 (26A434)" });
- record_mode_refuses_a_case_whose_metal_run_stopped gets the same
  HostMoved where it expects Refused.
These tests check record mode's logic through a stub side, but record mode
read the host's sw_vers directly. So on any Mac but the oracle, the host
check stopped them first.

Form:
- The Side trait gains macos_release (macOS only). Its default answers this
  host's sw_vers -productVersion and -buildVersion (record::sw_vers, the
  same reads check_host made). Metal's side and the runtime's side keep the
  default.
- check_host takes the side and holds its release against ORACLE_OS_VERSION
  and ORACLE_OS_BUILD as before. HostMoved and its text are unchanged. Off
  macOS it is NoMetal, as before.
- watch::Watching forwards macos_release to the side it wraps, as it
  forwards every Side call (the_announcing_side_forwards_every_call reads
  the trait). docs/CONFORMANCE-COVERAGE.md is regenerated: the Side method
  count is 135.
- The test StubSide states the oracle's release, so the record-mode tests
  check record mode's logic on any Mac. on_release moves it.
- New test record_mode_refuses_a_host_that_is_not_the_oracle (macOS):
  - a stub on macOS 26.7.2 (25G332) is HostMoved, naming both hosts;
  - the oracle's release on another build is HostMoved too.

The rest of the macOS job after this step: only "Doc tests" (cargo test
--workspace --all-features --doc). Every later step is Linux-only. No
running doctest touches the host: the only doc code fence in macOS-gated
code is a text block in the conformance binary. Packaging and the
documentation steps run before this one, and passed in run 47018745061.

Verified: see the hand-over. The M3 runs no tests, so the macOS proof is
the next CI run.
2026-12-02 20:00:52 -08:00
Anees Iqbal 208360ab6d rt: surface.rs imports Gap only on Windows, where its one use is
87693a368c left surface.rs's one Gap use, Gap::D3d11SurfaceBuffer, in a #[cfg(windows)] arm,
so every other build warned of an unused import and clippy with -D warnings failed on it
(m3-max-81412: workspace clippy plain, m2v_gpu and m2v_cpu_icd all EXIT=101 at 417d86ac90). The
import is now cfg(windows), and the make's doc links Gap::TextureView by path.
2026-12-02 19:29:39 -08:00
Anees Iqbal 094405e9a9 Harness and player: video planes ask shader read and write with no read-alone fallback
Since c850655216, new_exported_surface answers a plane whose image in place lacks storage with
the copy form (SurfaceCopy::Usage) rather than Gap::SurfaceUsage. So the harness's churn probe
and the replay player's video surfaces can no longer reach their fallback to planes of shader
read alone, and this commit deletes it:
- churn.rs: the probe's retry and Video's usage field, replaced by one const usage;
- videos.rs: the retry, its read_only counter, and the report's "with planes of shader read
  alone" count;
- REPLAY-STREAM.md and videos.rs's module doc now say the copy form takes such a device.
A device that lacks storage now shows in the report's copy-form count under its reason.

Checked by the hand-over job: clippy of the harness and validation crates, and the validation
suite.
2026-12-02 19:29:39 -08:00
Anees Iqbal 6d9706769a rt: a surface plane whose image in place lacks a usage its texture asks takes the copy form
new_exported_surface refused a plane whose texture asks a usage that its image in place does
not hold or export, ShaderWrite's storage for one, with Gap::SurfaceUsage. As ruled for row 5,
that plane now takes the counted copy form with its own reason, SurfaceCopy::Usage { plane }.
The copy form's texture over the block's buffer is an optimal image of the usage the texture
asks. The submissions copy it into the image and back (Metrics::over_copies), so a kernel's
write through a view of the plane reaches the exported bytes by that copy before the host or
the other API reads them.

How:
- Query::plane answers usage_verdict's reason in place of the gap. With nothing else to fail,
  its return type drops the outer Result and the pixel_format it carried only for the gap.
- The feedback-loop retry skips Usage, as it skips Tiling and NoModifier, since dropping the
  loop does not change the usage asked.
- Gap::SurfaceUsage stays for the Direct3D 11 import, and its doc now says that alone.

Docs, in this commit: the runtime README (the guide's storage paragraph, the copy form's list
of reasons, and a fifth case in the known gaps), REFUSALS.md regenerated (SurfaceUsage's row
and its sites) and the api_surface table (the new variant).

Tests:
- Verdict unit test a_plane_whose_tiling_lacks_an_asked_usage_takes_the_copy_form, with
  synthetic features: a LINEAR tiling without STORAGE_IMAGE, where the optimal tiling has it,
  takes Usage for a plane that asks storage, and lies in place for one that does not.
- The device test every_device_writes_a_surface_plane_through_a_shader_write_uint_view no
  longer accepts Gap::SurfaceUsage at the make.
- The write-back through the copy form's own copy is the same copy_form path the device test
  already ran at f997a251fc: on the RTX 3090 (NVIDIA 620.70.06, m3-max-81338) the dma-buf row
  took Copy(Tiling) and the copy-form row Copy(Pitch); on the RX 7900 XTX (RADV, Mesa 26.2.6,
  m3-max-81352) and lavapipe (Mesa 26.2.4, m3-max-81341) the copy-form row took Copy(Pitch).
  Each had the kernel's 2,073,600 texels written through the ShaderWrite R8Uint view, read
  back exactly from the surface's buffer.
- No device queried takes Usage for an R8 plane (the row 5 queries m3-max-81308, 81309,
  81310, 81314, 81318, 81322 and 81353).
2026-12-02 19:29:39 -08:00
Anees Iqbal adba2693a1 Conformance ledger: the shared creator's remaining refusals are the consumer's own and rt's padded formats
With a247e1ec2b the rt side answers newSharedTextureWithDescriptor:,
newSharedTextureHandle and newSharedTextureWithHandle:. Replaying the four cases on lavapipe
(Mesa 26.2.4, m3-max-81374) gave these results:
- the made, texture and handle sites compare against Metal's recording;
- a creator outside Private storage, and RGBA16Float_XR, answer nil as Metal does;
- 52 sites stayed refused, none divergent. This commit lists them:
  - 40 sites read parentTexture, parentRelativeLevel, parentRelativeSlice and isShareable, on
    the shared texture and its views. rt keeps no getter for them (TheConsumers), with the same
    text as the views' existing rows.
  - 8 resource and resource-after-handle sites read MTLResource's getters (TheConsumers), with
    storageMode among them, so storageMode is not compared at those sites.
  - 4 made sites for Private R10Unorm_X6, R10Unorm_X6_sRGB, RG10Unorm_X12 and
    RG10Unorm_X12_sRGB, where rt makes no texture of the format (the same gap as
    extended-swizzles-*'s rows; the 11-19 selector census found no stream that uses them).
All are venue *. CONFORMANCE-COVERAGE.md is regenerated (coverage.py --check: as derived).

The same job's full replay found no mismatch outside these four cases (52 in all, every one
listed here), and the conformance suite passed (1048 of 1048). The replay that shows these rows
holding is the hand-over's job.
2026-12-02 19:13:13 -08:00
Anees Iqbal 3f41b3b5b8 Conformance rt side: the shareable set keys textures by the handle's u32
957d59ecc1 kept the shareable textures in a set of u64, where a Handle is a u32; its build
failed (m3-max-81319, lavapipe, GREEN BUILD EXIT=101, E0308 at both uses). The set now holds
the handle's own type.
2026-12-02 19:13:13 -08:00
Anees Iqbal d0934196ef Conformance rt side: the shared creator and its handle as the runtime's consumer answers them
newSharedTextureWithDescriptor: is the texture newTextureWithDescriptor: makes, kept as
shareable; Metal's nil outside Private storage and for a format Metal makes no texture of
from a descriptor alone (texture_query::WITHOUT_TEXTURES, the list heap_metal_sizes already
asked, now shared) comes out nil, as measured on the M3 Max. newSharedTextureHandle and
newSharedTextureWithHandle: answer the handle of the one device and a clone of the same
Texture, shareable; a texture that is not shareable answers nil.

Not yet run: the replay of the four cases on lavapipe, and the ledger rows the getters of
the consumer's own (the resource getters, the parent facts and shareable) add at the new
sites, follow in their own commit.
2026-12-02 19:13:12 -08:00
Anees Iqbal e33ee4099f Conformance ledger: the shared creator's 31 cells compare against Metal (red)
The 31 rows of shared-creator-padded-format-storage, shared-creator-extended-range-samples,
texture-shared-handles and texture-view-descriptors at which the rt side answers
Unavailable(shared_texture) are dropped: the side is to answer newSharedTextureWithDescriptor:
and the handle calls as the runtime's consumer does on the runtime's one device, so each of
those sites compares against the M3 Max recordings (Metal's nil at Shared, Managed and
Memoryless, and for RGBA16Float_XR at Private; a texture at Private otherwise).

Red: the side still answers Unavailable, so a replay of the four cases fails on 31 refusals
the ledger does not list. CONFORMANCE-COVERAGE.md is regenerated (coverage.py --check: as
derived).
2026-12-02 19:13:12 -08:00
Anees Iqbal c13871f07a rt test: the shader-write plane test fills its texels as 16-byte arrays
clippy's chunks_exact_to_as_chunks failed the test build under --cfg m2v_gpu and
--cfg m2v_cpu_icd (m3-max-81362, CLIPPY m2v_gpu EXIT=101, m2v_cpu_icd EXIT=101) at
f997a251fc's chunks_exact_mut(16); as_chunks_mut::<16>() takes the same texels.
2026-12-02 19:11:30 -08:00
Anees Iqbal 02702415f9 rt: a dma-buf plane's view list holds only formats its DRM_FORMAT_MOD_LINEAR modifier samples
view_list takes each format's features in the plane image's own tiling: LINEAR's for an
opaque handle's LINEAR image, the MOD_LINEAR modifier's for a dma-buf's modifier image, as
Vulkan 12.6.1 defines a view's format features. A format the modifier lists no features for
is no longer listed for a dma-buf's plane, so no view of it is made with empty format
features (VUID-VkImageViewCreateInfo-None-02273); a view in it is Gap::TextureView of
SurfacePixelFormat, as for a format the LINEAR tiling does not sample.

No device the tests run on routes a dma-buf export through NVIDIA, whose LINEAR tiling
samples the 8-bit UINT and SINT formats with no modifier listed for them (row 5's queries);
the AMD and Intel devices list MOD_LINEAR for every format they sample (780M m3-max-81314,
Iris Xe 81310). The verdicts test from the red commit passes.
2026-12-02 19:11:30 -08:00
Anees Iqbal 17868df415 rt: a plane's view list from its tiling's features, beside a test that a dma-buf's list holds only formats its modifier samples (red)
surface.rs filtered an in-place plane's view formats by each format's LINEAR tiling
features whatever the plane's image is. A dma-buf's plane is a DRM_FORMAT_MOD_LINEAR
modifier image, whose view's format features are its format's drmFormatModifierTilingFeatures
for that modifier (Vulkan 12.6.1), and on a device whose LINEAR tiling samples a format the
modifier lists no features for, the list named a format no view of the image may take
(VUID-VkImageViewCreateInfo-None-02273). Row 5's queries found that on NVIDIA 620.70.06 and
615.71.09 (RTX 3090 m3-max-81318, RTX 2080 81309, RTX 5080 Laptop 81308): R8_UINT and
R8G8_UINT sample in LINEAR and list no modifier.

This commit is a refactor with no change in behaviour: the filter moves into view_list,
over TilingFeatures (a format's LINEAR features and its MOD_LINEAR modifier's) that
Query::tilings reads, and still reads the LINEAR features for both tillings (the same
SAMPLED_IMAGE bit as the legacy word it read). The new verdicts test,
a_plane_s_view_list_takes_the_formats_its_own_tiling_samples, gives synthetic features where
R8_UINT and the rest of the 8-bit list sample in LINEAR and list no modifier, and expects a
dma-buf's list empty: red.
2026-12-02 19:11:30 -08:00
Anees Iqbal afa0046e9e rt test: a kernel writes an exported surface plane through a ShaderWrite R8Uint view
A guard, not red. For each row the device exports (the VA-API dma-buf row, the NVIDIA
opaque-handle row and the copy-form row), on the 1080p picture, a surface whose luma has
ShaderRead, ShaderWrite, RenderTarget and PixelFormatView usage; an R8Uint view of the luma
that fpv_rgbx_write_uint writes from a buffer of values; then the surface's buffer, copied
whole to a Shared buffer, holds each written texel at the luma's offset and pitch as the
export states them. In place, a device whose linear image takes no storage usage may answer
Gap::SurfaceUsage at the make, or Gap::TextureView of SurfacePixelFormat at the view, each
printed.

This is the consumer's form for the exported planes a guest writes (row 5): the plane's own
image, viewed, with no storage shape and no copy. The row 5 format queries
(5080 m3-max-81308, 2080 81309, Iris Xe 81310, 780M 81314, 3090 81318, RX 550 81322) found
storage offered on the plane's linear and DRM_FORMAT_MOD_LINEAR images on every card, and
the layout unchanged by it; surface.rs already adds storage where the query offers it.
2026-12-02 19:11:30 -08:00
Anees Iqbal 0d2d3ef99b rt: a state takes the loop's colour flag at its make where a function can read a texture
T1 (795edfb733) made every render pipeline without the attachment feedback loop's colour flag
and, at a state's first draw that reads its pass's attachment through a texture, made a flagged
one on the encoding thread. In a window-drag stream (windrag-780m-b4, to frame 500) that was 110
compiles at first use on each desktop card that the base (every pipeline flagged at its make)
did not have: 603.7 ms in all on the RX 7900 XTX with the driver's shader cache off
(m3-max-81076), 2.39 ms on the RTX 2080 (m3-max-80961). None of the 110 was a state whose
fragment function fetches its attachment ([[color(n)]]): T1 flagged those at their make. Each
was a draw handed its pass's attachment as a texture, which no state's make can know.

The ruled form decides the flag at the state's make from its functions' structure
(Draws::reads_textures): a state takes the flag on every pipeline where a function of any stage
can read a texture (a texture slot it reads, at any stage; a colour the fragment function
fetches; or a read beyond its slots, an argument buffer's texture or a resource ID, which the
structure cannot settle). A state whose functions read no texture never reads an attachment
other than as one, and takes no flag. No draw makes a pipeline for the loop: Raster's `loops`,
FirstUse::Loop and the content's per-raster flags go, and the content's later pipelines are
again at most 15.

Metrics::first_use_loop_waits, first_use_loop_wait_nanos and first_use_loop_wait_max_nanos go
with the site they counted (api_signatures.tsv), as do Raster's `loops` and FirstUse::Loop; the
replay's report drops their two keys. No consumer search was needed: T1 never reached a pushed
sha (origin is at 9186e2fe46, and T1 sits above it on development), so no consumer pin can hold
them.

Docs: the runtime README's attachment-read paragraph says which states take the flag; the first
use waits list drops the loop's; the known gap of render encoders for T1's first-use compile
gives way to one for the flag on the pipelines of every state that can read a texture, whether
or not a draw hands it an attachment, with what the flag costs a draw that reads none, and what
leaving it off saves, not measured on a tile-based phone GPU (no such device in the lab). The
floor table's VK_EXT_attachment_feedback_loop_layout row, Core::feedback_loop,
floor::Capabilities::feedback_loop and the render encoder's module doc say the same. No gain is
claimed for any device.

Verified at 00fe2f78be, this patch on development 795edfb733 (base = 59326c8dff, before T1),
then rebased onto d69a0bda18 with the same patch:
- Red/green: both tests of the red commit fail at it and pass here, on the RTX 2080 and on
  lavapipe (llvmpipe, LLVM 23.1.4) in m3-max-81257, on the Iris Xe (RPL-P) in m3-max-81291 and
  m3-max-81367, on the RX 7900 XTX (RADV NAVI31) in m3-max-81373 and on the RTX 3090 in
  m3-max-81365. At the red commit the fragment test reads ((1, 0), (1, 0)) against
  ((1, 0), (0, 1)), and the vertex test (1, 0) against (0, 1).
- The stream's states, counted with a build of this tree that printed each content and each
  render pipeline made (never committed; one play of windrag-780m-b4 to frame 500 on the 2080 in
  m3-max-81257): 275 render contents, 218 of which can read a texture, every one through a
  fragment texture slot, and 57 read none. 281 render pipelines: 220 with the flag, 61 without.
  The play's Metrics::pipelines_created, 407, counts compute and the runtime's own pipelines too;
  the 281 render pipelines are the ones the base flagged, and 61 of them lose the flag here.
- The A/B on the RTX 2080 (m3-max-81257): arms alternating a:cold, b:cold, a, b, a, b, cold with
  the driver's disk cache off (__GL_SHADER_DISK_CACHE=0), each with a fresh rt shader cache.
  Every play of both arms: pipelines_created 407, rendering interrupts 28857, barriers 136307,
  attachment loop reads 33533, 0 refused; first-use waits a 17, 18, 15 and b 17, 16, 17 (the other
  kinds; none for the loop, which the base never had and this tree no longer has). Median frame
  GPU time: a 1.7290 (cold), 1.7267, 1.7542 ms; b 1.7188 (cold), 1.2215, 1.7233 ms. Every play's
  clock samples mix P0, P5 and P8, and b's 1.2215 ms play is the one whose median moved alone; b's
  other two sit at or below a's range. No gain is claimed.
- Merged-tree check (m3-max-81184, at 00fe2f78be): signatures, clippy plain, --cfg m2v_gpu and
  --cfg m2v_cpu_icd, rustdoc, private intra-doc links, the translator's core (3420 passed, 37
  skipped), the runtime on lavapipe (947 passed, 4 skipped), validation (1319 passed, 3 skipped),
  validation on lavapipe (1441 passed, 3 skipped), and the conformance replay on lavapipe
  (exactly the ledger's gaps, 0 drift), each exit 0. Clippy plain, --cfg m2v_gpu and --cfg
  m2v_cpu_icd at the rebased tree (m3-max-81311), each exit 0.
- The A/B on the RX 7900 XTX (m3-max-81373, holding its node alone; cold with
  MESA_SHADER_CACHE_DISABLE=true): every play's counts equal (pipelines_created 407, barriers
  127909); the play's GPU time a 128.88 (cold), 129.16, 128.96 ms against b 129.12 (cold), 129.48,
  129.20 ms (+0.21%, same-arm spreads 0.22% and 0.28%); median frame a 341.2, 340.0, 339.7 us
  against b 339.8, 340.5, 339.9 us (-0.07%).
- The A/B on the Iris Xe (m3-max-81367, holding its node alone; a:cold, b:cold, then three pairs):
  every play's pipelines_created 407, barriers 135343, loop reads 33533; median frame a 518.9
  (cold), 524.8, 522.6, 525.2 us against b 507.8 (cold), 494.6, 522.0, 467.3 us, none of b's above
  a's highest; the play's GPU time a 287.5, 292.6, 272.1, 280.9 ms against b 281.5, 281.3, 273.7,
  277.4 ms, b's within a's range.
- The RTX 3090 (m3-max-81365): every play's pipelines_created 407 and other counts as the 2080's;
  its clock samples mix P0, P5 and P8 within every play, so its timing is not read.
- Runtime command buffers per play vary between plays of one arm, the base's included (6258 to
  6263 on the Iris Xe, 6320 and 6321 on the 3090): the play's own variance.
- Not measured on a tile-based phone GPU (no such device in the lab).
2026-12-02 19:07:57 -08:00
Anees Iqbal d781dbbe93 rt test: a state takes the loop's colour flag at its make where a function reads a texture (red)
T1 (795edfb733) made a state's pipelines without the attachment feedback loop's colour flag
and, at the first draw that reads an attachment through a texture, made a flagged one on the
encoding thread: 110 such compiles at first use in a window-drag stream on each desktop card,
603.7 ms in all on the RX 7900 XTX with the driver's cache off (m3-max-81076). The ruled form
decides the flag at the state's make, from the structure of its functions: a state whose
functions can read a texture (a slot one reads, a colour the fragment function fetches, or a
read beyond the slots) takes it on every pipeline from its make, as every state did before T1;
one whose functions read none never takes it. No draw makes a pipeline for the loop.

Two tests, red at this commit on a device with the loop:
- every_device_flags_a_pipeline_for_the_loop_at_its_make_where_its_fragment_reads_a_texture
  replaces T1's test: own_pixel_fragment's state makes its pipeline with the flag, and its
  reading passes make no pipeline and wait for none (Metrics::pipelines_created,
  Metrics::first_use_waits). T1 makes it without the flag, and its first reading draw makes a
  second pipeline.
- every_device_flags_a_pipeline_for_the_loop_at_its_make_where_its_vertex_reads_a_texture:
  icb_direct_arguments' texture_vertex with plain_fragment makes its pipeline with the flag. A
  draw that hands the vertex function its pass's attachment is refused on every device
  (Gap::Draw { AttachmentRead }), as before: only a fragment function reads an attachment of
  its pass through a texture. T1 never flags this state.
2026-12-02 19:07:57 -08:00
Anees Iqbal e1e6f52848 Conformance ledger: the shared-texture rows are not built yet, as a guest meets the call
The 31 rows of shared-creator-padded-format-storage, shared-creator-extended-range-samples,
texture-shared-handles and texture-view-descriptors that the rt side refuses with
Unavailable(shared_texture) gave "no stream uses it yet" (the 11-19 census) as their reason.
That is stale: on 12-02 a viewer's render process called newSharedTextureWithDescriptor:
about 2.5 s after its window opened, and its consumer answered nil. Their reason is now the
ledger's "refused: not built yet (fix-l155)", so every replay counts them as open work, and
the row says what is to be built: on rt's one device a shared texture is a Private texture
and the texture its handle opens a clone of the same Texture, the handle the consumer's.

Docs only: no row's case, venue, site or answer changes. CONFORMANCE-COVERAGE.md is
regenerated (coverage.py --check: as derived).
2026-12-02 18:34:56 -08:00
Anees Iqbal d69a0bda18 Runtime README: KosmicKrisp's indirect patch draws of more than one instance as a known gap
The Mac host leg of the runtime's device tests failed two patch tests with indirect true only:
every_device_reads_a_patch_draw_s_base_instance_after_tessellation and
every_device_reads_a_patch_s_position_as_its_primitive_id_under_a_patch_index_buffer (M3 Max
under KosmicKrisp, job m3-max-81082). Both draw 2 patches in 2 instances, and in both the second
instance's second patch is missing.

The cause is in the driver, not in the runtime. The runtime records an indirect patch draw as one
vkCmdDrawIndirect on Metal's argument buffer, the same on every device, with no compute pass in
front of it. KosmicKrisp (Mesa 26.3.1) emulates tessellation in compute. For an indirect draw,
libkk_tess_setup_indirect writes the vertex grid as {count, instances, 1} and the control grid as
{patches * output vertices, instances, 1}. kk_dispatch_compute then runs both through
dispatchThreadgroupsWithIndirectBuffer, so each word counts threadgroups (64 threads for the
vertex grid), where the direct draw passes the same words to dispatchThreads as thread counts.
Neither stage bounds the extra work, so it overwrites the next instance's vertices and control
points. This was read from the driver's source, not instrumented.

A bare Vulkan program (no runtime code) draws 2 patches of 3 control points in 1 and then 2
instances, direct and from the host-written VkDrawIndirectCommand, 8 rounds each. Under
KosmicKrisp the second instance's second patch was wrong in 3 of 8 indirect draws, and right in
all 8 direct draws and in every one-instance draw. Under MoltenVK on the same M3 Max, every draw
was right (job m3-max-81189). The tests' indirect arms pass on RADV on the RX 7900 XTX and the
Radeon 780M (m3-max-80750) and on lavapipe (m3-max-80990).

Docs only: one known-gap bullet under "Known gaps of render encoders". The README is not part of
any crate's Rustdoc, and its tests read only the floor tables.
2026-12-02 18:17:42 -08:00
Anees Iqbal 6b939ef793 Replay player: copyFromTexture:...sliceCount:levelCount: as the runtime's region copies
Metal's copy of whole surfaces between textures has no runtime call of its
own; the player refused it as not played on a blit encoder, which ended a
viewer stream's play on the XTX in its first seconds (job m3-max-81089). It
now plays as the runtime's copy_from_texture, once for each slice and level
of the counts, each the source level's whole extent from the origin to the
origin, as a bind of a range plays as single-slot binds. The runtime's own
checks refuse a level or slice past either texture. REPLAY-STREAM.md says so.
2026-12-02 18:17:42 -08:00
Anees Iqbal 375b66b5b2 Replay test: a copy of whole texture surfaces, which the player refuses, played through the runtime (red)
A device test of the replay player copies slices 0 and 1 at levels 0 and 1 of
a 2D array texture into slices 1 and 2 of another with
copyFromTexture:sourceSlice:sourceLevel:toTexture:destinationSlice:
destinationLevel:sliceCount:levelCount:, each source surface written from its
own bytes first, and checks the four copied surfaces read back as those bytes.

Red until the player plays the selector: it refuses it as not played on a
blit encoder, which stops a viewer stream's play on the XTX (job
m3-max-81089) long before its patch draws.
2026-12-02 18:17:42 -08:00
Anees Iqbal 8ac91a9b33 Docs: REPLAY-STREAM.md's render encoder paragraph rewrapped at 100 columns
The patch draws' sentence left two lines past the paragraph's width.
2026-12-02 18:17:41 -08:00
Anees Iqbal b6c6997cfa Replay player: drawPrimitives and drawIndexedPrimitives from an indirect buffer
The player refused both of Metal's indirect draws of primitives as not
played on a render encoder, so a stream whose program draws from an indirect
buffer lost each such draw. Each now plays as the runtime's call
(draw_primitives_indirect, draw_indexed_primitives_indirect), its arguments
and index buffer at their offsets. The patch draws' buffer helper becomes
draw_buffers, which both arms share: a draw naming a skipped index or
indirect buffer is a skipped draw, and one skipped by its state or a bound
object is counted as before; patch_draw keeps the patch draws' count of
draws through a state whose record lacks tessellation. REPLAY-STREAM.md says
the draws play direct or from an indirect buffer.
2026-12-02 18:17:41 -08:00
Anees Iqbal 3f8cdba2ee Replay test: draws from an indirect buffer, which the player refuses, played through the runtime (red)
Three device tests of the replay player draw the render fixture's triangle
from an indirect buffer into a pass cleared red:
drawPrimitives:indirectBuffer:indirectBufferOffset: with its arguments at byte
16, and drawIndexedPrimitives:...:indirectBuffer:indirectBufferOffset: of 16-bit
and of 32-bit indices, its arguments at byte 20 and its index buffer at an
offset of one index. Vertex 0 is a blue one at the target's centre and the
arguments start at vertex (or index) 1, so only a draw that reads its
arguments and indices at their offsets covers the target green, which the
stream checks.

Red until the player plays those selectors: it refuses each as not played on
a render encoder.
2026-12-02 18:17:41 -08:00
Anees Iqbal b141773499 rt: a render pipeline takes the loop's colour flag only where a draw reads its attachment
Every render pipeline was made with VK_PIPELINE_CREATE_COLOR_ATTACHMENT_FEEDBACK_LOOP_BIT_EXT on a
device with the attachment feedback loop (22ca6271eb). Vulkan asks for the flag only of a draw
that reads, other than as an attachment, an attachment in the feedback layout (vkspec
"Non-Overlapping Access Between Resources"). Tile-based GPUs are a target; the flag stays off
the pipelines of draws that read no attachment. Not measured on a tile-based phone GPU; no such
device in the lab.

Now:
- Raster gains `loops`: the draw reads an attachment of its pass through the loop. The content's
  main pipelines are made without the flag; the first draw that reads an attachment through a
  texture makes the content's pipeline under `loops` in the content's bounded map of later
  pipelines (at most 31 now, from 15), and later reading draws take it. One form on every device
  with the loop; a device without it keeps its counted copy into the shadow, unchanged.
- A content whose fragment function fetches a colour ([[color(n)]]) reads through the loop at
  every draw, so all its pipelines take the flag from creation, as before.
- An execution of an indirect command buffer takes the flagged pipeline wherever the device has
  the loop, as before, since its commands bind their own slots; execution_part asks the same
  pipeline, so the part and the draw's shape agree.
- A draw that may read beyond its slots while a read declaration covers an attachment the pass
  holds out of its home layout (Metrics::unslotted_attachment_reads) takes it too.
- The extra make is a first-use wait of its own: Metrics::first_use_loop_waits, with its
  nanoseconds and longest (three new public fields of the non-exhaustive Metrics, additive;
  api_signatures.tsv blessed). The replay's metrics report the count and the nanoseconds.

No dynamic-state form: the loop's dynamic state stays gone.

Docs: the runtime README's attachment-read paragraph, the first-use waits list, a known gap of
render encoders for the extra compile at a state's first reading draw (with where the form has not
run), the floor table's VK_EXT_attachment_feedback_loop_layout row, the AMDVLK measurement's
wording, Core::feedback_loop, floor::Capabilities::feedback_loop and the render encoder's module
doc.

Not run on an Intel card: the lab's Iris Xe node is down; that leg is owed.

Not run on the M3: KosmicKrisp ignores the pipeline flag. Read in Mesa 26.3.1's source: KK lists
VK_EXT_attachment_feedback_loop_layout and attachmentFeedbackLoopLayout
(kk_physical_device.c:171, :431); Mesa's common runtime turns the flag into vk_graphics_state's
feedback_loops, which no kk_* file reads; KK reads only the image's feedback usage
(kk_image_layout.c:111). A run there could show no change.

Verified (the tree of this commit, 87e8f0241a, on development 15898e612e):
- Red/green: every_device_flags_a_render_pipeline_for_the_loop_only_where_a_draw_reads_its_attachment
  fails before and passes after, at the pre-rebase shas 5e1e88e94b and d2e563c826, on lavapipe
  (m3-max-80585), the RX 7900 XTX (m3-max-80586) and the RTX 3090 (m3-max-80589); at this tree it
  passes on lavapipe in the merged-tree check.
- Merged-tree check (m3-max-80973, then m3-max-81099 for its last step): signatures, clippy plain,
  --cfg m2v_gpu and --cfg m2v_cpu_icd, rustdoc, private intra-doc links, the translator's core
  (3413 passed, 37 skipped), the runtime on lavapipe (945 passed, 4 skipped), validation (1319
  passed, 3 skipped), validation on lavapipe (1438 passed, 3 skipped), and the conformance replay
  on lavapipe (exactly the ledger's gaps, 0 drift), each exit 0.
- A window-drag replay stream recorded on a 780M (windrag-780m-b4) to frame 500 (501 frames),
  arm a = 15898e612e and arm b = this tree, alternating in one job per card, a fresh rt shader
  cache each play. On the RX 7900 XTX (m3-max-80880) and the RTX 2080 (m3-max-80926), every
  play: rendering interrupts 28857, passes 41477, barriers 127909 (XTX) and 136307 (2080),
  attachment loop reads 33533, 0 refused, equal in
  both arms; pipelines made 407 in a and 515 in b, first-use loop waits 0 and 110.
- GPU time, the driver's shader cache warm: XTX, the play's command buffers, a 128.86, 129.29,
  128.88 ms against b 129.02, 129.43, 129.27 ms (+0.18%, spread 0.33%); 2080, the median frame
  over four plays each (its play totals follow the card's clock state), a 1.7255 ms against b
  1.7320 ms (+0.38%, spreads 0.71% and 1.01%).
- The 110 loop compiles with the driver's disk cache off for the play (a measurement setting of
  the job), alternated with warm plays in one job: XTX (MESA_SHADER_CACHE_DISABLE=true,
  m3-max-81076, on a node running other jobs' CPU work then) 603.7 ms in all on the encoding
  thread, against a play GPU time of 129.35 ms and 32.5 s of wall; 2.24 ms warm. 2080
  (__GL_SHADER_DISK_CACHE=0, m3-max-80947) 2.39 ms cold and 1.88 ms warm; its cold plays' first-use
  waits were no longer than its warm plays', so that setting's effect is not shown.
- Not run on an Intel card; not on the M3 (above); not measured on a tile-based phone GPU.
2026-12-02 18:17:41 -08:00
Anees Iqbal fcbb221b5f rt test: a render pipeline takes the loop's colour flag only where a draw reads its attachment (red)
Every render pipeline is made with VK_PIPELINE_CREATE_COLOR_ATTACHMENT_FEEDBACK_LOOP_BIT_EXT on a
device with the attachment feedback loop, whether or not a draw reads an attachment through it.
Vulkan asks for the flag only where a draw reads, as a non-attachment, an attachment that is in
the feedback layout (vkspec 8.10.2).

The test replaces the one that held every pipeline to the flag:
- an ordinary pass draws a state whose fragment function reads no texture and one whose function
  reads a texture no attachment renders; each state's pipelines carry no flag;
- two passes draw blue, then, after a memory barrier, each pixel read plus green; the reading draw
  makes its state's flagged pipeline once, at the first pass, and every pixel reads blue plus
  green each time, each reading draw one attachment_loop_reads;
- a device without the loop makes every pipeline with no flag and reads through a copy.

RenderCompiled::made_flags, for the device tests, lists the create flags of each pipeline a
content made.

Red here on a device with the loop: the ordinary pass's pipelines carry the flag.
2026-12-02 18:17:41 -08:00
Anees Iqbal 9186e2fe46 Validation test: the oracle-fuel fixture round trip skips what the toolchain is too old for and puts its status at the oracle's slot
oracle_fuel::tests::public_fixtures_with_loops_round_trip_instrumented failed on macOS CI (run
47003321413, macos-26, MetalToolchain 17.6), the first macOS run to reach it, in three ways:

- Ten .metal fixtures that name metal4.1, newer than that toolchain's metal4.0: "invalid value
  'metal4.1' in '-std=metal4.1'".
- tns_mm_fp8, tns_mm_left and tns_mm_v2 .air.ll: metal-opt "unrecognized architecture
  'air64_v29' provided." for the fixtures' own target triple.
- parked_heap_handles (.metal and .air.ll, four entries each): "buffer argument m2v_oracle_status
  has invalid location (<29,1>)". The fixture binds buffers 28 and 29, and the test put every
  status buffer at a fixed slot 29. The oracle itself puts it at the highest slot the entry's
  interface leaves free (NativeBufferSlots::from_interface(..).allocate(), via producer_slots);
  that is slot 30 here. This one is a test defect on any SDK.

The air writer's round trips already skip, list and count an input above the toolchain's AIR
version or Metal standard (Tally::refused). That rule moves into
air_writer::tests::above_the_toolchain and gains a third case, arch_ceiling: metal-opt's
refusal of an `air64_v<N>` architecture that the input's own target triple names. Each is the
toolchain's own refusal of something the input states; any other error stays a failure.

The oracle-fuel round trip now applies above_the_toolchain to a failure of a step on the fixture's
own AIR (compiling or assembling it, and finding the strictest level metal-opt passes). It prints
each skip and their count, "SKIP N of M inputs above the toolchain's newest version", as the air
writer's round trips do. A failure of the instrumented module's own round trip is never skipped.
Each entry is instrumented with its status buffer at the slot the oracle gives it, from the
entry's interface (status_slot).

Verified: red job m3-max-81148 (msi CPU) failed
an_input_of_an_architecture_the_toolchain_does_not_know_is_skipped_and_counted, and
every_other_toolchain_error_fails passed, at bec8a8dea1. The green and the macOS runs are named
in the hand-over.
2026-12-02 18:09:53 -08:00
Anees Iqbal 4bd7516305 Validation test: the L3 stand-in finds its parent with pgrep -a on macOS
translation_l3_stage::spirv_val_runs_in_the_l3_stage_that_replaced_the_translation failed on
macOS CI (run 47003321413, macos-26), the first macOS run to reach it: 'spirv-val ran under
"96367: not the L3 stage", not the worker's L3 stage'. The worker is right; the test's stand-in
is wrong. The stand-in spirv-val asks pgrep for the processes whose arguments hold
"--l3-stage engine" and looks for its parent there. macOS's pgrep leaves out its own ancestors
unless given -a (pgrep(1): "By default, the current pgrep or pkill process and all of its
ancestors are excluded"), and the L3 stage is pgrep's grandparent, so it never matched. procps's
pgrep on Linux excludes only itself, which is why the Linux job passes.

The stand-in now passes -a on Darwin alone: procps reads -a as --list-full, which would print each
command line beside its pid and break the exact pid match.

Verified: a local probe of the same script under `bash -c "sh standin.sh; :" --l3-stage engine`
on macOS 27 printed "not found" with plain pgrep and "found" with the fixed line. The test itself
runs on the next macOS CI run; it is not run on the M3 (no tests there).
2026-12-02 18:09:53 -08:00
Anees Iqbal e85535dbfa Validation test: an input whose architecture the toolchain does not know is skipped and counted (red)
macOS CI (run 47003321413, macos-26, MetalToolchain 17.6) failed
oracle_fuel::tests::public_fixtures_with_loops_round_trip_instrumented on tns_mm_fp8, tns_mm_left
and tns_mm_v2 .air.ll: that toolchain's metal-opt answers "unrecognized architecture 'air64_v29'
provided." for the fixtures' own target triple, which is newer than it knows. The air writer's
Tally already skips, lists and counts an input above the toolchain's AIR version or Metal
standard; it has no rule for this third refusal, so the fixture counts as a failure.

The new test hands Tally::refused that refusal for tns_mm_v2.air.ll and expects a skip. Two more
cases join every_other_toolchain_error_fails: an architecture the input's triple does not name,
and one refused for an input with no triple, both still failures.

Red: string-only, so it runs on Linux; expected to fail until the classifier lands (next
commits).
2026-12-02 18:09:53 -08:00
Anees Iqbal dddd91b993 Tables: golden hashes at semantics 2325
The bless for mad (2324) and the half form on devices lacking only 16-bit
DenormPreserve (2325). 1413 cells move, 471 in each of lavapipe,
gate-lavapipe and gate-lavapipe-x86_64, over 320 fixtures; no other profile's
cell moves, as T3's comparison predicted (the 3090 column is still owed). No
row is added or removed; mad's fixtures are not in the public set.

Blessed on the M3 (job m3-max-81107): inventory, golden hashes and printouts
exit 0; the metallib half of committed_air_fixtures_parse_and_link exit 0.
2026-12-02 17:58:54 -08:00
Anees Iqbal 59326c8dff Translator: half computes in 16 bits where only 16-bit DenormPreserve is missing, noting half denormals
The planner's ruling (T3). On a device with shaderFloat16, 16-bit RoundingModeRTE and 16-bit
SignedZeroInfNanPreserve whose only missing 16-bit control is DenormPreserve, the half operations
narrow::half_controls gates take the 16-bit route: a half + - * / sqrt and fused multiply-add on
the device's 16-bit instructions, half values held at 16 bits, the controlled pair for a float
rounded to half, and a half widened from and narrowed to its bits by the device's conversion.
It is the 16-bit floats query's existing form, read from one more of its properties.

narrow::controlled_modes declares RoundingModeRTE and SignedZeroInfNanPreserve for 16 bits there
and no denormal mode: not DenormPreserve for 16 bits (VUID 06296), nor the 64-bit one the
independence for 32 bits only ties to it (VUID 06289 asks for the same denormal mode at 16 and
64 bits). The independence rules decide which devices take it as before, and a device missing any
other 16-bit control keeps half in float.

MoltenVK on the M3 stays off the route: its denormal modes are not independent at all
(denormBehaviorIndependence NONE), where the form would tie float's denormal mode to half's and
change how the module's float arithmetic reads denormals, which Metal flushes; and its rounding
modes are not independent while it offers no 64-bit RoundingModeRTE, so the 16-bit
RoundingModeRTE the form declares cannot be declared at every width as VUID 06292 asks.

Every module that declares those controls on such a device (narrow::flushes_half_denormals)
records the new static note PrecisionNote::DeviceHalfDenormals, "half denormals may flush to
zero where Metal preserves them": the Vulkan spec leaves a 16-bit denormal to the device in an
entry declaring no 16-bit denormal mode. No other module records it. The conformance suite holds
its code, metal2vulkan-degrade-device-half-denormals, among the native notes beside
device-denormals (the device's own denormals, the one form built there); validation allows it
unbounded, as it does NativeHalfConversion.

Run on lavapipe, whose committed profile has this shape: its half arithmetic moves from float to
16 bits. Turnip on an Adreno GPU before the 8xx series reports the same controls (Mesa 26.3.1,
tu_device.cc lines 534, 1038-1048: shaderFloat16, RTE and SignedZeroInfNanPreserve for 16 bits,
DenormPreserve for 16 bits false below A8XX, independence ALL): not measured on a tile-based
phone GPU; no such device in the lab. No performance claim is made.

Tests: engine_native_half's new test (the red commit before this) now also asks for the note on
each such module and for none under all three controls or without another one. The tests that
held lavapipe as the conversion form now hold it under the controls (engine_native_half's
rounding kinds, memory and decode widenings and controlled modes; engine_half_hold's held values
and division; engine_arith's 16-bit fma profiles), and the conversion form on lavapipe's
description without 16-bit RoundingModeRTE.

SEMANTICS_VERSION 2325 (development holds 2323; 2324 is mad's), and ARTIFACT_FORMAT_VERSION
601 -> 602 (the new note's codec member). Golden rows are blessed at the pin.

Docs: the precision-note catalogue (docs/API.md, the new entry and the conversion entry's
controls), docs/HOWTO.md, the runtime README's shaderFloat16 row and its half fma line, the
NativeHalfConversion note's device list, api_signatures.

The conformance ledger. The form moves lavapipe, whose float controls lack only 16-bit
DenormPreserve, onto the 16-bit route. The conformance replay in the pinned lavapipe image (Mesa
26.2.4, LLVM 23.1.1) then answers 79 of the runtime ledger's llvmpipe rows otherwise:

- 47 now match Metal and are dropped: vertex-format-half4 28 and integer-vertex-attributes 16
  (the rows said lavapipe folds the unrounded OpFConvert pair, with no 16-bit DenormPreserve to
  make it Metal's; the pair now rounds under the 16-bit controls), and half-texel-nans-rg11b10f's
  3 (nearest-sample, read, widened).
- 32 now answer otherwise and are replaced, each with the answer and a reason written from this
  run's printout (first differing element):
  - vertex-format-half4, 8 rows (Float..Float4, Half..Half4): only the NaN differs now, Metal
    0x7fc00000, the device 0xffc00000; one element per component, where the rows recorded the
    unrounded values (Float, the largest difference inf) or the kept payload (Half).
  - half-texel-nans, 18 rows (nearest-sample, read and widened of r16f, rg16f, rgba16f, r32f,
    rg32f, rgba32f): a 16-bit float texel's NaN now narrows to 0x7e00 (the payload dropped, as
    read-through-sample already answered; Metal hands back the texel's code); a 32-bit one to
    0xfe00 (Metal 0x7e00); the widening answers 0xffc00000 (Metal 0x7fc00000). Six rows count more
    elements than before (the 16f nearest-sample and read rows: 215 -> 472, 428 -> 940,
    852 -> 1874), twelve fewer.
  - bicubic-texel-classes, 6 rows: fewer elements at every site, each count and largest
    difference the one the 780M and RTX 5080 rows record; within the bicubic note's bound.
  None of the 79 is a half denormal.

docs/CONFORMANCE-COVERAGE.md regenerated (scripts/conformance-coverage/coverage.py): ledger rows
7932 -> 7885. The image is the pinned one, so the ledger's llvmpipe line does not move.

Not replayed, a follow-up: the six bicubic-texel-classes rows of venue "llvmpipe (LLVM 23.1.4,
256 bits)", a lavapipe outside the pinned image; this commit leaves them as they were.

Verified: the replay of this tree without the ledger edit, job m3-max-80972 (pinned lavapipe
image): exit 1 with row differs 32, now answers otherwise 32, now matches 47; the rows are written
from its printout. The same counts in job m3-max-80871 (the pre-rebase fix, against its base,
which exits 0). coverage.py --check: as derived.

No lab card's translation moves. The golden blesses at development (15898e612e) and at this
change, over the committed profiles plus the RX 7900 XTX's vulkaninfo --json capture (job
m3-max-80916), compared cell for cell, job m3-max-81006 (macOS, every fixture, 3624 rows): every
column but lavapipe, gate-lavapipe and gate-lavapipe-x86_64 (471 cells each) is equal, among them
the XTX capture, amd-780m-radv, amd-780m-hawkpoint-radv, intel-irisxe-rplp-anv,
intel-irisxe-anv and moltenvk-m3; no profile fingerprint moves (job m3-max-80958, the
same over the 1910 rows a Linux host assembles, agrees). Not run on an RTX 3090: its column is
owed until the card is back.

Gate at this tree, job m3-max-80990: clippy -D warnings plain, under m2v_cpu_icd and under m2v_gpu
0; rustdoc -D warnings 0, and with private items for metal2vulkan 0; the runtime's suite on
lavapipe 945 passed, 4 skipped (whole suite); translator and AIR 3415 passed, 37 skipped (the
golden hash table, the fixture inventory and the engine printouts excluded: their bless is due at
the pin); validation 1319 passed, 3 skipped; conformance 1048 passed. CI's lavapipe steps in the
pinned image, job m3-max-81012: device tests 841 passed (843 listed), the conformance replay exit 0
(the 4640 gaps the ledger expects, exactly), public case qualification exit 0.
2026-12-02 17:49:23 -08:00
Anees Iqbal 306f8b00eb Translator test: half computes in 16 bits under RTE and SignedZeroInfNanPreserve where only 16-bit DenormPreserve is missing (red)
The planner's ruling (T3): on a device with shaderFloat16, 16-bit RoundingModeRTE and 16-bit
SignedZeroInfNanPreserve whose only missing 16-bit control is DenormPreserve, the half
operations narrow::half_controls gates take the 16-bit route, and any other missing control
keeps today's 32-bit form, under today's independence rules.

engine_native_half's new test asks, on the committed lavapipe profile and on the RTX 5080
Laptop GPU's and the Radeon 780M's descriptions without shaderDenormPreserveFloat16, for the
16-bit instructions the full controls give (a sum, a product and a chain of two on 16-bit
floats, the controlled pair for a half narrowed alone), an entry declaring RoundingModeRTE and
SignedZeroInfNanPreserve for 16 bits and no DenormPreserve at any width (the 780M's
independence for 32 bits only would tie a 64-bit one to a 16-bit one, VUID 06289), no
DenormPreserve property required, L3, and each operation rounded on the interpreter. And it
asks that the RTX 5080 Laptop GPU without 16-bit SignedZeroInfNanPreserve too, MoltenVK on the
M3 (denormal and rounding modes not independent), and the 780M without 64-bit DenormPreserve
stay in float.

Red: half_controls asks for 16-bit DenormPreserve, so lavapipe computes half in float.
2026-12-02 17:49:16 -08:00
Anees Iqbal 4fa543f9e6 rt test: a half mad answers the fused 2^-12 only where the module records NativeHalfConversion
opencl_mode_mad_rounds_its_product_and_its_sum failed on lavapipe (llvmpipe, LLVM 23.1.1):
the half mad(a, a, c) at a = 1 + 2^-6, c = -(1 + 2^-5) answered 0x0c00, the fused 2^-12,
where the M3 Max answers 0. The float and float4 rows answered 0 there too, as on every
device.

lavapipe has no 16-bit denormal-preserve control, so the module computes the half product
in float and rounds it through the conversion pair, records NativeHalfConversion, and
lavapipe's compiler folds the pair: the product stays exact and the sum is the fused
answer. That is the note's documented bound (docs/API.md), so the test now accepts 0x0c00
only where the module records NativeHalfConversion, as the vstore_half test beside it
does; every other row, and the half row on a module without the note, stays exact. The
test prints the half it read and the notes, so a run shows which case it took.

When the 16-bit route for lavapipe lands, the half mad there is the device's 16-bit
multiply and add, the module records no NativeHalfConversion, and this test is exact on
lavapipe too.

Verified: m3-max-80986 (msi, 8dbd521441) failed the test on lavapipe; m3-max-81037 read its
assertion, half 0x0c00 with the float rows 0. The run of this commit on lavapipe is the
hand-over's job.
2026-12-02 17:49:12 -08:00
Anees Iqbal 90950389a8 canon: routine_len takes a routine's operands with get, not a slice index
clippy's indexing_slicing lint refused `&any[..r.kind.arity()]` in routine_len, in all three
configurations (job m3-max-80905, STEP clippy_plain, clippy_gpu and clippy_cpu EXIT=101: "slicing
may panic"). The operands are now `any.get(..arity)`; an arity past three is an invariant error,
which no kind has.

Verified: cargo fmt only on this host; the check job reruns clippy.
2026-12-02 17:49:12 -08:00
Anees Iqbal 9f42b4c1f3 Translator: OpenCL C's mad is its multiply and its addition, each rounded on its own
Apple's OpenCL compiler spells OpenCL C's mad(a, b, c) as air.mad.<T>. No
family decoded it, so a kernel that calls it (a real OpenCL workload's
image-scaling kernel, air.mad.f32 in AIR 2.8) was refused as
UnknownIntrinsic. OpenCL C leaves how mad rounds its product to the
implementation. The M3 Max's GPU rounds the product and then the sum.

- Decode: MathFn::Mad, which Math::parse reads from air.mad.<T> for the
  three types the compiler was measured to spell (MAD_TYPES: f32, v4f32,
  f16), each T (T, T, T), always Precision::Precise. Every other type
  (v2f32, v3f32, v8f32, v4f16, bf16, i32) and spelling (fast_mad,
  native_mad, a sign token) stays undecoded, as the planner ruled. mad is
  not a TABLE stem, so Math::float_stems (Metal's own functions) is
  unchanged.
- Lowering, the planner's option (2): canon::routine, which already
  rewrites the frexp and ilogb routine calls into plain AIR after SCCP,
  now replaces each mad call with an fmul of a and b followed by an fadd
  of that product and c. Both carry no fast-math flags, whatever the
  call's own flags are. Lowering then gives them exactly what an
  unflagged fmul and fadd get: NoContraction on each, the profile's half
  form, and no new note. air_math's invariant arm (Frexp, Ilogb) now
  takes Mad too.
- Which form is smaller: the canonicalization. The families rows need a
  DeclClass::Air, so MathFn::Mad cannot be avoided, but the rewrite
  reuses the routine pass's expander, about 40 lines. A lowering of its
  own would need a new FloatFn and its half forms.

Evidence, with its caveat as it is:
- Spellings come from Metal's OpenCL mode (newLibraryWithSource with
  sourceLanguage 1, macOS 27.0.1, AIR 2.9), over our own kernels on the
  M3 (job m3-max-80752).
- Answers come through the OpenCL framework on the M3 Max's GPU (job
  m3-max-80759), not through a Metal pipeline of OpenCL mode:
  - float, at a = b = 1 + 2^-12 and c = -(1 + 2^-11): mad answers 0,
    fma 2^-24, and a*b+c 2^-24;
  - float4: each lane of mad answers 0;
  - half, at a = b = 1 + 2^-6 and c = -(1 + 2^-5): mad answers 0 and
    fma 2^-12.

Tests:
- families_tests OBSERVED rows (previous commit, red).
- intrinsics::tests::opencl_mad_decodes_in_its_measured_types_alone.
- engine_arith::opencl_mad_is_its_multiply_and_its_addition, over our
  own .ll on the three profiles:
  - each mad kernel's linked SPIR-V has the same opcodes as its twin
    written as an unflagged fmul and fadd, with the same notes;
  - the float and float4 kernels have OpFMul and OpFAdd, each
    NoContraction, and no Fma;
  - the interpreter answers 0 on the probe's inputs.
- runtime opencl_data::opencl_mode_mad_rounds_its_product_and_its_sum, a
  kernel of OpenCL mode: +0 on the float, on each float4 lane and on the
  half, under a device cfg.

Public surface: MathFn gains Mad (api_signatures.tsv blessed), so an
exhaustive match over MathFn in a consumer breaks. docs/REFUSALS.md was
regenerated and is unchanged. docs/API.md lists mad beside the OpenCL C
native_ and half_ functions.

SEMANTICS_VERSION 2323 -> 2324: a module that calls air.mad translated to
a refusal before and translates now. The authoring classification follows
on its own, since its key fingerprints the product's sources
(ANALYZER_ABI), so no census version needs a bump.
2026-12-02 17:49:11 -08:00
Anees Iqbal 3507ce2694 Intrinsics: observed rows for OpenCL C's mad (red)
Apple's OpenCL compiler, through Metal's OpenCL mode (newLibraryWithSource
with sourceLanguage 1, macOS 27.0.1, AIR 2.9), spells OpenCL C's mad(a, b,
c) of float, float4 and half as air.mad.f32, air.mad.v4f32 and
air.mad.f16, each T (T, T, T). No family decodes them, so a kernel that
calls one is refused as UnknownIntrinsic (air.mad.f32).

The three declarations go into OBSERVED, which observed_declarations_decode
requires to decode. Red until the next commit decodes them.

Spellings from our own OpenCL C kernels on the M3 (potluck job
m3-max-80752), carved from each entry's bitcode and disassembled with
metal-opt. The probe produced no other vector width, so no other is added.
2026-12-02 17:49:11 -08:00
Anees Iqbal 8798938407 Tests: the indexed-patch factors test builds devices of the identity domains
The link test of IndexedPatchFactors read the identity domains off the
committed profiles, whose policy is the resident tables', so it tried none
and failed only on its own count (job m3-max-80982 on the msi CPU:
'a committed profile takes the identity domains'). It now builds each
committed profile with bufferDeviceAddress and shaderInt64 under the
identity domains' policy, as the engine test of the address form does,
and asserts the policy took. The engine test's doc names the cause.
2026-12-02 17:39:09 -08:00
Anees Iqbal 0c12c606fa Translator: the address form's indexed patches name their cause
The last cause-less Feature::Tessellation refusal of the translator, the
address form's in pipeline/link/tessellation control_plan
("addressed && !fits"), now names TessellationCause::IndexedPatchFactors:
a control-point index type beside a per-instance factor step or a factor
scale where pointers are device addresses used directly, where the
control-point indices' address takes the control stage's push words that
hold the factors' instance stride and scale (control::address_fits).
Every Feature::Tessellation NotImplemented refusal now carries a cause:
the translator's through Unsupported::tessellation, the AIR front end's
through its conversion.

Tests: the link test of the commit before this one (each such pair on
every committed profile of the identity domains); the engine test of the
address form's stepped and scaled descriptors asserts the cause too.
api_signatures blessed (the variant), REFUSALS.md regenerated (the
control_plan site moves under error/mod.rs's Unsupported::tessellation).
runtime-sources.sha256 unchanged: neither file is a runtime input.
2026-12-02 17:39:09 -08:00
Anees Iqbal 56a86dcc14 Tests: indexed patches beside instanced or scaled factors name their cause (red)
TessellationCause gains IndexedPatchFactors: a control-point index type
beside a per-instance factor step or a factor scale where pointers are
device addresses used directly. The link test asserts it for each such
pair on every committed profile of the identity domains, and that each
pair without the index type is planned. The address form's refusal
(pipeline/link/tessellation control_plan) still names no cause, so the
test fails.
2026-12-02 17:39:08 -08:00
Anees Iqbal 530fb4ea4c Validation: the runtime route refuses no patch draw through index buffers, which no case makes
The engine candidate's runtime route required a patch draw to name no patch
or control-point index buffer, and refused one that did as
executor_not_implemented. No case reaches that refusal: the case mapping
(graphics::patch_draw) names neither buffer for every patch draw, the case
schema has no field for them, and the AIR states nothing about a draw's
index buffers. The conformance suite's tessellation-patch-indices case
compares drawIndexedPatches and patch index buffers against Metal.

The route now takes every patch draw, its refusal message and
VALIDATION.md's sentence drop the clause, and the routing test drops its
patch draw through a patch index buffer. The runtime platform's draw keeps
its own check of the translator's DrawCall fields, which fails a draw that
names an index buffer visibly.
2026-12-02 17:26:54 -08:00
Anees Iqbal 7dff42d6a5 command-replay: SIGTERM stops the play at its next frame end
A watchdog's SIGTERM killed a play inside a frame; on a 3090, plays killed mid-frame were
followed by a wedged card (11-23), which is why a play on an NVIDIA card ends at an
--until-frame. The player now takes a stop flag (Player::stopping_on): once it is set, the
play stops after the frame then playing ends, as at --until-frame, and command-replay tears
the device down as at any end. The SIGTERM handler writes its progress line and sets the
flag instead of re-raising; after the stop the play writes `progress stopped after SIGTERM:
frame N of M ended last at T s`, no judged metric, the report verdict `stopped SIGTERM after
frame N, short of its range` and exit status 1. A frame that never ends (a call that never
returns) is left to the caller's kill (timeout -k).

Not yet built: a lavapipe job plays one stream under a forced 150 s watchdog with the player
before this commit (red: killed inside a frame) and with it (green: ends at a frame).
2026-12-02 17:21:11 -08:00
Anees Iqbal af4dc848bd command-replay: progress lines every tenth frame and at the last, and a line on SIGTERM
A play killed by a caller's watchdog left no line saying how far it got: the 5080 stream
arm of job m3-max-80863 ended at its 840 s watchdog with the frame unknown. play now writes
`progress frame N of M ended at T s` to the standard error at the end of every tenth frame
and of the last frame it plays to, counted at the one flush the player makes as each frame
ends (Player::with_frame_lines), and on SIGTERM (Unix) `progress SIGTERM at T s: frame N of M
ended last` (or `no frame ended`), formatted without allocating, before SIGTERM ends the
process as it would have. Test-side only: the validation crate's binary.

Not yet built: the players' rebuild job and the 3090 rehearsal with a forced watchdog check it.
2026-12-02 17:21:11 -08:00
Anees Iqbal 778e7c3acc Replay player: the patch draw helper's buffers as one named type
Clippy's type_complexity refused the helper's return type in every
configuration (job m3-max-80857). AtOffset names a buffer a draw names, at its
offset, or none.
2026-12-02 17:12:14 -08:00
Anees Iqbal ac99c98778 Replay player: drawPatches from an indirect buffer, and drawIndexedPatches direct and indirect
The player refused three of Metal's four patch draws as not played on a
render encoder, so a stream whose program draws patches through an indirect
buffer or a control-point index buffer lost those draws. Each now plays as
the runtime's call (draw_patches_indirect, draw_indexed_patches,
draw_indexed_patches_indirect), beside drawPatches, through one helper the
four share: a nil patch index buffer is none, a draw naming a skipped buffer
(patch index, control-point index or indirect) is a skipped draw, a draw
skipped by its state or a bound object is counted as before, and a draw
through a state whose record lacks the tessellation key is counted.
REPLAY-STREAM.md names the patch draws among what render encoders play.
2026-12-02 17:12:14 -08:00
Anees Iqbal e50911e861 Replay test: the three patch draws the player refuses, played through the runtime (red)
Three device tests of the replay player: a stream of the owned fixture
tess_indexed_patches draws twice into one pass, once with a nil patch index
buffer and once through one at offset 4, by
drawPatches:...indirectBuffer:indirectBufferOffset: (no control-point index
type), drawIndexedPatches:patchStart:...:baseInstance: (UInt16) and
drawIndexedPatches:...indirectBuffer:indirectBufferOffset: (UInt32). Each
checks both output buffers against the values Metal writes (the runtime's
patch test holds the M3 Max's runs) and asserts nothing skipped.

Red until the player plays those selectors: it refuses each as not played on
a render encoder.
2026-12-02 17:12:13 -08:00
Anees Iqbal 64ea7aaedc Docs: the DontCare store gap names its form and when it is built
The runtime README's DontCare store gap now says an Unknown store action
stores too, and states the form on file: each rendering recorded into a
secondary command buffer of its own, its begin recorded as it ends, when
its store operations are known, which would also take the late store
action RenderPassKind::LateStore refuses. It is not built while no
tile-based phone GPU is in the lab, no measurement on one shows the
write-back as a cost, and no guest program is known to meet that refusal.
The pass counts are those of the store census, jobs m3-max-80663,
m3-max-80681 and m3-max-80720 (the README quotes the last). The paragraph
is rewrapped at 100 columns.

Docs only.
2026-12-02 16:52:24 -08:00
Anees Iqbal ce337e89a7 Docs: the overlap refusal's basis cites the Mac readings; a DontCare store is a known gap
Refusal::BufferCopyOverlap's Basis line kept "ours" with no reading of
Metal behind it. It now cites the two: on an Apple M3 Max, macOS 27.0.1,
arm64 and x86_64 under Rosetta (job m3-max-80419), and on a Radeon Pro
5300M, macOS 26.7.1 (job m3-max-80501), every overlapping copy equals
memmove's, forward and backward, Shared and Private, 64 bytes to 16 MiB,
five runs each; on that Mac's UHD Graphics 630 a forward overlap of 64 KiB
and up differs from memmove's in each of five runs, at the same first byte
and the same count of bytes. Metal's validation layer was on in both and
stopped none. The kind stays "ours": the readings show plain Metal takes
the copy, which the refusal-surface script calls metal-takes, and the
runtime's RefusalBasis has no variant for it, so naming it is a public type
change, not this docs commit. REFUSALS.md regenerated.

The runtime README's render encoder gaps gain the DontCare store: it
stores, because Vulkan fixes a rendering's store operation as it begins
and a pass may become several renderings for commands met after it
begins, so a tile-based GPU writes back attachments Metal lets a program
discard; not measured on a tile-based phone GPU, no such device in the
lab. The counts are from the store census over two replay streams (jobs
m3-max-80663, m3-max-80681 and m3-max-80720, the last the one the README
quotes, after the census also followed descriptors made by
renderPassDescriptor): 6,401 of 80,906 passes over 1,115 frames (5.74 a
frame, 7.9%) and 4,886 of 73,212 over 1,036 frames (4.72 a frame, 6.7%),
each such pass storing one colour attachment and not caring about a second
or its stencil attachment.

Docs only: a doc comment, the generated REFUSALS.md and the README.
refusal_surface.py --check passes.
2026-12-02 16:52:24 -08:00
Anees Iqbal dec74d9cf7 Translator: a tessellation refusal names the structure it met
Feature::Tessellation with Needs::NotImplemented covered fourteen refusal
sites behind one name, so a walk's log line ("the translator refused the
feature Tessellation, needing NotImplemented", cause None) could not say
which without the AIR. A tessellation refusal now carries
Cause::Tessellation(TessellationCause), one variant per structure the
sites refuse, the way an access refusal names its AccessCause; sites that
refuse the same structure share a variant, none is named by a file, a line
or a string of its own:

- PatchStep: a layout stepping per patch or per patch control point read
  by a vertex function that is not post-tessellation (metal/vertex.rs
  fetch_as, fixed-function input; lower/stage_io/fetch.rs, the pulled
  fetch).
- PatchInterface: a patch input or a patch builtin in a function that is
  not post-tessellation (lower/stage_io/plan.rs, two arms).
- UncountedPatch: [[patch(kind)]] with no count, or a count of 0 whose
  control points are read (lower/tessellation plan_entry and select).
- InstanceStepRate, AttributeStep: a patch attribute per instance at a
  rate above 1; a step the attribute's input has no element for.
- Builtin, VertexInput, SimdGroup: another builtin, a vertex input, or
  SIMD-group semantics in a post-tessellation vertex function.
- ControlPointInput: the AIR front end's Tessellation, which is that one
  structure (its two arms in canon post_check); the conversion from the
  front end's refusal names it, so the front end's types are unchanged.

lower/tessellation's not_implemented() helper takes the cause, so the
compiler makes each of its sites name one; thirteen of the fourteen arms
name a cause. The fourteenth, the control-point index type
on the address form (pipeline/link/tessellation control_plan) is left as
it is: the drawIndexedPatches change removes that arm.

Feature stays Tessellation, so validation's outcome key (feature_key, the
Debug of the feature) and the census are unchanged; nothing stores the
cause (as for the access cause). No version bump.

Tests: the error module's Display test of a tessellation refusal and of
the front end's conversion; the cause asserted at the fixed-function and
pulled patch-step refusals (metal/vertex.rs, engine_vertex_fetch), the
uncounted patch (reflection), post-tessellation SIMD-group functions, and
a new test of a control-point layout stepping per patch, a patch layout
stepping per vertex (AttributeStep) and per instance at 2
(InstanceStepRate). The commit before this one adds those tests against
the cause-less sites.

runtime-sources.sha256 rewritten: metal/vertex.rs's refusal names its
cause, and no run behaves otherwise. api_signatures blessed
(TessellationCause, Cause::Tessellation), api_surface lists the enum,
REFUSALS.md regenerated (the sites are built through error/mod.rs's
Unsupported::tessellation), docs/API.md's error table names the cause.

Consumer uses (consumer-uses.sh, read-only, over the consumer's
development 33784022f1 and its lane tips of the last day):
Feature::Tessellation and TessellationCause, 0 hits.
2026-12-02 16:51:29 -08:00
Anees Iqbal c932d15639 Tests: a tessellation refusal names the structure it met (red)
The error module gains Cause::Tessellation(TessellationCause), one variant
per structure a Feature::Tessellation NotImplemented refusal meets, and
Unsupported::tessellation; the front end's Tessellation refusal maps to
ControlPointInput. The tests assert the cause at the sites: the patch-step
fetch (metal/vertex.rs, engine_vertex_fetch), the uncounted patch
(reflection), SIMD-group functions after tessellation, and a new test of
an attribute step a patch input has no element for and a patch instance
rate above 1. The sites still build cause-less refusals, so these fail.
2026-12-02 16:51:29 -08:00
Anees Iqbal 15898e612e Tables: golden hashes at semantics 2323, and tess_indexed_patches's inventory rows and printout
Re-blessed on the M3 at 466d447c6a (bless job m3-max-80813: inventory, golden, printouts and the metallib link half all EXIT=0). The golden table moves 94 rows for split-store (semantics 2322) and drawIndexedPatches (2323), and adds tess_indexed_patches's rows; the engine inventory gains the fixture's .ll and .air.ll rows; tests/air_input/tess_indexed_patches.txt is its printout. These are the four bless items lavapipe named in m3-max-80734 (golden cells, the inventory's 1338 against 1340, llvm_as part 1's row, the missing printout).
2026-12-02 16:25:48 -08:00
Anees Iqbal c50fd04219 rt: drawIndexedPatches, and patch draws through a patch index buffer
The runtime refused a patch draw through a patch index buffer
(Gap::Draw of DrawKind::PatchIndexBuffer) and had no indexed patch draw.
The viewer draws every patch with drawIndexedPatches, indirectly, through
a nil patch index buffer and a UInt32 control-point index buffer (reims's
walk at development 8a2f155883, job m3-max-80637 on the XTX: 4202
draw_indexed_patches calls left unbuilt).

The encoder now:
- takes a patch index buffer in draw_patches and draw_patches_indirect;
- has draw_indexed_patches and draw_indexed_patches_indirect, whose two
  index buffers come as one PatchIndexBuffers (the patch index buffer or
  none, and the control-point index buffer, each with its offset), as the
  indexed primitive draws take an IndexBuffer;
- pushes each index buffer's address plus its offset beside the factors'
  (FieldValue::PatchIndices, FieldValue::ControlPointIndices, 0 for none),
  and fills the push bytes again when they change. The control stage reads
  the indices through those addresses, unchecked, as it reads the factors;
- counts each index buffer among the draw's reads, as an index buffer
  (a Managed one's device copy brought up to date first), and keeps it until
  the command buffer retires.
Metal's validation refuses four things (an Apple M3 Max, job
m3-max-80366), and the runtime refuses them typed, direct and indirect:
- drawIndexedPatches through a state of index type None,
  Refusal::IndexedPatchDrawWithoutIndexType;
- drawPatches through a state with an index type,
  Refusal::PatchDrawWithIndexType;
- a patch index buffer offset that is not a multiple of 4,
  Refusal::PatchIndexBufferOffset;
- a control-point index buffer offset that is not a multiple of the index
  size, Refusal::ControlPointIndexBufferOffset.
Indices at a byte of the buffer's allocation off that multiple (a no-copy
buffer over such a pointer) are Refusal::ArgumentPlace, as an indexed
draw's are.

DrawKind::PatchIndexBuffer is deleted: nothing returns it. consumer-uses
at the consumer's development db87b77b07 (104 refs) finds PatchIndexBuffer
at 0 code hits; the consumer's DrawKind uses construct AttachmentRead and
LineWidth, and its one match on DrawKind has a wildcard arm
(render.rs:283-287), so the deletion breaks nothing there.

The conformance suite's runtime side draws RenderStep::DrawIndexedPatches.
Its tessellation-patch-indices case now compares on lavapipe (announced:
only the declared winding notice), so its four refused rows leave
known-gaps-rt.tsv; indirect-render-commands-patch-draws now makes its
indexed patch pipeline and reaches its command buffer, whose
indirect_command_buffer call the side answers Unavailable as the case's
siblings do, so its row moves there. docs/CONFORMANCE-COVERAGE.md is
regenerated. The runtime README, docs/REFUSALS.md, the refusal bases, the
API signature table and the Metal coverage map say the same.
2026-12-02 16:25:48 -08:00
Anees Iqbal 082248f947 Translator: the address form reads patch and control-point indices through their pushed addresses; a fragment's primitive id is the patch's position
Under the identity domains (the runtime's), a post-tessellation function's
control stage reads its factors through their pushed address and binds no
buffer. It had no way to read a patch index buffer or a control-point
index buffer, so it took each patch's index from its position and refused
a control-point index type (NotImplemented(Tessellation)). The viewer's
two pipelines are UInt32 control-point indices drawn by
drawIndexedPatches, and both were refused.

The control stage's push range now holds, at its offset:
- 0: the factors' address (u64), as before;
- 8: under a control-point index type, the control-point index buffer's
  address plus its offset (PushField::ControlPointIndexAddress, u64);
  otherwise the per-instance step's stride at 8 and the scale at 12, as
  before;
- 16: the patch index buffer's address plus its offset
  (PushField::PatchIndexAddress, u64), 0 for a draw without one.
24 bytes in all, below the post-tessellation function's window
(push::TESSELLATION_BASE). A control-point index type beside a
per-instance factor step or an enabled factor scale has no room for both,
and stays NotImplemented(Tessellation) (control::address_fits); the
runtime refuses those two at state creation anyway.

What the stage reads, from the Apple M3 Max's tables (jobs m3-max-80366
and m3-max-80398):
- the patch at position p (patchStart plus its place in the draw) reads its
  factors at p, whatever its patch index;
- its [[patch_id]] is the uint at index p of the patch index buffer where
  the pushed address is not 0, else p;
- control point j of patch pid is the vertex the index at pid * N + j of
  the control-point index buffer names (a ushort read out of its aligned
  word for UInt16, a uint for UInt32), else pid * N + j.
Each read goes through the address unchecked, as the factor reads do. No
check form is added.

A fragment function's [[primitive_id]] behind the stage is the patch's
position, with a patch index buffer or without (the same tables): the
control stage writes p to a flat varying at PATCH_POSITION_LOCATION (3),
which the evaluation stage hands on, and the control point varying moves
to location 4. Before, the varying carried the patch index, which equals
the position only without a patch index buffer.

The cache codec carries the two new push fields: ARTIFACT_FORMAT_VERSION
601. Translation output changes for every post-tessellation pipeline
under the identity domains: SEMANTICS_VERSION 2323 (2322 is split-store's).

Tests: control/tests.rs runs the address form's patch index and control
points on the SPIR-V interpreter (both index types, a nonzero and a zero
patch index address) and checks the pushed fields of each form;
engine_tessellation compiles the stream's state under UInt16 and UInt32
on every committed profile with the identity domains, with the fields at
0, 8 and 16, and refuses UInt32 beside a per-instance step or a scale;
lower::push checks the range fits below the window for every step, scale
and index type the form takes.
2026-12-02 16:25:21 -08:00
Anees Iqbal 975a9c0fc2 rt test: patch draws read control points and patch indices through their index buffers, factors and primitive ids at the position (red)
What Metal reads under a patch index buffer and a control-point index
buffer, from the Apple M3 Max's tables (jobs m3-max-80366 and
m3-max-80398, every form: drawPatches and drawIndexedPatches, direct and
indirect, with and without a patch index buffer):
- patch p of a draw (patchStart plus its index) is patch
  pid = patchIndexBuffer[patchIndexBufferOffset / 4 + p], or p without one;
- control point j is element
  controlPointIndexBuffer[controlPointIndexBufferOffset / size + pid * 3 + j]
  under drawIndexedPatches (u16 and u32 alike), and pid * 3 + j under
  drawPatches;
- the factors are entry p of the factor buffer, and [[primitive_id]] is p,
  whatever pid is;
- [[instance_id]] includes the base instance, and both instances agree.
Metal's validation refuses four things: drawIndexedPatches through a state
of index type None; drawPatches through one with an index type; a
controlPointIndexBufferOffset that is not a multiple of the index size; and
a patchIndexBufferOffset that is not a multiple of 4.

The tests, in tests/patch.rs:
- every_device_reads_control_points_and_patch_indices_through_their_index_buffers
  uses the new fixture tess_indexed_patches. It draws three patches of two
  instances from patch 1 and base instance 3, under each index type (None
  through drawPatches; UInt16 and UInt32 through drawIndexedPatches, their
  indices one index into the buffer), with and without a patch index buffer
  (position p is patch 6 - p), direct and indirect. Factor entries 1 and 4
  cull, so a build that read factors at the patch index would draw position
  1's patch 5 and cull position 2's patch 4.
- every_device_reads_a_patch_s_position_as_its_primitive_id_under_a_patch_index_buffer
  draws tess_primitive_ids with a patch index buffer that maps positions 1
  and 2 to patches 3 and 0. Each tile sits at its patch index and reads its
  position as [[primitive_id]].
- every_device_refuses_the_patch_draws_it_does_not_build now expects the four
  refusals, direct and indirect, as typed Refusal variants. The indexed state
  is made, where the translator refused it. The indirect test no longer
  expects a patch index buffer's Gap::Draw.

The indexed calls take their two index buffers as one PatchIndexBuffers
(the patch index buffer, or none, and the control-point index buffer, each
with its offset), as the indexed primitive draws take an IndexBuffer.

Red: the runtime has no draw_indexed_patches, draw_indexed_patches_indirect,
PatchIndexBuffers or new refusal variants yet, so the tests do not build
(lavapipe, job named in the next commit).
2026-12-02 16:25:21 -08:00
Anees Iqbal 4a08c04013 Fixtures: tess_indexed_patches, a post-tessellation function's control points and patch index through index buffers
An owned engine fixture for drawIndexedPatches and patch index buffers. It
is a rasterization-disabled post-tessellation function: triangle patches of
three control points, each with one float attribute through a
PerPatchControlPoint layout. Patch pid of instance iid writes its three
control points' values and iid to slot (iid % 2) * 8 + pid % 8. So a
patch's slot names its patch index, and the slot's values name the elements
its control points read.

Regenerated by scripts/regen-air-fixtures on the Apple M3 Max (job
m3-max-80491; one fixture of 585, Apple metal 32023.922, macOS SDK 27.2).
The fixture README gives its row. Its inventory rows and air_input
printout are for the landing bless.
2026-12-02 16:25:21 -08:00
Anees Iqbal 30a7654ac5 CLI: --tessellation FILE sets a post-tessellation vertex function's tessellation state
The command built its render descriptor from separate options and set no
tessellation state, so a post-tessellation vertex function always compiled
under Metal's default state: no control-point index type, factor 16,
clockwise. A pipeline of another state, such as one whose control points
come through a UInt32 control-point index buffer, could not be compiled
from the command line.

--tessellation FILE reads the JSON form of TessellationDescriptor (it
derives serde already) into the descriptor's tessellation field. Without
it the descriptor has no tessellation state of its own, as before. A repro
bundle carries the file as tessellation.json, as it carries the stage-input
and vertex descriptors. The README's command-line section and --help name
it. The option lives in the command's binary, which the cli feature
builds.
2026-12-02 16:25:21 -08:00
Anees Iqbal a3fb852de3 rt: a heap makes texture buffers in place in its bytes
Metal's heap makes a texture buffer (MTLTextureTypeTextureBuffer): heapTextureSizeAndAlign
answers its texels' bytes at an alignment of 16, and newTextureWithDescriptor:offset: lays the
texels linearly in place at the offset (m3-max-80369, m3-max-80398). rt refused both with
Refusal::TextureBufferNotOverBuffer.

Now:
- Device::heap_texture_size_and_align of a texture buffer answers width x texel bytes, unrounded,
  at 16, or at the device's texel-buffer offset alignment for the format where that is larger
  (minimum_texture_buffer_alignment). No Vulkan call.
- Device::new_heap_texture and new_heap_texture_for_views of a texture buffer place a buffer of
  those bytes at the offset as new_heap_buffer places one, and make the texture buffer over it as
  Buffer::new_texture makes one, through the same texel_texture: one buffer view, one form on
  every device, no query. It takes the heap buffer's heap id and placement, so its uses are the
  heap's in the hazard sets and its writes mark the heap's aliasing textures stale.
- Its backing is TextureBacking::Texture, as Metal answers its buffer with nil.
- A placement past the heap or off the alignment is Refusal::HeapTexturePlace. A heap in an
  exported block makes one too: a buffer view needs no image.
- texel_texture's descriptor checks move to texel_shape and texel_width, shared with the size
  answer.

TextureBufferNotOverBuffer stays for new_texture, new_texture_for_views, new_managed_texture and
new_drawable_texture. The test also checks HeapTexturePlace at offset 8 and past the heap's end.

Docs: the runtime's README (textures, heaps, exported blocks), docs/API.md's heap-size accepted
difference, the refusals' docs; docs/REFUSALS.md regenerated.

Conformance ledger (docs/CONFORMANCE-COVERAGE.md regenerated):
- 22 rows of a one-level RGBA8Unorm, R8Unorm or RGBA16Float texture buffer's heap size in the
  texture-pairs cases are dropped: the replay now matches them;
- 6 rows of a texture buffer of 2 or 7 levels now record Refusal::TextureLevelCount, as
  Buffer::new_texture refuses it, where Metal's heap answers one level's footprint;
- 11 rows of RGBA16Float_XR, YCBCR8_420_2P, Unspecialized and BGRA4Unorm texture buffers' heap
  sizes now record Gap::TextureFormat;
- the device's newTextureWithDescriptor: rows keep TextureBufferNotOverBuffer, their reason
  naming the heap as the other way to make one.

Verified (the change at 6d5f748347 on 787fbbb061, then this commit rebased onto development
8a2f155883, the same change):
- red: the test fails at heap_texture_size_and_align on llvmpipe (job m3-max-80460) and on the
  RX 7900 XTX and the 780M (m3-max-80461);
- green: it passes on llvmpipe, whose 6 dispatches reach the buffers at their addresses
  (m3-max-80460), and on the RX 7900 XTX and the 780M, bound (m3-max-80461). Each device's
  texel-buffer alignment for R32Uint is 4, so all three answer 16 at 16;
- the conformance replay matches known-gaps-rt.tsv: llvmpipe, every case (m3-max-80487, and on
  this tree m3-max-80503); the RX 7900 XTX, the 8 cases the ledger edit touches (m3-max-80488);
  the conformance suite, 1047 passed (m3-max-80493);
- on this tree (m3-max-80502): signatures, refusals, both coverage checks, fmt, clippy plain,
  --cfg m2v_gpu and --cfg m2v_cpu_icd, rustdoc and private rustdoc, all 0; the runtime suite on
  llvmpipe 942 passed, 1 failed, 4 skipped. The failure,
  private_sinks::every_device_keeps_a_store_past_a_private_array_off_its_words, fails the same
  at development 8a2f155883 without this change (m3-max-80535) and passed at 787fbbb061 with it
  (m3-max-80462, 940 passed).
2026-12-02 16:25:21 -08:00
Anees Iqbal 4786da9503 rt test: a heap makes texture buffers in place at offsets 0, 16 and 4096 (red)
A guest's viewer asks heapTextureSizeAndAlignWithDescriptor: of a texture-buffer descriptor and
makes the texture in a heap. rt refuses both with Refusal::TextureBufferNotOverBuffer.

The test asks for what Metal does on an Apple M3 Max (m3-max-80369 and m3-max-80398):
- a 4-texel R32Uint texture buffer is sized 16 bytes at an alignment of 16;
- a Shared and a Private heap make it at offsets 0, 16 and 4096;
- it reads the bytes a buffer placed at the same offset wrote, because placement keeps a reused
  region's bytes;
- tb_atomic adds 3 to each texel, and the sums land in place, linear, in the heap's bytes, with
  the sentinels past them unchanged.

Red here: heap_texture_size_and_align refuses the descriptor.
2026-12-02 16:24:50 -08:00
Anees Iqbal 2e5503c0f7 Translator: a store moves into the ways of a branch only under a key that orders nothing
The sink (lower::access::quad::sink) ran on the specialized entry, before lockstep's order, on
every profile. Lockstep pairs only accesses that reach each other on one path, so a store moved
into each way of a branch whose lanes diverge lost its pairs with the other way's accesses:
under a key that orders lanes (the resident-table domains), a pair the program has, which
lockstep would have ordered, went unordered. The sink now runs on the ordered entry, and only
under a key that orders nothing (OrderKey::orders_nothing, the identity domains, which order no
pair and so lose none); under a key that orders, the store stays in its block. Under the
identity domains the same stores move; the order, which inserts nothing there, now finds the
pairs behind its SimdgroupAccessOrder note in the program as written.

engine_store_quad's descriptor-profile test now asks for sst_split's seven word stores there.

Verified: the test fails before this change, on moltenvk-m3 with seven stores where six are
expected (filtered, 3 tests), and passes after (filtered, 47 tests), with clippy clean
(m3-max-80575). Under the identity domains the change moves the same stores: the row_tail module
is byte-identical before and after it on the committed rtx50, lavapipe, 780M and Iris Xe profiles
(m3-max-80635). At the branch's last commit: clippy in all three configurations, rustdoc, the
runtime's suite on lavapipe (942 passed, 4 skipped), the translator's (3412 passed, 37 skipped,
the tables a bless is due for left out), validation's (1319 passed, 3 skipped) and
conformance's (1047 passed) (m3-max-80665).
2026-12-02 16:24:50 -08:00
Anees Iqbal 862b698c22 Translator docs: a bound range ends at the buffer's length, not at a multiple of 16
memory::views said every bound range is a whole number of 16-byte units, and lower::access::quad
leaned on it for the 16-byte store through a robust view. A range is its bind offset plus the
buffer's length, rounded up only to robustStorageBufferAccessSizeAlignment (at most 4), so a
16-byte unit can straddle its end, and Vulkan lets a device drop the whole unit there. Such a unit
holds bytes past the end of the Metal buffer, which only a program that accesses past its
buffer's end reaches, and Metal does not define that; for every other unit the old reasoning
holds. Both docs now say so. No code changes.
2026-12-02 16:24:50 -08:00
Anees Iqbal 647825639e Translator test: a store before a divergent branch stays where lockstep orders lanes (red)
sst_lanes, written by hand: thread g stores g + 1 at word 4g of out, then branches on its index
in its simdgroup. The lanes below 16 store zero at the next three words, so the store before the
branch begins four at consecutive words in that way, and read word 4g + 64, which lane t + 16
stored before the branch. Under a key that orders lanes, lockstep pairs the store with that read
and orders the two; moved into each way of the branch, the copy in the other way reaches the read
on no path and the pair is lost. The test asks, on the descriptor profiles, for the AIR's six
stores in the ordered entry beside an inserted barrier, and under the identity domains, which
order nothing, for the store moved into both ways (seven) and no barrier.

Red: the sink runs before lockstep's order on every profile, so the descriptor profiles' entries
hold seven stores.
2026-12-02 16:24:50 -08:00
Anees Iqbal 71aa9829d0 Validation cases: Metal's answer for a row of floats written four at a time with its tail guarded
Four authored cases over engine/split_store_tail, 16 threads at two a row over 8 rows, out
filled with 0xCD: sst_split at rows of 7, 6 and 5 floats (each row's second thread writes
three, two or one float after its first) and sst_block at rows of 7 (the four in one block,
nothing where the row does not hold them). A row starts at 4w bytes times its index, so the
first word of a run of four sits at every residue of 16 across the rows. Installed with
corpus-case-check (m3-max-80423) and qualified on Metal on the Apple M3 Max, three executions
each (m3-max-80428). Each Metal output equals the MSL's stores computed on the CPU, byte for
byte (output sha256 d875b981, 2f994d06, 1a84d360, 21ceb16b).

scripts/qualify-public-cases now runs the four on lavapipe against those rows. At the branch's
last commit their Vulkan runs match Metal on lavapipe (m3-max-80560), the AMD Radeon RX 7900 XTX
(m3-max-80568) and the AMD Radeon 780M (m3-max-80570). Not run on an Intel card.
2026-12-02 16:24:50 -08:00
Anees Iqbal 8e2fc13cfe Translator: four word stores of one block at consecutive words are one 16-byte store where aligned
A row of floats written four at a time from a float4, with its tail guarded, stores the first
float in one block and the other three in the block its branch takes when the row holds them.
Each store was its own word store. Now the specialized entry moves such a block's last store
into both successors of its branch, where one of them opens with the three stores after it
(`lower::access::quad::sink`). Selection then finds, in one block, four plain word stores at
byte offsets k, k+4, k+8 and k+12 from one base with nothing between them that touches memory,
all reaching one slot (`quad::plan`). The last of them emits the four; the others emit nothing.

At emit each invocation tests the first word's offset: where it is a multiple of 16 and the 16
bytes pass the slot's containment check, the four words are one uvec4 store (through the slot's
uvec4 view where the kernel binds its buffers, at the device address with Aligned 16
elsewhere); otherwise the four word stores run as selected, each checked by itself. At a device
address the 16 bytes are checked in the shader, so a store that straddles the buffer's end keeps
every in-range byte. One form on every device: the memory decides only where the store goes, as
for every other access. Under the descriptor profiles, where lockstep orders lanes, a barrier it
puts between the stores keeps them words.

engine_word_phases's alignment test now allows the two tested 16-byte stores of vwp_words's
two runs of four word stores. SEMANTICS_VERSION 2322 (development holds 2321): the SPIR-V of
such kernels changed.

Verified: engine_store_quad, engine_word_phases and the access tests pass on the interpreter
in both forms at bind offsets 0, 4, 8 and 12 (m3-max-80331, m3-max-80352); clippy in all three
configurations, rustdoc, the runtime's suite on lavapipe (937 passed, 3 skipped) and the
translator's (3404 passed, 37 skipped, the tables a bless is due for left out) at the change
(m3-max-80386).

Timed with the harness's row_tail workloads, the harness commit against this change, the arms
alternated in one job per card; GPU time, the median of the rounds' medians:
- NVIDIA GeForce RTX 3090 (m3-max-80449, 4 rounds): the Shared rows fell from 46.3 to 2.12 ms
  (224 floats a row), from 52.4 to 3.29 ms (49) and from 24.8 to 19.4 ms (27,730, bimodal in
  both arms); the Private rows took 0.2 to 0.4% longer.
- AMD Radeon RX 7900 XTX (m3-max-80450, 4 rounds): every row within 1.1% of the base.
- AMD Radeon 780M (m3-max-80482, 8 rounds): the times fall in two clock states, the change's
  runs in the slower one in 5 of 8 rounds and the base's in 2 to 4; within a state the change
  takes 0.973 to 1.014 of the base's time.
Not run on an Intel card. Those jobs ran an earlier build of this change on an older
development; its row_tail module equals the one at this branch's last commit byte for byte on
the committed rtx50, lavapipe, 780M and Iris Xe profiles (m3-max-80707, m3-max-80705).
2026-12-02 16:24:50 -08:00
Anees Iqbal 3e2bf11a5c Translator test: four word stores of one block are one 16-byte store where their offset is a multiple of 16 (red)
engine_store_quad compiles split_store_tail's two kernels on every committed profile under the
identity domains, each with its kernel buffers at their device addresses and, where the profile
binds them, bound. It asks for one 4-lane store into buffer memory beside the word stores of the
other arm and the kernel's other ways, the uvec4 view of `out` where the buffers are bound, and,
on the interpreter at bind offsets 0, 4, 8 and 12 with rows of 5 to 8 floats, every word of
`out` as the MSL stores it. A second test holds the descriptor profiles: where lockstep puts a
barrier between the stores none joins.

Red before the change: `out` has one view, not two, and no 4-lane store (m3-max-80271).
2026-12-02 16:24:49 -08:00
Anees Iqbal cfc69949a4 Harness: row_tail workloads, rows of floats written four at a time with the tail guarded
row_tail writes a row of `shape.x` floats four at a time from a float4: the first float, then
the next three where the row holds them, else the next two, else the next one. Six workloads
run it: rows of 224 floats (every row 16-byte aligned), 27,730 (every other row) and 49 (one
row in four), each into a Shared buffer over about 381,000 threads and into a Private one over
16 times as many. Each checks the whole output against its CPU reference. They time the store
shape the translator's next change merges.

Companions regenerated by scripts/regen-air-fixtures --dir harness on the M3 (m3-max-80294).
2026-12-02 16:24:49 -08:00
Anees Iqbal 2005dae350 Fixtures: split_store_tail, a row of floats written four at a time with its tail guarded
Our own MSL of the shape a guest kernel writes its output in: thread gid reads in[gid] (a float4)
and writes its lanes to a float buffer at element row * w + col, col = (gid % d) * 4. sst_split
stores the first lane in one block and the other three in the block its branch takes where
col | 3 is inside the row (else the next two, else the next one); sst_block stores the four in
one block. Apple's compiler keeps the four scalar stores, at add i32 %i, 1 / 2 / 3, zext to i64.
The element's byte offset is a multiple of 16 only where w is.

Companions from scripts/regen-air-fixtures (job m3-max-80214 on the M3: Metal 32023.922, SDK
27.2). The engine inventory gets its four rows, written as ok on every profile, and the golden
printout under tests/air_input comes from bless_engine_goldens on the M3 (m3-max-80509); the
golden hashes are left to the bless on development.
2026-12-02 16:24:49 -08:00
Anees Iqbal 6a922c4ea2 CI: every nextest suite runs to its end (--no-fail-fast)
At da37e9e5df's macOS leg (run 46984549568) the validation suite stopped at its first failure,
with 831 of its 1326 tests not run; the failure before it had hidden that one for a whole cycle in
the same way. Every nextest step of both legs now passes --no-fail-fast: the three suites
(metal2vulkan and its sibling crates, validation, conformance) and, on Linux, the device tests
lavapipe-image runs in the image (its nextest command takes nextest's arguments after the
filters). A red step stays red; only how much runs after the first red changes. The CI replica
reads ci.yml, so it runs the same way.

Verified: the replica job named on the ready line runs these steps.
2026-12-02 16:24:22 -08:00
Anees Iqbal 0fe4e38198 validation: an engine run answers a case's Metal qualification gap before the host's gate
The CI's macOS leg at da37e9e5df (run 46984549568) failed
check::admission::tests::a_metal_row_from_an_earlier_oracle_needs_metal_qualification: on macOS
engine::execute returned Failed("Vulkan candidate execution is not available on macOS") where the
test expects NeedsMetal(OracleAbi). execute_prepared called validate_host before it read the
case's Metal observation, so on macOS the host's refusal hid the admission's device-free answer.
Whether a case needs Metal qualification does not depend on the host.

Now execute_prepared reads the Metal observation (MetalObservation::current, from the case's Metal
shard alone, no device) first and refuses the host after it, before the device half. A run on
Linux is unchanged: the gate passes there. The order of every other refusal is unchanged.

The same order decides the_engine_candidate_is_admitted_whatever_its_loops (the same file; it
expects NeedsMetal(Missing) on both devices), which never ran on macOS: nextest stopped at the
first failure. No other test reaches validate_host: engine::execute's callers are those two tests
and corpus-vulkan's candidate_common; the device worker's tests start the worker directly.

Verified: on Linux in the jobs named on the ready line. On macOS expected from the code reading,
not run; the remote macOS leg is the run.
2026-12-02 16:24:22 -08:00
Anees Iqbal f1689ad668 conformance: a ledger row lists each answer its venue's hosts give, where they part by what the venue does not state
The CI's ubuntu leg at da37e9e5df (run 46984549568) failed its conformance replay: on an x86-64
AVX-512 runner, llvmpipe of Mesa 26.2.4 and LLVM 23.1.1 gave five sites the counts the ledger keyed
to AVX2 hosts, where the AVX-512 runners of runs 46969176610 and 46974578786, in the same image,
gave the AVX-512 rows' counts. The count follows a property of the host finer than its widest
vector set, which the venue does not state, so no venue key separates the two.

Ruled by the planner: for those five sites only, the llvmpipe row accepts the set of counts
recorded there, each named with the run it came from; any other count on those sites, and any
difference on any other site, still fails. The venue string carries no new property.

Now:
- known_gaps: a row's answer field may list more than one answer, with ` | ` between them
  (ANSWER_SEPARATOR). KnownGap::answers lists them; the row covers each and no other, in both
  directions: a run holding any of them holds the row, a third answer is a new gap and reads the
  row as no longer held, and a site that no longer diverges reads it as fixed. A row of one answer
  is compared as before.
- known-gaps-rt.tsv: the AVX2 and AVX-512 rows of each site become one llvmpipe row:
  - fetch-ordered-bgra8unorm-srgb and fetch-ordered-rgba8unorm-srgb at case/x3 and case/x3-depth:
    6304 or 6496 elements (U8), the largest difference 2;
  - blend-interaction-format-srgb8 at case/blended/one-one-subtract: 81 or 78 elements (U8), the
    largest difference 3.
  Each row's gap names the runs of each count, from the commits that wrote the rows and CI's runs:
  6304 by the lavapipe legs of m3-max-55331 to 55337 (x3) and m3-max-55569 to 55574 (x3-depth),
  m3-max-56427 (LLVM 23.1.1) and CI run 46984549568; 6496 by m3-max-56238 and m3-max-56342
  (LLVM 23.1.4) and CI runs 46969176610 and 46974578786 (LLVM 23.1.1); 81 by m3-max-50686 and
  m3-max-56427 (LLVM 23.1.1), m3-max-63645 (LLVM 23.1.4) and CI run 46984549568; 78 by
  m3-max-56238 and m3-max-56342 (LLVM 23.1.4) and CI runs 46969176610 and 46974578786. The venue
  is llvmpipe, as the same cases' x1 and x2 rows are, so the lab's LLVM 23.1.4 hosts, which gave
  the same counts, stay covered.
- Docs: the ledger's header, the conformance README and known_gaps's module doc describe the form;
  Venue::host's doc and the README no longer say a CPU venue's answers follow its vector set.
  CONFORMANCE-COVERAGE.md regenerated (5 ledger rows fewer).

Verified: coverage.py --check, refusal_surface.py --check and metal-coverage --check pass here;
the red test, the CI replica and the lint are in the jobs named on the ready line.
2026-12-02 16:24:22 -08:00
Anees Iqbal dc6ab2fda7 conformance test: a ledger row of two answers covers either and no third (red)
The CI's ubuntu leg at da37e9e5df (run 46984549568) failed its conformance replay on an x86-64
AVX-512 runner, llvmpipe of Mesa 26.2.4 and LLVM 23.1.1: five sites gave the counts
known-gaps-rt.tsv records under the AVX2 venue (6304 elements at the x3 and x3-depth sites of
fetch-ordered-bgra8unorm-srgb and fetch-ordered-rgba8unorm-srgb, 81 at blend-interaction-format-
srgb8's one-one-subtract), where runs 46969176610 and 46974578786, on AVX-512 runners of the same
image, gave the AVX-512 rows' 6496 and 78. The property that decides the count is finer than the
host's widest vector set the venue states, and a row holds one answer.

The test: a row of the ledger's own format listing two answers with ` | ` between them covers a
run that answers either; a third answer is a new gap and reads the row as no longer held; a run
that no longer diverges reads it as fixed; a row of one answer covers that answer alone, as
before.

Red here: the ledger compares the whole answer field, so neither answer of the two-answer row
matches it.
2026-12-02 16:23:52 -08:00
Anees Iqbal b12d57dc98 Tables: golden hashes at semantics 2321, for the array-field sink
The bless for pin I at 5e0d5fb6ea, run on the M3 Max (job m3-max-80645): bless_engine_inventory,
bless_golden_hashes and bless_engine_goldens each exited 0, and the metallib half of
committed_air_fixtures_parse_and_link ran unskipped (linkhalf=0). Only golden_hashes.tsv moves:
40 rows, the run-time indexes into array fields that now go to the private sink rather than the
last element (511f31b0ba). Generated by the bless tests; no hand edits.
2026-12-02 15:44:39 -08:00
Anees Iqbal 5e0d5fb6ea Docs: the array-field bound's lowering doc and the parked-handles test say the sink, not a clamp
The two doc lines 511f31b0ba missed: memory::provenance's array_bound and
engine_parked_handles' compile test still said each run-time index into the
array field is clamped. Lowering sends such an access to the private sink
where an index is past its array. Doc text only; cargo fmt.
2026-12-02 15:19:29 -08:00
Anees Iqbal 511f31b0ba Translator: an index past an array field's array sends its private-arena access to the sink, not onto the last element
a992aa6929 bounded a GEP into an array field of a thread variable to its
array, so a struct holding handles beside a run-time-indexed array closes
as a forwarding cell. In the private arena it held every run to that bound
by clamping each run-time index to the array's last element. A store past
the array then landed on the array's own last word. The runtime's
private_sinks contract wants such a store kept off every word a thread
reads, as a store past a private array is. On lavapipe at development
8a2f155883 (job m3-max-80535),
every_device_keeps_a_store_past_a_private_array_off_its_words failed: the
fold over the arrays moved by about 193,700, which is b[k]'s store of
t + 200000 over b[N - 1]. The same test at 8a2f155883 with a992aa6929
reverted (scratch tree, job m3-max-80554) is the cause check.

The bound only promises that no run reaches outside the variable; where an
out-of-range index lands is undefined in MSL. So the GEP's offset is now
the sink's, 2^32 - 1, where any run-time index is above its array's last
element: ULessThanEqual per index, LogicalAnd across them, and one select.
No arena holds that offset, so the access's existing containment check
makes it a zero load or no store, as an access past a private array is,
off the array's words and every other's. The forwarding analysis keeps
relying on the in-field assumption alone (memory::provenance, unchanged).
parked_heap_handles' run-time-indexed array fields stay bounded and the
struct still closes (access.private.gep.array, 3 uses).

docs/API.md's accepted difference says it: a read past the end of an array
field reads zero and a write is dropped, in the private arena as in a
variable of its own. The local, provenance and parked-handles docs say the
same. The device-arena budget test's run-time-index shapes cost one
instruction more than the clamp (a compare and a select in place of a
UMin): bounds 14, 13 and 25. SEMANTICS_VERSION 2321 (development holds
2320).
2026-12-02 15:16:20 -08:00
Anees Iqbal 77ec1b3bb6 Tables: golden hashes at semantics 2320, and the parked-handle and tessellation fixtures' inventory rows and printouts
The bless for pin I at 8a2f155883, run on the M3 Max (job m3-max-80469): bless_engine_inventory,
bless_golden_hashes and bless_engine_goldens (llvm-as 21) each exited 0, and the metallib half of
committed_air_fixtures_parse_and_link ran unskipped on the fixtures' SDK (linkhalf=0).

- golden_hashes.tsv moves from semantics 2318 to 2320: the dead-type removal, the evaluation
  stage's output limit and the post-tessellation series.
- public_fixture_expectations_engine.tsv gains the seven new rows: parked_heap_handles,
  parked_heap_handles_read, _copied and _stepped, tess_primitive_ids,
  tess_primitive_ids_fragment and tess_draw_bases.
- air_input printouts for parked_heap_handles, tess_primitive_ids and tess_draw_bases.

Generated by the bless tests; no hand edits.
2026-12-02 15:08:39 -08:00
Anees Iqbal 8a2f155883 Fixtures: the post-tessellation draw-bases function moves to a fixture of its own, tess_draw_bases
engine/rvc_draw_bases.ll is the public source of four committed cases,
which check its hash. Regenerating it to add draw_bases_after_tessellation
(and under a newer metal) failed all four in
committed_public_cases_check (lavapipe's host, job m3-max-80338). The
fixture goes back to the AIR its cases check, and the function moves,
unchanged, to engine/tess_draw_bases, regenerated by
scripts/regen-air-fixtures on the Apple M3 Max (job m3-max-80403; one
fixture of 584 regenerated, Apple metal 32023.922, macOS SDK 27.2). The
fixture README gains its row and rvc_draw_bases's row is as before.

The translator test the_base_instance_after_tessellation_is_the_patch_input_or_the_push_lane
reads base_instance_after_tessellation from rvc_draw_bases and
draw_bases_after_tessellation from tess_draw_bases, and the runtime's
every_device_reads_a_patch_draw_s_base_instance_after_tessellation draws it
from there. The engine inventory's new row is tess_draw_bases's, in place
of rvc_draw_bases's draw_bases_after_tessellation, for the landing bless.
2026-12-02 14:41:35 -08:00
Anees Iqbal e93d7e6b1b Docs: a fragment's primitive id behind tessellation is the patch's position without a patch index buffer
The evaluation stage's varying carries Metal's patch index, which is the
patch's position in its draw only where no patch index buffer is bound. With
one, Metal's [[primitive_id]] stays the patch's position while its patch
index is the buffer's entry (an Apple M3 Max, job m3-max-80366), so the
docs now say which draws the varying's value is Metal's for, and that the
runtime records no patch draw through a patch index buffer
(DrawKind::PatchIndexBuffer stays refused). The translator module docs,
lower_inputs, the tessellation link module, docs/API.md and the runtime
README say so; no code changes.

Doc lines past 100 columns in stage_io/plan.rs, lower_inputs.rs, the
tessellation link module and the engine_device_arena and engine_draw_bases
tests are rewrapped, and the patch test's println is shortened under the
limit.
2026-12-02 14:41:35 -08:00
Anees Iqbal 5689683788 Translator: a fragment function's primitive id behind a post-tessellation function is the patch's position
Behind an evaluation stage, Metal's [[primitive_id]] is the patch's position
in its draw, patch start included, the same in every instance and for every
triangle the tessellator makes of the patch (an Apple M3 Max, job
m3-max-80266: draws of two patches from patch 0 over two instances read 0
and 1 in both instances; two patches from patch 2 read 2 and 3). Vulkan's
PrimitiveId there counts the draw's patches from 0 and restarts in each
instance (the specification's PrimitiveId: "The index of the first primitive
generated by a drawing command is zero ... reset to zero between each
instance drawn ... In a fragment shader, it will contain ... the value that
would have been presented as input to the geometry shader had it been
present"), so it differs once patchStart is not 0. The translator refused
such a pipeline at link, NotImplemented(Tessellation), which a walk's
pipeline met behind its post-tessellation [[base_instance]].

The fragment function now reads it through the primitive ID's flat varying
(IoRole::PrimitiveId), on every device, one form: a post-tessellation
vertex function compiled under LoweringInputs::primitive_id_varying writes
Metal's patch index, its patch input at PATCH_INDEX_LOCATION, to that
varying at each return (stage_io::PrimitiveIdStore::Patch). Without a patch
index buffer the patch index is the patch's position; the runtime draws no
patches through one (DrawKind::PatchIndexBuffer stays refused), and the docs
state the value for draws without one. The same value
reaches every vertex of the patch, so the provoking vertex does not matter.
Device::compile_render_pipeline and the render keys decide the varying for a
post-tessellation vertex stage as they do on a device without a fragment
PrimitiveId; the library answers that without decoding the function (a
metallib function's TESS tag, a module entry's air.patch), and a compiled
stage from its interface. Link refuses a fragment function compiled to read
Vulkan's PrimitiveId behind an evaluation stage as NeedsInput(PrimitiveId),
where it refused every such fragment as NotImplemented(Tessellation);
docs/REFUSALS.md is regenerated.

The varying takes a location as any other: the evaluation stage's outputs
are held to maxTessellationEvaluationOutputComponents when it is planned,
and link numbers the fragment's inputs below maxFragmentInputComponents / 4,
each a typed InterfaceComponents limit refusal past it.

Tests: a_fragment_primitive_id_behind_tessellation_is_the_patch_index_varying
(MoltenVK's and RADV's profiles: the evaluation stage reads the patch-index
input, the fragment stage one flat input and no PrimitiveId, L3), the link
test of a fragment that reads Vulkan's PrimitiveId, and the runtime test
every_device_reads_a_patch_s_position_as_its_fragments_primitive_id, green on
lavapipe (llvmpipe), job m3-max-80338.
2026-12-02 14:41:35 -08:00
Anees Iqbal 5f4c55cf45 rt test: a fragment function's primitive id behind a post-tessellation function is its patch's position (red)
The owned fixture tess_primitive_ids (MSL we wrote, its companions
regenerated on the Mac, job m3-max-80275) is a post-tessellation vertex
function (triangle patches of three control points, no stage-in) that places
patch pid of instance iid in its own tile of an 8x8 target and passes pid and
iid flat, and a fragment function that writes [[primitive_id]], pid, iid and 1.

Metal's answer, read on an Apple M3 Max (job m3-max-80266, the same shape at
64x32, every factor 4 with the integer partition): every fragment of every
triangle of a patch reads one value, the patch's position in its draw,
patch start included, the same in each instance. A draw of two patches from
patch 0 over two instances reads 0 and 1 in both; a draw of two patches from
patch 2 reads 2 and 3. Vulkan's PrimitiveId behind an evaluation stage counts
the draw's patches from 0 and restarts in each instance, so it reads 0 and 1
for the second draw.

every_device_reads_a_patch_s_position_as_its_fragments_primitive_id draws
both in one pass and checks every covered texel of each drawn tile, and that
the tiles no patch draws stay clear. Today the translator refuses the
pipeline: Tessellation, NotImplemented, at link (a fragment function that
reads [[primitive_id]] behind an evaluation stage).

Red on lavapipe (llvmpipe), job m3-max-80279: "Tessellation; needs
NotImplemented" for the state; the control draw passes.
2026-12-02 14:41:34 -08:00
Anees Iqbal 0e9d11b76d Translator: a post-tessellation function's base instance travels from the vertex stage as a patch input
Metal gives [[base_instance]] to a post-tessellation vertex function on every
Mac device. An evaluation shader has no BaseInstance builtin, so the
translator read it from the second lane of PushField::BaseVertexInstance, an
encoder value the identity domains do not admit: the runtime refused every
such state.

On a profile with shaderDrawParameters (the runtime's floor), the base
instance now travels the way the instance index already does: the
synthesized vertex stage reads BaseInstance and writes it to the new fixed
location TessellationStage::BASE_INSTANCE_LOCATION (2), the control stage
hands it on as a patch output, and the evaluation stage reads that patch
input. CONTROL_POINT_LOCATION moves from 2 to 3. The runtime records a patch
draw as vkCmdDraw(patchCount, instanceCount, patchStart, baseInstance), and
reads MTLDrawPatchIndirectArguments as VkDrawIndirectCommand, so the builtin
is Metal's baseInstance in both forms. A profile without shaderDrawParameters
keeps the push lane, as a plain vertex function's [[base_instance]] does
there; the identity domains and the push window do not change.

TessellationStage is crate-private (pipeline::interface is pub(crate) and
does not re-export it), so neither constant is on the published surface.
The consumer's checkout names none of CONTROL_POINT_LOCATION,
INSTANCE_LOCATION, BASE_INSTANCE_LOCATION or TessellationStage
(consumer-uses.sh, development cba3a88875: 0 hits each).

Tests: the translator test
the_base_instance_after_tessellation_is_the_patch_input_or_the_push_lane
compiles both post-tessellation entries of rvc_draw_bases on every committed
profile with tessellationShader and on runtime-floor without
shaderDrawParameters: the patch input at BASE_INSTANCE_LOCATION with the
feature, the push lane and its fact without it, L3 either way. The
synthesized vertex stage passes L3 with and without the carry. The runtime
test every_device_reads_a_patch_draw_s_base_instance_after_tessellation is
green on lavapipe (llvmpipe), job m3-max-80249 (52 passed: the
runtime's patch tests, engine_draw_bases, engine_tessellation and the
link's tessellation tests). The walk's vertex function now compiles
(m3-max-80250, the XTX node).
2026-12-02 14:41:34 -08:00
Anees Iqbal 587be990ee rt test: a post-tessellation function reads the draw's base instance beside its instance id (red)
The owned fixture rvc_draw_bases gains draw_bases_after_tessellation: a
rasterization-disabled post-tessellation vertex function (triangle patches of
three control points) whose patch pid of instance iid writes pid, iid,
[[base_instance]] and 1 to slot (iid % 4) * 8 + pid % 8. The companions are
regenerated from the MSL on the Mac (job m3-max-80217).

Metal's answer, read on an Apple M3 Max (job m3-max-80206): the pipeline is
made, and a drawPatches of two patches, instanceCount 2, baseInstance 3 runs
each patch of instances 3 and 4 with [[base_instance]] 3.

The runtime test every_device_reads_a_patch_draw_s_base_instance_after_tessellation
draws that function directly and from MTLDrawPatchIndirectArguments with the
same counts and checks every slot. Today the translator refuses the state on
every runtime device: under the identity domains the evaluation stage's
[[base_instance]] is a pushed encoder value they do not admit.

Red on lavapipe (llvmpipe), job m3-max-80232: "IdentityDomains (an encoder
value the function reads as BaseVertexInstance); needs NotImplemented"; the
control draw passes.
2026-12-02 14:41:34 -08:00
Anees Iqbal 9f4aded219 Translator: a post-tessellation function reads a Constant layout's control-point attribute from its one element
pulled_read takes (ControlPoint, Constant) as it takes (Patch, Constant):
Element::None, the attribute's offset alone, with no stride pushed or
depended on. A control-point call fetches such a member with no element.
It computes the control point's element only when some member steps per
control point, so a struct of Constant members alone needs no elements
input. The module doc states the rule and Metal's measured answer (every
control point reads element 0, Mac job m3-max-80062).

Verified: lavapipe (llvmpipe), job m3-max-80143 at the same tree on a
scratch branch: both tests pass, with the patch draws beside them.
2026-12-02 14:41:34 -08:00
Anees Iqbal 3fbaca0b9b Translator and rt tests: a control point's attribute on a Constant layout reads its one element (red)
A post-tessellation vertex function may read a control-point attribute
whose vertex buffer layout has the Constant step function (step rate 0).
Metal makes such a pipeline, and on an Apple M3 Max every control point of
every patch reads the layout's element 0 at the attribute's offset (an
Objective-C probe, Mac job m3-max-80062; the other elements held other
values and none was read). That matches Apple's documentation of
MTLVertexStepFunctionConstant ("fetches attribute data once and uses that
data for every vertex"). The translator refuses the pair,
NotImplemented(Tessellation), and a walk met that refusal behind the
array-field one.

- a_control_point_attribute_on_a_constant_layout_reads_its_one_element
  (engine_tessellation): tess_triangle_points with its control points'
  half2 from buffer 2 at offset 4, on a Constant layout, compiles. It
  pushes no stride of buffer 2 and passes L3.
- every_device_reads_a_constant_layout_s_one_element_at_each_control_point
  (rt, patch): the same draw as
  every_device_draws_patches_from_their_factors, with that half2 shifting
  the third control point's x. Element 0's half2 at offset 4 is 0;
  element e's is e, with 5 at offset 0. So a control point that reads
  another element, or the element's first bytes, moves the patch and
  changes the texels.

Red: lavapipe (llvmpipe), job m3-max-80108: both refused, "Tessellation;
needs NotImplemented at function tess_triangle_points"; the control draw
passes.
2026-12-02 14:41:34 -08:00
Anees Iqbal a992aa6929 Translator: a GEP into an array field of a thread variable stays inside its array
A thread struct that holds pointers or heap handles beside an array field
indexed at run time was open to pointer forwarding: provenance made the
offset of any run-time index unknown, so the data access could overlap a
pointer slot. A heap handle stored into such a struct then fell to the
handle family's catch-all, Lowering(Access). That is the refusal of a
post-tessellation vertex function a walk met (two render pipeline states
refused).

The Metal Shading Language leaves an index past an array undefined. So a
thread-space getelementptr whose first index is a constant, each of whose
run-time indices steps over an array its own type path names, and whose
every use is a load or store address, is a GEP into an array field
(provenance::array_geps). Over a base whose roots are stack allocations at
constant offsets, its offsets are its displacement plus at most
(len - 1) * stride per run-time index. These keep unknown offsets: a
flattened offset (a run-time pointer index), a run-time vector lane, an
address another GEP offsets or that is merged or stored, a base that may
be null, and memory outside the thread space. A run-time index at a struct
level has no IR form.

Lowering holds every run to the bound. In the private arena, where
objects lie side by side, such a GEP takes each run-time index as
min(index, len - 1) (access.private.gep.array). A typed object's access
already never leaves its levels. docs/API.md records the accepted
difference: an index past the end of an array field of a local struct
does not reach its neighbouring fields; it is undefined in MSL. The
struct then closes as a forwarding cell, and its heap-handle stores that
no load reads take the cell's unread store (the previous commit).

Verified:
- red: m3-max-80079, b9d9dfc9ba (parked_heap_handles refused at its
  handle store, block 0 instruction 11).
- green: gate m3-max-80143 at the same tree on a scratch branch
  (lavapipe tests 47 passed; validation 1315 passed, 3 skipped;
  conformance 1047 passed; the translator suite's only failures are the
  tables development re-blesses: the engine inventory with four new
  parked_heap_handles rows, the golden printout, and 315 golden hash
  cells under SEMANTICS_VERSION 2319).
- L0: a_gep_into_an_array_field_is_bounded_to_the_array (the bound, and
  each disqualifying shape staying unknown).
- read-back, whole-struct copy (a memcpy) and a stepped address stay
  Lowering(Access).
- the walk's two metallibs on the XTX node (m3-max-80156): the handle
  store's refusal is gone; the vertex function next met the two
  refusals the following commits remove.

Cost: one UMin per run-time index into a private-arena array, the bound
itself. The device-arena budget test's word bounds move by one each (13
for a word load, 12 for a word store, 24 for a float4 load).
SEMANTICS_VERSION 2320 (development holds 2319).
2026-12-02 14:41:34 -08:00
Anees Iqbal 728e4c9b1d Translator test: heap handles parked in a thread struct with run-time-indexed array fields compile (red)
The owned fixture engine/parked_heap_handles now matches the shape a
post-tessellation vertex function was refused for: a thread struct holds
heap handles (a sampler and a texture loaded from argument buffers, also
sampled directly) beside two array fields a loop writes at a run-time
index, and the out-of-line callee reads one array at a run-time index.
Every run-time index sits at an array level of its GEP's own type path.
Such a data access at an unknown offset opens the struct today, so the
handle stores fall to the handle family's catch-all, Lowering(Access).

heap_handles_parked_where_nothing_reads_them_compile expects the kernel
to compile with both handle stores unread and the three run-time array
indices clamped in the private arena. The read-back, copied and stepped
kernels (an address offset by a second GEP after the array GEP) must
stay Lowering(Access).

Companions regenerated with Apple metal 32023.922, macOS SDK 27.2
(Mac job m3-max-80076).
2026-12-02 14:41:34 -08:00
Anees Iqbal a13b16fd4c Translator: a store into a cell slot no load reads needs no encoding; a heap handle stored there writes nothing
A heap texture or sampler handle (a handle loaded from an argument
buffer, whose root is Dynamic) stored into a field of a thread struct
that is a forwarding cell was refused at the store, Lowering(Access)
NotImplemented, because no cell encoding carries a heap handle. A
post-tessellation vertex function seen in a guest's render pipeline
parks three samplers and three textures from its argument buffers in a
struct that nothing ever reads them back from, so the whole pipeline
was refused at the first of those stores.

cell::select's store arm now asks the store's slot group for its
loads before it needs an encoding: where the group holds no load
(cell_reads has no entry for it), a pointer no cell encodes writes
nothing (CellStrategy::Unread, census name access.cell.unread). A
store whose value has an encoding still writes it, as before, so pools
(which data loads may read) are untouched: a pool holds arena pointers
alone, each of which a cell encodes.

Why "no load in the group" means nothing observes the slot: the
group is formed over every access of a closed forwarding cell, and a
cell is closed only while nothing else reaches it
(memory/provenance/cells.rs, Round::walk):
- a store of the cell's address into memory that does not forward it
  opens it (line 1218);
- any other operand use, a call the translator does not inline, a
  ptrtoint, an atomic or an aggregate, opens it (line 1241);
- a memcpy or memmove whose bytes meet a pointer slot is a data
  access and opens it (line 1146), unless it is a slot copy between
  two cells (line 1134), which joins the source and destination slots
  into one group (CellFacts::groups, line 172), so a load of the copy
  is a load of the group.

Still refused, by the same Lowering(Access): a heap handle in a slot
that a load reads, directly or through a copy. Carrying a heap handle
through a cell to a load would take a cell encoding for the looked-up
handle, whose form (flagged or indexed) follows its uses; that form is
not built here.

The test of the previous commit pins both: parked_heap_handles
compiles, with its two handle stores as access.cell.unread, and the
read-back and memcpy controls stay Lowering(Access).
2026-12-02 14:41:34 -08:00
Anees Iqbal 462379121d Translator test: heap handles parked in a thread struct whose handle fields nothing reads compile (red)
The owned fixture parked_heap_handles loads a sampler and a texture from
argument buffers, passes them by value to a thread struct's constructor,
which stores each as a pointer into its field, and hands the struct by
reference to a function compiled out of line. Once the call is inlined
the struct is a forwarding cell, and no load reads the handle fields.
The translator refuses the first such store today as Lowering(Access)
NotImplemented, at the cell encoding of a handle with a Dynamic root.

The test expects the kernel to compile and pass L3 on every committed
profile with the sampled heap, its two handle stores selected as
unread cell stores, and ArgumentBufferTextures elsewhere. Two controls
read the parked handles back, from the cell and through a whole-struct
memcpy into a second cell, and must stay Lowering(Access).

The companions come from scripts/regen-air-fixtures on Metal
32023.922, SDK 27.2 (jobs m3-max-79932 and m3-max-79936).
2026-12-02 14:41:33 -08:00
Anees Iqbal c261fef463 Translator: link holds an evaluation stage's outputs to maxTessellationEvaluationOutputComponents
A post-tessellation vertex function's module is a tessellation evaluation entry, whose output
interface the Vulkan specification limits to maxTessellationEvaluationOutputComponents / 4
locations (19.1.4, Table 21, Shader Input and Output Locations). Link's check_limits held every
vertex stage's outputs to maxVertexOutputComponents / 4, so on a device whose evaluation limit is
below its vertex limit link placed an evaluation stage's varyings past its locations, and on one
whose evaluation limit is above it refused (or packed) varyings that fit.

check_limits now takes the pre-fragment stage's limit, output_limit: the evaluation limit for a
vertex stage whose interface names an evaluation stage (StageInterface::tessellation), the vertex
limit for any other. Its packing and refusals are otherwise unchanged, and a refusal names the
limit it met. The module doc's Limits paragraph says so.

No committed profile at the floor changes: each has the two limits equal; the below-floor vk12
profile, the one that differs, has no tessellation. The lowering's own check of a
post-tessellation function's output components (lower/stage_io/plan.rs) already used the
evaluation limit.
2026-12-02 14:36:11 -08:00
Anees Iqbal 00b405cff9 Translator test: an evaluation stage's outputs fit maxTessellationEvaluationOutputComponents (red)
Link's check_limits (pipeline/link/varyings.rs) holds the outputs of a render pipeline's vertex
stage to maxVertexOutputComponents / 4 locations, a post-tessellation vertex function's too. That
function's module is a tessellation evaluation entry, whose output interface the Vulkan
specification limits to maxTessellationEvaluationOutputComponents / 4 locations (19.1.4, Table 21,
Shader Input and Output Locations). Every committed profile at the floor has the two equal; the
below-floor vk12 profile has 64 and 0.

The test links three four-component varyings, which no packing shares, from a vertex stage whose
interface names an evaluation stage (`PipelineInterface::tessellation`) into a fragment stage:
- with the vertex limit 8 and the evaluation limit 12 they must take locations 0, 1 and 2;
- with the vertex limit 12 and the evaluation limit 8 they must be refused as
  InterfaceComponents needing MaxTessellationEvaluationOutputComponents, 12 of 8.
Red today at the first half: link refuses them naming MaxVertexOutputComponents.
2026-12-02 14:35:10 -08:00
Anees Iqbal 787fbbb061 Translator docs: remove_dead's doc in 100 columns, and IndexType's and UnfixedLocation's docs say what their sites refuse
Three doc nits from the audit lane's cold read of today's landings:

- TypedModule::remove_dead's doc (spirv/ir/edit.rs) had one 120-column line since dead removal
  took any type; it is rewrapped within 100 columns, word for word.
- AccessCause::IndexType said "an index of a type other than an integer". Its one site,
  index_form (lower/access/mod.rs), refuses every type but an integer of 1 to 64 bits: a 0-bit
  integer and an integer wider than 64 bits too. The doc now names them.
- AccessCause::UnfixedLocation listed "a table's count". A threadgroup argument's count is
  checked in check_tables (memory/plan.rs), which names ArgumentTable for any count that is not
  a constant 1, a constant or not; the doc now says so and names an argument table's count
  alone.

Docs only; no generated doc carries these comments (docs/REFUSALS.md, API.md and the coverage
tables do not), and neither file is a runtime or classifier input of the validation crate.
2026-12-02 14:26:46 -08:00
Anees Iqbal 3d45f3ff9b rt: texel_texture_copy takes each side with its texel buffer, a type of its own for clippy
50170636e7 passed both sides' texel buffers to texel_texture_copy as one
(Option<(Buffer, u64)>, Option<(Buffer, u64)>), which clippy's type_complexity refuses under
-D warnings (blit.rs:344, all three clippy configurations, job m3-max-80104 on ms01). Each side
is now one TexelSide (the texture, its place, and its Texture::texel_buffer where it is a texture
buffer), as the two sides were (texture, place) pairs before. No behaviour changes.
2026-12-02 14:24:14 -08:00
Anees Iqbal 4fe41c795d rt: a blit copy with a texture buffer on either side copies its buffer's bytes
Metal makes copyFromTexture:...toTexture: with a texture buffer as the source or the destination.
copy_from_texture refused it as Gap::TextureCopy ("A texture buffer's texels are its buffer's
bytes, which no image copy reaches"). Under the rule that a refusal of what Metal makes is built,
it now copies a texture buffer's texels as the bytes of its buffer (texel_texture_copy):

- Checked as Metal checks any copy: one pixel format and one sample count
  (Refusal::TextureCopyMismatch), and each region inside its texture's level and slice (`place`,
  Refusal::TextureRegion), sizes of 0 taken as copy_from_texture takes them.
- Between two texture buffers: the region's bytes copied between their buffers by
  copy_from_buffer_to_buffer, from each one's offset plus origin.x texels. The same bytes copy
  nothing, as the same region of one image does, and bytes that meet are
  Refusal::BufferCopyOverlap, as that call refuses them.
- Between a texture buffer and another texture: copy_from_buffer into the texture from the texture
  buffer's row in its buffer, or copy_from_texture_to_buffer out of it into that row. That is one
  vkCmdCopyBufferToImage or vkCmdCopyImageToBuffer region, checked and ordered as those calls are.

The command buffer keeps both textures. Gap::TextureCopy's doc drops the texture buffer case, and
docs/REFUSALS.md is regenerated. Buffer::new_texture's doc, copy_from_texture's doc and the runtime
README's texture buffer contract say what such a copy does. The texture buffer refusal test no
longer expects the gap from a copy of one into itself; that copy of the same bytes now copies
nothing.
2026-12-02 14:24:14 -08:00
Anees Iqbal 0c4777ead7 rt test: blit copies between texture buffers and a texture move the region's texels (red)
Metal makes copyFromTexture:...toTexture: with a texture buffer on either side; the runtime refuses
it as Gap::TextureCopy (blit.rs, copy_from_texture: "A texture buffer's texels are its buffer's
bytes, which no image copy reaches"). The test makes two RGBA8Unorm texture buffers of 64 texels
over one Shared buffer (A at offset 0 with known bytes, B at 1024 holding 0x5a) and a Private 2D
texture of 16 x 4. A blit copies texels 8 to 23 of A into texels 4 to 19 of B, texels 0 to 15 of A
into the texture's row 2, and that row back into texels 32 to 47 of B. B must hold A's bytes at
both places and 0x5a around them, and A must keep its own. Red today at the first copy.
2026-12-02 14:24:14 -08:00
Anees Iqbal 5874017899 rt docs: the host-memory over-copy's second measurement on the M3, and what would give it another form
The runtime README's host-memory bullet gains a second measurement and the condition under which
that copy would have another form on KosmicKrisp.

The second measurement is the consumer's census on the M3 Max (KosmicKrisp, Mesa 26.3.1), at rt
d122da6ae3:
- run A, m3-max-80100, software decode;
- run B, m3-max-80121, the host's decoder;
- two 30 s 1080p screen recordings in each run.

Metrics::over_copy_bytes_host_memory came to 12,178,324,736 bytes in run A and 12,624,820,212 in
run B. The census's other over-copies in run B are 10 Linear copies of 8,294,400 bytes (a 1080p
BGRA8Unorm render target) and Pitch copies of small textures, which it does not total. So the 99.3%
share is derived here from the census's counts: 12,624,820,212 / (12,624,820,212 + 82,944,000).
It covers the host-memory and Linear bytes.

The condition comes from probe m3-max-80267 (Apple M3 Max, KosmicKrisp Mesa 26.3.1; queries only):
- The one handle type with an owner the driver offers is MTLHEAP: importable and exportable for a
  plain buffer and for linear sampled BGRA8 and R8 images.
- It lists no VK_EXT_queue_family_foreign. An acquire of another driver's writes would name its
  queue family; VK_QUEUE_FAMILY_EXTERNAL covers only the same driver.
- It makes no linear image with COLOR_ATTACHMENT, with or without a handle type.
The bullet says the copy has no other form on that driver until it lists that extension or offers
that attachment.

Docs only. refusal-surface --check passes.
2026-12-02 14:24:14 -08:00
Anees Iqbal 08b385ddc5 Translator: dead removal drops every type nothing that stays refers to, and its capability with it
Dead removal dropped only vector and function types, and a module's
requirements were derived from every type its interner ever held, a
forgotten one included. So once a slot's direct base and address left
(fd8b132834), their OpTypeInt 64 and { uint, uint } struct stayed declared,
and the module still declared OpCapability Int64 and required shaderInt64.

Now:
- unread_types drops any declared type nothing that stays refers to (a kept
  instruction or phi result, a function that stays, a variable of one, a
  global, a push member, a kept constant, or a type itself referred to), of
  any kind, after the sweep and the offers' weighing;
- an array type's length is no longer counted as a use up front, since
  which array types stay is known only then: the length of each array type
  that stays is revived (a scalar constant, which reads nothing), and a
  length only a removed array type read leaves with it;
- TypedModule::remove_dead accepts any type, and Types::iter lists only the
  types still interned, so the requirements and spec_bits walk the types
  the module declares, not the ones it forgot.

This starts from the L155 seat's partial patch (its three changes), which
lacked the lengths list and the edit's check.

Tests: the dead-removal
tests change where more types now leave: the constants kernel's array type
nothing has leaves with its length while a private variable's array type
keeps its own; the offers kernel's pointer type no value has leaves with
the uvec3 only it names (3 types, was 1); the routines kernel without r's
call loses the float type too (3, was 2).

Module words change where an unused type was declared: SEMANTICS_VERSION
2318 -> 2319. The golden tables re-bless on development.

Verified: job m3-max-79992 (no card) at this tree. The previous commit's
test fails there alone, left (2, 0) against (2, 2): two dead instructions,
no type removed. Here all 7 dead-removal tests pass; clippy plain, cpu-icd
and gpu cfg, doc and privdoc exit 0; rt on lavapipe 933 passed, 3 skipped;
translator and AIR 3402 passed, 37 skipped (golden tables excluded, due);
validation 1315 passed, 3 skipped; conformance 1047 passed. Release-mode
translation time and peak memory were not measured.
2026-12-02 14:24:14 -08:00
Anees Iqbal 95199bb968 Translator test: a type only dead values had leaves with its capability (red)
After fd8b132834 made a slot's direct base and address in the entry block,
dead removal leaves the ones no access reads, but not their types: an
unused OpTypeInt 64 and a { uint, uint } struct stay declared, and with
the 64-bit type the module's OpCapability Int64 (3 of 8 sampled modules in
the byte-identity probe). Dead removal drops only vector and function
types.

The test builds that shape: a kernel that widens a loaded word to a 64-bit
integer and pairs the word with itself in a { uint, uint } struct, and
reads neither. After dead removal both types must leave, and the module
must no longer require Int64 or shaderInt64. Red here: no type leaves, so
the report counts 0 types and Int64 stays.
2026-12-02 14:24:14 -08:00
Anees Iqbal 6ae0f8244b rt docs: the identity domains' refusal of a resource bound through a descriptor names the test that reaches it
The runtime README listed that form with no test. tests::reflection_answers (d8efdd3e20) reaches
it: the device's translator refuses the tile pipeline of engine/k10ts_tile_grid with
"unsupported: IdentityDomains (a resource bound through a descriptor)" on lavapipe (job
m3-max-80179) and an RX 7900 XTX (job m3-max-80228), and the test compares that text across every
make.

Docs only. Verified: cargo fmt.
2026-12-02 14:24:14 -08:00
Anees Iqbal aea3a53ea1 rt test: the reflection guard's subjects hold their descriptors boxed, as clippy's large_enum_variant asks
Job m3-max-80136: clippy under m2v_cpu_icd and m2v_gpu flagged the Subject enum's variants'
size difference. Verified: cargo fmt; clippy follows as a job.
2026-12-02 14:24:14 -08:00
Anees Iqbal 480d162ce8 rt test: a tile pipeline's refusal is its answer in the reflection guard, as every make must give the same
The first lavapipe run (job m3-max-80136) panicked at the translator's compile of the tile
pipeline on the device, before any comparison. The tile answer is now the refusal's text where
the translator refuses it, compared like every other answer.

Verified: cargo fmt. The runs follow as jobs.
2026-12-02 14:24:13 -08:00
Anees Iqbal aa2ef691b2 rt test: every make of a pipeline answers its reflection alike
A pipeline's reflection answers must not depend on the make. This test makes each pipeline
seven times:
- three times on one device;
- once on a second device;
- once on a fresh cache directory, which lowers and keeps each translation;
- once on a device after it on that directory, which reads them;
- once in a second process on the directory.
It compares the answers byte for byte.

The pipelines:
- compute states:
  - a tiling kernel;
  - an observing kernel;
  - one with static threadgroup memory;
  - one that declares its thread limit;
  - fold_config, specialized by function constants.
  It compares maxTotalThreadsPerThreadgroup, threadExecutionWidth, staticThreadgroupMemoryLength,
  imageblockMemoryLengthForDimensions:, supportIndirectCommandBuffers and
  requiredThreadsPerThreadgroup.
- render states:
  - one colour attachment;
  - two attachments;
  - made for indirect command buffers;
  - a fragment function specialized by function constants.
  It compares imageblockSampleLength, the memory length and supportIndirectCommandBuffers.
- the translator's tile pipeline of k10ts_tile_grid with threadgroupSizeMatchesTileSize: its
  ComputePipelineMetalInfo and the flag. The runtime makes no tile state.

The device after the first on the directory must read translations, which shows the hit path
ran.

The consumer's row reported reflections that differed between two makes of one identity. Their
logs hold no observed difference, so this test is the property's guard.

Verified: cargo fmt. The lavapipe and card runs and clippy follow as jobs.
2026-12-02 14:24:13 -08:00
Anees Iqbal c55fd4603c Validation: a video picture landed is the surface's mark of the other API's writes, not an acquire
The play calls Surface::external_writes_done once a picture lands on a video surface's pages. That
call records no acquire: each submission part that uses the planes acquires and releases them
itself, and the call marks the other API's writes on the host side. videos.rs' module doc already
said so, but its counter and report line still named the call an acquire, as did
docs/REPLAY-STREAM.md (the `m2v.externalWriteDone` row in section 4, and the video surface
paragraph and its counters in section 10) and the replay test's doc.

The executed counter video_surface_acquires is now video_surface_writes_done, and the report's
`video surfaces` line says "N writes marked done" for "N acquires". Its one reader in the tree is
rt_replay.rs' a_video_surface_is_waited_for_at_its_ready_point_once, updated; no script in the
tree names it (grep for surface_acquires over *.rs, *.md, *.py and *.sh). The count is unchanged:
one a picture landed in a surface.

Wording and naming only; no behaviour changes.
2026-12-02 14:24:13 -08:00
Anees Iqbal 463921d7df rt test: the texture buffer blit test binds its kernel's output at the kernel's buffer slot 0
tb_blit_read declares its output buffer at buffer index 0 (`air.location_index` 0), but the test
bound it at slot 1, so the kernel wrote nowhere and its output read zero. Both blit reads (the
copy out and the buffer's bytes) were already exact on lavapipe at 65ea05bf4a (job m3-max-80061).
2026-12-02 14:24:13 -08:00
Anees Iqbal dd453f5731 rt: a texture buffer's buffer handle is Texture::texel_buffer, apart from TextureObject::texel_bytes
d80c9eb173 named the new inherent method Texture::texel_bytes, which shadowed TextureObject's
texel_bytes (a texel's bytes, u64) where render_encoder.rs reads it for a shadowed attachment, so
the crate did not compile (lavapipe job m3-max-80035). The method is now texel_buffer.
2026-12-02 14:24:13 -08:00
Anees Iqbal 772441372c rt: a blit between a buffer and a texture buffer copies the region's bytes between the two buffers
A guest's 3D model window stayed blank: it fills an RGBA8Unorm texture buffer placed in a heap by
copyFromBuffer:...toTexture:, which BlitCommandEncoder::buffer_copy refused as Gap::TextureBytes
("A texture buffer's texels are its buffer's bytes, which no image copy reaches"). A texture
buffer has no image: its texels are its buffer's bytes from its offset. So a copy between it and a
buffer, in either direction (copy_from_buffer into it, copy_from_texture_to_buffer out of it), is
now checked as any texture's copy is, by the same checker (`buffer_copy`: the region inside its one
row, level 0 and slice 0, Refusal::TextureRegion past it; Metal's measured layout rules,
Refusal::BufferCopyLayout), and then the region's bytes (origin.x and width in texels times the
texel's bytes, at the texture buffer's offset) are copied between the two buffers by
copy_from_buffer_to_buffer. That path keeps both buffers, takes the Managed copies and the heap
places, and orders the copy as any copy between buffers. A texture buffer's uses take its buffer's
id in the hazard sets, so a later kernel's read is ordered after it. The command buffer also keeps
the texture. Two parts of the generic check don't apply: an image's rows or memory meeting the
region (it has none), and a copy command's offset alignment (vkCmdCopyBuffer takes any). The check
runs without them. Bytes of the texture buffer that meet the other buffer's region are
Refusal::BufferCopyOverlap, as copy_from_buffer_to_buffer refuses them.

Gap::TextureBytes's doc drops the texture buffer case and its basis line ("nor a texture buffer's
copy as a buffer copy; no recorded stream copies a texture buffer"), and docs/REFUSALS.md is
regenerated. Buffer::new_texture's doc, copy_from_buffer's and copy_from_texture_to_buffer's docs
and the runtime README's texture buffer contract now say what a blit with a buffer does. The
texture buffer refusal test no longer expects the gap from copy_from_buffer_with_options. A copy
between a texture buffer and a texture (Gap::TextureCopy) is left as it is.
2026-12-02 14:24:13 -08:00
Anees Iqbal 8f6c24c41b rt test: the texture buffer blit test's source words take a name of their own, apart from words()
9d3249b1f8's test named its source words `words`, which shadowed the module's `words` function
its reads call, so the test did not compile (lavapipe job m3-max-79857). Still red at the copy in.
2026-12-02 14:24:13 -08:00
Anees Iqbal afec366ab3 rt test: a texture buffer filled by a blit reads back through a blit, its buffer and a kernel (red)
A guest's 3D model window stays blank: it fills an RGBA8Unorm texture buffer placed in a heap by
copyFromBuffer:...toTexture:, which the runtime refuses as Gap::TextureBytes (blit.rs, buffer_copy:
"A texture buffer's texels are its buffer's bytes, which no image copy reaches"). The test makes
an RGBA8Unorm texture buffer of 64 texels at offset 256 in a buffer placed in a Private heap,
fills the buffer with 0x5a, copies 32 texels of a Shared buffer into texels 16 to 47, copies
texels 8 to 55 out into a Shared buffer, copies the heap buffer's bytes into another, and reads
every texel in a kernel (an owned AIR kernel over texture_buffer<float, read>). Each read must
hold the source's bytes at texels 16 to 47 and 0x5a around them. Red today at the copy in.
2026-12-02 14:24:13 -08:00
Anees Iqbal 5a3e25fb31 Fixtures: dic_post_process's rows in the engine inventory and its printout, blessed on the M3
Blessed with bless_engine_inventory and bless_engine_goldens (job m3-max-80148 on the M3, which has
every assembler) at 066d192863: the fixture's two entries, dic_full_screen and dic_post_process,
compile (ok) on all 15 profiles from both its typed .air.ll and its .ll, and tests/air_input gets
dic_post_process.txt. No other row or printout moved; both bless tests passed.
2026-12-02 14:24:12 -08:00
Anees Iqbal 4d82322e18 rt test: each texture over a buffer takes the form Buffer::texture_copy_cause answered
On every device of the cfg's kind: asked twice, then made, the form equals the answer, and the asking makes no texture and counts no copy. A guest's four textures at offset 32, rows 3648 apart, over a Private buffer (copied for Alignment on lavapipe), and RGBA8Unorm controls over a Shared and a Private buffer at the device's pitch (in place over Shared on every device) and one rounding past it (copied for Pitch everywhere).

The test keeps every texture it makes until it ends. A texture's release is asynchronous, so when
the 3090 dropped one case's texture before the next case asked, the textures gauge moved during
the ask (m3-max-79921, copy_cause.rs:82).

Passed at this change on 4c613f389b, with each case printing its answer and its form:
- RTX 3090 (m3-max-79946): Pitch for the guest's four.
- RX 7900 XTX (m3-max-79947): Pitch for the guest's four.
- Iris Xe (m3-max-79948): in place for the guest's four.
- lavapipe (m3-max-79982): Alignment for the guest's four.
- On all four, the controls were in place at the pitch and Pitch past it.

On the tree rebased onto 8c927efe94 (m3-max-79985), the runtime suite on lavapipe ran 934 tests:
934 passed, 3 skipped.
2026-12-02 14:24:12 -08:00
Anees Iqbal d7e4b5154c rt: Buffer::texture_copy_cause answers whether new_texture makes a texture over a buffer in place
A consumer that keeps its own copy form for textures over a buffer asks rt only where rt would
place the texture in place. The answer is new_texture's own decision, with no texture made:
Device::over_cause takes the descriptor's checks (prepare), check_over, the bind texture() lays
(over_bind, factored out of texture()), and the linear image's fit with and without the feedback
usage (without_loop_where_unfit, which texture() now takes too). The fit is one function, unfit(),
that Made::make and the query both call: the pitch and the memory alignment are the linear image's
own, so the query makes the image new_texture would bind (linear_info, shared with make), reads its
layout and memory requirements, and destroys it, never bound, as minimum_linear_texture_alignment
does. None where in place, else the OverCause its copies count under; a texture buffer is never
copied. The answer holds for the life of the buffer's block.

The runtime README names why a guest's textures at offset 32 with rows 3648 bytes apart copy on
three of the four devices probed: the row rounded up to 128 (RTX 3090) and 256 (RX 7900 XTX) bytes,
and lavapipe's 64-byte memory alignment, from probe jobs m3-max-79849..79852. api_signatures.tsv
blessed; refusal-surface, metal-coverage and conformance-coverage checks pass with no change.

Verified with the next commit's test at this change on 4c613f389b. A guest's four textures over a
Private buffer (offset 32, rows 3648 bytes apart) were answered and made Pitch on the RTX 3090
(m3-max-79946) and RX 7900 XTX (m3-max-79947), in place on Iris Xe (m3-max-79948), and Alignment on
lavapipe (m3-max-79982). The RGBA8Unorm controls were in place at the device's pitch and Pitch one
rounding past it, over Shared and Private, on all four. On the tree rebased onto 8c927efe94
(m3-max-79985), lint passed (generated tables, fmt, clippy plain, m2v_gpu and m2v_cpu_icd, doc and
private doc all exit 0), and the runtime suite on lavapipe ran 934 tests: 934 passed, 3 skipped.
2026-12-02 14:24:12 -08:00
Anees Iqbal f4f5cc33da rt docs: Metal's validation asks ShaderRead and ShaderWrite at every read_write slot; the runtime asks less where the function only writes
The runtime README's rule (Textures: Texture slots and usage), pipeline::slot_usage's doc and
RESOURCE-ID.md's sentence on slot usage said the runtime asks a texture's usage at a slot as
Metal's validation asks it, ShaderWrite alone at a read_write slot the function does not read.
Metal's validation asks both at every read_write slot, by the declared access, whatever the
function does there. Measured on an Apple M3 Max, macOS 27.0.1 (job m3-max-80068, a scratch
probe of runtime-compiled MSL, R32Float 4x4):
- a read_write slot the function only writes, of a ShaderWrite-alone texture, asserts "Compute
  Function(k_rw_write): reads texture (t[0]) whose usage (0x02) doesn't specify
  MTLTextureUsageShaderRead (0x01)";
- one the function only asks the width of asserts the same of 0x02 and the write of 0x01;
- one it only reads asserts the write of 0x01 and the read of 0x02;
- both usages run.
Plain Metal runs every case, and the written one writes its texels.

The runtime keeps its rule: such a slot asks ShaderWrite alone, as its write reaches the texture
through its storage element alone, so a ShaderWrite-alone texture runs there as plain Metal runs
it. The three texts now say what Metal's validation asks and what the runtime asks. They also
name a texture atomic's slot as one that reads. Metal's validation asks both there: a 0x21
texture asserts the write and a 0x22 one the read; 0x03 runs without ShaderAtomic.

Docs only; no behaviour changes. Verified: cargo fmt. Rustdoc runs as a job.
2026-12-02 14:24:12 -08:00
Anees Iqbal 626da2e537 rt test: a copy-form block handed over apart takes the uploads' part and one a member, three vkQueueSubmit2 calls
The test of 12126b64d6 expected one vkQueueSubmit2 a member, two in all. On lavapipe (job
m3-max-79795, llvmpipe, Copy(Pitch { plane: 0 })) the group went as three, with acquires and
releases [2, 2] and B's bytes picture 1's. Three is the design: a group sent member by member
takes one part ahead of the first member's, with the submission's uploads, and one for each
member, and a part left empty is left out (`submit::parts`; the apart count, starts plus one).
Here the over copy into the planes' images is an upload, so the parts are the uploads', A's and
B's. The `read` branch puts the block in the uploads' part, which acquires and releases it once;
A's part takes no hand-over; B's takes one. The Direct3D 11 apart test expects one call a member
because its submissions carry no uploads: its part ahead of the first member is empty and left
out. The test now expects three calls and its doc names the uploads' part; the [2, 2] and texel
asserts stay.
2026-12-02 14:24:12 -08:00
Anees Iqbal d9067a1a24 rt test: a copy-form surface's block is handed over in the first part of a group sent apart, for the upload's copy that reads it
Where a group goes member by member, the uploads' copies into textures over a buffer in a block
another API shares read that block in the first part, which hands it over too (`read` in
submit.rs). No device test covered that: the only test of a group sent apart is Direct3D 11's, on
Windows, whose planes are images with no over copy. On the copy-form row (an opaque handle at a
pitch multiple of 4096) and the 1080p picture, the other device writes picture 1 and the consumer
calls external_writes_done; on one queue behind the busy work, a copy between two buffers that
uses no plane (A) and a blit read of both planes (B) join one group, which goes member by member.
The test asserts two vkQueueSubmit2 calls, one acquire and one release in each part (two of each,
a part handing a block over at most once), B's bytes picture 1's, and no layer message. A device
that takes another form for the row says so and checks nothing. rt_read's blits move into
encode_read, which the new test encodes into a command buffer it commits itself.
2026-12-02 14:24:12 -08:00
Anees Iqbal 003d258843 rt docs: an exported block's textures owe a copy in at external_writes_done's host mark, not at an acquire
Since each submission part that uses shared memory hands it over (acquire at its head, release at
its end), `Block::external_writes_done` records no acquire: it marks the other API's writes on the
host side (`Work::exported_changed`, `ExportedOvers::owe`). ExportedOvers' doc still named "an
acquire" as an event that changes a texture's bytes, as did owe's and exported_changed's docs and
four places in the runtime's README (the copy form's planes "copied at each acquire and release",
"an acquire among them", "after its acquire", "the block's acquire"). They now name the mark, and
say the per-part acquire and release change no byte. Block::external_writes_done,
Surface::external_writes_done and the README's hand-over contract already said so. Wording only;
no behaviour changes.
2026-12-02 14:24:12 -08:00
Anees Iqbal 59d00cd865 Validation: the play's own buffers take each copy-form surface's buffer over its exported block
A surface in the copy form holds a buffer of the runtime's over its exported block
(`Device::copy_form`), which its planes, textures over it, hold too. The play's count of its own
buffers (`NewRuntime::play_holds`) took none of them, so each copy-form surface the program made
between frames 100 and 200 moved `buffers_excess`. The copy-form merge leg's RX 550 (m3-max-79613)
and a rerun on the RTX 5080 Laptop GPU (m3-max-79696, at 2361470bff) failed
the_play_s_own_textures_take_its_video_and_exported_surface_planes on `buffers`: excess 1 at frame
100 and 2 at 200, with both video surfaces copied (Tiling) and both exported surfaces in place.
No leak: the growth is the second video surface's buffer, freed with the surface.

The play now holds one buffer for each video surface in the copy form while the player keeps it
(`Videos::held_buffers`), and one for each exported surface in the copy form while it or a plane
of it the stream holds lives (`Exported::held_buffers`), as the textures term counts their planes.
The test's first exported surface is a dma-buf's, which NVIDIA's dma-buf takes in the copy form,
so the exported term with a plane outliving its surface runs there too.
2026-12-02 14:24:12 -08:00
Anees Iqbal f124b1489f Translator: an access refusal names the structure it met
Feature::Lowering(LowerFamily::Access) with Needs::NotImplemented covered
about 235 refusal sites behind one name, so a walk's log line could not say
which without the AIR. Unsupported gains `cause: Option<Cause>`; an access
refusal carries Cause::Access(AccessCause), one variant per structure the
sites refuse: the access's shape, the type it moves or the memory it
reaches. Sites that refuse the same structure share a variant, wherever
they are; none is named by a file, a line or a string of its own.

The five helpers that build the refusal (lower/access/mod.rs refuse() and
memory/{alloca,leaf,plan,provenance}.rs not_lowered()) take the cause, so
the compiler makes every site name one; the three direct constructions in
memory/handles.rs and lower/access/handle.rs do too, through
Unsupported::access. Feature stays Lowering(Access), so validation's
outcome key (feature_key, the Debug of the feature) and the census are
unchanged. Display prints the cause after the feature:
"Lowering(Access): PointerStore; needs NotImplemented at ...".

Storage: nothing stores the cause. Validation keys a refusal by
feature_key(&u.feature) (engine.rs); a FALLBACK repro bundle keeps the
failure as text (repro.rs, whose only serde record is the device); the
runtime's cache marks a refused translation with fixed bytes. No version
bump.

A buffer argument of a count other than one outside an argument table
names BufferArray, apart from an index or count the metadata does not fix
(UnfixedLocation).

Tests: the error module's Display test of an access refusal; the plan's
table gaps assert ArgumentTable, and its typed-depth, initializer and
buffer-array refusals PrivateType, Initializer and BufferArray.
runtime-sources.sha256 rewritten: memory/handles.rs's two refusals name
their cause, and no run behaves otherwise. api_signatures blessed (Cause,
AccessCause, Unsupported.cause), api_surface lists the two enums,
REFUSALS.md regenerated (the access refusals are built in error/mod.rs),
docs/API.md's error table names the field.

Consumer uses (consumer-uses.sh, read-only, plus git grep, over the
consumer's development 22cfe51a54 and its lane tips of the last day): no
struct literal or exhaustive destructuring of the translator's Unsupported
("Unsupported {" hits only its video crate's own Unsupported(String),
codec/encode.rs:494-502). Its rt platform builds refusals in tests with
Unsupported::not_implemented (rt_platform/diag.rs:3076, 3078, 3490;
rt_platform/unbuilt.rs:1203, 1293), whose cause is None, so their keys
("Translation-Lowering") hold. It reads u.feature where it names a refusal
(rt_platform/diag.rs:1082) and where it says one (rt_platform/unbuilt.rs:
507); each shows the cause once it reads u.cause too.
2026-12-02 14:24:11 -08:00
Anees Iqbal 8cbec0d80b rt test: every device makes a post-process state of two stage-in buffers and bool constants
The shape of the render pipeline state a guest's model viewer had refused
as a draw input (RenderPipelineKind::DrawInput), from our own MSL:
dic_post_process.metal's full-screen vertex function reads a float4 at
attribute 0 and a float2 at attribute 1, which the test's vertex descriptor
fetches from buffers 0 and 5 at strides 16 and 8, and its fragment function
samples a texture and changes the colour under bool function constants 0, 1,
3 and 4 (set false, true, false, true), into one RGBA16Float colour.

The companions come from scripts/regen-air-fixtures on the oracle Mac's
toolchain (job m3-max-79796; TOOLCHAIN records it). The engine fixture
expectations' bless is due on development for the new fixture.
2026-12-02 14:24:11 -08:00
Anees Iqbal 1cc16eb4da rt: a draw-input refusal names its cause
RenderPipelineKind::DrawInput covered a dozen causes behind one name, so a
walk's log line could not say which without the AIR. It now carries
DrawInputCause, one variant per reason the runtime's draws() (and the
constexpr numbering it hands its gap to) refuses a render pipeline state's
input for:
- pointer translation, handle translation, a descriptor set that is not the device's
- a slot, fact, sampler or pushed parameter of a stage other than vertex and fragment
- a runtime fact the encoder does not supply, by its RuntimeFact::name
- a slot the encoder does not bind (a visible or intersection function table)
- a push field the encoder does not fill
- the stride of a layout of MTLBufferLayoutStrideDynamic
- a constexpr sampler the state does not hold, and an unnormalized one
- a parameter block past one ring chunk, and one without its pushed address
- pushed bytes past the device's push window

The variants follow KernelInputKind's names where a cause is the same.
Gap's Display shows the cause ("a render pipeline state with DrawInput
{ cause: Slot } is not built"), so the conformance ledger's seven DrawInput
rows now name theirs: DynamicStride for the indirect vertex-stride case,
Slot for the visible-table stage cases. The icb_stage_in test asserts
DynamicStride.

api_signatures blessed (DrawInputCause and its variants; DrawInput's
signature). REFUSALS.md regenerates unchanged at this base.

Consumer uses (consumer-uses.sh, read-only, over the consumer's
development 22cfe51a54 and its lane tips of the last day): one
construction of RenderPipelineKind::DrawInput, in a test of its rt
platform (rt_platform/diag.rs:3494, on development and ten lane tips),
which needs `DrawInput { cause: .. }`; no match on the kind's fields
("DrawInput {" 0 code hits; its IndirectCommandBuffers-DrawInput keys are
another enum's). Its refusal name keys every RenderPipeline gap by the
gap's variant alone (rt_platform/diag.rs:1074), so its counts line names
the cause once an arm for DrawInput { cause } precedes that one.
2026-12-02 14:24:11 -08:00
Anees Iqbal c1f999eb06 rt: pipeline states answer Metal's allocatedSize as their translated SPIR-V's bytes
ComputePipelineState::allocated_size and RenderPipelineState::allocated_size
answer MTLAllocation's allocatedSize, which both Metal pipeline states adopt.
The answer is our code's size, not the driver's compiled binary, which the
runtime does not measure. A compute state answers its kernel's module, the
one its interface is read from. A render state answers its stages' modules,
summed. Both numbers are taken from the translation when the content is made
and kept as a u64 in the content (a compute content's Answers, a field of
RenderCompiled); no module is kept for them. Every device takes the same form.

No variant counts: not the emulated-SIMD-group or partial-threadgroups
variant lowered with a compute state, not one made at a dispatch (the
emulated-partial variant), and not a render content made later for a pass.
So the answer never changes once a state is made, and two states of one
content answer one size.

docs/API.md's accepted differences (Heaps and memory) gets the entry.
MTLAllocation.allocatedSize stays missing in the coverage ledger: buffers,
textures and heaps still lack it. Its note now names the pipeline states'
answers, and docs/METAL-COVERAGE.md is regenerated. api_signatures.tsv is
blessed with the two methods.

Tests:
- state_answers: a new test. block_scan (plain module) and sample_down
  (partial-threadgroups variant) answer non-zero. Each equals the bytes of
  the module the state keeps (a test-only Kernel::module_bytes). The
  render state of first_texel_fragment answers the sum of the translator's
  compile_render_pipeline stages' SPIR-V lengths. Two states of one content
  answer one size.
- translate.rs: the ragged-grid test on emulated SIMD groups now also checks
  that a state's answer is the same after the dispatches that make the
  variant later.

Verified: job m3-max-79929 on lavapipe, a check of this tree.
- signatures --check, coverage --check, clippy (plain, m2v_gpu,
  m2v_cpu_icd), workspace doc and the runtime's private doc: all 0.
- The runtime suite: 928 passed, 3 skipped.
- The two tests rerun with output: both pass. On lavapipe the variant
  already emulates its SIMD groups, so the ragged test makes nothing at a
  dispatch there. No card run yet.
2026-12-02 14:24:11 -08:00
Anees Iqbal 2ae50d2fd5 rt: a draw supplies the vertex amplification count
draws() refused a state whose function reads [[amplification_count]]
(RuntimeFact::AmplificationCount) as DrawInput, though the state's creation
already fixes the fact's SpecKey::AmplificationCount constant at 1 in each
stage's module. 1 is every draw's count: the runtime makes no state whose
maxVertexAmplificationCount is above 1
(RenderPipelineKind::VertexAmplification), and its render encoder sets no
count, so each draw has Metal's default. draws() now names the fact as
supplied, beside the sample count it fixes the same way.

This is the cause of a guest's model viewer's five refusals of three
post-process states in a walk (job m3-max-79894, XTX/RADV, where the
typed cause named it).
2026-12-02 14:24:11 -08:00
Anees Iqbal 8ad387cc0f rt test: every device draws a vertex function that reads its amplification count (red)
A guest's model viewer leaves its window blank because the runtime refused
its post-process states as RenderPipelineKind::DrawInput: their vertex
functions read [[amplification_count]], and draws() named no such fact as
supplied. The fact is RuntimeFact::AmplificationCount, as the typed draw
input cause on steelbrain/fix-rt-causes printed over the walk's refused
states (job m3-max-79894, XTX/RADV).

The owned fixture engine/vertex_amplification.ll's amp_vertex_store reads
[[amplification_count]] and [[amplification_id]] and stores both; drawn
with rasterization disabled in a state whose maxVertexAmplificationCount
is 1, each vertex must write (1 << 16) | 1 to word vid * 8. Red here: the
state's creation refuses it as DrawInput.
2026-12-02 14:24:11 -08:00
Anees Iqbal 06d2d22bf7 Translator: a library keeps each module in an allocation of its own, and a function keeps its module, not its library
A pipeline state keeps its descriptor's functions to lower its later variants from, and a
function held its whole library through an Arc: a guest that made a state of one function of a
metallib of many, then released the library, kept every module of it alive as long as the
state lived.

At load, a library now splits the one copy it makes of the loaded bytes: each module (each run
of bytes one or more functions' bitcode covers, so functions over one module, as a Core Image
kernel library's or a dynamic library's exported functions, share one) in an allocation of its
own, and every other byte (header, function list, metadata, other sections, padding) in one
more. A function holds its library's function table (rows, content hash, type, install name,
dependencies), its own module's allocation and its index, and the library weakly. So a state
keeps exactly its functions' modules whether the library lives or not: while it lives, the
same allocations the library holds, each module once; nothing is copied at a state's make.

Public changes (api_signatures.tsv, docs/API.md, the doc comments):
- Library::bytes() returns an owned Vec<u8>, assembled from the allocations, equal byte for
  byte to the loaded bytes (of a universal file, its AIR slice, as before); content_hash() is
  their SHA-256, computed at load as before.
- Function::library() returns Option<Library>: the library while a Library value of it lives,
  None after; MTLFunction names no library either.
- Function::library_content_hash() (new): the library's content hash, kept with the table.
- Function::bitcode() (now public, infallible): the function's own module (a metallib
  function's wrapped module, a bare module's whole module, a dynamic library's one module); its
  doc says the bytes are the guest's shader, never committed or sent anywhere.
- Function's PartialEq and Eq: equal tables (each holding its library's content hash) and
  indices.
The translator's own uses of a function's library read the table (compile.rs's dependency
order and EntryNotFound's count); linked_sources no longer fails.

The consumer's call sites (reims-vgpu development 53e7385993, read only; search: git grep -n -E
'\.(bytes|library)\(\)' over crates/reims-vgpu-vulkan and crates/reims-vgpu, and \.library\(\)
over the whole tree; every other hit is a string's, a NAL's, a staging buffer's or
graphics().library()): crates/reims-vgpu-vulkan/src/rt_platform/diag.rs:1860 and :1863 (the
kept-AIR bundle: the container while the library lives, else the function's own module through
bitcode(), the line naming which), diag.rs:1934 (FunctionName::of: library_content_hash()),
diag.rs:3495 (test; unchanged, the bytes compare equal) and unbuilt.rs:653 (test; a function
keeps bitcode().len()).

Tests: the red test's two states (lavapipe; their test accessors now read a kept function's
library where it lives, else its own module); a_live_library_and_its_states_hold_each_module_once
(two compute states and a render state share the library's own allocations);
tests/library_modules.rs: bytes() equals the loaded input for a plain metallib, a Core Image
kernel library (shared module), a dynamic library, each universal header and a bare module, the
content hash their SHA-256; a function holds its module (one allocation per module, shared over
a shared module), names no library once it is released, keeps the content hash and compiles
under the same keys to the same words. The runtime's README says what a state keeps.
2026-12-02 14:24:11 -08:00
Anees Iqbal 6e70ad687c rt test: a pipeline state keeps no more of a released library than its functions' modules (red)
A compute state keeps its descriptor to lower its later variants from, and a render state keeps
its descriptor to make a pass's content from; each function there holds its whole library. A
guest that makes a state of one function of a metallib of many, then releases the library,
leaves every module of that library alive as long as the state lives.

Two device tests, each over a metallib of one function and four other kernels, each entry over
a module of its own as Apple's toolchain writes one: a compute state of the kernel pool_reach,
and a render state of a bare module's colored_vertex with the metallib's fragment
a2_front_facing. Each makes the state, drops the libraries and the descriptor, and asserts the
state keeps no more of the metallib than its function's own module (plus 1 KiB); the render
test also asserts the bare module's vertex function stays whole. Test-only accessors on both
states read the bytes kept.
2026-12-02 14:24:11 -08:00
Anees Iqbal e160098eda rt README: Metal makes a texture buffer of formats the runtime refuses
The known gaps of textures say which formats Metal makes a texture
buffer of where the runtime answers Gap::TextureFormat. Plain Metal on
an Apple M3 Max under macOS 27.0.1 (jobs m3-max-79872 and m3-max-79879,
the same answers both runs), asked for each of the 300 formats the
runtime names, over a buffer and from the device, for reading, writing
and both, made one of 99, ended the process for 125 and answered nil
for 71. The runtime's refused sets come from texel_form and the
committed vulkaninfo profiles, not from a card run, and the README
says so. Docs only; no refusal or public item moves.
2026-12-02 14:24:10 -08:00
Anees Iqbal cdadbc8d2f api_signatures.tsv: Metrics' translations_at_encode and translation_at_encode_max_nanos
The widened counter replaced variant_translations_at_dispatch; the table was
not blessed with it (the_public_signatures_are_the_committed_table failed in
the translator suites, job m3-max-79131).
2026-12-02 14:24:10 -08:00
Anees Iqbal e0f63843c4 replay: the longest translation at encode is an end line, not a frame's counter
translation_at_encode_max_nanos is a maximum since the device was made, so a
frame's difference of it means nothing: the report gives it once, as
`translation at encode longest N ns` beside the commit lock's, and keeps
translations_at_encode among the executed counters.
2026-12-02 14:24:10 -08:00
Anees Iqbal adc68cb356 rt tests: dispatches racing for the partial-threadgroups variant on emulated SIMD groups lower it once
Four threads dispatch wps_uint_k40_s32's ragged grid at threadgroups of 48
at once, each through its own queue and buffers: where the kernel's
partial-threadgroups variant runs only whole SIMD groups, one lowers the
variant on emulated SIMD groups and the rest wait for it in its OnceLock
(translations_at_encode moves by 1); every racer's whole SIMD groups have
the CPU's words.
2026-12-02 14:24:10 -08:00
Anees Iqbal 5a16277eb3 rt: one counter for every translation made at encode, with its longest make
The planner widened the counter of the fourth variant made at dispatch to
every translation made at encode, named once: Metrics::translations_at_encode
counts the makes, made or refused, and translation_at_encode_max_nanos holds
the longest (a maximum since the device was made, as maker_wait_max_nanos).

Its sites, each a module or content the state's creation did not make, made on
the encoding thread that waits for it:
- an observing kernel's partial-threadgroups variant on emulated SIMD groups
  lowered by a dispatch (not by prepare_dispatch);
- a compute state's content for a dispatch's buffers bound at a multiple of 4
  below their alignment, or its 8-bit sRGB textures' UNORM twins
  (PipelineInner::variant, one function for both);
- a render state's content for a draw's buffers bound so (for_words);
- a render state's content for a pass it does not render into as made
  (for_pass: a colour attachment the pass lacks, or a fetched colour in a 2D
  array).
The first replaces variant_translations_at_dispatch. A content the map of
contents holds is a reuse and counts nothing; one it forgot counts again. The
replay's metrics report both fields.

Tests: each site counts one make at its first need and none at a reuse:
the word-bound compute variant (and again for a second mask and a forgotten
variant), the sRGB variant, the word-bound render content per draw case, the
pass content of a lacking pass, and the fourth variant's dispatch (with the
maximum above 0).
2026-12-02 14:24:10 -08:00
Anees Iqbal c7f9a58f6e rt: decide's kernel borrows from the content, not from the need
The need now carries the state's descriptor, so the elided lifetime of
decide's returned kernel no longer has one source.
2026-12-02 14:24:10 -08:00
Anees Iqbal fc9ebee2fc rt: a ragged grid at a threadgroup of partial SIMD groups runs the partial-threadgroups variant on emulated SIMD groups
An observing kernel whose partial-threadgroups variant runs only whole SIMD
groups (a subgroup tier) refused a dispatchThreads grid that is not whole
threadgroups at a threadgroup that is not whole SIMD groups
(Gap::PartialThreadgroups, site SimdGroups). The translator now lowers the
partial-threadgroups variant on emulated SIMD groups, so the runtime runs it.

What: a fourth KernelVariant, EmulatedPartialThreadgroups, in ALL, whose
inputs set both partial_threadgroups and emulated_simdgroups. The state's make
does not lower it (the planner's form: made at the first dispatch shape that
needs it). Compiled holds its inputs and a OnceLock for its lowering, made
for a content whose partial-threadgroups variant runs only whole SIMD groups.
encoder::decide takes a Need: prepare_dispatch and a dispatch lower it from
their state's descriptor, once, a racing thread waiting in the OnceLock; the
state's make and dispatch_variant read keys and lower nothing. A dispatch's
lowering counts in Metrics::variant_translations_at_dispatch (also in the
replay's metrics), which a pre-pass that prepares every dispatch keeps at 0.
The lowering is lower_variant's, the same bounded translation through the
cache directory as every variant's; the translator's refusal of it stays the
dispatch's Gap::PartialThreadgroups { site: SimdGroups }, any other failure
is reported as itself. Its dispatches count as emulated SIMD-group
dispatches and partial-variant ragged grids. Compiled's drop releases it.

Docs: prepare_dispatch's and dispatch_variant's docs, the counter's, the
SimdGroups site's, the runtime README (which variant is made when, the gap's
narrowed scope); api_signatures.tsv re-blessed.

Tests: every_device_runs_a_ragged_grid_of_partial_simdgroups_on_emulated_simdgroups
and every_device_frees_a_ragged_grid_s_modules_with_its_content now also read
the counter: 1 for k24_s32's first dispatch on a subgroup-tier card, 0 after
k8_s48's prepare_dispatch, 0 where the variant emulates its SIMD groups
already.
2026-12-02 14:24:10 -08:00
Anees Iqbal adfd60f805 rt tests: a ragged grid at threadgroups of partial SIMD groups runs on emulated SIMD groups (red)
wps_uint_k24_s32 and wps_uint_k8_s48 over dispatchThreads grids of 184
threads in threadgroups of 48: each threadgroup one whole SIMD group and a
partial one. Where the kernel's partial-threadgroups variant runs only whole
SIMD groups (a subgroup tier), the dispatch is refused today with
Gap::PartialThreadgroups { site: SimdGroups }. The tests want the grid run on
emulated SIMD groups, the whole SIMD groups' words equal to the CPU's, the
words past the grid untouched, a prepare_dispatch ahead of k8_s48's
dispatches, and the map of compiled contents, filled past a cap of 1, freeing
the first content's modules with its state.

Red on a subgroup-tier card; passes where the variant emulates its SIMD
groups already (lavapipe, the Intel GPUs).
2026-12-02 14:24:10 -08:00
Anees Iqbal 819d811015 rt README: the Iris Xe places a texture in a Shared heap too
The known gaps of textures named lavapipe and the Radeon 780M as the
devices whose optimal images take the Shared memory type. The Iris Xe
(Mesa 26.2.6) takes it as well: its run of the rt and harness heap,
Shared-heap sampling, export and churn_rest tests at development
30e7be6aff's product code (archive m3-max-79814, run m3-max-79854)
placed a source and a target in a Shared heap, wrote, read back and
sampled them, and churn_rest held every gauge with the kind included.
The same archive on the RTX 2080 (m3-max-79855) took the refusal path
and passed, heap.rs's Shared-descriptor size queries included, and on
the Radeon 780M (m3-max-79856) placed and sampled them: 8 of 8 each.
2026-12-02 14:24:09 -08:00
Anees Iqbal 9e510fa042 rt README: a Shared heap's texture on a discrete device reads and writes across its link, 97 times as long on the RX 7900 XTX
This is the timed row the ruling on Shared heap textures asked for. It was taken on the RX 7900 XTX
(RADV, Mesa 26.2.6, job m3-max-79841), behind a PCIe 4.0 x4 link. That is the narrowest link
upstream of the card: the bridge at 16 GT/s x4. The test is a helper branch's own and does not
land.
- The harness's sample_down kernel sampled a 4096 by 4096 RGBA16Float texture (128 MiB) into a
  2048 by 2048 target, 10 dispatches in each command buffer.
- The texture was placed once in a Private heap and once in a Shared heap, with the same
  descriptor.
- 7 command buffers of each were alternated in one job. The GPU spans are the command buffers'
  own GPU start and end times.
- Private: median 2.099 ms (2.093 to 2.103).
- Shared: median 203.136 ms (203.079 to 203.184).
- The ratio is 96.8: about 640 GB/s against 6.6 GB/s, the link's rate.

A first run (job m3-max-79822) filled the texture with one repeated texel. Its Private arm read
1.28 GB in 0.458 ms, faster than the card's memory, because the image compresses a constant
texel. The row above uses texels from a xorshift64 sequence, which nothing compresses.

The NVIDIA cards place no Shared heap texture (the bullet above), so this cost is the discrete
AMD case. Nothing works around it, as the ruling says. A Mac whose Metal makes Shared heap
textures has unified memory, where the cost does not arise.
2026-12-02 14:24:09 -08:00
Anees Iqbal 0631128baf rt README: a Shared heap's texture is expected to be Gap::HeapTexture on the RTX 3090 too, not run
The RTX 2080 refused it (job m3-max-79682) because its optimal images take no Shared memory type.
The 3090 runs the same NVIDIA driver (620.70.06) and was not run, so the known gap says expected,
as the planner asked.
2026-12-02 14:24:09 -08:00
Anees Iqbal ac220d6f52 rt: the heap size query answers every storage mode alike; a Shared heap's texture is refused at its placement where the image takes no Shared type
On the RTX 2080 (NVIDIA 620.70.06, job m3-max-79682) the device's optimal images take no Shared
memory type. Two things followed from that:
- The parent commits' size query, which checked a Shared descriptor against the Shared type,
  refused Shared descriptors there. heap.rs's two Private-block tests size Shared descriptors, and
  both failed at their size query.
- A guest that sizes a texture with a Shared descriptor would have lost an answer it had before.

The size query now checks the Private type for every descriptor, as it did before this series.
Its answer does not depend on the storage mode. The Shared type is checked where the texture is
placed in a Shared block, and the placement is Gap::HeapTexture where the image does not take
it.

Follow-on changes:
- The Shared-heap device test expects the size query to answer on every device and the placement
  to be refused exactly where `Device::heap_image_fits` says the image does not take the Shared
  type.
- The conformance side holds a Shared query to the placement and read-back steps in a Shared heap,
  and to step 1 where that placement is Gap::HeapTexture (docs/API.md section 10 says so).
- churn_rest finds out once, by placing a texture for views in a Shared block and releasing it,
  whether the device places its Shared heap texture. Where it does not, the row leaves the kind
  out, naming it with the reason.
- The rt README's known gaps of textures name where a Shared heap's texture is placed: lavapipe
  and the Radeon 780M take it (jobs m3-max-79654 and m3-max-79685); the RTX 2080 does not. The
  Gap::HeapTexture doc says the same.

Ledger: the five rows of the RGB10A8_2P_XR10 heap cases (texture-fills-550, texture-fills-551,
texture-fills-heap-run-550-b5, texture-fills-heap-run-551-b5 and two-plane-heap-blits) take the
Err the replay at 1e1c3f39b8 pasted (lavapipe, job m3-max-79680). Their Shared heap no longer
refuses first, so the format's own Gap::TextureFormat answers. Their venue stays *, since the
format check comes before the placement on every device, and their justification already names
Gap::TextureFormat. CONFORMANCE-COVERAGE.md is regenerated and unchanged.
2026-12-02 14:24:09 -08:00
Anees Iqbal 220a7a6660 Harness: churn_rest places a texture in a Shared heap in each iteration, reads it by a blit and releases it
The gauge loop covers the new kind's release, as the ruling on Shared heap textures asks. Each of
churn_rest's 200 iterations:
- takes a Shared block of its own, of the texture's size rounded up to its alignment, at which
  such a block starts;
- places a 64 by 64 RGBA8Unorm texture of shader-read usage there by new_heap_texture, at the next
  index;
- copies it into the row's Shared scratch buffer in the blit encoder that reads the texture over
  the exported block;
- drops the texture and the block with the rest.
The gauges read at the 100th and 200th iterations and at the drop then include the heap texture's
texture and Shared block.

Where the device does not place the texture (the size query is Gap::HeapTexture), the row leaves
it out from the start and names it with the reason, as it does an export the device lacks.

Verification is to follow: the harness's churn_rest test on lavapipe and on one card per vendor.
2026-12-02 14:24:09 -08:00
Anees Iqbal 0caee8b62f rt test: heap.rs's Private-block tests keep their Shared descriptors, which replace_region and get_bytes take
The red commit set these two tests' descriptors to Private, the mode of the block they are placed
in. replace_region refuses a Private texture, so both tests failed at their first write on
lavapipe (jobs m3-max-79642 and m3-max-79644, heap.rs:106 and :229). They take back the Shared
descriptors they had. The runtime does not check a descriptor's mode against its heap's; the
consumer refuses that mismatch as Metal does.

The size query sizes a Shared descriptor against the Shared type now. That changes nothing on a
device whose optimal images take both types. On lavapipe the Shared-heap test placed and sampled
its textures at the fix commit (m3-max-79644), so its images take the Shared type.
2026-12-02 14:24:09 -08:00
Anees Iqbal 13951e8daf rt: a texture is placed in a Shared heap as in a Private one, where the device's image takes the Shared type
Metal places textures in a Shared heap: the M3 Max makes them, in automatic and placement heaps
(job m3-max-79576). The runtime refused every texture in a Shared block as Gap::HeapTexture. Now
new_heap_texture and new_heap_texture_for_views bind the device's optimal image in a Shared block's
memory exactly as in a Private block's. That is one form, with no linear image and no copy.

- heap_source refuses an exported block alone, whose memory is dedicated to its buffer.
- heap_fit takes the heap's memory class. At the placement, the class is the block's (Bind::Heap
  carries it). At heap_texture_size_and_align, it is the class the descriptor's storage mode names:
  Shared for Shared, Private for any other, as before.
- Gap::HeapTexture stays typed for an image the device requires an allocation of its own for, or
  whose memoryTypeBits leave out the heap's type, at the size query and at the placement. The
  consumer counts it.

The host reaches such a texture as any texture's, through replace_region and get_bytes. Their
copies go through the GPU and flush or invalidate only their staging bytes. The block's mapping
over the image holds the device's own layout, so the image's range needs no flush or invalidate of
its own. A command buffer that uses the heap (use_heap) flushes and invalidates its whole Shared
block, as it did for the heap's buffers.

Nothing in the runtime asks which Mac the guest has. Whether a guest may make a Shared heap at all
is the consumer's decision; the runtime has no heap object and hands a Shared block to any take.

Docs:
- the rt README's heap paragraph covers Shared heaps;
- the Gap::HeapTexture doc is updated, and REFUSALS.md regenerated;
- docs/API.md's heap-size entry: a Shared descriptor is now held to the placement and read-back
  steps in a heap of a Shared block, as the conformance side's heap_sizes::hold now does;
- the known-gap sentence of the UHD 630 Windows texel-buffer refusal gains its trigger: a second
  device above the floor whose formats lack those buffer features, or a walk that meets the
  refusal.

The test is the parent commit's. Verification is to follow in the handover: lavapipe red then
green, one card per vendor, the gate, and the conformance replay.
2026-12-02 14:24:09 -08:00
Anees Iqbal b32fc6677a rt test: textures placed in a Shared heap are written, read back and sampled where the device's image takes the Shared type (red)
Metal places a texture in a Shared heap on the M3 Max, and the runtime refuses every texture in a
Shared block as Gap::HeapTexture. The new device test
`every_device_samples_textures_placed_in_a_shared_heap` (sampling.rs) does two things:
- Where the device's image of a Shared RGBA16Float descriptor takes the Shared memory type with
  no allocation of its own (the Vulkan query, through the test helper `Device::heap_image_fits`),
  it places a source and a target first-fit in a Shared block's heap by the size query's answers
  and checks that nothing is allocated. It writes the source by replace_region, reads it back by
  get_bytes, and samples it into the target with the harness's sample_down, checking the linear
  filter's mean.
- Where the query excludes the type, it checks that the size query and the placement are
  Gap::HeapTexture.

The two Shared-heap refusal pins in heap.rs go, and that file's descriptors take the Private mode
of the heap they are placed in, as Metal asks. The exported block's pin (export.rs) stays.
heap_texture_size_and_align's image query moves into `heap_image_requirements`, which the test
helper shares; heap_fit takes the dedicated answer as a bool. Neither changes behaviour.

Expected red on lavapipe: the source's placement in the Shared block is Gap::HeapTexture.
2026-12-02 14:24:09 -08:00
Anees Iqbal a6efc7ab79 rt README: the mixed-pass plane copies' known gap gives measured figures
The known gap for a pass that mixes a linear-only surface plane with another attachment gave a
worked 1920x1080 example. It now gives what was measured on the RTX 3090 (job m3-max-79781): a
guest's screen recording of 1676 frames renders one such pass a frame (a 3648x2038 R8Unorm luma
plane beside a 3648x2038 RG8Unorm colour attachment, both loaded and stored), paying 1676 copies
in and 1676 out of 7,434,624 bytes each (12.46 GB each way), with at most 8 stand-ins of
59,768,832 bytes. The planner ruled no form change for this pass: the forms that drop the copies
run fragment side effects twice, grow rule 3's exceptions, or trade one workload for another.

Docs only; no build.
2026-12-02 14:24:08 -08:00
Anees Iqbal 86386c4873 Refusal surface: --check compares the totals, and REFUSALS.md counts Refusal::TextureUsageAtSlot
docs/REFUSALS.md listed 89 runtime Refusal variants but its two totals tables still counted 88
(and 24 metal-measured where there are 25). A union of two branches' rows keeps every variant row
and one side's totals, and --check compared only the variant rows, so it passed. The totals count
variants alone (no sites, no line numbers), so they are structural: --check now compares them too.

Verified locally (plain script, no build): with the old REFUSALS.md, --check exits 1 naming the
two stale Refusal totals rows; after regeneration it exits 0. The regeneration changes only those
two rows; basis.rs is unchanged.
2026-12-02 14:24:08 -08:00
Anees Iqbal b723c90272 rt: Device::default_sample_positions answers getDefaultSamplePositions:count:
The runtime answered no default positions (its README's known gap). Device::default_sample_positions
answers a count with the positions a pass of that many samples that sets none rasterizes at:
Vulkan's standard sample locations, which the floor's standardSampleLocations makes every such pass
take, and which are plain Metal's answers at 1, 2 and 4 samples on an Apple M3 Max, macOS 27.0.1
(probes/default_sample_positions.m, m3-max-78953). supports_texture_sample_count answers at most
1, 2 and 4, so no other count is answered. A count it does not answer is
Refusal::DefaultSamplePositions (basis metal-measured: plain Metal asserts "count (n) is not
supported on this device." and ends the process, at 0, 3, 5, 6, 8, 16, 17, 32 and 33 on the M3).

README (the device's answers; the sample-positions gap sentence), coverage.tsv (I), and the
generated REFUSALS.md, basis.rs, api_signatures.tsv, METAL-COVERAGE.md and CONFORMANCE-COVERAGE.md.

Verified on lavapipe, job m3-max-79650: clippy, doc and private doc EXIT=0; the runtime suite 923
passed, 3 skipped. Metal's answers: m3-max-78953 (Apple M3 Max).
2026-12-02 14:24:08 -08:00
Anees Iqbal 1e92b0a71e rt test: getDefaultSamplePositions:count: answers Metal's positions, and a pass set to them is one set to none (red)
Plain Metal's answers on an Apple M3 Max, macOS 27.0.1 (probes/default_sample_positions.m, job
m3-max-78953): (0.5, 0.5) at 1 sample; (0.75, 0.75), (0.25, 0.25) at 2; (0.375, 0.125),
(0.875, 0.375), (0.125, 0.625), (0.625, 0.875) at 4; and for 0, 3, 5, 6, 8, 16, 17, 32 and 33, which
the M3 does not render, the assertion "count (n) is not supported on this device." ends the
process, with or without the validation layer.

- placed::the_default_positions_are_metal_s_at_each_count_it_renders: the standard locations the
  runtime answers with are those values, bit for bit.
- on_device::every_device_answers_metal_s_default_positions_and_a_pass_set_to_them_is_one_set_to_none:
  on every device, Device::default_sample_positions answers them at each count the device renders
  and Refusal::DefaultSamplePositions at every other count; a pass of that count that sets them,
  under a triangle whose slanted edge crosses the target's pixels, resolves to the same bytes as one
  that sets none.

Red: the runtime has no such method or refusal yet, so the tests do not build (job named in the
next commit).
2026-12-02 14:24:08 -08:00
Anees Iqbal 24fa970780 Conformance probe: what Metal answers for getDefaultSamplePositions:count: at each count
A probe of plain Metal's answer at counts the device renders and counts it does not, each count
in its own process so a validation stop ends only that count, the reference the runtime's answer
is read against. Run on the M3 oracle in the commit that adds the runtime's answer.
2026-12-02 14:24:08 -08:00
Anees Iqbal 38306b95ba rt test: a fragment's SIMD-group fills read only words of the draw, on every device
fragment_simd_fills (engine/gsm2_quad_ops.ll), whose shuffles-and-fills read other lanes of its
simdgroup, is now drawn over a whole 8 by 8 RGBA32Float target cleared to -1 on every device with
shaderQuadControl. Every channel of every pixel must be a word some pixel of the draw holds: its
index_at or that plus 10000. A lane that takes no part gives no promised value, but never one no
invocation holds.

The point is lavapipe. Its fragment subgroups are 8 lanes (4 on arm64), and no card's fragment
stage is narrower than 32, so lavapipe is the one device that takes the translator's
PartialFragment tier. There, a fill whose source is a Metal lane at or above the subgroup's size
reads the calling lane's word without naming that lane, testing the source against the
SubgroupSize builtin. Until now only translation tests (spirv-val, and an interpreter on a
synthetic 4-lane profile) covered that lane-naming branch; no device drew it. On such a device the
test also asserts that the fragment stage reads SubgroupSize, so the run shows the tier ran.

The draw of the existing 32-wide lane test moves into a helper both tests share.
2026-12-02 14:24:08 -08:00
Anees Iqbal a3a91a10f2 Conformance ledger: the Accumulate cases' rows as the replay of the Reset answer gives them
The rows of visibility-boolean-accumulate, visibility-counting-accumulate (both),
visibility-counting-accumulate-one-command-buffer and visibility-counting-accumulate-revisit
named the Gap::Draw{AccumulatedVisibilityResults} refusal, which is gone. The conformance
replay on lavapipe at efa04c576a (job m3-max-79548) read those five rows as fixed and gave
six in their place, pasted as it printed them with the venue widened to every venue, as the
rows they replace were:
- divergent at case/pass-0/words and case/pass-1/words of the Boolean and the Counting
  shapes, and at case/pass-1/words of the one-command-buffer shape: Metal on the M3 Max adds
  into the words, the runtime writes each result in place of its word;
- refused at case/pass-0/calls/0-render of the revisit shape: its first mode is now taken,
  so the second mode at the same offset meets Refusal::VisibilityResultOffsetTaken, the
  refusal of visibility-counting-revisit's row, whose text it takes.
No other row moved in that run. docs/CONFORMANCE-COVERAGE.md regenerated.
2026-12-02 14:24:08 -08:00
Anees Iqbal ce471296d5 rt: an Accumulate pass writes its visibility results as a Reset pass does, on every device
set_visibility_result_mode refused Boolean and Counting in a pass whose
visibilityResultType is Accumulate (Gap::Draw{AccumulatedVisibilityResults}, counted in
Metrics::accumulated_visibility_refused). MTLRenderPass.h documents Accumulate in one
sentence, "Accumulate visibility results data across multiple render passes." Measured
(the conformance recordings, values.rs VisibilityResultType): Metal on an Apple M3 Max
(macOS 27.0.1) adds a Counting result into the word's low 32 bits and ORs a Boolean one,
while Metal on a Radeon Pro 5300M and a UHD Graphics 630 (macOS 26.7.1) writes it in
place of the word, as Reset does. The documented sum needs an add of a query's count into
a buffer word: a scratch copy of the query results and a kernel of the runtime's own after
the rendering, which is not built. The planner ruled that the runtime answers Accumulate
as Reset on every device until that sum is built, which then replaces it everywhere.

So the setter takes every mode in an Accumulate pass as in a Reset pass, and the
encoder no longer keeps the pass's visibilityResultType, which nothing reads now.
Removed public items: DrawKind::AccumulatedVisibilityResults and
Metrics::accumulated_visibility_refused (the consumer's checkout names neither in code;
two doc comments and one test of its rt platform describe the refusal:
rt_platform/render.rs:76 and its test at :2299, rt_platform/descriptor.rs:21).
DrawKind::VisibilityResultInterrupt stays refused, its doc now saying why: its answer
needs the same add. docs/API.md's accepted differences records the measured answers; the
rt README, VisibilityResultType's doc, the validation replay's docs and
docs/REPLAY-STREAM.md follow. The validation replay test of an Accumulate stream now
holds that its modes write as a Reset pass's, nothing skipped. REFUSALS.md regenerated
(Gap::Draw loses one site); api_signatures blessed (the two removed records).
2026-12-02 14:24:08 -08:00
Anees Iqbal 002c917994 rt test: an Accumulate pass writes what a Reset pass of the same modes and draws writes (red)
set_visibility_result_mode refuses Boolean and Counting in a pass whose
visibilityResultType is Accumulate (Gap::Draw{AccumulatedVisibilityResults}). The planner
ruled that the runtime answers Accumulate as Reset on every device: Metal on a Radeon Pro
5300M and a UHD Graphics 630 does, and Metal on an Apple M3 Max adds each result into its
word, which no form here builds yet.

The test replaces the refusal's pin: two passes of one command buffer, Reset and
Accumulate, each Counting at 0 over the whole target, Boolean at 8 over its top half and
Counting at 16 with no draw, into buffers of 0xaa bytes. Both read 64, 32, 0 and the
untouched word. Red at the base: the Accumulate pass's first mode is refused.
2026-12-02 14:24:07 -08:00
Anees Iqbal 053a57b831 Harness: churn_rest executes each indirect command buffer it makes, and records the preprocess bytes executions hold
The planner asked for the executed path's objects in churn_rest's gauges. Each iteration's
indirect command buffer (16 indexed draws, three vertex buffers and one fragment buffer a
command, as the owned fixture engine/icb_merged_indexed.ll's icb_indexed_vertex and
icb_indexed_fragment read) is now executed whole, in a pass of its own into an RGBA32Uint target,
with a state of those functions made once for indirect command buffers. Its commands are as the
commit resets them, each drawing nothing: the execution records and takes its preprocess region
as any does. The row's records add preprocess_used_bytes, 0 once a command buffer completed, at
100, 200 and the drop; the first iteration's line shows the idle preprocess bytes kept for the
next execution, which are no record, as they fall to zero at an idle age a settled read does not
fix.
2026-12-02 14:24:07 -08:00
Anees Iqbal 2dc8b1c002 rt: the triangle fill mode of raw value 2 draws as Fill on every device
set_triangle_fill_mode refused TriangleFillMode::Points, the raw value 2 that no SDK
header declares (MTLRenderCommandEncoder.h declares Fill and Lines alone), as
Gap::Draw{FillMode} on every device. Apple's OpenGL renderer sends it for
glPolygonMode(GL_POINT). Metal refuses it on no Mac measured, and the Macs disagree: an
Apple M3 Max and an Intel UHD Graphics 630 draw a triangle's vertices as points, an AMD
Radeon Pro 5300M fills the triangle. The planner ruled that the runtime takes the Fill
answer, which needs no device feature, no pipeline of its own and no precision note.

The setter now takes Points as Fill. DrawKind::FillMode keeps one case, Lines on a
device without fillModeNonSolid. docs/API.md's accepted differences records the
measured answers and that a points form waits for a guest's report that the points
answer matters; the rt README's fill modes and known gaps say the same. REFUSALS.md
regenerated, unchanged (it lists no DrawKind text).

Verified: tests::raster::on_device::every_device_draws_the_fill_mode_of_raw_value_2_as_fill
on lavapipe, red at the test's commit (the setter refused), green here.
2026-12-02 14:24:07 -08:00
Anees Iqbal a98a3f748e rt test: the fill mode of raw value 2 draws what Fill draws, on every device (red)
set_triangle_fill_mode refuses TriangleFillMode::Points, the raw value 2 that no SDK
header declares, as Gap::Draw{FillMode} on every device. Metal refuses it on no Mac
measured: an Apple M3 Max and an Intel UHD Graphics 630 draw a triangle's vertices as
points, a Radeon Pro 5300M fills it. The planner ruled that the runtime takes the Fill
answer, which needs no query and no new path.

The test draws the edge triangle under Fill and under raw value 2, in passes of one
command buffer, and holds that both targets read the same filled texels, and that the
second pass makes no pipeline and waits for none. Red at the base: the setter refuses.
2026-12-02 14:24:07 -08:00
Anees Iqbal 51c4700a76 Validation: the play's own textures take its video and exported surface planes, held from frame 100 to 200
The excess judge's count of the play's own textures adds the planes of its video surfaces
(`Videos::held`) and of its exported surfaces, a plane object that outlives its surface among
them (`Exported::held`); no matrix stream makes either, so neither term had a test. The new
replay test makes a video surface and an exported surface by frame 100, then a second video
surface, releases the exported surface and its plane 1 while keeping plane 0's object, and makes
another exported surface by frame 200: where the device makes every surface the play holds 6
textures at frame 100 and 11 at 200, and every kind's excess holds still.
2026-12-02 14:24:07 -08:00
Anees Iqbal 8209b0d83b Harness: two churn rows make and release every kind of their group in each of 200 iterations, their gauges read at 100, 200 and the drop
The thirteen gauge kinds no replay judges and no harness workload recorded now each have a loop,
grouped as the planner ranked them. `churn_all_day` (OwnRow::ChurnAllDay) makes, uses and releases
in each iteration: a host memory import with a buffer over it; an exported block with a buffer
over it; a video surface of each decoder route the device exports (a dma-buf at the VA-API
layout, the host's opaque handle at NVIDIA's), as the replay player makes them, with a view of
each plane at an index, its buffer in place, and plane 0 kept past the surface's release; the
runtime device tests' plane stand-in surface (two RGBA8Unorm planes of the opaque handle) whose
plane 0 a pass renders beside another colour attachment; two render pipeline states; and a
Private target and a target over a Shared buffer, each drawn into, then read through a texture
after a memory barrier. `churn_rest` (OwnRow::ChurnRest) makes a compute state of one of 40
contents in turn (past the 32 stage entries kept), a draw under a Counting visibility mode into 4
samples resolved into a texture over a Shared buffer, a texture over an exported block read by a
blit, and an indirect command buffer.

Each row reads the device's gauges once it settles (no release waiting, no command buffer
unretired, two reads 20 ms apart equal) after the 100th and the 200th iterations, and once more
after its device dropped (own::run, through the counters that outlive it), and the command prints
them as `M2V-MATRIX gauge harness-<runtime>/<row>/<gauge>@100|@200|@drop`: the harness's gauges
and the eleven kinds they left out (imports, exports, surface imports and buffers, plane
stand-ins, shadows, stage entries, resolve images, textures copied over, occlusion pools,
indirect command buffers). The matrix judges them as every gauge. A kind the device does not
make is left out with its reason on the row's lines; the first line gives each of the group's
kinds live in the first iteration before its release. No kind needed a consumer-side object: the
host import's memory is the row's own, as in the runtime's import tests.

The device tests churn_all_day_holds_every_gauge_still_and_frees_all_at_the_drop and
churn_rest_holds_every_gauge_still_and_frees_all_at_the_drop hold the matrix's rule on the
report.
2026-12-02 14:24:07 -08:00
Anees Iqbal 09e7277972 rt: an event's semaphore counts the event's signals, not Metal's values
rt put Metal's 64-bit event values on the event's timeline semaphore as they were. Vulkan bounds
a signal's distance from the semaphore's value and from every signal pending on it by the
device's maxTimelineSemaphoreValueDifference (VUID-VkSubmitInfo2-semaphore-03883), which a
device may report as 2,147,483,647 (two committed profiles do: nvidia-pascal-linux and
runtime-floor; the 780M under AMDVLK reports 2^32 - 1). So an event's first signal of 2^31 or
more, or a GPU signal just above a host value far above the last GPU signal, was outside valid
usage there.

One form on every device: the k-th signal of an event the submit thread stages signals its
semaphore to k (submit.rs stage), and the event keeps each pending signal as (count, Metal
value). Both rise, since a signal not above the highest value submitted or set is still left
out, so the value the host sees is the value of the signal the confirmed count reached
(EventState::value_of), and a wait for a Metal value waits for the count of the first pending
signal that reaches it (EventState::count_reaching). Every signal moves the semaphore by one, so
no signal lies further from its value than the signals pending on it. rt submits no semaphore
wait for an event, so 03884 never applied; the README's known-gap paragraph, which named it and
waits, is removed, and the event paragraph says what the semaphore holds. The completion thread
confirms and takes in counts (EventInner::take_in); reached() now takes the state its callers
hold. No Vulkan call, GPU work or copy is added: per signal one increment and a (u64, u64) pushed
where a u64 was; per host read an index into the pending signals under the lock already taken.

Metal's answer for a lower signal: the MTLEvent.h and MTLCommandBuffer.h headers say nothing of
one; the conformance case event-highest-signal, recorded on an Apple M3 Max under macOS 27.0.1,
reads 7 after 7 then 4 and after 4 then 7, so a lower signal changes nothing. rt matches: it is
left out and takes no count.

The pending signals have no bound of their own: one 16-byte entry each, which the signals the
submit thread has staged bound (256 of one command buffer were pending at once behind the gate
on the RX 7900 XTX, job m3-max-78721). The count cannot wrap: at one signal a nanosecond, 2^64
counts take about 584 years.

the_largest_value_is_kept no longer skips a device whose limit is below u64::MAX, and its
semaphore reads 1. The tests of the previous two commits failed at them on the RX 7900 XTX (jobs
m3-max-78698 and m3-max-78708: the semaphore read 7 for a 7, 2^40 for a 2^40, 9 for a 9).
2026-12-02 14:24:07 -08:00
Anees Iqbal 182d1d56df rt tests: many pending signals are checked as the submit thread stages them
The first run of many_pending_signals_each_take_the_next_count on the RX 7900 XTX (job
m3-max-78698) found 61 of the 256 signals pending at its first read, not 256: the submit thread
stages a command buffer's signalling segments as its queue's room allows, so the test now reads
the pending signals 200 ms after the first submission, prints how many, and checks that they are
the first ones in order with the semaphore still at 0. Its check of the semaphore's count once
the GPU runs is unchanged, and still fails here.
2026-12-02 14:24:07 -08:00
Anees Iqbal 8220e260b9 rt tests: an event's semaphore counts its signals, not Metal's values
rt puts Metal's 64-bit event values on the event's timeline semaphore as they are, so a signal
can lie further from the semaphore's value than the device's maxTimelineSemaphoreValueDifference
(VUID-VkSubmitInfo2-semaphore-03883; Vulkan lets the limit be as low as 2,147,483,647). These
tests ask for the semaphore to count the event's signals instead:

- a first signal of 2^40 is the semaphore's 1, one of 3 * 2^40 its 2;
- a lower signal moves neither the value nor the semaphore (Metal keeps the highest value: the
  conformance case event-highest-signal, recorded on an Apple M3 Max under macOS 27.0.1, reads 7
  after 7 then 4 and after 4 then 7; the MTLEvent.h and MTLCommandBuffer.h headers say nothing of
  a lower signal);
- a host set between two GPU signals leaves the semaphore where it is, and the next GPU signal
  above it moves it by one;
- a host wait for 8 is met by the later of two pending signals (9), and one at the host's value
  at once;
- 256 signals pending at once take the counts 1 to 256.

They fail at this commit, where the semaphore reads Metal's values: the fix follows.
2026-12-02 14:24:06 -08:00
Anees Iqbal c72ba75343 rt: a blob write skipped past the bound keeps its size as the last written
A blob write skipped past the bound left the last written size where it was. So when the reaper's
last write had read the cache's data and skipped its write past the bound, the device's drop
(Caches::close) found the size changed since the last write. It read the same data again from the
driver and counted a second skip (Metrics::pipeline_cache_writes_skipped) of data that had not
changed.

A skip past the bound now records the cache's size as the last written. The drop then finds no
change since the reaper's last write and neither reads nor counts again. A look never meets this
path: it replaces a cache past the bound before it would write. Skips for a quiesce's deadline
record nothing, so the drop still writes what a quiesce skipped for time.

The cache module's doc, the field's doc, write's doc and the runtime README say so.

Verified, at this commit, by red then green on every_device_replaces_its_pipeline_cache_past_its_bound.
Each job ran the test at this tree, then with cache.rs from the red commit:
- Iris Xe (ANV), m3-max-79405.
- RX 7900 XTX (RADV), m3-max-79427.
- RTX 5080 Laptop (NVIDIA 615.71.09), m3-max-79433.
Green on all three: "writes skipped at the teardown 1", PASS. Red: left (2, 2), right (1, 1).
Lint and the suite on lavapipe, m3-max-79406: clippy -D warnings plain, m2v_cpu_icd and m2v_gpu
EXIT=0; rustdoc EXIT=0; workspace rustdoc of private items EXIT=0; the runtime's suite 914
passed, 3 skipped. On lavapipe this test returns before the teardown part, since lavapipe keeps
no blob or creation to bound.
2026-12-02 14:24:06 -08:00
Anees Iqbal e0026355e7 rt test: the drop reads and skips no blob write the reaper's last write skipped (red)
A blob write skipped past the bound leaves the cache's last written size where it was. So when the
reaper's last write has read the cache's data and skipped its write past the bound, the device's
drop (Caches::close) finds the size changed since the last write. It reads the same data again and
counts a second skip of it.

The bound test now counts the reads of the cache's data for a blob write at the teardown, through
a cfg(test) counter (Counters::read_cache_data, read at the look's, the last write's and the
drop's reads). With the bound at 1 and the cache grown since its last write, the teardown should
read the data once, in the reaper's last write, and count one skip. The test asserted 2 skips
before.

Expected red today: 2 skips and 2 reads at the teardown.
2026-12-02 14:24:06 -08:00
Anees Iqbal 014b3919b1 rt README: idle recorders' 48 says what was measured and what is by structure
The paragraph said only a burst reaches past 48 idle recorders. What was measured is narrower:
the most recorders idle at once in three steady plays (36 on an RTX 5080, 31 on an RX 7900 XTX,
28 on an Iris Xe), so in those plays no recorder of steady use took the releasing reset. The
memory the release gives the driver back is by structure, not measured, and the CPU cost per
frame is not resolved by the Iris instruction count, whose plays spread 22%. Docs only.
2026-12-02 14:24:06 -08:00
Anees Iqbal 4c8152ddd0 rt: idle recorders past the first 48 release their pools' memory and hazard tables
The device keeps up to 64 idle recorders. Until now, every reset that idled one kept its pool's
memory and its hazard table, so a burst of command buffers left up to 64 pools holding the memory
of the largest command buffers they had recorded until the device went.

The idle recorders now sit in two lists:
- warm: at most WARM (48), taken first. A reset that idles a recorder while fewer than 48 are warm
  keeps the pool's memory and the table, as before. Releasing at every reset cost the UHD 630's
  Windows driver about 170 us per command buffer (m3-max-46545).
- cold: past the warm ones, which only a burst reaches, the reset releases the pool's memory
  (RELEASE_RESOURCES) and the recorder drops its hazard table.
64 idle in all stay the bound, and one given back past them is destroyed.

WARM comes from the most recorders idle at once in steady play of three recorded streams, measured
by a probe build (never merged):
- RTX 5080, m3-max-79136: 36, every recorder the play made, idle at each frame's end; in use p50
  5, p90 10.
- RX 7900 XTX, m3-max-79135: 31 (p50 15, p90 26).
- Iris Xe, m3-max-79134: 28 (p50 20, p90 23).
The XTX and Iris counts leave out the moments the play's work drained, when 56 and 64 were idle.
48 is the most (36) and a third. The steady ~50 in use on the XTX and Iris plays are command buffers
held at once; every recorder came back by teardown.

The reset runs outside the lock, after it reads the warm count. A give-back on another thread can
pass that count meanwhile, and a recorder that kept its memory then goes cold, holding it until
its next use, as the doc says.

The runtime README states the rule after the parameter ring's.

Verified:
- Red, then green on the test, a_burst_s_recorders_past_the_warm_ones_release_their_memory. Each
  job ran the test at 904bfe3b45 (base 6a14aa4192), then with this commit's record.rs taken from
  the red commit. Green: 72 given back, 48 idle kept their memory, 16 released it. Red: left
  [(64, 64), (0, 0)], right [(48, 48), (16, 0)].
  - Iris Xe (ANV): m3-max-79201.
  - Radeon 780M (RADV): m3-max-79202.
  - RTX 5080 Laptop (NVIDIA 615.71.09): m3-max-79203.
- At the rebased tip, m3-max-79278 (lavapipe suite): clippy -D warnings plain, m2v_cpu_icd and
  m2v_gpu EXIT=0; rustdoc EXIT=0; workspace rustdoc of private items EXIT=0; the runtime's suite
  913 passed, 3 skipped.
- CPU instructions on Iris Xe, m3-max-79308. The same 792-frame recorded stream was played a b a b,
  each play with a fresh pipeline cache and Mesa's disk cache off (512 pipelines created in each).
  perf stat counted user-space instructions over the whole play: a = the parent, b = this commit.
  - a: 198.1 and 192.7 M per frame.
  - b: 212.1 and 170.1 M per frame.
  The means are 195.4 (a) and 191.1 (b). No increase shows, but the measure only resolves
  differences well above the plays' own spread (b against b, 22%).
- What the device tests show is the pools reset with release and the tables dropped. The memory
  a driver gets back is not measured.
2026-12-02 14:24:06 -08:00
Anees Iqbal 7a2a2247f8 rt test: a burst's idle recorders past the warm ones release their memory (red)
The device keeps up to 64 idle recorders, and every reset that idles one keeps its pool's memory
and its hazard table. So a burst of command buffers leaves 64 command pools holding the memory of
the largest command buffers they recorded, plus their hazard tables, until the device goes.

The test: 64 and 8 recorders, each with a command buffer recorded and a hazard table marked, are
given back. The first 48 (WARM) should keep their memory and tables, and the other 16 should be idle
with both released. Taking the 48 again should leave the released ones idle, and giving them back
should make them warm again. Taking every idle one records into the released ones as well, and
giving them back should leave the same split.

The test seams are cfg(test): WARM, the idle accessor (kept and released, each with how many hold
a table) and Hazards::holds_table.

Expected red today: the burst leaves 64 idle that kept their memory and tables, and none released.
2026-12-02 14:24:06 -08:00
Anees Iqbal d9054b5164 Validation: a play's gauge records are the runtime's objects past the play's own, of each kind the program makes one at a time
A play's frames 100 and 200 are not one loop's iterations: the program makes and releases
objects between them (glbench-3090-r4 holds 62 textures at frame 100 and 690 at 200), so a
runtime gauge held flat there judged the program. The matrix's records of a play are now,
for buffers, textures, samplers and events, the runtime's live objects of the kind less the
play's own (`KIND_excess`): the stream's live objects the backend made, and the backend's own
that stand for them (two-copy Managed buffers' CPU copies and the released ones a commit still
copies, the asides, the guest RAM scratches; the planes' shapes, one texture a plane and shape
that the plane's surface textures and views are views of; the video and exported surfaces'
planes). The settled end lines at frames 100 and 200 carry the play's count of each kind as
KIND_held. An excess below zero is written as it is, which results.py takes for no count.
The runtime's other kinds follow the program's objects and work, not one object each: they are
not replay records (the harness's loops hold those its workloads reach), and every kind stays
held at zero at the device's drop.

Verified: in the hand-over.
2026-12-02 14:24:06 -08:00
Anees Iqbal f4eb47d792 Validation: a play's gauges at frames 100 and 200 go out as the matrix's records, every kind on its end lines
What:
- The runtime backend's end lines (`Backend::live`) carry every count of an object kind the
  runtime keeps live: samplers, LOD clamp variants, level elements, kernel variants and entries,
  render contents, attachment views, descriptor slots, device samplers, shadows, resolve images,
  plane stand-ins, buffer set pools, surface buffers, indirect command buffers, releases waiting
  and handles out join them, and the pipeline cache's bytes.
- At the ends of frames 100 and 200 (GAUGE_FRAMES) the player reads them once they hold still
  (Backend::settled_live): the runtime backend reads them every 10 ms until no release waits and
  two reads in a row agree on every recorded kind, for at most 2 s, a wait no frame's time holds.
  What the program released goes on the runtime's block-maker and reaper threads after the work
  before it retired, so a read straight after the frame's waits could differ between two plays.
- command-replay prints, where the play ended frame 200 and skipped nothing by then,
  `M2V-MATRIX gauge replay-rt/STEM/GAUGE@100` and `@200` for each kind of GAUGED (gauge_records).
  scripts/matrix/results.py judges them as it judges the harness's: equal at 100 and 200, blocks
  no higher at 200.
- Left out, and why: handles_out (1 while the play holds the device), releases_waiting (lowered by
  the block-maker thread whenever it runs), private_units (a layout of memory that follows the
  bytes the program holds), and every byte and age gauge, which follows the program's content and
  the pool's idle clock: the pipeline cache's data (bound 128 MiB), the translator's entries'
  bytes (bound 64 MiB), the staging bytes, the pool's allocated, idle, reserved, reused, taken and
  block bytes, and the shadows', resolve images' and stand-ins' bytes, whose counts are recorded.

Why: the matrix's leak rule (live gauges per resource kind flat between iterations 100 and 200)
reached only the harness's compute workloads. The kinds only draws and passes make (render
contents, attachment views, shadows, resolve images, stand-ins, the samplers draws reach) had no
such check, and a play's end lines lacked 17 of the kinds.

Docs: REPLAY-STREAM.md section 10 (the end line's gauges, the settled read, the records),
VALIDATION.md's gauge row, command-replay's module doc.

Tests: replay::tests the_player_settles_the_gauges_at_frames_100_and_200_alone and
the_gauge_records_are_the_counted_kinds_at_frames_100_and_200; replay::rt_replay
the_end_lines_carry_every_gauge_the_gauge_records_carry (device); test_results.py
test_a_plays_gauges_at_frames_100_and_200_are_held_flat_as_the_harness_s.

Verified: in the hand-over.
2026-12-02 14:24:06 -08:00
Anees Iqbal da37e9e5df validation test: skip an input whose version the toolchain refuses as above its newest
Tally::refused now reads the input's own version and keys the skip on the toolchain's own refusal
of it, compared with the version the toolchain says it takes:

- typed AIR: the input's `!air.version` node, and `xcrun metallib`'s "air version set to X (...),
  but expecting Y". Skipped only where X is the input's version and Y is below it.
- MSL: the source's `// metal-std:` standard S, and `xcrun metal`'s "invalid value 'S' in
  '-std=S'". Skipped only where every `metalX.Y` the compiler's notes offer is below S.

Anything else stays a failure. finish lists each skipped input with both versions, then prints
"SKIP <n> of <inputs> inputs above the toolchain's newest version".

Over the public fixtures, 31 of 582 typed inputs state AIR 2.9.0 (545 state 2.8.0, the rest
older) and 10 of 747 MSL sources name metal4.1. Those are the counts of the two refusals in CI
run 46959260218 on macos-26 (31 and 10). On that runner, the two round trips should print
"SKIP 31 of 582" and "SKIP 10 of 747" and pass.

ci.yml is unchanged. The macos-26 arm64 image 20261123.0526.1 carries Xcode 26.0.1 to 26.6
(default 26.6) and SDKs up to macOS 26.5, so no Xcode on it takes AIR 2.9.
2026-12-02 13:54:10 -08:00
Anees Iqbal 55cca59b13 validation test: an input above the toolchain's newest version is skipped and counted (red)
On macos-26, CI's Xcode 26.6 refuses the public fixtures of AIR 2.9 and Metal 4.1, which come from
the macOS 27 SDK: `xcrun metallib` says "air version set to 2.9.0 (...), but expecting 2.8" for 31
typed fixtures, and `xcrun metal` says "invalid value 'metal4.1' in '-std=metal4.1'" for the 10
sources that name metal4.1. typed_fixtures_round_trip and msl_fixtures_round_trip fail on them.

round_trip_all now keeps each input's outcome in a Tally, whose finish lists every skipped input
and the total above the toolchain's newest version. The tests own their inputs and need no Mac: a
fixture of AIR 2.9 refused by a toolchain that states 2.8, and a source naming metal4.1 refused by
a compiler whose notes offer up to metal4.0, are each to be skipped and counted; every other error
(another metallib error, a refusal whose expected version is not below the input's or names
another version, a refused standard the source does not name or that the compiler offers, any
other compiler error) is a failure, and a failure fails the round trip.

Red here: Tally::refused files every refusal as a failure, so the two skip tests fail.
2026-12-02 13:50:51 -08:00
Anees Iqbal cffa762bda rt: a heap texture placed over another's bytes moves from undefined at its first use, not in an upload
A newer heap texture placed over an older one's bytes moved out of UNDEFINED
in the upload ahead of its first command buffer. Vulkan lets that move write
the image's memory (a compression state's initialization), and a command
buffer that reads the older texture before writing the newer one then reads
changed bytes, where Metal changes none. AMDVLK does this on a Radeon 780M
(round job m3-max-79662, 1 of 915 failed; RADV and ANV pass).

The ruled form, one form on every device with no device or driver key: no
upload moves such a texture. Its first use moves it, in the command stream,
after the earlier reads.

- alias: a texture placed with links is unmoved (Placement::unmoved) as well
  as stale. A first use in a command buffer of a texture unmoved as it is
  encoded, a read included, adds a check at the head of its segment, as a
  first write already did. The segment ends first where a link was read in
  it. The submit thread resolves the check in queue order: a write's check
  moves a stale texture, and any check moves an unmoved one, which is then
  unmoved no more.
- Each heap lists its unmoved textures (Places::unmoved). An entry leaves as
  its texture moves or is released, so the list never holds more than the
  heap's live placements. The device counts them, so use_heap on a device with
  none loads one atomic and locks nothing.
- use_heap (compute and render) is a read of each unmoved texture of the heap,
  since a kernel or a draw may reach it next through an address: its check
  goes where the use_heap is.
- get_bytes of an unmoved texture moves it in its own upload, ahead of its copy
  (alias::host_read). replace_region already moved a stale texture
  (host_write).
- Image.over and its source scope in Image::homing are gone: an unmoved
  image is made homed and never enters an upload's homes.
- Runtime README: the heap texture contract says when the move happens. The
  known gap of textures carries the residuals: a never-written newer texture
  that is read; an older texture read through a heap declaration after a newer
  one over its bytes was made and before that one is written (in both, the
  move may change the older bytes, as AMDVLK's does); a first use rt cannot
  name; and a draw's first use, checked where the pass's part of the command
  buffer starts.

To verify at this commit (jobs in the handover): the red commit's counts test
and heap_alias on lavapipe, clippy in three configurations, doc and private
doc, the runtime and validation suites on lavapipe, AMDVLK on a Radeon 780M
red at the red commit and green here, and RADV, ANV and NVIDIA unchanged.
2026-12-02 13:04:25 -08:00
Anees Iqbal 78af808c98 rt test: a texture placed over another's bytes moves at its first use, not in an upload (red)
A newer heap texture placed over an older one's bytes takes its move from
UNDEFINED in the upload ahead of its first command buffer. Vulkan lets that
move write the image's memory. If the command buffer reads the older texture
before it writes the newer one, the read can see changed bytes, and Metal
changes none. The pin round's AMDVLK leg showed it: Radeon 780M under AMDVLK,
job m3-max-79662 at 685df4244e, 1 of 915 failed. The failing test is
heap_alias's every_device_reads_an_older_texture_before_a_newer_one_over_its_bytes_is_written:
554 of 262144 texels of the older RGBA16Float texture read NaN, for the
RGBA8Unorm 256x256 newer shape, with the RGBA16Float 256x128 and R32Float
256x256 shapes failing the same way. RADV and ANV pass it. That test's comment
now says so.

New counts test in tests/alias.rs, deterministic on every device lavapipe
included. P is written; then Q, R, S and U are each placed over P's bytes:
- Q is written after a read of P: checks [0, 1], one heap move, no upload
  barrier.
- R is read after a read of P: the same for a first use that reads.
- S's heap is declared (useHeap:), then P is read: checks [1], one heap move,
  no upload barrier; declaring the heap again moves nothing.
- U is read by the host (get_bytes): its upload moves it once, the second
  read not at all.
At this commit the uploads move each newer texture, so the upload-barrier,
check and heap-move counts differ (red); the fix follows.
2026-12-02 13:04:24 -08:00
Anees Iqbal 9a89d5e25c CI: the lavapipe image's udmabuf decided by the node's presence, its downloads saved on fetch, its build step limited
lavapipe exports a dma-buf through /dev/udmabuf. The image's containers now get the host's node
wherever the host has one (docker's daemon opens it for them; rootless podman only where the
user may), with the node's group, and `lavapipe-image udmabuf`, which the build step runs, says
which. Where they get none, `nextest` skips the tests and `replay` (new: the conformance replay in
the image) leaves out the cases scripts/lavapipe-image/needs-udmabuf names, each named in the log:
those are measured, each failing without the node and passing with it. The workflow decides by the
node's presence alone; no test is loosened. LAVAPIPE_IMAGE_UDMABUF names another node, or none,
which is how the lab's replica shows what a runner without the node runs.

The downloads are restored before the build and saved right after it, keyed on the pin (the
tarball's sha256, the date and the packages' versions), so a job whose later steps fail still
keeps them. The build step's limit is 90 minutes: a cold fetch at the slowest rate measured from
the archive, one connection at 57 KB/s, of the 127 MB tarball and 135 MB of databases and
packages (262 MB) takes 77 minutes. A fetch that fails ends the build step with the URL and curl's
status, or pacman's, before any test runs; the fetches retry three times.

Measured at this change's parent plus the probe (job m3-max-79668, lavapipe on x86-64 AVX2, no
node passed in): of 807 device tests run, 806 pass and
replay::rt_replay::a_video_surface_is_waited_for_at_its_ready_point_once fails with "the device
exports no DmaBuf"; with the node (m3-max-79517) every one passes. The four surface-textures cases
are refused at replace-region without the node (m3-max-79408) and hold the ledger's expectations
with it (m3-max-79517).
2026-12-02 11:59:40 -08:00
Anees Iqbal 7687644485 CI: the device-executing steps run on lavapipe in an image of one Arch Linux Archive date
CI's lavapipe steps ran on Ubuntu's Mesa 26.0.8 (LLVM 21.1.8), whose llvmpipe faults in its JIT
code on the conformance case reconvergence-constructs' rc_break draw (a null load on its
rasterizer thread), while the ledger's llvmpipe rows were recorded on Mesa 26.2.4 with LLVM 23.1.1.
The device tests, the conformance replay and public case qualification now run in a container
image of exactly that Mesa and LLVM, and nowhere else.

scripts/lavapipe-image/pin names the image: the Arch Linux bootstrap tarball of 2026.10.01 and its
sha256, the archive date 2026-10-05 its packages come from, and each package's exact version
(vulkan-swrast 1:26.2.4-1, llvm and llvm-libs 23.1.1-1, vulkan-icd-loader and
vulkan-validation-layers 1.4.363.0-1, spirv-tools 1:1.4.363.0-1, vulkan-tools 1.4.363.0-1,
python 3.14.7-1). scripts/lavapipe-image/lavapipe-image builds it: the tarball by curl -A curl,
checked against the sha256; its root imported with docker or podman; then pacman, against that
date's archive repositories alone, fetching through curl -A curl (XferCommand), with signatures
required and checked by the bootstrap's own keyring. Its downloads stay under
~/.cache/m2v-lavapipe-image, which CI caches keyed on the pin, so a run whose pin has not moved
downloads nothing. `ensure` prints the pin, the packages the image holds and its device's name and
driver, and fails where any differs from the pin or from the ledger's new `# llvmpipe:` line,
which names the venue's Mesa, LLVM, loader and layers. That line holds upstream versions: the
image is Arch's build (mesa 1:26.2.4-1), and the rows were recorded on another distribution's
build of the same release (3:26.2.4-1).

The tests are built on the host and only run in the image, with no network, only the
environment named, and the checkout mounted read-only (qualification writes the corpus alone).
lavapipe exports a dma-buf through /dev/udmabuf, so a container gets the host's where the host's
user may open it, and offers the exports the host's lavapipe does. Each container is held to its job's memory (LAVAPIPE_IMAGE_MEMORY, else the host's) and CPUs
(CARGO_BUILD_JOBS, else the host's), since the container runtime runs it outside the job's
processes. The archive serves a connection slowly at times, so the build fetches the
transaction's packages eight at a time with the same curl command before pacman runs.
The device tests are the tests the --cfg m2v_cpu_icd build lists and the plain builds do not
(only_in.py): a test that opens a device compiles only under the cfg, and the plain builds' tests,
the .ll fixtures' test with Ubuntu's LLVM 21 among them, run on the host as before. They go into
the image as a nextest archive, which needs no toolchain there; the replay and qualification run
the binaries built in the checkout. The host keeps the Vulkan loader and no driver.

AGENTS.md and CONTRIBUTING say in one sentence each that the pin and the ledger's line move
together.

Verified in the lab's replica of CI's Linux job (job m3-max-79517, at this change on
e086e51c7e, docker 29.10.1, lavapipe on x86-64 AVX2): the image builds from the cached downloads
in 55 s and its check passes (every package equal to the pin; "llvmpipe (LLVM 23.1.1, 256 bits)",
"Mesa 26.2.4-arch1.1 (LLVM 23.1.1)"). The device tests: 810 listed, 809 run, 809 passed. The
conformance replay holds exactly the 4,712 open gaps the ledger expects on llvmpipe, with no fault.
Public case qualification passes. Without /dev/udmabuf (m3-max-79408) one device test met "the
device exports no DmaBuf" and the replay refused four surface-textures cases at replace-region;
with it both are as the ledger expects. The two red host steps of both runs, golden_hashes and
the pinned opened chains, are the tables the next pin blesses, not this change.
2026-12-02 11:50:03 -08:00
Anees Iqbal d122da6ae3 Tests: the killed-helper test's threads drop their device clones before they answer
a_helper_killed_mid_make_leaves_every_make_its_refusal_at_once makes each
pipeline, and the stage fill, on a detached thread holding a clone of the
device, and that thread sent its answer before its clone was dropped. After
the last answer the test drops its own device and returns, so a detached
thread could hold the last reference and destroy the device while the
process exits. Each thread now drops its clone before it answers, so the
test's own drop is the device's last.

Test-only: no product file changes.

Seen once: the pin round's runtime item on a Radeon RX 7900 XTX (RADV
NAVI31), job m3-max-79526, at 685df4244e: the test printed its two lines
and "test result: ok", then the process ended with SIGSEGV. The same item
passed this test on the Iris Xe, the Radeon 780M, Hawk Point, the RX 550,
the RTX 2080 and the RTX 5080 Laptop.
2026-12-02 11:47:36 -08:00
Anees Iqbal 71750115c3 Tests: a video surface's ready wait counts in the copy form too
a_video_surface_is_waited_for_at_its_ready_point_once asserted that only a
surface in place counts a ready wait, the copy form's returning at once.
d0a424060a made Surface::wait_until_ready wait in both forms, the copy
form's for its block's making, and documented it so; the test kept the old
expectation. Its device runs were on devices that take the surface in place
(lavapipe, the Radeon 780M, the UHD 630), so the copy form's count was not
run until the pin's round on discrete cards, which take this 64 by 64
surface at a 64-byte pitch as a copy. The test now expects one wait in
either form.

Test-only: no product file changes.

Verified (red), at 685df4244e, the round's runtime item, 979 of 980 passed,
"surface_waits" left 1 right 0 with the surface copied: GeForce RTX 2080
(m3-max-79524), Radeon RX 550 (m3-max-79581), GeForce RTX 5080 Laptop
(m3-max-79542). The Iris Xe and the Radeon 780M of the same round take it in
place and passed.
2026-12-02 11:34:10 -08:00
Anees Iqbal f645dde503 Tests: the time-breach lives skip a driver whose pipeline cache keeps no creation
a_time_breach_is_asked_once_more_by_a_later_device made the pipeline from
a helper's fill on every device that keeps a blob. lavapipe of Mesa 26.0
keeps nothing of a creation in its pipeline cache (keeps_creations' doc), so
there a fill's entry makes no pipeline and the make after the fill met
CompileRequired. The product answered as documented; the test lacked the
guard a_kernel_past_the_stage_bound_is_made_only_from_its_helpers_fill has.
The test now asks keeps_creations for each device while the kernel is within
the bound, as that test does, and skips a device that keeps none.

Test-only: no product file changes.

Verified (red): the CI replica's lavapipe step (Ubuntu's Mesa 26.0.8, LLVM
21.1.8), job m3-max-79286, at the cut: "after the fill: a stage of entry
weight 264 past the stage bound is not made: its helper's compile met
CompileRequired".
2026-12-02 11:29:06 -08:00
Anees Iqbal 685df4244e Validation: the authored compile census re-blessed at semantics 2318
The census table moves with the translator since the last pin: 1903 rows change, every one a
new artifact hash (the product fingerprint moves with SEMANTICS_VERSION 2311-2318). Fifteen rows
change class, all from not_supported to compiled, none the other way: eight that needed the
IdentityDomains form, which the identity-domain reads since 2f16658ac2 build, and seven whose
PixelCoverageAtSampleRate or SampleRateShading needed ShaderSampleRateInterpolationFunctions,
which the moltenvk-m3 profile's stated portability feature now meets (341b80cdef). Blessed by
corpus-triage --audit authored-compile --bless on an Apple M3 Max (job m3-max-79338, census
exit 0). Table only.
2026-12-02 10:54:32 -08:00
YXC0915 19090d5f2e 🐛 Isolate Places allocations from buffer address replay
Keep image placement slabs separate when buffer capture and replay is enabled. Leave buffer replay enabled for captured buffer allocations.
2026-12-03 02:52:31 +08:00
YXC0915 3337b4d868 🐛 Use static flags for eligible attachment feedback draws
Keep the dynamic feedback capability check for path selection. Declare color feedback on the pipeline instead of toggling it for each draw.
2026-12-03 02:52:02 +08:00
YXC0915 94ff838bb8 🆕 Support GPU state capture and replay for VM suspend
Expose buffer address capture, replay and device idle operations for suspend and resume. Preserve the existing dynamic attachment-feedback device capability.
2026-12-03 02:51:52 +08:00
Anees Iqbal 6d7127708d Tables: golden hashes at semantics 2318, and the MoltenVK profile's opened chains with its stated portability features
The golden hashes table moves from semantics 2310 to 2318 (the bumps of 2311-2318 since the last
bless): 2418 rows change, 1136 engine .ll and 1131 engine .air.ll fixtures plus 151 others, every
change a hash to a hash. Blessed by bless_golden_hashes on an Apple M3 Max (job m3-max-79327),
where the engine inventory and the AIR printouts were blessed unchanged and the metallib half of
committed_air_fixtures_parse_and_link ran un-skipped and passed (linkhalf 0).

opened_chains.txt: the moltenvk-m3 device and restricted contexts now enable the portability
features that profile states (constantAlphaColorBlendFactors and the others 341b80cdef passes on),
so their chain hashes move. Blessed by bless_opened_chains (job m3-max-79328, lavapipe node);
every_committed_profiles_context_enables_its_pinned_chain passes after it, and failed before it
in the pin's lavapipe suite (job m3-max-79276).

Tables only; no source change.
2026-12-02 10:36:52 -08:00
Anees Iqbal 8f708a85b8 rt: a portability device's other portability features reach the translator where it states them
The floor asked a device listing VK_KHR_portability_subset for four portability features and
enabled only those, so the translator's description withheld the six others it names
(constantAlphaColorBlendFactors, vertexAttributeAccessBeyondStride, samplerMipLodBias,
shaderSampleRateInterpolationFunctions, separateStencilMaskRef, pointPolygons) on every such
device, and the translator took its form without each (a refusal of sample-rate interpolation,
of triangles filled as points, a withheld sampler bias) though the device states it.

floor.rs: PORTABILITY_STATED holds the six. decide() copies each as the device states it, beside
the optional tables, and no device misses the floor for one; device creation enables what decide
copies (consumer_features starts from it), and ENABLED carries the table, so named_features and
shader_enables pass each enabled one to the translator. A device that does not list the subset
reports none and chains no portability structure.

README: the table of stated portability features under Portability features; tests::floor holds
it to the code.

No device above the floor lists the subset: on the M3, KosmicKrisp (Mesa 26.3.1) lists none, and
MoltenVK 1.4.2 lists it but lacks nullDescriptor and logicOp (job m3-max-79220, which ran a
device leg printing each device's stated and given features). So the change is held by the unit
test on the floor's queries.
2026-12-02 10:19:41 -08:00
Anees Iqbal e2750b6723 rt test: a portability device gives the translator each portability feature it states (red)
The floor's PORTABILITY table enables only the four portability features it requires
(imageViewFormatSwizzle, mutableComparisonSamplers, multisampleArrayImage, imageView2DOn3DImage),
so on a device that lists VK_KHR_portability_subset, shader_enables passes the translator none of
the six other portability features it names (constantAlphaColorBlendFactors,
vertexAttributeAccessBeyondStride, samplerMipLodBias, shaderSampleRateInterpolationFunctions,
separateStencilMaskRef, pointPolygons). The translator then refuses what they carry (sample-rate
interpolation in census 65547 on MoltenVK) though the device states them.

A unit test on the floor's queries: a device at the floor listing the subset and stating every
portability feature; it asks that each portability feature the translator names reach
shader_enables. Expected red until creation enables them where the device states them.
2026-12-02 10:19:41 -08:00
Anees Iqbal 4609b8c9ac Validation: the runtime guard's hash for the emulated tier's partial-threadgroups variant
The emulated simdgroup tier's partial-threadgroups variant (15e53e4209, 54d2087b83) changed
metal2vulkan/src/lower/dispatch.rs, one of the runtime inputs: KernelDecl::live now also returns
the threadgroup's live thread count, and emit_entry keeps it for the entry. That is compile-time
emission only; what it emits is in the pipeline the artifact digests, and SEMANTICS_VERSION 2318
already covers it. No behaviour of a run changes beyond that, so only the hash moves and
RUNTIME_VERSION stays 2551. Seen in merge check m3-max-79171 (lavapipe, validation suite).
2026-12-02 10:19:37 -08:00
Anees Iqbal 4edb8041ba rt test: the bound test ends its open creation while the device's last handle goes on another thread
every_device_replaces_its_pipeline_cache_past_its_bound hung on every card (XTX, RTX 2080,
Iris Xe; 600 s, then killed). It holds a creation guard open (cache::creation) so no look comes
before the teardown, and it dropped the device's last handle before that guard. Since
4346532344 the teardown's last write (Caches::last_write, with no deadline at a teardown)
waits for a creation still running, so the drop waited for the reaper, and the reaper for the
guard the same thread held: under gdb on the XTX (m3-max-79155) the test thread was in
Shared::drop -> halt -> finish -> Ended::wait and the reaper in last_write (cache.rs:1841).
8dd00ec58c hangs the same way (79155, the test alone, exit 124).

No product path can do this. The one creation guard, in made_through_cache (pipeline.rs), covers
only its vkCreate*Pipelines call (render.rs, pipeline.rs, own.rs); no consumer code, no
completion handler and no drop of a state, library or handle runs under it, and the runtime
has no completionHandler forms. A last handle dropped on another thread waits only for that
create to end. Creation's doc now says the guard lives on its creating thread for that create.

The test now drops the device on another thread, waits for the reaper to stop, and then ends
the creation. With the bound lowered past the cache, both of the teardown's writes are skipped
and counted: the reaper's last write (1), then the drop's (2), since a skipped write leaves the
size last written as it was. The blob keeps the fresh cache's data.

The hang begins at 4346532344: the test alone on the XTX passes at 9f680a352e and at its parent
1149c04081, and is killed at 120 s at 4346532344 (m3-max-79175).

Verified: the test and the other blob and stage tests, 15 in all, pass on an RTX 2080
(m3-max-79189), an Iris Xe (m3-max-79188), a Radeon 780M and an RX 550 (m3-max-79242) and the
lab's lavapipe (m3-max-79237). Lint (fmt, the generated tables' checks, clippy plain, under
m2v_gpu and under m2v_cpu_icd, rustdoc and the private rustdoc) passes (m3-max-79221).
2026-12-02 10:14:56 -08:00
Anees Iqbal fd80fd886b rt tests: the pipeline cache's blob tests ask whether the driver keeps a creation in its cache
Twelve device tests wanted a blob, a grown blob or a stage fill's pipeline wherever the device's
cache data begins with a usable header. The runtime writes the blob only where the cache's size
changed since the last write, and a stage's pipeline is made from the helper's cache data alone;
a driver may keep nothing of a creation in its cache. On Mesa 26.0.8's lavapipe (LLVM 21.1.8,
the CI's) the empty cache's data is its 32-byte header and stays 32 bytes after a render
pipeline or a kernel is made through it, so no blob is written, and a stage fill's data is
answered compile-required, which the runtime keeps as a breach and refuses as a typed
StageSize gap (StageBreach::CompileRequired). The render test failed there at 9f680a352e too,
before the blob-write changes, so this is the device's answer, not a regression. The node's own
lavapipe (Mesa 26.2.4) gives a header the runtime does not take, so those tests already took
their no-blob arm there.

tests::keeps_creations asks it: a device on no cache directory makes the test's own pipeline,
and the cache's data grew. Where it did not, it says so, and:
- the render and kernel cache-directory tests, the second-process test and the header test want
  no blob;
- the bound, quiesce, deadline, skipped-write, removal, three-times and seed tests take their
  no-blob arm, as for a device with no header;
- the stage-fill test wants the fill's make refused with the compile-required breach, and asks
  the driver before it sets the test's stage bound, while the kernel compiles in this process.
Every other assertion is unchanged; a driver that keeps its creations runs each test as before.

Verified: the CI replica's step 15 in full with no fail-fast, 2331 passed and 6 skipped
(m3-max-79120, Mesa 26.0.8 lavapipe). The twelve tests and the stage test pass on an RTX 2080
(m3-max-79189), an Iris Xe (m3-max-79188), a Radeon 780M and an RX 550 (m3-max-79242) and the
lab's lavapipe, Mesa 26.2.6 (m3-max-79237), with the next commit.
2026-12-02 10:14:56 -08:00
Anees Iqbal 91f3e1ed60 Validation: the replay's stand-in checks the hang tripwire before it opens its device
The exported-surface stand-in (replay/new_runtime/standin.rs) opens a Vulkan device of its own
with vkCreateDevice, and gpu::tests::device_opens_exist_only_behind_the_tripwire_check failed on
it: the open was in no row of the test's table. The stand-in is made at a play's first export,
after the play's GPU work began, so a hang its waits wrote to the tripwire could already be set
when it opens; the tripwire's contract is that no GPU entry point starts new work while it is
set. StandIn::new now calls refuse_if_tripped first, and the table names its open.

The test's ordered check (the tripwire check before the open, in the open's own file) held only
the runtime's device opens; it now holds every row, each of which already met it.

Verified in the CI replica's environment (Ubuntu's Mesa 26.0.8 lavapipe, LLVM 21.1.8, VVL
1.4.341): the test passes (job m3-max-79044), and CI's step 12 in full with no fail-fast passes,
1313 passed and 3 skipped (m3-max-79062).
2026-12-02 10:14:56 -08:00
Anees Iqbal fcdcffea07 Docs: REFUSALS.md regenerated after the slot-usage refusal met the word-bound draw
The draw now refuses a missing pipeline state at two sites, one from the word-bound content's
path (7a1da6cb22) and one from the slot-usage check (73bb5eb204); each branch regenerated the
table on its own base, so the landed tree counted one. Regenerated with
scripts/refusal-surface/refusal_surface.py; no code change.
2026-12-02 10:12:50 -08:00
Anees Iqbal c25a5b238a rt: a view made with a swizzle keeps its texture's usage at a slot, as its known gap rules
8811dd6790 checked a texture slot against the usage Metal answers, and answered a view made with a
swizzle as ShaderRead and PixelFormatView alone, so a kernel's write through such a view became
Refusal::TextureUsageAtSlot. That reversed the runtime's recorded known gap of swizzles (README,
Known gaps of textures: a view's descriptor reports its base texture's usage, so a draw into such
a view and a kernel's write through it run, the write stored unswizzled; docs/API.md's accepted
differences), on which OpenCL mode stands: Apple's OpenCL binds an image of most channel orders
as a swizzled view and writes it (tests/opencl_swizzles.rs, job m3-max-16336). The runtime suite
on lavapipe at b28f70e076 (job m3-max-78531) failed three tests on it:
opencl_mode_queries_of_a_swizzled_write_only_image_answer_the_view,
opencl_mode_writes_through_a_swizzled_image_store_the_value_as_written and
every_device_reads_through_a_view_s_swizzle_and_writes_past_it, each "the Kernel function uses
texture slot 0, whose texture's usage MTLTextureUsageShaderRead |
MTLTextureUsagePixelFormatView lacks what its access there asks".

The slot check now takes the texture's descriptor usage (TextureObject::metal_usage: Metal's
unknown usage as 0x17, a view's its texture's, a swizzled view's included). The known-gap text
and new_texture_view_with_swizzle's doc are as before 8811dd6790; the refusal's doc, the README's
Texture slots and usage and RESOURCE-ID.md say a view's usage is its texture's, a swizzled one
included. The slot_usage test's swizzled destination is now a case that runs and stores the
texel as written.

The same run failed every_device_gives_an_index_to_the_texture_placed_there_last, whose dispatch
wrote through A, a texture of ShaderRead usage alone, at sample_down's written slot: that is the
refusal Metal's validation gives, and the test's point is that A's placement empties D's storage
element. It now writes through D's ID, the same index, which D's ShaderWrite usage lets the slot
check pass, and D still keeps its texels.

Verified: cargo fmt; refusal_surface.py --check (REFUSALS.md unchanged). The suite run of this
commit follows as a job. The other 865 tests of job m3-max-78531 passed (3 skipped).
2026-12-02 10:12:04 -08:00
Anees Iqbal da03093c0c rt: TextureUsageAtSlot's basis quotes Metal's (t[0]) as code, which rustdoc read as a link
Rustdoc with -D warnings refused the basis line of Refusal::TextureUsageAtSlot: the quoted Metal
validation text "reads texture (t[0]) whose usage ..." holds t[0], which rustdoc reads as an
intra-doc link to an item named 0 ("unresolved link to `0`", error.rs, three times, in both the
public and the private-items build). The three t[0] are now code spans and the lines reflowed
under 100 columns; REFUSALS.md regenerated (the row's text; basis.rs is unchanged).

Verified: the failure is job m3-max-78486's rustdoc steps (doc and privdoc EXIT=101; fmt, clippy
over the workspace and under --cfg m2v_cpu_icd and --cfg m2v_gpu, refusal_surface --check and
the signatures check passed there). Here: cargo fmt and refusal_surface.py --check; the rustdoc
run of this commit follows as a job.
2026-12-02 10:12:04 -08:00
Anees Iqbal 73bb5eb204 rt: a dispatch or draw whose texture lacks the usage its slot's access asks is TextureUsageAtSlot
A function's texture slot bound to a texture whose usage lacks what the function's access there
asks reached no element of the texture's and ran: it read element 0 of set 1 (nil's null
descriptor) or a null element as zeros and dropped its writes, with no refusal and no count. The
textures: one no shader reaches (no index: a Depth32Float target of RenderTarget usage alone, a
texture of PixelFormatView usage alone), a colour target of RenderTarget usage alone (null
elements), a texture not made for shader writes at a written slot (no storage element), and a
view made with a swizzle at a written slot (written unswizzled, where plain Metal writes through
the swizzle).

Each dispatch and draw now checks, once after the pipeline state or a binding changes and before
it records anything, each texture its functions' slots reach against the usage Metal's validation
asks by the access the function declares there (pipeline::slot_usage): ShaderRead for a sample or
read slot, a size query alone included; ShaderWrite for a write or read_write slot; both for a
read_write slot it reads. The texture's usage is Metal's answer (TextureObject::metal_usage):
the descriptor's, Metal's unknown usage as 0x17, and a texture reading through a swizzle other
than the identity ShaderRead and PixelFormatView alone. A texture short of it refuses the command,
Refusal::TextureUsageAtSlot { stage, index, usage }, binding and recording nothing. The binds take
every texture, as Metal's do. Gap::SwizzledReadWrite stays checked first for a read_write slot it
reads. The check reads facts the interface and the texture already hold; nothing runs per draw.

Basis (the previous commit's measurement, an Apple M3 Max, macOS 27.0.1, jobs m3-max-78392 and
m3-max-78422): plain Metal reads and writes the texels; Metal's validation asserts "Compute
Function(k_read): reads texture (t[0]) whose usage (0x04) doesn't specify
MTLTextureUsageShaderRead (0x01)", "writes texture (t[0]) whose usage (0x01) doesn't specify
MTLTextureUsageShaderWrite (0x02)" (an access::write argument asked only its width included), and
"Fragment Function(f_first): Shader reads texture (t[0]) whose usage (0x04) doesn't specify
MTLTextureUsageShaderRead (0x01)".

Docs: REFUSALS.md regenerated (the refusal's site); the runtime README's Textures section states
the rule (Texture slots and usage) and its compute encoder, render encoder and swizzle entries
name the refusal; RESOURCE-ID.md's sentence that a slot binding a colour target of neither usage
reads nil now says what a runtime refuses; the doc comments of set_texture, set_vertex_texture,
dispatch_threadgroups, draw_primitives, gpu_resource_id and new_texture_view_with_swizzle name it.

The test literals of the kernel interface and of a content's draws (tests/compute.rs,
tests/indirect.rs) take the new field.

Verified: cargo fmt. The red and green runs, clippy and the runtime suite on lavapipe follow as
jobs.
2026-12-02 10:12:04 -08:00
Anees Iqbal 9ad296c6cd rt: Refusal::TextureUsageAtSlot, and a test of slots whose texture lacks the usage they ask (red)
A texture slot a function uses, bound to a texture whose usage lacks what the function's access
there asks, reaches no element of the texture's, and nothing refuses it: the slot reads element 0
of set 1 (nil's null descriptor) as zeros and its writes are dropped. A texture no shader reaches
(a Depth32Float target of RenderTarget usage alone, a texture of PixelFormatView usage alone) has
no index; a colour target of RenderTarget usage alone has an index whose elements are null; a
texture not made for shader writes has no storage element. This is the index-free direct bind of
the consumer's row 194 that is still open after f3bb94275b, which refuses the bind of a texture
reached through its views alone.

Metal binds such a texture and its validation stops the command that uses the slot, by the
argument's declared access; plain Metal reads and writes the texels. Measured on an Apple M3 Max,
macOS 27.0.1 (jobs m3-max-78392 and m3-max-78422, runtime-compiled MSL):
- setTexture:atIndex: binds every such texture, under the validation layer too;
- the validation layer asserts at the dispatch "Compute Function(k_read): reads texture (t[0])
  whose usage (0x04) doesn't specify MTLTextureUsageShaderRead (0x01)" for a sample, a read or a
  get_width alone of an access::read or access::sample argument; "writes texture (t[0]) whose
  usage (0x01) doesn't specify MTLTextureUsageShaderWrite (0x02)" for an access::write argument,
  its get_width alone included; both for access::read_write; and at the draw "Fragment
  Function(f_first): Shader reads texture (t[0]) whose usage (0x04) doesn't specify
  MTLTextureUsageShaderRead (0x01)", the pass's own attachment included;
- Metal's unknown usage answers 0x17 and passes every access; a view's usage is its texture's
  (0x14, 0x11); a view made with a swizzle answers 0x11 (ShaderRead | PixelFormatView) of a
  texture of 0x13 and of one of unknown usage, and a write of it asserts;
- with the layer off, plain Metal reads the depth (0.75), the texels (64, 128, 192, 255) and the
  width (4) in every case, and writes a swizzled view through its swizzle.

This commit adds the refusal a dispatch or draw will return (stage, slot index, the texture's
usage as Metal answers it), its basis line, REFUSALS.md, basis.rs and the signature table, and the
device test slot_usage: sample_down (slot 0 sampled, slot 1 written and its size asked),
depth_fill_read and first_texel_fragment over textures of each usage. Its controls (read and
write usage, unknown usage, a view of a read texture, a read depth) run with their texels; a
render-target colour source, a read-only destination, a swizzled view's destination, a
render-target depth with no index and a PixelFormatView-only texture with no index expect the
refusal and their bytes kept. The commands do not refuse yet, so the test is red here: they run
and read zeros (or drop or unswizzle the write). The next commit makes them refuse.

Verified: cargo fmt; the red run is the next commit's job.
2026-12-02 10:12:04 -08:00
Anees Iqbal 1b240ba508 rt README: an M3 Max runs a wait met early in another queue's command buffer beside it
The queues' known gap (c9cf5bb1cc) said what the runtime does and what Metal's documented order
asks. This adds what Metal does, measured in the same two shapes by a new conformance probe,
cross_queue_event_stall.m: A on one queue runs a short dispatch, signals an MTLEvent, then 25
spins of 4.00 ms; B on another queue, committed after it, waits and runs one thread over its own
buffer; then the same with an MTLSharedEvent the host sets after both commits. Five rounds each,
MTL_DEBUG_LAYER unset, job m3-max-79181 on an M3 Max with macOS 27.0.1: B's GPU end came 0.01-0.08
ms after A's GPU start while A ran 99.96-100.00 ms, and 0.13-0.15 ms after the host's set while
A ran 99.95 ms. So the gap stands: the runtime's waiter starts at the signalling command buffer's
end (28.5-111.0 ms in the runtime's measurement), Metal's at the signal.

The probe's header records the result. Docs and a probe only.
2026-12-02 10:00:39 -08:00
Anees Iqbal c9cf5bb1cc rt README: a wait met early in another queue's command buffer runs after that whole command buffer (known gap)
L65. Every queue submits to the device's one VkQueue and each segment ends with one global
barrier, so a waiter runs after every segment its signaller submitted ahead of it: the rest of
the signalling command buffer, not only the signal. Metal's documented order asks only for the
signal. Recorded in the queues' known gaps with what was measured.

Measured by a WIP probe (not landed; steelbrain/fix-rt-l65 7d5b5cbd21, lavapipe at cef6068642):
A runs a short dispatch, signals an Event, then about 100 ms of dispatches; B, committed after
it on another queue, waits and runs one short dispatch over buffers of its own; five rounds,
then the same with a SharedEvent the host sets after both commits. The stall beyond the event's
order: RTX 2080 99.2-100.8 ms (job m3-max-79162), Radeon 780M RADV 99.6-99.7 ms (79142), Iris Xe
ANV 28.8-46.0 ms (79143, its A 28-46 ms), lavapipe 110.5-110.9 ms (79126, B on A's buffers);
host shape 100.9-101.0, 100.5-101.4, 28.5-29.0, 110.3-111.0 ms. Docs only.
2026-12-02 09:56:42 -08:00
Anees Iqbal 1536e89b36 rt tests: a shuffle kernel's ragged grid runs on its partial-threadgroups variant on every device
wps_uint_k24_s32 over 160 threads in threadgroups of 64 (two whole and
one of 32, a whole simdgroup) runs the partial-threadgroups variant:
the Emulated tier on lavapipe (compute subgroups below 32) and on the
Intel GPUs (the widest-pin rule), a subgroup tier elsewhere. Each
thread's 24 words must be the CPU's and every word past the grid keeps
its fill; partial_variant_ragged_grids counts the dispatch.
2026-12-02 09:56:19 -08:00
Anees Iqbal 0d10d346df Translator tests: an emulated variant's simdgroup barrier is guaranteed without maximal reconvergence
The partial-threadgroups variant of a4_simdgroup_barrier now compiles in
the Emulated tier (runtime-floor), whose predicated walk runs no subgroup
operation and keeps no reconvergence mode: Guaranteed with no note, as
the plain module. The test expected the subgroup tiers' answer there
(job m3-max-78909).
2026-12-02 09:56:19 -08:00
Anees Iqbal 54d2087b83 Translator: the partial-threadgroups variant takes emulated simdgroups at the compile's entry too
compile.rs refused partial_threadgroups beside emulated_simdgroups before
lowering, so the emulated variant's partial form never reached the walk
a1cbbe66cf plans. Only a flat grid, folded groups and a replay's bindings
are refused with it now. Found by an_emulated_partial_threadgroup_
exchanges_among_metal_s_threads on moltenvk-m3 (job m3-max-78894).
2026-12-02 09:56:19 -08:00
Anees Iqbal 3a5ce18a81 Translator tests: the dispatch unit test reads live's flag beside its thread count
KernelDecl::live answers the threadgroup's threads beside the flag since
a1cbbe66cf; the test that stores the flag takes the first of the two.
2026-12-02 09:56:19 -08:00
Anees Iqbal 4b01109b8c Translator: SEMANTICS_VERSION 2318 for the emulated tier's partial-threadgroups variant
2317 is held by another change that lands first; the variant's output
changes with a1cbbe66cf, so it takes the next.
2026-12-02 09:56:19 -08:00
Anees Iqbal 15e53e4209 Translator: the emulated simdgroup tier takes the partial-threadgroups variant
select.rs refused a kernel's partial-threadgroups variant in the
Emulated tier (Unsupported{PartialThreadgroups}), which the runtime
reports for a ragged grid as Gap::PartialThreadgroups{Translator}. The
tier is lavapipe's for every SIMD-group kernel (its compute subgroups
are below 32), Intel's for a large kernel the widest-pin rule sends
there, and the emulated variant's on every device.

The variant now walks the tier's synchronizations as the subgroup tiers
walk their barriers. workgroup::check plans the predicated walk for a
kernel of partial threadgroups with any of the tier's synchronizations
(an exchange or a threadgroup barrier), with Predication::partial_groups
set, so emit_entry starts `live` from Metal's threads (lin < n) and the
invocations past them reach each exchange's barriers never live, storing
nothing. The exchanges take Metal's thread count as the threadgroup's
N: KernelDecl::live also answers that count, emit_entry keeps it as
EmitCx::entry_threads, and Emu::n is it in place of the local-size
constant. Every existing rule below N then answers Metal's partial
threadgroup: a read of a lane past it reads the calling lane, folds,
votes, ballots and quad masks take only the lanes below it. The scratch
stays sized from the local size, so every invocation has its slot.

Docs: LoweringInputs::partial_threadgroups, the divergent and workgroup
module docs, PartialThreadgroupsSite::Translator, the runtime README's
partial-threadgroups gap, and docs/REFUSALS.md regenerated.
SEMANTICS_VERSION 2316 -> 2317.
2026-12-02 09:56:19 -08:00
Anees Iqbal 7951effa91 Tests: the emulated simdgroup tier's partial-threadgroups variant
The interpreter runs neighbour (a threadgroup barrier and a simd_sum)
over a ragged grid of 100 threads in threadgroups of 48, its region
flagged NONUNIFORM, in the Emulated tier: lavapipe's and gate-lavapipe's
own (compute subgroups of 8 and 4) and moltenvk-m3's emulated variant.
Each thread must read its neighbour modulo its threadgroup's threads and
sum its simdgroup's lanes among them, and the invocations past the grid
store nothing. The widest-pin rule's four large shuffle kernels must
take the partial-threadgroups variant in the Emulated tier on the four
Intel profiles.

partial_threadgroups_are_refused_with_another_form drops its emulated
form, which the variant now takes.

Red at this commit: select.rs refuses the variant in the Emulated tier
(Unsupported{PartialThreadgroups}).
2026-12-02 09:56:19 -08:00
Xiaochi You a97670348c Merge pull request #2 from reiasu2/reims-go/multi-draw-indirect
runtime, spirv: add opt-in multi-draw indirect batching for vertex-offset draws
2026-12-03 01:43:49 +08:00
Anees Iqbal 6a14aa4192 rt: the parameter ring frees its idle blocks past the first
What: the ring's idle rule (Ring::due), run on the block-maker thread beside the pool's: a block
past the first goes once every chunk of it has been free for the idle age (250 ms), where the
ring, at its fewest free chunks since the block fell idle, kept more than a block's chunks free
without it, so neither a take in that time nor the next would have asked for a block. The fewest
is set at the give-back that made the block idle, from the chunks the ring has free once that
give-back is done, and falls with each take. The first block stays, and so does a block holding
the nil buffer, the zero range or the whole range. A take now takes a chunk of the oldest block
with one free, so the newest blocks fall idle first; each block keeps its own free chunks. A
block past the first that falls idle wakes the block-maker thread (Pool::nudge); the thread
frees it as memory of its own (Loose::RingBlock: its fault span noted freed, the buffer
destroyed, the memory freed, the blocks gauge falling). A block that does not meet the rule now
cannot meet it in the same idle time, so the thread sets no wake for it.

Why: the planner's cache ruling (1). The ring kept every block it made for the device's life, so
a burst of parameter writes left its peak of 2 MiB blocks of the ring type (device-local and
host-visible, small without resizable BAR) until the device went. Freed at idle alone, a ring in
steady use would free its second block and make it again each idle age. A second condition, no
take for the idle age, which took an idle ring down to its first block, was dropped by the
planner's ruling: whether a take waited for a block it then made again could not be read on a
recorded play, so an idle ring keeps its first block and the one ahead of it.

Docs: the ring module doc, Ring::due, Pool::nudge, memory::run, the runtime README's internals
paragraph.

Verified: red on the RX 7900 XTX (RADV 26.2.6) with the parent's runtime and this branch's tests,
m3-max-79046: the burst test timed out waiting for the ring back to its first block and the one
ahead; the steady-use test passed (nothing is freed). Green in the same job at this code: the
ring, ahead and memory modules, 33 passed, "6 blocks after the burst, 2 once idle; the next take
made none". At this tree (f882510ace, the same tree): clippy -D warnings plain, under m2v_cpu_icd
and under m2v_gpu, rustdoc -D warnings, and the workspace's rustdoc of private items, all exit 0;
the runtime's suite on lavapipe 904 passed, 3 skipped, with the same line (m3-max-79050).

The cost line, one job on the Radeon 780M (RADV PHOENIX, Mesa 26.2.6), the release replay player
on stream glbench-780m-r2 with a fresh pipeline cache each play, arms a (the parent's runtime)
and b (this one) alternated a b a b (m3-max-79045): 792 frames each; blocks made a 300 and 299, b
300 and 299, 37.88 and 37.75 per 100 frames in each arm, with block bytes made equal pair by pair
(the one-block difference between the pairs is a pool allocation, 33.5 MB, in both arms). This
play makes no ring block more than the parent.
2026-12-02 09:38:04 -08:00
Anees Iqbal 37386714e3 rt test: the ring frees a burst's blocks past the first once idle, and none in steady use (red)
The parameter ring keeps every block it makes for the device's life, so a burst of parameter writes
(a guest's set_bytes, long parameter blocks) leaves its peak of 2 MiB blocks of the ring type,
device-local and host-visible memory, which is small on a device without resizable BAR, until the
device goes.

The tests: with the nil buffer kept in the first block, a burst of four blocks' chunks makes blocks
past them; given back, the ring goes back at the idle age to its first block and the one ahead of
it, and no block more goes another idle age later; the blocks gauge falls with the blocks freed,
and the next take makes no block. And a ring settled at two blocks that serves frames of three
chunks, taken and given back every few milliseconds for six idle ages, makes and frees no block.

Expected red today: the burst's blocks stay; the steady test passes (nothing is freed).
2026-12-02 09:38:04 -08:00
Anees Iqbal 94ff4c989a rt: a time breach counts the device lives that met it
Main's ruling on the stage cache's time breach. The first breach refuses in
its own device life alone, and a later device asks the helper once more. A
second breach, in another life, refuses in every life until the driver's
version changes. A fill after the first clears the count. Old records are
dropped.

- Core.stage_life: an id for each device life (stage::life(): the process
  id and the host time, hashed under fresh RandomState keys).
- Entry::Timed(Timed { lives, life }): a time breach's record after its
  byte is TIME_FORMAT (2), the count of lives (1 or 2) and the last life's
  id (8 bytes).
- record_stage_breach(Time) keeps stage::timed(dir, key, life). The count
  is 1 where the directory holds no time breach of the key (none kept, or a
  fill took its place), and 2 where it holds one of another life. A breach
  kept again in the same life changes nothing.
- read_entry takes the reader's life:
  - a time breach of 2 lives, or of the reader's own life, refuses
    (StageGap::Breach(Time));
  - one of 1 other life is a miss that keeps its file: Error::StageUnfilled
    again, the consumer asks its helper once more, and the record stays for
    a second breach to count;
  - any other time record is a miss and removed: the old one (the byte
    alone), another format version, a count of 0 or 3, a life cut short.

The format version is the time record's own byte after the breach's byte,
not a change to the stage key. So the other breaches and the cache-data
entries keep their format and stay: no helper compiles again for them.

Docs:
- the stage module docs; StageBreach::Time; record_stage_breach;
  StageGap::Breach;
- the runtime README, under Kernels past the stage bound: a bullet for the
  count, and the sentence on a breach refusing with no helper asked
  qualified for a time breach of one life;
- the README's known gap on heavy kernels: refused for the cap, or for the
  time in two device lives. One sentence: a kernel whose helper passed the
  time in one life is asked once more by the next device, which waits up to
  that time again;
- REFUSALS.md regenerated (unchanged); api signatures --check 0.

Tests, in tests/stage.rs, device-free: the ruling's four.
- a_time_breach_refuses_in_its_own_life_alone_and_a_later_device_asks_again
  (also: the record is 68 bytes; two lives' ids differ);
- a_second_time_breach_in_another_life_refuses_in_every_life (a breach kept
  again in the first life counts no second life, and a third counts no
  third);
- a_fill_after_a_first_time_breach_clears_its_count;
- a_time_breach_of_an_old_format_is_dropped.
The existing unit tests read in a fixed life, and the time breach leaves
their list of breaches that hold their byte alone.

Verified (green): Radeon 780M (RADV PHOENIX, Mesa 26.2.6), m3-max-79073, at
this commit. tests::stage: 15 tests run, 15 passed, 897 skipped, the device
tests included.
m3-max-79094, at this commit: workspace clippy (all targets, all features,
-D warnings) EXIT=0 in all three configurations (plain, --cfg m2v_cpu_icd,
--cfg m2v_gpu); Rustdoc EXIT=0; the runtime's private Rustdoc EXIT=0. The
runtime suite on lavapipe: 907 tests run, 907 passed, 3 skipped.
2026-12-02 09:31:46 -08:00
Anees Iqbal ccb067d2af Tests: a time breach is asked once more by a later device
The stage cache's time breach (StageBreach::Time) refused its pipeline on
every later device life until the driver's version changed. So one helper
compile past the consumer's time limit, on a loaded host for example,
refused a heavy kernel for good. Main's ruling: the record counts the device
lives that met the breach. The first refuses in its own life alone, and a
later device asks the helper once more. A second, in another life, refuses
in every life, as before. A fill after the first clears the count. The
record's format version is bumped, so old records are dropped, not trusted.

tests/stage.rs, on a device, through the public API alone:
- a_time_breach_is_asked_once_more_by_a_later_device: six device lives on
  one cache directory.
  - The first keeps a time breach and is refused.
  - The second asks for the same fill. A helper's fill there takes the
    breach's place, and the pipeline is made.
  - The third makes the pipeline from that fill.
  - The fourth keeps a time breach before its make (a first again) and is
    refused.
  - The fifth asks past it, keeps its own breach (the second life's), and is
    refused.
  - The sixth is refused, with no fill asked.
- a_helper_killed_mid_make_leaves_every_make_its_refusal_at_once: after the
  time breach, the later device now asks for the same fill once. Its own
  breach then refuses there and on the device after it. The memory breach
  is unchanged.

Verified (red): Radeon 780M (RADV PHOENIX, Mesa 26.2.6), m3-max-79073, at
this commit. Both tests fail where the later device is refused:
"Some(Unsupported(StageSize { weight: 204, cause: Breach(Time) }))"
(stage.rs:577 "the second life"; stage.rs:782 "a later device, one time
breach"). tests::stage: 11 tests run, 9 passed, 2 failed, 897 skipped.
2026-12-02 09:31:46 -08:00
Anees Iqbal 7a1da6cb22 rt: a draw through buffers bound at a multiple of 4 below their alignment draws the state's word-bound content
Row L97 (the draw residual). A dispatch of a function's kernel whose buffer
argument of 8 or 16 is bound at a multiple of 4 below that alignment runs a
variant of its kernel that holds the slot to 4 (8 where a 64-bit atomic may
reach it). A draw refused such a bind (Refusal::BufferOffsetAlignment). It
now draws the same way.

- RenderPipelineState::for_words(device, words) makes the state's content
  with LoweringInputs::word_bound_buffers set for its vertex function (bits
  0..31) and fragment function (bits 32..63). The device's map of contents
  keeps it under the state's key with that mask (KernelKey.words widens to
  u64). Like a pass's 2D-array content, it has no cache record of its own.
  Its samplers are numbered at the state's indices; a mismatch is
  Gap::KernelInput (ConstexprSampler).
- RenderCommandEncoder keeps the state set (`base`) apart from the state it
  draws through (`pipeline`). Where a draw's facts are not held (a bind or
  the state changed), bind_words reads the base's buffer address fields. A
  slot of mask 7 or 15 whose bound address is a multiple of 4 but not of
  its alignment sets its bit. The mask is ANDed with the slots the state
  lowers from AIR (word_slots: a function the consumer compiled has none,
  and its bind stays refused). A new mask switches `pipeline` to that
  content, or back to `base`. An execution of an indirect command buffer
  draws through `base`.
- The draw's own checks then hold each slot to the content's alignment: an
  address off a multiple of 4 is still refused, as is one off 8 that a
  64-bit atomic may reach.

Cost: a draw bound aligned keeps the state it was set with, and the scan of
its address fields runs only where the draw's facts are found again
(expected from the code, not measured). The first draw of a new mask lowers
both functions again and makes the content's VkPipeline (a first-use wait),
as the compute variant does. A later draw of that mask finds the content.

Docs: the runtime README (Render encoders: the draw bullet; Compute
encoders: the variant's paragraph); error.rs's BufferOffsetAlignment;
docs/API.md section 1 and its accepted differences. REFUSALS.md unchanged
(refusal_surface --check 0); api signatures --check 0.

Verified:
- Green on lavapipe, m3-max-79015 (at this commit's tree before its rebase
  onto 8dd00ec58c). Over tests::draw, render_offsets and indirect: 67 of 67
  passed, 838 skipped. The new test draws every case through the content,
  and the second draw of a bind finds it.
- The two draw-alignment tests on a card per vendor, 2 of 2 passed on each:
  - Radeon 780M (RADV PHOENIX, Mesa 26.2.6), m3-max-79076, at this commit;
  - RTX 3090 (NVIDIA 620.70.06), m3-max-79043, and Iris Xe (ANV, Mesa
    26.2.6), m3-max-79051, both before the rebase.
- m3-max-79086, at this commit: workspace clippy (all targets, all
  features, -D warnings) EXIT=0 in all three configurations (plain,
  --cfg m2v_cpu_icd, --cfg m2v_gpu); Rustdoc EXIT=0; the runtime's private
  Rustdoc EXIT=0. The runtime suite on lavapipe: 903 tests run, 903 passed,
  3 skipped.
2026-12-02 09:30:59 -08:00
Anees Iqbal d8c04db088 Tests: a draw through buffers bound at a multiple of 4 below their alignment
Row L97 (the draw residual): a draw whose vertex or fragment function takes
a buffer argument of 8- or 16-byte alignment bound at a multiple of 4 below
it is refused (Refusal::BufferOffsetAlignment). A dispatch of a function's
kernel bound so runs a variant of its kernel that holds the slot to 4
(LoweringInputs::word_bound_buffers). Plain Metal draws it, each element at
its own address; Metal's API validation stops the bind offset.

tests/draw.rs, new:
every_device_draws_through_buffers_bound_at_a_multiple_of_4_below_their_alignment.
It binds colored_vertex's float2 positions at 20 and float4 colours at 24,
and branching_fragment's float4 weights (examples/icb_linked_arguments.ll)
at 4, apart and together. Each draw must give the texels the same values
give bound aligned. The first draw of each new bind lowers a content (the
translations counter rises); a second draw of the same bind finds it.
Positions bound at 18 are still refused (index 0, offset 18, alignment 8).

every_device_refuses_a_draw_whose_buffer_is_off_its_alignment now binds off
a multiple of 4 (18), which stays refused.

Verified (red): lavapipe, m3-max-79015, at this commit alone (tree equal to
this one before its rebase onto 8dd00ec58c). The new test fails with its
first misaligned draw refused (draw.rs:2892): "vertex: the buffer at index
0, bound at offset 20, is not at a multiple of 8 bytes, the alignment its
function holds it to". Over tests::draw, render_offsets and indirect: 67
tests run, 66 passed, 1 failed, 838 skipped.
2026-12-02 09:30:59 -08:00
Anees Iqbal 0bf6fa1e3e rt README: a target's linear image in place is made again without the loop usages for any place condition it fails
Audit finding F3 (wording). The runtime README said a colour render target's
linear image over a buffer is made again without the sampled and feedback
usages where the image with them "does not lie at bytes_per_row". The
retry (texture.rs, after make's Unmade::Unfit) runs for every cause Unfit
names:
- Pitch: its rows not at bytes_per_row;
- RenderReach: its subresource past the texture's rows or the buffer;
- Alignment: its memory alignment not met;
- ImageMemory: its memory type not taken.
The sentence now names those conditions. It also says what follows the
retry: the texture lies in place where the image without the usages meets
them, and is copied where it does not.

Docs only; nothing built.
2026-12-02 09:30:21 -08:00
Anees Iqbal 0a7a446fa1 Harness: its gauges name what they hold, with level elements, timestamp pools and buffer set pools
named()'s doc said it held every count of an object kind the runtime keeps live; it held 15 of
them. It now says what it holds: the kinds a compute workload makes or reaches, and the render
contents and attachment views, which none makes; the kinds only draws, passes, surfaces, imports,
exports and indirect command buffers make are a replay's gauge records. It adds the three of
those kinds a compute workload reaches: level_elements (a texture's levels' storage elements),
timestamp_pools (the command buffers' GPU time queries) and buffer_set_pools (a dispatch's bound
buffers' descriptor sets). Each is recorded at the 100th and 200th runs and at device drop, as
the others are.

Verified: in the hand-over.
2026-12-02 09:29:20 -08:00
Anees Iqbal 8dd00ec58c rt: a quiesce begins no last blob write past its deadline
What: Caches::last_write, the reaper's last write at a quiesce, checks the quiesce's deadline
before each try for the creations lock and again before it reads the cache's data to write: past
the deadline it writes nothing and counts the skip in Metrics::pipeline_cache_writes_skipped. A
write begun before the deadline still runs to its end. Past the deadline before the lock, the size
is not read, so the skip is counted whether or not the cache changed; the doc says so. At the
device's teardown, with no deadline, nothing changes.

Why: the audit lane's finding. The deadline was checked only while a creation held the lock, and
halt() asks the reaper to stop after the submit, block-maker and completion stages, which may use
the whole timeout; so with no creation running a write of up to 128 MiB could begin past the
deadline, quiesce answering false while it ran on, against the quiesce doc.

Docs: Device::quiesce, Metrics::pipeline_cache_writes_skipped, Caches::last_write, the runtime
README's Quiesce and exit.

Verified: red on the RTX 5080 Laptop (NVIDIA 615.71.09) with the runtime sources of the test's
commit, m3-max-78990: the new test timed out waiting for the skip (61.7 s; the last write took the
lock and wrote). Green in the same job at this code: the five blob tests passed, 902 skipped;
"quiesce late: the last write past a passed deadline skipped, the drop wrote the blob"; the
doubling test 5 writes of 286050 bytes for a 108159-byte blob. At this tree (dd0a40d8c6, the same
tree): clippy -D warnings plain, under m2v_cpu_icd and under m2v_gpu, and rustdoc -D warnings, all
exit 0; the runtime's suite on lavapipe 902 passed, 3 skipped (m3-max-78987). lavapipe keeps no
blob, so the blob tests pass there without one.
2026-12-02 08:57:41 -08:00
Anees Iqbal 5b1acd0aa9 rt test: a quiesce begins no last blob write past its deadline with no creation running (red)
Caches::last_write checks a quiesce's deadline only while a creation holds the creations lock.
halt() asks the reaper to stop after the submit, block-maker and completion stages, which may use
the whole timeout, so with no creation running a blob write of up to 128 MiB could begin past the
deadline: quiesce answers false, and the write runs on after it, which the quiesce doc says does
not happen.

The test: a cache grown with its look skipped under a creation held open; the reaper held at a job
of the test's; the creation ended; a quiesce of no time, which answers false; then the reaper,
let go, comes to its end with the deadline passed and no creation running. It writes nothing and
counts one skip in Metrics::pipeline_cache_writes_skipped, and the drop then writes the grown
cache.

Expected red today: the last write takes the lock at once and writes the blob; no skip counted.
2026-12-02 08:57:41 -08:00
Anees Iqbal 78ae218f00 rt docs: the sample-positions links name their items plainly
The private-items rustdoc (CI's "Private intra-doc links" step, merge check m3-max-78917 at
9c375eb504, STEP privdoc EXIT=1) failed on redundant explicit links that 1c307b4608 added:
`Refusal::SamplePositions` in device.rs (programmable_sample_positions_supported) and pass.rs
(RenderPassDescriptor::sample_positions), each in scope by its import, so the explicit target
repeated the text's own path. pass.rs's `RenderPassKind::SamplePositions` link, also imported, takes
the same form. The links that name items not imported there (Device, DrawKind) keep their targets.

Verified: the job named in the handover runs rustdoc with -D warnings over the workspace, with and
without --document-private-items, and cargo fmt --check.
2026-12-02 08:54:02 -08:00
Anees Iqbal 212d7b2d8e rt: blit copies whose rows meet go a row at a time where no one axis orders them, and a surface's plane lies in its buffer
Row L212. Metal leaves overlapping copies undefined; an Apple M3 Max reads the
source whole before it writes, which the runtime gives as slabs, and no Vulkan
copy command may read bytes it writes (VUID-vkCmdCopyImage-pRegions-00124,
VUID-vkCmdCopyBufferToImage-pRegions-00173,
VUID-vkCmdCopyImageToBuffer-pRegions-00184).

Form (blit.rs):
- Slabs becomes an enum: Across (the existing single-axis cut) and Rows
  (RowSlabs). Where cut() finds no axis, row_by_row() takes the rows one at a
  time. Each row goes before every row whose source its destination lies on:
  descending where every destination row lies on a source row after its own
  (meeting()'s y shifts all positive), ascending where all are negative.
- Within a row, the shift from the destination row to its own source row
  (the first row's, plus the pitch difference per row) decides the cut. Zero:
  the row is its own bytes and copies nothing. Less than the row: slabs of
  |shift| in whole texels, the far end first. Otherwise: one command.
- Slabs::of yields each slab's 3D start, which ImageCopy::regions and
  BufferCopy::slabs add to the other side's origin and to the buffer offset.
- An execution barrier still separates two commands. Every hazard between
  them is a write after a read, as no row reads bytes an earlier row wrote.
- Still refused (Gap::OverlappingCopy): rows of two pitches that cross, where
  one destination row lies on a source row before its own and another on one
  after its own.

Surface (texture.rs, buffer.rs, surface.rs, d3d11.rs):
- An exported surface's plane image keeps its PlaneLayout (Under::Surface
  laid, from SurfaceImage).
- TextureObject::rows_in(buffer) answers the plane's rows in a buffer on the
  surface's memory: BufferObject::surface_range matches the buffer's block
  aliases to the plane's (Arc::ptr_eq) and maps the plane's offset through the
  block's memory range.
- A copy between a buffer and a texture takes those rows where the texture
  has none of its own. A texture over the surface's buffer is always the copied
  form (OverCause::Surface), so a copy between it and a plane shares no bytes
  in Vulkan, and is left as it was.
- The surface's buffer and planes are aliases that read alike in the general
  layout. Surface::buffer's doc quotes the section.

Docs:
- blit.rs and the copy methods' docs; error.rs's OverlappingCopy (REFUSALS.md
  regenerated).
- The runtime README: Blit encoders, their known gaps (only crossing pitches
  remain refused), and the surface's buffer.

Verified:
- Green, on lavapipe, m3-max-78902 (at 70c887a155, before the rebase): the
  blit module, 26 of 26 passed (865 skipped). The plane is in place
  (OpaqueFd); into it and out of it go a row at a time.
- Cards, the blit module at 02421a08a9, 26 of 26 passed (867 skipped) on each.
  That tree differs from this one only by a branch for a texture in place over
  a surface's buffer, now deleted: no device laid one in place, and each
  printed "copied".
  - Radeon 780M (RADV, Mesa 26.2.6), m3-max-78888.
  - Iris Xe (ANV, Mesa 26.2.6), m3-max-78889.
  - RTX 3090 (NVIDIA 620.70.06), m3-max-78896.
  On each, the textures over one buffer are in place: whole rows go a row at a
  time (16 slabs; 256 on the Iris, whose memory alignment is 4), and two
  pitches go a row at a time. The surface's plane is in place (OpaqueFd), into
  it and out of it a row at a time.
- m3-max-78906 at 70c887a155: workspace clippy (all targets, all features,
  -D warnings) EXIT=0 in all three configurations (plain, --cfg m2v_cpu_icd,
  --cfg m2v_gpu). Rustdoc and the runtime's private Rustdoc EXIT=0. The
  runtime suite on lavapipe: 888 tests run, 888 passed, 3 skipped.
- refusal_surface.py --check: 0 at this commit.
2026-12-02 08:42:26 -08:00
Anees Iqbal fb53900e04 Tests: blit copies whose rows meet in no order one axis keeps, and a surface's buffer and its plane
Row L212: copies between rows in place over one buffer (two textures over it,
or a region of it and a texture over it) whose rows meet in no order a cut
along one axis keeps were refused (Gap::OverlappingCopy): a destination row
across the end of its own source row and the start of the next, and rows of
two pitches that meet at their starts. Copies between an exported surface's
buffer and its own plane in place were not checked at all: the plane carried
no rows, so the copy was one command whose source and destination share bytes.

Unit tests (blit.rs):
- regions_of_two_textures_over_one_buffer_copy_in_slabs_where_their_bytes_meet
  expects whole rows two texels on to copy a row at a time, the last row first
  on and the first row first back, each row in slabs of two texels, the far end
  of its shift first. Rows of two pitches that meet at their starts copy a row
  at a time, after the row whose source each writes, and the first rows (the
  same bytes) copy nothing.
- a_buffer_copy_over_its_texture_s_own_bytes_copies_in_slabs_or_in_no_order
  expects the same of a region and a texture over its bytes, into the texture
  and out of it, with each command's buffer offset.

Device tests:
- Textures over one buffer: whole rows a memory alignment on and back. Where
  the device lays a texture twice as wide at twice the pitch in place, the two
  pitches both ways.
- A buffer and a texture over it: whole rows on, and a region at twice the
  texture's pitch, into it and out of it.
- New: a copy between an exported surface's buffer (Surface::buffer) and its own
  plane, a row on, into the plane and out of it.
Each checks every byte against a memmove of the source from before the copy,
one submission, and the barriers of one command a row (blit barriers for the
surface, whose hand-overs add barriers of their own). None is refused.

Verified (red): on lavapipe, m3-max-78902 at this commit alone: 26 tests run,
21 passed, 5 failed, the five tests above. The unit tests and the two device
tests of rows in place are refused (Gap::OverlappingCopy). The surface test
records one command where three rows were due: blit barriers (1, 2, 0, 0)
against (1, 4, 0, 0).
2026-12-02 08:42:26 -08:00
Anees Iqbal 9c375eb504 Conformance ledger: the sample-positions cases answer on the runtime, so their seventeen refused rows go
The rt side of the suite now hands a pass's positions to the runtime's RenderPassDescriptor
instead of answering `setSamplePositions:count:` Unavailable, so the answer those rows expect,
`Err(Unavailable({call: "setSamplePositions:count:"}))`, can no longer occur on any venue. The
fourteen `*` rows (custom-left, custom-mixed, custom-right, the three fewer-, high, off-grid,
off-grid-low and the five rounded- cases) and the three venue rows of sample-positions-custom-2x
(Iris(R) Xe, RADV, NVIDIA) are dropped. A venue without VK_EXT_sample_locations, or whose
properties fall short of the answer, would answer at the same site with
`Refusal::SamplePositions` of `Unsupported` or `Gap::RenderPass`, which its replay would print as
unlisted; no venue run here does. docs/CONFORMANCE-COVERAGE.md is regenerated (7979 ledger rows to
7962); docs/METAL-COVERAGE.md is unchanged.

Verified: `conformance replay` of the 19 sample-positions cases and pass-sample-positions at
33865b2a57, before this edit, on each venue: every one of them listed exactly these rows as no
longer held ("now matches: 15", 14 on the Apple M3 Max, which has no custom-2x row) and nothing
unlisted; the custom and rounded cases read announced (justified by notices) on each.
- RX 7900 XTX, RADV NAVI31, Mesa 26.2.6: m3-max-78702
- Radeon 780M, RADV PHOENIX, Mesa 26.2.6: m3-max-78710
- RX 550, RADV POLARIS12, Mesa 26.2.6: m3-max-78713
- RTX 2080, NVIDIA 620.70.06: m3-max-78703
- RTX 3090, NVIDIA 620.70.06: m3-max-78711
- Iris Xe (RPL-P), Mesa 26.2.6: m3-max-78704
- Apple M3 Max, KosmicKrisp Mesa 26.3.1 (VK_EXT_sample_locations revision 1): m3-max-78722
lavapipe's replay with this ledger runs in the green job. Not run: the RTX 5080 Laptop GPU and the
Windows host's UHD Graphics 630.
2026-12-02 08:39:11 -08:00
Anees Iqbal 1c307b4608 Runtime: a pass rasterizes at the sample positions its descriptor sets, through VK_EXT_sample_locations
L168: a pass's custom sample positions were dropped while the guest could be told they are
supported, so a non-default set rendered at the standard positions with no refusal.

What changed:
- VK_EXT_sample_locations joins the floor's OPTIONAL_EXTENSIONS (enabled where listed; it has no
  feature). Device::programmable_sample_positions_supported (programmableSamplePositionsSupported)
  is true where the device lists it with locations at every sample count above 1 it renders, a
  1 x 1 grid, every sixteenth from 0 to 15/16 and variableSampleLocations; false elsewhere. No
  second form: a device that answers no refuses positions other than the defaults.
- RenderPassDescriptor::sample_positions is checked as the pass begins (crate::positions): each
  coordinate is taken to the nearest sixteenth, a tie up, at most 15/16, and each sample past the
  positions given at the pixel's corner, as the conformance suite's sample_positions rows measured
  an Apple M4. A set that comes to Vulkan's standard locations (Metal's defaults at 1, 2 and 4
  samples) rasterizes as an empty one on every device.
- Refusal::SamplePositions (Count, Coordinate, OneSample, Unsupported) where Metal's validation
  stops the descriptor or the device answers no. Gap::RenderPass of SamplePositions for other
  positions beside a depth attachment (Vulkan needs a sample-locations-compatible depth image whose
  layout transitions name the last locations) or at a count the device's locations lack.
  Gap::Draw of SamplePositions for a draw in such a pass whose fragment module uses
  InterpolateAtSample (VUID-01524), read from the translator's GraphicsState.
- A draw in such a pass takes a VkPipeline of its class made with sampleLocationsEnable and the
  locations as dynamic state (Raster::positions), one pipeline for every set; the encoder records
  vkCmdSetSampleLocationsEXT before the pass's first draw. Every coordinate handed to Vulkan is a
  sixteenth in [0, 15/16], which Vulkan's required 4 sub-pixel bits hold exactly, so no precision
  note.
- The translator's description of a device that enables the extension states it
  (floor::shader_extension), as for every extension creation enables that the translator names;
  the translator reads none of its properties. tests::translator_fields gives
  GraphicsState::interpolates_at_sample its verdict (refused at custom positions).
- The conformance rt side passes a case's positions to the runtime; the replay player sets them on
  the runtime's descriptor and drops its count of passes at other positions (docs/REPLAY-STREAM.md
  says so).
- README (floor table, the device's answers, the known gap rewritten), REFUSALS.md and basis.rs,
  api_signatures.tsv, METAL-COVERAGE.md and CONFORMANCE-COVERAGE.md regenerated.

Tests: the device test every_device_rasterizes_a_pass_at_its_sample_positions now gates on the
device's answer and holds the answer to the extension's properties; new device tests
every_device_refuses_the_positions_metal_refuses and
a_draw_that_interpolates_at_a_sample_is_refused_at_custom_positions; new device-free tests
(placed::) of the answer's gates (each count above 1 the device renders in
sampleLocationSampleCounts, a 1 x 1 grid, a range holding 15/16, 4 sub-pixel bits, variable
locations) and of the placement (every coordinate in [0, 1) on a sixteenth from 0 to 15/16,
refusals, the corner, the standard sets, the count and depth gaps); the replay device test
sample_positions_play_through_the_runtime_s_descriptor. Verification: the lane's jobs, named in
the ledger commit that follows.
2026-12-02 08:39:10 -08:00
Anees Iqbal c2860b1fa0 Runtime test: a pass rasterizes at the sample positions its descriptor sets
The red test of L168 (custom sample positions dropped while the guest is told they are
supported): RenderPassDescriptor gains sample_positions (`setSamplePositions:count:`), held and not
applied, and SamplePosition (`MTLSamplePosition`). The device test
every_device_rasterizes_a_pass_at_its_sample_positions draws a white triangle left of a vertical
edge through column 4 of an 8 x 8, 4-sample RGBA8Unorm target, resolves it, and checks the samples
of that column the positions cover, as the conformance suite's sample_positions rows measured
Metal on an Apple M4: the defaults 2 of 4 at the column's middle, four at x 0.25 all, at 0.75
none, one at 0.25 and three at 0.75 one, a tie at 0.53125 taken up to 9/16, 0.97 taken to 15/16,
and two positions in the pass of four putting samples 2 and 3 at the pixel's corner. It runs on
each device that lists VK_EXT_sample_locations with 4 samples and variable locations, and prints
the extension's properties.

Red here: the positions are dropped, so every custom case covers what the defaults cover.
2026-12-02 08:39:10 -08:00
Anees Iqbal d4b181c2a8 Translator: the graphics state says whether the fragment module interpolates at a sample
GraphicsState::interpolates_at_sample is true where the fragment stage's module statically uses
GLSL.std.450's InterpolateAtSample (interpolate_at_sample, or a sample-qualified varying read in
the loop over the covered samples), read from the module's instructions at link: an OpExtInst of
instruction 77 through the GLSL.std.450 import. Vulkan forbids that instruction in a pipeline
whose sampleLocationsEnable is true (VUID-VkGraphicsPipelineCreateInfo-sampleLocationsEnable-01524),
so a runtime that draws Metal's programmable sample positions through VK_EXT_sample_locations
reads it before it makes such a pipeline.

The field is encoded with the graphics state, so ARTIFACT_FORMAT_VERSION moves to 600, and it is a
new reflection fact of every render pipeline, so SEMANTICS_VERSION moves to 2317 (development's is
2316). No module's words change.

Test: engine_pull_model's the_graphics_state_states_whether_the_fragment_module_interpolates_at_a_sample
(pm_sample and pm_sample_id true, pm_center, pm_centroid and pm_offset false, at four samples on
every committed profile that compiles them). Verification: the lane's msi job (below the fix).
2026-12-02 08:39:10 -08:00
Anees Iqbal dcd502c921 Tests: the attachment-view tests' render targets take a texture index
A colour render target takes an index of set 1's texture arrays (Refusal::TextureIndex), so
both tests stopped at their target's make on lavapipe (job m3-max-78835) before reaching a
pass. Each now grants index 4096 and makes its target there, as the pass tests do.
2026-12-02 08:36:02 -08:00
Anees Iqbal 80ef3ea24e Runtime: a texture's attachment views bounded, the least recently used idle one evicted
A texture kept an image view for each level, first layer and layer count a pass rendered into,
for its whole life and with no bound (the field's doc said levels times slices, but the key
holds the layer count, so an N-slice array could keep N(N+1)/2 a level). Now a texture keeps at
most one view for each level and slice (each depth plane of a 3D texture's levels) and one more
a level (texture.rs attachment_bound): a cube's six faces one by one and its six layered fit.
A view made past the bound first evicts the least recently taken views that no command buffer
holds, to the reaper, until the bound has room (texture.rs evict_idle); where command buffers in
flight hold every one it evicts none, so the list holds the bound and what work not yet retired
holds past it.

How a view a command buffer in flight uses is known never to be evicted:
- Each view is an Arc (texture.rs AttachmentView). The texture's list holds one count; a take
  (texture.rs attachment_view) clones another only under the list's lock, into the pass's
  Attachment::held (texture.rs:406).
- The pass's begin keeps that Arc in its command buffer's kept list before the pass records
  (render_encoder.rs:935 for each target, :940 for each resolve; command.rs:1701
  hold_attachment_view into kept.rs:256 ByKind::attachment_views, via Kept::hold, kept.rs:191).
  A stencil target that targets() skips shares the depth target's view, which the pass checks
  (pass.rs DepthStencilViews).
- That list is cleared only at the command buffer's retirement (command.rs:2124, in retire) or
  at the drop of one never committed (command.rs:2201), before the texture list
  (kept.rs:264).
- Eviction takes only a view whose strong count is 1, the list's own (texture.rs:386), counted
  under the same lock, so no other hold can appear while it decides.
Between the take and the keep, the pass's own Attachment holds a count, so a view is never seen
idle in that window.

Docs: the field's, the attachment call's, Gauges::attachment_views' and the runtime README's
pass section now state the key and the bound. The kept-list size note counts eight lists.

Verification is in the jobs named where this lands; the device tests of the previous commit
are red without this change.
2026-12-02 08:36:02 -08:00
Anees Iqbal 15d5e6f0f2 Tests: a texture's attachment views within a bound, a view held in flight kept until it retires
A texture keeps an image view per level, first layer and layer count a pass renders into
(texture.rs attachment_view), with no bound: the field's doc says at most its levels times its
slices, but each distinct renderTargetArrayLength from each first slice adds one, so an N-slice
array can keep N(N+1)/2 a level for its whole life.

Two device tests, red here:
- a cube's six faces one by one, then all six layered: seven views, the cube's bound, and the
  same passes again make none (no thrash at the bound); the views go with the cube;
- a 4-slice 2D array rendered at all ten first slices and layer counts keeps five (its bound),
  the most recently rendered. The first view's command buffer is held in flight (its pass ran,
  then it waits at a shared event) while the other nine render on another queue, each retired
  before the next: the held view stays through every eviction, though least recently rendered,
  and once its command buffer retires a view rendered again takes its place.

A test-only accessor lists a texture's views.
2026-12-02 08:36:02 -08:00
Anees Iqbal 1ff3f6b522 Tests: a stage object asked past its decode and answer bounds keeps the most recent
StageEntries bounds its module decodes (KEPT_DECODES, 4) and its plain answers (32) with
least-recently-used eviction (pipeline/compile.rs evict), but no test drove either past its
bound: the existing fill test asks forty entries of one module, so it holds one decode and no
answer.

The new test assembles the multi-entry fixture under seven source file names (seven libraries
of different bytes, six stages each) and asks every stage's plain answer through one object:
seven decodes read, forty-two answers made, and four decodes and thirty-two answers held. The
last answer is found again with no decode read; the first library's first answer, gone past both
bounds, is made again and its decode read again, and both bounds still hold.

KEPT_DECODES becomes pub(crate) for the test, and a test-only accessor reads the answers held.
2026-12-02 08:36:02 -08:00
Anees Iqbal 1f2e18c97f rt: the pipeline cache blob is written where the cache's size at least doubled since the last write
What: the reaper's look writes the blob only where the size the driver gives is at least twice the
size at the last write (and more than it, so an empty cache's first pipelines write once); the
drop still writes where the size changed at all. The looks' writes then sum to at most twice the
last of them, and with the drop's the data of a device's writes over its life comes to at most
three times the data it leaves, where the cache stays within its bound. One threshold, no switch.

Why: L171. At the eighth, a run from an empty cache wrote the blob at nearly every look while it
was small, up to about nine times the blob it left (9 writes, 271.9 MB, for a 62.6 MB blob on the
Mac host, seedfoot m3-max-68006). The cost, now in the runtime README beside the bound: a crash
loses the pipelines made since the last write, at most those made since the size last doubled,
where at the eighth it lost at most an eighth; a later run compiles them again. A run seeded from
its own blob writes once, at the drop, where it made anything new.

Docs: the cache module doc, Caches::look, DeviceOptions::pipeline_cache_dir,
Metrics::cache_bytes_written and the runtime README's pipeline cache paragraph.

Verified: red at the parent on the Iris Xe, m3-max-78862: ten kernels wrote the blob 8 times,
254030 bytes in all, for a 60535-byte blob left (4.2 times). With the fix, m3-max-78867 on the Iris
Xe: 4 writes, 122950 bytes in all, for the same 60535-byte blob (2.0 times). The file part of a
write (create, write, rename, no fsync) on a btrfs disk, m3-max-78865: 62.6 MB in 6.1, 37.3 and
37.4 ms; 128 MiB in 74.1, 93.4 and 89.7 ms.

The series' tree (cd06eda084, the same tree as this branch's tip): clippy -D warnings plain,
under m2v_cpu_icd and under m2v_gpu, and rustdoc -D warnings, all exit 0; the runtime's suite on
lavapipe 892 passed, 3 skipped (m3-max-78869). lavapipe keeps no blob, so the device blob tests
pass there without a blob; their evidence is the Iris Xe's.
2026-12-02 08:33:34 -08:00
Anees Iqbal 506ec28c26 rt test: a device's blob writes over its life come to at most three times the blob it leaves (red)
The reaper's look writes the pipeline cache blob whenever the cache's size grew by more than an
eighth since the last write, so from an empty cache a run's writes come to up to about nine times
the blob it leaves (L171: 9 writes, 271.9 MB, for a 62.6 MB blob on the Mac host). The test makes
ten kernels one after another on a new cache directory, each followed by the reaper's look, sums
the bytes of every blob write (each look's that wrote, and the drop's where it changed the blob),
and asks for at most three times the blob left.

Expected red today: a write at nearly every look while the cache is small.
2026-12-02 08:33:34 -08:00
Anees Iqbal 7d9073331d rt: a device's seed removes a killed blob write's temporary file once a minute old
What: prune_blobs, run at a device's seed, also removes each blob's temporary file
(<blob>.<pid>.<n>.tmp, write_whole's) older than STALE_TEMP, 60 s. A younger one stays: another
process's write may still rename it, and where the prune removes one a write still holds, that
write fails, a miss that leaves the blob as it was. Anything not named as a blob or its temporary
file stays, as before.

Why: L171, the coordinator's question on the last write at a quiesce. A write begun before the
quiesce's deadline runs to its end, so a SIGKILL can land in it. The blob survives that: the write
goes to the temporary file, and only its rename replaces the blob. The temporary file, up to
128 MiB, was never removed, nor written again under its name (which carries the process id and
the write's number), so killed writes gathered them without bound.

Docs: prune_blobs, STALE_TEMP, the cache module doc and the runtime README's directory paragraph.

Verified: red at the parent on lavapipe, m3-max-78841: the ten-minute-old temporary file stayed
("...4321.7.tmp removed" failed). Green on the Iris Xe, m3-max-78867, and in the suite below.

The series' tree (cd06eda084, the same tree as this branch's tip): clippy -D warnings plain,
under m2v_cpu_icd and under m2v_gpu, and rustdoc -D warnings, all exit 0; the runtime's suite on
lavapipe 892 passed, 3 skipped (m3-max-78869). lavapipe keeps no blob, so the device blob tests
pass there without a blob; their evidence is the Iris Xe's.
2026-12-02 08:33:34 -08:00
Anees Iqbal 112494364b rt test: a killed blob write's temporary file is removed at the next seed once a minute old (red)
A blob write is a temporary file beside the blob, named for its process and write
(<blob>.<pid>.<n>.tmp), renamed over the blob. A process killed between the two, which the
reaper's last write at a quiesce makes likelier (a write begun before the deadline runs on, and
the consumer's SIGKILL can land in it), leaves that file, up to 128 MiB, and nothing removes it:
prune_blobs keeps every temporary file, so they gather, one a killed write.

The test leaves two such files ten minutes old, for the device's own blob and another's, a young
one and another file's temporary file, and runs the seed's prune: the old two are to go, the
other two to stay.

Expected red today: the old temporary files stay.
2026-12-02 08:33:34 -08:00
Anees Iqbal 4346532344 rt: the reaper writes the pipeline cache's blob as it ends, so a quiesce keeps what the device made
What: the reaper's end, at Device::quiesce or at the device's teardown, writes the blob where the
cache's size changed since the last write (Caches::last_write), before it ends. Where a creation
still runs, it tries for the creations lock every 10 ms (LAST_WRITE_STEP) until the quiesce's
deadline, the same deadline quiesce's other waits share (Reaper::stop now carries it), and past it
skips the write and counts it in Metrics::pipeline_cache_writes_skipped; at the teardown, with no
deadline, until the creation ends. It waits for no GPU work: the wait is for a creation, which
compiles on the CPU, and reading a cache's data waits for nothing the GPU does. The drop's write in
Caches::close then finds nothing changed. No public item is added.

Why: L171, the planner's addition. A consumer's process that ends with _exit after quiesce, as the
README's Quiesce and exit says it does, kept none of the pipelines made since the last look's
write: quiesce stopped the reaper, which ended with no blob write, and only the device's drop wrote
the blob.

Docs: Device::quiesce, Metrics::pipeline_cache_writes_skipped, the cache and reaper module docs,
the runtime README's Quiesce and exit and pipeline cache paragraphs.

Verified: red at the parent on the Iris Xe (ANV, i915), m3-max-78842, at the test's first form
(the skip test then read the count as soon as the quiesce returned): no blob after the quiesce, and
no skip counted. With the series, m3-max-78867 on the Iris Xe: a 6439-byte blob written at the
quiesce after the creation it waited for, nothing more at the drop nor at a seeded device's
quiesce with no growth; under a creation held past a 300 ms quiesce's deadline, one skip counted,
no blob, and the drop then wrote it. The reaper counts that skip as it ends alone, about one 10 ms
step past the deadline at most, after the quiesce may have returned (m3-max-78866, at the first
form, read the count too early); the test now waits for it.

The series' tree (cd06eda084, the same tree as this branch's tip): clippy -D warnings plain,
under m2v_cpu_icd and under m2v_gpu, and rustdoc -D warnings, all exit 0; the runtime's suite on
lavapipe 892 passed, 3 skipped (m3-max-78869). lavapipe keeps no blob, so the device blob tests
pass there without a blob; their evidence is the Iris Xe's.
2026-12-02 08:33:33 -08:00
Anees Iqbal 1149c04081 rt test: a quiesce writes a grown pipeline cache blob with no drop, after a creation it waits for (red)
The blob is written only at the reaper's looks and at the device's drop (Caches::close). A
consumer whose process ends with _exit after Device::quiesce, as the README's Quiesce and exit
says it does, keeps none of the pipelines made since the last look's write: quiesce stops the
reaper, which ends with no blob write.

The tests: a cache grown with its look skipped under a creation held open; a quiesce on another
thread, the creation ending once the reaper's stop is asked; then the blob holds the cache, the
drop writes nothing more, and a device seeded from it quiesces with no growth and writes nothing.
And with the creation held past a 300 ms quiesce's deadline, the last write is skipped and counted
in Metrics::pipeline_cache_writes_skipped, and the drop writes the grown cache.

Expected red today: no blob after the quiesce; no skip counted.
2026-12-02 08:29:50 -08:00
Anees Iqbal 0a1173ab55 rt: an image an upload or a command buffer held past its texture's release goes by the release's mark
What: the release of a texture, and of each view over its image, notes its mark (the wait for the
work committed by then, and those commits) in the image. Where an upload (the move home, its
zeroing, a copy) or a command buffer holds the image past that release, the image's Free::Texture,
made when that holder lets it go, waits for that mark instead of every commit made by then, and
goes into the queue of releases waiting at its mark's place, after the releases noted at as many
commits, so the queue's waits still rise along it and the texture's index, elements and views go
before its image. Pool::release_marked carries the mark; Pool::release is unchanged.

Why: L181. The zeroing upload holds a new texture's image until it retires; a texture released
before then had its image freed only after the command buffers committed by the upload's
retirement, which cannot reach it (in the harness's busy row, an image stayed two command buffers
past its views). Work committed after a release reaches nothing it released, as the runtime's
README states; the image now keeps that too. A holder that kept the image for its own work lets it
go once that work retired, and the work that reaches the image without a handle (through set 1)
was committed before the last texture over it let go, which the mark covers.

Verified: in the hand-over.
2026-12-02 08:24:00 -08:00
Anees Iqbal 856bb57b20 rt test: an image its upload held past its texture's release goes by the release's mark (red)
The upload that moves a new texture's image to its home layout, zeroing it, holds the image until
it retires. Where the program released the texture before then, the image's Free::Texture is noted
at the upload's retirement, against every commit made by then, so the image waits for command
buffers committed after the texture's release, which cannot reach it (L181: two command buffers
past its views in the harness's busy row).

The test holds the completion thread in a first command buffer's completed handler, makes a
Private texture whose zeroing upload goes with the next commit (the carrier, whose scheduled
handler marks the upload taken), releases the texture, and holds a later command buffer between
its close and its submission. Once the completion thread goes on, the image is to go while the
later one is held.

Expected red today: the image waits for the later submission, and the wait times out.
2026-12-02 08:24:00 -08:00
Anees Iqbal edad2e31fb rt: dma-buf rule A: a device-local first type takes a coherent device-local type of its own heap
What: the dma-buf rule reads the first type a dma-buf's fd query offers as the driver's word for
where such an import lives. Where that type is host-visible and host-coherent and the buffer's
requirements list it, the import takes it, as before. Where it is device-local, the import takes
the first type offered that the requirements list and that is device-local, host-visible and
host-coherent, in that first type's own heap. Anything else is Limit::ImportType. It is still one
choice from the query and one import, never a type after another (on NVIDIA's 620.70.06 one failed
import into a later type broke that type's later allocations). DmaBufTypes holds each type's
coherent and device-local bits and its heap, read once at the device's making. import_dma_bufs
takes its fds' types by the same rule. Docs: the module doc, import_dma_buf, Limit::ImportType,
and the runtime README (the import contract, the NVIDIA paragraph, the Iris Xe known gap with the
Xe2 claim as read, the pointer-import and texture-over-dma-buf paragraphs, and the AMDVLK row,
which now says nothing of a dma-buf pick: its recorded row gives no flags or heap of type 0).

Why: the planner's ruling (rule A). The Iris Xe's query offers its device-local type 0 first, so
every dma-buf was refused there, and its pages took the host-memory import and the counted copy.

Rows, each from the device test every_device_takes_its_dma_buf_type_by_the_rule at f3f332b209
(before, the rule's pick):
- Iris Xe RPL-P (ANV, Mesa 26.2.6, i915), m3-max-78652: offered 0x7f, listed 0x7, types
  [0:DL 1:DL|HV|HC 2:DL|HV|HC|HCACHED 3:DL 4:DL 5:DL|HV|HC 6:DL|HV|HC|HCACHED], one heap:
  refused, 1.
- RX 7900 XTX (RADV), m3-max-78660: offered 0x420, listed 0x7ad: 5, 5.
- Radeon 780M Phoenix (RADV), m3-max-78662: offered 0x10820, listed 0x1eaad: 5, 5; the same
  table as Hawk Point's, m3-max-78548: 5, 5. RX 550 (RADV), m3-max-78563: 5, 5.
- RTX 3090, m3-max-78667, and RTX 2080, m3-max-78547 (620.70.06): offered 0x11, listed 0x3b,
  type 0 with no flag, both offered types of heap 1: refused, refused.
- lavapipe, m3-max-78608: offered 0x1, listed 0x1: 0, 0.

Coherence both ways, every_device_imports_a_dma_buf_by_the_rule_and_each_side_reads_the_other_s_write:
65,536 bytes the guest's side wrote through a shared mapping of the memfd after the import, read
by a GPU copy, then a GPU fill read through that mapping, with no flush or invalidate call: 0
stale each way on the Iris Xe in type 1 under i915 (m3-max-78652), the XTX (m3-max-78660), the
Phoenix 780M (m3-max-78662), the RX 550 (m3-max-78563) and lavapipe (m3-max-78608).

Tests: the unit test a_dma_buf_takes_the_first_offered_type_or_a_coherent_type_of_its_device_memory
over the three table shapes (RADV's from m3-max-78548, the Iris Xe's from m3-max-78652, the RTX
2080's from m3-max-78547) and its refusals: a coherent first type not listed, nothing coherent
offered or listed, a coherent device-local type of another heap, no type offered.

Verified: the dma-buf modules (import, import_time, import_overs, dma_bufs, the Managed buffer
over a dma-buf) on the Iris Xe at this code, m3-max-78694: 24 passed, 860 skipped; a texture over
a dma-buf in place there with 0 copies and 1 acquire. At this tree (74c6614ae9): clippy -D warnings
plain, under m2v_cpu_icd and under m2v_gpu, and rustdoc -D warnings, all exit 0 (job m3-max-78815);
the runtime suite on lavapipe 884 passed, 3 skipped (job m3-max-78816).
2026-12-02 08:23:03 -08:00
Anees Iqbal 6750442c22 rt: a draw reads its target over a buffer in place through the feedback loop, or through its shadow
Row L291: a texture over a buffer laid in place (a linear image on the
buffer's memory, rule 3's form) took neither the feedback usage nor a shadow,
so a draw that read it as an attachment of its own pass, through a texture or
by a fetch, was Gap::Draw (AttachmentRead, FetchedAttachment) on every device.
Metal reads any render target this way.

Form (the ruled one: rule 2's attachment feedback loop form, with the counted
shadow copy where it is not available, a known gap):
- Plan::linear_loop. check_over sets it where the plan reads attachments, the
  device has the feedback loop, the format's linear tiling features sample it,
  and the linear image query makes the image with the sampled and feedback
  usages at the texture's extent (asked with the dma-buf handle for a dma-buf's
  import). Plan::linear_usage then adds both usages.
- If the linear image with those usages does not lie as the texture's bytes do
  (Unmade::Unfit), it is made again in place without them, and a draw reads it
  through its shadow where the device makes one (Plan::shadow_offered), as a
  device without the loop does. Only after that does a texture fall back to the
  copied form, as before.
- The pass moves the image from the general layout to the feedback layout and
  back, through the same moves a surface plane takes. Once it is back in
  general, the image and the buffer are again aliases that read their bytes
  alike. vkspec, memory aliasing: "Buffers, linear tensors, and linear image
  subresources are considered host-accessible subresources when they are in
  any of these layouts: VK_IMAGE_LAYOUT_PREINITIALIZED, VK_IMAGE_LAYOUT_GENERAL,
  VK_IMAGE_LAYOUT_ZERO_INITIALIZED_EXT" and "If two aliases are both
  host-accessible, then they interpret the contents of the memory in
  consistent ways, and data written to one alias can be read by the other
  alias."

Docs: the runtime README says where the image leaves the general layout
(Memory blocks and buffers) and how a draw reads it (Render encoders). Its
known gaps of render encoders gain the shadow for an in-place target whose
linear image takes no feedback usage, and drop the refusal. error.rs's
AttachmentRead doc is updated, and REFUSALS.md is regenerated (unchanged).
known-gaps-rt.tsv drops the 15 rows the change fixes, each of which the replay
printed as "the gap looks fixed" once the draw read its target in place:
- pass-start-barrier-over-buffer-{read, sample, barrier-read, barrier-sample,
  draw-barrier-read} on llvmpipe and the Iris Xe (10 rows): their targets are
  in place on these two, and the reading draw was refused; it now reads its
  target in place. The 780M, the RX 7900 XTX and the RX 550 had no rows for
  these cases; their replays report "differed, justified" (the case's
  accepted difference).
- pass-start-barrier-new-texture-chain on llvmpipe, the Iris Xe, the 780M, the
  RX 7900 XTX and the RX 550 (5 rows): its new texture over a buffer is in
  place on all five (the refusal arose only there), and its reading draw was
  refused the same way; it now reads its target in place.
CONFORMANCE-COVERAGE.md is regenerated.

Verified:
- Green, on lavapipe, m3-max-78715 (at 60d2af3017, this change before the
  ledger and layouts edits): 12 of 12 passed (876 skipped). Both forms read
  in place through the feedback loop.
- Cards, at 921a33a894, running over_reads, fetch-over and the layouts
  in-place test, 3 of 3 passed on each:
  - Radeon 780M (RADV, Mesa 26.2.6), m3-max-78784: in place, through the loop.
  - Iris Xe (ANV, Mesa 26.2.6), m3-max-78819: in place, through the loop.
  - RTX 3090 (NVIDIA 620.70.06), m3-max-78785: its linear tiling lays these
    targets in the copied form, so the in-place path did not run there.
  - The shadow form for an in-place target (a linear query that refuses the
    feedback usage) ran on no lab device: unaudited.
- Conformance replay (the case selection, or every case for lavapipe) with
  the 15 rows dropped, EXIT=0 with no surprise either way:
  - llvmpipe, m3-max-78743 (at 580fecacb7, every case);
  - RX 7900 XTX, m3-max-78749; RX 550, m3-max-78750; Radeon 780M,
    m3-max-78751; Iris Xe, m3-max-78760 (each at f9f3178302).
  The trees differ from 921a33a894 only in other venues' rows and the
  layouts test.
- m3-max-78783 at 921a33a894: workspace clippy (all targets, all features,
  -D warnings) EXIT=0 in all three configurations (plain, --cfg m2v_cpu_icd,
  --cfg m2v_gpu); Rustdoc EXIT=0. The runtime suite on lavapipe: 885 tests
  run, 885 passed, 3 skipped.
- m3-max-78757 at f9f3178302: private Rustdoc of the runtime EXIT=0. The
  conformance crate's suite: 1047 of 1047 passed, 0 skipped.
2026-12-02 08:22:01 -08:00
Anees Iqbal 8117a49bf9 Tests: a draw reads and fetches its target over a buffer in place
Row L291: a draw that reads the colour target its own pass renders, through a
texture or by a fetch ([[color(n)]]), is refused (Gap::Draw AttachmentRead,
FetchedAttachment) where that target is a texture over a Shared buffer laid
in place, a linear image on the buffer's memory. Metal reads any render target
this way.

tests/over_reads.rs: an RGBA8Unorm render target of shader-read usage over a
Shared buffer, its rows a whole number of the device's linear alignment answer
and the rest of the buffer a sentinel. A pass reads it at the fragment's own
pixel and at the first texel, draws blue over it, then after a memory barrier
draws each pixel read plus green. Every texel in the buffer must be blue plus
green and every other byte the sentinel. Both reading draws go through the
feedback loop (2 loop reads) or through the shadow (1 copy), and the texture's
form must match the counts.

tests/fetch.rs: exf_fetch_count over 1 and 4 draws into an RGBA32Uint target
over a Shared buffer. The values must be exact in the buffer at its pitch, and
the draws counted as for a texture of its own image.

A device without the attachment reads refuses both. Each device prints whether
its target lies in place and which form read it.

Verified (red): on lavapipe, m3-max-78715 at this commit alone, both tests
fail with the draws refused (fetch.rs:558, over_reads.rs:125): 12 tests run,
10 passed, 2 failed.
2026-12-02 08:22:01 -08:00
Anees Iqbal 36b1daff16 rt: a command buffer's parts that go at its signals are seen complete
A command buffer's part before its last goes at an event's signal as a
submission of its own (submit.rs, WorkState::step), and its queue
counts it in flight (Fifo::in_flight), so it takes room (submit::room).
It carries no command buffer, upload or copy-in, so the completion
thread had nothing to retire for it: with nothing else in flight it
waited on the host, never read the progress semaphore, never raised
`completed` and never woke the submit thread. A command buffer whose
signals made IN_FLIGHT parts then held its last part for room for good,
unless a host wait for it or another queue's work came. Its completed
handler never ran and polling its status never saw it complete.

Done::submitted now gives such a submission a retiree of its own
(Item::Part), which retires nothing: the round that sees it complete
raises the completed value and wakes the submit thread, as the round
for any other submission does.
2026-12-02 08:11:12 -08:00
Anees Iqbal e44d4d31f8 rt tests: a command buffer whose signals fill its queue's room completes with no host wait
One command buffer signals an event IN_FLIGHT times, a fill after each,
with nothing else in flight, no later commit and no host wait. Its parts
before its last go at their signals, one submission each, and fill the
queue's room (submit::room); its last part is held for room.

Red at development's tip: the command buffer stays Scheduled. The parts
carry nothing that retires, so the completion thread waits on the host
and never reads the progress semaphore; the submit thread's settled
value stays below the first part and the held last part never goes.
2026-12-02 08:09:46 -08:00
Xiaochi You 2245ae27b0 Merge PR #1: Optimize render buffer offsets and push constants
runtime: update render buffer offsets locally and submit minimal push-constant deltas
2026-12-03 00:01:41 +08:00
Anees Iqbal 9f680a352e Tests: an older heap texture read before a newer one over its bytes is first written
A newer texture placed over an older one's bytes takes its move home from
UNDEFINED in the upload ahead of its first command buffer. Vulkan lets that
move write the image's memory: RADV initializes DCC, and ANV ambiguates the
CCS, each inside the image's own range. If that command buffer reads the older
texture before writing the newer one, the move can change bytes the read
still needs.

The test takes that shape: for four newer shapes, each smaller than the older
512 by 512 RGBA16Float texture, A is written in one command buffer, which
completes. B is then placed over A's bytes, and a second command buffer reads
A, then writes B. Each read of A must be A's write.

No lab driver showed the loss, so the test lands as coverage, and its comment
says so:
- Radeon 780M (RADV): m3-max-78630.
- Iris Xe (ANV, Mesa 26.2.6): m3-max-78670.
On each, every one of the four shapes read A's write.
2026-12-02 07:52:39 -08:00
Anees Iqbal 5d6ac696d0 Runtime and translator: a framebuffer fetch from the first slice of a 2D array that its pass renders alone
Row L223: a fragment function's fetch ([[color(n)]]) of a one-slice 2D array
attachment of a layered pass was refused (Gap::Draw FetchedAttachment), where
Metal reads the attachment at the fragment's pixel. The fetch reads the
texture's second element, which for a 2D array texture holds a 2D_ARRAY view.
Vulkan reads such a view only through an arrayed image (vkspec, image view
validation). The function read every element as a 2D image.

Form (ruled B, the per-state variant, as L97's compute variant):
- Translator: LoweringInputs::arrayed_fetches names the colours read through
  such an element. The fragment function declares that element's class arrayed
  and fetches it at (x, y, 0). The key takes the field only when it is set,
  so every existing function keeps its key and its bytes. No SEMANTICS bump.
- Runtime: set_render_pipeline_state binds, for a pass whose fetched attachment
  is a 2D array texture (a multisample one too), the state's content lowered
  with those colours (RenderPipelineState::for_pass, which also makes the
  content without colours past the pass's last attachment, as before). The
  content is kept in the device's bounded map of contents under the
  descriptor's key and its colour mask (KernelKey::arrays). The cache
  directory's render record is neither read nor kept for it. A failed variant
  leaves the state itself, whose fetching draws are then refused.
- attachment_reads accepts a 2D array texture whose first level and slice the
  pass renders, one layer, where the bound content fetches that colour
  arrayed.

Still refused (README, error.rs): an array whose pass renders more than one
layer, a slice past an array's first, and a view whose first slice is not the
rendered one.

REFUSALS.md and the api_signatures table are regenerated (the new
LoweringInputs field). API.md and the runtime README are updated.

Verified:
- Red, lavapipe, m3-max-78542: the test commit alone fails at fetch.rs:396
  (FetchedAttachment): 10 tests run, 9 passed, 1 failed.
- Green, lavapipe, m3-max-78570: 45 of 45 passed (832 skipped); the one-slice
  array is fetched exactly through the feedback loop.
- Radeon 780M (RADV), m3-max-78604; RTX 3090 (NVIDIA 620.70.06), m3-max-78609;
  Iris Xe (ANV, Mesa 26.2.6), m3-max-78649: the fetch and unattached-colour
  tests, 6 of 6 each, the array fetched exactly through the feedback loop.
- States-only play, m3-max-78602, lavapipe, this change against 118bd0dff7:
  identical on both replay streams (one recorded on the 3090: 10643 render and
  15299 compute states made; one on the 780M: 8972 and 225), 0 refused.
- m3-max-78600 (at the pre-rebase 90726b13b7): clippy, Rustdoc and private
  Rustdoc EXIT 0; runtime 874 of 874 passed (3 skipped), translator 3393 of
  3393 (37 skipped).
- Workspace clippy in all three configurations (plain, --cfg m2v_cpu_icd,
  --cfg m2v_gpu; all targets, all features, -D warnings): m3-max-78645 at
  this change alone on development, and m3-max-78677 at this tree on top of
  the row-1166 tests. Every EXIT=0.
2026-12-02 07:52:24 -08:00
Anees Iqbal d33ac94a3a Tests: a framebuffer fetch from the first slice of a 2D array that its pass renders alone
Row L223: a fragment function's fetch ([[color(n)]]) of a one-slice 2D array
attachment of a layered pass is refused (Gap::Draw FetchedAttachment), where
Metal reads the attachment at the fragment's pixel.

The test draws exf_fetch_count over 1 and 4 draws into a one-slice
RGBA32Uint 2D array in a pass of render_target_array_length 1, and into slice 0
of a two-slice array in a pass of one layer. Every texel must hold the exact
count, slice 1 must keep the bytes written to it, and the counts must match a
2D target's (through the feedback loop or the image's shadow). The arrayed
content must be lowered once and kept in the device's map of contents at a cap
of 1. Slice 1 of the array, and a pass over both slices, stay
FetchedAttachment. A device without attachment reads refuses every case.
2026-12-02 07:44:36 -08:00
Anees Iqbal b1addc170c Tests: the other-queue hand-over drops the last run's B without an assignment it never reads
The build of the hand-over tests warned that the value assigned to b is never
read (seen in the 780M job m3-max-78533's build); the last run's B now goes by
an explicit drop.

Verified (these three commits' tests, at 38d497f6cb, before this warning fix):
one run per device of 4 pairs x 3 hand-overs x 256 runs; every pair and
hand-over read 0 of 256 runs a value not written:
- lavapipe: m3-max-78501
- RTX 3090: m3-max-78519
- Radeon 780M (RADV): m3-max-78533
- Iris Xe (ANV, Mesa 26.2.6): m3-max-78659
Row 1166 did not reproduce on any lab device; the tests land as coverage.
2026-12-02 07:44:36 -08:00
Anees Iqbal 15aae65dc3 Tests: a 2 MiB aliased pair among the hand-overs run after run
A device may keep a compression state only for images past a size; the
hand-overs now take a 512 by 512 RGBA16Float texture and a 512 by 256 RGBA8Unorm
one over its bytes too, their buffers 4 MiB apart.
2026-12-02 07:44:35 -08:00
Anees Iqbal 8deeb4c38a Tests: aliased heap textures handed over run after run, as a Tracked heap's program hands them
The consumer's row 1166: heap textures over one memory give compute results
that vary run to run (2 of 64 on the Iris Xe). Its recording of the compute
benchmark shows the guest keeps Metal's aliasing contract: textures at one
offset of a Tracked heap, the older never used after the newer's first use,
handed over inside one serial compute encoder with no fence, in a later
command buffer of the same queue, or on another queue after the older's
release.

These tests take that shape: for three pairs (one shape twice, and two pairs of
different formats and sizes) A and B at offset 0 of one heap, 256 runs each of
A written, A read, B written over A's bytes and B read, every read compared
with its write. Hand-overs: one serial encoder; the next command buffer of the
same queue; another queue after A's release. Each prints how many runs read a
value not written.
2026-12-02 07:44:35 -08:00
Anees Iqbal 908e7eed55 rt tests: the cube-read and OpenCL-line tests split their read-backs with as_chunks
clippy -D warnings under --cfg m2v_cpu_icd and --cfg m2v_gpu denied `chunks_exact` with a constant
size in both device tests that 039de2090e and 283d8d8f50 added (use `as_chunks::<N>()`), seen in
m3-max-78608. Plain clippy compiles neither test. Each now takes the fixed-size chunks of its
read-back with as_chunks, as the AIR crate's bitcode readers do; the values read are the same.

Verified: the next job runs clippy over the runtime under both cfgs and the two tests on lavapipe.
2026-12-02 07:29:59 -08:00
Anees Iqbal b4cf114a13 rt: a Managed texture's texels are its own (TextureBacking::Texture), as Metal's buffer of one is nil
What: Texture::backing answered TextureBacking::Buffer for every texture that names bytes in a
buffer, a Managed texture's among them. A Managed texture's image is memory of its own; the bytes
the consumer names are a copy beside it, which upload_region and synchronize_resource move. It now
answers Texture for a Managed texture, and Buffer for a texture over a buffer in place or through
the image the runtime copies the buffer's bytes into, and for a texture buffer.

Why: TextureBacking's doc says Texture is memory of its own and Buffer a buffer's bytes
(Buffer::new_texture), and Metal answers a Managed texture's buffer with nil (L319). The doc of
Texture and Buffer now names the Managed and copied forms.

Verified: the test every_device_names_a_managed_texture_s_texels_its_own_in_a_storage_gap, red at
the previous commit on lavapipe (job m3-max-78576: "a Managed texture's texels left: Buffer right:
Texture"); at this change (job m3-max-78577, tested at 9b29e1405c, the same change on an earlier base; rebased
since onto 2f16658ac2 with no conflict): clippy -D warnings plain, under m2v_cpu_icd and under m2v_gpu, and
rustdoc -D warnings, all exit 0; the runtime's suite on lavapipe 875 passed, 3 skipped, the test
among them.
2026-12-02 07:27:51 -08:00
Anees Iqbal a242170b38 rt test: a Managed texture's storage gap names its texels the texture's own (red)
TextureBacking's doc says Texture covers memory of the texture's own, and Metal answers a Managed
texture's buffer with nil; Texture::backing reports a Managed texture, whose bytes the consumer
names in a buffer beside its image, as TextureBacking::Buffer (L319). The test binds a 2 by 2
RGBA8Unorm_sRGB Managed texture of shader-read and shader-write usage to the fixture's
access::read_write slot, which is Gap::StorageElement on every device, and asks the gap's backing
to be Texture.

Expected red today: backing Buffer.
2026-12-02 07:27:32 -08:00
Anees Iqbal 2f16658ac2 Translator, runtime: an OpenCL-mode kernel's 1D images read their 2D textures under the identity domains
L61. A kernel of OpenCL mode that takes a 1D image stated RuntimeFact::OpenClLineTexture for each
such slot. That fact marks the variant in which the table domains read a 1D texture bound there,
as a Radeon Pro 5300M answers. The identity domains source no such fact, so every such kernel's
pipeline was Unsupported{IdentityDomains} when made, whatever else it did.

Apple's OpenCL binds a 2D texture of height 1 for an image1d_t and a 2D array of that height for an
image1d_array_t, and never a 1D texture. The kernel already reads its 1D images as those 2D textures
at row 0 (canon::opencl_1d), as the M3 Max and the 5300M answer. A 1D texture bound there is
outside documented Metal, and the Macs disagree on it: the M3 Max reads texel 0 at every
coordinate, the 5300M the 1D texture's texels, a UHD Graphics 630 layer 0 of an array.

- Translator: under the identity domains a kernel states no OpenClLineTexture and has no such
  variant; it reads the 2D textures. The table domains keep the fact and the variant.
  identity_unsourced no longer names a fact the identity domains never state.
- Runtime: a state records whether its kernel is of OpenCL mode (RuntimeFact::OpenClMode). A
  dispatch of one with a 1D or 1D array texture bound at any of its texture slots is the new
  typed Gap::OpenClLineTexture { slot }, not a read: Apple's OpenCL binds none, and Metal defines
  no reading of one. It is checked where the swizzle and bicubic checks run, when the state or a
  binding changes. Its doc ends in "Basis: ours".
- Docs: the runtime README's known gap is rewritten for the dispatch's refusal. API.md and the
  fact's doc say what the identity domains do. docs/REFUSALS.md and error/basis.rs are regenerated
  (Gap 30 to 31), and api_signatures.tsv is blessed (one variant).
- The runtime test opencl_lines now also binds a 1D texture at each of the kernel's three slots in
  turn. Each dispatch answers Gap::OpenClLineTexture naming that slot and writes nothing.

A refusal becomes a module, so SEMANTICS_VERSION 2316. The translator's refusal sites are
unchanged.
2026-12-02 07:25:18 -08:00
Anees Iqbal 283d8d8f50 Tests: an OpenCL-mode kernel's 1D images read their 2D textures under the identity domains
Red first for L61. Every kernel of OpenCL mode that takes a 1D image (image1d_t or
image1d_array_t) is refused when its pipeline is made: Unsupported{IdentityDomains} naming
RuntimeFact::OpenClLineTexture, the fact by which the table domains read a 1D texture bound
there in a variant. Apple's OpenCL binds a 2D texture of height 1 for an image1d_t and a 2D array
of that height for an image1d_array_t, and the M3 Max and the Radeon Pro 5300M read those as the
1D image's row 0. These tests now ask for that answer.

- engine_opencl_mode: __entry_lr (read_imagef of an image1d_t at 2 and of an image1d_array_t at
  (1, 1)) compiles in OpenCL mode and passes L3 on every profile the identity domains derive. It
  states OpenClMode and no OpenClLineTexture, and its images are elements of the sampled float 2D
  and 2D-array classes. On the CPU interpreter, over a 4 x 1 2D texture and a 4 x 1 2D array of two
  layers, it reads texel 2 of the first and texel 1 of the second's layer 1.
- runtime opencl_lines (device cfg, under the validation layer): __entry_ol, with its hidden
  buffers bound as Apple's OpenCL binds them, reads a 4 x 1 2D texture at x and a 2D array at
  (x, 1). It writes their sum to a third 2D texture and the array's texel to o[x]; both are
  checked.
2026-12-02 07:25:18 -08:00
Anees Iqbal 5806b10c13 Translator: a sampled cube read by face samples its cube element under the identity domains
L215 (a). A texturecube or texturecube_array read by face was declared as the binder's 2D-array
view of its faces (RuntimeFact::ImageViewShape), since SPIR-V's OpImageFetch takes no cube. The
identity domains hold a sampled cube's element as its cube view and source no such fact, so
every such read was Unsupported{IdentityDomains}.

Under the identity domains a sampled cube (not a depth cube) that is read is now declared as its
cube element, and the read samples it. It goes through element 0 of its numeric type's sampler
array (binding 2, or 4 for an integer texture), which no ID reaches: the default sampler. It
samples at the direction of the read texel's centre on its face, with the read's level as the
explicit Lod.
- On face f the centre is (sc, tc) = ((2x + 1 - w) / w, (2y + 1 - h) / h), whose numerator is an
  exact integer.
- The direction is Vulkan's cube map face selection read backwards, the table Metal's faces share.
  With m the face's sign, it is (m, -tc, -m*sc), (sc, m, m*tc) or (m*sc, -tc, m).
- Its major axis is the face's, at magnitude 1, so (s, t) on that face is the texel's centre, half
  a texel inside its cell, and nearest reads that texel. Integer Lod l under nearest mip selects
  level l.
- A sample clamps every operand, so the read is checked in the shader on every device
  (ReadCheck::Shader). x and y are tested against the extent at the level, the face against 6, the
  cube index against the cube count, and the level against the level count, with Metal's
  out-of-bounds texel outside (its alpha from the ID's word).
- slot::samples_cube_element is the one rule the declaration and the read's check share.
  SlotPlan::face_sampler gives the sampler use the sampler family declares.
- A depth cube read by face, and a cube whose faces an emulated filter fetches, keep the 2D-array
  view and stay refused under the identity domains. The table domains are unchanged.

The runtime's default samplers now reach every level (maxLod VK_LOD_CLAMP_NONE, was 0), so an
explicit level past 0 reads that level. A sampler element nobody owns holds the default, as do
nil, freed and out-of-range sampler IDs. Their samples could reach only level 0 before; they now
reach the level they ask for.
Existing tests that cover the default samplers:
- tests::arrays' set_1_is_filled_at_creation (both live with set 1);
- tests::device's gauge check (set 1's two default samplers and nothing else);
- tests::argument_sampling's argument_sampler_edges (an argument buffer's sampler against the
  default's answer).
RESOURCE-ID.md states the default sampler and the cube read's contract for a consumer that lays
the arrays out itself. API.md and the runtime README say so too; the README's known gap now names
only the depth cube read.

A refusal becomes a module, so SEMANTICS_VERSION 2315. The golden table's cube_faces cells
change from the refusal, a bless at the next pin. No refusal site was added or removed:
docs/REFUSALS.md regenerates unchanged.
2026-12-02 07:25:18 -08:00
Anees Iqbal 039de2090e Tests: a sampled cube read by face reads its texels under the identity domains
Red first for L215 (a). Under the identity domains a texturecube or texturecube_array read by
face (access::read or access::sample) is refused, Unsupported{IdentityDomains} naming
ImageViewShape: the read takes the binder's 2D-array view, which the identity arrays do not hold.
These tests now ask for Metal's answer, the texel read(coord, face[, cube], lod) names.

- engine_texture: texture_ops' cube_faces compiles and passes L3 on every profile the identity
  domains derive, with no ImageViewShape, its textures elements of the sampled float cube and
  cube-array classes, the plain sampler array declared, and an explicit-level sample where it
  fetches nothing. The CPU interpreter models no sampler, so values are a device's.
- runtime cube_reads (device cfg, under the validation layer): an RGBA32Float and an RGBA32Uint
  cube (4 x 4, three levels) and an R32Sint cube array (two cubes, two levels) read at every texel
  of every face, level and cube, each the uploaded texel bit for bit; an RGBA8Unorm_sRGB cube read
  the same way equals a 2D array's fetches of the same bytes (the device's decode); and reads past
  the level's extent on each axis, at face 6 and past, at the level count and past, at the cube
  count and past, and at u32::MAX on each operand are Metal's out-of-bounds texel (zero, alpha 1
  for R32Sint).
- validation engine_textures: the cube_faces case through the runtime, which asserted the
  refusal, now asserts its values: face 3's texel, cube 1's face 4 (layer 10), then width 1, 2
  cubes and 1 level.
2026-12-02 07:25:17 -08:00
Anees Iqbal 4295a197e1 rt: map_made answers the allocation and whether it was mapped
clippy's result_large_err refused Result<Allocation, Allocation> (job m3-max-78507, all three cfgs).
map_made now returns (Allocation, bool); a refusal is freed by its caller as before, outside the
timed map in Pool::take.
2026-12-02 07:20:50 -08:00
Anees Iqbal 531f3944d2 rt test: the block-maker panic tests' taker drops its core before it answers
The taker thread held its Arc of the core until its closure returned, after its answer, so the
device's teardown could wait for it past the test's gauge read: job m3-max-78507 read 8 blocks and
2 device samplers after the map case's teardown, the device not yet torn down. The taker now drops
the core first.
2026-12-02 07:20:50 -08:00
Anees Iqbal 71be3eedac rt: the block-maker thread ends as a stop however it ends, a panic of a consumer's hook too
What: run() holds an Ends guard whose drop, on a stop or a panic alike, stops the pool, clears
every internal asked or being made, wakes the waiters, and hands the ring's next block back to the
takes (Ring::unasked). The stop branch, which did the same for a stop alone, now only returns.
The consumer's two hooks on that thread:
- map: Pool::map_made runs BlockMappings::map under catch_unwind. Where it panics, the allocation
  just made is freed and the panic goes on (resume_unwind), on the block-maker thread (ahead) and
  on a take's thread (Pool::take) alike.
- unmap: free_idle runs BlockMappings::unmap under catch_unwind. Where it panics, the consumer's
  mappings may stand, so the allocation is not freed there: it goes back to the pool, which is
  stopped under the same lock so no take lands in it, and teardown frees it with no second unmap.
  Then the panic goes on.

Why: a panic of either hook ended the thread with the ring's ask outstanding, so a ring take that
found no free chunk waited for good, as did a call in Pool::await_made; and the allocation the
hook panicked over was never freed. Now a panic ends the thread as a quiesce does: a take of the
pool's memory is Error::Quiesced (the typed error rt already has; no new public type), what was
asked of the thread is made on the thread that needs it, as after a stop, and nothing waits.

Docs: Error::Quiesced, BlockMappings::map and BlockMappings::unmap say what a panic of the hook
does; the runtime README's mappings section the same.

Verified: the two tests every_device_whose_block_maker_thread_ends_by_{a_map,an_unmap}_hook_s_panic_leaves_nothing_waiting
(red at the previous commit) are the check; jobs in the hand-over.
2026-12-02 07:20:50 -08:00
Anees Iqbal e9b233b7c4 rt test: a block-maker thread ended by a panic of the consumer's map or unmap hook leaves nothing waiting (red)
The block-maker thread runs two of the consumer's hooks: BlockMappings::map for an allocation made
ahead of need, and BlockMappings::unmap before the free of an allocation idle past the idle age.
Where either panics, the thread ends with what was asked of it still marked asked or being made:
the ring's next block stays the thread's to make, so a ring take that finds no free chunk waits
for good, as does a call in Pool::await_made.

Two tests, one per hook, share one body. The hook is armed to hold the thread inside its run (the
map of the allocation a 12 MiB Shared take sets off; the unmap of a whole Shared unit given back
once the next is made). Takes of the parameter ring run past every free chunk on a thread of their
own until the ring has asked the thread for its next block; then the hook panics. The test waits
for the takes at most the tests' patience (60 s) and fails, not hangs, where they still wait. Then:
the pool is stopped, a take is Error::Quiesced, an internal asked now is the asking call's, the
allocation the hook panicked over is freed (gauges zero after teardown), and every other mapped
allocation is unmapped once, the one whose unmap panicked never a second time.

Expected red today: the ring's takes still wait after 60 s, in both tests.
2026-12-02 07:20:50 -08:00
Anees Iqbal bd1f8c479d CI: the private intra-doc link count runs with colour off, so a broken link counts
The step counts the lines of `cargo doc --document-private-items` that begin `error: ` and holds
each crate at its ceiling. The workflow sets CARGO_TERM_COLOR=always, under which Cargo prints
each diagnostic with a colour code ahead of `error`, so the count was 0 whatever rustdoc
reported: the step could not fail.

Verified: m3-max-78564 (msi) plants one broken private intra-doc link in the harness crate and
runs the step's count over it: CARGO_TERM_COLOR=always counts 0 (the unresolved-link diagnostic
is in the log), never counts 1. The step now sets never.
2026-12-02 07:11:57 -08:00
Anees Iqbal 118bd0dff7 Translator: a query-only argument buffer texture reads its element under the identity domains
L215 (b). An argument buffer's texture that a function only queries has no texel class: nothing
structural types it (the member's texture type is only its MSL type name, which decides nothing),
so its group is declared Float and states RuntimeFact::HeapNumericType for the binder of the
table domains. The identity domains source no such fact, so every function with such a member
was refused, whatever its shape.

Under the identity domains the group's element is the texture its resource ID names, as a
texture slot's is, and a slot only queried already takes the Float class there with no fact.
A query reads the element's extent and its level, layer and sample counts; Vulkan's image query
instructions access no texel (13.4.4), so the texture's numeric type changes nothing a query
returns. So under the identity domains a query-only group states no HeapNumericType; the table
domains keep it.

The runtime README's known gap for it goes; the golden table's tail_heap_cube_queries cells
change from the refusal, a bless at the next pin. SEMANTICS_VERSION 2314. No refusal site was
added or removed.

Verified (job m3-max-78379, msi, at this tree before its rebase onto 0b71bdf72a): the interpreter
test passes on every identity profile (2 passed with its neighbour), and on lavapipe (llvmpipe,
LLVM 23.1.1) the runtime test passes under the validation layer, both dispatches at their
addresses (M2V-FORM 0 bound, 2 at their addresses).
2026-12-02 07:00:02 -08:00
Anees Iqbal e02bfb2699 Tests: a query-only argument buffer texture answers its element's size under the identity domains
Red first for L215 (b). The pin that held the refusal of an argument buffer's texture a kernel
only queries (Unsupported{IdentityDomains}, naming HeapNumericType) now asks for Metal's answer:
the size of the texture the member's resource ID names, whatever its numeric type.

- engine_heap_groups: abq_2d (a 2D texture's width) and abq_cube_array (a cube array's cube
  count) on every profile the identity domains derive: no HeapNumericType fact, one Float sampled
  class, L3, and on the CPU interpreter, with an R32Uint texture's resource ID naming element 3,
  the width 12 and the 2 cubes from each thread, the word past them kept.
- runtime query_only_textures (device cfg, under the validation layer): the same kernels over an
  R32Uint 2D texture of 12 x 5 and three levels and an RGBA8Uint cube array of two cubes, each
  reached through an argument buffer's resource ID.

Verified red (job m3-max-78379, msi, at this tree before its rebase onto 0b71bdf72a): the
interpreter test fails at compile_kept with the refusal (1 passed, 1 failed with its neighbour),
and on lavapipe the runtime test fails at new_compute_pipeline_state (0 passed, 1 failed).
2026-12-02 07:00:02 -08:00
Anees Iqbal 357d728590 Validation tests: bin_exe! reads CARGO_BIN_EXE_<name> with env! again
56cf3dbd1b and 5d62e2079a moved the macro's compile-time fallback to option_env!, on the reading
that Cargo does not set `CARGO_BIN_EXE_<name>` for `cargo clippy --all-targets`. That reading was
wrong: Cargo sets it, and the remote CI's Linux leg lost it in scripts/rustc-wrapper, whose
/bin/sh there (dash) drops variables with a hyphen in the name. c231c41ddd runs the wrapper under
bash. The macro is again the text it had before 56cf3dbd1b, where a missing variable is a build
error rather than a test-time panic.

Verified: the next msi job's green arm runs clippy over the validation crate at this tree as CI
runs it (CI=1, a fresh target) through c231c41ddd's wrapper.
2026-12-02 06:59:54 -08:00
Anees Iqbal c231c41ddd scripts: rustc-wrapper runs under bash, so the compiler keeps Cargo's hyphenated variables
The remote CI's Linux leg has failed "Clippy (warnings denied)" on master since at least
11-15 (run 43704398652 and every push after it, 46893773054 at d8735b75f0 included): each bin_exe!
use in the validation crate's integration tests stopped with "environment variable
`CARGO_BIN_EXE_corpus-triage` not defined at compile time" (and corpus-pipeline, corpus-vulkan,
corpus-index, command-replay). The macOS leg's clippy, and every clippy in the lab, passed the
same tree on the same nightly.

The cause is the wrapper's shell. Cargo sets `CARGO_BIN_EXE_<name>` for the test's compile and
runs `scripts/rustc-wrapper` as `#!/bin/sh`. On ubuntu-26.04 /bin/sh is dash, which drops every
variable whose name is not a shell identifier from the environment it passes to exec, so rustc
never saw the hyphenated names. On Arch (the lab) and macOS /bin/sh is bash, which passes them
through. Checked by hand on macOS: `env 'CARGO_BIN_EXE_x-y=1' /bin/dash -c 'exec env'` prints
no such line; /bin/bash and /bin/sh print it.

The wrapper now names bash, present at /bin/bash on Ubuntu, Arch and macOS.

Verified: the next msi job runs clippy over the validation crate as CI runs it (CI=1, a fresh
target, env! in bin_exe!), once through the parent's wrapper under Debian's dash (red, "not
defined at compile time") and once through this one (green).
2026-12-02 06:59:34 -08:00
Anees Iqbal 5d62e2079a Validation tests: bin_exe! takes CARGO_BIN_EXE_<name> through option_env! without unwrapping it, which clippy denies
56cf3dbd1b called .expect on option_env!(...), and clippy::option_env_unwrap ("this will panic at
run-time if the environment variable doesn't exist at compile-time") is denied under -D warnings:
m3-max-78487's run at 01d80f2d65 failed five of them. The compile-time path is now one more fallback
after nextest's NEXTEST_BIN_EXE_<name>, and a test that finds neither panics naming both.

Verified: the next msi job runs clippy over the validation crate as CI does (CI=1, so
scripts/rustc-wrapper runs the compiler itself, and a fresh target), at the old macro and at this one.
2026-12-02 06:53:35 -08:00
Anees Iqbal a3cfe0be7c rt: a pool allocation the device places off a multiple of 16 is refused as Limit::AllocationAddress
What: make_allocation reads the allocation's device address and, where it is not a multiple of
16, frees the allocation and returns the new Limit::AllocationAddress { class, address }. A take
that no free range fits returns it; an allocation made ahead of need (Device::new's stock, the
block-maker thread) is not kept, so the next take makes its own and gets the refusal.

Why: Vulkan places a buffer's address at a multiple of the largest of its memory requirements'
alignment and its usages' minimum offset alignments (vkGetBufferDeviceAddress), none of which has
a lower bound of 16. Metal's offset rule for a device buffer (offset aligned to the data type's
size, at most 16) asks a base at a multiple of 16, which the translator's accesses take. A block's
buffers take the allocation's address as their base and its images sit beside them in the same
allocation, so no offset serves both; an allocation off 16 cannot keep Metal's alignment, and it
now fails visibly instead of handing out blocks the translated kernels misread (L84).

Docs: the variant's doc names Metal's counterpart and what differs; take_block's errors; the
runtime README's block contract; docs/REFUSALS.md, src/error/basis.rs (Basis: device) and
api_signatures.tsv regenerated (refusal_surface.py, signatures.py --bless).

Verified: the test every_device_hands_out_no_block_at_an_address_off_16 (red at the previous
commit) is the check; jobs in the hand-over.
2026-12-02 06:51:00 -08:00
Anees Iqbal a4a9d232c8 rt test: a device that places the pool's allocations off 16 hands out no block there (red)
What: a device-test answer, DeviceOptions::placed_past (cfg test with a device cfg), adds bytes
to the device address each pool allocation reads from vkGetBufferDeviceAddress, as a device that
places its memory there would answer. every_device_hands_out_no_block_at_an_address_off_16 opens
each device with 4 and asks that no Private or Shared block a take hands out has its first byte
off a multiple of 16.

Why (L84): a block's buffers take their allocation's address as their base. The blocks hold
images bound at memory offsets beside buffers reached by address, so no offset of ours can put
both on their alignment where Vulkan places the allocation off 16, which it may (it promises the
largest of the buffer's memory requirements' alignment and its usages' offset alignments, none
bounded below 16). Metal's offset rule for a device buffer (Apple's setBuffer(_:offset:index:):
the offset aligned to the data type's size, at most 16) asks a base at a multiple of 16. The fix
refuses such an allocation, typed.

How verified: expected red at this commit (the take hands out a block at 4 past 16); the fix
follows.
2026-12-02 06:51:00 -08:00
Anees Iqbal a4001735fb rt test: every device places a block of each class and the ring's nil buffer and zero range at a multiple of 16
What: every_device_of_the_cfgs_kind_opens_presents_and_tears_down_to_zero prints the alignment
Vulkan promises the device's buffer addresses (the largest of the buffers' memory requirements'
alignment, minStorageBufferOffsetAlignment, minUniformBufferOffsetAlignment and
minTexelBufferOffsetAlignment, the floor's usage holding each) and asserts that a Private and a
Shared block's first buffer, and the ring's nil buffer and zero range, lie at multiples of 16.

Why (L84): the ring now starts its chunks on 16 wherever the device places a block, but a block's
buffers take their allocation's address, and the blocks hold images bound at memory offsets beside
buffers reached by address, so no offset can serve both where an allocation's address is off 16.
Metal's offset rule for a device buffer (the offset aligned to its data type, up to 16; Apple's
setBuffer(_:offset:index:) page) asks a base at a multiple of 16. This pins, on every device the
device suites open, that the allocations they make lie on 16, and names the device where one does
not.

How verified: in the hand-over (lavapipe on msi, the Iris on ms01).
2026-12-02 06:51:00 -08:00
Anees Iqbal 459a50702a rt: the ring starts each chunk at a multiple of its alignment in the device address space, wherever Vulkan places the block
What: chunk_starts(address, align) now answers the skew, the first offset in a ring block whose
device address is a multiple of the ring's alignment (16, or the translator's buffer base
alignment where larger), and the chunks the block holds whole from there: 32 where Vulkan places
the block at a multiple of the alignment, 31 elsewhere. State::add places chunk i at skew + i * 64
KiB. So every write, the nil buffer, the zero range and the whole execution range lie at a
multiple of the alignment in the device address space on every device. The skew is a multiple of
the block's own placement, which holds minStorageBufferOffsetAlignment, so a set_bytes copy's
descriptor offset still meets that limit; view()'s debug check now asks the copy's device address,
not its buffer offset, to be a multiple of the alignment. Ring and README docs say so.

Why (L84): the ring assumed every chunk lay at a multiple of 16 ('like every chunk'), which held
only where the block's address did. Vulkan's vkGetBufferDeviceAddress promises a multiple of the
largest of the buffer's memory requirements' alignment and its usages' minStorage/Uniform/Texel
BufferOffsetAlignment, none bounded below 16. The translator reads a parameter block in 16-byte
lines at multiples of 16, and PushField::ZeroAddress is documented (docs/API.md section 5) as a
multiple of 16. One form on every device: the skew is 0 wherever the block's address is already a
multiple of the alignment (no lab card is expected to differ: their buffer alignments are 16 or
64), so nothing changes there; no device in reach places a block off 16.

How verified: a_block_placed_off_the_ring_s_alignment_starts_every_chunk_on_it, red at the parent
commit, green here (jobs in the hand-over).
2026-12-02 06:51:00 -08:00
Anees Iqbal fa9d917ef4 rt: a test that a ring block placed off the ring's alignment starts every chunk on it (red)
What: State::add takes its chunks' places from chunk_starts(address, align), which answers today's
layout (the first chunk at the block's first byte, 32 of them), and a device-free test,
a_block_placed_off_the_ring_s_alignment_starts_every_chunk_on_it, asks of a block at a device
address that is a multiple of 1, 2, 4, 8, 16, 64 or 256 alone that every chunk start at a multiple
of the ring's alignment (16, 64, 256) in the device address space and at a multiple of the block's
own placement in its buffer, and lie whole in the block.

Why (L84): the ring places its writes at multiples of its alignment from each chunk's first byte,
and each chunk at a multiple of 64 KiB from the block's first byte, so a write's device address is
a multiple of 16 only where the block's is. Vulkan promises a buffer's address only at a multiple
of the largest of its memory requirements' alignment and the offset alignments of its usages
(vkGetBufferDeviceAddress, the spec's alignment list), none of which has a lower bound of 16.

How verified: expected red at this commit (a block at a multiple of 4 alone puts chunk 0 at 4 past
a multiple of 16); the fix follows.
2026-12-02 06:50:59 -08:00
Anees Iqbal 01d80f2d65 AIR tests: the metallib half of the committed-fixtures test is skipped where the SDK's linker refuses the fixtures' AIR version
The remote CI's macOS leg (macos-26) has failed "Test metal2vulkan" on master since at least
959a4ccbcd (runs 46004353737, 46104484064, 46893773054): container::tests::
committed_air_fixtures_parse_and_link asserted the link succeeded, and that runner's xcrun metallib
answers "air version set to 2.9.0 (!10 = !{i32 2, i32 9, i32 0}), but expecting 2.8 in fbd_vertex".
The fixtures are compiled by the SDK scripts/regen-air-fixtures ran on, newer than the runner's, and
that linker cannot link them at all. The parse half still runs on every host; the link half is skipped
with a SKIPPED line naming the linker's answer, as it already is where xcrun metallib is absent. Any
other link failure still fails the test with the linker's stderr.

Verified: not run here (the M3 runs no tests, and its SDK links AIR 2.9); the next remote macOS run
shows it.
2026-12-02 06:50:40 -08:00
Anees Iqbal 56cf3dbd1b Validation tests: bin_exe! reads CARGO_BIN_EXE_<name> with option_env!, so clippy --all-targets compiles them
The remote CI's Linux leg has failed "Clippy (warnings denied)" on master since at least fc9c99916d
(runs 45911520903, 46004353737, 46104484064, and 46893773054 at d8735b75f0): every bin_exe! use in the
validation crate's integration tests stops with "environment variable `CARGO_BIN_EXE_corpus-triage`
not defined at compile time" (and corpus-pipeline, corpus-vulkan, corpus-index, command-replay), on
the pinned nightly-2026-11-03. The macro read the path with env!, a compile-time error where Cargo
does not set the variable. option_env! compiles either way; when the test runs, nextest's
NEXTEST_BIN_EXE_<name> or Cargo's baked-in path is still taken first, and a missing one panics with
its name instead of failing the build.

Verified: the next msi job runs clippy over the validation crate with no rustc wrapper and a fresh
target, at the parent's macro and at this one.
2026-12-02 06:50:40 -08:00
Anees Iqbal 0b71bdf72a Translator: OpenGL mode makes a rasterizing void vertex function's state as Metal does
Metal makes, under the private OpenGL mode, a rasterizing render pipeline
state whose vertex function returns void, with or without a fragment
function, and its draws run the vertex function and rasterize nothing (an
Apple M3 Max, macOS 27.0.1, conformance/probes/opengl_mode.m). The link
refused it whatever the mode (DescriptorError::RasterizedVoidVertex), so the
runtime refused a state the guest GL renderer may make.

The compile now takes such a descriptor as the descriptor with rasterization
disabled and no fragment function (private_state::unrasterized_void_vertex),
in both render_variant_key and render_pipeline, before anything compiles: a
Function vertex stage's answer through StageEntries::returns_value (the
decode its specialization through the same object shares), a Compiled one's
from its interface's position, as the link reads it. The fragment function,
which never runs, is neither compiled nor checked; a state Metal would refuse
for another reason is then made, an answer not measured, recorded in
private_state's docs. Without the mode the refusal stands, as Metal's.

The runtime needs no change: its pipelines with rasterization disabled take
the discard as dynamic state. The runtime README's known gap for this state
is removed; docs/REFUSALS.md does not list descriptor errors (its --check
passes unchanged). SEMANTICS_VERSION 2312 -> 2313 (a refusal lifted).

Verified on lavapipe (llvmpipe, msi): job m3-max-78373 at 6aab044c24 (this
change before its rebase onto 472cfba642): the runtime's opengl_mode tests 3
run, 3 passed; the translator's link test 1 run, 1 passed. Job m3-max-78378 at
24d71d71be, this commit's tree but for the version and development's two
translator commits since (edabd70447, fd8b132834) and the four that followed
up to f29613d057: clippy -D warnings over the
workspace (all targets, all features) and over the runtime under m2v_cpu_icd
and m2v_gpu, rustdoc -D warnings and the private docs of metal2vulkan and the
runtime, all clean; the runtime's suite on lavapipe 868 run, 868 passed, 3
skipped; the translator's and AIR's suites without the tables a bless is due
for 3392 run, 3392 passed, 37 skipped. No card run: the state is one form on
every device (rasterization disabled, its discard dynamic state), the form
every_device_runs_a_vertex_function_that_stores already draws on each card.
2026-12-02 06:36:32 -08:00
Anees Iqbal 0538a8395d Tests: OpenGL mode makes a rasterizing state whose vertex function returns void
Under the private OpenGL mode an Apple M3 Max (macOS 27.0.1, the probe
conformance/probes/opengl_mode.m) makes a rasterizing render pipeline state
whose vertex function returns void, with or without a fragment function: its
draw runs the vertex function, its stores landing, and leaves the colour as
cleared. The runtime refuses it in either mode (Error::Translation naming
RasterizedVoidVertex), a known gap.

The runtime's device test now asserts Metal's answer on every device: the
state is made with and without inputless_fragment, a draw of three vertices
of void_store_vertex stores the tint texel three times into its buffer, and
the cleared target reads all zero. The refusal without the mode stays
asserted. The translator's link test asserts that the mode's state compiles
to the pipeline of the descriptor with rasterization disabled and no
fragment function, rasterizer discard set.

Red until the fix that follows, verified on lavapipe in job m3-max-78373
(msi, this commit before its rebase, e25fc1be7d): the runtime's opengl_mode
tests 3 run, 2 passed, 1 failed (the new test, its state refused at
creation); the translator's test 1 run, 1 failed (the OpenGL-mode compile
refused).
2026-12-02 06:36:21 -08:00
Anees Iqbal f29613d057 Translator: a slot pointer stored through a loaded pointer or into an open cell is its Metal address
L288. Under the identity domains (and on Profile F) an escaping slot root stays static, so a
stored slot pointer is access::pointer's: its Metal address, the slot's SlotGuestBase plus its
displacement, as an 8-byte leaf. That leaf went only through a static-root destination; a store
through a pointer loaded from memory, or into a pointer cell whose bytes are read at an offset only
the run knows (an open cell), was Unsupported{Lowering(Access), NotImplemented}. Metal stores the
pointer's 64-bit address wherever it is stored.

Now the stored address goes through any destination dynamic stores a wide pointer's through: a
static-root pointer (unchanged), the address a wide pointer holds (an 8-byte store there), or an
arena's pointer cell. dynamic::store_destination and dynamic::emit_store_word are the one form
both share; dynamic's own StorePointer selects and emits through them as before. A destination in
the blob, a typed object or a constant global stays refused. Census names:
access.pointer.store_pointer.wide and .arena, as dynamic names its own.

Existing inputs keep their modules (the static-root path is unchanged); a refusal becomes a
module, so SEMANTICS_VERSION 2312. No refusal site was added or removed: docs/REFUSALS.md
regenerates unchanged.

Verified (job m3-max-78337, msi, at this tree before its rebase onto f1dfed1138): the interpreter
test passes on every identity profile and compiles and passes L3 on the bound ones (1 passed);
on lavapipe the runtime test passes, both dispatches at their addresses ("32 slot pointers stored
as their Metal addresses", M2V-FORM 0 bound, 2 at their addresses).
2026-12-02 06:35:55 -08:00
Anees Iqbal 37a5bc7f0c Tests: a slot pointer stored through a loaded pointer or into an open cell is its Metal address
Red first for L288. The pin that held the refusal (Unsupported{Lowering(Access)}, NotImplemented)
of a slot pointer stored through a pointer loaded from memory, or into an open thread cell, now
asks for Metal's answer: the stored 8 bytes are the slot's address (gpuAddress plus the bind
offset) plus the element's offset.

- engine_identity_pointers: sp_into_slot, sp_through_loaded and sp_open_cell run on the CPU
  interpreter on every profile the identity domains derive, buf bound 16 bytes past its start,
  each above 4 GiB, and must store those addresses and nothing else (a spare cell keeps its
  bytes); on the profiles that bind a kernel's buffers each must compile and pass L3.
- runtime stored_slot_pointers (device cfg): the same two kernels dispatched on every device of
  the cfg's kind, the loaded pointer naming a buffer made resident by useResource:usage:.

Verified red (job m3-max-78337, msi, at this tree before its rebase onto f1dfed1138): the
interpreter test fails at compile_kept with the refusal (0 passed, 1 failed), and on lavapipe
(llvmpipe, LLVM 23.1.1) the runtime test fails at new_compute_pipeline_state (0 passed, 1 failed).
2026-12-02 06:35:55 -08:00
Anees Iqbal ef9a825aaa rt: a helper killed mid-make leaves every make its refusal at once, and the compute make's doc says no refusal waits
What: a device test, a_helper_killed_mid_make_leaves_every_make_its_refusal_at_once. A helper
that reads the request whole and is killed partway through its reply (the consumer's memory cap
or time limit) ends Device::fill_stage at once with StageFill::Ended; the breach the consumer then
keeps, StageBreach::Memory or StageBreach::Time, answers four makes of the pipeline on threads at
once, and a later device's on the same directory, with Gap::StageSize of that breach, with no
helper asked again and no fill counted. Each call runs on a thread of its own and is given the
tests' patience, so one that waits for good fails rather than hangs. The test runs on a device
whose driver writes a pipeline cache header (lavapipe writes none and is skipped, as the other
stage tests skip it).

new_compute_pipeline_state's doc now says every error is the call's answer as it returns on the
calling thread, that no refusal waits for the consumer's helper, and that Metal's
completionHandler: forms are the consumer's, made over this call.

Why: the consumer's ledger row 1120 (an Iris Xe run at pin 28e1026b3d: 2 of 8 heavy kernels
made, 6 refused, 5 at the helper's memory cap and 1 at its time limit, then the guest app waited
at its first sample for good) was put to rt with a lead: the ring's lost-ask race (the consumer's
row 393). That race was fixed by 9749fcbd63 on 11-23, after 28e1026b3d, and is in the consumer's
current pin d8735b75f0. rt's paths from a refused or killed make to its caller hold no wait: the
make reads the stage entry and answers StageUnfilled or Gap::StageSize at once; a dispatch that
waits for another thread's make of its variant is woken when that make ends, made or failed
(Pending's drop), and makes it itself; a render state's main pipeline the same (Making's drop).
This test pins that answer for the two breaches the run met.

How verified: see the hand-over (msi lavapipe suite and clippy, Iris card run).
2026-12-02 06:26:45 -08:00
Anees Iqbal fd8b132834 Translator: a slot's direct base and address are made before the body, in the function's first block
e2e76d8879 made a slot's direct base and Metal address once, in the block that first asks for
them, and recalled them where that block dominates. Where that block was the walk's first one,
the first application of a function inlined more than once made the base after work of its own,
and every later application read it: the applications were no longer the same code, and
spirv::roll wrote the body twice where it had written it once. The identity-domains engine_roll
case shows it: three applications weighed 26,737 against one's 13,355 on lavapipe (m3-max-78287).

Now EmitCx::load_push_fields, the first hook, makes every placed SlotGuestBase slot's direct base
and address under the identity domains (pointer::make_ahead), after the push fields load and
before any other hook or the body: every block recalls them, and every application reads them
from before it. Those no access reads leave with the other unused values (spirv::dead, at the end
of emission, before the roll and the weighing). Making them in the entry block where first asked
(fb.in_entry_block) is not enough: the walk's first block is the entry block itself until a hook
closes a construct, so the base still landed inside the first application (m3-max-78326: 2.00
bodies, as before).

The arithmetic is unchanged; module bytes change (the bases move to the first block):
SEMANTICS_VERSION 2310 -> 2311. The golden table is re-blessed at the next pin.

Verified: nothing run yet for this commit; the roll, identity, identity-flow, access-size and
golden tests run next on msi.
2026-12-02 06:20:53 -08:00
Anees Iqbal edabd70447 Translator tests: a function inlined three times rolls under the identity domains
engine_roll ran only under the resident-table domains, where an access never makes the slot's
direct base. Under the identity domains, the runtime's, each application of a function reaches its
buffer at the slot's own device address. The new kernel `@head_thrice` applies `@head` three
times: it adds its constant, then loads word 0, before the body's first branch, so the first
application makes the slot's address after an instruction of its own. The test asserts on lavapipe
and MoltenVK that the entry weighs about one application (`@head_once`), that it holds one more
loop, that the slot is reached at its address (an `OpIAddCarry`), that it passes L3, and that it
computes the three applications' values on the CPU interpreter. Each profile prints its weights.

Red at development (m3-max-78287, msi): three applications weighed 26,737 against one's 13,355 on
lavapipe (2.00 bodies), and 13,539 against 13,488 at e2e76d8879^ (1.00). With the load as the
application's first instruction both forms rolled (m3-max-78272): the run then starts after the
first application's two extracts, so that shape does not show it.
2026-12-02 06:20:53 -08:00
Anees Iqbal 472cfba642 Runtime: a viewport Vulkan takes in no form that covers no pixel of the render area draws nothing
set_viewport and set_viewports refused, as Gap::Draw of DrawKind::Viewport, every viewport that
VkViewport's valid usage forbids: an extent past maxViewportDimensions, a corner past
viewportBoundsRange (VUID-VkViewport-width-01771, -height-01773, -x-01774, -x-01232, -y-01775,
-y-01776, -y-01777, -y-01233), a negative width, and depths past [0, 1] (the runtime enables no
VK_EXT_depth_range_unrestricted). Metal documents no such limit. A user met the refusal four times
in one session, and a WebGL 1 page reaches it with a far gl.viewport: 32768 is the bounds range on
the 780M and Iris profiles, 65536 on NVIDIA's.

No other Vulkan viewport maps clip space as one of these does, since a viewport's transform is
fixed by its own origin and extent. But where such a viewport covers no pixel of Metal's render
area, Metal draws nothing through it, as the rt draws nothing through a viewport of no extent. So
checked() now keeps a viewport Vulkan takes as it is, makes one it does not take that covers no
pixel (viewport_pixels) a viewport of no width or height at the area's origin with its depths cut
to [0, 1], which Vulkan takes and whose draws record an empty scissor, and refuses the rest. With
the bounds Vulkan requires (at least twice the largest extent past either side of the origin) and
an area no larger than maxViewportDimensions, a viewport past the bounds within that extent covers
a pixel only where its edge lies inside the last pixel of an area of the largest size; WebGL's
integer origins never do. What stays refused: a negative width over the area (Metal mirrors it), a
depth range past [0, 1] over it, an extent past maxViewportDimensions over it, and that last-pixel
edge. DrawKind::Viewport, set_viewport and the runtime README (Render encoders, and its known gaps)
say so. docs/REFUSALS.md regenerates unchanged: the Gap::Draw row and its checked() site stay.

The refusal test's mirrored viewport now lies over the target (origin x 4, width -4); at origin 0
it covered no pixel and now draws nothing, as Metal's. The new test also sets a mirrored viewport
and one with depths past [0, 1], both off the target.

Verified:
- Red: the test commit 17aa4279b3 on lavapipe (job m3-max-78333): 0 passed, 1 failed, at
  draw.rs:501, the set_viewport of the first far viewport.
- Green, this commit's tree (fd7df2eccb), run as a scratch commit of the same tree: lavapipe (job
  m3-max-78345) 3 passed, 868 skipped: the new test, the triangle test and the refusal test, under
  the validation layer, "10 viewports past bounds [-32768, 32768] and dimensions [16384, 16384]
  drew nothing". The same three tests from one msi-built gpucfg archive under the carried
  validation layer 1.4.363.0, each 3 passed, 870 skipped: Radeon 780M, RADV, Mesa 26.2.6 (job
  m3-max-78347, bounds [-32768, 32767], dimensions 16384); Iris Xe, ANV, Mesa 26.2.6 (job
  m3-max-78348, the same limits); RTX 3090, NVIDIA 620.70.06 (job m3-max-78349, bounds
  [-65536, 65536], dimensions 32768); RX 7900 XTX, RADV, Mesa 26.2.6 (job m3-max-78350, bounds
  [-32768, 32767], dimensions 16384).
- Job m3-max-78346: clippy -D warnings on metal2vulkan-runtime, all targets and features, plain,
  --cfg m2v_gpu and --cfg m2v_cpu_icd, each exit 0; the runtime's whole suite on lavapipe, 868
  passed, 3 skipped. Job m3-max-78371: the runtime's rustdoc with warnings denied, public and with
  private items, 0 diagnostics. scripts/api-signatures/signatures.py --check and
  refusal_surface.py --check pass. cargo fmt --all.
2026-12-02 06:15:13 -08:00
Anees Iqbal b0a8bd866b Runtime test: a viewport past the device's bounds that covers no pixel draws nothing
every_device_draws_nothing_through_a_viewport_past_its_bounds sets seven viewports, each past
one of the device's own limits and over no pixel of an 8 by 8 target: an origin whose x plus the
width passes the top of viewportBoundsRange (what a WebGL 1 page's far gl.viewport reaches), an
origin below its bottom, the same two in y, a flipped viewport whose origin passes the top, and
one wider and one taller than maxViewportDimensions. It draws the whole of clip space in white
through each, and once more through setViewports with the far one as viewport 0. Metal draws
nothing through any of them: its viewport maps clip space onto pixels the target does not hold.
A viewport wider than the largest over the target stays refused (Gap::Draw Viewport), since no
Vulkan viewport maps clip space as it does. Then the whole of clip space in blue through the left
half's viewport, and the target is compared texel by texel with the CPU reference: left half
blue, right half the clear's black. The validation layer checks every viewport recorded.

Today set_viewport refuses the first viewport (Gap::Draw Viewport), so the test fails on every
device; the next commit makes it pass.
2026-12-02 06:15:13 -08:00
Anees Iqbal f1dfed1138 Translator: a slot's direct base takes no borrow; an unbiased SlotGuestBase word there is an invariant error
pointer::direct_base made its base in one of two ways. A biased SlotGuestBase word was used as
it is. An unbiased one, a device-replay variant's under the identity domains, was the word less
2^31, with a borrow from the high word. No admitted compile reaches the second arm.
plan_replay (lower/access/mod.rs) swaps every SlotGuestBase field for RootTableAddress, and
identity_refusal (lower/select.rs) refuses RootTableAddress. identity_admits runs at the end of
every identity select, before emission. So a replay variant that reaches a slot is refused,
typed, under the identity domains, and the emitter never runs with identity && replay.
a_replay_variant_under_the_identity_domains_is_refused_typed (pipeline/compile/tests.rs) holds
that refusal for a vertex function's and a kernel's buffers.

The arm goes. Its place returns an invariant error (EmitCx::fail), so an identity+replay
compile that select admits one day fails visibly and is never silently wrong. Nothing else was
used only by the arm: k32, BinOp and biased all keep other callers. Module bytes do not change
(the arm emitted nothing in an admitted compile), so SEMANTICS_VERSION stays.

Verified: not yet run; the msi job's results follow in the hand-over.
2026-12-02 05:48:53 -08:00
Anees Iqbal 6fff439212 Tests: an irreducible cycle and a phi over two slots under the identity domains, checked by value
Since e2e76d8879 a slot's direct base and address are made once where they dominate (EmitCx's
memo). The finalize verifier catches a use its definition does not dominate, but not a wrong
address. These two shapes had no executed identity-domain test: fuzz_interp's irreducible
automata run only under the resident tables and reach no slot inside the cycle, and the public
pointer-phi fixture runs in the validation executor under the resident tables.

engine_identity_flow, on every committed profile the identity domains derive (lavapipe
asserted among them), compiled with no descriptor, passed through L3 and run on the CPU
interpreter. It checks every word of every buffer against a CPU walk of the program:
- cycle: a two-block cycle entered at either block by the thread's parity. The entry reads
  slot 1. Slots 0, 2 and 3 are first reached inside the cycle, in blocks neither of which
  dominates the other: step sums go to slot 0, and a slot-2 word's Metal address (ptrtoint) is
  stored to slot 3 inside the cycle. The exit stores the sum and the exit block.
- merged: a phi of slot 0 and slot 1 (each path first reads the other slot), read and written at
  the thread's index after the merge, compared with slot 1's pointer (eq and ult), stored as two
  words and as a pointer, then slot 1 read directly.
Slots lie just below and just above 2^31, with bind offsets that are not 0, and some buffers
cross 2^31, 6 GiB or 12 GiB inside the bytes the kernel reaches. So the carry of each biased
access and the bias that a pointer used as a value adds back both show in the answers, and a
compare of biased words would answer the other way.

Verified: not yet run; the msi job's results follow in the hand-over.
2026-12-02 05:48:17 -08:00
Anees Iqbal a6e42ca617 Translator: the bind residual's push comment says what it holds, past the offset alignment
The comment on PushField::SlotBindOffset's shape said the residual is below
min{Storage,Uniform}BufferOffsetAlignment. It is not: where several bind offsets share one
descriptor range, a slot's residual is hundreds or thousands of bytes, which
a_constant_slot_reads_exactly_far_above_its_descriptor_base (tests/engine_access.rs) reads
exactly at 256 and 4096. The comment now states the field as sym.rs documents it (the bind offset
less the descriptor base, modulo 2^32) and names that test, and says the other field of the arm is
a pulled vertex buffer layout's stride. One u32 holds both; nothing else changes.

Doc only; cargo fmt --all.
2026-12-02 05:39:51 -08:00
Anees Iqbal 19e2b1f3ef Replay: a pass uses an exported surface only while one of its attachments holds a surface's texture
The audit lane found that a render pass descriptor stayed among the surface passes once any
attachment setter named a surface's texture, even after that attachment took an ordinary texture,
so its encoders' commits counted as hand-over parts and the hand-over line could show a false
"differ" (exported.rs:178-183 at cc3188c3da). The backend now keeps, per descriptor, the
attachment properties (texture or resolveTexture of each color attachment, depth and stencil) that
hold a surface's texture: a setter's object there sets or clears its property, a nil property keeps
what it held, and the descriptor counts while any property holds one. A unit test of the backend
plays the replacement: a plane at color 0, an ordinary texture at color 1 and a nil at color 0
(still a part), an ordinary texture at color 0 (no part), the plane's view as the depth
attachment's resolve texture (a part again), then object 0 there (none).
2026-12-02 05:39:50 -08:00
Anees Iqbal edee7b22ec Replay: the stand-in makes no import Vulkan forbids: no dedicated opaque fd import, no memory type its buffer lacks
The audit lane read the stand-in cold (standin.rs:262, 288-290 at cc3188c3da):
- An opaque fd's import named the stand-in's buffer in VkMemoryDedicatedAllocateInfo wherever the
  driver keeps that buffer to a dedicated allocation. Such an import must name a buffer identical
  to the exporter's (VUID-VkMemoryDedicatedAllocateInfo-buffer-01879), and the runtime's export is
  dedicated to its own buffer, of other usage, whose create info the export does not give. That
  case is now an import the stand-in cannot make, counted with that reason; an opaque fd's import
  is dedicated to no buffer.
- The import bound memory of the export's type without checking that the stand-in's buffer lists
  it (VUID-vkBindBufferMemory-memory-01035). A type the buffer does not list is now an import
  failure with that reason, before the allocation.
docs/REPLAY-STREAM.md section 10 says both.
2026-12-02 05:39:50 -08:00
Anees Iqbal 4233a1127b Runtime: a surface image's mark names the image's stand-ins, the field that holds it
The doc of SurfaceImage::linear_attachment named Image's linear_attachment, which the
stand-in form replaced with stand_ins. Docs only.
2026-12-02 05:39:50 -08:00
Anees Iqbal 51f93ee1fd Runtime: a plane's stand-in makes no sampled or storage view
At 951aff127e the stand-in's make took the plan of a Private render target, which has a
sampled view, and dropped the views make returned: one VkImageView leaked per stand-in, which
the validation layer reported at vkDestroyDevice (VUID-vkDestroyDevice-device-05137) in each
NVIDIA test that makes one (RTX 3090, NVIDIA 620.70.06, job m3-max-78190). Every render and
every plane-copy count was right there. The stand-in is only rendered, resolved into and
copied, so its plan now has no sampled view, no storage view and no sRGB twin, and make makes
no view; the stand-in's own attachment view is unchanged.
2026-12-02 05:39:50 -08:00
Anees Iqbal 23847fe2ae Runtime: a pass that mixes a marked surface plane with another attachment renders it through a stand-in
A surface plane in place whose format's LINEAR tiling renders only through
VK_FORMAT_FEATURE_2_LINEAR_COLOR_ATTACHMENT_BIT_NV (VK_NV_linear_color_attachment: such a
format renders "as long as all the color attachments in the render pass instance have
VK_IMAGE_TILING_LINEAR tiling") was refused in any pass that set something beside it,
Gap::LinearPlanePass. A guest met it: a view of an exported 1920x1080 surface's R8 luma plane as
colour 0 beside an ordinary RG8 texture as colour 1, both loaded and stored. Red on the RTX 5080
Laptop GPU (job m3-max-78092) and the RTX 3090 (job m3-max-78106, NVIDIA 620.70.06).

The planner's ruling, form (ii): in a pass that mixes a marked plane with another attachment (a
colour attachment that is not one, a depth or stencil attachment, or a multisample attachment
resolving into it; decided by the format query's mark and the pass's attachments alone,
pass::mixes_linear), each marked colour attachment and each marked resolve target renders into
its stand-in, an optimal image of the runtime's of the plane's format and size
(TextureObject::stand_in). The pass's begin moves the stand-in from undefined and, where the
plane's Vulkan load op is LOAD, copies the render area of the plane into it; its end copies the
stand-in's render area into the plane where its store op is STORE or the pass resolves into it.
The plane stays general. A pass of marked planes alone still renders them in place; a device
whose LINEAR tiling offers the format as a colour attachment renders the plane in place in every
pass.

Counted: Metrics::plane_copies_in, plane_copy_in_bytes, plane_copies_out, plane_copy_out_bytes
(in bytes_copied too). The guest's pass pays both: its luma plane is loaded and stored, so each
run copies 2,073,600 bytes in and 2,073,600 bytes out. The stand-ins are bounded by structure,
one per (plane image, format), made at the first mixed pass and freed with the plane
(StandIns, Free::StandIn), counted in Gauges::plane_stand_ins and plane_stand_in_bytes, which
each_device checks are zero at the device's drop. A draw of such a pass that reads the plane
through a texture, or fetches it, stays refused: Gap::Draw of AttachmentRead or
FetchedAttachment (the plane holds what the pass rendered only after its end); a read of another
plane of the same surface is not.

Gap::LinearPlanePass and LinearPlanePassKind are gone: every kind (OtherColor, DepthStencil,
Resolve) renders. AGENTS.md's rule 2 grows to thirteen forms with the mixed-pass entry; the
runtime README's exported surfaces, floor and render encoder known gaps say the form and its
cost; docs/REFUSALS.md and the signatures table are regenerated.

Tests: the plane tests assert the plane copies (none in place; one out for a cleared plane
beside a colour or resolved into; one in and one out for the loaded plane beside a depth
attachment and the guest's pass), and a new test runs eight mixed passes over one plane: one
stand-in where it is marked, none elsewhere, freed when the surface drops. The unit test of
mixes_linear replaces linear_shape's. Device runs follow in the lane's report.
2026-12-02 05:39:50 -08:00
Anees Iqbal 29cb25b5a8 Runtime tests: the depth test passes its depth-stencil state as the encoder takes it, an option
The test at 3fae8a4632 did not compile (job m3-max-78124): set_depth_stencil_state takes
Option<&DepthStencilState>.
2026-12-02 05:39:50 -08:00
Anees Iqbal 790f5b3cac Runtime tests: a surface plane renders in every pass shape, beside a depth attachment among them
every_device_renders_a_plane_alone_and_holds_a_marked_one_to_its_rule asserted that a marked
plane (an opaque handle's plane in place whose LINEAR tiling renders only through
VK_FORMAT_FEATURE_2_LINEAR_COLOR_ATTACHMENT_BIT_NV) is refused beside another colour attachment,
beside a depth attachment and as a resolve target. The planner ruled that such a plane renders
in every pass shape, through an optimal image of the runtime's where the pass mixes it with
another attachment. The test becomes every_device_renders_a_plane_in_every_pass_shape: a draw
into one plane, both planes in one pass, a plane cleared beside another colour attachment (that
one compared too) and a multisample attachment resolved into a plane, each read back exact.

The draw beside a depth attachment gets its own test,
every_device_draws_into_a_plane_beside_a_depth_attachment, since an RTX 3090 lost the device
rendering a linear colour attachment beside one: a plane loaded green, a depth attachment cleared
to 1, and the fixture's whole-clip-space triangle drawn blue under Less with writes; every texel
of the plane reads blue.

Expected red where the plane is marked (the RTX 3090 and the RTX 5080 Laptop GPU refuse the pass
as it begins, Gap::LinearPlanePass), green where it is not (RADV, ANV, lavapipe).
2026-12-02 05:39:50 -08:00
Anees Iqbal ad79dedbcd Runtime tests: the guest's pass gives the plane view and the chroma texture indices
A view or texture that shaders may read takes an index; the lavapipe run (m3-max-78076) refused
the view without one.
2026-12-02 05:39:50 -08:00
Anees Iqbal 23fe8702b5 Runtime tests: a guest's pass of a surface plane view beside an ordinary colour attachment renders
The regression's replay, from a recording's refused descriptor (an arm64 guest recording its
screen through the consumer's H.264 encoder on NVENC, every recorded frame flat green): colour 0
a view (its own format, level 0, slice 0) of the R8Unorm luma plane of an exported 1920x1080
two-plane surface in the opaque handle, colour 1 an ordinary Private RG8Unorm 1920x1080 texture,
both Load and Store, one sample, no depth or stencil. Each is cleared alone, then one draw writes
luma 1 and chroma (1, 0), and both are read back through a blit, every texel compared.

It prints the surface's form, R8's and RG8's LINEAR colour attachment bits, whether the device
enabled VK_NV_linear_color_attachment and whether the luma plane is marked. Expected to fail
where the luma plane is marked (its LINEAR tiling renders through
LINEAR_COLOR_ATTACHMENT_BIT_NV alone): the pass is refused as it begins,
Gap::LinearPlanePass { kind: OtherColor }.
2026-12-02 05:39:50 -08:00
Anees Iqbal cdb4725308 Runtime README: the known gaps of a release and acquire with nothing between, and of an exported block reached by address alone
README C. Vulkan 1.4 section 7.7.6's note calls an acquire after a release with no other
release between invalid. The APIs that share an exported surface or block (VA-API, NVDEC,
Direct3D 11) have no release of their own, so where the other side did nothing between two of
rt's submissions, rt's release and next acquire meet with no external operation between. The
form stays; the known gap says so and when it reopens.

README D. The residency-set line gains its exported-block case: a buffer in an exported block
reached only through an address (never bound, declared or kept) puts nothing in its segment's
hand-overs, so its part neither acquires nor releases the block.

Docs only.
2026-12-02 05:39:50 -08:00
Anees Iqbal 87081c05bb Runtime: a surface's planes and buffer are handed over together, and its making releases from the general layout
FIX A. An exported surface in place is one memory that its planes' images and its buffer
alias, and Vulkan 1.4 section 7.7.6 makes "the contents of any other resource aliasing the
transferred memory" undefined after a release or an acquire. A part that used only the planes
handed over only the planes, and a part that used only Surface::buffer only the buffer's block.
Now the surface's make gives its planes one handed::Aliases set, which the buffer joins when
Surface::buffer makes it (memory::Block::aliases, Under::Surface's aliases); Handed::keep adds
every living member with any one, so each part's one acquire and one release name the planes
and the buffer as further entries of the same barriers. No barrier is added. The set holds its
members weakly: one gone is handed over no more. The making is not expanded: the buffer has no
making of its own, and the planes' making releases only what was made.

FIX B. The making released each plane from the undefined layout, while every later acquire and
release names the general layout, and a release's layouts are its acquire's (section 7.7.6). Now
Upload::hand_over records, for a making, the planes' moves out of the undefined layout first,
within the runtime's queue family (handed::moves, Image::making_move), counted in
Metrics::upload_barriers, then the release from and to the general layout. One barrier more per
surface at its making; nothing per picture changes.

The README's making and hand-over text says both.

Tests: ad65d6a70e's two structural tests, red on lavapipe at ad65d6a70e (job m3-max-78062);
the green runs follow in the lane's report.
2026-12-02 05:39:49 -08:00
Anees Iqbal 4a9437f6b3 Runtime tests: the picture loop prints its surface's making's counts
The counts of the surface's make and its ready wait, which submits its making ([barriers,
runtime command buffers, submissions, acquires, releases]), beside each picture's: a change to
the making shows there, and a picture's counts show it changed nothing per picture.
2026-12-02 05:39:49 -08:00
Anees Iqbal e3493ad83c Runtime tests: an exported surface's planes and buffer are handed over together, in the general layout
Two structural tests over the layouts recorder, which now keeps each barrier's ownership
transfers to or from the external or foreign queue family (images with their old and new
layouts, and buffers), in the order submitted.

- A part that uses only an exported surface's planes in place, and a part that uses only its
  buffer, each name both the planes and the buffer in their one acquire and their one release:
  the two alias one memory, and Vulkan 1.4 section 7.7.6 makes "the contents of any other
  resource aliasing the transferred memory ... undefined after a release or acquire operation".
- Every hand-over of such a plane, the making's release included, names the general layout as
  its old and its new layout: a release's layouts are its acquire's (section 7.7.6), and every
  acquire names the general layout.

Both fail at this commit: a planes-only part hands over only the planes, a buffer-only part only
the buffer, and the making releases each plane from the undefined layout.
2026-12-02 05:39:49 -08:00
Anees Iqbal cbd5423458 Replay device tests: the layer guard is LayerOn, apart from the profiles layer's Layered; the test device constant is the device tests' hosts' 2026-12-02 05:39:49 -08:00
Anees Iqbal 909739e23f Replay device tests: every device a test opens runs under the validation layer, as VALIDATION.md says
VALIDATION.md's GPU-leg row says the replay player's device tests (replay::rt_replay) run under
the validation layer, but only the exported-surface test enabled it: the jobs put the layer on the
loader's path and nothing in the validation crate turned it on. Each test's pipeline cache
directory (ScratchCache), which every rt_replay test holds longer than its devices, now puts the
layer over the process's instances through candidate::Layered (the candidate runs' helper, which
validated now uses too): rt_device asserts the device lists the layer as an active tool, and the
cache's drop fails the test on any message the layer logged. The exported-surface test no longer
wraps itself. rt_replay, and places' device test that shares its helpers, are Linux's and macOS's,
where the candidate's platform gives the layer.

Cost (job m3-max-78137 at edc3bfa01b, lavapipe on msi, LP_NUM_THREADS=1): ID:rt's device filter
94.9 s; replay::rt_replay alone 1.4 s bare, 1.5 s with the layer enabled through the same
variables, no layer message. Unverified here: the run with this commit follows.
2026-12-02 05:39:49 -08:00
Anees Iqbal e5631ea806 Validation tests: the wait tests' fake source is gated with the tests that use it, which Windows leaves out 2026-12-02 05:39:49 -08:00
Anees Iqbal e8f9ecf7f0 Validation tests: the build-support fingerprint hex-encodes its digest byte by byte, which sha2's array type does not format 2026-12-02 05:39:49 -08:00
Anees Iqbal ca370da605 Replay: the stand-in for the other API is Linux's and macOS's; the validation crate's clippy for Windows passes
The validation crate builds for x86_64-pc-windows-gnullvm (with llvm-mingw for the bundled
SQLite, as win-cross.sh builds command-replay for the Windows play), and its clippy there (job
m3-max-78094 at abf7b8f873, plain and under --cfg m2v_gpu) reported the stand-in: its writes wait
under the crate's bounded fence waits (gpu::wait::vulkan), which the crate keeps to Linux and macOS,
and its empty extension list for an NT handle did not type-check. Rather than a Windows form of the
fence wait, the stand-in is Linux's and macOS's alone: its import is fd-only, and on any other host
StandIn::new says why it is absent, so each landing is counted unwritten with that reason and the
play goes on (the S1 ruling's handling of a stand-in that cannot be made). The NT-handle import,
which no build compiled, is gone, and so is the device test's Windows arm: the test, under the
layer through candidate::validated, is Linux's and macOS's. A plane's rows are the caller's tuple.

The same clippy reported lib-test code that predates the exported surfaces and never compiled for
Windows: build_support_tests.rs hex-encoded through crate::hash (not on Windows; now sha2's own
lower-hex), and gpu/wait.rs's tests of the fence and Metal waits' own endings, which Windows lacks
(now gated as those variants are).

docs/REPLAY-STREAM.md section 10 says the stand-in is Linux's and macOS's and what Windows counts.
2026-12-02 05:39:49 -08:00
Anees Iqbal b111f209ec Replay: the stand-in's device keeps its loader word as the candidate's context does; a doc line no longer starts a list
Clippy of the validation crate (job m3-max-78070, aeb43cd8b7, default and m2v_cpu_icd configs)
refused the stand-in's direct vkGetDeviceQueue, vkAllocateCommandBuffers and vkDestroyDevice: the
crate's clippy.toml keeps those loader-served calls behind the loader word a driver may write over
while reporting a message (candidate/platform/loader_word.rs). The stand-in now records its device's
word as vkCreateDevice returns it and puts it back before each such call on Linux and macOS, with
the crate's #[expect(clippy::disallowed_methods)] at those sites as VulkanContext has; LoaderWord is
re-exported to the crate for it. A redundant deref and a doc line that began with "+ " (a list
item to rustdoc's markdown) are fixed.
2026-12-02 05:39:49 -08:00
Anees Iqbal edc657331a Replay: the exported-surface device test plays under the validation layer; the format doc's exported-surface records
The device test of the exported-surface snippet ran with the layer on the loader's path but not
enabled: the validation crate's replay tests make their instance with no layer. Each of its plays
now runs under the Khronos validation layer as the candidate runs do (candidate::validated, made
reachable from the replay tests): the device must list the layer as an active tool, and any
message the layer logs fails the test, the stand-in's device's included, since it lives on the
runtime's instance.

docs/REPLAY-STREAM.md: section 4 points at the records, section 7 gives them (m2v.newExportedSurface,
m2v.surfacePlane, m2v.exportSurface, m2v.surfaceWritesDone, release), and section 10 says what the
player does at each, the stand-in for the other API, what a player cannot reproduce, the runtime's
hand-overs with its Metrics docs as the contract, the hand-over and exported-surfaces report lines
and counters, --video-handle's override, and `command-replay snippet video-surfaces`.

Verified before this commit (job m3-max-78051, f58ff0a2b3, lavapipe on msi, layer on the path
but not enabled): dma-buf in place and opaque-fd in the copy form each play 3 frames that agree
with the contract (acquires 2, releases 3 in frame 0 and 2 after) and 6 checks that match.
2026-12-02 05:39:49 -08:00
Anees Iqbal 02325796bc Replay: the exported-surface records, played through the runtime's surface call with a stand-in for the other API
The player plays m2v.newExportedSurface, m2v.surfacePlane, m2v.exportSurface and
m2v.surfaceWritesDone (the snippet's records) through Device::new_exported_surface,
Surface::planes, Surface::wait_until_ready and Surface::external_writes_done. Where the
stream was recorded a decoder wrote each picture; on replay a Vulkan device of the
player's own, on the runtime's instance and physical device, imports the surface's
handle, copies the picture's packed rows into its memory at the play's layout (or fills
it with the landing's number where the stream holds no bytes), releases it to the
handle's queue family and waits on its own fence. An import or write the stand-in cannot
make is counted on the exported-surfaces line and the play goes on.

The backend also counts what the runtime's hand-overs follow from, per frame: commits
whose command buffers name a texture in an exported surface, the makings a submission
carried, the pictures landed, and CPU calls on such textures (frames with those are not
judged). The report's hand-over line compares each frame's external_acquires and
external_releases with the runtime's Metrics contract at this commit: one acquire per
such submission, one release per such submission plus one per submission carrying a
making.

Unverified at this commit: the lavapipe run follows.
2026-12-02 05:39:49 -08:00
Anees Iqbal e4c206f759 Validation tests: an exported surface's snippet, its hand-overs per picture as the runtime's contract says
What: snippets::video_surfaces writes a synthetic stream of our own: one exported surface of a
64x36 8-bit 4:2:0 picture's two planes (m2v.newExportedSurface, m2v.surfacePlane, a view of the
luma plane, m2v.exportSurface), then three pictures of our own bytes (m2v.surfaceWritesDone), each
in a frame of its own: two submission parts (m2v.split) read the planes back into Shared buffers,
a third command buffer uses none of the surface, and m2v.check compares the read-backs with our
bytes. The device test plays it for each handle the host has and asserts that every frame's
external acquires and releases agree with the report's hand-over line (the runtime's documented
contract), that every check matches, and that nothing is skipped; a handle the device does not
export is counted and passed over.

Why: no recorded stream carries the exported-surface hand-over the consumer's video uses; this
test fails until the player plays the record family (it refuses m2v.newExportedSurface now).

Verified: not yet run; its first run is the red one, before the player change.
2026-12-02 05:39:48 -08:00
Anees Iqbal 6ae68f6eab Runtime tests: an acquire from the general layout moves an image over another API's memory home
The layouts recorder's moves() took an image's move home to be a barrier of its first level from
the undefined or the preinitialized layout, so a texture over a dma-buf in place, whose move home
is its acquire from the foreign queue family from the general layout (Vulkan's section 12.10.1:
that acquire's layout is the image's true initial layout), would have been noted as a step before
its move home, as would a Direct3D 11 plane's first acquire. No test read moves() for either.

The recorder now keeps the memory allocated from another API's handle (VkImportMemoryFdInfoKHR,
VkImportMemoryWin32HandleInfoKHR, through vkAllocateMemory) and the images made with external
memory info that vkBindImageMemory binds to it. For such an image alone, an acquire of its first
level from the external or foreign queue family from the general layout is its move home where
it has not moved home, and a use after. For every other image a first move from the general
layout stays a step before its move home. An exported surface's dma-buf planes are bound to the
runtime's own imports of its export, which the record does not tell from another API's; the
module doc says so.

Tests: a device-free test of the step a barrier is (an acquire over another API's memory, over
the runtime's, at another level, a release, a plain barrier, from undefined) and of take() (the
first acquire a move home, the second a use, a plain barrier first out of order); and import_overs'
dma-buf layouts test reads moves() and asserts no step out of order.

Also: forget() gets its own doc line, and barriers()'s doc is back above barriers().
2026-12-02 05:39:48 -08:00
Anees Iqbal 28a4ee50a8 Runtime README: a dma-buf texture's first acquire names the general layout by convention, not by a sentence
The planner's ruling on d789ca7aa5. The first acquire of a texture in place over a dma-buf's import
names the general layout as its old one, though the runtime has released nothing yet and the
image was made undefined. For a Direct3D 11 plane that layout stands on section 12.10.1 with
Table 17 (External Image Implied Layouts). Table 17 lists no dma-buf handle type, and section
12.10.1 leaves layouts to the other API, so no sentence names the dma-buf's layout there: the
first acquire's old layout is general by the same convention as the later ones. Imported blocks
says so, and Known gaps of memory blocks lists it. The undefined layout there would discard the
bytes, so the code stays.

Docs only.
2026-12-02 05:39:48 -08:00
Anees Iqbal 5ae5d0a169 Runtime tests: the external-image check compares its layout with assert!, ImageLayout having no Debug
no_external_preinitialized used assert_eq! on a vk::ImageLayout, which this build of ash gives no
Debug, so the runtime's lib tests did not compile at 49583b80c0 (lavapipe jobs m3-max-77905 and
m3-max-77906 stopped at E0277). The check now compares with assert! and prints the layout's
number, as the message already did.
2026-12-02 05:39:48 -08:00
Anees Iqbal e61d47452f Runtime README: a write to an imported dma-buf through another mapping is a host write
The planner's ruling on the aliased-write row. Imported blocks' coherence paragraph says that rt
takes a write to an imported dma-buf's pages, made through another mapping of the same pages, as a
host write to that memory, and that rt imports a dma-buf only into a host-visible, host-coherent
type on a device whose Shared type is host-coherent, refusing otherwise
(Limit::ImportCoherence, Limit::ImportType), so no flush or invalidate is owed (import.rs at
lines 420, 431, 439, 444, 530 and 696, read by main). Known gaps of memory blocks records that
Vulkan defines host access only through its own mapping and host-pointer imports, so the order of
such a write rests on the pages being the same and the type host-coherent, measured on the
Radeon 780M (RADV), not on a sentence of the spec.

Docs only.
2026-12-02 05:39:48 -08:00
Anees Iqbal 6fe011608a Runtime: a texture over a dma-buf in place is acquired from the general layout, never preinitialized
A texture over a buffer in a dma-buf's import, in place, is a linear image made with the import's
handle, so undefined (VUID-VkImageCreateInfo-pNext-01443). Its move home is the acquire of the
image and the buffer's range under it from the foreign queue family, and that acquire's old layout
is the image's true initial layout (section 12.10.1). It named the preinitialized layout: the
Source::Over in-place arm of Device::new_texture set first to PREINITIALIZED for every image in
place, the dma-buf's included, and Image::homing's foreign acquire named it.

The planner's ruling: no image with external memory info is named in the preinitialized layout,
and the acquire names the layout the memory was released in. The arm now sets first to
PREINITIALIZED only for an image of the runtime's own memory (made preinitialized, Laid::Own); the
dma-buf's image keeps first undefined, and homing's foreign acquire names the general layout
(first.old_layout(home)), the layout of the runtime's own hand-overs, in which a linear image and
the buffer are host-accessible aliases that read the bytes alike (section 12.11). copy_layout,
which took a preinitialized first to mean an image in place, also takes an image with a foreign
acquire as one, so a copy keeps it in the general layout. writes_whole already excluded it.

After this, no product code names the preinitialized layout for an image made with external
memory info: the remaining PREINITIALIZED sites are the in-place arm for the runtime's own memory
(texture.rs:1718), the probe image of linear_layout (texture.rs:2556, never bound) and
image_create's None-handle arm (texture.rs:3421); the handle arm makes undefined.

README: Imported blocks and Buffer::new_texture name the general layout as the acquire's old one.

Pinned by the previous commit's test (import_overs:
every_device_names_a_texture_over_a_dma_buf_in_no_preinitialized_layout), red before this commit
and green after on lavapipe (llvmpipe); jobs reported with the series.
2026-12-02 05:39:48 -08:00
Anees Iqbal 30b21e5ffb Runtime tests: no command names an image made with external memory info in the preinitialized layout
The layouts recorder keeps each image made with VkExternalMemoryImageCreateInfo in its chain, with
the layout it was made in. no_external_preinitialized checks every such image of a device: made
undefined (VUID-VkImageCreateInfo-pNext-01443), and named in the preinitialized layout by no
command. An acquire's old layout is such an image's true initial layout (section 12.10.1), and
Vulkan names the preinitialized layout only as one an image is made in and, under memory
aliasing, as the old layout of a move after host writes through an alias (section 12.11).

Two tests use it, each under a recording:
- import_overs: a texture over a dma-buf's buffer, read by a blit; exact against the CPU's bytes,
  and in place exactly one external image named.
- surface: every row the device exports, on the 1080p picture: read after external_writes_done,
  then written by a blit; every plane in place named.

At this commit the dma-buf test fails where the texture takes the form in place: the image's move
home is the acquire from the foreign queue family from the preinitialized layout
(texture.rs, the Source::Over in-place arm sets first to PREINITIALIZED for the dma-buf's image
too; Image::homing's foreign acquire names it). The next commit fixes it.
2026-12-02 05:39:48 -08:00
Anees Iqbal d562f130a6 Runtime: a making's wait for the work lock is a home lock wait; the ready-order test reads the semaphore
Work::create, which an exported block's or surface's make calls to owe its making to the next
submission's upload, waits for the submit side's work lock as a texture's move home does. It now
times that wait as Part::HomeLock, so Metrics::home_lock_waits counts it again; the hand-over change
moved the surface make's upload entry into Work::create and left the wait untimed, and
make_parts' every_device_times_an_exported_surfaces_make_by_part expects one home lock wait per
make. The counter's doc names the exported make.

every_device_completes_a_surface_s_making_before_its_ready_wait_returns read the device's
completed progress (Done::completed), which the completion thread raises after the progress
semaphore does; the ready wait returns on the semaphore. The test now reads the semaphore's own
value (vkGetSemaphoreCounterValue), which the ready wait's return orders after.

Failing before: both tests on lavapipe (llvmpipe), runtime suite job m3-max-77883 at 6559c48acd.
2026-12-02 05:39:48 -08:00
Anees Iqbal 4ea93af18c Runtime tests: a picture loop's hand-overs, counted per picture
every_device_counts_a_picture_loop_s_hand_overs runs, for each row the device exports on the
1080p picture, 8 decode pictures (the other device writes, external_writes_done, rt reads through
the planes) and 8 encode pictures (rt writes the planes by a blit, the other device reads through
the handle) after one warm-up of each, each read exact, and prints each picture's barriers,
runtime command buffers, submissions, acquires and releases counted around rt's calls alone. It
is the before-and-after measure of the hand-over: the same loop at 21d219b089, with the release
call the consumer's encode path made there, runs on a scratch branch; no lab recording carries
decoded pictures (main, 12-02). Printed only.

Verified on lavapipe with the before run; reported with the lane's tip.
2026-12-02 05:39:48 -08:00
Anees Iqbal 2113de81cb Runtime: the hand-over's private docs name Image::making and Upload::hand_over
6559c48acd renamed Image::made to Image::making and folded Upload::make_handed into
Upload::hand_over, and four private doc links still named the old items: the private-items
rustdoc of the runtime failed on them (job m3-max-77880, the Linux node's privdoc step; its
public rustdoc, gpu clippy and the validation crate's clippy passed there).

Verified by the next privdoc run, reported with the lane's tip.
2026-12-02 05:39:48 -08:00
Anees Iqbal d0a424060a Runtime: each submission that uses memory another API shares hands it over; the release calls are gone
A consumer's video path showed green frames. Its paths call external_writes_done before each
picture and a release only in their encode fills, so every acquire of an exported block or surface
after the first had no release of the runtime's to match (VUID-vkQueueSubmit2-commandBuffer-03879),
and whether memory another API wrote was acquired, or discarded, depended on the order the
consumer's calls arrived in. f6fe21431c's test shows it: no submission released the surface.

Now one form serves every kind of memory another API shares, the form Direct3D 11 planes already
took (crate::handed): each vkQueueSubmit2 part whose command buffers or uploads use an exported
block, an exported surface's planes in place or its buffer, or a Direct3D 11 plane acquires all of
it from the other API's queue family in one barrier, in a runtime command buffer at the part's head
after a global barrier, and releases it in one barrier in another at the part's end, which takes
the part's last signals. Per such part: 3 barriers and 2 runtime command buffers; no submission,
VkSubmitInfo2 or semaphore wait is added. The uploads' copies into textures over a buffer in an
exported block go with the first part, which hands that block over too.

Exported memory is the runtime's until its making (Work::create): an exported block's buffer is
released, and an exported surface's planes in place move out of the undefined layout and are
released in the same barrier, in a runtime command buffer at the head of the submission that takes
the make's upload, ahead of any acquire. The upload owes the making by weak reference, so a surface
or block dropped first owes nothing and holds nothing. The making's submission is the ready point:
Surface::wait_until_ready waits for it in both forms (the copy form's is its block's), and the new
Block::wait_until_ready is its twin (Metal counterpart none; refuses a block that is not exported;
has the submission go at once, so it returns with no command buffer committed). One barrier at the
making, nothing per frame beyond the per-part hand-over.

external_writes_done keeps only its host-side mark: on a block (and a copy-form surface) the
textures over it take its bytes again; in place and on a Direct3D 11 import it records nothing.
Surface::buffer records nothing at its make. A block that is not exported is still refused.

Deleted, with no replacement: BlitCommandEncoder::release_to_external and
BlitCommandEncoder::release_surface_to_external, and Building::release_command, which only they
used. Consumer uses (the consumer's checkout, searched for main): release_to_external at
vaapi/fill.rs:599 and nvidia/encode/fill.rs:289, each followed by EndEncoding, commit and the
consumer's CPU wait; its wrapper trait method BlitEncoder::release_to_external
(core/platform/blit.rs:395, a cfg(unix) no-op default) and the RtPlatform impl
(rt_platform/blit.rs:992-999); doc mentions at rt_platform/export.rs:33, vaapi/fill.rs:30 and
nvidia/encode/fill.rs:18. release_surface_to_external: zero uses. The consumer drops them all in
the pin that takes this commit.

The guard the planner asked for: a plane's image in place takes its tiling from InPlaceTiling
alone, whose values are LINEAR and the DRM_FORMAT_MOD_LINEAR modifier, never OPTIMAL; the
device-free test no_plane_in_place_takes_the_optimal_tiling pins it. The order test
every_device_completes_a_surface_s_making_before_its_ready_wait_returns checks that each plane
owes its move at the make and none once the wait returns, with the device's completed progress at
or past the ready point. The export, surface and Direct3D 11 tests now count one acquire and one
release per submission and one release at the making, with no release call.

The runtime README states the contract (The hand-over contract): nothing another API writes may
be handed memory of ours before that memory's ready point; the other API's next write must not
begin before the submissions that used the memory have completed; who waits by kind and what a
reader gets where no write landed; no optimal image in memory another API writes in place
(section 12.11), the Direct3D 11 import being the documented case (section 12.10.1, Table 17).
Its known gaps carry the planner's line on host-pointer memory. docs/REFUSALS.md is regenerated
and the signature table blessed (one added, two removed).

Checked before this commit: clippy of the runtime, all targets, plain and under --cfg
m2v_cpu_icd, on this commit's code less its doc changes (job m3-max-77874). The device runs at
this commit (lavapipe, the Radeon 780M, the UHD 630) follow and are reported with the lane's tip.
The dma-buf import half is not built.
2026-12-02 05:39:47 -08:00
Anees Iqbal 6557e60115 Runtime tests: a picture the other API writes after rt's read is read with no release call between
The consumer's video paths (VA-API into a dma-buf surface, NVIDIA's decode into an opaque one)
call Surface::external_writes_done before each picture and release_surface_to_external only in
their encode fills, so every acquire after a surface's first has no release of rt's to match
(VUID-vkQueueSubmit2-commandBuffer-03879: "there must exist a previously submitted Queue Family
Ownership Transfer Release Operation ... with parameters matching the acquire operation").

The new test makes each row's surface (the VA-API dma-buf, the NVIDIA opaque handle, the copy form)
at 1080p, waits for its ready point, and has the second device write picture 1, then the
consumer's call and rt's read; then picture 2 the same way, with no release call between. Each read
must be its picture's exactly, the validation layer silent, and each read's submission must count
one acquire and one release of the surface's memory (Metrics::external_acquires,
Metrics::external_releases). At this commit no submission releases the surface, so it fails there.
2026-12-02 05:39:47 -08:00
Anees Iqbal a57f18224c Runtime: a serial dispatch that writes after a read through an address outside every resource takes a barrier
A serial compute encoder recorded no barrier between a dispatch that reads through an address
outside its resources and a later dispatch that writes a resource through its slot or a
use_resource declaration, so on Vulkan the write could overlap the read and the read see its
bytes. Metal runs a serial encoder's dispatches in dispatched order (MTLCommandBuffer.h:
"Command encoder dispatches are executed in dispatched order"), and the README held that such a
pipeline conflicts with any write. The hazard sets marked nothing for the read
(Hazards::mark_wild_read set touched alone), and Building::dispatch_hazards tested an unbound
read against earlier writes and an unbound write against any earlier access, never a write
against an earlier unbound read.

Now Hazards keeps read_wild since the last barrier, set by mark_wild_read and cleared with the
sets, and a dispatch any of whose accesses writes conflicts with it, counted in
Metrics::dispatch_unbound_barriers (its doc says so). The flag covers any resource: what an
address read reaches is whatever the guest made resident, residency sets included, which the
runtime does not see, the breadth the rule already takes for an unbound read after any write.
The README's serial-encoder sentence and use_heap's doc say the read orders before later writes.
No public change; no new form. The barrier is the one an unbound access already takes.

Verified: not run yet; the lavapipe run of every_device_orders_a_write_after_an_unbound_read,
the runtime suite and clippy follow.
2026-12-02 05:39:47 -08:00
Anees Iqbal 58305fb9cd Runtime tests: a serial dispatch that writes after a read through an address outside every resource takes a barrier
A serial compute encoder records no barrier between a dispatch that reads through an address
outside its resources and a later dispatch that writes a resource through its slot or a
use_resource declaration: the read marks nothing in the hazard sets (Hazards::mark_wild_read sets
touched alone), and the unbound test in Building::dispatch_hazards looks at earlier writes for an
unbound read and at any earlier access for an unbound write, never at an earlier unbound read for
a write. Metal runs a serial encoder's dispatches in dispatched order (MTLCommandBuffer.h), so the
read sees the bytes from before the write; on Vulkan the two may overlap.

every_device_orders_a_write_after_an_unbound_read: the wild step kernel (reads_unbound) over y,
then step over x, in one serial encoder; it asserts one barrier in the unbound source and two
barriers with the segment's end. It fails before the fix (no source, one barrier).

Verified: not run yet; the lavapipe run follows.
2026-12-02 05:39:47 -08:00
Anees Iqbal d8735b75f0 Golden tables: bless at semantics 2310 for the high-word carry and the dominating slot base
The golden hash table was last blessed at semantics 2307 (031c37d674). Two translator commits
since then change emitted SPIR-V and bump SEMANTICS_VERSION to 2310: 2a42256955 carries biased
buffer offsets into the high address word, and e2e76d8879 makes a slot's direct base and address
once where they dominate. golden_hashes_match_the_table therefore reports a bless due, not a
missing bump.

What moved, read from the table's diff: 2310 of 3600 rows, every one hash to hash. No refusal
class changed, no fixture source hash changed, and no row was added or removed. That is 19275
cells: 10086 in .ll fixtures, the count the Linux run reports, and 9189 in .air.ll fixtures,
which only a macOS run computes. Every changed row's fixture source holds a device or constant
buffer pointer, which is the path both commits change. The 137 rows whose fixture has none did
not move.

The table is the only file changed. Every other test in the same core run passed, and the
public cases ran at 7adf1d6603 with new_mismatch 0 on lavapipe, the Iris and the 780M.

Blessed on the M3 at 7adf1d6603 (job m3-max-78055: inventory, golden and printouts all exit 0;
only golden_hashes.tsv changed).
2026-12-02 04:13:30 -08:00
棠渚听潮 6c22641a9c Batch vertex-offset draws with draw-table SPIR-V variants and multi-draw indirect 2026-12-02 19:33:16 +08:00
棠渚听潮 d92aa60353 Submit aligned render push constant deltas
Track the last push length and record only the changed words for a draw. Keep Managed index and slot reaches on the full draw path, and leave device-wide alias and unslotted reads to the existing post-update checks.

Verified with cargo fmt and runtime Clippy, 207 runtime unit tests with the existing CRLF-sensitive stage test skipped, and the draw-offset regression on Intel Arc B390 including a Managed copy back.
2026-12-02 19:33:15 +08:00
棠渚听潮 3c6be6a1ed Update render buffer offsets without rebuilding push data
Reuse retained buffers for offset-only binds and track changed slots by stage. Patch indexed push fields and fixed-function bindings for eligible direct draws, and use full validation and filling when the draw cannot reuse them.

Verified with runtime clippy, the 207 lib tests in a temporary copy with LF in stage.rs, and the offset regression on Intel Arc B390.
2026-12-02 19:33:15 +08:00
Anees Iqbal 7adf1d6603 Runtime: a command marks its Managed-over writes and takes their copies back in its own segment, after its command buffer begins
A command encoded right after encodeSignalEvent marked what it did to textures over a Managed
buffer's device copy (managed_reach, wrote_managed, wrote_texture_managed) in the segment the
signal ends, before ordered_command split the recording there. That segment goes in a submission
of its own ahead of the command's, so on a device with two copies a write's copy in was taken
before the write ran and never after it (a fill of the buffer, then every later reader of the
texture read the bytes from before the fill), and a texture write's copy back was made before the
write. And managed_reach took the copy back owed by a write earlier in the command buffer before
managed_backs began the command buffer, so a begin that failed dropped it for good.

Building::open_segment makes the current segment the command's (a new one past a signal) and
begins its command buffer, with what is owed left owed. The blit copies, fill, mipmap chain and
synchronize, and the dispatch, call it before their first mark; a render pass's begin marks its
attachments after its ordered_command instead, so whether it opens its command buffer, which
spares its first barrier, is read as before. No public change and no new form.
2026-12-02 03:20:20 -08:00
Anees Iqbal 6bc41c8b94 Runtime tests: the two Managed-over tests print and check the copies over the device copy
The fill-after-a-signal test prints the bytes R's submission copied between the texture and the
Managed buffer's device copy (over_copy_bytes less those over Private and over Shared memory), and
the failed-begin test the bytes the copy encoded again copied back in its own commands. Where the
texture is owed by its buffer's entry (two copies), each must be non-zero: the evidence that the
two-copy form ran, not only that the bytes match.

Unverified at this commit: the failing run follows on lavapipe.
2026-12-02 03:20:20 -08:00
Anees Iqbal 1bc769f58a Runtime tests: a Managed buffer's write after an event signal, and a copy whose begin fails, keep the copies a texture over it owes
Two device tests over a texture over a Managed buffer in an image of its own, in both forms:

- A fill of the buffer encoded right after encodeSignalEvent reaches a later reader of the
  texture. Today the fill's marks (managed_reach, wrote_managed) land in the signalling segment,
  whose submission goes first: the copy in it owes is taken before the fill runs, and none after.
- A blit copy of the buffer whose command buffer cannot begin fails before it takes the copy back
  a write of the texture owes. Today managed_reach takes it, managed_backs fails at the begin, and
  the same copy encoded again reads the buffer without the texture's write.

A test-only seam, Core::fail_begins, fails the next begins of a command buffer's recording
(Building::begin) as vkBeginCommandBuffer out of host memory, before the driver is called.

Both are expected to fail in the two-copy form until the fix that follows. Unverified at this
commit: the failing run is being dispatched on lavapipe.
2026-12-02 03:20:20 -08:00
Anees Iqbal 01ed021d53 Translator tests: a direct access's instruction bounds are PR 22's carry form's measured cost
engine_access_size::a_device_access_of_whole_words_is_one_access held a direct access to the old
form's cost: a 64-bit add of the slot's base and the zero-extended biased offset. PR 22 replaced
that add with an OpIAddCarry on the low word and a carry into the high word, because AMD's Windows
driver folded the biased offset's 2^31 into a sign-extended 64-bit immediate and read 4 GiB below
the buffer. The structural pass (e2e76d8879) made the base and the slot's address once per slot;
the per-access remainder is the carry. The bounds move to the measured cost, never rounded up:

  float4 load at a uint offset    16 -> 19
  float4 store at a uint offset   16 -> 19
  float4 load at a float4 offset  16 -> 18
  pointer chase                   24 -> 22  (the pass took it below the old form)

The loss, as measured:
- On a device that takes compute buffers by address (lavapipe, a states-only play of 25,942
  states, refused 0 in both forms; m3-max-77799, a b a b): SPIR-V +7.0% (largest entry +6.2%),
  driver compile +5.1% (same-arm spread 1.1% and 2.6%), translation +0.7%, pipeline-make time
  +1.6%, play wall +0.8%.
- One translation by the compile worker's counting allocator (corpus-pipeline --compile-only,
  lavapipe; m3-max-77820, m3-max-77825): the corpus's largest row by allocator peak, 184,135,107
  bytes in both forms (PR 22 does not reach it); its largest by SPIR-V output, 62,572 -> 62,894
  words and 2,905,472 -> 2,921,373 bytes (+0.5%), 11 ms in both.
- Runtime GPU time of the frames (a b a b, one job per card): XTX +0.09% (m3-max-77764). RTX 3090 (gem10, in a
  Thunderbolt enclosure): m3-max-77854 not resolved, its arms at unequal clocks (one b play 81
  samples at P8 210 MHz against 50 and 51, wall 144.4 s against 133.7-137.9 s); m3-max-77895, both
  pairs counted (P8 samples 109/109 and 108/103), +1.90% and -2.72%, means -0.44%: inside. The
  +0.21% at 2f5f35ca47 on that card was before it moved hosts and is not a before-run. Iris Xe: no loss shown, 3% not resolved by this measure there (pair spread 7.8% and
  11.3%).

The carry form is unverified in the lab on the driver it fixes: no lab device runs AMD's Windows
driver; only the contributor's run (RX 6950 XT and an integrated Radeon, driver 26.11.2, offsets 0
and 256) covers it. A cheaper form for constant offsets was not taken for that reason; the cost is
a no-lane row that reopens on a venue running that driver or a pipeline-make cost of 5% or more on
a real device that takes buffers by address.

Verified: the measured values are m3-max-77757's size table at e2e76d8879 (no translator change
since); this commit's test runs in the merge check next.
2026-12-02 03:19:08 -08:00
Anees Iqbal 21d219b089 Runtime tests: every acquire of a Direct3D 11 plane read ahead of external_writes_done names the general layout
every_device_reads_what_direct3d_11_drew_through_a_commit_ahead_of_external_writes_done (d68f165aae)
now asserts what it printed: every acquire of a plane, the first included, names the general
layout as its old layout (Work::acquired). Its byte checks stay.

Why the structural check: no wrong picture was reproduced. On the UHD 630 the read committed ahead
of the call matched picture 1 at 3072 of 3072 bytes at d68f165aae, the old code, whose acquires'
old layouts were [undefined, undefined, general, general] (job m3-max-77834); at cd5d7df2f0 the
same read matched 3072 of 3072 with [general, general, general, general] (job m3-max-77839). That
driver kept the bytes through an acquire from the undefined layout, which Vulkan does not promise
(section 12.5.1: "implying that the contents of the image subresource need not be preserved"), so
the bytes cannot fail there and the old layouts are the failing proof. cd5d7df2f0 stays as the
spec's form (sections 12.5.2, 12.10.1, Table 17).

How it is verified: one job on the UHD 630 runs tests::d3d11 from two Windows cross-builds, the
old code with this assertion (expected to fail on [0, 0, 1, 1]) and this commit (expected to
pass); its job is reported with the lane's tip.
2026-12-02 02:41:12 -08:00
Anees Iqbal cd5d7df2f0 Runtime: every acquire of a Direct3D 11 plane names the general layout, the first included
A consumer's video path showed green frames. A plane's first acquire named the undefined layout
unless Surface::external_writes_done had been called before the first commit that used it, and a
transition from the undefined layout need not keep the bytes (section 12.5.1: "implying that the
contents of the image subresource need not be preserved"). What 9737a44d98 and its test 7c5df5a317
left open: whether that first acquire discards depended on the order the commit and the call
arrived in. The consumer's decode order today is fence wait, external_writes_done, then the
session's signal, so the hole is reached by a guest command buffer that reads a new cache's planes
without waiting on the session, committed between the draw's completion and the call.

Now Image::handed names the general layout as the old layout of every acquire, the first included,
and of every release. A Direct3D 11 plane is made owing no move (its homed flag set), so no upload
moves it, as before 9737a44d98. Surface::external_writes_done records nothing and changes nothing
for a Direct3D 11 surface; Image::external_access, which it called, is gone. No barrier, command
buffer, submission or wait is added or removed: the acquire is the same barrier with another old
layout.

The spec's form for this handle type. Section 12.5.2: "When images created with external memory
handle types listed in the external image implied layouts table are accessed outside of Vulkan,
they must be in the layout specified in the table, and can be assumed to be in that layout when
they are accessed in Vulkan after external access", and Table 17 gives
VK_EXTERNAL_MEMORY_HANDLE_TYPE_D3D11_TEXTURE_BIT the layout VK_IMAGE_LAYOUT_GENERAL. The conflict
9737a44d98 met (a plane rt uses before any Direct3D 11 access, whose image is made undefined) is
answered by section 12.10.1's note on an image bound to memory another API owns: "Such an image is
not usable until it acquires ownership of its memory from the existing owner. Therefore, the layout
specified as part of this transition will be the true initial layout of the image. The undefined
layout specified when creating it is a placeholder to simplify valid usage requirements."
Direct3D 11 made the texture, so it is that owner, and VUID-VkImageMemoryBarrier-
srcQueueFamilyIndex-12332 allows the general layout for any acquire of such an image from
VK_QUEUE_FAMILY_EXTERNAL ("oldLayout must be VK_IMAGE_LAYOUT_GENERAL or
VK_IMAGE_LAYOUT_UNDEFINED"). Left open by the text: whether Direct3D 11's making of a texture with
no initial data counts as an access "outside of Vulkan"; such a texture's bytes are undefined
either way, and the acquire that names the general layout is allowed by the VUID.

The suite now states this rule: every_device_acquires_a_direct3d_11_plane_from_the_general_layout_
first_included replaces the first-use test and reads the old layouts from Work::acquired, the
general layout for every acquire, with and without the call first. The d3d11 module's doc,
import_d3d11_surface's Layout, Ownership and precondition paragraphs, external_writes_done's doc
and the runtime README say so; the consumer's precondition no longer names the call.

Not yet run on a device: the red test's run at d68f165aae and this commit's run of tests::d3d11
on the UHD 630 wait for the card, which potluck does not list on the Windows host as this is
committed; their jobs are reported with the lane's tip. The Windows cross-build of this commit is
its compile check.
2026-12-02 02:22:45 -08:00
Anees Iqbal d68f165aae Runtime tests: a Direct3D 11 picture drawn before rt's first commit is read whatever order external_writes_done arrives in
A consumer's video path showed green frames: planes Direct3D 11 wrote, read by rt, came back without
Direct3D 11's content. A plane's first acquire names the undefined layout unless
Surface::external_writes_done was called before the first commit that uses it, and section 12.5.1
lets a transition from the undefined layout discard ("implying that the contents of the image
subresource need not be preserved").

The new test draws picture 1 with Direct3D 11 and waits for it, imports the planes, commits and
waits for rt's read of them with no external_writes_done before it, then makes the consumer's call
and reads again. Both reads must be picture 1's exactly. It prints the first read's matching and
zero bytes and each acquire's old layout (Work::acquired).

Its run at this commit on the UHD 630 is named in the fix's message.
2026-12-02 02:13:33 -08:00
Anees Iqbal ad49a715ff Runtime tests: a group sent apart is read from the values its members were given, not by a clock
every_device_signals_each_member_of_a_group_sent_apart failed once on llvmpipe in the merge check
at 1da727a583 (m3-max-77710, lvp_rt: "no value between the busy work's 6 and the group's 9 before
L's end") and passed at 2f5f35ca47 (m3-max-77732) and in round 89fb420796-1202-0117. Its proof
needed a host thread polling the progress semaphore to catch A's value inside the 4-10 ms between
A's end and L's: on a loaded CPU device the thread can be off the CPU for the whole window. The
specification bounds when a timeline signal is seen only from below (a submission's signal
follows its own commands), so a device that showed the value late would also fail it.

The deterministic form the planner asked for, a wait on an event instead of the clock, has no
valid Vulkan shape here. A GPU wait on a host-set event is defunct: "Events signaled by the host
must be signaled before the command buffer waits on those events" (6.6; also
VUID-vkCmdWaitEvents2-pEvents-03840). The runtime's own shared-event wait holds L on the host
until the event is met, so L would never join A's group.

So the test now reads what the runtime gave each member as the group went: Work::assigned, a
record kept for the device tests (as Work::acquired is), of each group member's place in the
commit order and the progress value it retires at. It asserts A then L in commit order, the
busy work's last value < A's < L's = the group's last, and still one submission each. The
timings (A's handler and L's GPU end, from A's GPU end) are printed, not asserted, and so are the
values.

Verified: nothing run yet for this commit; the merge check's lvp_rt and clippy in the device
configurations run it next.
2026-12-02 02:06:32 -08:00
Anees Iqbal e2e76d8879 Translator: a slot's direct base and address are made once where they dominate; an access adds its carry alone
PR 22's carry form cost about 10 SPIR-V instructions for each direct access against 2 before,
and engine_access_size::a_device_access_of_whole_words_is_one_access failed its bounds at
2f5f35ca47 (m3-max-77753, first identity profile: the uint-offset float4 load and store 24
against a bound of 16, the float4-offset load 23 against 16, the pointer chase 33 against 24;
the old form 16, 16, 15 and 24). Most of that was work repeated on every access: the base's u64
bitcast back to words and its split, and an add of the offset's zero high word; and
slot_address added the bias with the same sequence at every use.

Now:
- pointer::direct_base: the slot's address less the bias as its two words (the SlotGuestBase
  push word split, or in a replay variant that word less 2^31 with a borrow), remembered under
  SlotMemo::DirectBase and recalled where its block dominates (EmitCx's invariant memo, as
  slot_bounds does). Reach::Direct holds the words; biased_slot_address, which only the direct
  reach called, goes.
- psb::add_slot_offset: OpIAddCarry of the low word and the offset, its two words, one add of the
  carry to the high word, the words joined and bitcast: six instructions, with no add of a zero
  word and no 64-bit add of a constant.
- pointer::slot_address: remembered under SlotMemo::Address, so a pointer compare, a converted
  or stored pointer or an access from the word below adds the bias once where it dominates.

The arithmetic is unchanged: the address plus the unsigned biased offset modulo 2^64, carried
into the high word as PR 22 made it. SEMANTICS_VERSION 2309 -> 2310 (module bytes change).

Verified: nothing run yet for this commit; the access-size table, the engine suites and the merge
check run next, and the table is reported against the bounds.
2026-12-02 01:58:07 -08:00
Anees Iqbal ad6940ff92 Runtime: Pushed's doc links PUSH_STAGES by its name in scope
PR 23 imported PUSH_STAGES into command.rs, so the explicit target of the link in Pushed's doc
became redundant, and CI's private intra-doc links step (cargo doc --document-private-items with
-D warnings) failed on metal2vulkan-runtime: "redundant explicit link target" at command.rs:290.

Verified: found by the merge check at 2f5f35ca47 (m3-max-77732, STEP privdoc EXIT=1, the one
error); the next merge check runs the step again.
2026-12-02 01:52:53 -08:00
YXC0915 ea695f9456 Require dynamic state for native attachment feedback
Enable color feedback around draws using the feedback layout instead of marking every graphics pipeline. Use the attachment shadow when the device lacks the dynamic feature, so drivers with only the static layout can still run workloads that sample their render targets.
2026-12-02 17:50:47 +08:00
Anees Iqbal 2f5f35ca47 Translator tests: a constant slot reads exactly at residuals 256 and 4096 above its descriptor base
PR 18 (rponeawa) reported that a shared-range uniform descriptor could start far below the bind
offset (a residual of 256 on a device with a 64-byte uniform offset alignment), past the fixed
array the uniform view declared, so the read left the declared array. Its fix sized the array to
the device's uniform range. 5e3477e60a (11-22) has since removed the uniform view: every buffer
slot's view is a storage word array whose OpArrayLength is the bound range, with no declared size.
So the PR is credited by an empty merge and this test pins its case on the view the tree has: the
last byte of a constant window, read with residuals 0, 256 and 4096 on every tested profile, is
exact.

Verified: run in the merge check at the integrated tip, and with the residual's push word forced
to 0 (the read lands in the 0xEE fill) to show it is not vacuous; results in the PR report.
2026-12-02 01:40:41 -08:00
Anees Iqbal ebc0486b71 Translator: the slot address bias's docs state the carry form PR 22 brought
PR 22 (vistaero) adds a slot's biased 32-bit offset into the low word of its 64-bit base and carries
into the high word, at both direct-reach sites and in slot_address, in place of a 64-bit add of
the zero-extended offset (or of the 64-bit constant 2^31). This commit brings the bias's own doc
comment to that form and words the test's comment by structure.

Which case it was: (b). The old form was right by the specification: the biased offset is
the signed offset plus 2^31, in [0, 2^32), so UConvert's zero extension and a 64-bit add give the
address plus the offset exactly, and IAdd of the 64-bit constant 2^31 is exact. The PR reports
that AMD's Windows Vulkan driver (26.11.2, RX 6950 XT and an integrated Radeon) turned the bias
into a 64-bit immediate add that read 4 GiB below the buffer: a driver compiler fault, noted for
a repro draft. The carry form is rung 1 of the workaround ladder: one form for every device, chosen
by no query. Its 3% check (the XTX, the 5080 and the Iris Xe, arms alternated in one job) is owed
before the integrated commit is called regression-less. The lab has no AMD Windows host, so
the fault itself is built, not run: no venue.

The two subtract sites (biased_slot_address's unbiased arm and the indirect command's stored
word) subtract 2^31, which a sign-extended 32-bit immediate represents exactly. They are left
as they are: no report names them, and the PR's own run on the faulting driver passed with them.

Verified: nothing run for this commit alone (comments only); the merge check at the integrated tip
covers it.
2026-12-02 01:40:15 -08:00
rponeawa 4e067714f2 Merge pull request #18 from rponeawa/fix/shared-uniform-array-capacity 2026-12-02 01:38:19 -08:00
vistaero 2a42256955 🐛 Carry biased buffer offsets into the high address word
Windows Radeon shaders reading the first byte of a bound vertex buffer read
4 GiB below its address when the unsigned 2 GiB bias became a native
64-bit immediate add. Add the offset to the low word and carry into the
high word for direct accesses and recovered slot addresses. Keep the push
layout and invalidate translations emitted under the previous semantics.
2026-12-02 01:38:03 -08:00
vistaero 0c6981dddd Merge pull request #22 from vistaero/amd-buffer-address-carry 2026-12-02 01:38:03 -08:00
Anees Iqbal 4da155fd34 Devtools: the Format enum's doc links to the write function, not the ambiguous write
`[`write`]` on the private Format enum (from 4bcb58dbb1) names both the module's private fn write and
std's write! macro, so rustdoc under -D warnings with --document-private-items refuses it as an
ambiguous intra-doc link: CI's "Private intra-doc links" step reads metal2vulkan-devtools at 1 over
its ceiling of 0. Link the function with [`write()`].

Found by the private-doc step timed for the merge check on x86_64 Linux (job m3-max-77704:
M2V-PRIVDOC metal2vulkan-devtools 1, every other crate 0; the diagnostic in m3-max-77707).
2026-12-02 01:38:03 -08:00
YXC0915 729d91d23b Restore device addresses with an explicit carry
The biased slot word let a driver lower a zero-extended 32-bit
displacement as a signed physical storage buffer offset. On AMD Windows
the first draw then read exactly 4 GiB below the intended device address.

Reconstruct the slot address with two words and a carry before adding
the signed byte displacement. Keep the binding layout and invalidate
cached shaders. The existing identity-buffer test checks the carry and
the interpreted values at addresses above 4 GiB.
2026-12-02 16:59:13 +08:00
棠渚听潮 9826aa708b Submit aligned render push constant deltas
Track the last push length and record only the changed words for a draw. Keep Managed index and slot reaches on the full draw path, and leave device-wide alias and unslotted reads to the existing post-update checks.

Verified with cargo fmt and runtime Clippy, 207 runtime unit tests with the existing CRLF-sensitive stage test skipped, and the draw-offset regression on Intel Arc B390 including a Managed copy back.
2026-12-02 16:38:05 +08:00
棠渚听潮 d17046ea81 Update render buffer offsets without rebuilding push data
Reuse retained buffers for offset-only binds and track changed slots by stage. Patch indexed push fields and fixed-function bindings for eligible direct draws, and use full validation and filling when the draw cannot reuse them.

Verified with runtime clippy, the 207 lib tests in a temporary copy with LF in stage.rs, and the offset regression on Intel Arc B390.
2026-12-02 16:38:05 +08:00
vistaero 8f8b930ca1 🐛 Carry biased buffer offsets into the high address word
Windows Radeon shaders reading the first byte of a bound vertex buffer read
4 GiB below its address when the unsigned 2 GiB bias became a native
64-bit immediate add. Add the offset to the low word and carry into the
high word for direct accesses and recovered slot addresses. Keep the push
layout and invalidate translations emitted under the previous semantics.
2026-11-30 23:48:40 +01:00
rponeawa bf92016c82 fix(shader): cover shared uniform ranges in fixed arrays
A shared descriptor can start before the nearest aligned binding base, so
its residual can exceed the fixed array sized from the Metal window.
Reads then leave the declared SPIR-V array despite fitting the descriptor,
corrupting macOS and iOS system icons and widgets on the UniXNU ports.

Declare eligible uniform views to cover the aligned device range limit
and bump the compiler semantics version. Extend the existing interpreter
case with residuals of 256 and 4096 for word and vec4 views.

The extended case reproduces IndexOutOfRange on unmodified development.
The correction has also restored the macOS icon atlas and widget
backgrounds in the downstream Adreno 740 device comparison.
2026-11-17 16:23:29 +08:00
1099 changed files with 111648 additions and 76807 deletions

No files matched your search

+104 -40
View File
@@ -42,22 +42,15 @@ jobs:
set -euo pipefail
sudo apt-get update
# llvm: llvm-dis; spirv-tools: spirv-val + the product passthrough path's spirv-as.
# lavapipe is the CPU Vulkan ICD for the `m2v_cpu_icd` execution tests and the explicit
# `corpus-vulkan --device-type cpu` qualification on GPU-less Linux runners.
# vulkan-validationlayers: every engine candidate and L4 run enables
# VK_LAYER_KHRONOS_validation and refuses to run without it.
sudo apt-get install -y llvm spirv-tools mesa-vulkan-drivers libvulkan1 vulkan-validationlayers
# libvulkan1 is the loader alone: this host has no Vulkan driver, and the steps that run
# on one (lavapipe) run in the lavapipe image below.
sudo apt-get install -y llvm spirv-tools libvulkan1
command -v llvm-dis
command -v spirv-val
command -v spirv-as
# Ubuntu's llvm is the oldest LLVM the committed `.ll` fixtures are written for:
# here the validation test that each assembles with it must run, not skip.
echo "METAL2VULKAN_TEST_REQUIRE_PINNED_LLVM=1" >> "$GITHUB_ENV"
# Fail setup early if the CPU-ICD steps would have no ICD.
shopt -s nullglob
icds=(/usr/share/vulkan/icd.d/*.json /etc/vulkan/icd.d/*.json)
echo "Vulkan ICDs: ${icds[*]:-none}"
test "${#icds[@]}" -gt 0
- name: Install LLVM + SPIR-V tools (macOS)
if: runner.os == 'macOS'
@@ -151,7 +144,8 @@ jobs:
run: cargo doc --workspace --all-features --no-deps
# The consumer reference of the new API's frozen surface: the library's
# rustdoc build, warnings denied, and no link to a hidden item.
# rustdoc build, warnings denied, and no link to a hidden item; first, no lab
# job id in the prose docs.
- name: Build the new API's consumer reference (warnings denied)
run: scripts/api-docs
@@ -167,6 +161,9 @@ jobs:
- name: Private intra-doc links (no new breakage)
env:
RUSTDOCFLAGS: -Dwarnings
# The count below reads lines that begin `error: `. Under the workflow's
# CARGO_TERM_COLOR=always each one begins with a colour code instead, so it counted none.
CARGO_TERM_COLOR: never
run: |
set -euo pipefail
log="$RUNNER_TEMP/private-doc-links.log"
@@ -208,61 +205,128 @@ jobs:
run: cargo package --workspace --exclude metal2vulkan-validation --exclude metal2vulkan-conformance --exclude metal2vulkan-devtools --exclude metal2vulkan-harness
# With the AIR front end's crate's own tests, and the dev-tools crate's:
# its tool runner and L3 checks.
# its tool runner and L3 checks. Every suite here runs to its end (--no-fail-fast), so one
# red test does not hide the tests after it; the step's verdict is the same.
- name: Test metal2vulkan
run: cargo nextest run -p metal2vulkan -p metal2vulkan-air -p metal2vulkan-runtime -p metal2vulkan-devtools -p metal2vulkan-harness --all-features
run: cargo nextest run --no-fail-fast -p metal2vulkan -p metal2vulkan-air -p metal2vulkan-runtime -p metal2vulkan-devtools -p metal2vulkan-harness --all-features
# GPU-free on every host: tests that open a device compile only under `--cfg m2v_gpu` or
# `--cfg m2v_cpu_icd`, and no device-opening code runs without one of them.
- name: Test validation suite
run: cargo nextest run -p metal2vulkan-validation --all-features
run: cargo nextest run --no-fail-fast -p metal2vulkan-validation --all-features
# The conformance suite's own machinery, with no device: a stub side stands in for a GPU, so
# the transcript, the comparison, the justification rule, the verdicts, the recordings'
# staleness and the report are all checked on every host.
- name: Test the conformance suite
run: cargo nextest run -p metal2vulkan-conformance --all-features
run: cargo nextest run --no-fail-fast -p metal2vulkan-conformance --all-features
# nextest does not run doctests.
- name: Doc tests
run: cargo test --workspace --all-features --doc
# Device-executing validation tests, and the runtime's floor check, on lavapipe.
# `DeviceType::Cpu` matches only a CPU physical device, and the runtime's device tests under
# `m2v_cpu_icd` check only CPU devices, so this never reaches a GPU even on a runner that has
# one. macOS CI runs no device tests.
# The steps below that execute on a device run on lavapipe in the lavapipe image, and
# nowhere else: Arch Linux's packages of one Arch Linux Archive date, which
# scripts/lavapipe-image/pin pins with the bootstrap tarball's sha256, carrying the Mesa and
# LLVM the conformance ledger's llvmpipe rows hold on (its `# llvmpipe:` line). The image's
# downloads are cached keyed on the pin (its tarball's sha256, its date and its packages'
# versions), and saved as soon as the build has them, so a run whose pin has not moved
# downloads nothing, whatever the later steps answer.
- name: Restore the lavapipe image's downloads (Linux)
if: runner.os == 'Linux'
id: lavapipe-downloads
uses: actions/cache/restore@v4
with:
path: ~/.cache/m2v-lavapipe-image
key: lavapipe-image-${{ hashFiles('scripts/lavapipe-image/pin') }}
# Prints the image's pin, its packages, its device's name and driver, and whether its
# containers get /dev/udmabuf, and fails where the image differs from the pin or from the
# ledger's `# llvmpipe:` line. A fetch that fails ends this step with the URL it failed on,
# before any test runs. The limit fits a cold fetch at the slowest rate measured from the
# archive, one connection at 57 KB/s: the 127 MB tarball and 135 MB of databases and
# packages, 262 MB, take 77 minutes there.
- name: Build the lavapipe image (Linux)
if: runner.os == 'Linux'
timeout-minutes: 90
run: scripts/lavapipe-image/lavapipe-image ensure
- name: Save the lavapipe image's downloads (Linux)
if: runner.os == 'Linux' && steps.lavapipe-downloads.outputs.cache-hit != 'true'
uses: actions/cache/save@v4
with:
path: ~/.cache/m2v-lavapipe-image
key: lavapipe-image-${{ hashFiles('scripts/lavapipe-image/pin') }}
# The device tests of validation and the runtime, and the runtime's floor check, on lavapipe.
# They are the tests the `--cfg m2v_cpu_icd` build holds and the plain builds above do not: a
# test that opens a device compiles only under that cfg. The plain builds' tests ran on this
# host above, the `.ll` fixtures' test with Ubuntu's LLVM among them. The tests are built
# here, on the host, and only run in the image. Where its containers get no /dev/udmabuf,
# the tests scripts/lavapipe-image/needs-udmabuf names are skipped, each named in the log. `DeviceType::Cpu` matches only a CPU physical
# device, and the runtime's device tests under `m2v_cpu_icd` check only CPU devices. macOS CI
# runs no device tests.
- name: Test validation suite and the runtime on the CPU Vulkan ICD (Linux)
if: runner.os == 'Linux'
env:
RUSTFLAGS: -Dwarnings --cfg m2v_cpu_icd
LP_NUM_THREADS: "1"
run: cargo nextest run -p metal2vulkan-validation -p metal2vulkan-runtime --all-features
run: |
set -euo pipefail
out=$RUNNER_TEMP/cpu-icd
mkdir -p "$out"
cargo nextest list -p metal2vulkan -p metal2vulkan-air -p metal2vulkan-runtime -p metal2vulkan-devtools -p metal2vulkan-harness --all-features --message-format json > "$out/plain-1.json"
cargo nextest list -p metal2vulkan-validation --all-features --message-format json > "$out/plain-2.json"
export RUSTFLAGS='-Dwarnings --cfg m2v_cpu_icd'
cargo nextest list -p metal2vulkan-validation -p metal2vulkan-runtime --all-features --message-format json > "$out/cpu-icd.json"
cargo nextest archive -p metal2vulkan-validation -p metal2vulkan-runtime --all-features --archive-file "$out/cpu-icd.tar.zst"
python3 -I scripts/lavapipe-image/only_in.py "$out/cpu-icd.json" "$out/plain-1.json" "$out/plain-2.json" > "$out/device-tests"
echo "$(wc -l < "$out/device-tests") device tests"
scripts/lavapipe-image/lavapipe-image nextest "$out/cpu-icd.tar.zst" "$out/device-tests" --no-fail-fast
# The conformance suite's replay leg on lavapipe: it reads the committed recordings, runs the
# runtime side and compares, with no Metal present. Its exit status is 0 only where the run
# holds no surprise: no unrecorded case, no stale recording, and exactly the gaps
# crates/metal2vulkan-conformance/known-gaps-rt.tsv expects on this venue. A refusal or a
# divergence that ledger does not list fails here, and so does a row it lists that the run no
# longer holds, so closing a gap forces the ledger edit. A venue that lacks a feature a case
# needs does not spoil it.
# The runtime's device tests again, the step above's archive, with llvmpipe at 128-bit vectors
# (LP_NATIVE_VECTOR_WIDTH=128): the width arm64 lavapipe runs at, where a fragment or compute
# subgroup is 4 lanes. The leg's Mesa shader cache is a directory of its own in the workspace:
# llvmpipe keys its disk cache without the vector width (Mesa 26.2.4), so a cache it shared
# with a 256-bit run would hand a 128-bit shader a 256-bit texture function. vulkaninfo's
# device name and subgroup sizes are printed first, and the step fails unless they show 128
# bits and subgroups of 4.
- name: Test the runtime on the CPU Vulkan ICD at 128-bit vectors (Linux)
if: runner.os == 'Linux'
run: |
set -euo pipefail
out=$RUNNER_TEMP/cpu-icd
cache=$PWD/target/mesa-shader-cache-128
mkdir -p "$cache"
scripts/lavapipe-image/lavapipe-image run --env LP_NATIVE_VECTOR_WIDTH=128 -- vulkaninfo > "$out/vulkaninfo-128.txt"
grep -E 'deviceName|subgroupSize|minSubgroupSize|maxSubgroupSize' "$out/vulkaninfo-128.txt" | sort -u
grep -q 'deviceName *= llvmpipe .*128 bits' "$out/vulkaninfo-128.txt"
grep -Eq 'maxSubgroupSize *= 4$' "$out/vulkaninfo-128.txt"
grep '^binary_id(=metal2vulkan-runtime[):]' "$out/device-tests" > "$out/device-tests-runtime"
echo "$(wc -l < "$out/device-tests-runtime") runtime device tests at 128-bit vectors"
scripts/lavapipe-image/lavapipe-image nextest --write "$cache" --env LP_NATIVE_VECTOR_WIDTH=128 \
--env MESA_SHADER_CACHE_DIR="$cache" "$out/cpu-icd.tar.zst" "$out/device-tests-runtime" --no-fail-fast
# The conformance suite's replay leg on lavapipe, in the image: it reads the committed
# recordings, runs the runtime side and compares, with no Metal present. Its exit status is 0
# only where the run holds no surprise: no unrecorded case, no stale recording, and exactly
# the gaps crates/metal2vulkan-conformance/known-gaps-rt.tsv expects on this venue. A refusal
# or a divergence that ledger does not list fails here, and so does a row it lists that the
# run no longer holds, so closing a gap forces the ledger edit. A venue that lacks a feature
# a case needs does not spoil it. Where the image's containers get no /dev/udmabuf, the
# cases scripts/lavapipe-image/needs-udmabuf names are left out, each named in the log.
- name: Replay the conformance suite on the CPU Vulkan ICD (Linux)
if: runner.os == 'Linux'
env:
LP_NUM_THREADS: "1"
run: |
set -euo pipefail
cargo build -p metal2vulkan-conformance --bin conformance
target/debug/conformance replay --cpu
scripts/lavapipe-image/lavapipe-image replay target/debug/conformance
# Machine-specific semantic qualification remains explicit. Linux CI has lavapipe, so it can
# execute the owned public cases with the engine, in both robustness legs, against their
# exact committed Metal observations without a physical GPU. Rows written here are ephemeral
# CI evidence, not committed environment slots (see the script's header).
# Machine-specific semantic qualification remains explicit. On lavapipe in the image, it
# executes the owned public cases with the engine, in both robustness legs, against their
# exact committed Metal observations without a physical GPU. Rows written here (in the
# corpus, the one directory the image may write) are ephemeral CI evidence, not committed
# environment slots (see the script's header).
- name: Qualify public cases on native Vulkan (Linux)
if: runner.os == 'Linux'
env:
LP_NUM_THREADS: "1"
run: |
set -euo pipefail
cargo build -p metal2vulkan-validation --bins
bash scripts/qualify-public-cases target/debug
scripts/lavapipe-image/lavapipe-image run --write crates/metal2vulkan-validation/corpus -- bash scripts/qualify-public-cases target/debug
+54 -13
View File
@@ -58,12 +58,17 @@ order, and a lower one never overrides a higher one.
limit and memory-type queries. Product code holds no vendor, device or driver ID, and no
runtime policy switch. A test enforces this for `metal2vulkan-runtime`. One form means one form per
Vulkan capability: where the floor cannot require a feature, that feature's query may choose a
second form, for twelve only: 16-bit floats, storage-image reads without a format, 64-bit
second form, for fourteen only: 16-bit floats, storage-image reads without a format, 64-bit
atomics, 64-bit floats, SIMD groups (the subgroup size range with its stages and operations,
and maximal reconvergence), unified memory (decided by
Vulkan's physical device type alone: one copy of a Managed buffer on an integrated or CPU
device, two elsewhere), the attachment feedback loop (a device without it reads a render
target through a counted copy of that target, recorded as a known gap), run-time texel
device, two elsewhere; a texture over a host-pointer import in place on an integrated or
CPU device, after one counted copy pair at its making, and through its per-use counted copy
elsewhere; and a Shared heap's image texture in its heap on an integrated or CPU device, and
elsewhere an optimal image of its own in device memory, its heap range left unused, whose
device memory beside the heap's block is recorded as a known gap), the attachment feedback
loop (a device without it reads a render target through a counted copy of that target,
recorded as a known gap), run-time texel
offsets (a device with the maintenance8 feature takes a run-time texel offset as the sampling
or read instruction's own operand; a device without it branches over the offset's values, and
that branch's compile time is recorded as a known gap), the push window (the device's
@@ -85,8 +90,29 @@ order, and a lower one never overrides a higher one.
device without them reaches them at their device addresses with each access checked in the
shader, and that check's cost is recorded as a known gap, as is the check that stays by
structure on a slot a wide pointer, a typed atomic or the stage-in fetch reaches, on a slot
bound below its argument's alignment, and on every render stage), and Shared memory's host
coherence (decided by the host-coherent flag of the memory type
bound below its argument's alignment, and on every render stage), mixed passes over a linear
plane (ruled 12-02; a device whose linear tiling offers a plane's format as a colour attachment
renders a surface plane in place in every pass; a device that offers it only where every
colour attachment of the pass is linear (the linear-colour-attachment feature) renders a plane
in place in a pass of planes alone, and in a pass that mixes a plane with an attachment that is
not one (another colour, a depth or stencil, a resolve) renders it through an optimal image of
the runtime's with a counted copy into the plane at the pass's end and, where its load action
is Load, a counted copy in at its begin; those copies and that image's memory are recorded as a
known gap), texture buffer formats (ruled 12-02; for each format, does the device serve it
natively for every access a texture buffer makes, as a uniform texel buffer, as a storage texel
buffer, and as a storage write without a format, and, for a texture buffer made with both
shader read and shader write usage, as a storage read without a format? A device that does
makes a texture buffer of it the format's own view; where any of those is missing, that
format's texture buffer of that usage is held as words, an `R32_UINT` view whose texels shaders
convert, one answer per format and usage per device; on a device that holds any format so, a
stage that reaches a texture buffer declares a stage constant, false by default, under which
every word arm is dead code at pipeline creation, and each of its `VkPipeline`s has a words twin
specialized with it true, made in the same make, which a draw or dispatch runs where a texture
buffer held as words is bound at a slot its stage reaches or, for a stage that reaches one
through a handle, while one lives on the device; the twins' second compile and memory, and the
words' cost, 7.3 times the own view's GPU time for an `R8Unorm` texture buffer written on an
RTX 3090, are recorded as a known gap), and Shared
memory's host coherence (decided by the host-coherent flag of the memory type
Shared takes, the first host-visible, host-cached type a buffer can use, a host-coherent one
first: a device whose type has it makes no flush or invalidate call; on a device whose type is
the cached type without coherence, the Shared memory a submission's command buffers and Managed
@@ -100,10 +126,14 @@ order, and a lower one never overrides a higher one.
3. **Native-like speed.** Structure decides speed: driver-owned memory, optimal images in real
layouts, direct addresses (for a compute function's buffer arguments, bound buffers where
rule 2's query takes them), nothing copied that Metal would not copy. Optimal images have two
exceptions. A texture over a Shared buffer: a linear image on that buffer's memory, in the
device's own layout, created so its first use keeps the bytes, with the alignment the guest
reads from Metal's minimum linear texture alignment, and where a format query offers no linear
image for the format and usage, a counted copy at commit. A plane texture of an exported
exceptions. A texture over a buffer, of any storage mode: a linear image on that buffer's
memory (a Managed buffer's device copy, where it has one), in the device's own layout, created
so its first use keeps the bytes, and where that memory is a
host-pointer import on an integrated or CPU device (rule 2's unified memory), whose images
must start undefined, a counted copy pair at the texture's making restores the bytes,
with the alignment the guest reads from Metal's minimum linear texture alignment, and where a
format query offers no linear image for the format and usage, a counted copy at commit. A
plane texture of an exported
surface: a linear image on the surface's own exported memory, at the pitch and plane starts the
surface's export states, and where the device offers no such image or cannot meet the layout
the consumer asked for, the copy form of the same call, counted and recorded as a known gap.
@@ -146,9 +176,13 @@ as a known gap.
- **Structure over names.** Decide lowering from IR structure (types, address spaces, access
chains, AIR's metadata ABI), never from a function, type, variable or shader name. Dispatching on
the stable `air.*` and `llvm.*` intrinsic families is allowed; prefer a structural test when one
exists. A name-keyed branch that passes one shader while failing identically shaped others is a
defect. No behavior keyed to an app, a shader hash or a corpus census.
the stable `air.*` and `llvm.*` intrinsic families is allowed; the same holds for the bodiless
runtime-library routines Metal's compiler links by symbol (the `___metal_*` maths routines and
the `__tensorops_impl_*` family), where the declaration has no body and the symbol is the only
thing that says what the routine is; an unknown member of such a family is a typed refusal.
Prefer a structural test when one exists. A name-keyed branch that passes one shader while
failing identically shaped others is a defect. No behavior keyed to an app, a shader hash or a
corpus census.
- **Honest FALLBACK.** Unsupported input returns a typed `Err` (the command line prints
`FALLBACK`). Never emit wrong-but-valid SPIR-V to silence a gate.
- **Scope.** The runtime has a floor: one Vulkan version plus a fixed extension list
@@ -318,7 +352,14 @@ cargo test --workspace --all-features --doc
clippy (all features, each feature alone, `--cfg m2v_gpu`), Rustdoc, the API reference check
(`scripts/api-docs`), packaging, the suites, doctests, and on Linux clippy of the published
crates and devtools for `x86_64-pc-windows-gnullvm` and `x86_64-pc-windows-msvc`, the device
tests and public case qualification on lavapipe.
tests (the runtime's twice: at lavapipe's own width, and at 128-bit vectors, subgroups of 4, with
a Mesa shader cache of their own) and public case qualification on lavapipe.
- On Linux, CI's steps that execute on a device (the `m2v_cpu_icd` device tests, the conformance
replay and public case qualification) run on lavapipe in the image `scripts/lavapipe-image`
builds from `scripts/lavapipe-image/pin` (the Arch Linux bootstrap tarball's sha256, one Arch
Linux Archive date and each package's exact version), and when the conformance ledger's llvmpipe
rows are re-recorded on another lavapipe, the pin and the ledger's `# llvmpipe:` line move in the
same commit.
When chasing a hang, read the whole nextest output; do not pipe it through `head` or `grep`.
+6 -1
View File
@@ -53,7 +53,7 @@ they bind people too.
cargo fmt --all
cargo clippy --workspace --all-targets --all-features -- -D warnings
RUSTDOCFLAGS='-D warnings' cargo doc --workspace --all-features --no-deps
scripts/api-docs # the translator's API reference; fails on a link to a hidden item
scripts/api-docs # the translator's API reference; fails on a link to a hidden item or a job id
cargo nextest run -p metal2vulkan -p metal2vulkan-air -p metal2vulkan-runtime -p metal2vulkan-devtools -p metal2vulkan-harness --all-features
cargo nextest run -p metal2vulkan-validation --all-features
cargo nextest run -p metal2vulkan-conformance --all-features
@@ -68,6 +68,11 @@ limits only with `--cfg m2v_gpu_hazards` too ([docs/VALIDATION.md](docs/VALIDATI
validation layer under `metal2vulkan-runtime`'s device tests"). On a machine that has no layer,
`METAL2VULKAN_TEST_UNVALIDATED=1` runs them without it, and the run says so.
CI runs the device tests, the conformance replay and public case qualification on lavapipe in the
container image `scripts/lavapipe-image` builds from one Arch Linux Archive date, pinned by
`scripts/lavapipe-image/pin`, and re-recording the conformance ledger's llvmpipe rows on another
lavapipe moves that pin and the ledger's `# llvmpipe:` line in the same commit.
To build the command:
```sh
+16 -9
View File
@@ -27,7 +27,9 @@ What the translator promises:
- **Typed refusals.** Input the device cannot run exactly fails with an error that names the Metal
feature and what would make it work. It never returns a module that computes something else.
- **Recorded differences.** Where a pipeline gives a near-equivalent of Metal's answer, its
artifact records a precision note, and the runtime announces it once with a stable code.
artifact records a precision note. The runtime records each state's notes when the state is
made and exposes them, each with a stable code (`PrecisionNote::code`); the caller announces
them.
- **The GPU's native arithmetic.** Where the device has a native form (its maths, rounding,
conversions and sampler), that form gives the answer, its difference from Metal's recorded.
- **Bounded work.** Every compile runs under a deadline, a cancellation token and deterministic
@@ -80,15 +82,20 @@ metal2vulkan kernel.ll kernel.spv --profile device.json --emit-meta kernel.json
- `--profile` is required: the crate ships no device description. Any Khronos profiles JSON works;
[`crates/metal2vulkan-validation/profiles/`](crates/metal2vulkan-validation/profiles) has
examples, from a bare Vulkan 1.2 device to desktop GPUs and MoltenVK. A profile compiles under
the runtime's policy (`DevicePolicy::default()`, the identity pointer and handle domains), so a
profile without `bufferDeviceAddress` and `shaderInt64` is refused. `--device FILE` takes its
place with a device description and policy as JSON (`{"description": ..., "policy": ...}`),
which is how a runtime's compile device is reproduced: metal2vulkan-runtime's is the
description restricted to the features it enables, under that policy.
the identity pointer and handle domains, the only form, so a profile without
`bufferDeviceAddress` and `shaderInt64` is refused. `--device FILE` takes its place with a
device description as JSON (`{"description": ...}`), which is how a runtime's compile device is
reproduced: metal2vulkan-runtime's is the description restricted to the features it enables.
- Without `--function` it compiles the library's only kernel or vertex function. A kernel with
`--color-format` compiles as a tile pipeline. A post-tessellation vertex function adds
`.tesc.spv` and `.tese.spv` modules; on a device without `tessellationShader` it answers
`FALLBACK`, naming the feature.
`FALLBACK`, naming the feature. `--tessellation FILE` sets its tessellation state (the JSON form
of `TessellationDescriptor`: its maximum factor, partition mode, factor format, step function,
winding, control-point index type and factor scale, for example
`{"max_tessellation_factor": 64, "partition_mode": "Pow2", "factor_format": "Half",
"factor_step_function": "Constant", "output_winding_order": "CounterClockwise",
"control_point_index_type": "UInt32", "factor_scale_enabled": false}`); without it the pipeline
has no tessellation state of its own, which is Metal's default state.
- A vertex function that returns no value, with no `--fragment`, compiles with rasterization
disabled, the one pipeline Metal makes of it.
- A compile that needs a pipeline input fails naming it and the option that supplies it:
@@ -109,13 +116,13 @@ The flow follows Metal's object lifecycle: describe the device, parse a library,
pipeline, then plan and instantiate each dispatch or draw.
```rust,ignore
use metal2vulkan::device::{Device, DeviceDescription, DevicePolicy};
use metal2vulkan::device::{Device, DeviceDescription};
use metal2vulkan::library::Library;
use metal2vulkan::pipeline::{ComputePipelineDescriptor, FunctionDescriptor, StageSource};
use metal2vulkan::Budget;
let description = DeviceDescription::from_khronos_json(&profile_json, None)?;
let device = Device::from_queries(description, DevicePolicy::default())?;
let device = Device::from_queries(description)?;
let library = Library::parse(&metallib_bytes)?;
let kernel = FunctionDescriptor::new(library.function("my_kernel")?);
let descriptor = ComputePipelineDescriptor::new(StageSource::Function(kernel));
+4
View File
@@ -443,6 +443,7 @@ fn bound_global(b: &mut ModuleBuilder, external: bool) -> GlobalId {
constant: true,
init: Some(undef),
externally_initialized: external,
thread_local: false,
visibility: Default::default(),
unnamed_addr: Default::default(),
linkage: Linkage::Internal,
@@ -3237,6 +3238,7 @@ fn fc_global_as(
constant,
init,
externally_initialized,
thread_local: false,
visibility: Default::default(),
unnamed_addr: Default::default(),
linkage: Linkage::External,
@@ -3352,6 +3354,7 @@ fn sampler_global(b: &mut ModuleBuilder, words: &[u64]) -> GlobalId {
constant: true,
init: Some(init),
externally_initialized: false,
thread_local: false,
visibility: Default::default(),
unnamed_addr: Default::default(),
linkage: Linkage::Internal,
@@ -4762,6 +4765,7 @@ fn kernel_with_constants(
constant: true,
init: Some(undef),
externally_initialized: true,
thread_local: false,
visibility: Default::default(),
unnamed_addr: Default::default(),
linkage: Linkage::Internal,
@@ -623,8 +623,10 @@ impl<'a> ModuleDecoder<'a> {
let align = align(op(4)?).ok_or_else(|| s.malformed(MODULE_BLOCK, C))?;
let section = self.section(s, C, op(5)?)?;
let opt = |i: usize| s.ops().get(base + i).copied().unwrap_or(0);
// Thread-local storage and comdats are rejected at decode.
if opt(7) != 0 || opt(11) != 0 {
// Thread-local storage is read only in the thread space, where Metal gives each thread
// an object of its own; elsewhere, and comdats, are rejected at decode.
let thread_local = opt(7) != 0;
if (thread_local && space != AddrSpace::Thread) || opt(11) != 0 {
return Err(s.unsupported(Feature::ModuleRecord { code: C }));
}
let global = Global {
@@ -634,6 +636,7 @@ impl<'a> ModuleDecoder<'a> {
constant: flags & 1 != 0,
init: None,
externally_initialized: opt(9) != 0,
thread_local,
linkage,
visibility: visibility(linkage, opt(6)),
unnamed_addr: unnamed_addr(opt(8)),
+76 -2
View File
@@ -547,12 +547,20 @@ fn unknown_and_unsupported_records_are_typed() {
bitcode_kind(&e),
Some(&BitcodeError::UnknownBlock { block: 60 })
);
// A thread-local global.
let e = with_body(|w| w.unabbrev(7, &[0, 1, 0, 2, 0, 0, 0, 0, 0, 1])).unwrap_err();
// A thread-local global outside the thread address space (flags 14: explicit type,
// threadgroup): Metal gives a thread-local global meaning only in the thread space.
let e = with_body(|w| w.unabbrev(7, &[0, 1, 0, 14, 0, 0, 0, 0, 0, 1])).unwrap_err();
assert_eq!(
unsupported_feature(&e),
Some(&Feature::ModuleRecord { code: 7 })
);
// A thread-local global of the thread address space is read: each thread's own object.
let t = with_body(|w| w.unabbrev(7, &[0, 1, 0, 2, 0, 0, 0, 0, 0, 1])).unwrap();
let thread_locals = t.parts.globals.values().filter(|g| g.thread_local);
assert_eq!(
thread_locals.map(|g| g.space).collect::<Vec<_>>(),
[crate::ir::AddrSpace::Thread]
);
// A calling convention other than C or fast.
let e = with_body(|w| w.unabbrev(8, &[1, 1, 4, 9, 1, 0, 0, 0, 0])).unwrap_err();
assert_eq!(
@@ -1711,6 +1719,72 @@ fn a_public_fixture_survives_mutation() {
mutate(stream_of(&bytes));
}
/// Metal's runtime routines are taken by their symbol only on a declaration, which has no body to
/// say what it is: a module that declares `___metal_frexp_float_pthreadint32` calls the math
/// family's `frexp`, and one that defines a function of that name calls its own definition.
#[test]
fn a_defined_function_named_as_a_runtime_routine_is_the_modules_own() {
let Some(tool) = llvm_as() else {
eprintln!("SKIP a_defined_function_named_as_a_runtime_routine_is_the_modules_own: llvm-as not found");
return;
};
let scratch = Scratch::new();
let kernel = "define void @k(ptr addrspace(1) %out) {\n %e = alloca i32\n %r = call float @___metal_frexp_float_pthreadint32(float 1.0, ptr %e)\n store float %r, ptr addrspace(1) %out\n ret void\n}\n";
let decoded = |routine: &str, stem: &str| -> ModuleTables {
let ll = scratch.0.join(format!("{stem}.ll"));
std::fs::write(&ll, format!("{routine}\n{kernel}")).unwrap();
let out = scratch.0.join(format!("{stem}.bc"));
let bytes = assemble(&tool, &[ll.as_os_str()], &out)
.unwrap_or_else(|| panic!("llvm-as rejected the {stem} module"));
decode(stream_of(&bytes)).unwrap_or_else(|e| panic!("{stem}: {e}"))
};
let callee = |t: &ModuleTables| -> crate::ir::Callee {
let p = &t.parts;
let k = p
.funcs
.values()
.find(|f| p.symbols.get(f.name) == Some(&b"k"[..]))
.expect("the kernel");
let body = k.body.as_ref().expect("the kernel's body");
body.insts
.values()
.find_map(|i| match &i.kind {
crate::ir::InstKind::Call(c) => Some(c.callee.clone()),
_ => None,
})
.expect("the kernel's call")
};
let declared = decoded(
"declare float @___metal_frexp_float_pthreadint32(float, ptr)",
"declared",
);
let c = callee(&declared);
assert!(
matches!(
&c,
crate::ir::Callee::Air {
op: crate::intrinsics::AirIntrinsic::Math(m),
..
} if m.f == crate::intrinsics::MathFn::Frexp
),
"{c:?}"
);
let defined = decoded(
"define float @___metal_frexp_float_pthreadint32(float %x, ptr %e) {\n store i32 9, ptr %e\n ret float 2.5\n}",
"defined",
);
let c = callee(&defined);
let crate::ir::Callee::Direct(f) = c else {
panic!("{c:?}");
};
let f = defined.parts.funcs.get(f).expect("the callee");
assert!(f.body.is_some(), "the callee is the module's definition");
assert_eq!(
defined.parts.symbols.get(f.name),
Some(&b"___metal_frexp_float_pthreadint32"[..])
);
}
/// Whether `xcrun metal-as` exists. Tests that need it skip visibly when it does not, and fail
/// when it exists but rejects a committed fixture.
fn have_metal_as() -> bool {
@@ -108,6 +108,7 @@ fn variable(m: &mut ModuleBuilder, name: &str, ty: TypeId, init: Option<ConstId>
constant: init.is_some(),
init,
externally_initialized: false,
thread_local: false,
linkage: Linkage::External,
visibility: Visibility::Default,
unnamed_addr: Default::default(),
@@ -183,6 +184,7 @@ fn flat_table(m: &mut ModuleBuilder, imports: &[Item]) {
constant: false,
init: Some(init),
externally_initialized: false,
thread_local: false,
linkage: Linkage::External,
visibility: Visibility::Hidden,
unnamed_addr: Default::default(),
@@ -5,13 +5,13 @@
//! constant-space global, externally initialized and `undef`, makes each read of it (`&p`
//! included) a load of the pointer it holds, and lists it in `!air.global_bindings`
//! ([`GlobalBinding`]). Metal fills it from the executing stage's own argument table: measured on
//! an Apple M3 Max under macOS 27.0.1 (m3-max-70268), a kernel's global reads and writes the buffer
//! bound at its index, a vertex and a fragment function that read one global each read their own
//! stage's buffer there, and two globals of one type at one index, or a global and a parameter of
//! one type, read the one buffer bound there. So `expand` makes each load of a bound buffer's
//! pointer a read of a parameter of the entry: its own parameter of the binding's role and type
//! where it takes one, else one `expand` adds, shared by the bindings of one role and type.
//! Lowering then binds an added parameter where a `[[buffer(n)]]` parameter binds.
//! an Apple M3 Max under macOS 27.0.1, a kernel's global reads and writes the buffer bound at its
//! index, a vertex and a fragment function that read one global each read their own stage's buffer
//! there, and two globals of one type at one index, or a global and a parameter of one type, read
//! the one buffer bound there. So `expand` makes each load of a bound buffer's pointer a read of a
//! parameter of the entry: its own parameter of the binding's role and type where it takes one,
//! else one `expand` adds, shared by the bindings of one role and type. Lowering then binds an
//! added parameter where a `[[buffer(n)]]` parameter binds.
//!
//! Three shapes stay refused, each where it is found: an added parameter whose slot another
//! parameter of the entry binds ([`shared_slot`]), and, through what pruning keeps, any read of a
@@ -170,6 +170,7 @@ fn callee(name: &str, calls: &[&str]) -> LinkedModule {
constant: true,
init: Some(init),
externally_initialized: false,
thread_local: false,
visibility: Default::default(),
unnamed_addr: Default::default(),
linkage: Linkage::Internal,
@@ -529,6 +530,7 @@ fn constant_callee() -> LinkedCode {
constant: false,
init: Some(undef),
externally_initialized: false,
thread_local: false,
visibility: Default::default(),
unnamed_addr: Default::default(),
linkage: Linkage::Internal,
+29 -50
View File
@@ -293,8 +293,8 @@ pub struct Entry {
/// words: `ep` states each as a read-only device `Buffer`, and the interface says the slot
/// holds a table.
pub function_tables: BTreeSet<u32>,
/// The barriers that make the order of a simdgroup's lockstep explicit: empty from
/// canonicalization; `lower::simd::lockstep` fills it when it inserts them.
/// Whether the body holds a pair only a simdgroup's lockstep orders: unset from
/// canonicalization; `lower::simd::lockstep` sets it.
pub lockstep: Lockstep,
/// The call stack of the entry's recursion through visible functions: `None` when the entry has
/// none.
@@ -320,58 +320,19 @@ pub struct CallStack {
pub depth: u32,
}
/// The threadgroup and simdgroup barriers `lower::simd::lockstep` inserted into an entry's body.
/// What `lower::simd::lockstep` found in an entry's body.
///
/// Apple GPUs run a simdgroup's 32 threads in lockstep, so two conflicting threadgroup accesses
/// of different threads of one simdgroup between two barriers run in program order there; Vulkan
/// orders nothing between barriers. Each inserted barrier orders such a pair where the program
/// left it to lockstep.
/// Apple GPUs run a simdgroup's 32 threads in lockstep, so two conflicting threadgroup or device
/// accesses of different threads of one simdgroup between two barriers run in program order
/// there; Vulkan orders nothing between barriers, and documented Metal calls such a pair a data
/// race. The pass orders no pair: it finds them, and leaves them as the program wrote them.
#[derive(Clone, Debug, Default, PartialEq, Eq)]
pub struct Lockstep {
/// The inserted barrier calls, sorted.
pub barriers: Vec<crate::ir::InstId>,
/// Some inserted simdgroup barrier stands where the lanes of a subgroup are not known to
/// reach it together, so it orders its pair only on emulated simdgroups, whose predicated
/// walk takes every thread of the workgroup through it: the kernel takes the `Emulated` tier.
/// Never set where a subgroup barrier in divergent flow orders the threads that run it together
/// (maximal reconvergence on 32-lane subgroups).
pub emulated: bool,
/// Every inserted simdgroup barrier orders only pairs whose threads meet where a simdgroup
/// spans two rows of its threadgroup (two of its threads then share their position's `x`, or
/// hold different `y`s or `z`s): in a threadgroup whose simdgroups each lie within one row (a
/// single row, or rows of a multiple of 32 threads) no pair a simdgroup barrier orders
/// conflicts. The inserted threadgroup barriers may order pairs that meet there too; a
/// threadgroup barrier stands where the whole threadgroup runs together, orders every pair a
/// simdgroup barrier at its place would, and needs no subgroup size, so a pipeline for such
/// threadgroups keeps them and leaves out only the simdgroup barriers, and with them the
/// subgroup size they pinned: an exact removal. Decided where a subgroup barrier keeps a
/// 32-lane tier (maximal reconvergence on 32-lane subgroups); `false` elsewhere and where no
/// barrier is inserted.
pub rows: bool,
/// The inserted threadgroup barriers that order only pairs whose threads meet where a
/// simdgroup spans two rows of its threadgroup, sorted: each runs only in a threadgroup whose
/// simdgroups may span two rows (more than one row, of a width not a multiple of 32), and in
/// any other no pair it orders meets.
pub across_rows: Vec<crate::ir::InstId>,
/// The kernel holds such a pair and no barrier was inserted for it: under a profile that
/// orders none (the identity domains), its pairs are found and left as the program wrote
/// them, and the kernel records that its answer there is the device's order's.
/// The kernel holds such a pair: its answer there is the device's order's, which the kernel
/// records.
pub unordered: bool,
}
impl Lockstep {
/// Whether instruction `i` is an inserted barrier.
pub fn inserted(&self, i: crate::ir::InstId) -> bool {
self.barriers.binary_search(&i).is_ok()
}
/// Whether instruction `i` is an inserted barrier that orders only pairs meeting across rows
/// (one of [`across_rows`](Self::across_rows)).
pub fn orders_across_rows(&self, i: crate::ir::InstId) -> bool {
self.across_rows.binary_search(&i).is_ok()
}
}
impl Entry {
/// Whether the entry may encode, reset or copy indirect commands: `false` only where its
/// metadata names no indirect command buffer it takes and its body proves it touches none.
@@ -806,7 +767,8 @@ pub fn specialize_dynamic(
// The AIR 2.7 simdgroup-matrix block loads and stores in their AIR 2.8 form.
let body = legacy_matrix::expand(body, &mut parts, m)?;
// Metal runtime routines: each `frexp` and `ilogb` call becomes the routine's measured answer
// in plain AIR.
// in plain AIR, each OpenCL C `mad` call its multiply and addition, and each `mul24` and
// `mad24` call the 32-bit product of its operands' low 24 bits (and the addition).
let body = routine::expand(body, &mut parts, m)?;
// Aggregate loads and stores of buffer and threadgroup memory as their members' accesses.
let body = aggregates::expand(body, &mut parts, func, m)?;
@@ -1488,6 +1450,10 @@ fn post_check(
.and_then(|f| parts.symbols.get(f.name))
.unwrap_or(b"?")
};
let section = |f: FuncId| match parts.funcs.get(f).and_then(|f| f.section) {
Some(crate::ir::Section::Other(s)) => parts.symbols.get(s),
_ => None,
};
let diag = |bytes: &[u8]| DiagName::new(String::from_utf8_lossy(bytes));
// A call to the declaration `f` this module does not define.
let undefined =
@@ -1503,9 +1469,22 @@ fn post_check(
Some(Stub::Resolved { .. }) => {
Err(invariant("a call to a resolved stub survived linking"))
}
// A dynamic-library import, or a declaration no library can define.
// A dynamic-library import, or a declaration no library can define: an
// unknown member of a family of Metal's runtime-library routines, which
// Metal supplies, is refused as its family, and any other needs linking.
None => match stubs.import_refusal(Item::Func(f), symbol(f)) {
Some(e) => Err(e),
None if intrinsics::is_routine_family(symbol(f)) => {
let kind =
InputErrorKind::Intrinsic(IntrinsicError::UnknownIntrinsic {
name: diag(symbol(f)),
});
Err(InputError::new(kind, at.clone()).into())
}
None if crate::tensor_ops::in_family(symbol(f), section(f)) => {
Ok(Unsupported::not_implemented(Feature::Tensors)
.naming(diag(symbol(f))))
}
None => Ok(Unsupported::not_implemented(Feature::Linking)
.naming(diag(symbol(f)))),
},
+131 -17
View File
@@ -1,4 +1,4 @@
//! Metal runtime routines as plain AIR.
//! Metal runtime routines, OpenCL C's `mad`, and `mul24` and `mad24`, as plain AIR.
//!
//! Apple's compiler emits MSL's `frexp` and `ilogb` as calls to routines its backend defines at
//! pipeline creation, `___metal_frexp_<T>_pthread<I>(T x, thread I *e)` and
@@ -30,10 +30,25 @@
//!
//! Runtime-compiled source keeps `float` denormals (`frexp(0x1p-149) = (0.5, -148)`): what it
//! compiles to is not this routine, which AIR the translator receives calls by name.
//!
//! **OpenCL C's `mad`.** [`expand`] also replaces each `air.mad` call ([`MathFn::Mad`]) by its
//! product, an `fmul` of `a` and `b`, and the `fadd` of that product and `c`, in `T`'s shape and
//! with no fast-math flags, whatever the call's own: each is rounded on its own and neither is
//! fused, as the M3 Max answers `mad` (`intrinsics::math`'s module doc). Lowering takes them as it
//! takes any such pair.
//!
//! **`mul24` and `mad24`.** [`expand`] replaces each `air.mul24` and `air.mad24` call
//! ([`MathFn::Mul24`], [`MathFn::Mad24`]) by the 32-bit `mul` of its operands' low 24 bits, each
//! zero-extended (`and` with `0xffffff`) for `u` or sign-extended (`shl` and then `ashr` by 8) for
//! `s`, and for `mad24` the 32-bit `add` of that product and `c`, in `T`'s shape, each wrapping (no
//! `nsw` or `nuw`). That is the specification's wording, "only the low 24 bits perform the
//! multiplication" (MSL section 6.4, Table 6.2), and the M3 Max's answer for every operand
//! measured, inside the range where the specification defines the product and outside it
//! (`intrinsics::math`'s module doc).
use crate::budget::Meter;
use crate::error::Error;
use crate::intrinsics::{AirIntrinsic, Elem, Math, MathFn};
use crate::intrinsics::{AirIntrinsic, Elem, Math, MathFn, Sign};
use crate::ir::{
BinOp, Block, Body, Call, Callee, CastOp, Const, FastMath, Idx, Inst, InstId, InstKind,
IntFlags, IntPredicate, ModuleParts, Type, TypeId, Value,
@@ -41,10 +56,36 @@ use crate::ir::{
use super::rewrite::invariant;
/// What a call [`expand`] replaces computes.
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
enum Kind {
Frexp,
Ilogb,
Mad,
/// `mul24`, `signed` for `s`.
Mul24 {
signed: bool,
},
/// `mad24`, `signed` for `s`.
Mad24 {
signed: bool,
},
}
impl Kind {
/// The call's operand count.
fn arity(self) -> usize {
match self {
Kind::Frexp | Kind::Ilogb | Kind::Mul24 { .. } => 2,
Kind::Mad | Kind::Mad24 { .. } => 3,
}
}
}
/// The routine a call is, and its value type's lanes and element.
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
struct Routine {
frexp: bool,
kind: Kind,
half: bool,
lanes: u32,
}
@@ -61,19 +102,28 @@ fn routine(kind: &InstKind) -> Option<(Routine, &Call)> {
else {
return None;
};
let frexp = match f {
MathFn::Frexp => true,
MathFn::Ilogb => false,
let kind = match f {
MathFn::Frexp => Kind::Frexp,
MathFn::Ilogb => Kind::Ilogb,
MathFn::Mad => Kind::Mad,
MathFn::Mul24(s) => Kind::Mul24 {
signed: s == Sign::Signed,
},
MathFn::Mad24(s) => Kind::Mad24 {
signed: s == Sign::Signed,
},
_ => return None,
};
let half = match ty.elem {
Elem::F16 => true,
Elem::F32 => false,
let half = match (kind, ty.elem) {
(Kind::Mul24 { .. } | Kind::Mad24 { .. }, Elem::I32) => false,
(Kind::Mul24 { .. } | Kind::Mad24 { .. }, _) => return None,
(_, Elem::F16) => true,
(_, Elem::F32) => false,
_ => return None,
};
Some((
Routine {
frexp,
kind,
half,
lanes: ty.lanes,
},
@@ -267,12 +317,72 @@ impl Sink<'_> {
Ok(())
}
/// `mad(a, b, c)`: the product, then the sum, each with no fast-math flags; the last
/// instruction is the sum.
fn mad(&mut self, r: Routine, [a, b, c]: [Value; 3], m: &mut Meter) -> Result<(), Error> {
let ty = self.shaped(if r.half { Type::Half } else { Type::Float }, m)?;
let product = self.push(
ty,
InstKind::BinOp {
op: BinOp::FMul,
flags: IntFlags::NONE,
fmf: FastMath::NONE,
a,
b,
},
m,
)?;
self.push(
ty,
InstKind::BinOp {
op: BinOp::FAdd,
flags: IntFlags::NONE,
fmf: FastMath::NONE,
a: product,
b: c,
},
m,
)?;
Ok(())
}
/// `x`'s low 24 bits as an `i32`: zero-extended, or sign-extended where `signed`.
fn low24(&mut self, x: Value, signed: bool, m: &mut Meter) -> Result<Value, Error> {
if !signed {
return self.bin_k(BinOp::And, x, 0x00ff_ffff, m);
}
let high = self.bin_k(BinOp::Shl, x, 8, m)?;
self.bin_k(BinOp::AShr, high, 8, m)
}
/// `mul24(a, b)`, and `mad24(a, b, c)` where `c` is given: the 32-bit product of the
/// operands' low 24 bits, then its 32-bit sum with `c`, each wrapping; the last instruction is
/// the result (the module docs).
fn int24(
&mut self,
signed: bool,
[a, b]: [Value; 2],
c: Option<Value>,
m: &mut Meter,
) -> Result<(), Error> {
let a = self.low24(a, signed, m)?;
let b = self.low24(b, signed, m)?;
let product = self.bin(BinOp::Mul, a, b, m)?;
if let Some(c) = c {
self.bin(BinOp::Add, product, c, m)?;
}
Ok(())
}
/// The instructions of call `r` with operands `args`; the last is the call's result.
fn emit(&mut self, r: Routine, args: &[Value], m: &mut Meter) -> Result<(), Error> {
match (r.frexp, args) {
(true, [x, p]) => self.frexp(r, *x, *p, m),
(false, [x, _mode]) => self.ilogb(r, *x, m),
_ => Err(invariant("a runtime routine's call without its operands")),
match (r.kind, args) {
(Kind::Frexp, [x, p]) => self.frexp(r, *x, *p, m),
(Kind::Ilogb, [x, _mode]) => self.ilogb(r, *x, m),
(Kind::Mad, [a, b, c]) => self.mad(r, [*a, *b, *c], m),
(Kind::Mul24 { signed }, [a, b]) => self.int24(signed, [*a, *b], None, m),
(Kind::Mad24 { signed }, [a, b, c]) => self.int24(signed, [*a, *b], Some(*c), m),
_ => Err(invariant("a replaced call without its operands")),
}
}
}
@@ -285,14 +395,18 @@ fn routine_len(r: Routine, parts: &mut ModuleParts, m: &mut Meter) -> Result<u32
parts,
lanes: r.lanes,
};
let any = Value::Inst(InstId::new(0));
s.emit(r, &[any, any], m)?;
let any = [Value::Inst(InstId::new(0)); 3];
let args = any
.get(..r.kind.arity())
.ok_or_else(|| invariant("a routine of more operands than three"))?;
s.emit(r, args, m)?;
let len = scratch.insts.len();
scratch.release(m);
u32::try_from(len).map_err(|_| invariant("routine length"))
}
/// Replace every `frexp` and `ilogb` routine call of `body` by its answer (the module docs).
/// Replace every `frexp` and `ilogb` routine call and every `mad`, `mul24` and `mad24` call of
/// `body` by its answer (the module docs).
pub(super) fn expand(body: Body, parts: &mut ModuleParts, m: &mut Meter) -> Result<Body, Error> {
if !body.insts.iter().any(|(_, i)| routine(&i.kind).is_some()) {
return Ok(body);
@@ -217,6 +217,7 @@ impl Fixture {
constant: true,
init: Some(undef),
externally_initialized: true,
thread_local: false,
linkage: Linkage::LinkOnceOdr,
align: None,
section: Some(Section::FcInitializer),
@@ -242,6 +243,7 @@ impl Fixture {
constant: true,
init: Some(two),
externally_initialized: false,
thread_local: false,
linkage: Linkage::Internal,
align: None,
section: None,
+72 -1
View File
@@ -111,6 +111,7 @@ pub(super) fn fc_global(m: &mut ModuleBuilder, name: &str, ty: TypeId) -> Global
constant: true,
init: Some(undef),
externally_initialized: true,
thread_local: false,
visibility: Default::default(),
unnamed_addr: Default::default(),
linkage: Linkage::LinkOnceOdr,
@@ -1855,6 +1856,7 @@ fn static_initializers_run_in_global_ctors_order() {
constant: false,
init: Some(list),
externally_initialized: false,
thread_local: false,
visibility: Default::default(),
unnamed_addr: Default::default(),
linkage: Linkage::Appending,
@@ -2628,6 +2630,7 @@ fn constant_global(
constant: true,
init: Some(init),
externally_initialized: false,
thread_local: false,
visibility: Default::default(),
unnamed_addr: Default::default(),
linkage: Linkage::Internal,
@@ -3476,7 +3479,8 @@ fn surviving_calls_are_refused_by_family_naming_the_callee() {
assert_eq!(u.location, Some(at.clone()));
assert_eq!(u.symbol, Some(DiagName::new("air.some_future_op")));
// An undefined external function (the shape of the tensor-ops library calls) needs linking.
// An undefined external function needs linking, one named as the tensor-ops library's included
// where it is not in that library's section, `air.externally_defined`.
let u = refusal(specialize_call(|m, fty| {
Callee::Direct(m.declare("__tensorops_impl_matmul2d_op_cooperative_tensor_init", fty))
}));
@@ -3502,6 +3506,73 @@ fn surviving_calls_are_refused_by_family_naming_the_callee() {
assert_eq!(u.symbol, None);
}
/// Marks `d` as declared in `air.externally_defined`, the tensor-ops library's section.
fn externally_defined(m: &mut ModuleBuilder, d: FuncId) {
let s = m.sym("air.externally_defined");
m.func_mut(d).unwrap().section = Some(Section::Other(s));
}
/// A body-less declaration of a family of Metal's runtime-library routines that nothing models is
/// refused at its call as its family, naming it: a `___metal_*` routine the math family does not
/// model is an unknown intrinsic, and a `__tensorops_impl_*` function in `air.externally_defined`
/// outside the `matmul2d` ABI is tensors, as an unmodeled function of that ABI is (the `matmul2d`
/// lowering's refusal). Outside the section a `__tensorops_impl_*` name is no member, and needs
/// linking like any other undefined function.
#[test]
fn an_unknown_runtime_library_routine_is_refused_as_its_family() {
let at = Location::function(DiagName::new("k"), Some(0), Some(0));
let declared = |name: &'static str, external: bool| {
refusal(specialize_call(move |m, fty| {
let d = m.declare(name, fty);
if external {
externally_defined(m, d);
}
Callee::Direct(d)
}))
};
for (name, external, feature) in [
("___metal_ldexp_float", false, Feature::UnknownIntrinsic),
(
"___metal_frexp_float_pthreadv2int32",
false,
Feature::UnknownIntrinsic,
),
("__tensorops_impl_conv2d_op_run", true, Feature::Tensors),
("__tensorops_impl_conv2d_op_run", false, Feature::Linking),
] {
let u = declared(name, external);
assert_eq!(u.feature, feature, "{name} external {external}");
assert_eq!(u.location, Some(at.clone()), "{name}");
assert_eq!(u.symbol, Some(DiagName::new(name)), "{name}");
}
let u = declared("__tensorops_impl_matmul2d_op_cooperative_tensor_copy", true);
assert_eq!(u.feature, Feature::Tensors);
assert_eq!(u.location, Some(at));
}
/// A function of the tensor-ops library is taken by its symbol only where the module declares it
/// without a body: one the module defines under the same name, in the same section, is the
/// module's own and is inlined like any other, where the body-less declaration is the `matmul2d`
/// ABI's (here refused as tensors, called without its operands).
#[test]
fn a_defined_function_named_as_a_tensor_op_is_the_modules_own() {
let name = "__tensorops_impl_matmul2d_op_cooperative_tensor_init";
let u = refusal(specialize_call(|m, fty| {
let d = m.declare(name, fty);
externally_defined(m, d);
Callee::Direct(d)
}));
assert_eq!(u.feature, Feature::Tensors);
let defined = specialize_call(|m, fty| {
let mut f = m.define(name, fty);
f.ret(None);
let d = f.finish();
externally_defined(m, d);
Callee::Direct(d)
});
assert!(defined.is_ok(), "{:?}", defined.err());
}
/// The decoder keeps a call through a function's own constant address indirect when the call's
/// function type is not the function's. Such a call is classified by that function, not as a
/// dynamic call: a defined function whose parameters cannot receive the call's arguments is invalid
@@ -69,6 +69,7 @@ fn moved(how: Move) -> Entry {
constant: false,
init: Some(tg_undef),
externally_initialized: false,
thread_local: false,
visibility: Default::default(),
unnamed_addr: Default::default(),
linkage: Linkage::Internal,
@@ -45,6 +45,7 @@ fn configured(
constant: false,
init: Some(zero),
externally_initialized: false,
thread_local: false,
visibility: Default::default(),
unnamed_addr: Default::default(),
linkage: Linkage::Internal,
@@ -20,6 +20,7 @@ fn bound_global(m: &mut ModuleBuilder, name: &str) -> GlobalId {
constant: true,
init: Some(undef),
externally_initialized: true,
thread_local: false,
visibility: Default::default(),
unnamed_addr: Default::default(),
linkage: Linkage::Internal,
@@ -38,6 +38,7 @@ fn table_kernel(elements: &[Element]) -> Result<Entry, Error> {
constant: true,
init: Some(init),
externally_initialized: false,
thread_local: false,
visibility: Default::default(),
unnamed_addr: Default::default(),
linkage: Linkage::Internal,
@@ -71,6 +72,7 @@ fn table_kernel(elements: &[Element]) -> Result<Entry, Error> {
constant: true,
init: Some(init),
externally_initialized: false,
thread_local: false,
visibility: Default::default(),
unnamed_addr: Default::default(),
linkage: Linkage::Internal,
+15 -3
View File
@@ -1101,16 +1101,28 @@ fn committed_air_fixtures_parse_and_link() {
return;
}
let out = std::env::temp_dir().join(format!("m2v-container-{}.metallib", std::process::id()));
let status = std::process::Command::new("xcrun")
let linked = std::process::Command::new("xcrun")
.args(["-sdk", "macosx", "metallib"])
.args(&airs)
.arg("-o")
.arg(&out)
.status()
.output()
.unwrap();
let bytes = std::fs::read(&out);
let _ = std::fs::remove_file(&out);
assert!(status.success());
let stderr = String::from_utf8_lossy(&linked.stderr);
// The fixtures are compiled by the SDK `scripts/regen-air-fixtures` ran on; an older SDK's
// linker refuses their newer AIR version ("air version set to 2.9.0 ..., but expecting 2.8").
// That linker cannot link them at all, so the half that compares with Apple's link is skipped
// there; the parse half above has run.
if !linked.status.success()
&& stderr.contains("air version set to")
&& stderr.contains("but expecting")
{
eprintln!("SKIPPED metallib half: this SDK's metallib links an older AIR version than the fixtures': {}", stderr.trim());
return;
}
assert!(linked.status.success(), "xcrun metallib: {stderr}");
let bytes = bytes.unwrap();
let lib = metallib(&bytes);
assert_eq!(lib.functions.len(), entries);
+6 -6
View File
@@ -833,20 +833,20 @@ pub enum Feature {
/// A texture, a sampler or threadgroup memory bound at program scope (MSL 3.2's
/// `!air.global_bindings`), one or an array, that the entry reads: only a bound buffer becomes
/// a parameter. Metal takes each: an Apple M3 Max under macOS 27.0.1 runs kernels that read a
/// bound texture and sampler, a bound sampler array and bound threadgroup memory (m3-max-70306).
/// Basis: metal-takes (an Apple M3 Max under macOS 27.0.1, potluck job m3-max-70306)
/// bound texture and sampler, a bound sampler array and bound threadgroup memory.
/// Basis: metal-takes (an Apple M3 Max under macOS 27.0.1)
ProgramScopeResource,
/// A buffer bound at program scope at a slot that a parameter of the entry, or another binding
/// it reads, binds with another role or type. Metal takes it: on an Apple M3 Max under macOS
/// 27.0.1, a `device float *` and a `constant uint *` bound at one index read the one buffer
/// bound there (m3-max-70268).
/// Basis: metal-takes (an Apple M3 Max under macOS 27.0.1, potluck job m3-max-70268)
/// bound there.
/// Basis: metal-takes (an Apple M3 Max under macOS 27.0.1)
ProgramScopeSharedSlot,
/// A program-scope binding in the module of a function a pipeline links (a visible function,
/// or a dynamic library's). Metal takes it: on an Apple M3 Max under macOS 27.0.1, a kernel's
/// pipeline links another library's visible function, which reads the buffer the kernel's
/// stage binds at the global's index (m3-max-70306).
/// Basis: metal-takes (an Apple M3 Max under macOS 27.0.1, potluck job m3-max-70306)
/// stage binds at the global's index.
/// Basis: metal-takes (an Apple M3 Max under macOS 27.0.1)
ProgramScopeLinked,
/// A read of a buffer bound at program scope other than a load of the pointer its global
/// holds. `xcrun metal` 32023.922 writes every read so, `&p` included, so only other AIR reaches
@@ -789,6 +789,11 @@ const OBSERVED: &[(&str, &str)] = &[
("air.native_exp10.v3f32", "v3f32 (v3f32)"),
("air.half_cos.v4f32", "v4f32 (v4f32)"),
("air.half_powr.v4f32", "v4f32 (v4f32, v4f32)"),
// OpenCL C's `mad(a, b, c)` of `float`, `float4` and `half` (Apple's OpenCL compiler in Metal's
// OpenCL mode, macOS 27.0.1, AIR 2.9).
("air.mad.f32", "f32 (f32, f32, f32)"),
("air.mad.v4f32", "v4f32 (v4f32, v4f32, v4f32)"),
("air.mad.f16", "f16 (f16, f16, f16)"),
// OpenCL C's vector data functions (the same compilers).
("air.vload.global.v3i32", "v3i32 (i64, p1)"),
("air.vload.constant.v16i8", "v16i8 (i64, p2)"),
+61 -4
View File
@@ -1,5 +1,5 @@
//! The math family: `air.[fast_]<function>[.<s|u>].<type>`, and OpenCL C's
//! `air.{native,half}_<function>.<type>`.
//! `air.{native,half}_<function>.<type>` and `air.mad.<type>`.
//!
//! One declarative table ([`TABLE`]) lists every function stem with its domain and operand
//! shape. A float function takes an optional `fast_` prefix and no sign token; a sign-sensitive
@@ -15,6 +15,27 @@
//! 27.0.1) and `0x1.4p+3` on a Radeon Pro 5300M (macOS 26.7.1). Each reads as the function at
//! [`Precision::Fast`], the device's fast form.
//!
//! It spells OpenCL C's `mad(a, b, c)` `air.mad.<type>`, `T (T, T, T)`, for the types
//! [`MAD_TYPES`] lists: `float`, `float4` and `half`, measured over our own kernels in Metal's
//! OpenCL mode (`newLibraryWithSource` with `sourceLanguage` 1, macOS 27.0.1, AIR 2.9; `fma` is
//! `air.fma`). OpenCL C leaves how `mad` rounds its product to the implementation; the M3 Max's GPU
//! rounds the product and then the sum, run through the OpenCL framework (macOS 27.0.1): at
//! `a = b = 1 + 2^-12`, `c = -(1 + 2^-11)` `mad` answers 0 where `fma` answers `2^-24`, on `float`
//! and on each lane of `float4`, and of `half` at `a = b = 1 + 2^-6`, `c = -(1 + 2^-5)` 0 where
//! `fma` answers `2^-12`. It reads as [`MathFn::Mad`], that multiply and addition.
//!
//! MSL's and OpenCL C's `mul24` and `mad24` of a 32-bit `int` or `uint` (MSL section 6.4,
//! Table 6.2) are `air.mul24.<s|u>.<T>(T, T)` and `air.mad24.<s|u>.<T>(T, T, T)`, `T` `i32` or a
//! vector of it; Apple's compiler spells MSL's at 1 to 4 lanes (MSL on macOS reserves the 8- and
//! 16-lane types). The specification multiplies "only the low 24 bits" of the two 32-bit operands
//! and returns "the 32-bit integer result", and calls the product implementation-defined for
//! operands outside `[0, 2^24 - 1]` unsigned and `[-2^23, 2^23 - 1]` signed. The M3 Max (macOS
//! 27.0.1) answers outside that range too as the product of the operands' low 24 bits, zero-extended
//! for `u` and sign-extended for `s`, the 32-bit sum with `z` for `mad24` (validation cases
//! `int24-products-in-range` and `int24-products-outside-24-bits`). They read as [`MathFn::Mul24`]
//! and [`MathFn::Mad24`], which canonicalization replaces by that product in plain AIR. A width
//! other than 32 bits stays undecoded.
//!
//! Two functions reach AIR as calls to Metal runtime routines instead, declarations Apple's
//! compiler emits and its backend defines at pipeline creation: `frexp` as
//! `___metal_frexp_<T>_pthread<I>(T, thread I*)` (AIR 2.9 spells the same operation
@@ -48,6 +69,17 @@ pub(super) const OPENCL_STEMS: &[&str] = &[
"cos", "exp", "exp10", "exp2", "log", "log10", "log2", "powr", "rsqrt", "sin", "sqrt", "tan",
];
/// The types of OpenCL C's `mad` that Apple's OpenCL compiler is measured to spell, as
/// `air.mad.<type>`: `float`, `float4` and `half` (module doc). Any other type stays undecoded.
pub(super) const MAD_TYPES: &[NumTy] = &[
NumTy::scalar(Elem::F32),
NumTy {
elem: Elem::F32,
lanes: 4,
},
NumTy::scalar(Elem::F16),
];
/// A math function. Integer functions whose result depends on signedness carry the [`Sign`] the
/// name spells; `Clz`/`Ctz` carry their `is_zero_undef` immediate.
#[derive(Clone, Copy, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
@@ -137,6 +169,11 @@ pub enum MathFn {
// Float, three operands.
/// `air.fma`: `a * b + c`, rounded once.
Fma,
/// `air.mad`: OpenCL C's `mad(a, b, c)`, `a * b + c` rounded twice, the product and then the
/// sum, as the M3 Max answers it; spelled for `float`, `float4` and `half` alone, as Apple's
/// OpenCL compiler is measured to spell it. Canonicalization replaces each call by that
/// multiply and addition in plain AIR.
Mad,
/// `air.mix`: `x + (y - x) * a`.
Mix,
/// `air.clamp` with a float type: `x` clamped to `[min, max]`.
@@ -181,6 +218,11 @@ pub enum MathFn {
MadHi(Sign),
/// `air.mad_sat.<s|u>`: `a * b + c`, saturated.
MadSat(Sign),
/// `air.mul24.<s|u>` of `i32` lanes: the 32-bit product of the operands' low 24 bits,
/// zero-extended (`u`) or sign-extended (`s`) (module doc).
Mul24(Sign),
/// `air.mad24.<s|u>` of `i32` lanes: `mul24(a, b) + c` in 32 bits (module doc).
Mad24(Sign),
/// `air.add_sat.<s|u>`: `x + y`, saturated.
AddSat(Sign),
/// `air.sub_sat.<s|u>`: `x - y`, saturated.
@@ -332,6 +374,8 @@ pub(super) const TABLE: &[(&str, Domain, Shape)] = {
("mul_hi", S(M::MulHi), Same(2)),
("mad_hi", S(M::MadHi), Same(3)),
("mad_sat", S(M::MadSat), Same(3)),
("mul24", S(M::Mul24), Same(2)),
("mad24", S(M::Mad24), Same(3)),
("add_sat", S(M::AddSat), Same(2)),
("sub_sat", S(M::SubSat), Same(2)),
("hadd", S(M::HAdd), Same(2)),
@@ -348,10 +392,19 @@ pub(super) const TABLE: &[(&str, Domain, Shape)] = {
};
impl Math {
/// Parse the part of a name after `air.`: `[fast_]stem.[s|u.]type`, or
/// `{native,half}_stem.type` of a stem [`OPENCL_STEMS`] lists and a `float` type. `None` is not
/// a math name (another family's, or an unknown one).
/// Parse the part of a name after `air.`: `[fast_]stem.[s|u.]type`,
/// `{native,half}_stem.type` of a stem [`OPENCL_STEMS`] lists and a `float` type, or
/// `mad.type` of a type [`MAD_TYPES`] lists. `None` is not a math name (another family's, or an
/// unknown one).
pub(super) fn parse(rest: &str) -> Option<Math> {
if let Some(ty) = rest.strip_prefix("mad.") {
let ty = NumTy::parse(ty)?;
return MAD_TYPES.contains(&ty).then_some(Math {
f: MathFn::Mad,
precision: Precision::Precise,
ty,
});
}
let opencl = ["native_", "half_"]
.iter()
.find_map(|p| rest.strip_prefix(p));
@@ -399,6 +452,9 @@ impl Math {
if f == MathFn::Dot && !ty.is_vector() {
return None;
}
if matches!(f, MathFn::Mul24(_) | MathFn::Mad24(_)) && ty.elem != Elem::I32 {
return None;
}
Some(Math { f, precision, ty })
}
@@ -455,6 +511,7 @@ impl Math {
match self.f {
MathFn::Frexp => return Shape::Frexp,
MathFn::Ilogb => return Shape::Ilogb,
MathFn::Mad => return Shape::Same(3),
_ => {}
}
TABLE
+12 -1
View File
@@ -418,13 +418,24 @@ pub enum DeclClass {
Mismatch,
}
/// The symbol prefix of Metal's runtime routines: functions Metal's compiler declares without a
/// body and Metal supplies, so the symbol is all that says which routine one is.
const ROUTINE_PREFIX: &[u8] = b"___metal_";
/// The Metal runtime routine a declaration named `name` is, when the math family models it:
/// `___metal_frexp_*` or `___metal_ilogb_*`.
fn routine(name: &[u8]) -> Option<Math> {
let rest = name.strip_prefix(b"___metal_")?;
let rest = name.strip_prefix(ROUTINE_PREFIX)?;
Math::parse_routine(std::str::from_utf8(rest).ok()?)
}
/// Whether a declaration named `name` is of the family of Metal's runtime routines, modeled or
/// not. A call that survives to a body-less one the math family does not model is an unknown
/// intrinsic: Metal defines it, and nothing here says what it does.
pub(crate) fn is_routine_family(name: &[u8]) -> bool {
name.starts_with(ROUTINE_PREFIX)
}
/// Whether a declaration named `name` is an intrinsic: its name has the `air.` or the `llvm.`
/// prefix of the stable ABI, or it is a Metal runtime routine the math family models (`frexp`,
/// `ilogb`). Any other declaration is an ordinary function.
@@ -159,6 +159,11 @@ fn every_math_entry_decodes_and_checks() {
if f == MathFn::Dot && !ty.is_vector() {
continue;
}
// `mul24` and `mad24` are of 32-bit lanes alone
// (`mul24_and_mad24_decode_on_32_bit_lanes_alone`).
if matches!(f, MathFn::Mul24(_) | MathFn::Mad24(_)) && ty.elem != Elem::I32 {
continue;
}
let name = format!("{prefix}.{}", token(ty));
let AirIntrinsic::Math(m) = air(&name) else {
panic!("{name}");
@@ -272,6 +277,11 @@ fn math_conversion_and_atomic_families_decode() {
"air.atomic.global.and.u.i32",
"air.load.system_coherent.volatile.i32.p1i32",
"air.store.device_coherent.v4f32.p1v4f32",
// A texture of MSL's `memory_coherence_device`, as Apple's compiler names its accesses.
"air.read_texture_2d.device_coherent.u.v4i32",
"air.write_texture_2d.device_coherent.i16.v4f16",
"air.read_texture_buffer_1d.device_coherent.u.v4i32",
"air.write_texture_3d.device_coherent.v4f32",
] {
air(name);
}
@@ -295,6 +305,10 @@ fn math_conversion_and_atomic_families_decode() {
"air.atomic.global.xchg.u.i32", // exchange takes no sign
"air.atomic.region.add.u.i32", // unknown space
"air.load.somewhat_coherent.i32.p1i32",
// Only a texture's read, block read and write name a coherence, before `.i16`.
"air.sample_texture_2d.device_coherent.v4f32",
"air.atomic_fetch_add_explicit_texture_2d.device_coherent.u.i32",
"air.read_texture_2d.i16.device_coherent.v4f16",
] {
assert_eq!(classify_self(name), DeclClass::Unknown, "{name}");
}
@@ -1234,6 +1248,86 @@ fn opencl_native_and_half_functions_read_as_the_fast_form() {
}
}
/// OpenCL C's `mad` decodes in the types Apple's OpenCL compiler is measured to spell it, `float`,
/// `float4` and `half`, as the precise `Mad`; any other type or spelling stays unknown.
#[test]
fn opencl_mad_decodes_in_its_measured_types_alone() {
for (name, elem, lanes) in [
("air.mad.f32", Elem::F32, 1),
("air.mad.v4f32", Elem::F32, 4),
("air.mad.f16", Elem::F16, 1),
] {
let AirIntrinsic::Math(m) = air(name) else {
panic!("{name}");
};
assert_eq!(
(m.f, m.precision, m.ty),
(MathFn::Mad, Precision::Precise, NumTy { elem, lanes }),
"{name}"
);
}
for name in [
"air.mad.v2f32", // not measured
"air.mad.v3f32", // not measured
"air.mad.v8f32", // not measured
"air.mad.v4f16", // not measured
"air.mad.bf16", // not measured
"air.mad.i32", // float types only
"air.fast_mad.f32", // no prefix
"air.native_mad.f32", // no prefix
"air.mad.s.f32", // no sign token
"air.mad.f32.extra", // trailing token
] {
assert_eq!(classify_self(name), DeclClass::Unknown, "{name}");
}
}
/// `mul24` and `mad24` decode in the sixteen names Apple's compiler spells (both signs, `i32` and
/// 2 to 4 of its lanes) as `Mul24` and `Mad24`; a width other than 32 bits, a float, or a
/// spelling without a sign stays unknown.
#[test]
fn mul24_and_mad24_decode_on_32_bit_lanes_alone() {
for (stem, sign) in [
("mul24.s", Sign::Signed),
("mul24.u", Sign::Unsigned),
("mad24.s", Sign::Signed),
("mad24.u", Sign::Unsigned),
] {
for (ty, lanes) in [("i32", 1), ("v2i32", 2), ("v3i32", 3), ("v4i32", 4)] {
let name = format!("air.{stem}.{ty}");
let AirIntrinsic::Math(m) = air(&name) else {
panic!("{name}");
};
let f = match stem.starts_with("mul") {
true => MathFn::Mul24(sign),
false => MathFn::Mad24(sign),
};
assert_eq!(
(m.f, m.precision, m.ty),
(
f,
Precision::Precise,
NumTy {
elem: Elem::I32,
lanes
}
),
"{name}"
);
}
}
for name in [
"air.mul24.u.i16", // 32-bit lanes only
"air.mad24.s.i64", // 32-bit lanes only
"air.mul24.s.v2i8", // 32-bit lanes only
"air.mul24.f32", // integer types only
"air.mul24.i32", // a sign token is required
"air.fast_mul24.u.i32", // no prefix
] {
assert_eq!(classify_self(name), DeclClass::Unknown, "{name}");
}
}
#[test]
fn opencl_vector_data_functions_decode_with_their_strides() {
use AddrSpace::{Constant as C, Device as G, Thread as P, Threadgroup as L};
@@ -1,5 +1,5 @@
//! Textures and samplers: `air.<op>_{texture,depth}_<dim>[.i16][.<s|u>].<type>` and
//! `air.get_read_sampler`.
//! Textures and samplers: `air.<op>_{texture,depth}_<dim>[.device_coherent][.i16][.<s|u>].<type>`
//! and `air.get_read_sampler`.
//!
//! The operand layout of each operation is derived from the variant ([`Texture::layout`]); every
//! position carries a [`TexRole`]. The layouts are the ones Apple's compiler emits, read from the
@@ -27,6 +27,11 @@
//! offset) without the status is not a form of it.
//! - **write** `void (tex, coord, [cube: face], [array: layer], texel, [not buffer: lod],
//! i32 access)`.
//! - a read, block read or write of a texture of MSL's `memory_coherence_device` names it
//! `.device_coherent` after the stem, before `.i16` ([`Texture::device_coherent`]), with the
//! operands of the same access to a texture of the default threadgroup coherence: Apple's
//! compiler (macOS 27's metal 32023) names a 2D, 3D and texture buffer's read and write so, at
//! 32-bit and 16-bit coordinates.
//! - **block_read** (Metal 4.1's `block_read<W, H>` and `sparse_block_read<W, H>` of a 2D, 2D
//! array, or 2D depth texture) `void (tex, smp, <2 x i32> coord, [array: i32 layer],
//! <2 x i32> offset, i32 lod, i32 access, ptr out, ptr status, <2 x i32> size)`: the `W x H`
@@ -259,6 +264,12 @@ pub struct Texture {
/// operation without it, and [`Texture::access`] is then `None`. `true` for an operation
/// whose layout states none in either form.
pub states_access: bool,
/// The name's `device_coherent` token, first after the stem
/// (`air.read_texture_2d.device_coherent.u.v4i32`): a read, block read or write of a texture
/// of MSL's `memory_coherence_device`, coherent at device scope, whose argument and operands
/// are those of the same access to a texture of the default threadgroup coherence. `false`
/// for every other access and operation, which no such token names.
pub device_coherent: bool,
}
/// What one texture operand position is.
@@ -701,6 +712,10 @@ impl Texture {
let mut tokens = tail
.map(|t| t.split('.').collect::<Vec<_>>())
.unwrap_or_default();
let device_coherent = tokens.first() == Some(&"device_coherent");
if device_coherent {
tokens.remove(0);
}
let coord16 = tokens.first() == Some(&"i16") && tokens.len() > 1;
if coord16 {
tokens.remove(0);
@@ -752,7 +767,12 @@ impl Texture {
status: true,
access: None,
states_access: true,
device_coherent,
};
// Only a read, a block read and a write name a coherence.
if device_coherent && !matches!(t.op, TexOp::Read | TexOp::BlockRead | TexOp::Write) {
return None;
}
// The `ulong` stems take a `ulong` texel, and the others none.
let ulong_stem = matches!(op_name, OpName::UlongAtomic(_));
let ulong_atomic = matches!(t.op, TexOp::Atomic(_)) && t.ulong();
+1
View File
@@ -167,6 +167,7 @@ impl ModuleBuilder {
constant: false,
init,
externally_initialized: false,
thread_local: false,
linkage: if init.is_some() {
Linkage::Internal
} else {
+4
View File
@@ -150,6 +150,10 @@ pub struct Global {
/// `externally_initialized`: the object may be given its value from outside the module
/// before execution starts.
pub externally_initialized: bool,
/// `thread_local`: each thread has an object of its own, which starts at the initializer, as
/// Metal runs a thread-local global of the thread space (the reader refuses one of any other
/// space).
pub thread_local: bool,
/// The linkage.
pub linkage: Linkage,
/// The visibility.
+12
View File
@@ -41,6 +41,18 @@ pub const SECTION: &[u8] = b"air.externally_defined";
/// The symbol prefix of the `matmul2d` ABI.
pub const PREFIX: &[u8] = b"__tensorops_impl_matmul2d_op_";
/// The symbol prefix of every function of the tensor-ops implementation headers, the `matmul2d`
/// ABI's among them.
const FAMILY: &[u8] = b"__tensorops_impl_";
/// Whether a declaration named `symbol` in `section` is of the tensor-ops implementation's family:
/// named under `__tensorops_impl_` in [`SECTION`]. Metal supplies each body-less one when it creates
/// the pipeline, so a call that survives to one [`MatMul2dFn::of_declaration`] does not model is
/// refused as tensors.
pub(crate) fn in_family(symbol: &[u8], section: Option<&[u8]>) -> bool {
section == Some(SECTION) && symbol.starts_with(FAMILY)
}
/// `__tensor_ops_datatype_invalid`: the scale type a `_v2` run passes for a tensor operand without
/// scale factors (`tensor_plane_scales`).
pub(crate) const NO_SCALE: u64 = 0;
+8 -2
View File
@@ -112,7 +112,7 @@ another's: a pipeline the runtime refuses on MoltenVK for a structural reason ca
lavapipe, and a global row would then fail the lavapipe run for existing. The field is held, without
case, against the venue's own description — its device name, for a CPU implementation the host's
widest vector instruction set (`llvmpipe (LLVM 23.1.4, 256 bits) on x86-64 AVX-512`, which its
compiler targets and its answers follow), then its driver and API version — so a row can name one
compiler targets), then its driver and API version — so a row can name one
device (`Apple M3 Max`), one implementation (`llvmpipe`), one host's (`on x86-64 AVX2`) or a family
of them, and a venue that joins later needs no new vocabulary. `*` means every venue, and it is the
**stronger** claim rather than the looser one: the row is then held on every venue the run selected
@@ -134,7 +134,12 @@ replaying one case does not read every other row as fixed, and a run on one venu
another venue's rows as fixed.
A row's identity is its case, the verdict it expects, the site and the answer there, so a gap that
changed into another gap at the same site is a new gap and not the old one.
changed into another gap at the same site is a new gap and not the old one. Where the hosts a venue
covers answer a site differently by a property the venue does not state, the row lists each answer
recorded there with ` | ` between them, and its gap names the run each came from: llvmpipe of one
Mesa and LLVM stores the `x3` sites of `fetch-ordered-*-srgb` at 6304 elements on one x86-64
AVX-512 host and at 6496 on others. Such a row covers each answer it lists and no other, and is
held while the run answers any of them.
For a divergence the answer says **how much** moved — how many of the site's leaves differ, and the
largest difference where the values are numbers — and never where the walk first noticed. Two
@@ -331,6 +336,7 @@ one.
| `color_write_masks` | Which channels of a texel a draw changes under a write mask of none, some and all of them | run on Metal |
| `blend_sweeps` | Every settable `MTLBlendFactor` in each of the four slots, every `MTLBlendOperation` against six factor pairs and against each other, all sixteen write masks with the blend on and off, blending enabled against disabled, the blend colour at and outside its range, and the `Source1` factors through a second fragment output | run on Metal |
| `fresh_contents` | What a new buffer or texture reads before anything writes it, and after memory that was written was released | run on Metal |
| `managed_naming` | Which commit takes a Managed buffer's named range to a second copy: a compute slot, `useResource:`, a vertex slot, a blit source and a reach through the address alone, each against a write after the name | carried; an AMD Radeon Pro 5300M's table, as the oracle keeps one copy |
| `argument_encoders` | What an argument encoder says of a layout, which word of an argument buffer each argument landed in, and what the kernel then sampled through it | run on Metal |
| `function_bindings` | What a kernel's reflection says each argument is: the binding, its subprotocol's fields, and an argument buffer's struct type member by member | run on Metal |
| `indirect_commands` | What an indirect command buffer's CPU-encoded compute and render commands ran: both dispatch kinds, ordinary and indexed draws, the resets, the barriers, an attribute stride, a stage-in region, and the descriptor properties no execution needs | run on Metal |
File diff suppressed because it is too large. Load diff
@@ -113,7 +113,9 @@ int main(void) {
height:kSide
mipmapped:NO];
t.usage = MTLTextureUsageRenderTarget;
t.storageMode = MTLStorageModeShared;
// A discrete GPU's Mac takes no Shared texture: there the read texture is Managed, and a
// blit synchronizes it before the CPU reads it.
t.storageMode = device.hasUnifiedMemory ? MTLStorageModeShared : MTLStorageModeManaged;
id<MTLTexture> read = [device newTextureWithDescriptor:t];
MTLRenderPassDescriptor *pass = [MTLRenderPassDescriptor renderPassDescriptor];
if (n > 1) {
@@ -146,6 +148,11 @@ int main(void) {
[e drawPrimitives:MTLPrimitiveTypeTriangle vertexStart:0 vertexCount:3];
}
[e endEncoding];
if (!device.hasUnifiedMemory) {
id<MTLBlitCommandEncoder> b = [cb blitCommandEncoder];
[b synchronizeResource:read];
[b endEncoding];
}
[cb commit];
[cb waitUntilCompleted];
if (cb.error) {
@@ -1,103 +1,218 @@
// Which pairs of pixel formats Metal takes in `copyFromTexture:sourceSlice:sourceLevel:
// sourceOrigin:sourceSize:toTexture:destinationSlice:destinationLevel:destinationOrigin:`.
// sourceOrigin:sourceSize:toTexture:destinationSlice:destinationLevel:destinationOrigin:`, and
// what bytes land where it takes them. Apple's page for the call asks the destination for "The
// pixel format is the same as `sourceTexture`. The sample count is the same as `sourceTexture`."
//
// ONE CASE PER PROCESS, chosen on the command line, run under MTL_DEBUG_LAYER=1: the validation
// layer stops the process at a copy it does not take, so a case that prints "taken" was taken.
// Both textures are Private 2D 8x8 with one level (the source of `samples` 2D multisample, four
// samples); the copy is the first 4x4 texels.
// ONE CASE PER PROCESS, chosen on the command line (CASE STORAGE [DEVICE], STORAGE `shared` or
// `private`, DEVICE an index into MTLCopyAllDevices, else the default device), each run plainly
// and under MTL_DEBUG_LAYER=1, whose validation layer stops the process at a copy it does not take.
// Both textures are 2D 8x8 with one level, usage ShaderRead (the source of `samples` 2D
// multisample of four samples, usage RenderTarget). A case marked `checked` loads the source with
// byte k = (37k + 11) & 0xff and the destination with 0xEE (a Private texture through Shared
// buffers, by blits in command buffers of their own), copies the source's 4x4 texels at (0, 0) to
// the destination's (2, 1), and prints whether the destination holds the source's region's bytes
// as they are there and 0xEE elsewhere. A case marked `validated` runs under the validation layer
// alone: plain Metal has no defined answer for it.
//
// same RGBA8Unorm into RGBA8Unorm (the control: taken)
// srgb RGBA8Unorm into RGBA8Unorm_sRGB
// uint RGBA8Unorm into RGBA8Uint
// word RGBA8Unorm into R32Uint
// float R32Uint into R32Float
// order RGBA8Unorm into BGRA8Unorm
// depth Depth32Float into R32Float
// block BC1_RGBA into RG32Uint
// samples RGBA8Unorm of four samples into RGBA8Unorm of one
// same RGBA8Unorm into RGBA8Unorm (the control) checked
// r8unorm_r8uint R8Unorm into R8Uint checked
// r8uint_r8unorm R8Uint into R8Unorm checked
// r8unorm_r8snorm R8Unorm into R8Snorm checked
// r8unorm_r8sint R8Unorm into R8Sint checked
// rg8unorm_r16uint RG8Unorm into R16Uint checked
// r16float_r16uint R16Float into R16Uint checked
// word RGBA8Unorm into R32Uint checked
// uint RGBA8Unorm into RGBA8Uint checked
// order RGBA8Unorm into BGRA8Unorm checked
// srgb RGBA8Unorm into RGBA8Unorm_sRGB checked
// float R32Uint into R32Float checked
// depth Depth32Float into R32Float, Private validated
// block BC1_RGBA into RG32Uint, Private validated
// samples RGBA8Unorm of four samples into one, Private validated
// sizes R8Unorm into RGBA8Unorm (two texel sizes) validated
//
// xcrun clang -fobjc-arc -framework Metal -framework Foundation \
// -o blit_copy_format_pairs blit_copy_format_pairs.m
// for c in same srgb uint word float order depth block samples; do
// MTL_DEBUG_LAYER=1 ./blit_copy_format_pairs $c; done
// for c in same r8unorm_r8uint r8uint_r8unorm r8unorm_r8snorm r8unorm_r8sint rg8unorm_r16uint \
// r16float_r16uint word uint order srgb float; do
// for s in shared private; do
// ./blit_copy_format_pairs $c $s; MTL_DEBUG_LAYER=1 ./blit_copy_format_pairs $c $s; done
// done
// for c in depth block samples sizes; do
// MTL_DEBUG_LAYER=1 ./blit_copy_format_pairs $c private; done
//
// WHAT IT MEASURED (Apple M3 Max, macOS 27.0.1, job m3-max-43465): `same` taken; every pair of
// two formats stopped by the validation layer with "[sourceTexture pixelFormat] must equal
// [destinationTexture pixelFormat]", and `samples` with "[sourceTexture sampleCount](4) must
// equal [destinationTexture sampleCount](1)".
// On the MacBook below the validation layer stops a Shared texture's descriptor, so there the
// Private rows are the answers; it runs each case with each storage once for each device
// (DEVICE 0 and 1).
//
// WHAT IT MEASURED. The Apple M3 Max (macOS 27.0.1), Shared and Private: plain Metal takes every
// checked case and copies the bytes as they are; the validation layer takes `same` and stops
// every other case with "[sourceTexture pixelFormat](...) must equal [destinationTexture
// pixelFormat](...)", `samples` with "[sourceTexture sampleCount](4) must equal
// [destinationTexture sampleCount](1)". The AMD Radeon Pro 5300M (macOS 26.7.1), Private: every
// checked case copies the bytes as they are, plainly and under the validation layer, which takes
// `depth` and `block` too, stops `samples` as the M3 Max's does, and stops `sizes` with
// "[sourceTexture pixelFormat](MTLPixelFormatR8Unorm) must be compatible with [destinationTexture
// pixelFormat](MTLPixelFormatRGBA8Unorm)". The Intel UHD Graphics 630 of the same MacBook (macOS
// 26.7.1), Private: `same` copies the bytes; every other checked case completes, plainly and under
// the validation layer, and leaves the destination unwritten; the validation layer answers
// `depth`, `block`, `samples` and `sizes` as on the 5300M.
#import <Foundation/Foundation.h>
#import <Metal/Metal.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
static id<MTLTexture> make(id<MTLDevice> device, MTLPixelFormat format, NSUInteger samples) {
struct Case {
const char *name;
MTLPixelFormat from, to;
unsigned from_bytes, to_bytes;
NSUInteger samples;
int checked;
};
static const struct Case kCases[] = {
{"same", MTLPixelFormatRGBA8Unorm, MTLPixelFormatRGBA8Unorm, 4, 4, 1, 1},
{"r8unorm_r8uint", MTLPixelFormatR8Unorm, MTLPixelFormatR8Uint, 1, 1, 1, 1},
{"r8uint_r8unorm", MTLPixelFormatR8Uint, MTLPixelFormatR8Unorm, 1, 1, 1, 1},
{"r8unorm_r8snorm", MTLPixelFormatR8Unorm, MTLPixelFormatR8Snorm, 1, 1, 1, 1},
{"r8unorm_r8sint", MTLPixelFormatR8Unorm, MTLPixelFormatR8Sint, 1, 1, 1, 1},
{"rg8unorm_r16uint", MTLPixelFormatRG8Unorm, MTLPixelFormatR16Uint, 2, 2, 1, 1},
{"r16float_r16uint", MTLPixelFormatR16Float, MTLPixelFormatR16Uint, 2, 2, 1, 1},
{"word", MTLPixelFormatRGBA8Unorm, MTLPixelFormatR32Uint, 4, 4, 1, 1},
{"uint", MTLPixelFormatRGBA8Unorm, MTLPixelFormatRGBA8Uint, 4, 4, 1, 1},
{"order", MTLPixelFormatRGBA8Unorm, MTLPixelFormatBGRA8Unorm, 4, 4, 1, 1},
{"srgb", MTLPixelFormatRGBA8Unorm, MTLPixelFormatRGBA8Unorm_sRGB, 4, 4, 1, 1},
{"float", MTLPixelFormatR32Uint, MTLPixelFormatR32Float, 4, 4, 1, 1},
{"depth", MTLPixelFormatDepth32Float, MTLPixelFormatR32Float, 4, 4, 1, 0},
{"block", MTLPixelFormatBC1_RGBA, MTLPixelFormatRG32Uint, 0, 8, 1, 0},
{"samples", MTLPixelFormatRGBA8Unorm, MTLPixelFormatRGBA8Unorm, 4, 4, 4, 0},
{"sizes", MTLPixelFormatR8Unorm, MTLPixelFormatRGBA8Unorm, 1, 4, 1, 0},
};
enum { SIDE = 8, N = 4, DX = 2, DY = 1 };
static id<MTLTexture> make(id<MTLDevice> dev, MTLPixelFormat format, NSUInteger samples, BOOL shared) {
MTLTextureDescriptor *desc =
[MTLTextureDescriptor texture2DDescriptorWithPixelFormat:format width:8 height:8 mipmapped:NO];
[MTLTextureDescriptor texture2DDescriptorWithPixelFormat:format width:SIDE height:SIDE mipmapped:NO];
desc.usage = MTLTextureUsageShaderRead;
desc.storageMode = MTLStorageModePrivate;
desc.storageMode = shared ? MTLStorageModeShared : MTLStorageModePrivate;
if (samples > 1) {
desc.textureType = MTLTextureType2DMultisample;
desc.sampleCount = samples;
desc.usage = MTLTextureUsageRenderTarget;
}
return [device newTextureWithDescriptor:desc];
return [dev newTextureWithDescriptor:desc];
}
static void run(id<MTLCommandQueue> queue, void (^encode)(id<MTLBlitCommandEncoder>), const char *what) {
id<MTLCommandBuffer> cb = [queue commandBuffer];
id<MTLBlitCommandEncoder> blit = [cb blitCommandEncoder];
encode(blit);
[blit endEncoding];
[cb commit];
[cb waitUntilCompleted];
printf("%s: status %ld%s%s\n", what, (long)cb.status, cb.error ? ", error " : "",
cb.error ? cb.error.localizedDescription.UTF8String : "");
}
int main(int argc, const char **argv) {
@autoreleasepool {
if (argc != 2) {
printf("usage: blit_copy_format_pairs CASE\n");
if (argc != 3 && argc != 4) {
printf("usage: blit_copy_format_pairs CASE shared|private [DEVICE]\n");
return 2;
}
const char *name = argv[1];
struct {
const char *name;
MTLPixelFormat from, to;
NSUInteger samples;
} cases[] = {
{"same", MTLPixelFormatRGBA8Unorm, MTLPixelFormatRGBA8Unorm, 1},
{"srgb", MTLPixelFormatRGBA8Unorm, MTLPixelFormatRGBA8Unorm_sRGB, 1},
{"uint", MTLPixelFormatRGBA8Unorm, MTLPixelFormatRGBA8Uint, 1},
{"word", MTLPixelFormatRGBA8Unorm, MTLPixelFormatR32Uint, 1},
{"float", MTLPixelFormatR32Uint, MTLPixelFormatR32Float, 1},
{"order", MTLPixelFormatRGBA8Unorm, MTLPixelFormatBGRA8Unorm, 1},
{"depth", MTLPixelFormatDepth32Float, MTLPixelFormatR32Float, 1},
{"block", MTLPixelFormatBC1_RGBA, MTLPixelFormatRG32Uint, 1},
{"samples", MTLPixelFormatRGBA8Unorm, MTLPixelFormatRGBA8Unorm, 4},
};
int found = -1;
for (int i = 0; i < (int)(sizeof cases / sizeof cases[0]); i++) {
if (strcmp(cases[i].name, name) == 0) found = i;
const struct Case *c = NULL;
for (size_t i = 0; i < sizeof kCases / sizeof kCases[0]; i++) {
if (strcmp(kCases[i].name, argv[1]) == 0) c = &kCases[i];
}
if (found < 0) {
printf("no case %s\n", name);
if (!c) {
printf("no case %s\n", argv[1]);
return 2;
}
id<MTLDevice> device = MTLCreateSystemDefaultDevice();
id<MTLTexture> from = make(device, cases[found].from, cases[found].samples);
id<MTLTexture> to = make(device, cases[found].to, 1);
BOOL shared = strcmp(argv[2], "shared") == 0;
id<MTLDevice> dev = MTLCreateSystemDefaultDevice();
if (argc == 4) {
NSArray<id<MTLDevice>> *all = MTLCopyAllDevices();
int k = atoi(argv[3]);
if (k < 0 || k >= (int)all.count) {
printf("no device %d\n", k);
return 2;
}
dev = all[k];
}
const char *debug = getenv("MTL_DEBUG_LAYER");
printf("case %s storage %s debug %s device %s\n", c->name, shared ? "shared" : "private",
debug ? debug : "-", dev.name.UTF8String);
id<MTLTexture> from = make(dev, c->from, c->samples, shared);
id<MTLTexture> to = make(dev, c->to, 1, shared);
if (!from || !to) {
printf("%s: no texture\n", name);
printf("%s: no texture\n", c->name);
return 1;
}
id<MTLCommandQueue> queue = [device newCommandQueue];
id<MTLCommandBuffer> cb = [queue commandBuffer];
id<MTLBlitCommandEncoder> blit = [cb blitCommandEncoder];
NSUInteger n = 4;
[blit copyFromTexture:from
sourceSlice:0
sourceLevel:0
sourceOrigin:MTLOriginMake(0, 0, 0)
sourceSize:MTLSizeMake(n, n, 1)
toTexture:to
destinationSlice:0
destinationLevel:0
destinationOrigin:MTLOriginMake(0, 0, 0)];
[blit endEncoding];
[cb commit];
[cb waitUntilCompleted];
printf("%s: taken, status %ld%s%s\n", name, (long)cb.status, cb.error ? ", error " : "",
cb.error ? cb.error.localizedDescription.UTF8String : "");
id<MTLCommandQueue> queue = [dev newCommandQueue];
NSUInteger fpitch = SIDE * c->from_bytes, tpitch = SIDE * c->to_bytes;
unsigned char src[SIDE * SIDE * 8], dst[SIDE * SIDE * 8], got[SIDE * SIDE * 8];
for (unsigned k = 0; k < sizeof src; k++) src[k] = (unsigned char)((37 * k + 11) & 0xff);
memset(dst, 0xEE, sizeof dst);
memset(got, 0, sizeof got);
MTLRegion all = MTLRegionMake2D(0, 0, SIDE, SIDE);
id<MTLBuffer> back = nil;
if (c->checked && shared) {
[from replaceRegion:all mipmapLevel:0 withBytes:src bytesPerRow:fpitch];
[to replaceRegion:all mipmapLevel:0 withBytes:dst bytesPerRow:tpitch];
} else if (c->checked) {
id<MTLBuffer> sb = [dev newBufferWithBytes:src length:fpitch * SIDE options:MTLResourceStorageModeShared];
id<MTLBuffer> db = [dev newBufferWithBytes:dst length:tpitch * SIDE options:MTLResourceStorageModeShared];
run(queue, ^(id<MTLBlitCommandEncoder> blit) {
[blit copyFromBuffer:sb sourceOffset:0 sourceBytesPerRow:fpitch sourceBytesPerImage:fpitch * SIDE
sourceSize:MTLSizeMake(SIDE, SIDE, 1) toTexture:from destinationSlice:0
destinationLevel:0 destinationOrigin:MTLOriginMake(0, 0, 0)];
[blit copyFromBuffer:db sourceOffset:0 sourceBytesPerRow:tpitch sourceBytesPerImage:tpitch * SIDE
sourceSize:MTLSizeMake(SIDE, SIDE, 1) toTexture:to destinationSlice:0
destinationLevel:0 destinationOrigin:MTLOriginMake(0, 0, 0)];
}, "load");
back = [dev newBufferWithLength:tpitch * SIDE options:MTLResourceStorageModeShared];
}
run(queue, ^(id<MTLBlitCommandEncoder> blit) {
[blit copyFromTexture:from sourceSlice:0 sourceLevel:0 sourceOrigin:MTLOriginMake(0, 0, 0)
sourceSize:MTLSizeMake(N, N, 1) toTexture:to destinationSlice:0 destinationLevel:0
destinationOrigin:MTLOriginMake(DX, DY, 0)];
}, "copy");
if (!c->checked) return 0;
if (shared) {
[to getBytes:got bytesPerRow:tpitch fromRegion:all mipmapLevel:0];
} else {
run(queue, ^(id<MTLBlitCommandEncoder> blit) {
[blit copyFromTexture:to sourceSlice:0 sourceLevel:0 sourceOrigin:MTLOriginMake(0, 0, 0)
sourceSize:MTLSizeMake(SIDE, SIDE, 1) toBuffer:back destinationOffset:0
destinationBytesPerRow:tpitch destinationBytesPerImage:tpitch * SIDE];
}, "read-back");
memcpy(got, back.contents, tpitch * SIDE);
}
// The region holds the source's region's bytes as they are (the texel sizes are equal),
// the rest 0xEE.
int region = 1, rest = 1, first = -1;
for (unsigned y = 0; y < SIDE; y++) {
for (unsigned x = 0; x < tpitch; x++) {
unsigned char g = got[y * tpitch + x];
unsigned tx = x / c->to_bytes;
int inside = tx >= DX && tx < DX + N && y >= DY && y < DY + N;
int ok = inside ? g == src[(y - DY) * fpitch + (tx - DX) * c->from_bytes + x % c->to_bytes]
: g == 0xEE;
if (!ok) {
if (inside) region = 0;
else rest = 0;
if (first < 0) first = (int)(y * tpitch + x);
}
}
}
printf("bytes: region %s, outside %s", region ? "as copied" : "DIFFER", rest ? "0xEE" : "DIFFER");
if (first >= 0) printf(", first difference at byte %d: 0x%02x", first, got[first]);
printf("\nrow %u:", DY);
for (unsigned x = 0; x < tpitch; x++) printf(" %02x", got[DY * tpitch + x]);
printf("\n");
}
return 0;
}
@@ -0,0 +1,228 @@
// Whether a command buffer that waits for an event on one queue runs once another queue's command
// buffer signals it, or only after that whole command buffer, on Metal.
//
// The runtime submits every queue to one `VkQueue`, so its waiter runs after the signaller's whole
// command buffer (the runtime's README, the queues' known gaps). This probe measures Metal in the
// same two shapes, five rounds each, in one process:
//
// event A, on queue A: one short dispatch, a signal of an `MTLEvent` to the round's value, then
// about 100 ms of dispatches (25 of a kernel that spins about 4 ms, calibrated first,
// alone). B, on queue B and committed just after A: a wait for that value, then one
// dispatch of one thread over B's own buffer.
// host A: the 25 spins alone. B: a wait for an `MTLSharedEvent`'s round value, then the one
// thread; the host sets the value just after both commits.
//
// Each round reports A's GPU span, and when B's GPU work started and ended: from A's GPU start
// (event) or from the host's set (host). B's GPU start may include its wait, so the stall beyond
// the event's order is read from B's GPU end, B's one thread being about 0.01 ms: in the event
// shape B's end less A's start less A's short part (one dispatch of one thread and the signal,
// timed alone first); in the host shape B's end less the set. A and B share no resource, so only
// the event orders them. Each round's GPU work is about 0.1 s; nothing can hang: every wait's value
// is signalled in the same round.
//
// WHAT IT MEASURED (MTL_DEBUG_LAYER unset; one spin 4.00 ms at 275,795 iterations, A's short part
// 0.002 ms; job m3-max-79181):
//
// M3 Max, macOS 27.0.1: event, A ran 99.96-100.00 ms and B's GPU end came 0.01-0.08 ms after
// A's GPU start; host, A ran 99.95 ms from 0.13-0.14 ms after the set and B's GPU end came
// 0.13-0.15 ms after the set. No command buffer reported an error.
//
// So the M3 runs B once the event reaches its value, beside the rest of A's command buffer.
//
// Run: cross_queue_event_stall [DEVICE] (a part of a device's name, or the default device)
// Build: clang -fobjc-arc -O1 -fmodules -o cross_queue_event_stall cross_queue_event_stall.m \
// -framework Foundation -framework Metal
//
// Measuring runs keep `MTL_DEBUG_LAYER` OUT of the environment.
#import <Foundation/Foundation.h>
#import <Metal/Metal.h>
#include <mach/mach_time.h>
#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
static void P(const char *fmt, ...) {
va_list ap;
va_start(ap, fmt);
fputs("RESULT ", stdout);
vfprintf(stdout, fmt, ap);
fputc('\n', stdout);
fflush(stdout);
va_end(ap);
}
/// The host's clock in seconds, the one `GPUStartTime` and `GPUEndTime` answer on.
static double host_seconds(void) {
static mach_timebase_info_data_t base;
if (base.denom == 0) {
mach_timebase_info(&base);
}
return (double)mach_absolute_time() * base.numer / base.denom / 1e9;
}
static const int ROUNDS = 5;
static const int SPINS = 25;
static const NSUInteger THREADS = 256;
static NSString *const kSource =
@"#include <metal_stdlib>\n"
"using namespace metal;\n"
"kernel void spin(device uint *b [[buffer(0)]],\n"
" constant uint &iters [[buffer(1)]],\n"
" uint gid [[thread_position_in_grid]]) {\n"
" uint x = gid * 2654435761u;\n"
" for (uint i = 0; i < iters; i++) { x = x * 1664525u + 1013904223u; }\n"
" b[gid] = x == 0x12345678u ? 1u : 0xFFFFFFFFu;\n"
"}\n"
"kernel void one(device uint *b [[buffer(0)]]) { b[0] = 7u; }\n";
typedef struct {
id<MTLDevice> device;
id<MTLComputePipelineState> spin;
id<MTLComputePipelineState> one;
id<MTLBuffer> a_words;
id<MTLBuffer> b_words;
} Probe;
static void encode_spins(Probe *p, id<MTLCommandBuffer> cb, uint32_t iters, int dispatches) {
id<MTLComputeCommandEncoder> e = [cb computeCommandEncoder];
[e setComputePipelineState:p->spin];
[e setBuffer:p->a_words offset:0 atIndex:0];
[e setBytes:&iters length:sizeof iters atIndex:1];
for (int d = 0; d < dispatches; d++) {
[e dispatchThreadgroups:MTLSizeMake(THREADS / 64, 1, 1)
threadsPerThreadgroup:MTLSizeMake(64, 1, 1)];
}
[e endEncoding];
}
/// One dispatch of one thread over `buffer`.
static void encode_one(Probe *p, id<MTLCommandBuffer> cb, id<MTLBuffer> buffer) {
id<MTLComputeCommandEncoder> e = [cb computeCommandEncoder];
[e setComputePipelineState:p->one];
[e setBuffer:buffer offset:0 atIndex:0];
[e dispatchThreadgroups:MTLSizeMake(1, 1, 1) threadsPerThreadgroup:MTLSizeMake(1, 1, 1)];
[e endEncoding];
}
static double span_ms(id<MTLCommandBuffer> cb) {
return (cb.GPUEndTime - cb.GPUStartTime) * 1000.0;
}
static const char *status(id<MTLCommandBuffer> cb) {
return cb.error ? cb.error.localizedDescription.UTF8String : "no error";
}
int main(int argc, char **argv) {
@autoreleasepool {
Probe p;
p.device = MTLCreateSystemDefaultDevice();
if (argc == 2) {
p.device = nil;
for (id<MTLDevice> device in MTLCopyAllDevices()) {
if (strstr(device.name.UTF8String, argv[1])) {
p.device = device;
}
}
if (!p.device) {
P("no device named like %s", argv[1]);
return 1;
}
}
NSOperatingSystemVersion v = [[NSProcessInfo processInfo] operatingSystemVersion];
P("device %s macOS %ld.%ld.%ld MTL_DEBUG_LAYER=%s", p.device.name.UTF8String,
(long)v.majorVersion, (long)v.minorVersion, (long)v.patchVersion,
getenv("MTL_DEBUG_LAYER") ? getenv("MTL_DEBUG_LAYER") : "unset");
NSError *error = nil;
id<MTLLibrary> library = [p.device newLibraryWithSource:kSource options:nil error:&error];
if (!library) {
P("library: %s", error.localizedDescription.UTF8String);
return 1;
}
p.spin = [p.device newComputePipelineStateWithFunction:[library newFunctionWithName:@"spin"]
error:&error];
p.one = [p.device newComputePipelineStateWithFunction:[library newFunctionWithName:@"one"]
error:&error];
if (!p.spin || !p.one) {
P("pipeline: %s", error.localizedDescription.UTF8String);
return 1;
}
p.a_words = [p.device newBufferWithLength:THREADS * 4 options:MTLResourceStorageModePrivate];
p.b_words = [p.device newBufferWithLength:4096 options:MTLResourceStorageModePrivate];
id<MTLBuffer> a_one = [p.device newBufferWithLength:4096 options:MTLResourceStorageModePrivate];
id<MTLCommandQueue> queue_a = [p.device newCommandQueue];
id<MTLCommandQueue> queue_b = [p.device newCommandQueue];
// Calibration on A's queue, alone: one spin of about 4 ms, then A's short part.
uint32_t iters = 1u << 10;
double one_ms = 0;
for (int step = 0; step < 14 && (one_ms < 3.5 || one_ms > 4.5); step++) {
if (step > 0) {
double scale = one_ms > 0.1 ? 4.0 / one_ms : 8.0;
iters = (uint32_t)MIN((double)(1u << 28), MAX(1.0, iters * scale));
}
id<MTLCommandBuffer> cb = [queue_a commandBuffer];
encode_spins(&p, cb, iters, 1);
[cb commit];
[cb waitUntilCompleted];
one_ms = span_ms(cb);
}
id<MTLEvent> warm_event = [p.device newEvent];
double short_ms = 0;
for (int w = 0; w < 3; w++) {
id<MTLCommandBuffer> cb = [queue_a commandBuffer];
encode_one(&p, cb, a_one);
[cb encodeSignalEvent:warm_event value:(uint64_t)(w + 1)];
[cb commit];
[cb waitUntilCompleted];
short_ms = span_ms(cb);
}
P("one spin alone: %u iterations, %.2f ms; the short part (one thread and a signal) %.3f ms; "
"A's long part %d spins",
iters, one_ms, short_ms, SPINS);
id<MTLEvent> event = [p.device newEvent];
for (int round = 1; round <= ROUNDS; round++) {
id<MTLCommandBuffer> a = [queue_a commandBuffer];
encode_one(&p, a, a_one);
[a encodeSignalEvent:event value:(uint64_t)round];
encode_spins(&p, a, iters, SPINS);
id<MTLCommandBuffer> b = [queue_b commandBuffer];
[b encodeWaitForEvent:event value:(uint64_t)round];
encode_one(&p, b, p.b_words);
[a commit];
[b commit];
[b waitUntilCompleted];
[a waitUntilCompleted];
double ms = 1000.0, a0 = a.GPUStartTime;
P("event round %d: A %.2f ms; B's GPU start %.2f and end %.2f ms after A's start (A ended "
"at %.2f); stall beyond the event's order (B's end) %.2f ms; A %s, B %s",
round, span_ms(a), (b.GPUStartTime - a0) * ms, (b.GPUEndTime - a0) * ms,
(a.GPUEndTime - a0) * ms, (b.GPUEndTime - a0) * ms - short_ms, status(a), status(b));
}
id<MTLSharedEvent> shared = [p.device newSharedEvent];
for (int round = 1; round <= ROUNDS; round++) {
id<MTLCommandBuffer> a = [queue_a commandBuffer];
encode_spins(&p, a, iters, SPINS);
id<MTLCommandBuffer> b = [queue_b commandBuffer];
[b encodeWaitForEvent:shared value:(uint64_t)round];
encode_one(&p, b, p.b_words);
[a commit];
[b commit];
double set = host_seconds();
shared.signaledValue = (uint64_t)round;
[b waitUntilCompleted];
[a waitUntilCompleted];
double ms = 1000.0;
P("host round %d: A %.2f ms, its GPU start %.2f ms after the host's set; B's GPU start %.2f "
"and end %.2f ms after the set (A ended at %.2f); stall beyond the event's order (B's "
"end) %.2f ms; A %s, B %s",
round, span_ms(a), (a.GPUStartTime - set) * ms, (b.GPUStartTime - set) * ms,
(b.GPUEndTime - set) * ms, (a.GPUEndTime - set) * ms, (b.GPUEndTime - set) * ms,
status(a), status(b));
}
}
return 0;
}
@@ -0,0 +1,66 @@
// What plain Metal answers for `-[MTLDevice getDefaultSamplePositions:count:]` at each sample count,
// those the device renders (`supportsTextureSampleCount:`) and those it does not, the reference
// metal2vulkan-runtime's `Device::default_sample_positions` is read against.
//
// default_sample_positions <count> one count a process: an assertion ends it.
// default_sample_positions list the counts.
//
// Each count prints whether the device renders it, then calls the method into 64 positions first
// set to (-1, -1), and prints every position it changed (index and value, each coordinate to 9
// digits), how many it changed, and an exception it raised, if any. A count Metal's validation
// stops ends the process; run it under MTL_DEBUG_LAYER=1 as well to see what the validation layer
// says (the exit status and the assertion's text on stderr).
//
// Build and run (macOS):
// clang -O2 -fobjc-arc -framework Metal -framework Foundation -o default_sample_positions \
// default_sample_positions.m
// for n in $(./default_sample_positions list); do ./default_sample_positions $n; echo "exit $?"; done
// for n in $(./default_sample_positions list); do MTL_DEBUG_LAYER=1 ./default_sample_positions $n;
// echo "exit $?"; done
#import <Foundation/Foundation.h>
#import <Metal/Metal.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
static const unsigned long kCounts[] = {0, 1, 2, 3, 4, 5, 6, 8, 16, 17, 32, 33};
int main(int argc, const char *argv[]) {
@autoreleasepool {
if (argc != 2) {
fprintf(stderr, "usage: %s <count> | list\n", argv[0]);
return 2;
}
if (strcmp(argv[1], "list") == 0) {
for (size_t i = 0; i < sizeof kCounts / sizeof kCounts[0]; i++) printf("%lu\n", kCounts[i]);
return 0;
}
NSUInteger n = (NSUInteger)strtoul(argv[1], NULL, 10);
id<MTLDevice> device = MTLCreateSystemDefaultDevice();
if (!device) {
fprintf(stderr, "no Metal device\n");
return 3;
}
printf("device %s; count %lu; supportsTextureSampleCount %s\n", device.name.UTF8String,
(unsigned long)n, [device supportsTextureSampleCount:n] ? "YES" : "NO");
enum { kSlots = 64 };
MTLSamplePosition pos[kSlots];
for (int i = 0; i < kSlots; i++) pos[i] = MTLSamplePositionMake(-1.0f, -1.0f);
fflush(stdout);
@try {
[device getDefaultSamplePositions:pos count:n];
} @catch (NSException *e) {
printf("count %lu: exception %s: %s\n", (unsigned long)n, e.name.UTF8String,
e.reason.UTF8String);
}
int changed = 0;
for (int i = 0; i < kSlots; i++) {
if (pos[i].x == -1.0f && pos[i].y == -1.0f) continue;
changed++;
printf("count %lu: position %d (%.9f, %.9f)\n", (unsigned long)n, i, pos[i].x, pos[i].y);
}
printf("count %lu: %d of %d positions changed\n", (unsigned long)n, changed, kSlots);
}
return 0;
}
@@ -0,0 +1,161 @@
// What a kernel's `[[stage_in]]` fetch reads through a layout of `MTLBufferLayoutStrideDynamic`
// whose buffer is bound by a setter WITHOUT an `attributeStride`: `setBuffer:offset:atIndex:`,
// `setBufferOffset:atIndex:` and `setBytes:length:atIndex:`, alone and after a stride setter
// bound the slot at a stride of its own.
//
// Metal's headers say the stride setters are the ones to call for such a layout ("only call this
// when the kernel-buffer is part of the stageInputDescriptor and has set its stride to
// `MTLBufferLayoutStrideDynamic`") and say nothing of what a plain bind of it reads. So the
// answer is a reading, and this probe takes it.
//
// The kernel reads one `uint` attribute (attribute 0, offset 0, buffer index 1) through a
// thread-position-in-grid-x layout at step rate 1 of a dynamic stride, and stores it at the
// thread's position in buffer 0. The source buffer holds `0x10 + w` at word `w`, so the words a
// row reads name the stride it fetched at: stride 0 reads `0x10` for every thread, 4 reads
// `0x10, 0x11, ...`, 8 reads `0x10, 0x12, ...`. Eight threads in one threadgroup, the stage-in
// region the grid's own; every fetch at a stride of at most 16 lies inside the 256-byte source.
//
// The rows, each its own command buffer and encoder:
//
// plain-buffer setBuffer:offset:0 atIndex:1, nothing else
// stride-8 setBuffer:offset:0 attributeStride:8 atIndex:1 (the control: it must
// read 0x10, 0x12, ..., or the probe measures nothing)
// stride-8-then-buffer the stride bind, then setBuffer:offset:0 atIndex:1 of the same buffer
// stride-8-then-offset the stride bind, then setBufferOffset:0 atIndex:1
// plain-bytes setBytes:length:256 atIndex:1 of the source's words
// stride-8-then-bytes the stride bind, then setBytes:length:256 atIndex:1
//
// Each row prints the eight words read, the stride they imply (or "other"), and the command
// buffer's status.
//
// xcrun clang -fobjc-arc -framework Metal -framework Foundation \
// -o dynamic_stride_plain_binds dynamic_stride_plain_binds.m
// ./dynamic_stride_plain_binds
// MTL_DEBUG_LAYER=1 MTL_DEBUG_LAYER_ERROR_MODE=nslog ./dynamic_stride_plain_binds
//
// The measuring run keeps `MTL_DEBUG_LAYER` out of the environment; the layer's messages are
// taken in the second run and reported as the layer's, never as plain Metal's answer.
//
// WHAT IT MEASURED: see the commit that adds the reading, with the run it came from.
#import <Foundation/Foundation.h>
#import <Metal/Metal.h>
#include <stdio.h>
#include <string.h>
static NSString *const SOURCE =
@"#include <metal_stdlib>\n"
"using namespace metal;\n"
"struct In { uint v [[attribute(0)]]; };\n"
"kernel void fetch(In in [[stage_in]], device uint *out [[buffer(0)]],\n"
" uint tid [[thread_position_in_grid]]) {\n"
" out[tid] = in.v;\n"
"}\n";
enum { THREADS = 8, WORDS = 64 };
typedef enum { PLAIN_BUFFER, STRIDE_8, STRIDE_THEN_BUFFER, STRIDE_THEN_OFFSET, PLAIN_BYTES,
STRIDE_THEN_BYTES, ROWS } Row;
static const char *NAMES[ROWS] = {"plain-buffer", "stride-8",
"stride-8-then-buffer", "stride-8-then-offset",
"plain-bytes", "stride-8-then-bytes"};
static void run(id<MTLDevice> device, id<MTLComputePipelineState> state,
id<MTLCommandQueue> queue, id<MTLBuffer> source, Row row) {
id<MTLBuffer> out = [device newBufferWithLength:THREADS * 4
options:MTLResourceStorageModeShared];
memset(out.contents, 0xee, THREADS * 4);
id<MTLCommandBuffer> cb = [queue commandBuffer];
id<MTLComputeCommandEncoder> encoder = [cb computeCommandEncoder];
[encoder setComputePipelineState:state];
[encoder setBuffer:out offset:0 atIndex:0];
switch (row) {
case PLAIN_BUFFER:
[encoder setBuffer:source offset:0 atIndex:1];
break;
case STRIDE_8:
[encoder setBuffer:source offset:0 attributeStride:8 atIndex:1];
break;
case STRIDE_THEN_BUFFER:
[encoder setBuffer:source offset:0 attributeStride:8 atIndex:1];
[encoder setBuffer:source offset:0 atIndex:1];
break;
case STRIDE_THEN_OFFSET:
[encoder setBuffer:source offset:0 attributeStride:8 atIndex:1];
[encoder setBufferOffset:0 atIndex:1];
break;
case PLAIN_BYTES:
[encoder setBytes:source.contents length:WORDS * 4 atIndex:1];
break;
case STRIDE_THEN_BYTES:
[encoder setBuffer:source offset:0 attributeStride:8 atIndex:1];
[encoder setBytes:source.contents length:WORDS * 4 atIndex:1];
break;
default:
break;
}
[encoder setStageInRegion:MTLRegionMake1D(0, THREADS)];
[encoder dispatchThreads:MTLSizeMake(THREADS, 1, 1)
threadsPerThreadgroup:MTLSizeMake(THREADS, 1, 1)];
[encoder endEncoding];
[cb commit];
[cb waitUntilCompleted];
const uint32_t *w = out.contents;
// The stride the words imply: every thread t read word t * k for one k, stride 4k bytes.
long stride = -1;
for (int k = 0; k <= 4 && stride < 0; k++) {
int all = 1;
for (int t = 0; t < THREADS; t++)
if (w[t] != 0x10u + (uint32_t)(t * k)) all = 0;
if (all) stride = 4 * k;
}
printf("%-21s status %ld%s:", NAMES[row], (long)cb.status, cb.error ? " (error)" : "");
for (int t = 0; t < THREADS; t++) printf(" %#x", w[t]);
if (stride >= 0)
printf(" -> stride %ld\n", stride);
else
printf(" -> other\n");
}
int main(void) {
@autoreleasepool {
id<MTLDevice> device = MTLCreateSystemDefaultDevice();
NSError *error = nil;
id<MTLLibrary> library = [device newLibraryWithSource:SOURCE
options:[MTLCompileOptions new]
error:&error];
if (!library) {
printf("library: %s\n", error.localizedDescription.UTF8String);
return 2;
}
MTLStageInputOutputDescriptor *stage = [MTLStageInputOutputDescriptor new];
stage.attributes[0].format = MTLAttributeFormatUInt;
stage.attributes[0].offset = 0;
stage.attributes[0].bufferIndex = 1;
stage.layouts[1].stride = MTLBufferLayoutStrideDynamic;
stage.layouts[1].stepFunction = MTLStepFunctionThreadPositionInGridX;
stage.layouts[1].stepRate = 1;
MTLComputePipelineDescriptor *descriptor = [MTLComputePipelineDescriptor new];
descriptor.computeFunction = [library newFunctionWithName:@"fetch"];
descriptor.stageInputDescriptor = stage;
id<MTLComputePipelineState> state =
[device newComputePipelineStateWithDescriptor:descriptor
options:MTLPipelineOptionNone
reflection:nil
error:&error];
if (!state) {
printf("state: %s\n", error.localizedDescription.UTF8String);
return 2;
}
id<MTLBuffer> source = [device newBufferWithLength:WORDS * 4
options:MTLResourceStorageModeShared];
uint32_t *words = source.contents;
for (int w = 0; w < WORDS; w++) words[w] = 0x10u + (uint32_t)w;
printf("%s, macOS %s\n", device.name.UTF8String,
NSProcessInfo.processInfo.operatingSystemVersionString.UTF8String);
id<MTLCommandQueue> queue = [device newCommandQueue];
for (int row = 0; row < ROWS; row++) run(device, state, queue, source, (Row)row);
}
return 0;
}
@@ -0,0 +1,260 @@
// How Metal blends an extended-range texture's two levels under a linear mip filter, for the forms
// `metal2vulkan`'s `lower/sampler/extended.rs` does not blend (`ExtendedRange::blends_levels`: the
// padded `R10Unorm_X6`, `RG10Unorm_X12` and their `_sRGB` twins, `RGB10A2Unorm_sRGB`, the bfloat
// formats) and, in 3D, for `BGR10_XR`, `BGRA10_XR` and their twins, against the rule the 2D
// samples of `BGR10_XR` and `BGRA10_XR` take: the two levels' samples blended by `mix` at the level
// fraction truncated onto sixty-fourths.
//
// Each form's texture (2D 16 x 16, or 3D 16 x 16 x 16, five levels, random codes: a padded form's
// low bits 0, a bfloat form's values in [0, 2)) is sampled by a kernel at 4,096 points per filter
// (nearest, linear), coordinates up to 0.15 past the edges and levels between two (a quarter on a
// sixty-fourth, a quarter one `f32` step beside one, the rest random), through a sampler clamping
// to the edge with a linear mip filter, and at the two levels themselves (the level's integer
// below and above) and at the point's own level through the same sampler with a nearest mip
// filter. For each lane the line counts the samples equal to the rule (`mix(a, b, w)` as
// `a * (1 - w) + b * w` in `f32`, no fused multiply-add), within one `f32` step of it, equal to
// the lower or upper level's sample or to the nearest mip filter's at the point's level (where
// the two levels differ), and equal to the blend at the unrounded fraction, and gives the largest
// distance from the rule, absolute and in units of the two samples' difference, after the level
// count of the texture Metal made. A two-plane form (`RGB10A8_2P_XR10` and its twin) is asked
// only whether a texture of five levels is made.
//
// xcrun clang -fobjc-arc -framework Metal -framework Foundation -o extended_linear_mip_blends \
// extended_linear_mip_blends.m
// /usr/bin/env -u MTL_DEBUG_LAYER ./extended_linear_mip_blends
#pragma STDC FP_CONTRACT OFF
#import <Foundation/Foundation.h>
#import <Metal/Metal.h>
#include <math.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
enum { SIDE = 16, LEVELS = 5, POINTS = 4096 };
static const char *SRC =
"#include <metal_stdlib>\n"
"using namespace metal;\n"
"kernel void k2(texture2d<float> t [[texture(0)]], sampler s [[sampler(0)]],\n"
" device const float4 *p [[buffer(0)]], device float4 *o [[buffer(1)]],\n"
" uint i [[thread_position_in_grid]]) {\n"
" o[i] = t.sample(s, p[i].xy, level(p[i].w));\n"
"}\n"
"kernel void k3(texture3d<float> t [[texture(0)]], sampler s [[sampler(0)]],\n"
" device const float4 *p [[buffer(0)]], device float4 *o [[buffer(1)]],\n"
" uint i [[thread_position_in_grid]]) {\n"
" o[i] = t.sample(s, p[i].xyz, level(p[i].w));\n"
"}\n";
static uint64_t sm = 11;
static uint64_t next64(void) {
uint64_t z = (sm += 0x9E3779B97F4A7C15ull);
z = (z ^ (z >> 30)) * 0xBF58476D1CE4E5B9ull;
z = (z ^ (z >> 27)) * 0x94D049BB133111EBull;
return z ^ (z >> 31);
}
static uint32_t r32(void) { return (uint32_t)(next64() >> 32); }
static float unit(void) { return (float)(r32() >> 8) / 16777216.0f; }
// A form: its raw `MTLPixelFormat`, name, bytes per texel and how a random texel's bytes are made
// (0: every bit random, 1: 16-bit words with their low 6 bits 0, 2: 16-bit bfloats in [0, 2),
// 3: a 32-bit word of three 10-bit fields and two bits 0).
typedef struct {
NSUInteger raw;
const char *name;
int bytes, kind, volume;
} Form;
static void texel(const Form *f, uint8_t *out) {
for (int b = 0; b < f->bytes; b += 2) {
uint16_t w = (uint16_t)r32();
if (f->kind == 1) w &= 0xffc0;
if (f->kind == 2) w = (uint16_t)(0x3b00 + (r32() % 0x500)); // bfloat 2^-9 .. ~2
memcpy(out + b, &w, 2);
}
if (f->kind == 3) {
uint32_t w = r32() & 0x3fffffff;
memcpy(out, &w, 4);
}
}
int main(void) {
@autoreleasepool {
id<MTLDevice> dev = MTLCreateSystemDefaultDevice();
printf("device %s\n", dev.name.UTF8String);
NSError *err = nil;
MTLCompileOptions *co = [MTLCompileOptions new];
co.mathMode = MTLMathModeSafe;
id<MTLLibrary> lib = [dev newLibraryWithSource:@(SRC) options:co error:&err];
if (!lib) {
printf("library: %s\n", err.description.UTF8String);
return 1;
}
id<MTLComputePipelineState> k2 = [dev newComputePipelineStateWithFunction:[lib newFunctionWithName:@"k2"] error:&err];
id<MTLComputePipelineState> k3 = [dev newComputePipelineStateWithFunction:[lib newFunctionWithName:@"k3"] error:&err];
id<MTLCommandQueue> q = [dev newCommandQueue];
Form forms[] = {
{576, "R10Unorm_X6", 2, 1, 0}, {577, "R10Unorm_X6_sRGB", 2, 1, 0},
{578, "RG10Unorm_X12", 4, 1, 0}, {579, "RG10Unorm_X12_sRGB", 4, 1, 0},
{586, "RGB10A2Unorm_sRGB", 4, 0, 0}, {26, "R16Bfloat", 2, 2, 0},
{66, "RG16Bfloat", 4, 2, 0}, {116, "RGBA16Bfloat", 8, 2, 0},
{554, "BGR10_XR", 4, 3, 1}, {555, "BGR10_XR_sRGB", 4, 3, 1},
{552, "BGRA10_XR", 8, 1, 1}, {553, "BGRA10_XR_sRGB", 8, 1, 1},
{554, "BGR10_XR", 4, 3, 0}, {552, "BGRA10_XR", 8, 1, 0},
};
// The two-plane forms: whether a texture of five levels is made.
for (NSUInteger raw = 550; raw <= 551; raw++) {
MTLTextureDescriptor *td = [MTLTextureDescriptor new];
td.pixelFormat = (MTLPixelFormat)raw;
td.width = td.height = SIDE;
td.mipmapLevelCount = LEVELS;
td.usage = MTLTextureUsageShaderRead;
td.storageMode = MTLStorageModePrivate;
id<MTLTexture> t = [dev newTextureWithDescriptor:td];
printf("RESULT two-plane %lu: a texture of %d levels %s\n", (unsigned long)raw, LEVELS,
t ? "is made" : "is not made");
}
for (unsigned fi = 0; fi < sizeof forms / sizeof forms[0]; fi++) {
Form f = forms[fi];
MTLTextureDescriptor *td = [MTLTextureDescriptor new];
td.textureType = f.volume ? MTLTextureType3D : MTLTextureType2D;
td.pixelFormat = (MTLPixelFormat)f.raw;
td.width = td.height = SIDE;
td.depth = f.volume ? SIDE : 1;
td.mipmapLevelCount = LEVELS;
td.usage = MTLTextureUsageShaderRead;
td.storageMode = MTLStorageModePrivate;
id<MTLTexture> tex = [dev newTextureWithDescriptor:td];
if (!tex) {
printf("RESULT %s %s: no texture\n", f.name, f.volume ? "3d" : "2d");
continue;
}
printf("FORM %s %s: a texture of %lu levels\n", f.name, f.volume ? "3d" : "2d",
(unsigned long)tex.mipmapLevelCount);
// Each level's random texels, through a buffer.
id<MTLCommandBuffer> cb = [q commandBuffer];
id<MTLBlitCommandEncoder> bl = [cb blitCommandEncoder];
for (int l = 0; l < LEVELS; l++) {
NSUInteger w = SIDE >> l, d = f.volume ? w : 1, n = w * w * d;
NSUInteger row = w * (NSUInteger)f.bytes;
uint8_t *bytes = malloc(n * f.bytes);
for (NSUInteger t = 0; t < n; t++) texel(&f, bytes + t * f.bytes);
id<MTLBuffer> src = [dev newBufferWithBytes:bytes length:n * f.bytes options:MTLResourceStorageModeShared];
free(bytes);
[bl copyFromBuffer:src
sourceOffset:0
sourceBytesPerRow:row
sourceBytesPerImage:row * w
sourceSize:MTLSizeMake(w, w, d)
toTexture:tex
destinationSlice:0
destinationLevel:l
destinationOrigin:MTLOriginMake(0, 0, 0)];
}
[bl endEncoding];
[cb commit];
[cb waitUntilCompleted];
for (int linear = 0; linear < 2; linear++) {
// The points, and the same points at the level below and above.
float *pts = calloc(POINTS * 4 * 4, sizeof(float));
for (int i = 0; i < POINTS; i++) {
float *p = pts + 4 * i;
for (int c = 0; c < 3; c++) p[c] = unit() * 1.3f - 0.15f;
int l0 = (int)(r32() % 4);
float frac;
uint32_t pick = r32() % 4;
int k = 1 + (int)(r32() % 63);
if (pick == 0) {
frac = (float)k / 64.0f;
} else if (pick == 1) {
frac = nextafterf((float)k / 64.0f, (r32() & 1) ? 1.0f : 0.0f);
} else {
frac = unit();
if (frac == 0.0f) frac = 0.5f;
}
p[3] = (float)l0 + frac;
memcpy(pts + 4 * (POINTS + i), p, 16);
memcpy(pts + 4 * (2 * POINTS + i), p, 16);
memcpy(pts + 4 * (3 * POINTS + i), p, 16);
pts[4 * (POINTS + i) + 3] = (float)l0;
pts[4 * (2 * POINTS + i) + 3] = (float)(l0 + 1);
}
id<MTLBuffer> pb = [dev newBufferWithBytes:pts length:POINTS * 64 options:MTLResourceStorageModeShared];
id<MTLBuffer> ob = [dev newBufferWithLength:POINTS * 64 options:MTLResourceStorageModeShared];
id<MTLSamplerState> ss[2];
for (int mip = 0; mip < 2; mip++) {
MTLSamplerDescriptor *sd = [MTLSamplerDescriptor new];
sd.minFilter = sd.magFilter = linear ? MTLSamplerMinMagFilterLinear : MTLSamplerMinMagFilterNearest;
sd.mipFilter = mip ? MTLSamplerMipFilterNearest : MTLSamplerMipFilterLinear;
sd.sAddressMode = sd.tAddressMode = sd.rAddressMode = MTLSamplerAddressModeClampToEdge;
ss[mip] = [dev newSamplerStateWithDescriptor:sd];
}
cb = [q commandBuffer];
id<MTLComputeCommandEncoder> en = [cb computeCommandEncoder];
[en setComputePipelineState:f.volume ? k3 : k2];
[en setTexture:tex atIndex:0];
for (int part = 0; part < 4; part++) {
[en setSamplerState:ss[part == 0 ? 0 : 1] atIndex:0];
[en setBuffer:pb offset:part * POINTS * 16 atIndex:0];
[en setBuffer:ob offset:part * POINTS * 16 atIndex:1];
[en dispatchThreads:MTLSizeMake(POINTS, 1, 1) threadsPerThreadgroup:MTLSizeMake(64, 1, 1)];
}
[en endEncoding];
[cb commit];
[cb waitUntilCompleted];
if (cb.status != MTLCommandBufferStatusCompleted) {
printf("RESULT %s: command buffer status %ld\n", f.name, (long)cb.status);
return 1;
}
const float *o = ob.contents;
long lanes = 0, rule = 0, ulp = 0, lower = 0, upper = 0, unrounded = 0, flat = 0, nearest = 0;
double maxd = 0, maxrel = 0;
int shown = 0;
for (int i = 0; i < POINTS; i++) {
float frac = pts[4 * i + 3] - floorf(pts[4 * i + 3]);
float w = floorf(frac * 64.0f) / 64.0f;
for (int c = 0; c < 4; c++) {
float x = o[4 * i + c], a = o[4 * (POINTS + i) + c], b = o[4 * (2 * POINTS + i) + c];
nearest += x == o[4 * (3 * POINTS + i) + c] && a != b;
if (isnan(x) || isnan(a) || isnan(b)) continue;
lanes++;
float one = 1.0f - w;
float pa = a * one;
float pb2 = b * w;
float m = pa + pb2;
float mu = (float)((double)a + ((double)b - (double)a) * (double)frac);
if (a == b) flat++;
rule += x == m;
ulp += fabsf(x - m) <= fabsf(nextafterf(m, INFINITY) - m);
lower += x == a && a != b;
upper += x == b && a != b;
unrounded += x == mu;
double d = fabs((double)x - (double)m);
if (d > maxd) maxd = d;
if (a != b) {
double rel = d / fabs((double)b - (double)a);
if (rel > maxrel) maxrel = rel;
}
if (x != m && shown < 4) {
shown++;
printf(" %s %s point (%.6g %.6g %.6g) level %.9g lane %d: %.9g, rule %.9g (levels %.9g %.9g, w %.6g)\n",
f.name, linear ? "linear" : "nearest", pts[4 * i], pts[4 * i + 1], pts[4 * i + 2],
pts[4 * i + 3], c, x, m, a, b, w);
}
}
}
printf("RESULT %s %s %s: %ld lanes (%ld of equal levels); the rule %ld, within an f32 step %ld; "
"the lower level %ld, the upper %ld, the nearest mip filter's at the level %ld (of unequal levels); "
"the unrounded fraction %ld; largest distance %.3g (%.4g of the levels' difference)\n",
f.name, f.volume ? "3d" : "2d", linear ? "linear" : "nearest", lanes, flat, rule, ulp, lower,
upper, nearest, unrounded, maxd, maxrel);
free(pts);
}
}
}
return 0;
}
@@ -0,0 +1,156 @@
// What an imageblock slice write holds, in a partial threadgroup of a dispatchThreads grid, for
// the cells of the threads past the grid.
//
// The kernel has an explicit imageblock of one float4 per cell. Each thread stores
// (gx, gy, 7, 9) in its cell, gx and gy being its position in the grid, then a threadgroup
// barrier on imageblock memory. Then the thread at local (0, 0) writes the slice of that field
// (the imageblock's whole 8 by 8 extent, set with setImageblockWidth:height:) at its
// threadgroup's origin in an RGBA32Float texture. The grid is 21 by 13 threads in 8 by 8
// threadgroups, so three kinds of edge group are partial: in x (groups (2, 0)), in y ((0, 1)
// and (1, 1)), and in the corner ((2, 1)). The texture is 24 by 16, so every slice lies inside
// it. Before each dispatch every texel is set to a sentinel. Each run makes two dispatches into
// two textures, the first with sentinel (-1, -1, -1, -1) and the second with (-2, -2, -2, -2),
// and prints, for each kind of edge, how many of the cells past the grid hold:
//
// sentinel the texel as it was before the dispatch (the cell not written)
// as-if-ran (gx, gy, 7, 9) for the cell's own position (as if the thread had run)
// pattern (x, y, 7, 9) of another grid position (a cell some other thread stored)
// zero (0, 0, 0, 0)
// other anything else
//
// plus a hash of those texels, so that runs can be compared. It also counts the texels of grid
// threads that do not hold their own (gx, gy, 7, 9).
//
// xcrun clang -fobjc-arc -framework Metal -framework Foundation \
// -o imageblock_slice_past_the_grid imageblock_slice_past_the_grid.m
// ./imageblock_slice_past_the_grid; ./imageblock_slice_past_the_grid
//
// WHAT IT MEASURED: see the commit that added this probe, with the run it came from.
#import <Foundation/Foundation.h>
#import <Metal/Metal.h>
#include <string.h>
static NSString *const SOURCE =
@"#include <metal_stdlib>\n"
"using namespace metal;\n"
"struct Cell { float4 colour; };\n"
"kernel void slice_past_the_grid(imageblock<Cell, imageblock_layout_explicit> block,\n"
" texture2d<float, access::write> out [[texture(0)]],\n"
" ushort2 lid [[thread_position_in_threadgroup]],\n"
" ushort2 tgp [[threadgroup_position_in_grid]],\n"
" ushort2 gid [[thread_position_in_grid]]) {\n"
" threadgroup_imageblock Cell *cell = block.data(lid);\n"
" cell->colour = float4(float(gid.x), float(gid.y), 7.0, 9.0);\n"
" threadgroup_barrier(mem_flags::mem_threadgroup_imageblock);\n"
" if (lid.x == 0 && lid.y == 0) {\n"
" out.write(block.slice(block.data(ushort2(0))->colour), tgp * ushort2(8));\n"
" }\n"
"}\n";
enum { GRID_W = 21, GRID_H = 13, TEX_W = 24, TEX_H = 16, GROUP = 8 };
static const char *edge_of(int x, int y) {
BOOL past_x = x >= GRID_W, past_y = y >= GRID_H;
int gx = x / GROUP, gy = y / GROUP;
BOOL edge_x = gx == (GRID_W - 1) / GROUP, edge_y = gy == (GRID_H - 1) / GROUP;
if (!past_x && !past_y) return NULL;
if (edge_x && edge_y) return "corner";
return past_x ? "x-edge" : "y-edge";
}
static void report(id<MTLDevice> device, id<MTLComputePipelineState> state,
id<MTLCommandQueue> queue, float sentinel) {
MTLTextureDescriptor *d =
[MTLTextureDescriptor texture2DDescriptorWithPixelFormat:MTLPixelFormatRGBA32Float
width:TEX_W
height:TEX_H
mipmapped:NO];
d.usage = MTLTextureUsageShaderWrite | MTLTextureUsageShaderRead;
d.storageMode = MTLStorageModeShared;
id<MTLTexture> tex = [device newTextureWithDescriptor:d];
static float texels[TEX_H][TEX_W][4];
for (int y = 0; y < TEX_H; y++)
for (int x = 0; x < TEX_W; x++)
for (int c = 0; c < 4; c++) texels[y][x][c] = sentinel;
MTLRegion all = MTLRegionMake2D(0, 0, TEX_W, TEX_H);
[tex replaceRegion:all mipmapLevel:0 withBytes:texels bytesPerRow:TEX_W * 16];
id<MTLCommandBuffer> cb = [queue commandBuffer];
id<MTLComputeCommandEncoder> encoder = [cb computeCommandEncoder];
[encoder setComputePipelineState:state];
[encoder setTexture:tex atIndex:0];
[encoder setImageblockWidth:GROUP height:GROUP];
[encoder dispatchThreads:MTLSizeMake(GRID_W, GRID_H, 1)
threadsPerThreadgroup:MTLSizeMake(GROUP, GROUP, 1)];
[encoder endEncoding];
[cb commit];
[cb waitUntilCompleted];
memset(texels, 0, sizeof texels);
[tex getBytes:texels bytesPerRow:TEX_W * 16 fromRegion:all mipmapLevel:0];
const char *edges[3] = {"x-edge", "y-edge", "corner"};
int wrong_grid = 0;
for (int y = 0; y < TEX_H; y++)
for (int x = 0; x < TEX_W; x++) {
const float *t = texels[y][x];
if (!edge_of(x, y) &&
!(t[0] == x && t[1] == y && t[2] == 7.0f && t[3] == 9.0f))
wrong_grid++;
}
printf("sentinel %g, status %ld%s%s, grid texels not their own: %d\n", sentinel,
(long)cb.status, cb.error ? ", error " : "",
cb.error ? cb.error.localizedDescription.UTF8String : "", wrong_grid);
for (int e = 0; e < 3; e++) {
int cells = 0, kept = 0, ran = 0, pattern = 0, zero = 0, other = 0;
uint64_t hash = 1469598103934665603ull;
for (int y = 0; y < TEX_H; y++)
for (int x = 0; x < TEX_W; x++) {
const char *edge = edge_of(x, y);
if (!edge || strcmp(edge, edges[e]) != 0) continue;
const float *t = texels[y][x];
cells++;
if (t[0] == sentinel && t[1] == sentinel && t[2] == sentinel && t[3] == sentinel)
kept++;
else if (t[0] == x && t[1] == y && t[2] == 7.0f && t[3] == 9.0f)
ran++;
else if (t[2] == 7.0f && t[3] == 9.0f && t[0] >= 0 && t[0] < GRID_W &&
t[1] >= 0 && t[1] < GRID_H)
pattern++;
else if (t[0] == 0 && t[1] == 0 && t[2] == 0 && t[3] == 0)
zero++;
else
other++;
const unsigned char *b = (const unsigned char *)t;
for (int i = 0; i < 16; i++) hash = (hash ^ b[i]) * 1099511628211ull;
}
printf(" %s: %d cells past the grid: sentinel %d, as-if-ran %d, pattern %d, zero %d, "
"other %d; hash %016llx\n",
edges[e], cells, kept, ran, pattern, zero, other, (unsigned long long)hash);
}
}
int main(void) {
@autoreleasepool {
id<MTLDevice> device = MTLCreateSystemDefaultDevice();
NSError *error = nil;
id<MTLLibrary> library = [device newLibraryWithSource:SOURCE
options:[MTLCompileOptions new]
error:&error];
if (!library) {
printf("library: %s\n", error.localizedDescription.UTF8String);
return 2;
}
id<MTLComputePipelineState> state = [device
newComputePipelineStateWithFunction:[library newFunctionWithName:@"slice_past_the_grid"]
error:&error];
if (!state) {
printf("state: %s\n", error.localizedDescription.UTF8String);
return 2;
}
printf("%s, maxTotalThreadsPerThreadgroup %lu\n", device.name.UTF8String,
(unsigned long)state.maxTotalThreadsPerThreadgroup);
id<MTLCommandQueue> queue = [device newCommandQueue];
report(device, state, queue, -1.0f);
report(device, state, queue, -2.0f);
}
return 0;
}
@@ -0,0 +1,667 @@
// Whether a Metal blit copy gives the source's bytes from before the copy where its source and its
// destination are two resources over one memory: a texture placed in a placement heap and another
// resource of the heap placed over its bytes, and an IOSurface plane's texture and a no-copy buffer
// over the surface's own bytes.
//
// The runtime refuses the first (`Gap::OverlappingCopy`: a heap texture's texels lie as the device
// chooses, so no cut of Vulkan copy commands keeps one command's source and destination apart),
// and copies the second a row at a time from the source as it was before the copy. MTLHeap.h of a
// placement heap's resources: "Any resources that exist in this heap at overlapping half-open
// range [offset, offset + requiredSize) are implicitly aliased with the new resource."
//
// Cases, one a process, ROUNDS (8) rounds each, each round with words of its own:
//
// heap-<mode>-b2t a buffer and a 64x64 RGBA8Unorm texture, both at offset 0 of a placement
// heap: the buffer is written (a blit from a Shared buffer), then copied
// whole into the texture, which is then read out
// heap-<mode>-t2b the texture is written, then copied whole into the buffer, which is read out
// heap-<mode>-t2t two such textures at offset 0: the first is written, then copied whole into
// the second, which is read out
// heap-private-<shape>-apart
// controls: the second resource placed past the first's bytes
// tex-shift two such textures in a Private placement heap, the second one texture
// alignment on: `copyFromTexture:toTexture:` from the first to the second
// tex-half the second half the texture's bytes on (rounded up to the alignment)
// tex-region both at 0: the region method (`copyFromTexture:sourceSlice:...`) over the
// whole level
// tex-region-half the region method over the whole level, the second half the bytes on
// tex-region-part both at 0: the region method, texels (0, 0) to (31, 31) into (32, 32)
// tex-inplace-to a heap texture at 0 and a linear texture over a heap buffer at 0
// (`newTextureWithDescriptor:offset:bytesPerRow:`): `copyFromTexture:toTexture:`
// from the heap texture to the linear one
// tex-inplace-from the same, from the linear texture to the heap texture
// buf-alias-<way>-<n>
// two buffers at offset 0 of a Private placement heap, 64 KiB and 4 KiB more
// each: `copyFromBuffer:sourceOffset:toBuffer:destinationOffset:size:` of
// 64 KiB from the first to the second, the destination <n> bytes past the
// source (`up`) or the source <n> bytes past the destination (`down`)
// buf-one-up-4 control: one such buffer into itself, the destination 4 bytes past the
// source, which Apple's page for the copy allows only where the size is less
// than the offsets' distance
// surface-in-up a 64x16 BGRA8Unorm IOSurface's plane texture and a no-copy buffer over the
// surface's bytes: buffer rows 1-15 into texture rows 0-14
// surface-in-down buffer rows 0-14 into texture rows 1-15
// surface-in-right texels 0-55 of each buffer row into texels 8-63 of the texture's
// surface-out-up texture rows 1-15 into buffer rows 0-14
// surface-out-down texture rows 0-14 into buffer rows 1-15
// surface-out-right texels 0-55 of each texture row into texels 8-63 of the buffer's
//
// <mode> is the heap's storage mode, `private` or `shared`. Every resource is tracked. Each step is
// a command buffer of its own, waited for, so the copy is one blit command alone.
//
// Each heap round prints how many of the destination's 32-bit words hold the source's word from
// before the copy ("source") and how many do not ("other"), with the destination's FNV-1a 64. Each
// surface round prints, over the destination region, how many words hold the source's word from
// before the copy ("source"), the word a copy of texels in place front to back would leave
// ("forward"), back to front ("backward"), or none of them ("other"), and how many words outside
// the region changed ("outside"). Each case ends with `SUMMARY <case> whole <n> of <ROUNDS>`: the
// rounds whose every destination word was the source's.
//
// xcrun clang -O2 -fobjc-arc -framework Metal -framework Foundation -framework IOSurface \
// -o overlapping_alias_copies overlapping_alias_copies.m
// for c in $(./overlapping_alias_copies --list); do
// ./overlapping_alias_copies $c; MTL_DEBUG_LAYER=1 ./overlapping_alias_copies $c
// done
//
// Every case prints `DEVICE <name> / RELEASE <os>`, then `CASE <case>`, `READ` lines, and `DONE
// <case>`. A case whose process Metal ends prints no `DONE`, and its exit status is the reading.
//
// WHAT IT MEASURED: on an Apple M3 Max, macOS 27.0.1 (26A434), jobs m3-max-81486 (heap-*,
// surface-*) and m3-max-81493 (tex-*). The texture's heap footprint was 16512 bytes at an
// alignment of 128.
//
// - With the API validation off, every case gave the source's words from before the copy in 8 of
// 8 rounds, including the aliases at 0, 128 and 8320 bytes apart. The surface cases also left
// no word outside the region changed.
// - With MTL_DEBUG_LAYER=1, these cases end the process (status 134) at the copy:
// - heap-{private,shared}-{b2t,t2b}, tex-region, tex-region-half and tex-region-part:
// "validateResourceAliasing:332: failed assertion `blitting between aliasing resources is
// defined on a placement heap only when using a blit method copying entire texture surfaces,
// or when copying between buffers.'"
// - tex-inplace-to and tex-inplace-from: "validateResourceAliasing:332: failed assertion
// `blitting between aliasing resources is defined on a placement heap only when both textures
// are linear and have the same bufferBytesPerRow value.'"
// - Under validation, the other cases run to the end with the same words: heap-*-t2t, tex-shift
// and tex-half (copyFromTexture:toTexture:), the -apart controls, and every surface-* case.
// - Job m3-max-81544 (buf-*): with the API validation off, every case gave memmove's bytes in 8 of
// 8 rounds, buf-one-up-4 too. With MTL_DEBUG_LAYER=1, buf-one-up-4 runs to the end with the same
// bytes, and every buf-alias-* case ends the process (status 134) inside the layer's own
// aliasing check, "-[MTLDebugBuffer width]: unrecognized selector sent to instance",
// from `validateResourceAliasing` under `-[MTLDebugBlitCommandEncoder
// copyFromBuffer:sourceOffset:toBuffer:destinationOffset:size:]`: the layer's fault, not a
// refusal; its assertion text above names copies between buffers among the defined ones.
#import <Foundation/Foundation.h>
#import <IOSurface/IOSurface.h>
#import <Metal/Metal.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
enum {
ROUNDS = 8,
SIDE = 64,
ROW = SIDE * 4,
TEXELS = SIDE * SIDE,
SURFACE_WIDTH = 64,
SURFACE_HEIGHT = 16,
SURFACE_PITCH = 256,
SHIFT = 8,
};
static id<MTLDevice> gDevice = nil;
static id<MTLCommandQueue> gQueue = nil;
static const char *kCases[] = {
"heap-private-b2t", "heap-private-t2b", "heap-private-t2t",
"heap-shared-b2t", "heap-shared-t2b", "heap-shared-t2t",
"heap-private-b2t-apart", "heap-private-t2b-apart", "heap-private-t2t-apart",
"tex-shift", "tex-half", "tex-region",
"tex-region-half", "tex-region-part", "tex-inplace-to",
"tex-inplace-from",
"buf-alias-up-4", "buf-alias-down-4", "buf-alias-up-4096",
"buf-alias-down-4096", "buf-one-up-4",
"surface-in-up", "surface-in-down", "surface-in-right",
"surface-out-up", "surface-out-down", "surface-out-right",
};
static NSUInteger round_up(NSUInteger value, NSUInteger multiple) {
return (value + multiple - 1) / multiple * multiple;
}
static uint64_t fnv(const uint8_t *bytes, size_t len) {
uint64_t h = 0xcbf29ce484222325ull;
for (size_t i = 0; i < len; i++) {
h ^= bytes[i];
h *= 0x100000001b3ull;
}
return h;
}
/// Commits `cb`, waits for it, and prints its status where it did not complete.
static void run(id<MTLCommandBuffer> cb, const char *step) {
[cb commit];
[cb waitUntilCompleted];
if (cb.status != MTLCommandBufferStatusCompleted) {
printf("READ step %s status %ld error %s\n", step, (long)cb.status,
cb.error ? cb.error.localizedDescription.UTF8String : "none");
fflush(stdout);
}
}
// ---- heap cases ----------------------------------------------------------------------------
static int heap_case(MTLStorageMode mode, const char *shape, BOOL apart, const char *name) {
MTLTextureDescriptor *td =
[MTLTextureDescriptor texture2DDescriptorWithPixelFormat:MTLPixelFormatRGBA8Unorm
width:SIDE
height:SIDE
mipmapped:NO];
td.usage = MTLTextureUsageShaderRead;
td.storageMode = mode;
td.hazardTrackingMode = MTLHazardTrackingModeTracked;
MTLResourceOptions bo =
(mode == MTLStorageModePrivate ? MTLResourceStorageModePrivate
: MTLResourceStorageModeShared) |
MTLResourceHazardTrackingModeTracked;
MTLSizeAndAlign ts = [gDevice heapTextureSizeAndAlignWithDescriptor:td];
NSUInteger blen = ts.size;
MTLSizeAndAlign bs = [gDevice heapBufferSizeAndAlignWithLength:blen options:bo];
NSUInteger align = MAX(ts.align, bs.align);
NSUInteger span = MAX(ts.size, bs.size);
NSUInteger second = apart ? round_up(span, align) : 0;
printf("READ texture_size %lu texture_align %lu buffer_size %lu buffer_align %lu second_at %lu\n",
(unsigned long)ts.size, (unsigned long)ts.align, (unsigned long)bs.size,
(unsigned long)bs.align, (unsigned long)second);
MTLHeapDescriptor *hd = [MTLHeapDescriptor new];
hd.type = MTLHeapTypePlacement;
hd.storageMode = mode;
hd.hazardTrackingMode = MTLHazardTrackingModeTracked;
hd.size = round_up(second + span, 1u << 16) + (1u << 16);
id<MTLHeap> heap = [gDevice newHeapWithDescriptor:hd];
if (!heap) {
printf("READ heap nil\n");
return 2;
}
BOOL b2t = strcmp(shape, "b2t") == 0, t2b = strcmp(shape, "t2b") == 0;
BOOL t2t = strcmp(shape, "t2t") == 0;
// The first resource at 0, the second at `second`: the texture first for t2b and t2t, the
// buffer first for b2t.
id<MTLTexture> texture = [heap newTextureWithDescriptor:td offset:(b2t ? second : 0)];
id<MTLBuffer> buffer =
(b2t || t2b) ? [heap newBufferWithLength:blen options:bo offset:(b2t ? 0 : second)] : nil;
id<MTLTexture> texture2 = t2t ? [heap newTextureWithDescriptor:td offset:second] : nil;
if (!texture || ((b2t || t2b) && !buffer) || (t2t && !texture2)) {
printf("READ resource nil texture %d buffer %d texture2 %d\n", texture != nil,
buffer != nil, texture2 != nil);
return 2;
}
id<MTLBuffer> src = [gDevice newBufferWithLength:TEXELS * 4 options:MTLResourceStorageModeShared];
id<MTLBuffer> out = [gDevice newBufferWithLength:TEXELS * 4 options:MTLResourceStorageModeShared];
MTLSize whole = MTLSizeMake(SIDE, SIDE, 1);
MTLOrigin zero = MTLOriginMake(0, 0, 0);
int wholeRounds = 0;
for (uint32_t round = 0; round < ROUNDS; round++) {
uint32_t *words = (uint32_t *)src.contents;
for (uint32_t i = 0; i < TEXELS; i++) words[i] = 0x80000000u | (round << 16) | i;
memset(out.contents, 0xEE, TEXELS * 4);
id<MTLCommandBuffer> cb = [gQueue commandBuffer];
id<MTLBlitCommandEncoder> blit = [cb blitCommandEncoder];
if (b2t) {
[blit copyFromBuffer:src sourceOffset:0 toBuffer:buffer destinationOffset:0
size:TEXELS * 4];
} else {
[blit copyFromBuffer:src sourceOffset:0 sourceBytesPerRow:ROW
sourceBytesPerImage:ROW * SIDE sourceSize:whole toTexture:texture
destinationSlice:0 destinationLevel:0 destinationOrigin:zero];
}
[blit endEncoding];
run(cb, "write");
cb = [gQueue commandBuffer];
blit = [cb blitCommandEncoder];
if (b2t) {
[blit copyFromBuffer:buffer sourceOffset:0 sourceBytesPerRow:ROW
sourceBytesPerImage:ROW * SIDE sourceSize:whole toTexture:texture
destinationSlice:0 destinationLevel:0 destinationOrigin:zero];
} else if (t2b) {
[blit copyFromTexture:texture sourceSlice:0 sourceLevel:0 sourceOrigin:zero
sourceSize:whole toBuffer:buffer destinationOffset:0
destinationBytesPerRow:ROW destinationBytesPerImage:ROW * SIDE];
} else {
[blit copyFromTexture:texture toTexture:texture2];
}
[blit endEncoding];
run(cb, "copy");
cb = [gQueue commandBuffer];
blit = [cb blitCommandEncoder];
if (t2b) {
[blit copyFromBuffer:buffer sourceOffset:0 toBuffer:out destinationOffset:0
size:TEXELS * 4];
} else {
[blit copyFromTexture:(b2t ? texture : texture2) sourceSlice:0 sourceLevel:0
sourceOrigin:zero sourceSize:whole toBuffer:out destinationOffset:0
destinationBytesPerRow:ROW destinationBytesPerImage:ROW * SIDE];
}
[blit endEncoding];
run(cb, "read");
const uint32_t *got = (const uint32_t *)out.contents;
int source = 0, other = 0, first = -1;
for (int i = 0; i < TEXELS; i++) {
if (got[i] == words[i]) {
source++;
} else {
other++;
if (first < 0) first = i;
}
}
printf("READ %s round %u source %d other %d", name, round, source, other);
if (first >= 0) printf(" first_other %d word 0x%08x", first, got[first]);
printf(" fnv %016llx\n", (unsigned long long)fnv(out.contents, TEXELS * 4));
fflush(stdout);
if (other == 0) wholeRounds++;
}
printf("SUMMARY %s whole %d of %d\n", name, wholeRounds, ROUNDS);
return 0;
}
// ---- texture to texture in a Private placement heap ---------------------------------------
/// How a `tex-*` case copies: `copyFromTexture:toTexture:` (`WHOLE`), or the region method over
/// the whole level (`REGION_WHOLE`) or over its 32 x 32 texels at (0, 0) into (32, 32)
/// (`REGION_PART`).
typedef enum { WHOLE, REGION_WHOLE, REGION_PART } Method;
/// The second texture at `at` (`0`, `1` the texture alignment, `2` half the texture's bytes rounded
/// up to it); `inPlace` 1 where the destination, 2 where the source, is a linear texture over a heap
/// buffer at offset 0 (`newTextureWithDescriptor:offset:bytesPerRow:`) instead of a heap texture.
static int tex_case(int at, Method method, int inPlace, const char *name) {
MTLTextureDescriptor *td =
[MTLTextureDescriptor texture2DDescriptorWithPixelFormat:MTLPixelFormatRGBA8Unorm
width:SIDE
height:SIDE
mipmapped:NO];
td.usage = MTLTextureUsageShaderRead;
td.storageMode = MTLStorageModePrivate;
td.hazardTrackingMode = MTLHazardTrackingModeTracked;
MTLResourceOptions bo = MTLResourceStorageModePrivate | MTLResourceHazardTrackingModeTracked;
MTLSizeAndAlign ts = [gDevice heapTextureSizeAndAlignWithDescriptor:td];
NSUInteger second = at == 0 ? 0 : at == 1 ? ts.align : round_up(ts.size / 2, ts.align);
printf("READ texture_size %lu texture_align %lu second_at %lu linear_align %lu\n",
(unsigned long)ts.size, (unsigned long)ts.align, (unsigned long)second,
(unsigned long)[gDevice minimumLinearTextureAlignmentForPixelFormat:td.pixelFormat]);
MTLHeapDescriptor *hd = [MTLHeapDescriptor new];
hd.type = MTLHeapTypePlacement;
hd.storageMode = MTLStorageModePrivate;
hd.hazardTrackingMode = MTLHazardTrackingModeTracked;
hd.size = round_up(second + ts.size, 1u << 16) + (1u << 16);
id<MTLHeap> heap = [gDevice newHeapWithDescriptor:hd];
id<MTLTexture> first = [heap newTextureWithDescriptor:td offset:0];
id<MTLTexture> other = nil;
id<MTLBuffer> under = nil;
if (inPlace) {
under = [heap newBufferWithLength:ts.size options:bo offset:second];
other = [under newTextureWithDescriptor:td offset:0 bytesPerRow:ROW];
} else {
other = [heap newTextureWithDescriptor:td offset:second];
}
if (!heap || !first || !other) {
printf("READ resource nil heap %d first %d other %d\n", heap != nil, first != nil,
other != nil);
return 2;
}
id<MTLTexture> source = inPlace == 2 ? other : first;
id<MTLTexture> destination = inPlace == 2 ? first : other;
id<MTLBuffer> src = [gDevice newBufferWithLength:TEXELS * 4 options:MTLResourceStorageModeShared];
id<MTLBuffer> out = [gDevice newBufferWithLength:TEXELS * 4 options:MTLResourceStorageModeShared];
MTLSize whole = MTLSizeMake(SIDE, SIDE, 1);
MTLOrigin zero = MTLOriginMake(0, 0, 0);
int half = SIDE / 2, wholeRounds = 0;
for (uint32_t round = 0; round < ROUNDS; round++) {
uint32_t *words = (uint32_t *)src.contents;
for (uint32_t i = 0; i < TEXELS; i++) words[i] = 0x80000000u | (round << 16) | i;
memset(out.contents, 0xEE, TEXELS * 4);
id<MTLCommandBuffer> cb = [gQueue commandBuffer];
id<MTLBlitCommandEncoder> blit = [cb blitCommandEncoder];
[blit copyFromBuffer:src sourceOffset:0 sourceBytesPerRow:ROW
sourceBytesPerImage:ROW * SIDE sourceSize:whole toTexture:source
destinationSlice:0 destinationLevel:0 destinationOrigin:zero];
[blit endEncoding];
run(cb, "write");
cb = [gQueue commandBuffer];
blit = [cb blitCommandEncoder];
if (method == WHOLE) {
[blit copyFromTexture:source toTexture:destination];
} else {
BOOL part = method == REGION_PART;
[blit copyFromTexture:source sourceSlice:0 sourceLevel:0 sourceOrigin:zero
sourceSize:(part ? MTLSizeMake(half, half, 1) : whole)
toTexture:destination destinationSlice:0 destinationLevel:0
destinationOrigin:(part ? MTLOriginMake(half, half, 0) : zero)];
}
[blit endEncoding];
run(cb, "copy");
cb = [gQueue commandBuffer];
blit = [cb blitCommandEncoder];
[blit copyFromTexture:destination sourceSlice:0 sourceLevel:0 sourceOrigin:zero
sourceSize:whole toBuffer:out destinationOffset:0
destinationBytesPerRow:ROW destinationBytesPerImage:ROW * SIDE];
[blit endEncoding];
run(cb, "read");
const uint32_t *got = (const uint32_t *)out.contents;
int source_words = 0, other_words = 0, region = 0, firstOther = -1;
for (int y = 0; y < SIDE; y++) {
for (int x = 0; x < SIDE; x++) {
int i = y * SIDE + x, from = i;
if (method == REGION_PART) {
if (x < half || y < half) continue;
from = (y - half) * SIDE + (x - half);
}
region++;
if (got[i] == words[from]) {
source_words++;
} else {
other_words++;
if (firstOther < 0) firstOther = i;
}
}
}
printf("READ %s round %u region %d source %d other %d", name, round, region, source_words,
other_words);
if (firstOther >= 0) printf(" first_other %d word 0x%08x", firstOther, got[firstOther]);
printf(" fnv %016llx\n", (unsigned long long)fnv(out.contents, TEXELS * 4));
fflush(stdout);
if (other_words == 0) wholeRounds++;
}
printf("SUMMARY %s whole %d of %d\n", name, wholeRounds, ROUNDS);
return 0;
}
// ---- buffer to buffer in a Private placement heap ------------------------------------------
/// A copy of 64 KiB between two buffers at offset 0 of a placement heap (one buffer where `one`),
/// the destination `shift` bytes past the source (before it where negative). A third buffer over
/// the same bytes writes them first and reads them after; each round prints how many of the bytes
/// the copy's two ranges cover hold memmove's answer ("source") and how many do not ("other").
static int buf_case(long shift, BOOL one, const char *name) {
enum { SIZE = 64 << 10, MORE = 4 << 10, SPAN = SIZE + MORE };
MTLResourceOptions bo = MTLResourceStorageModePrivate | MTLResourceHazardTrackingModeTracked;
MTLSizeAndAlign bs = [gDevice heapBufferSizeAndAlignWithLength:SPAN options:bo];
printf("READ buffer_size %lu buffer_align %lu\n", (unsigned long)bs.size,
(unsigned long)bs.align);
MTLHeapDescriptor *hd = [MTLHeapDescriptor new];
hd.type = MTLHeapTypePlacement;
hd.storageMode = MTLStorageModePrivate;
hd.hazardTrackingMode = MTLHazardTrackingModeTracked;
hd.size = round_up(bs.size, 1u << 16) + (1u << 16);
id<MTLHeap> heap = [gDevice newHeapWithDescriptor:hd];
id<MTLBuffer> whole = [heap newBufferWithLength:SPAN options:bo offset:0];
id<MTLBuffer> first = [heap newBufferWithLength:SPAN options:bo offset:0];
id<MTLBuffer> second = one ? first : [heap newBufferWithLength:SPAN options:bo offset:0];
if (!heap || !whole || !first || !second) {
printf("READ resource nil\n");
return 2;
}
id<MTLBuffer> src = [gDevice newBufferWithLength:SPAN options:MTLResourceStorageModeShared];
id<MTLBuffer> out = [gDevice newBufferWithLength:SPAN options:MTLResourceStorageModeShared];
NSUInteger from = shift < 0 ? (NSUInteger)-shift : 0, to = shift < 0 ? 0 : (NSUInteger)shift;
uint8_t *want = malloc(SPAN);
int wholeRounds = 0;
for (uint32_t round = 0; round < ROUNDS; round++) {
uint8_t *bytes = (uint8_t *)src.contents;
for (uint32_t i = 0; i < SPAN; i++) bytes[i] = (uint8_t)(i * 131u + i / 251u + round * 17u);
memcpy(want, bytes, SPAN);
memmove(want + to, want + from, SIZE);
memset(out.contents, 0xEE, SPAN);
id<MTLCommandBuffer> cb = [gQueue commandBuffer];
id<MTLBlitCommandEncoder> blit = [cb blitCommandEncoder];
[blit copyFromBuffer:src sourceOffset:0 toBuffer:whole destinationOffset:0 size:SPAN];
[blit endEncoding];
run(cb, "write");
cb = [gQueue commandBuffer];
blit = [cb blitCommandEncoder];
[blit copyFromBuffer:first sourceOffset:from toBuffer:second destinationOffset:to size:SIZE];
[blit endEncoding];
run(cb, "copy");
cb = [gQueue commandBuffer];
blit = [cb blitCommandEncoder];
[blit copyFromBuffer:whole sourceOffset:0 toBuffer:out destinationOffset:0 size:SPAN];
[blit endEncoding];
run(cb, "read");
const uint8_t *got = (const uint8_t *)out.contents;
int source = 0, other = 0;
long firstOther = -1;
for (long i = 0; i < SPAN; i++) {
if (got[i] == want[i]) {
source++;
} else {
other++;
if (firstOther < 0) firstOther = i;
}
}
printf("READ %s round %u source %d other %d", name, round, source, other);
if (firstOther >= 0)
printf(" first_other %ld byte 0x%02x want 0x%02x", firstOther, got[firstOther],
want[firstOther]);
printf(" fnv %016llx\n", (unsigned long long)fnv(out.contents, SPAN));
fflush(stdout);
if (other == 0) wholeRounds++;
}
free(want);
printf("SUMMARY %s whole %d of %d\n", name, wholeRounds, ROUNDS);
return 0;
}
// ---- surface cases -------------------------------------------------------------------------
/// A copy of `w` by `h` texels from `(sx, sy)` to `(dx, dy)` on the plane's grid of words, done
/// in place one word at a time, front to back (`forward`) or back to front.
static void in_place(uint32_t *grid, int pitchWords, int sx, int sy, int dx, int dy, int w, int h,
BOOL forward) {
for (int k = 0; k < w * h; k++) {
int i = forward ? k : w * h - 1 - k;
int x = i % w, y = i / w;
grid[(dy + y) * pitchWords + dx + x] = grid[(sy + y) * pitchWords + sx + x];
}
}
static int surface_case(const char *shape, const char *name) {
NSDictionary *props = @{
(__bridge NSString *)kIOSurfaceWidth : @(SURFACE_WIDTH),
(__bridge NSString *)kIOSurfaceHeight : @(SURFACE_HEIGHT),
(__bridge NSString *)kIOSurfaceBytesPerElement : @4,
(__bridge NSString *)kIOSurfaceBytesPerRow : @(SURFACE_PITCH),
(__bridge NSString *)kIOSurfacePixelFormat : @((uint32_t)'BGRA'),
};
IOSurfaceRef surface = IOSurfaceCreate((__bridge CFDictionaryRef)props);
if (!surface) {
printf("READ surface nil\n");
return 2;
}
uint8_t *base = (uint8_t *)IOSurfaceGetBaseAddress(surface);
size_t alloc = IOSurfaceGetAllocSize(surface), pitch = IOSurfaceGetBytesPerRow(surface);
size_t page = (size_t)getpagesize();
printf("READ surface alloc %zu pitch %zu base_page_offset %zu page %zu\n", alloc, pitch,
(size_t)((uintptr_t)base % page), page);
if ((uintptr_t)base % page != 0 || pitch % 4 != 0) {
printf("READ skipped: the surface's bytes take no no-copy buffer\n");
return 2;
}
id<MTLBuffer> buffer = [gDevice
newBufferWithBytesNoCopy:base
length:round_up(alloc, page)
options:MTLResourceStorageModeShared | MTLResourceHazardTrackingModeTracked
deallocator:nil];
MTLTextureDescriptor *td =
[MTLTextureDescriptor texture2DDescriptorWithPixelFormat:MTLPixelFormatBGRA8Unorm
width:SURFACE_WIDTH
height:SURFACE_HEIGHT
mipmapped:NO];
td.usage = MTLTextureUsageShaderRead | MTLTextureUsageShaderWrite;
td.storageMode = MTLStorageModeShared;
td.hazardTrackingMode = MTLHazardTrackingModeTracked;
id<MTLTexture> texture = [gDevice newTextureWithDescriptor:td iosurface:surface plane:0];
if (!buffer || !texture) {
printf("READ resource nil buffer %d texture %d\n", buffer != nil, texture != nil);
return 2;
}
BOOL into = strncmp(shape, "in-", 3) == 0;
const char *move = shape + (into ? 3 : 4);
int sx = 0, sy = 0, dx = 0, dy = 0, w = SURFACE_WIDTH, h = SURFACE_HEIGHT;
if (strcmp(move, "up") == 0) {
sy = 1;
h -= 1;
} else if (strcmp(move, "down") == 0) {
dy = 1;
h -= 1;
} else {
dx = SHIFT;
w -= SHIFT;
}
int pitchWords = (int)(pitch / 4);
size_t bytes = pitch * SURFACE_HEIGHT;
uint32_t *before = malloc(bytes), *expect = malloc(bytes), *forward = malloc(bytes),
*backward = malloc(bytes);
int wholeRounds = 0;
for (uint32_t round = 0; round < ROUNDS; round++) {
IOSurfaceLock(surface, 0, NULL);
uint32_t *grid = (uint32_t *)base;
for (int y = 0; y < SURFACE_HEIGHT; y++)
for (int x = 0; x < pitchWords; x++)
grid[y * pitchWords + x] = 0xC0000000u | (round << 16) | ((uint32_t)y << 8) |
(uint32_t)x;
memcpy(before, grid, bytes);
IOSurfaceUnlock(surface, 0, NULL);
memcpy(expect, before, bytes);
for (int y = 0; y < h; y++)
for (int x = 0; x < w; x++)
expect[(dy + y) * pitchWords + dx + x] = before[(sy + y) * pitchWords + sx + x];
memcpy(forward, before, bytes);
in_place(forward, pitchWords, sx, sy, dx, dy, w, h, YES);
memcpy(backward, before, bytes);
in_place(backward, pitchWords, sx, sy, dx, dy, w, h, NO);
id<MTLCommandBuffer> cb = [gQueue commandBuffer];
id<MTLBlitCommandEncoder> blit = [cb blitCommandEncoder];
if (into) {
[blit copyFromBuffer:buffer sourceOffset:(NSUInteger)(sy * pitch + sx * 4)
sourceBytesPerRow:pitch sourceBytesPerImage:pitch * h
sourceSize:MTLSizeMake(w, h, 1) toTexture:texture destinationSlice:0
destinationLevel:0 destinationOrigin:MTLOriginMake(dx, dy, 0)];
} else {
[blit copyFromTexture:texture sourceSlice:0 sourceLevel:0
sourceOrigin:MTLOriginMake(sx, sy, 0) sourceSize:MTLSizeMake(w, h, 1)
toBuffer:buffer destinationOffset:(NSUInteger)(dy * pitch + dx * 4)
destinationBytesPerRow:pitch destinationBytesPerImage:pitch * h];
}
[blit endEncoding];
run(cb, "copy");
IOSurfaceLock(surface, kIOSurfaceLockReadOnly, NULL);
const uint32_t *got = (const uint32_t *)base;
int source = 0, fwd = 0, bwd = 0, other = 0, outside = 0, first = -1;
for (int y = 0; y < SURFACE_HEIGHT; y++) {
for (int x = 0; x < pitchWords; x++) {
int i = y * pitchWords + x;
BOOL inRegion = y >= dy && y < dy + h && x >= dx && x < dx + w;
if (!inRegion) {
outside += got[i] != before[i];
continue;
}
BOOL any = NO;
if (got[i] == expect[i]) source++, any = YES;
if (got[i] == forward[i]) fwd++, any = YES;
if (got[i] == backward[i]) bwd++, any = YES;
if (!any) {
other++;
if (first < 0) first = i;
}
}
}
printf("READ %s round %u region %d source %d forward %d backward %d other %d outside %d",
name, round, w * h, source, fwd, bwd, other, outside);
if (first >= 0) printf(" first_other %d word 0x%08x", first, got[first]);
printf("\n");
fflush(stdout);
if (source == w * h && outside == 0) wholeRounds++;
IOSurfaceUnlock(surface, kIOSurfaceLockReadOnly, NULL);
}
printf("SUMMARY %s whole %d of %d\n", name, wholeRounds, ROUNDS);
free(before);
free(expect);
free(forward);
free(backward);
CFRelease(surface);
return 0;
}
int main(int argc, char **argv) {
@autoreleasepool {
if (argc != 2) {
fprintf(stderr, "usage: %s <case> | --list\n", argv[0]);
return 64;
}
if (strcmp(argv[1], "--list") == 0) {
for (size_t i = 0; i < sizeof kCases / sizeof kCases[0]; i++) printf("%s\n", kCases[i]);
return 0;
}
const char *name = argv[1];
BOOL known = NO;
for (size_t i = 0; i < sizeof kCases / sizeof kCases[0]; i++)
known |= strcmp(kCases[i], name) == 0;
if (!known) {
fprintf(stderr, "unknown case %s\n", name);
return 64;
}
gDevice = MTLCreateSystemDefaultDevice();
gQueue = [gDevice newCommandQueue];
printf("DEVICE %s\n", gDevice.name.UTF8String);
printf("RELEASE macOS %s\n",
[NSProcessInfo processInfo].operatingSystemVersionString.UTF8String);
printf("CASE %s\n", name);
fflush(stdout);
int rc;
if (strncmp(name, "heap-", 5) == 0) {
MTLStorageMode mode = strncmp(name + 5, "private", 7) == 0 ? MTLStorageModePrivate
: MTLStorageModeShared;
const char *shape = name + 5 + (mode == MTLStorageModePrivate ? 8 : 7);
char base[8] = {0};
strncpy(base, shape, 3);
rc = heap_case(mode, base, strstr(shape, "-apart") != NULL, name);
} else if (strncmp(name, "buf-", 4) == 0) {
BOOL one = strncmp(name, "buf-one-", 8) == 0;
const char *way = name + (one ? 8 : 10);
BOOL up = strncmp(way, "up-", 3) == 0;
long n = atol(way + (up ? 3 : 5));
rc = buf_case(up ? n : -n, one, name);
} else if (strncmp(name, "tex-", 4) == 0) {
const char *t = name + 4;
if (strcmp(t, "shift") == 0) rc = tex_case(1, WHOLE, 0, name);
else if (strcmp(t, "half") == 0) rc = tex_case(2, WHOLE, 0, name);
else if (strcmp(t, "region") == 0) rc = tex_case(0, REGION_WHOLE, 0, name);
else if (strcmp(t, "region-half") == 0) rc = tex_case(2, REGION_WHOLE, 0, name);
else if (strcmp(t, "region-part") == 0) rc = tex_case(0, REGION_PART, 0, name);
else if (strcmp(t, "inplace-to") == 0) rc = tex_case(0, WHOLE, 1, name);
else rc = tex_case(0, WHOLE, 2, name);
} else {
rc = surface_case(name + 8, name);
}
printf("DONE %s\n", name);
fflush(stdout);
return rc;
}
}
@@ -114,7 +114,11 @@ static float *draw(NSString *fragment, MTLPixelFormat format, int targets, int s
height:side
mipmapped:NO];
td.usage = MTLTextureUsageRenderTarget | MTLTextureUsageShaderRead;
td.storageMode = samples > 1 ? MTLStorageModePrivate : MTLStorageModeShared;
// A discrete GPU's Mac takes no Shared texture: there a single-sample attachment is Managed,
// and a blit synchronizes it before the CPU reads it.
td.storageMode = samples > 1 ? MTLStorageModePrivate
: gDevice.hasUnifiedMemory ? MTLStorageModeShared
: MTLStorageModeManaged;
td.textureType = samples > 1 ? MTLTextureType2DMultisample : MTLTextureType2D;
td.sampleCount = samples;
id<MTLTexture> textures[8];
@@ -158,6 +162,11 @@ static float *draw(NSString *fragment, MTLPixelFormat format, int targets, int s
[ce endEncoding];
}
}
if (samples == 1 && !gDevice.hasUnifiedMemory) {
id<MTLBlitCommandEncoder> b = [cb blitCommandEncoder];
for (int i = 0; i < targets; i++) [b synchronizeResource:textures[i]];
[b endEncoding];
}
[cb commit];
[cb waitUntilCompleted];
if (cb.error) {
@@ -0,0 +1,158 @@
// Whether Metal's MultisampleResolve writes the resolve texture past the pass's render area
// (`renderTargetWidth` and `renderTargetHeight`), where the runtime's Vulkan render area is the
// Metal one rounded up to 32 texels a side.
//
// ONE CASE PER PROCESS, chosen on the command line, run once under MTL_DEBUG_LAYER=1 and once
// without it. The attachment is a 600x600 4-sample BGRA8Unorm colour texture (RenderTarget,
// Private); the resolve texture a 600x600 1-sample BGRA8Unorm 2D texture (RenderTarget |
// ShaderRead, Private), whose bytes a blit from a Shared buffer first sets to 0xee. A first pass
// over the whole 600x600 clears the attachment to (0.25, 0.5, 0.75, 1.0) and stores it. The
// case's pass draws nothing and resolves the attachment into the resolve texture
// (MultisampleResolve):
//
// load loads the attachment, render area 300x300
// clear clears the attachment to (1.0, 0.0, 0.0, 1.0), render area 300x300
// full loads the attachment, no render area set (the control: all 600x600 resolve)
//
// Read back by a blit into a Shared buffer (BGRA bytes, rows tight), the case prints the command
// buffers' status and error, and for three regions how many texels changed from 0xee: the area
// (x and y below 300), the band (x and y below 320, not in the area) and the rest (x or y at 320
// or past). It prints the texels at (0, 0), (310, 0), (0, 310), (310, 310), (330, 0) and
// (599, 599).
//
// xcrun clang -fobjc-arc -framework Metal -framework Foundation \
// -o resolve_band_past_render_area resolve_band_past_render_area.m
// for c in load clear full; do
// MTL_DEBUG_LAYER=1 ./resolve_band_past_render_area $c
// env -u MTL_DEBUG_LAYER ./resolve_band_past_render_area $c
// done
//
// WHAT IT MEASURED (Apple M3 Max, macOS 27.0.1, job m3-max-83924; the same with and without the
// layer, every command buffer completed without an error):
//
// load area 90000 of 90000, band 12400 of 12400, rest 0 of 257600 changed: the loaded
// clear (BGRA bf 80 40 ff) to 320 a side, 0xee past it
// clear every texel of all three regions changed, to the clear (BGRA 00 00 ff ff)
// full every texel of all three regions changed, to the loaded clear
#import <Foundation/Foundation.h>
#import <Metal/Metal.h>
#include <string.h>
static const NSUInteger SIDE = 600;
static const NSUInteger AREA = 300;
static const NSUInteger BAND = 320;
static id<MTLTexture> texture(id<MTLDevice> device, NSUInteger samples, MTLTextureUsage usage) {
MTLTextureDescriptor *d = [MTLTextureDescriptor new];
d.textureType = samples > 1 ? MTLTextureType2DMultisample : MTLTextureType2D;
d.pixelFormat = MTLPixelFormatBGRA8Unorm;
d.width = SIDE;
d.height = SIDE;
d.sampleCount = samples;
d.usage = usage;
d.storageMode = MTLStorageModePrivate;
return [device newTextureWithDescriptor:d];
}
static void finish(const char *name, const char *what, id<MTLCommandBuffer> cb) {
[cb commit];
[cb waitUntilCompleted];
printf("%s: %s: status %ld, error %s\n", name, what, (long)cb.status,
cb.error ? cb.error.description.UTF8String : "none");
}
int main(int argc, const char **argv) {
@autoreleasepool {
if (argc != 2) {
printf("usage: resolve_band_past_render_area CASE\n");
return 2;
}
const char *name = argv[1];
BOOL load = strcmp(name, "load") == 0 || strcmp(name, "full") == 0;
BOOL area = strcmp(name, "full") != 0;
if (!load && strcmp(name, "clear") != 0) {
printf("no case %s\n", name);
return 2;
}
id<MTLDevice> device = MTLCreateSystemDefaultDevice();
printf("%s: device %s\n", name, device.name.UTF8String);
id<MTLTexture> msaa = texture(device, 4, MTLTextureUsageRenderTarget);
id<MTLTexture> resolve =
texture(device, 1, MTLTextureUsageRenderTarget | MTLTextureUsageShaderRead);
const NSUInteger row = SIDE * 4;
id<MTLBuffer> bytes = [device newBufferWithLength:row * SIDE
options:MTLResourceStorageModeShared];
memset(bytes.contents, 0xee, bytes.length);
id<MTLCommandQueue> queue = [device newCommandQueue];
id<MTLCommandBuffer> cb = [queue commandBuffer];
id<MTLBlitCommandEncoder> fill = [cb blitCommandEncoder];
[fill copyFromBuffer:bytes
sourceOffset:0
sourceBytesPerRow:row
sourceBytesPerImage:row * SIDE
sourceSize:MTLSizeMake(SIDE, SIDE, 1)
toTexture:resolve
destinationSlice:0
destinationLevel:0
destinationOrigin:MTLOriginMake(0, 0, 0)];
[fill endEncoding];
MTLRenderPassDescriptor *first = [MTLRenderPassDescriptor renderPassDescriptor];
first.colorAttachments[0].texture = msaa;
first.colorAttachments[0].loadAction = MTLLoadActionClear;
first.colorAttachments[0].storeAction = MTLStoreActionStore;
first.colorAttachments[0].clearColor = MTLClearColorMake(0.25, 0.5, 0.75, 1.0);
[[cb renderCommandEncoderWithDescriptor:first] endEncoding];
finish(name, "fill and first pass", cb);
cb = [queue commandBuffer];
MTLRenderPassDescriptor *pass = [MTLRenderPassDescriptor renderPassDescriptor];
pass.colorAttachments[0].texture = msaa;
pass.colorAttachments[0].resolveTexture = resolve;
pass.colorAttachments[0].loadAction = load ? MTLLoadActionLoad : MTLLoadActionClear;
pass.colorAttachments[0].clearColor = MTLClearColorMake(1.0, 0.0, 0.0, 1.0);
pass.colorAttachments[0].storeAction = MTLStoreActionMultisampleResolve;
if (area) {
pass.renderTargetWidth = AREA;
pass.renderTargetHeight = AREA;
}
id<MTLRenderCommandEncoder> encoder = [cb renderCommandEncoderWithDescriptor:pass];
printf("%s: encoder %s\n", name, encoder ? "made" : "not made");
[encoder endEncoding];
id<MTLBlitCommandEncoder> read = [cb blitCommandEncoder];
[read copyFromTexture:resolve
sourceSlice:0
sourceLevel:0
sourceOrigin:MTLOriginMake(0, 0, 0)
sourceSize:MTLSizeMake(SIDE, SIDE, 1)
toBuffer:bytes
destinationOffset:0
destinationBytesPerRow:row
destinationBytesPerImage:row * SIDE];
[read endEncoding];
finish(name, "case pass and read back", cb);
const uint8_t *texels = bytes.contents;
NSUInteger changed[3] = {0, 0, 0};
for (NSUInteger y = 0; y < SIDE; y++) {
for (NSUInteger x = 0; x < SIDE; x++) {
const uint8_t *t = texels + y * row + x * 4;
BOOL kept = t[0] == 0xee && t[1] == 0xee && t[2] == 0xee && t[3] == 0xee;
NSUInteger region = (x < AREA && y < AREA) ? 0 : (x < BAND && y < BAND) ? 1 : 2;
changed[region] += kept ? 0 : 1;
}
}
printf("%s: changed texels: area %lu of %lu, band %lu of %lu, rest %lu of %lu\n", name,
(unsigned long)changed[0], (unsigned long)(AREA * AREA),
(unsigned long)changed[1], (unsigned long)(BAND * BAND - AREA * AREA),
(unsigned long)changed[2], (unsigned long)(SIDE * SIDE - BAND * BAND));
const NSUInteger at[6][2] = {{0, 0}, {310, 0}, {0, 310}, {310, 310}, {330, 0}, {599, 599}};
for (int i = 0; i < 6; i++) {
const uint8_t *t = texels + at[i][1] * row + at[i][0] * 4;
printf("%s: texel (%lu, %lu) BGRA %02x %02x %02x %02x\n", name, (unsigned long)at[i][0],
(unsigned long)at[i][1], t[0], t[1], t[2], t[3]);
}
}
return 0;
}
@@ -0,0 +1,448 @@
// texture_write_rounding_storage.m with texture buffers for targets: what a fragment function's
// write to a texture buffer (`texture_buffer<T, access::write>`, a texture a buffer makes with
// `MTLTextureTypeTextureBuffer`) stores under Apple's `textureWriteRoundingMode` 2 against the
// default, for a `float` and a `half` texel into `RGBA16Float`, `RG11B10Float` and `RGB9E5Float`;
// a format whose texture buffer Metal refuses is printed and passed over. Each case draws one
// fullscreen triangle over a 256 x 256 target; the fragment function writes buffer 0's texel for
// its pixel into texture buffer 0 at texel `y * 256 + x`, once in a pipeline of mode 0 and once of
// mode 2, and the two texture buffers' codes are compared channel by channel with each other and with
// candidate rules computed here: toward zero (Metal's default), nearest even with an overflow to
// the infinity or held at the largest finite value and, for `RGB9E5Float`, the shared exponent of
// the largest clamped channel with each mantissa rounded (toward zero, to nearest even, half up),
// a mantissa of 512 either moving the exponent up or held at 511.
//
// The texels: each value of a list (zeros, infinities, NaN, negatives, the formats' largest finite
// values and the values past them, every tie of a 10-, 9-, 8-, 6- and 5-bit mantissa at a spread of
// exponents and one `f32` step either side, and random values) in all four channels, then random
// texels whose green and blue are the red scaled by a random factor in (0, 1], drawn from
// SplitMix64 seeded 7. A `half` texel is the `float` texel rounded to `half` on the host. `HASH`
// lines give the FNV-1a hashes of the inputs and of each texture buffer's bytes at each mode, which
// `metal2vulkan`'s tests `half_and_small_float_words_are_metals_at_either_mode` and
// `rgb9e5_words_are_metals_at_either_mode` hold a texture buffer's words to.
//
// xcrun clang -fobjc-arc -framework Metal -framework Foundation -o texture_buffer_write_rounding \
// texture_buffer_write_rounding.m
// /usr/bin/env -u MTL_DEBUG_LAYER ./texture_buffer_write_rounding
#import <Foundation/Foundation.h>
#import <Metal/Metal.h>
#import <objc/message.h>
#include <math.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
enum { W = 256, H = 256, N = W * H };
static const char *SRC =
"#include <metal_stdlib>\n"
"using namespace metal;\n"
"struct V { float4 p [[position]]; };\n"
"vertex V vs(uint id [[vertex_id]]) {\n"
" float2 xy = float2((id << 1) & 2, id & 2);\n"
" V v; v.p = float4(xy * 2.0 - 1.0, 0.0, 1.0); return v;\n"
"}\n"
"fragment float4 fs_float(V in [[stage_in]], texture_buffer<float, access::write> t [[texture(0)]],\n"
" device const float4 *src [[buffer(0)]]) {\n"
" uint2 c = uint2(in.p.xy);\n"
" t.write(src[c.y * 256 + c.x], c.y * 256 + c.x);\n"
" return float4(0.0);\n"
"}\n"
"fragment float4 fs_half(V in [[stage_in]], texture_buffer<half, access::write> t [[texture(0)]],\n"
" device const half4 *src [[buffer(0)]]) {\n"
" uint2 c = uint2(in.p.xy);\n"
" t.write(src[c.y * 256 + c.x], c.y * 256 + c.x);\n"
" return float4(0.0);\n"
"}\n";
enum Round { RTZ, RNE, RHU };
enum Over { INF, SAT };
// `v` as a float of `mb` mantissa and `eb` exponent bits (signed where `sign`), rounded by `r`, a
// value past the largest finite one to the infinity or held at the largest (`o`; toward zero
// always held). A NaN is the quiet NaN of the top mantissa bit; an unsigned format's negative 0.
static uint32_t enc(double v, int mb, int eb, int sign, enum Round r, enum Over o) {
uint32_t expall = (1u << eb) - 1, bias = (1u << (eb - 1)) - 1, s = 0;
if (isnan(v)) return (expall << mb) | (1u << (mb - 1));
if (v < 0 || (v == 0 && signbit(v))) {
if (!sign) return 0;
s = 1u << (mb + eb);
v = -v;
}
uint32_t maxfin = ((expall - 1) << mb) | ((1u << mb) - 1);
if (isinf(v)) return s | (expall << mb);
if (v == 0) return s;
int x;
frexp(v, &x);
int e = x - 1;
int denorm = e < 1 - (int)bias;
double q = denorm ? ldexp(v, (int)bias - 1 + mb) : ldexp(v, mb - e);
double qi = r == RTZ ? floor(q) : r == RNE ? nearbyint(q) : floor(q + 0.5);
uint32_t code;
if (denorm) {
code = (uint32_t)qi;
} else {
if (qi >= ldexp(1, mb + 1)) {
e += 1;
qi = ldexp(1, mb);
}
if (e + (int)bias >= (int)expall) return s | ((r == RTZ || o == SAT) ? maxfin : (expall << mb));
code = ((uint32_t)(e + (int)bias) << mb) | ((uint32_t)qi - (1u << mb));
}
return s | code;
}
static double dec(uint32_t c, int mb, int eb, int sign) {
uint32_t expall = (1u << eb) - 1, bias = (1u << (eb - 1)) - 1;
double sg = (sign && (c >> (mb + eb)) & 1) ? -1 : 1;
uint32_t e = (c >> mb) & expall, m = c & ((1u << mb) - 1);
if (e == expall) return m ? NAN : sg * INFINITY;
if (e == 0) return sg * ldexp(m, 1 - (int)bias - mb);
return sg * ldexp(m + (1u << mb), (int)e - (int)bias - mb);
}
static double clamp9(double v) { return isnan(v) || v < 0 ? 0 : v > 65408 ? 65408 : v; }
// RGB9E5: the shared exponent of the largest clamped channel, each mantissa rounded by `r`; a
// largest mantissa of 512 moves the exponent up where `bump`, else is held at 511.
static uint32_t rgb9e5(const double *c, enum Round r, int bump) {
double v[3], mx = 0;
for (int i = 0; i < 3; i++) {
v[i] = clamp9(c[i]);
if (v[i] > mx) mx = v[i];
}
if (mx == 0) return 0;
int x;
frexp(mx, &x);
int e = (x - 1 < -16 ? -16 : x - 1) + 16;
for (int pass = 0; pass < 2; pass++) {
uint32_t m[3], over = 0;
for (int i = 0; i < 3; i++) {
double q = ldexp(v[i], 24 - e);
double qi = r == RTZ ? floor(q) : r == RNE ? nearbyint(q) : floor(q + 0.5);
if (qi > 511) {
over = 1;
qi = 511;
}
m[i] = (uint32_t)qi;
}
if (over && bump && pass == 0 && e < 31) {
e += 1;
continue;
}
return ((uint32_t)e << 27) | (m[2] << 18) | (m[1] << 9) | m[0];
}
return 0;
}
static void dec9(uint32_t w, double *o) {
int e = (int)(w >> 27);
for (int i = 0; i < 3; i++) o[i] = ldexp((w >> (9 * i)) & 511, e - 24);
}
typedef struct {
const char *name;
MTLPixelFormat pf;
int bytes, kind; // kind 0: RGBA16Float, 1: RG11B10Float, 2: RGB9E5Float
} Fmt;
// The inputs' generator (SplitMix64 from 7), which `metal2vulkan`'s test of the words
// (`lower/arith/tests/color_write.rs`, `probe_texels`) takes again.
static uint64_t sm = 7;
static uint64_t next64(void) {
uint64_t z = (sm += 0x9E3779B97F4A7C15ull);
z = (z ^ (z >> 30)) * 0xBF58476D1CE4E5B9ull;
z = (z ^ (z >> 27)) * 0x94D049BB133111EBull;
return z ^ (z >> 31);
}
static uint32_t r32(void) { return (uint32_t)(next64() >> 32); }
// FNV-1a over `n` bytes, from `h`.
static uint64_t fnv(uint64_t h, const void *p, size_t n) {
const uint8_t *b = p;
for (size_t i = 0; i < n; i++) h = (h ^ b[i]) * 0x100000001b3ull;
return h;
}
static const uint64_t FNV0 = 0xcbf29ce484222325ull;
static float vals[40000];
static int nv;
static void add(double v) {
if (nv < 40000) vals[nv++] = (float)v;
}
static void build_values(void) {
double sp[] = {0, -0.0, -1, -65504, INFINITY, -INFINITY, NAN, 65504, 65505, 65519, 65519.99,
65520, 65521, 65536, 1e5, 1e9, 65024, 65040, 65055.99, 65056, 65057, 64512,
64528, 64543.99, 64544, 64545, 65408, 65407, 65409, 65416, 65424, 65471, 65472,
65473, 1e-10, 1e-40, ldexp(1, -24), ldexp(1, -25), ldexp(3, -26), ldexp(1, -20),
ldexp(1, -21), ldexp(3, -22), ldexp(1, -24) * 1.5, ldexp(1, -14), ldexp(1, -15),
ldexp(1, -16), ldexp(1, -17), 0.5, 1, 1.5, 2, 3};
for (unsigned i = 0; i < sizeof sp / sizeof sp[0]; i++) add(sp[i]);
int widths[] = {10, 9, 8, 6, 5};
for (int wi = 0; wi < 5; wi++) {
int mb = widths[wi];
for (int e = -26; e <= 16; e++) {
int ks[8] = {0, 1, 2, 3, (1 << mb) - 2, (1 << mb) - 1, 0, 0};
ks[6] = (int)(r32() % (1u << mb));
ks[7] = (int)(r32() % (1u << mb));
for (int k = 0; k < 8; k++) {
float t = (float)ldexp(1.0 + (ks[k] + 0.5) / ldexp(1, mb), e);
add(t);
add(nextafterf(t, INFINITY));
add(nextafterf(t, -INFINITY));
}
}
}
while (nv < 12000) {
int e = (int)(r32() % 44) - 27;
uint32_t mant = r32() & 0x7fffff;
double v = ldexp(1.0 + (double)mant / 8388608.0, e);
int neg = r32() % 16 == 0;
add(neg ? -v : v);
}
}
static double urand(void) { return (double)((r32() & 0xffffff) + 1) / 16777216.0; }
int main(int argc, char **argv) {
(void)argc;
(void)argv;
@autoreleasepool {
build_values();
id<MTLDevice> dev = MTLCreateSystemDefaultDevice();
printf("device %s\n", dev.name.UTF8String);
SEL sup = NSSelectorFromString(@"supportsTextureWriteRoundingMode:");
if ([dev respondsToSelector:sup]) {
for (NSUInteger m = 0; m <= 2; m++)
printf("supportsTextureWriteRoundingMode:%lu %d\n", (unsigned long)m,
((BOOL(*)(id, SEL, NSUInteger))objc_msgSend)(dev, sup, m));
}
NSError *err = nil;
MTLCompileOptions *co = [MTLCompileOptions new];
co.mathMode = MTLMathModeSafe;
id<MTLLibrary> lib = [dev newLibraryWithSource:@(SRC) options:co error:&err];
if (!lib) {
printf("library: %s\n", err.description.UTF8String);
return 1;
}
// The texels, `float` and `half`.
float *ftex = calloc(N * 4, sizeof(float));
__fp16 *htex = calloc(N * 4, sizeof(__fp16));
for (int i = 0; i < N; i++) {
float *t = ftex + 4 * i;
if (i < nv) {
t[0] = t[1] = t[2] = t[3] = vals[i];
} else {
float r = vals[r32() % (uint32_t)nv];
t[0] = r;
t[1] = (float)(r * urand());
if (r32() % 4 == 0) {
t[2] = vals[r32() % (uint32_t)nv];
} else {
t[2] = (float)(r * urand());
}
t[3] = vals[r32() % (uint32_t)nv];
}
for (int c = 0; c < 4; c++) htex[4 * i + c] = (__fp16)t[c];
}
printf("HASH inputs %016llx halves %016llx values %d\n", (unsigned long long)fnv(FNV0, ftex, N * 16),
(unsigned long long)fnv(FNV0, htex, N * 8), nv);
id<MTLBuffer> fbuf = [dev newBufferWithBytes:ftex length:N * 16 options:MTLResourceStorageModeShared];
id<MTLBuffer> hbuf = [dev newBufferWithBytes:htex length:N * 8 options:MTLResourceStorageModeShared];
MTLTextureDescriptor *td = [MTLTextureDescriptor texture2DDescriptorWithPixelFormat:MTLPixelFormatRGBA8Unorm
width:W
height:H
mipmapped:NO];
td.usage = MTLTextureUsageRenderTarget;
td.storageMode = MTLStorageModePrivate;
id<MTLTexture> rt = [dev newTextureWithDescriptor:td];
id<MTLCommandQueue> q = [dev newCommandQueue];
Fmt fmts[] = {{"RGBA16Float", MTLPixelFormatRGBA16Float, 8, 0},
{"RG11B10Float", MTLPixelFormatRG11B10Float, 4, 1},
{"RGB9E5Float", MTLPixelFormatRGB9E5Float, 4, 2}};
SEL set = NSSelectorFromString(@"setTextureWriteRoundingMode:");
SEL get = NSSelectorFromString(@"textureWriteRoundingMode");
for (int fi = 0; fi < 3; fi++) {
for (int half = 0; half < 2; half++) {
Fmt f = fmts[fi];
if (half && f.kind == 0) continue; // a half into a half-float texture is exact
uint8_t *out[2] = {NULL, NULL};
for (int mode = 0; mode < 2; mode++) {
MTLRenderPipelineDescriptor *pd = [MTLRenderPipelineDescriptor new];
pd.vertexFunction = [lib newFunctionWithName:@"vs"];
pd.fragmentFunction = [lib newFunctionWithName:half ? @"fs_half" : @"fs_float"];
pd.colorAttachments[0].pixelFormat = MTLPixelFormatRGBA8Unorm;
if (![pd respondsToSelector:set]) {
printf("no setTextureWriteRoundingMode:\n");
return 2;
}
((void (*)(id, SEL, NSUInteger))objc_msgSend)(pd, set, mode ? 2 : 0);
NSUInteger took = ((NSUInteger(*)(id, SEL))objc_msgSend)(pd, get);
id<MTLRenderPipelineState> ps = [dev newRenderPipelineStateWithDescriptor:pd error:&err];
if (!ps) {
printf("%s %s mode %d: pipeline: %s\n", f.name, half ? "half" : "float", mode ? 2 : 0,
err.description.UTF8String);
return 1;
}
MTLTextureDescriptor *sd =
[MTLTextureDescriptor textureBufferDescriptorWithPixelFormat:f.pf
width:N
resourceOptions:MTLResourceStorageModeShared
usage:MTLTextureUsageShaderWrite |
MTLTextureUsageShaderRead];
id<MTLBuffer> sb = [dev newBufferWithLength:(NSUInteger)N * f.bytes options:MTLResourceStorageModeShared];
memset(sb.contents, 0xA5, (size_t)N * f.bytes);
id<MTLTexture> st = [sb newTextureWithDescriptor:sd offset:0 bytesPerRow:(NSUInteger)N * f.bytes];
if (!st) {
printf("%s %s mode %d: no texture buffer of this format\n", f.name, half ? "half" : "float", mode ? 2 : 0);
break;
}
uint8_t *fill = malloc(N * f.bytes);
MTLRenderPassDescriptor *rp = [MTLRenderPassDescriptor renderPassDescriptor];
rp.colorAttachments[0].texture = rt;
rp.colorAttachments[0].loadAction = MTLLoadActionDontCare;
rp.colorAttachments[0].storeAction = MTLStoreActionDontCare;
id<MTLCommandBuffer> cb = [q commandBuffer];
id<MTLRenderCommandEncoder> en = [cb renderCommandEncoderWithDescriptor:rp];
[en setRenderPipelineState:ps];
[en setFragmentTexture:st atIndex:0];
[en setFragmentBuffer:half ? hbuf : fbuf offset:0 atIndex:0];
[en drawPrimitives:MTLPrimitiveTypeTriangle vertexStart:0 vertexCount:3];
[en endEncoding];
[cb commit];
[cb waitUntilCompleted];
if (cb.status != MTLCommandBufferStatusCompleted) {
printf("%s: command buffer status %ld\n", f.name, (long)cb.status);
return 1;
}
out[mode] = fill;
memcpy(fill, sb.contents, (size_t)N * f.bytes);
printf("%s %s mode %d (descriptor reads %lu)\n", f.name, half ? "half" : "float", mode ? 2 : 0,
(unsigned long)took);
}
if (!out[0] || !out[1]) {
free(out[0]);
continue;
}
printf("HASH %s %s mode0 %016llx mode2 %016llx\n", f.name, half ? "half" : "float",
(unsigned long long)fnv(FNV0, out[0], (size_t)N * f.bytes),
(unsigned long long)fnv(FNV0, out[1], (size_t)N * f.bytes));
// Per channel: the input, mode 0's and mode 2's codes, and the candidates'.
int chans = f.kind == 0 ? 4 : 3;
long total = 0, same = 0, unwritten = 0, dist[5] = {0}, nanish = 0;
const char *cn[] = {"rtz", "rne-inf", "rne-sat", "rhu-hold", "rne-bump", "rhu-bump", "rne-hold", "rtz-bump"};
long m0[8] = {0}, m2[8] = {0};
int ncand = f.kind == 2 ? 6 : 3;
int shown = 0;
double maxd = 0;
for (int i = 0; i < N; i++) {
double in[4];
for (int c = 0; c < 4; c++) in[c] = half ? (double)htex[4 * i + c] : (double)ftex[4 * i + c];
uint32_t w0 = 0, w2 = 0;
memcpy(&w0, out[0] + i * f.bytes, 4);
memcpy(&w2, out[1] + i * f.bytes, 4);
if (f.kind == 2) {
if (w0 == 0xA5A5A5A5u || w2 == 0xA5A5A5A5u) {
unwritten++;
continue;
}
uint32_t cand[6] = {rgb9e5(in, RTZ, 0), rgb9e5(in, RNE, 0), rgb9e5(in, RHU, 0),
rgb9e5(in, RNE, 1), rgb9e5(in, RHU, 1), rgb9e5(in, RTZ, 1)};
const int order[6] = {0, 6, 3, 4, 5, 7};
for (int k = 0; k < 6; k++) {
m0[order[k]] += cand[k] == w0;
m2[order[k]] += cand[k] == w2;
}
total++;
same += w0 == w2;
if (w0 != w2) {
double d0[3], d2[3];
dec9(w0, d0);
dec9(w2, d2);
int e = (int)((w0 >> 27) > (w2 >> 27) ? (w0 >> 27) : (w2 >> 27));
double ulp = ldexp(1, e - 24), d = 0;
for (int c = 0; c < 3; c++) d = fmax(d, fabs(d2[c] - d0[c]) / ulp);
maxd = fmax(maxd, d);
dist[d <= 1 ? 1 : d <= 2 ? 2 : 3]++;
if (shown < 6) {
shown++;
printf(" in (%.9g %.9g %.9g) mode0 %08x mode2 %08x rtz %08x rne %08x rhu %08x rne-bump %08x\n",
in[0], in[1], in[2], w0, w2, cand[0], cand[1], cand[2], cand[3]);
}
}
continue;
}
for (int c = 0; c < chans; c++) {
uint32_t c0, c2;
int mb, eb, sg;
if (f.kind == 0) {
uint16_t a, b;
memcpy(&a, out[0] + i * 8 + 2 * c, 2);
memcpy(&b, out[1] + i * 8 + 2 * c, 2);
c0 = a;
c2 = b;
mb = 10, eb = 5, sg = 1;
if (a == 0xA5A5 || b == 0xA5A5) {
unwritten++;
continue;
}
} else {
if (w0 == 0xA5A5A5A5u || w2 == 0xA5A5A5A5u) {
unwritten++;
continue;
}
int sh = c == 0 ? 0 : c == 1 ? 11 : 22;
mb = c == 2 ? 5 : 6, eb = 5, sg = 0;
c0 = (w0 >> sh) & ((1u << (mb + eb)) - 1);
c2 = (w2 >> sh) & ((1u << (mb + eb)) - 1);
}
total++;
double v0 = dec(c0, mb, eb, sg), v2 = dec(c2, mb, eb, sg);
if (isnan(in[c]) || isnan(v0) || isnan(v2)) {
nanish++;
same += isnan(v0) == isnan(v2);
continue;
}
uint32_t cand[3] = {enc(in[c], mb, eb, sg, RTZ, SAT), enc(in[c], mb, eb, sg, RNE, INF),
enc(in[c], mb, eb, sg, RNE, SAT)};
for (int k = 0; k < 3; k++) {
m0[k] += cand[k] == c0;
m2[k] += cand[k] == c2;
}
same += c0 == c2;
if (c0 != c2) {
// Codes of one sign are ordered by magnitude.
long a0 = (long)(c0 & ((1u << (mb + eb)) - 1)), a2 = (long)(c2 & ((1u << (mb + eb)) - 1));
long d = labs(a2 - a0);
if (isinf(v0) != isinf(v2)) d = 4;
dist[d >= 4 ? 4 : d >= 3 ? 3 : d]++;
if (shown < 6) {
shown++;
printf(" in %.9g (%a) mode0 %04x (%.9g) mode2 %04x (%.9g) rtz %04x rne-inf %04x rne-sat %04x\n",
in[c], in[c], c0, v0, c2, v2, cand[0], cand[1], cand[2]);
}
}
}
}
printf("RESULT %s %s: %ld %s, %ld unwritten, %ld NaN-ish; mode 2 = mode 0 on %ld; differing by 1: %ld, 2: %ld, "
"more: %ld, inf/finite: %ld%s",
f.name, half ? "half" : "float", total, f.kind == 2 ? "texels" : "channels", unwritten, nanish, same,
dist[1], dist[2], dist[3], dist[4], f.kind == 2 ? "" : "\n");
if (f.kind == 2) printf(" (max %.3g units of the larger exponent's last place)\n", maxd);
for (int k = 0; k < 8; k++) {
if (f.kind != 2 && k >= ncand) break;
if (f.kind == 2 && !(k == 0 || k >= 3)) continue;
printf(" candidate %-9s mode 0 %ld, mode 2 %ld\n", cn[k], m0[k], m2[k]);
}
free(out[0]);
free(out[1]);
}
}
}
return 0;
}
@@ -0,0 +1,438 @@
// What a fragment function's texture write stores under Apple's `textureWriteRoundingMode` 2
// (`-[MTLRenderPipelineDescriptor setTextureWriteRoundingMode:]`, SPI) against the default, for
// the writes `metal2vulkan`'s `lower/texture/mod.rs` (`mode_rounded_write`) names: a `float` and a
// `half` texel into `RGBA16Float`, `RG11B10Float` and `RGB9E5Float` storage textures. Each case
// draws one fullscreen triangle over a 256 x 256 target; the fragment function writes buffer 0's
// texel for its pixel into texture 0 (`access::write`), once in a pipeline of mode 0 and once of
// mode 2, and the two textures' codes are compared channel by channel with each other and with
// candidate rules computed here: toward zero (Metal's default), nearest even with an overflow to
// the infinity or held at the largest finite value and, for `RGB9E5Float`, the shared exponent of
// the largest clamped channel with each mantissa rounded (toward zero, to nearest even, half up),
// a mantissa of 512 either moving the exponent up or held at 511.
//
// The texels: each value of a list (zeros, infinities, NaN, negatives, the formats' largest finite
// values and the values past them, every tie of a 10-, 9-, 8-, 6- and 5-bit mantissa at a spread of
// exponents and one `f32` step either side, and random values) in all four channels, then random
// texels whose green and blue are the red scaled by a random factor in (0, 1], drawn from
// SplitMix64 seeded 7. A `half` texel is the `float` texel rounded to `half` on the host. `HASH`
// lines give the FNV-1a hashes of the inputs and of each texture's bytes at each mode, which
// `metal2vulkan`'s test `rgb9e5_words_are_metals_at_either_mode` holds its words to.
//
// xcrun clang -fobjc-arc -framework Metal -framework Foundation -o texture_write_rounding_storage \
// texture_write_rounding_storage.m
// /usr/bin/env -u MTL_DEBUG_LAYER ./texture_write_rounding_storage
#import <Foundation/Foundation.h>
#import <Metal/Metal.h>
#import <objc/message.h>
#include <math.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
enum { W = 256, H = 256, N = W * H };
static const char *SRC =
"#include <metal_stdlib>\n"
"using namespace metal;\n"
"struct V { float4 p [[position]]; };\n"
"vertex V vs(uint id [[vertex_id]]) {\n"
" float2 xy = float2((id << 1) & 2, id & 2);\n"
" V v; v.p = float4(xy * 2.0 - 1.0, 0.0, 1.0); return v;\n"
"}\n"
"fragment float4 fs_float(V in [[stage_in]], texture2d<float, access::write> t [[texture(0)]],\n"
" device const float4 *src [[buffer(0)]]) {\n"
" uint2 c = uint2(in.p.xy);\n"
" t.write(src[c.y * 256 + c.x], c);\n"
" return float4(0.0);\n"
"}\n"
"fragment float4 fs_half(V in [[stage_in]], texture2d<half, access::write> t [[texture(0)]],\n"
" device const half4 *src [[buffer(0)]]) {\n"
" uint2 c = uint2(in.p.xy);\n"
" t.write(src[c.y * 256 + c.x], c);\n"
" return float4(0.0);\n"
"}\n";
enum Round { RTZ, RNE, RHU };
enum Over { INF, SAT };
// `v` as a float of `mb` mantissa and `eb` exponent bits (signed where `sign`), rounded by `r`, a
// value past the largest finite one to the infinity or held at the largest (`o`; toward zero
// always held). A NaN is the quiet NaN of the top mantissa bit; an unsigned format's negative 0.
static uint32_t enc(double v, int mb, int eb, int sign, enum Round r, enum Over o) {
uint32_t expall = (1u << eb) - 1, bias = (1u << (eb - 1)) - 1, s = 0;
if (isnan(v)) return (expall << mb) | (1u << (mb - 1));
if (v < 0 || (v == 0 && signbit(v))) {
if (!sign) return 0;
s = 1u << (mb + eb);
v = -v;
}
uint32_t maxfin = ((expall - 1) << mb) | ((1u << mb) - 1);
if (isinf(v)) return s | (expall << mb);
if (v == 0) return s;
int x;
frexp(v, &x);
int e = x - 1;
int denorm = e < 1 - (int)bias;
double q = denorm ? ldexp(v, (int)bias - 1 + mb) : ldexp(v, mb - e);
double qi = r == RTZ ? floor(q) : r == RNE ? nearbyint(q) : floor(q + 0.5);
uint32_t code;
if (denorm) {
code = (uint32_t)qi;
} else {
if (qi >= ldexp(1, mb + 1)) {
e += 1;
qi = ldexp(1, mb);
}
if (e + (int)bias >= (int)expall) return s | ((r == RTZ || o == SAT) ? maxfin : (expall << mb));
code = ((uint32_t)(e + (int)bias) << mb) | ((uint32_t)qi - (1u << mb));
}
return s | code;
}
static double dec(uint32_t c, int mb, int eb, int sign) {
uint32_t expall = (1u << eb) - 1, bias = (1u << (eb - 1)) - 1;
double sg = (sign && (c >> (mb + eb)) & 1) ? -1 : 1;
uint32_t e = (c >> mb) & expall, m = c & ((1u << mb) - 1);
if (e == expall) return m ? NAN : sg * INFINITY;
if (e == 0) return sg * ldexp(m, 1 - (int)bias - mb);
return sg * ldexp(m + (1u << mb), (int)e - (int)bias - mb);
}
static double clamp9(double v) { return isnan(v) || v < 0 ? 0 : v > 65408 ? 65408 : v; }
// RGB9E5: the shared exponent of the largest clamped channel, each mantissa rounded by `r`; a
// largest mantissa of 512 moves the exponent up where `bump`, else is held at 511.
static uint32_t rgb9e5(const double *c, enum Round r, int bump) {
double v[3], mx = 0;
for (int i = 0; i < 3; i++) {
v[i] = clamp9(c[i]);
if (v[i] > mx) mx = v[i];
}
if (mx == 0) return 0;
int x;
frexp(mx, &x);
int e = (x - 1 < -16 ? -16 : x - 1) + 16;
for (int pass = 0; pass < 2; pass++) {
uint32_t m[3], over = 0;
for (int i = 0; i < 3; i++) {
double q = ldexp(v[i], 24 - e);
double qi = r == RTZ ? floor(q) : r == RNE ? nearbyint(q) : floor(q + 0.5);
if (qi > 511) {
over = 1;
qi = 511;
}
m[i] = (uint32_t)qi;
}
if (over && bump && pass == 0 && e < 31) {
e += 1;
continue;
}
return ((uint32_t)e << 27) | (m[2] << 18) | (m[1] << 9) | m[0];
}
return 0;
}
static void dec9(uint32_t w, double *o) {
int e = (int)(w >> 27);
for (int i = 0; i < 3; i++) o[i] = ldexp((w >> (9 * i)) & 511, e - 24);
}
typedef struct {
const char *name;
MTLPixelFormat pf;
int bytes, kind; // kind 0: RGBA16Float, 1: RG11B10Float, 2: RGB9E5Float
} Fmt;
// The inputs' generator (SplitMix64 from 7), which `metal2vulkan`'s test of the words
// (`lower/arith/tests/color_write.rs`, `probe_texels`) takes again.
static uint64_t sm = 7;
static uint64_t next64(void) {
uint64_t z = (sm += 0x9E3779B97F4A7C15ull);
z = (z ^ (z >> 30)) * 0xBF58476D1CE4E5B9ull;
z = (z ^ (z >> 27)) * 0x94D049BB133111EBull;
return z ^ (z >> 31);
}
static uint32_t r32(void) { return (uint32_t)(next64() >> 32); }
// FNV-1a over `n` bytes, from `h`.
static uint64_t fnv(uint64_t h, const void *p, size_t n) {
const uint8_t *b = p;
for (size_t i = 0; i < n; i++) h = (h ^ b[i]) * 0x100000001b3ull;
return h;
}
static const uint64_t FNV0 = 0xcbf29ce484222325ull;
static float vals[40000];
static int nv;
static void add(double v) {
if (nv < 40000) vals[nv++] = (float)v;
}
static void build_values(void) {
double sp[] = {0, -0.0, -1, -65504, INFINITY, -INFINITY, NAN, 65504, 65505, 65519, 65519.99,
65520, 65521, 65536, 1e5, 1e9, 65024, 65040, 65055.99, 65056, 65057, 64512,
64528, 64543.99, 64544, 64545, 65408, 65407, 65409, 65416, 65424, 65471, 65472,
65473, 1e-10, 1e-40, ldexp(1, -24), ldexp(1, -25), ldexp(3, -26), ldexp(1, -20),
ldexp(1, -21), ldexp(3, -22), ldexp(1, -24) * 1.5, ldexp(1, -14), ldexp(1, -15),
ldexp(1, -16), ldexp(1, -17), 0.5, 1, 1.5, 2, 3};
for (unsigned i = 0; i < sizeof sp / sizeof sp[0]; i++) add(sp[i]);
int widths[] = {10, 9, 8, 6, 5};
for (int wi = 0; wi < 5; wi++) {
int mb = widths[wi];
for (int e = -26; e <= 16; e++) {
int ks[8] = {0, 1, 2, 3, (1 << mb) - 2, (1 << mb) - 1, 0, 0};
ks[6] = (int)(r32() % (1u << mb));
ks[7] = (int)(r32() % (1u << mb));
for (int k = 0; k < 8; k++) {
float t = (float)ldexp(1.0 + (ks[k] + 0.5) / ldexp(1, mb), e);
add(t);
add(nextafterf(t, INFINITY));
add(nextafterf(t, -INFINITY));
}
}
}
while (nv < 12000) {
int e = (int)(r32() % 44) - 27;
uint32_t mant = r32() & 0x7fffff;
double v = ldexp(1.0 + (double)mant / 8388608.0, e);
int neg = r32() % 16 == 0;
add(neg ? -v : v);
}
}
static double urand(void) { return (double)((r32() & 0xffffff) + 1) / 16777216.0; }
int main(int argc, char **argv) {
(void)argc;
(void)argv;
@autoreleasepool {
build_values();
id<MTLDevice> dev = MTLCreateSystemDefaultDevice();
printf("device %s\n", dev.name.UTF8String);
SEL sup = NSSelectorFromString(@"supportsTextureWriteRoundingMode:");
if ([dev respondsToSelector:sup]) {
for (NSUInteger m = 0; m <= 2; m++)
printf("supportsTextureWriteRoundingMode:%lu %d\n", (unsigned long)m,
((BOOL(*)(id, SEL, NSUInteger))objc_msgSend)(dev, sup, m));
}
NSError *err = nil;
MTLCompileOptions *co = [MTLCompileOptions new];
co.mathMode = MTLMathModeSafe;
id<MTLLibrary> lib = [dev newLibraryWithSource:@(SRC) options:co error:&err];
if (!lib) {
printf("library: %s\n", err.description.UTF8String);
return 1;
}
// The texels, `float` and `half`.
float *ftex = calloc(N * 4, sizeof(float));
__fp16 *htex = calloc(N * 4, sizeof(__fp16));
for (int i = 0; i < N; i++) {
float *t = ftex + 4 * i;
if (i < nv) {
t[0] = t[1] = t[2] = t[3] = vals[i];
} else {
float r = vals[r32() % (uint32_t)nv];
t[0] = r;
t[1] = (float)(r * urand());
if (r32() % 4 == 0) {
t[2] = vals[r32() % (uint32_t)nv];
} else {
t[2] = (float)(r * urand());
}
t[3] = vals[r32() % (uint32_t)nv];
}
for (int c = 0; c < 4; c++) htex[4 * i + c] = (__fp16)t[c];
}
printf("HASH inputs %016llx halves %016llx values %d\n", (unsigned long long)fnv(FNV0, ftex, N * 16),
(unsigned long long)fnv(FNV0, htex, N * 8), nv);
id<MTLBuffer> fbuf = [dev newBufferWithBytes:ftex length:N * 16 options:MTLResourceStorageModeShared];
id<MTLBuffer> hbuf = [dev newBufferWithBytes:htex length:N * 8 options:MTLResourceStorageModeShared];
MTLTextureDescriptor *td = [MTLTextureDescriptor texture2DDescriptorWithPixelFormat:MTLPixelFormatRGBA8Unorm
width:W
height:H
mipmapped:NO];
td.usage = MTLTextureUsageRenderTarget;
td.storageMode = MTLStorageModePrivate;
id<MTLTexture> rt = [dev newTextureWithDescriptor:td];
id<MTLCommandQueue> q = [dev newCommandQueue];
Fmt fmts[] = {{"RGBA16Float", MTLPixelFormatRGBA16Float, 8, 0},
{"RG11B10Float", MTLPixelFormatRG11B10Float, 4, 1},
{"RGB9E5Float", MTLPixelFormatRGB9E5Float, 4, 2}};
SEL set = NSSelectorFromString(@"setTextureWriteRoundingMode:");
SEL get = NSSelectorFromString(@"textureWriteRoundingMode");
for (int fi = 0; fi < 3; fi++) {
for (int half = 0; half < 2; half++) {
Fmt f = fmts[fi];
if (half && f.kind == 0) continue; // a half into a half-float texture is exact
uint8_t *out[2];
for (int mode = 0; mode < 2; mode++) {
MTLRenderPipelineDescriptor *pd = [MTLRenderPipelineDescriptor new];
pd.vertexFunction = [lib newFunctionWithName:@"vs"];
pd.fragmentFunction = [lib newFunctionWithName:half ? @"fs_half" : @"fs_float"];
pd.colorAttachments[0].pixelFormat = MTLPixelFormatRGBA8Unorm;
if (![pd respondsToSelector:set]) {
printf("no setTextureWriteRoundingMode:\n");
return 2;
}
((void (*)(id, SEL, NSUInteger))objc_msgSend)(pd, set, mode ? 2 : 0);
NSUInteger took = ((NSUInteger(*)(id, SEL))objc_msgSend)(pd, get);
id<MTLRenderPipelineState> ps = [dev newRenderPipelineStateWithDescriptor:pd error:&err];
if (!ps) {
printf("%s %s mode %d: pipeline: %s\n", f.name, half ? "half" : "float", mode ? 2 : 0,
err.description.UTF8String);
return 1;
}
MTLTextureDescriptor *sd = [MTLTextureDescriptor texture2DDescriptorWithPixelFormat:f.pf
width:W
height:H
mipmapped:NO];
sd.usage = MTLTextureUsageShaderWrite | MTLTextureUsageShaderRead;
sd.storageMode = MTLStorageModeShared;
id<MTLTexture> st = [dev newTextureWithDescriptor:sd];
uint8_t *fill = malloc(N * f.bytes);
memset(fill, 0xA5, N * f.bytes);
[st replaceRegion:MTLRegionMake2D(0, 0, W, H) mipmapLevel:0 withBytes:fill bytesPerRow:W * f.bytes];
MTLRenderPassDescriptor *rp = [MTLRenderPassDescriptor renderPassDescriptor];
rp.colorAttachments[0].texture = rt;
rp.colorAttachments[0].loadAction = MTLLoadActionDontCare;
rp.colorAttachments[0].storeAction = MTLStoreActionDontCare;
id<MTLCommandBuffer> cb = [q commandBuffer];
id<MTLRenderCommandEncoder> en = [cb renderCommandEncoderWithDescriptor:rp];
[en setRenderPipelineState:ps];
[en setFragmentTexture:st atIndex:0];
[en setFragmentBuffer:half ? hbuf : fbuf offset:0 atIndex:0];
[en drawPrimitives:MTLPrimitiveTypeTriangle vertexStart:0 vertexCount:3];
[en endEncoding];
[cb commit];
[cb waitUntilCompleted];
if (cb.status != MTLCommandBufferStatusCompleted) {
printf("%s: command buffer status %ld\n", f.name, (long)cb.status);
return 1;
}
out[mode] = fill;
[st getBytes:fill bytesPerRow:W * f.bytes fromRegion:MTLRegionMake2D(0, 0, W, H) mipmapLevel:0];
printf("%s %s mode %d (descriptor reads %lu)\n", f.name, half ? "half" : "float", mode ? 2 : 0,
(unsigned long)took);
}
printf("HASH %s %s mode0 %016llx mode2 %016llx\n", f.name, half ? "half" : "float",
(unsigned long long)fnv(FNV0, out[0], (size_t)N * f.bytes),
(unsigned long long)fnv(FNV0, out[1], (size_t)N * f.bytes));
// Per channel: the input, mode 0's and mode 2's codes, and the candidates'.
int chans = f.kind == 0 ? 4 : 3;
long total = 0, same = 0, unwritten = 0, dist[5] = {0}, nanish = 0;
const char *cn[] = {"rtz", "rne-inf", "rne-sat", "rhu-hold", "rne-bump", "rhu-bump", "rne-hold", "rtz-bump"};
long m0[8] = {0}, m2[8] = {0};
int ncand = f.kind == 2 ? 6 : 3;
int shown = 0;
double maxd = 0;
for (int i = 0; i < N; i++) {
double in[4];
for (int c = 0; c < 4; c++) in[c] = half ? (double)htex[4 * i + c] : (double)ftex[4 * i + c];
uint32_t w0 = 0, w2 = 0;
memcpy(&w0, out[0] + i * f.bytes, 4);
memcpy(&w2, out[1] + i * f.bytes, 4);
if (f.kind == 2) {
if (w0 == 0xA5A5A5A5u || w2 == 0xA5A5A5A5u) {
unwritten++;
continue;
}
uint32_t cand[6] = {rgb9e5(in, RTZ, 0), rgb9e5(in, RNE, 0), rgb9e5(in, RHU, 0),
rgb9e5(in, RNE, 1), rgb9e5(in, RHU, 1), rgb9e5(in, RTZ, 1)};
const int order[6] = {0, 6, 3, 4, 5, 7};
for (int k = 0; k < 6; k++) {
m0[order[k]] += cand[k] == w0;
m2[order[k]] += cand[k] == w2;
}
total++;
same += w0 == w2;
if (w0 != w2) {
double d0[3], d2[3];
dec9(w0, d0);
dec9(w2, d2);
int e = (int)((w0 >> 27) > (w2 >> 27) ? (w0 >> 27) : (w2 >> 27));
double ulp = ldexp(1, e - 24), d = 0;
for (int c = 0; c < 3; c++) d = fmax(d, fabs(d2[c] - d0[c]) / ulp);
maxd = fmax(maxd, d);
dist[d <= 1 ? 1 : d <= 2 ? 2 : 3]++;
if (shown < 6) {
shown++;
printf(" in (%.9g %.9g %.9g) mode0 %08x mode2 %08x rtz %08x rne %08x rhu %08x rne-bump %08x\n",
in[0], in[1], in[2], w0, w2, cand[0], cand[1], cand[2], cand[3]);
}
}
continue;
}
for (int c = 0; c < chans; c++) {
uint32_t c0, c2;
int mb, eb, sg;
if (f.kind == 0) {
uint16_t a, b;
memcpy(&a, out[0] + i * 8 + 2 * c, 2);
memcpy(&b, out[1] + i * 8 + 2 * c, 2);
c0 = a;
c2 = b;
mb = 10, eb = 5, sg = 1;
if (a == 0xA5A5 || b == 0xA5A5) {
unwritten++;
continue;
}
} else {
if (w0 == 0xA5A5A5A5u || w2 == 0xA5A5A5A5u) {
unwritten++;
continue;
}
int sh = c == 0 ? 0 : c == 1 ? 11 : 22;
mb = c == 2 ? 5 : 6, eb = 5, sg = 0;
c0 = (w0 >> sh) & ((1u << (mb + eb)) - 1);
c2 = (w2 >> sh) & ((1u << (mb + eb)) - 1);
}
total++;
double v0 = dec(c0, mb, eb, sg), v2 = dec(c2, mb, eb, sg);
if (isnan(in[c]) || isnan(v0) || isnan(v2)) {
nanish++;
same += isnan(v0) == isnan(v2);
continue;
}
uint32_t cand[3] = {enc(in[c], mb, eb, sg, RTZ, SAT), enc(in[c], mb, eb, sg, RNE, INF),
enc(in[c], mb, eb, sg, RNE, SAT)};
for (int k = 0; k < 3; k++) {
m0[k] += cand[k] == c0;
m2[k] += cand[k] == c2;
}
same += c0 == c2;
if (c0 != c2) {
// Codes of one sign are ordered by magnitude.
long a0 = (long)(c0 & ((1u << (mb + eb)) - 1)), a2 = (long)(c2 & ((1u << (mb + eb)) - 1));
long d = labs(a2 - a0);
if (isinf(v0) != isinf(v2)) d = 4;
dist[d >= 4 ? 4 : d >= 3 ? 3 : d]++;
if (shown < 6) {
shown++;
printf(" in %.9g (%a) mode0 %04x (%.9g) mode2 %04x (%.9g) rtz %04x rne-inf %04x rne-sat %04x\n",
in[c], in[c], c0, v0, c2, v2, cand[0], cand[1], cand[2]);
}
}
}
}
printf("RESULT %s %s: %ld %s, %ld unwritten, %ld NaN-ish; mode 2 = mode 0 on %ld; differing by 1: %ld, 2: %ld, "
"more: %ld, inf/finite: %ld%s",
f.name, half ? "half" : "float", total, f.kind == 2 ? "texels" : "channels", unwritten, nanish, same,
dist[1], dist[2], dist[3], dist[4], f.kind == 2 ? "" : "\n");
if (f.kind == 2) printf(" (max %.3g units of the larger exponent's last place)\n", maxd);
for (int k = 0; k < 8; k++) {
if (f.kind != 2 && k >= ncand) break;
if (f.kind == 2 && !(k == 0 || k >= 3)) continue;
printf(" candidate %-9s mode 0 %ld, mode 2 %ld\n", cn[k], m0[k], m2[k]);
}
free(out[0]);
free(out[1]);
}
}
}
return 0;
}
@@ -0,0 +1,273 @@
// What Metal does with a viewport whose depth range lies past [0, 1], beside control ranges in it.
//
// One render pass per case into a 5 by 1 RGBA32Float colour target and, where the case has one, a
// 5 by 1 depth attachment (Depth32Float or Depth16Unorm) cleared to the case's depth, under the
// case's depth compare function with writes on, in the case's depth clip mode. Five quads cover
// the five columns, each at its own clip-space z (w = 1). Each fragment writes its
// [[position]].z, its .w and a 1 (the column was drawn) into the colour target, which is cleared
// to -9; the `depth` fragment also writes [[depth(any)]] = [[position]].z. For each case and
// column it prints the z the quad was drawn at, whether a fragment landed, the [[position]].z and
// .w it read, and the depth the attachment stored, with the command buffer's status.
//
// The cases ask, for a range past [0, 1]: what position.z reads; what a Depth32Float and a
// Depth16Unorm attachment store, from the rasterized depth and from a [[depth]] output; which
// value the depth test compares, on both sides of 0 and of 1; whether a quad past clip space's z
// bounds is clipped; and, in MTLDepthClipModeClamp, what the stored depth is clamped to (the
// viewport's range or [0, 1]). The [0, 1] and [0.25, 0.75] cases are the controls.
//
// xcrun clang -fobjc-arc -O1 -framework Foundation -framework Metal \
// -o viewport_depth_past_unit viewport_depth_past_unit.m
// ./viewport_depth_past_unit
// MTL_DEBUG_LAYER=1 MTL_DEBUG_LAYER_ERROR_MODE=nslog ./viewport_depth_past_unit
//
// The layer run says whether Metal's API validation takes the range; the plain run is Metal's
// answer (the layer is not passive).
//
// WHAT IT MEASURED, Apple M3 Max, macOS 27.0.1 (job m3-max-85541, the first five cases, which
// then printed no "drawn" field), the plain run and the layer run line for line alike, the layer
// printing nothing past "Metal API Validation Enabled":
//
// - setViewport takes znear -1, zfar 1, and every command buffer completes with no error;
// - [-1, 1]: position.z reads -1, -0.5, 0, 0.5 and 1 at clip z 0, 0.25, 0.5, 0.75 and 1
// (znear + z * (zfar - znear), unclamped), position.w 1, with a depth attachment or without;
// - [-1, 1]: the Depth32Float attachment stores 0, 0, 0, 0.5 and 1, that z clamped to [0, 1];
// a [[depth(any)]] output of position.z stores the same;
// - [0, 1], the control: position.z and the stored depth are clip z, with either fragment.
//
// WHAT IT MEASURED, Apple M3 Max, macOS 27.0.1 (job m3-max-85617, every case above), the plain
// run and the layer run byte for byte alike, every command buffer completed with no error, the
// layer printing nothing past "Metal API Validation Enabled":
//
// - the first five cases as before, each column drawn;
// - Clip mode: position.z is znear + z * (zfar - znear) unclamped, under every range ([-1, 1],
// [0, 2], the reversed [1, -1], [2, 3]); a quad at clip z -0.5, -0.01, 1.01 or 1.5 is not
// drawn under [-1, 1] or [0, 1], with a depth attachment or without: clip space's 0 <= z <= w
// holds whatever the range;
// - Clip mode: Depth32Float and Depth16Unorm store that z clamped to [0, 1], and so does a
// [[depth(any)]] output of it ([0, 2]: 0, 0.5, 1, 1, 1; Depth16Unorm raw 0, 32768, 65535,
// 65535, 65535; [2, 3]: 1 at every column);
// - Clip mode: the depth test compares the clamped value: Equal against a clear of 0 passes at
// position.z -1, -0.5 and 0 under [-1, 1], and Less against 0 at none, through [[depth]]
// too; Equal against a clear of 1 passes at 1, 1.5 and 2 under [0, 2], and Greater at none;
// Depth16Unorm alike;
// - Clamp mode: every quad is drawn (no z clip); position.z is unclamped (-0.25 to 2.75 under
// [0.5, 2]); the stored depth, from the rasterized z or a [[depth]] output, on Depth32Float
// and Depth16Unorm, is clamped to the range's part in [0, 1]: [0.25, 0.75] stores 0.25 to
// 0.75, [0.5, 2] stores 0.5, 0.5, 1, 1, 1 (raw 32768 and 65535), [-1, 1] and [0, 1] store 0
// to 1.
#import <Foundation/Foundation.h>
#import <Metal/Metal.h>
#include <stdio.h>
#include <stdarg.h>
#include <stdlib.h>
#include <string.h>
static void P(const char *fmt, ...) {
va_list ap; va_start(ap, fmt);
fputs("RESULT ", stdout); vfprintf(stdout, fmt, ap); fputc('\n', stdout); fflush(stdout);
va_end(ap);
}
static NSString *const SOURCE =
@"#include <metal_stdlib>\n"
"using namespace metal;\n"
"struct V { float4 pos [[position]]; };\n"
"vertex V quads(uint vid [[vertex_id]], constant float *Z [[buffer(0)]]) {\n"
" uint q = vid / 6, k = vid % 6;\n"
" float2 c[6] = {float2(0, 0), float2(1, 0), float2(0, 1), float2(1, 0), float2(1, 1), float2(0, 1)};\n"
" float x0 = -1.0 + 2.0 * float(q) / 5.0, x1 = -1.0 + 2.0 * float(q + 1) / 5.0;\n"
" V o; o.pos = float4(mix(x0, x1, c[k].x), mix(-1.0, 1.0, c[k].y), Z[q], 1.0); return o; }\n"
"fragment float4 plain(V in [[stage_in]]) { return float4(in.pos.z, in.pos.w, 1, 1); }\n"
"struct D { float4 c [[color(0)]]; float d [[depth(any)]]; };\n"
"fragment D depth(V in [[stage_in]]) {\n"
" D o; o.c = float4(in.pos.z, in.pos.w, 1, 1); o.d = in.pos.z; return o; }\n";
static const char *STATUS[] = {"NotEnqueued", "Enqueued", "Committed", "Scheduled", "Completed",
"Error"};
static id<MTLDevice> DEV;
static id<MTLCommandQueue> QUEUE;
static id<MTLLibrary> LIB;
// The clip-space z of the five quads: inside clip space, and across its bounds.
static const float INSIDE[5] = {0.0f, 0.25f, 0.5f, 0.75f, 1.0f};
static const float ACROSS[5] = {-0.5f, -0.01f, 0.5f, 1.01f, 1.5f};
enum DepthKind { NONE, D32, D16 };
typedef struct {
const char *name;
double znear, zfar;
enum DepthKind depth;
const char *fragment;
MTLDepthClipMode clip;
const float *z;
double clear;
MTLCompareFunction compare;
} Case;
static const char *depth_name(enum DepthKind k) {
return k == D32 ? "Depth32Float" : k == D16 ? "Depth16Unorm" : "none";
}
static const char *compare_name(MTLCompareFunction f) {
switch (f) {
case MTLCompareFunctionAlways: return "Always";
case MTLCompareFunctionEqual: return "Equal";
case MTLCompareFunctionLess: return "Less";
case MTLCompareFunctionGreater: return "Greater";
default: return "?";
}
}
static void run_case(const Case *k) {
NSError *e = nil;
MTLPixelFormat df = k->depth == D32 ? MTLPixelFormatDepth32Float
: k->depth == D16 ? MTLPixelFormatDepth16Unorm : MTLPixelFormatInvalid;
MTLRenderPipelineDescriptor *pd = [[MTLRenderPipelineDescriptor alloc] init];
pd.vertexFunction = [LIB newFunctionWithName:@"quads"];
pd.fragmentFunction = [LIB newFunctionWithName:[NSString stringWithUTF8String:k->fragment]];
pd.colorAttachments[0].pixelFormat = MTLPixelFormatRGBA32Float;
if (k->depth != NONE) pd.depthAttachmentPixelFormat = df;
id<MTLRenderPipelineState> ps = [DEV newRenderPipelineStateWithDescriptor:pd error:&e];
if (!ps) { P("%s: pipeline failed: %s", k->name, [[e description] UTF8String]); return; }
MTLTextureDescriptor *cd = [MTLTextureDescriptor
texture2DDescriptorWithPixelFormat:MTLPixelFormatRGBA32Float width:5 height:1 mipmapped:NO];
cd.usage = MTLTextureUsageRenderTarget; cd.storageMode = MTLStorageModePrivate;
id<MTLTexture> colour = [DEV newTextureWithDescriptor:cd];
id<MTLTexture> depth = nil;
if (k->depth != NONE) {
MTLTextureDescriptor *dd = [MTLTextureDescriptor
texture2DDescriptorWithPixelFormat:df width:5 height:1 mipmapped:NO];
dd.usage = MTLTextureUsageRenderTarget; dd.storageMode = MTLStorageModePrivate;
depth = [DEV newTextureWithDescriptor:dd];
}
id<MTLBuffer> cread = [DEV newBufferWithLength:5 * 16 options:MTLResourceStorageModeShared];
id<MTLBuffer> dread = [DEV newBufferWithLength:256 options:MTLResourceStorageModeShared];
memset(cread.contents, 0xFF, cread.length); memset(dread.contents, 0xFF, dread.length);
MTLRenderPassDescriptor *rp = [MTLRenderPassDescriptor renderPassDescriptor];
rp.colorAttachments[0].texture = colour;
rp.colorAttachments[0].loadAction = MTLLoadActionClear;
rp.colorAttachments[0].clearColor = MTLClearColorMake(-9, -9, -9, -9);
rp.colorAttachments[0].storeAction = MTLStoreActionStore;
if (depth) {
rp.depthAttachment.texture = depth;
rp.depthAttachment.loadAction = MTLLoadActionClear;
rp.depthAttachment.clearDepth = k->clear;
rp.depthAttachment.storeAction = MTLStoreActionStore;
}
MTLDepthStencilDescriptor *dsd = [[MTLDepthStencilDescriptor alloc] init];
dsd.depthCompareFunction = k->compare;
dsd.depthWriteEnabled = depth ? YES : NO;
id<MTLDepthStencilState> dss = [DEV newDepthStencilStateWithDescriptor:dsd];
id<MTLCommandBuffer> cb = [QUEUE commandBuffer];
id<MTLRenderCommandEncoder> re = [cb renderCommandEncoderWithDescriptor:rp];
[re setRenderPipelineState:ps];
[re setDepthStencilState:dss];
[re setDepthClipMode:k->clip];
[re setVertexBytes:k->z length:5 * sizeof(float) atIndex:0];
MTLViewport vp = {0, 0, 5, 1, k->znear, k->zfar};
[re setViewport:vp];
P("%s: znear %g zfar %g depth %s fragment %s clip mode %s clear %g compare %s", k->name, k->znear,
k->zfar, depth_name(k->depth), k->fragment,
k->clip == MTLDepthClipModeClamp ? "Clamp" : "Clip", k->clear, compare_name(k->compare));
[re drawPrimitives:MTLPrimitiveTypeTriangle vertexStart:0 vertexCount:30];
[re endEncoding];
id<MTLBlitCommandEncoder> be = [cb blitCommandEncoder];
[be copyFromTexture:colour sourceSlice:0 sourceLevel:0 sourceOrigin:MTLOriginMake(0, 0, 0)
sourceSize:MTLSizeMake(5, 1, 1) toBuffer:cread destinationOffset:0
destinationBytesPerRow:5 * 16 destinationBytesPerImage:5 * 16];
NSUInteger unit = k->depth == D16 ? 2 : 4;
if (depth) {
[be copyFromTexture:depth sourceSlice:0 sourceLevel:0 sourceOrigin:MTLOriginMake(0, 0, 0)
sourceSize:MTLSizeMake(5, 1, 1) toBuffer:dread destinationOffset:0
destinationBytesPerRow:5 * unit destinationBytesPerImage:5 * unit];
}
[be endEncoding];
[cb commit];
[cb waitUntilCompleted];
NSError *err = cb.error;
P("%s: status %s error %s", k->name, ((unsigned)cb.status < 6) ? STATUS[cb.status] : "?",
err ? [[err localizedDescription] UTF8String] : "none");
const float *c = (const float *)cread.contents;
for (int i = 0; i < 5; i++) {
const float *t = c + i * 4;
int drawn = t[2] == 1.0f;
char stored[64];
if (k->depth == D32)
snprintf(stored, sizeof stored, "%.9g", ((const float *)dread.contents)[i]);
else if (k->depth == D16) {
unsigned raw = ((const unsigned short *)dread.contents)[i];
snprintf(stored, sizeof stored, "%.9g (raw %u)", raw / 65535.0, raw);
} else
snprintf(stored, sizeof stored, "(no depth attachment)");
if (drawn)
P("%s: clip z %.2f drawn position.z %.9g position.w %.9g stored depth %s", k->name, k->z[i],
t[0], t[1], stored);
else
P("%s: clip z %.2f not drawn (texel %g %g %g %g) stored depth %s", k->name, k->z[i], t[0],
t[1], t[2], t[3], stored);
}
}
int main(void) {
@autoreleasepool {
NSOperatingSystemVersion v = [[NSProcessInfo processInfo] operatingSystemVersion];
P("macOS %ld.%ld.%ld MTL_DEBUG_LAYER=%s", (long)v.majorVersion, (long)v.minorVersion,
(long)v.patchVersion, getenv("MTL_DEBUG_LAYER") ?: "unset");
DEV = MTLCreateSystemDefaultDevice();
if (!DEV) { P("fatal: no device"); return 3; }
P("device %s", [[DEV name] UTF8String]);
QUEUE = [DEV newCommandQueue];
NSError *e = nil;
LIB = [DEV newLibraryWithSource:SOURCE options:nil error:&e];
if (!LIB) { P("fatal: library: %s", [[e description] UTF8String]); return 3; }
const MTLDepthClipMode CLIP = MTLDepthClipModeClip, CLAMP = MTLDepthClipModeClamp;
const MTLCompareFunction ALWAYS = MTLCompareFunctionAlways;
const Case cases[] = {
// The first run's five.
{"unit-depth", 0, 1, D32, "plain", CLIP, INSIDE, 0.5, ALWAYS},
{"past-depth", -1, 1, D32, "plain", CLIP, INSIDE, 0.5, ALWAYS},
{"past-fragdepth", -1, 1, D32, "depth", CLIP, INSIDE, 0.5, ALWAYS},
{"unit-fragdepth", 0, 1, D32, "depth", CLIP, INSIDE, 0.5, ALWAYS},
{"past-nodepth", -1, 1, NONE, "plain", CLIP, INSIDE, 0.5, ALWAYS},
// Above 1, and Depth16Unorm on both sides.
{"high-depth", 0, 2, D32, "plain", CLIP, INSIDE, 0.5, ALWAYS},
{"high-fragdepth", 0, 2, D32, "depth", CLIP, INSIDE, 0.5, ALWAYS},
{"past-d16", -1, 1, D16, "plain", CLIP, INSIDE, 0.5, ALWAYS},
{"past-d16-fragdepth", -1, 1, D16, "depth", CLIP, INSIDE, 0.5, ALWAYS},
{"high-d16", 0, 2, D16, "plain", CLIP, INSIDE, 0.5, ALWAYS},
{"high-d16-fragdepth", 0, 2, D16, "depth", CLIP, INSIDE, 0.5, ALWAYS},
// The depth test on both sides of 0 and of 1: the clamped value or the unclamped one.
{"test-low-equal", -1, 1, D32, "plain", CLIP, INSIDE, 0.0, MTLCompareFunctionEqual},
{"test-low-less", -1, 1, D32, "plain", CLIP, INSIDE, 0.0, MTLCompareFunctionLess},
{"test-high-equal", 0, 2, D32, "plain", CLIP, INSIDE, 1.0, MTLCompareFunctionEqual},
{"test-high-greater", 0, 2, D32, "plain", CLIP, INSIDE, 1.0, MTLCompareFunctionGreater},
{"test-low-equal-d16", -1, 1, D16, "plain", CLIP, INSIDE, 0.0, MTLCompareFunctionEqual},
{"test-high-greater-d16", 0, 2, D16, "plain", CLIP, INSIDE, 1.0, MTLCompareFunctionGreater},
{"test-low-less-fragdepth", -1, 1, D32, "depth", CLIP, INSIDE, 0.0, MTLCompareFunctionLess},
// Clip space's z bounds under the range, in Clip mode.
{"clip-past", -1, 1, D32, "plain", CLIP, ACROSS, 0.5, ALWAYS},
{"clip-past-nodepth", -1, 1, NONE, "plain", CLIP, ACROSS, 0.5, ALWAYS},
{"clip-unit", 0, 1, D32, "plain", CLIP, ACROSS, 0.5, ALWAYS},
// Clamp mode: what the stored depth is clamped to, and what position.z reads.
{"clamp-unit", 0, 1, D32, "plain", CLAMP, ACROSS, 0.5, ALWAYS},
{"clamp-mid", 0.25, 0.75, D32, "plain", CLAMP, ACROSS, 0.5, ALWAYS},
{"clamp-past", -1, 1, D32, "plain", CLAMP, ACROSS, 0.5, ALWAYS},
{"clamp-high", 0.5, 2, D32, "plain", CLAMP, ACROSS, 0.5, ALWAYS},
{"clamp-high-fragdepth", 0.5, 2, D32, "depth", CLAMP, ACROSS, 0.5, ALWAYS},
{"clamp-high-d16", 0.5, 2, D16, "plain", CLAMP, ACROSS, 0.5, ALWAYS},
{"clamp-past-nodepth", -1, 1, NONE, "plain", CLAMP, ACROSS, 0.5, ALWAYS},
// A reversed range, and one wholly above 1.
{"reversed", 1, -1, D32, "plain", CLIP, INSIDE, 0.5, ALWAYS},
{"both-past", 2, 3, D32, "plain", CLIP, INSIDE, 0.5, ALWAYS},
};
for (size_t i = 0; i < sizeof cases / sizeof cases[0]; i++) run_case(&cases[i]);
P("done");
}
return 0;
}
@@ -0,0 +1,470 @@
{
"format": 1,
"case": "block-writes-only-writes",
"suite_version": 1,
"shaders": [
{
"fixture": "fpv_srgb_storage.ll",
"entry": "fpv_srgb_write",
"source_sha256": "1fd72038430e03760b7c9f3096b2babe5056900741128527111e4a801627d51a"
},
{
"fixture": "fpv_srgb_storage.air.ll",
"entry": "fpv_srgb_write",
"source_sha256": "61b9ec9c9f1a8c33f6f3735b399078d2c1b225f723323f1ced884a16b4524d75"
}
],
"answers": [
{
"key": {
"chip": "apple-m3-max",
"os_version": "27.0.1",
"os_build": "26A434",
"metal_level": "27.0.1"
},
"provenance": "metal_run",
"device": "Apple M3 Max",
"runs": 3,
"outcomes": [
{
"runs": 3,
"transcript": {
"root": {
"name": "case",
"observed": {
"value": "absent"
},
"children": [
{
"name": "inputs",
"observed": {
"value": "absent"
},
"children": [
{
"name": "air",
"observed": {
"value": "absent",
"digest": {
"kind": "sha256",
"hex": "1fd72038430e03760b7c9f3096b2babe5056900741128527111e4a801627d51a"
}
}
},
{
"name": "air-typed",
"observed": {
"value": "absent",
"digest": {
"kind": "sha256",
"hex": "61b9ec9c9f1a8c33f6f3735b399078d2c1b225f723323f1ced884a16b4524d75"
}
}
},
{
"name": "buffer:0",
"observed": {
"value": "absent",
"digest": {
"kind": "sha256",
"hex": "57d0319aadc26913b6ea046b49d2c507337b6b165d642f3ebf4416cec7fc340c"
}
}
},
{
"name": "buffer:1",
"observed": {
"value": "absent",
"digest": {
"kind": "sha256",
"hex": "097328e8c957de2428283954f6a1ee8ff7ad7def12e100a600178407f5decf24"
}
}
},
{
"name": "usage-0x10005",
"observed": {
"value": "absent",
"digest": {
"kind": "sha256",
"hex": "fcb07099b8ea07b6bb835217dae8b2b58388361662a2866ecd32fd5a902aa195"
}
}
},
{
"name": "usage-0x10000",
"observed": {
"value": "absent",
"digest": {
"kind": "sha256",
"hex": "2df39b56c7b28ac6609132b8fa6689918bf3320a39cd0326ae685e92691b743f"
}
}
}
]
},
{
"name": "library",
"observed": {
"value": {
"variant": {
"name": "Ok",
"payload": "absent"
}
}
}
},
{
"name": "pipeline",
"observed": {
"value": {
"variant": {
"name": "Ok",
"payload": "absent"
}
}
}
},
{
"name": "buffer/0",
"observed": {
"value": {
"variant": {
"name": "Ok",
"payload": "absent"
}
}
}
},
{
"name": "buffer/width",
"observed": {
"value": {
"variant": {
"name": "Ok",
"payload": "absent"
}
}
}
},
{
"name": "usage-0x10005/texture",
"observed": {
"value": {
"variant": {
"name": "Ok",
"payload": "absent"
}
}
}
},
{
"name": "usage-0x10005/dispatch",
"observed": {
"value": {
"variant": {
"name": "Ok",
"payload": "absent"
}
}
}
},
{
"name": "usage-0x10005/status",
"observed": {
"value": {
"variant": {
"name": "Ok",
"payload": {
"variant": {
"name": "Completed",
"payload": "absent"
}
}
}
}
}
},
{
"name": "usage-0x10005/texels",
"observed": {
"value": {
"variant": {
"name": "Ok",
"payload": "absent"
}
}
}
},
{
"name": "usage-0x10005/stored",
"observed": {
"value": {
"bytes": "AP8A/xDvJf4g30r9MM9v/EC/lPtQr7n6YJ/e+XCPA/iAfyj3kG9N9qBfcvWwT5f0wD+889Av4fLgHwbx8A8r8A=="
},
"shape": {
"bytes": {
"region": {
"texture": {
"level": 0,
"slice": 0,
"aspect": "color",
"sample": 0,
"origin": [
0,
0,
0
],
"size": [
16,
1,
1
]
}
},
"element": "u8",
"row_offset": 0,
"row_elements": 64,
"row_pitch": 64,
"rows": 1,
"image_pitch": 64,
"images": 1,
"gaps": "ignored"
}
}
}
},
{
"name": "usage-0x10000/texture",
"observed": {
"value": {
"variant": {
"name": "Ok",
"payload": "absent"
}
}
}
},
{
"name": "usage-0x10000/dispatch",
"observed": {
"value": {
"variant": {
"name": "Ok",
"payload": "absent"
}
}
}
},
{
"name": "usage-0x10000/status",
"observed": {
"value": {
"variant": {
"name": "Ok",
"payload": {
"variant": {
"name": "Completed",
"payload": "absent"
}
}
}
}
}
},
{
"name": "usage-0x10000/texels",
"observed": {
"value": {
"variant": {
"name": "Ok",
"payload": "absent"
}
}
}
},
{
"name": "usage-0x10000/stored",
"observed": {
"value": {
"bytes": "AP8A/xDvJf4g30r9MM9v/EC/lPtQr7n6YJ/e+XCPA/iAfyj3kG9N9qBfcvWwT5f0wD+889Av4fLgHwbx8A8r8A=="
},
"shape": {
"bytes": {
"region": {
"texture": {
"level": 0,
"slice": 0,
"aspect": "color",
"sample": 0,
"origin": [
0,
0,
0
],
"size": [
16,
1,
1
]
}
},
"element": "u8",
"row_offset": 0,
"row_elements": 64,
"row_pitch": 64,
"rows": 1,
"image_pitch": 64,
"images": 1,
"gaps": "ignored"
}
}
}
},
{
"name": "notices",
"observed": {
"value": "absent"
},
"children": [
{
"name": "set",
"observed": {
"value": {
"nothing": "announced_nothing"
}
}
},
{
"name": "counts",
"observed": {
"value": {
"fields": {}
}
}
}
]
}
]
}
}
}
],
"validated": "ran"
}
],
"times": [
{
"venue": "native Metal",
"chip": "apple-m3-max",
"os_build": "26A434",
"rounds": 8,
"measured": "8 round(s) of the whole selection, in the case set's own order; a figure is the median of the rounds' own medians; Metal's leg ran at a one-minute load average of 13.20",
"instrument": 281,
"times": {
"case": "block-writes-only-writes",
"calls": 12,
"in_calls": 31871083,
"on_cpu": 1321585,
"blocked": 30603626,
"elsewhere": 3358500,
"spend": 35193665,
"spend_least": 34528832,
"spend_most": 354111042,
"per_call": [
{
"call": "buffer",
"least_calls": 2,
"most_calls": 2,
"wall": 7500,
"on_cpu": 7708,
"blocked": 0,
"wall_least": 6833,
"wall_most": 9292,
"wall_total": 43209,
"on_cpu_total": 43667,
"blocked_total": 0
},
{
"call": "compute_pipeline",
"least_calls": 1,
"most_calls": 1,
"wall": 120250,
"on_cpu": 120750,
"blocked": 0,
"wall_least": 112125,
"wall_most": 1516416,
"wall_total": 120250,
"on_cpu_total": 120750,
"blocked_total": 0
},
{
"call": "dispatch",
"least_calls": 2,
"most_calls": 2,
"wall": 54500,
"on_cpu": 54709,
"blocked": 0,
"wall_least": 48292,
"wall_most": 60708,
"wall_total": 215292,
"on_cpu_total": 215666,
"blocked_total": 0
},
{
"call": "library",
"least_calls": 1,
"most_calls": 1,
"wall": 27120084,
"on_cpu": 754209,
"blocked": 26324834,
"wall_least": 26707125,
"wall_most": 344126959,
"wall_total": 27120084,
"on_cpu_total": 754209,
"blocked_total": 26324834
},
{
"call": "read_texture",
"least_calls": 2,
"most_calls": 2,
"wall": 8166,
"on_cpu": 8375,
"blocked": 0,
"wall_least": 6125,
"wall_most": 12875,
"wall_total": 22374,
"on_cpu_total": 22709,
"blocked_total": 0
},
{
"call": "texture",
"least_calls": 2,
"most_calls": 2,
"wall": 51125,
"on_cpu": 51459,
"blocked": 0,
"wall_least": 49833,
"wall_most": 67750,
"wall_total": 112375,
"on_cpu_total": 112875,
"blocked_total": 0
},
{
"call": "wait",
"least_calls": 2,
"most_calls": 2,
"wall": 182334,
"on_cpu": 12292,
"blocked": 168001,
"wall_least": 172166,
"wall_most": 446959,
"wall_total": 4002000,
"on_cpu_total": 37833,
"blocked_total": 3956916
}
]
}
}
]
}
@@ -0,0 +1,394 @@
{
"format": 1,
"case": "compute-imageblock-slice-past-the-grid",
"suite_version": 1,
"shaders": [
{
"fixture": "tib_imageblock_slices.ll",
"entry": "tib_slot_half_slice",
"source_sha256": "e00dc828bc21cb59ff668559851fa8347208d36224e01e453c86090ab2b02609"
},
{
"fixture": "tib_imageblock_slices.air.ll",
"entry": "tib_slot_half_slice",
"source_sha256": "312d30f0c139ef278848e46bd114721c293f696ea15e331c555d73cce7204f2d"
}
],
"answers": [
{
"key": {
"chip": "apple-m3-max",
"os_version": "27.0.1",
"os_build": "26A434",
"metal_level": "27.0.1"
},
"provenance": "metal_run",
"device": "Apple M3 Max",
"runs": 3,
"outcomes": [
{
"runs": 3,
"transcript": {
"root": {
"name": "case",
"observed": {
"value": "absent"
},
"children": [
{
"name": "inputs",
"observed": {
"value": "absent"
},
"children": [
{
"name": "air",
"observed": {
"value": "absent",
"digest": {
"kind": "sha256",
"hex": "e00dc828bc21cb59ff668559851fa8347208d36224e01e453c86090ab2b02609"
}
}
},
{
"name": "air-typed",
"observed": {
"value": "absent",
"digest": {
"kind": "sha256",
"hex": "312d30f0c139ef278848e46bd114721c293f696ea15e331c555d73cce7204f2d"
}
}
},
{
"name": "entry",
"observed": {
"value": "absent",
"digest": {
"kind": "sha256",
"hex": "5811b06bddd6bca69b4920fba706707791afbfb9d86ce0fe8988d67ed561b83b"
}
}
},
{
"name": "texture:fill",
"observed": {
"value": "absent",
"digest": {
"kind": "sha256",
"hex": "812f3ff8152a5c6495088c0a040344831904a9ab5eeef3a59e18b43a8c52d123"
}
}
},
{
"name": "pass",
"observed": {
"value": "absent",
"digest": {
"kind": "sha256",
"hex": "57b97704c85415bc8c5702b34343a3460663ffa357a739b595dab79093ea4982"
}
}
}
]
},
{
"name": "library",
"observed": {
"value": {
"variant": {
"name": "Ok",
"payload": "absent"
}
}
}
},
{
"name": "pipeline",
"observed": {
"value": {
"variant": {
"name": "Ok",
"payload": "absent"
}
}
}
},
{
"name": "texture",
"observed": {
"value": {
"variant": {
"name": "Ok",
"payload": "absent"
}
}
}
},
{
"name": "pass",
"observed": {
"value": {
"variant": {
"name": "Ok",
"payload": "absent"
}
}
}
},
{
"name": "outcome",
"observed": {
"value": "absent"
},
"children": [
{
"name": "dispatch_type",
"observed": {
"value": {
"variant": {
"name": "Serial",
"payload": "absent"
}
}
}
},
{
"name": "status",
"observed": {
"value": {
"variant": {
"name": "Completed",
"payload": "absent"
}
}
}
},
{
"name": "error",
"observed": {
"value": {
"variant": {
"name": "None",
"payload": "absent"
}
}
}
},
{
"name": "step/0/setComputePipelineState",
"observed": {
"value": {
"variant": {
"name": "Ok",
"payload": "absent"
}
}
}
},
{
"name": "step/1/setTexture",
"observed": {
"value": {
"variant": {
"name": "Ok",
"payload": "absent"
}
}
}
},
{
"name": "step/2/setImageblockWidth",
"observed": {
"value": {
"variant": {
"name": "Ok",
"payload": "absent"
}
}
}
},
{
"name": "step/3/dispatchThreads",
"observed": {
"value": {
"variant": {
"name": "Ok",
"payload": "absent"
}
}
}
}
]
},
{
"name": "read-back",
"observed": {
"value": {
"variant": {
"name": "Ok",
"payload": "absent"
}
}
}
},
{
"name": "texels",
"observed": {
"value": {
"bytes": "ACQAAAAAAAAAKAAAAAAAAAAqAAAAAAAAACwAAAAAAAAALQAAAAAAAAAuAAAAAAAAAAAAAAAAAAAAAAAAAAAAAIAwAAAAAAAAADEAAAAAAACAMQAAAAAAAAAyAAAAAAAAgDIAAAAAAAAAMwAAAAAAAAAAAAAAAAAAAAAAAAAAAABANAAAAAAAAIA0AAAAAAAAwDQAAAAAAAAANQAAAAAAAEA1AAAAAAAAgDUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQDYAAAAAAACANgAAAAAAAMA2AAAAAAAAADcAAAAAAABANwAAAAAAAIA3AAAAAAAAAAAAAAAAAAAAAAAAAAAAACA4AAAAAAAAQDgAAAAAAABgOAAAAAAAAIA4AAAAAAAAoDgAAAAAAADAOAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAgOQAAAAAAAEA5AAAAAAAAYDkAAAAAAACAOQAAAAAAAKA5AAAAAAAAwDkAAAAAAAAAAAAAAAAAAAAAAAAAAAAAIDoAAAAAAABAOgAAAAAAAGA6AAAAAAAAgDoAAAAAAACgOgAAAAAAAMA6AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA="
},
"shape": {
"bytes": {
"region": {
"texture": {
"level": 0,
"slice": 0,
"aspect": "color",
"sample": 0,
"origin": [
0,
0,
0
],
"size": [
8,
8,
1
]
}
},
"element": "u16",
"row_offset": 0,
"row_elements": 4,
"row_pitch": 8,
"rows": 64,
"image_pitch": 512,
"images": 1,
"gaps": "ignored"
}
}
}
},
{
"name": "notices",
"observed": {
"value": "absent"
},
"children": [
{
"name": "set",
"observed": {
"value": {
"nothing": "announced_nothing"
}
}
},
{
"name": "counts",
"observed": {
"value": {
"fields": {}
}
}
}
]
}
]
}
}
}
],
"validated": "ran"
}
],
"times": [
{
"venue": "native Metal",
"chip": "apple-m3-max",
"os_build": "26A434",
"rounds": 8,
"measured": "8 round(s) of the whole selection, in the case set's own order; a figure is the median of the rounds' own medians; Metal's leg ran at a one-minute load average of 11.10",
"instrument": 231,
"times": {
"case": "compute-imageblock-slice-past-the-grid",
"calls": 5,
"in_calls": 31462875,
"on_cpu": 958584,
"blocked": 30501583,
"elsewhere": 3575750,
"spend": 35048708,
"spend_least": 34369333,
"spend_most": 44478166,
"per_call": [
{
"call": "compute_pass",
"least_calls": 1,
"most_calls": 1,
"wall": 4232083,
"on_cpu": 139666,
"blocked": 4089084,
"wall_least": 4057792,
"wall_most": 4507792,
"wall_total": 4232083,
"on_cpu_total": 139666,
"blocked_total": 4089084
},
{
"call": "compute_pipeline",
"least_calls": 1,
"most_calls": 1,
"wall": 106500,
"on_cpu": 106708,
"blocked": 0,
"wall_least": 92291,
"wall_most": 1042583,
"wall_total": 106500,
"on_cpu_total": 106708,
"blocked_total": 0
},
{
"call": "library",
"least_calls": 1,
"most_calls": 1,
"wall": 27078750,
"on_cpu": 646583,
"blocked": 26401917,
"wall_least": 26175250,
"wall_most": 36828500,
"wall_total": 27078750,
"on_cpu_total": 646583,
"blocked_total": 26401917
},
{
"call": "read_texture",
"least_calls": 1,
"most_calls": 1,
"wall": 3000,
"on_cpu": 3250,
"blocked": 0,
"wall_least": 2667,
"wall_most": 4833,
"wall_total": 3000,
"on_cpu_total": 3250,
"blocked_total": 0
},
{
"call": "texture_2d_in_role",
"least_calls": 1,
"most_calls": 1,
"wall": 42250,
"on_cpu": 42459,
"blocked": 0,
"wall_least": 36584,
"wall_most": 59334,
"wall_total": 42250,
"on_cpu_total": 42459,
"blocked_total": 0
}
]
}
}
]
}
File diff suppressed because it is too large. Load diff
@@ -0,0 +1,423 @@
{
"format": 1,
"case": "indirect-range-gpu-written-indexed-patch-draws",
"suite_version": 1,
"shaders": [
{
"fixture": "icb_merged_ipatches.ll",
"entry": "icb_merged_ipatches",
"source_sha256": "b25e68cedf24679d06f1c9c5b578dd24f9a6765c2730fe64c6748ec5ad9b8a94"
},
{
"fixture": "icb_merged_ipatches.air.ll",
"entry": "icb_merged_ipatches",
"source_sha256": "2e5e19c3a9c01d97e61c6ce7a55ecda1bb1cf7f5d078a5333db1f022ae68bf15"
},
{
"fixture": "icb_merged_ipatches.ll",
"entry": "icb_merged_ipatch_vertex",
"source_sha256": "b25e68cedf24679d06f1c9c5b578dd24f9a6765c2730fe64c6748ec5ad9b8a94"
},
{
"fixture": "icb_merged_ipatches.air.ll",
"entry": "icb_merged_ipatch_vertex",
"source_sha256": "2e5e19c3a9c01d97e61c6ce7a55ecda1bb1cf7f5d078a5333db1f022ae68bf15"
},
{
"fixture": "icb_merged_ipatches.ll",
"entry": "icb_merged_ipatch_fragment",
"source_sha256": "b25e68cedf24679d06f1c9c5b578dd24f9a6765c2730fe64c6748ec5ad9b8a94"
},
{
"fixture": "icb_merged_ipatches.air.ll",
"entry": "icb_merged_ipatch_fragment",
"source_sha256": "2e5e19c3a9c01d97e61c6ce7a55ecda1bb1cf7f5d078a5333db1f022ae68bf15"
}
],
"answers": [
{
"key": {
"chip": "apple-m3-max",
"os_version": "27.0.1",
"os_build": "26A434",
"metal_level": "27.0.1"
},
"provenance": "metal_run",
"device": "Apple M3 Max",
"runs": 3,
"outcomes": [
{
"runs": 3,
"transcript": {
"root": {
"name": "case",
"observed": {
"value": "absent"
},
"children": [
{
"name": "inputs",
"observed": {
"value": "absent"
},
"children": [
{
"name": "air",
"observed": {
"value": "absent",
"digest": {
"kind": "sha256",
"hex": "b25e68cedf24679d06f1c9c5b578dd24f9a6765c2730fe64c6748ec5ad9b8a94"
}
}
},
{
"name": "air-typed",
"observed": {
"value": "absent",
"digest": {
"kind": "sha256",
"hex": "2e5e19c3a9c01d97e61c6ce7a55ecda1bb1cf7f5d078a5333db1f022ae68bf15"
}
}
},
{
"name": "buffer:draws",
"observed": {
"value": "absent",
"digest": {
"kind": "sha256",
"hex": "0ce15fd22a62915fa73eb0f74d4591d48fbac3a3a7dd63add596ed5b943412d2"
}
}
},
{
"name": "buffer:marks",
"observed": {
"value": "absent",
"digest": {
"kind": "sha256",
"hex": "2c050a4484712374bc0061534a9607f09e7bfa43dc246463b34d80eef0210fe7"
}
}
},
{
"name": "buffer:frame",
"observed": {
"value": "absent",
"digest": {
"kind": "sha256",
"hex": "b7013c015db61a3fe79e6983697779e6f0d0cfa795ace130f2401424d94011c6"
}
}
},
{
"name": "buffer:corners",
"observed": {
"value": "absent",
"digest": {
"kind": "sha256",
"hex": "8387c9b2878550caca811c4689d84a51a39d96acd7883990dcafe6ce0c31ff36"
}
}
},
{
"name": "buffer:points",
"observed": {
"value": "absent",
"digest": {
"kind": "sha256",
"hex": "141f3df317a7b672aacc4d44f1571d23abbc11b483ee9e66678f5f2eb2f69184"
}
}
},
{
"name": "buffer:factors",
"observed": {
"value": "absent",
"digest": {
"kind": "sha256",
"hex": "6b915313f9a35aa1187c128f7a0b39416b7dde4a3c97d63fa1b1715a6630bd95"
}
}
},
{
"name": "buffer:range",
"observed": {
"value": "absent",
"digest": {
"kind": "sha256",
"hex": "dbec72d7af153cd0a8a4b33054d8ea7329136a5fc88f017d984653e93ce0b4a4"
}
}
},
{
"name": "buffer:copied-range",
"observed": {
"value": "absent",
"digest": {
"kind": "sha256",
"hex": "eca75f8497701d6223817cde38bf42cdd1124e01ef6b705bcfe9a584f7b42f0f"
}
}
},
{
"name": "execution",
"observed": {
"value": "absent",
"digest": {
"kind": "sha256",
"hex": "ad2aac34e8f61b894e782c47a2726c16f0dbbdf9789d95c68247c828bbad2621"
}
}
}
]
},
{
"name": "library",
"observed": {
"value": {
"variant": {
"name": "Ok",
"payload": "absent"
}
}
}
},
{
"name": "buffer:draws",
"observed": {
"value": {
"variant": {
"name": "Ok",
"payload": "absent"
}
}
}
},
{
"name": "buffer:marks",
"observed": {
"value": {
"variant": {
"name": "Ok",
"payload": "absent"
}
}
}
},
{
"name": "buffer:frame",
"observed": {
"value": {
"variant": {
"name": "Ok",
"payload": "absent"
}
}
}
},
{
"name": "buffer:corners",
"observed": {
"value": {
"variant": {
"name": "Ok",
"payload": "absent"
}
}
}
},
{
"name": "buffer:points",
"observed": {
"value": {
"variant": {
"name": "Ok",
"payload": "absent"
}
}
}
},
{
"name": "buffer:factors",
"observed": {
"value": {
"variant": {
"name": "Ok",
"payload": "absent"
}
}
}
},
{
"name": "buffer:range",
"observed": {
"value": {
"variant": {
"name": "Ok",
"payload": "absent"
}
}
}
},
{
"name": "buffer:copied-range",
"observed": {
"value": {
"variant": {
"name": "Ok",
"payload": "absent"
}
}
}
},
{
"name": "execution",
"observed": {
"value": {
"variant": {
"name": "Ok",
"payload": {
"variant": {
"name": "Completed",
"payload": "absent"
}
}
}
}
}
},
{
"name": "target-texels",
"observed": {
"value": {
"bytes": "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEBAAABAAAAAgAAAAEAAAABAQAAAQAAAAIAAAABAAAAAQEAAAEAAAACAAAAAQAAAAEBAAABAAAAAgAAAAEAAAABAQAAAQAAAAIAAAABAAAAAQEAAAEAAAACAAAAAQAAAAEBAAABAAAAAgAAAAEAAAABAQAAAQAAAAIAAAABAAAAAQEAAAEAAAACAAAAAQAAAAEBAAABAAAAAgAAAAEAAAABAQAAAQAAAAIAAAABAAAAAQEAAAEAAAACAAAAAQAAAAEBAAABAAAAAgAAAAEAAAABAQAAAQAAAAIAAAABAAAAAQEAAAEAAAACAAAAAQAAAAEBAAABAAAAAgAAAAEAAAACAQAAAgAAAAIAAAACAAAAAgEAAAIAAAACAAAAAgAAAAIBAAACAAAAAgAAAAIAAAACAQAAAgAAAAIAAAACAAAAAgEAAAIAAAACAAAAAgAAAAIBAAACAAAAAgAAAAIAAAACAQAAAgAAAAIAAAACAAAAAgEAAAIAAAACAAAAAgAAAAIBAAACAAAAAgAAAAIAAAACAQAAAgAAAAIAAAACAAAAAgEAAAIAAAACAAAAAgAAAAIBAAACAAAAAgAAAAIAAAACAQAAAgAAAAIAAAACAAAAAgEAAAIAAAACAAAAAgAAAAIBAAACAAAAAgAAAAIAAAACAQAAAgAAAAIAAAACAAAAAwEAAAMAAAAEAAAAAwAAAAMBAAADAAAABAAAAAMAAAADAQAAAwAAAAQAAAADAAAAAwEAAAMAAAAEAAAAAwAAAAMBAAADAAAABAAAAAMAAAADAQAAAwAAAAQAAAADAAAAAwEAAAMAAAAEAAAAAwAAAAMBAAADAAAABAAAAAMAAAADAQAAAwAAAAQAAAADAAAAAwEAAAMAAAAEAAAAAwAAAAMBAAADAAAABAAAAAMAAAADAQAAAwAAAAQAAAADAAAAAwEAAAMAAAAEAAAAAwAAAAMBAAADAAAABAAAAAMAAAADAQAAAwAAAAQAAAADAAAAAwEAAAMAAAAEAAAAAwAAAAQBAAAEAAAABAAAAAQAAAAEAQAABAAAAAQAAAAEAAAABAEAAAQAAAAEAAAABAAAAAQBAAAEAAAABAAAAAQAAAAEAQAABAAAAAQAAAAEAAAABAEAAAQAAAAEAAAABAAAAAQBAAAEAAAABAAAAAQAAAAEAQAABAAAAAQAAAAEAAAABAEAAAQAAAAEAAAABAAAAAQBAAAEAAAABAAAAAQAAAAEAQAABAAAAAQAAAAEAAAABAEAAAQAAAAEAAAABAAAAAQBAAAEAAAABAAAAAQAAAAEAQAABAAAAAQAAAAEAAAABAEAAAQAAAAEAAAABAAAAAQBAAAEAAAABAAAAAQAAAAFAQAABQAAAAYAAAAFAAAABQEAAAUAAAAGAAAABQAAAAUBAAAFAAAABgAAAAUAAAAFAQAABQAAAAYAAAAFAAAABQEAAAUAAAAGAAAABQAAAAUBAAAFAAAABgAAAAUAAAAFAQAABQAAAAYAAAAFAAAABQEAAAUAAAAGAAAABQAAAAUBAAAFAAAABgAAAAUAAAAFAQAABQAAAAYAAAAFAAAABQEAAAUAAAAGAAAABQAAAAUBAAAFAAAABgAAAAUAAAAFAQAABQAAAAYAAAAFAAAABQEAAAUAAAAGAAAABQAAAAUBAAAFAAAABgAAAAUAAAAFAQAABQAAAAYAAAAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA="
},
"shape": {
"bytes": {
"region": {
"texture": {
"level": 0,
"slice": 0,
"aspect": "color",
"sample": 0,
"origin": [
0,
0,
0
],
"size": [
8,
16,
1
]
}
},
"element": "u32",
"row_offset": 0,
"row_elements": 32,
"row_pitch": 128,
"rows": 16,
"image_pitch": 2048,
"images": 1,
"gaps": "compared"
}
}
}
},
{
"name": "notices",
"observed": {
"value": "absent"
},
"children": [
{
"name": "set",
"observed": {
"value": {
"nothing": "announced_nothing"
}
}
},
{
"name": "counts",
"observed": {
"value": {
"fields": {}
}
}
}
]
}
]
}
}
}
],
"validated": "ran"
}
],
"times": [
{
"venue": "native Metal",
"chip": "apple-m3-max",
"os_build": "26A434",
"rounds": 8,
"measured": "8 round(s) of the whole selection, in the case set's own order; a figure is the median of the rounds' own medians; Metal's leg ran at a one-minute load average of 10.54",
"instrument": 241,
"times": {
"case": "indirect-range-gpu-written-indexed-patch-draws",
"calls": 10,
"in_calls": 36194957,
"on_cpu": 1482498,
"blocked": 34785959,
"elsewhere": 8260000,
"spend": 44425792,
"spend_least": 43452459,
"spend_most": 46478627,
"per_call": [
{
"call": "buffer",
"least_calls": 8,
"most_calls": 8,
"wall": 2125,
"on_cpu": 2250,
"blocked": 0,
"wall_least": 1875,
"wall_most": 2750,
"wall_total": 46791,
"on_cpu_total": 48251,
"blocked_total": 0
},
{
"call": "encoded_range",
"least_calls": 1,
"most_calls": 1,
"wall": 9653625,
"on_cpu": 689792,
"blocked": 8828708,
"wall_least": 9103125,
"wall_most": 10684500,
"wall_total": 9653625,
"on_cpu_total": 689792,
"blocked_total": 8828708
},
{
"call": "library",
"least_calls": 1,
"most_calls": 1,
"wall": 26477750,
"on_cpu": 708084,
"blocked": 25811625,
"wall_least": 26255917,
"wall_most": 28317958,
"wall_total": 26477750,
"on_cpu_total": 708084,
"blocked_total": 25811625
}
]
}
}
]
}
@@ -0,0 +1,402 @@
{
"format": 1,
"case": "indirect-range-gpu-written-patch-draws",
"suite_version": 1,
"shaders": [
{
"fixture": "icb_merged_patches.ll",
"entry": "icb_merged_patches",
"source_sha256": "d71808b60017fb10c3b4cfcbc94106c0e463042539a5a7b167aebc68a6b9f0d6"
},
{
"fixture": "icb_merged_patches.air.ll",
"entry": "icb_merged_patches",
"source_sha256": "aad671f3480a454481577e25ee2c86d43b2b7cce5971456b1454319c59909219"
},
{
"fixture": "icb_merged_patches.ll",
"entry": "icb_merged_patch_vertex",
"source_sha256": "d71808b60017fb10c3b4cfcbc94106c0e463042539a5a7b167aebc68a6b9f0d6"
},
{
"fixture": "icb_merged_patches.air.ll",
"entry": "icb_merged_patch_vertex",
"source_sha256": "aad671f3480a454481577e25ee2c86d43b2b7cce5971456b1454319c59909219"
},
{
"fixture": "icb_merged_patches.ll",
"entry": "icb_merged_patch_fragment",
"source_sha256": "d71808b60017fb10c3b4cfcbc94106c0e463042539a5a7b167aebc68a6b9f0d6"
},
{
"fixture": "icb_merged_patches.air.ll",
"entry": "icb_merged_patch_fragment",
"source_sha256": "aad671f3480a454481577e25ee2c86d43b2b7cce5971456b1454319c59909219"
}
],
"answers": [
{
"key": {
"chip": "apple-m3-max",
"os_version": "27.0.1",
"os_build": "26A434",
"metal_level": "27.0.1"
},
"provenance": "metal_run",
"device": "Apple M3 Max",
"runs": 3,
"outcomes": [
{
"runs": 3,
"transcript": {
"root": {
"name": "case",
"observed": {
"value": "absent"
},
"children": [
{
"name": "inputs",
"observed": {
"value": "absent"
},
"children": [
{
"name": "air",
"observed": {
"value": "absent",
"digest": {
"kind": "sha256",
"hex": "d71808b60017fb10c3b4cfcbc94106c0e463042539a5a7b167aebc68a6b9f0d6"
}
}
},
{
"name": "air-typed",
"observed": {
"value": "absent",
"digest": {
"kind": "sha256",
"hex": "aad671f3480a454481577e25ee2c86d43b2b7cce5971456b1454319c59909219"
}
}
},
{
"name": "buffer:draws",
"observed": {
"value": "absent",
"digest": {
"kind": "sha256",
"hex": "0ce15fd22a62915fa73eb0f74d4591d48fbac3a3a7dd63add596ed5b943412d2"
}
}
},
{
"name": "buffer:marks",
"observed": {
"value": "absent",
"digest": {
"kind": "sha256",
"hex": "2c050a4484712374bc0061534a9607f09e7bfa43dc246463b34d80eef0210fe7"
}
}
},
{
"name": "buffer:frame",
"observed": {
"value": "absent",
"digest": {
"kind": "sha256",
"hex": "b7013c015db61a3fe79e6983697779e6f0d0cfa795ace130f2401424d94011c6"
}
}
},
{
"name": "buffer:xy",
"observed": {
"value": "absent",
"digest": {
"kind": "sha256",
"hex": "06eb16ee0c7fb7d2cce6f2d22c05ca75d3f43c96acd50cc50faa0b5cdaf67d0f"
}
}
},
{
"name": "buffer:factors",
"observed": {
"value": "absent",
"digest": {
"kind": "sha256",
"hex": "6b915313f9a35aa1187c128f7a0b39416b7dde4a3c97d63fa1b1715a6630bd95"
}
}
},
{
"name": "buffer:range",
"observed": {
"value": "absent",
"digest": {
"kind": "sha256",
"hex": "dbec72d7af153cd0a8a4b33054d8ea7329136a5fc88f017d984653e93ce0b4a4"
}
}
},
{
"name": "buffer:copied-range",
"observed": {
"value": "absent",
"digest": {
"kind": "sha256",
"hex": "eca75f8497701d6223817cde38bf42cdd1124e01ef6b705bcfe9a584f7b42f0f"
}
}
},
{
"name": "execution",
"observed": {
"value": "absent",
"digest": {
"kind": "sha256",
"hex": "47e37f4716e5483692d2930763ef674b40ebc015261a335cd1561a971ecab4fb"
}
}
}
]
},
{
"name": "library",
"observed": {
"value": {
"variant": {
"name": "Ok",
"payload": "absent"
}
}
}
},
{
"name": "buffer:draws",
"observed": {
"value": {
"variant": {
"name": "Ok",
"payload": "absent"
}
}
}
},
{
"name": "buffer:marks",
"observed": {
"value": {
"variant": {
"name": "Ok",
"payload": "absent"
}
}
}
},
{
"name": "buffer:frame",
"observed": {
"value": {
"variant": {
"name": "Ok",
"payload": "absent"
}
}
}
},
{
"name": "buffer:xy",
"observed": {
"value": {
"variant": {
"name": "Ok",
"payload": "absent"
}
}
}
},
{
"name": "buffer:factors",
"observed": {
"value": {
"variant": {
"name": "Ok",
"payload": "absent"
}
}
}
},
{
"name": "buffer:range",
"observed": {
"value": {
"variant": {
"name": "Ok",
"payload": "absent"
}
}
}
},
{
"name": "buffer:copied-range",
"observed": {
"value": {
"variant": {
"name": "Ok",
"payload": "absent"
}
}
}
},
{
"name": "execution",
"observed": {
"value": {
"variant": {
"name": "Ok",
"payload": {
"variant": {
"name": "Completed",
"payload": "absent"
}
}
}
}
}
},
{
"name": "target-texels",
"observed": {
"value": {
"bytes": "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEBAAABAAAAAgAAAAEAAAABAQAAAQAAAAIAAAABAAAAAQEAAAEAAAACAAAAAQAAAAEBAAABAAAAAgAAAAEAAAABAQAAAQAAAAIAAAABAAAAAQEAAAEAAAACAAAAAQAAAAEBAAABAAAAAgAAAAEAAAABAQAAAQAAAAIAAAABAAAAAQEAAAEAAAACAAAAAQAAAAEBAAABAAAAAgAAAAEAAAABAQAAAQAAAAIAAAABAAAAAQEAAAEAAAACAAAAAQAAAAEBAAABAAAAAgAAAAEAAAABAQAAAQAAAAIAAAABAAAAAQEAAAEAAAACAAAAAQAAAAEBAAABAAAAAgAAAAEAAAACAQAAAgAAAAIAAAACAAAAAgEAAAIAAAACAAAAAgAAAAIBAAACAAAAAgAAAAIAAAACAQAAAgAAAAIAAAACAAAAAgEAAAIAAAACAAAAAgAAAAIBAAACAAAAAgAAAAIAAAACAQAAAgAAAAIAAAACAAAAAgEAAAIAAAACAAAAAgAAAAIBAAACAAAAAgAAAAIAAAACAQAAAgAAAAIAAAACAAAAAgEAAAIAAAACAAAAAgAAAAIBAAACAAAAAgAAAAIAAAACAQAAAgAAAAIAAAACAAAAAgEAAAIAAAACAAAAAgAAAAIBAAACAAAAAgAAAAIAAAACAQAAAgAAAAIAAAACAAAAAwEAAAMAAAAEAAAAAwAAAAMBAAADAAAABAAAAAMAAAADAQAAAwAAAAQAAAADAAAAAwEAAAMAAAAEAAAAAwAAAAMBAAADAAAABAAAAAMAAAADAQAAAwAAAAQAAAADAAAAAwEAAAMAAAAEAAAAAwAAAAMBAAADAAAABAAAAAMAAAADAQAAAwAAAAQAAAADAAAAAwEAAAMAAAAEAAAAAwAAAAMBAAADAAAABAAAAAMAAAADAQAAAwAAAAQAAAADAAAAAwEAAAMAAAAEAAAAAwAAAAMBAAADAAAABAAAAAMAAAADAQAAAwAAAAQAAAADAAAAAwEAAAMAAAAEAAAAAwAAAAQBAAAEAAAABAAAAAQAAAAEAQAABAAAAAQAAAAEAAAABAEAAAQAAAAEAAAABAAAAAQBAAAEAAAABAAAAAQAAAAEAQAABAAAAAQAAAAEAAAABAEAAAQAAAAEAAAABAAAAAQBAAAEAAAABAAAAAQAAAAEAQAABAAAAAQAAAAEAAAABAEAAAQAAAAEAAAABAAAAAQBAAAEAAAABAAAAAQAAAAEAQAABAAAAAQAAAAEAAAABAEAAAQAAAAEAAAABAAAAAQBAAAEAAAABAAAAAQAAAAEAQAABAAAAAQAAAAEAAAABAEAAAQAAAAEAAAABAAAAAQBAAAEAAAABAAAAAQAAAAFAQAABQAAAAYAAAAFAAAABQEAAAUAAAAGAAAABQAAAAUBAAAFAAAABgAAAAUAAAAFAQAABQAAAAYAAAAFAAAABQEAAAUAAAAGAAAABQAAAAUBAAAFAAAABgAAAAUAAAAFAQAABQAAAAYAAAAFAAAABQEAAAUAAAAGAAAABQAAAAUBAAAFAAAABgAAAAUAAAAFAQAABQAAAAYAAAAFAAAABQEAAAUAAAAGAAAABQAAAAUBAAAFAAAABgAAAAUAAAAFAQAABQAAAAYAAAAFAAAABQEAAAUAAAAGAAAABQAAAAUBAAAFAAAABgAAAAUAAAAFAQAABQAAAAYAAAAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA="
},
"shape": {
"bytes": {
"region": {
"texture": {
"level": 0,
"slice": 0,
"aspect": "color",
"sample": 0,
"origin": [
0,
0,
0
],
"size": [
8,
16,
1
]
}
},
"element": "u32",
"row_offset": 0,
"row_elements": 32,
"row_pitch": 128,
"rows": 16,
"image_pitch": 2048,
"images": 1,
"gaps": "compared"
}
}
}
},
{
"name": "notices",
"observed": {
"value": "absent"
},
"children": [
{
"name": "set",
"observed": {
"value": {
"nothing": "announced_nothing"
}
}
},
{
"name": "counts",
"observed": {
"value": {
"fields": {}
}
}
}
]
}
]
}
}
}
],
"validated": "ran"
}
],
"times": [
{
"venue": "native Metal",
"chip": "apple-m3-max",
"os_build": "26A434",
"rounds": 8,
"measured": "8 round(s) of the whole selection, in the case set's own order; a figure is the median of the rounds' own medians; Metal's leg ran at a one-minute load average of 9.22",
"instrument": 243,
"times": {
"case": "indirect-range-gpu-written-patch-draws",
"calls": 9,
"in_calls": 35987916,
"on_cpu": 1301625,
"blocked": 34623584,
"elsewhere": 8263083,
"spend": 44553706,
"spend_least": 43017916,
"spend_most": 51074958,
"per_call": [
{
"call": "buffer",
"least_calls": 7,
"most_calls": 7,
"wall": 2083,
"on_cpu": 2209,
"blocked": 0,
"wall_least": 1791,
"wall_most": 2459,
"wall_total": 41790,
"on_cpu_total": 42750,
"blocked_total": 0
},
{
"call": "encoded_range",
"least_calls": 1,
"most_calls": 1,
"wall": 9405375,
"on_cpu": 617625,
"blocked": 8797958,
"wall_least": 8986208,
"wall_most": 11068625,
"wall_total": 9405375,
"on_cpu_total": 617625,
"blocked_total": 8797958
},
{
"call": "library",
"least_calls": 1,
"most_calls": 1,
"wall": 26239083,
"on_cpu": 640542,
"blocked": 25567583,
"wall_least": 25508041,
"wall_most": 33501292,
"wall_total": 26239083,
"on_cpu_total": 640542,
"blocked_total": 25567583
}
]
}
}
]
}
@@ -0,0 +1,381 @@
{
"format": 1,
"case": "indirect-range-gpu-written-plain-draws",
"suite_version": 1,
"shaders": [
{
"fixture": "icb_merged_draws.ll",
"entry": "icb_merged_triangles",
"source_sha256": "62094586abf5f2e8b34451370f2110e510800d5f154fa05c3ad6726fda571ada"
},
{
"fixture": "icb_merged_draws.air.ll",
"entry": "icb_merged_triangles",
"source_sha256": "057557b1e38d8813b3b8284419f1ab80da59e0ba5736543e3dc3cff4ca48d622"
},
{
"fixture": "icb_merged_draws.ll",
"entry": "icb_merged_vertex",
"source_sha256": "62094586abf5f2e8b34451370f2110e510800d5f154fa05c3ad6726fda571ada"
},
{
"fixture": "icb_merged_draws.air.ll",
"entry": "icb_merged_vertex",
"source_sha256": "057557b1e38d8813b3b8284419f1ab80da59e0ba5736543e3dc3cff4ca48d622"
},
{
"fixture": "icb_merged_draws.ll",
"entry": "icb_merged_fragment",
"source_sha256": "62094586abf5f2e8b34451370f2110e510800d5f154fa05c3ad6726fda571ada"
},
{
"fixture": "icb_merged_draws.air.ll",
"entry": "icb_merged_fragment",
"source_sha256": "057557b1e38d8813b3b8284419f1ab80da59e0ba5736543e3dc3cff4ca48d622"
}
],
"answers": [
{
"key": {
"chip": "apple-m3-max",
"os_version": "27.0.1",
"os_build": "26A434",
"metal_level": "27.0.1"
},
"provenance": "metal_run",
"device": "Apple M3 Max",
"runs": 3,
"outcomes": [
{
"runs": 3,
"transcript": {
"root": {
"name": "case",
"observed": {
"value": "absent"
},
"children": [
{
"name": "inputs",
"observed": {
"value": "absent"
},
"children": [
{
"name": "air",
"observed": {
"value": "absent",
"digest": {
"kind": "sha256",
"hex": "62094586abf5f2e8b34451370f2110e510800d5f154fa05c3ad6726fda571ada"
}
}
},
{
"name": "air-typed",
"observed": {
"value": "absent",
"digest": {
"kind": "sha256",
"hex": "057557b1e38d8813b3b8284419f1ab80da59e0ba5736543e3dc3cff4ca48d622"
}
}
},
{
"name": "buffer:draws",
"observed": {
"value": "absent",
"digest": {
"kind": "sha256",
"hex": "a218b20cc7cb7430a0252189ca31754adb8261576bacf865b0476c1eeaaa5a2c"
}
}
},
{
"name": "buffer:marks",
"observed": {
"value": "absent",
"digest": {
"kind": "sha256",
"hex": "2c050a4484712374bc0061534a9607f09e7bfa43dc246463b34d80eef0210fe7"
}
}
},
{
"name": "buffer:frame",
"observed": {
"value": "absent",
"digest": {
"kind": "sha256",
"hex": "b7013c015db61a3fe79e6983697779e6f0d0cfa795ace130f2401424d94011c6"
}
}
},
{
"name": "buffer:xy",
"observed": {
"value": "absent",
"digest": {
"kind": "sha256",
"hex": "2d1d34182af3ad3e082d0e0a210b30b782c1a506581fedd15b40447e2414c721"
}
}
},
{
"name": "buffer:range",
"observed": {
"value": "absent",
"digest": {
"kind": "sha256",
"hex": "dbec72d7af153cd0a8a4b33054d8ea7329136a5fc88f017d984653e93ce0b4a4"
}
}
},
{
"name": "buffer:copied-range",
"observed": {
"value": "absent",
"digest": {
"kind": "sha256",
"hex": "eca75f8497701d6223817cde38bf42cdd1124e01ef6b705bcfe9a584f7b42f0f"
}
}
},
{
"name": "execution",
"observed": {
"value": "absent",
"digest": {
"kind": "sha256",
"hex": "38a4728ce077a3a098320db29a766b6b7e727f063d0c724a232e1895a88507c9"
}
}
}
]
},
{
"name": "library",
"observed": {
"value": {
"variant": {
"name": "Ok",
"payload": "absent"
}
}
}
},
{
"name": "buffer:draws",
"observed": {
"value": {
"variant": {
"name": "Ok",
"payload": "absent"
}
}
}
},
{
"name": "buffer:marks",
"observed": {
"value": {
"variant": {
"name": "Ok",
"payload": "absent"
}
}
}
},
{
"name": "buffer:frame",
"observed": {
"value": {
"variant": {
"name": "Ok",
"payload": "absent"
}
}
}
},
{
"name": "buffer:xy",
"observed": {
"value": {
"variant": {
"name": "Ok",
"payload": "absent"
}
}
}
},
{
"name": "buffer:range",
"observed": {
"value": {
"variant": {
"name": "Ok",
"payload": "absent"
}
}
}
},
{
"name": "buffer:copied-range",
"observed": {
"value": {
"variant": {
"name": "Ok",
"payload": "absent"
}
}
}
},
{
"name": "execution",
"observed": {
"value": {
"variant": {
"name": "Ok",
"payload": {
"variant": {
"name": "Completed",
"payload": "absent"
}
}
}
}
}
},
{
"name": "target-texels",
"observed": {
"value": {
"bytes": "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEBAAAGAAAAAgAAAAEAAAABAQAABgAAAAIAAAABAAAAAQEAAAYAAAACAAAAAQAAAAEBAAAGAAAAAgAAAAEAAAABAQAABgAAAAIAAAABAAAAAQEAAAYAAAACAAAAAQAAAAEBAAAJAAAAAgAAAAEAAAABAQAACQAAAAIAAAABAAAAAQEAAAYAAAACAAAAAQAAAAEBAAAGAAAAAgAAAAEAAAABAQAACQAAAAIAAAABAAAAAQEAAAkAAAACAAAAAQAAAAEBAAAJAAAAAgAAAAEAAAABAQAACQAAAAIAAAABAAAAAQEAAAkAAAACAAAAAQAAAAEBAAAJAAAAAgAAAAEAAAACAQAADAAAAAIAAAACAAAAAgEAAAwAAAACAAAAAgAAAAIBAAAMAAAAAgAAAAIAAAACAQAADAAAAAIAAAACAAAAAgEAAAwAAAACAAAAAgAAAAIBAAAMAAAAAgAAAAIAAAACAQAADwAAAAIAAAACAAAAAgEAAA8AAAACAAAAAgAAAAIBAAAMAAAAAgAAAAIAAAACAQAADAAAAAIAAAACAAAAAgEAAA8AAAACAAAAAgAAAAIBAAAPAAAAAgAAAAIAAAACAQAADwAAAAIAAAACAAAAAgEAAA8AAAACAAAAAgAAAAIBAAAPAAAAAgAAAAIAAAACAQAADwAAAAIAAAACAAAAAwEAABIAAAAEAAAAAwAAAAMBAAASAAAABAAAAAMAAAADAQAAEgAAAAQAAAADAAAAAwEAABIAAAAEAAAAAwAAAAMBAAASAAAABAAAAAMAAAADAQAAEgAAAAQAAAADAAAAAwEAABUAAAAEAAAAAwAAAAMBAAAVAAAABAAAAAMAAAADAQAAEgAAAAQAAAADAAAAAwEAABIAAAAEAAAAAwAAAAMBAAAVAAAABAAAAAMAAAADAQAAFQAAAAQAAAADAAAAAwEAABUAAAAEAAAAAwAAAAMBAAAVAAAABAAAAAMAAAADAQAAFQAAAAQAAAADAAAAAwEAABUAAAAEAAAAAwAAAAQBAAAYAAAABAAAAAQAAAAEAQAAGAAAAAQAAAAEAAAABAEAABgAAAAEAAAABAAAAAQBAAAYAAAABAAAAAQAAAAEAQAAGAAAAAQAAAAEAAAABAEAABgAAAAEAAAABAAAAAQBAAAbAAAABAAAAAQAAAAEAQAAGwAAAAQAAAAEAAAABAEAABgAAAAEAAAABAAAAAQBAAAYAAAABAAAAAQAAAAEAQAAGwAAAAQAAAAEAAAABAEAABsAAAAEAAAABAAAAAQBAAAbAAAABAAAAAQAAAAEAQAAGwAAAAQAAAAEAAAABAEAABsAAAAEAAAABAAAAAQBAAAbAAAABAAAAAQAAAAFAQAAHgAAAAYAAAAFAAAABQEAAB4AAAAGAAAABQAAAAUBAAAeAAAABgAAAAUAAAAFAQAAHgAAAAYAAAAFAAAABQEAAB4AAAAGAAAABQAAAAUBAAAeAAAABgAAAAUAAAAFAQAAIQAAAAYAAAAFAAAABQEAACEAAAAGAAAABQAAAAUBAAAeAAAABgAAAAUAAAAFAQAAHgAAAAYAAAAFAAAABQEAACEAAAAGAAAABQAAAAUBAAAhAAAABgAAAAUAAAAFAQAAIQAAAAYAAAAFAAAABQEAACEAAAAGAAAABQAAAAUBAAAhAAAABgAAAAUAAAAFAQAAIQAAAAYAAAAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA="
},
"shape": {
"bytes": {
"region": {
"texture": {
"level": 0,
"slice": 0,
"aspect": "color",
"sample": 0,
"origin": [
0,
0,
0
],
"size": [
8,
16,
1
]
}
},
"element": "u32",
"row_offset": 0,
"row_elements": 32,
"row_pitch": 128,
"rows": 16,
"image_pitch": 2048,
"images": 1,
"gaps": "compared"
}
}
}
},
{
"name": "notices",
"observed": {
"value": "absent"
},
"children": [
{
"name": "set",
"observed": {
"value": {
"nothing": "announced_nothing"
}
}
},
{
"name": "counts",
"observed": {
"value": {
"fields": {}
}
}
}
]
}
]
}
}
}
],
"validated": "ran"
}
],
"times": [
{
"venue": "native Metal",
"chip": "apple-m3-max",
"os_build": "26A434",
"rounds": 8,
"measured": "8 round(s) of the whole selection, in the case set's own order; a figure is the median of the rounds' own medians; Metal's leg ran at a one-minute load average of 8.69",
"instrument": 335,
"times": {
"case": "indirect-range-gpu-written-plain-draws",
"calls": 8,
"in_calls": 35681583,
"on_cpu": 1324710,
"blocked": 34355668,
"elsewhere": 8006709,
"spend": 43671958,
"spend_least": 43513917,
"spend_most": 360937126,
"per_call": [
{
"call": "buffer",
"least_calls": 6,
"most_calls": 6,
"wall": 2125,
"on_cpu": 2250,
"blocked": 0,
"wall_least": 2000,
"wall_most": 3958,
"wall_total": 37083,
"on_cpu_total": 38044,
"blocked_total": 0
},
{
"call": "encoded_range",
"least_calls": 1,
"most_calls": 1,
"wall": 9033125,
"on_cpu": 643250,
"blocked": 8376667,
"wall_least": 8846333,
"wall_most": 12209583,
"wall_total": 9033125,
"on_cpu_total": 643250,
"blocked_total": 8376667
},
{
"call": "library",
"least_calls": 1,
"most_calls": 1,
"wall": 26798167,
"on_cpu": 659500,
"blocked": 26109209,
"wall_least": 26143667,
"wall_most": 339176584,
"wall_total": 26798167,
"on_cpu_total": 659500,
"blocked_total": 26109209
}
]
}
}
]
}
@@ -0,0 +1,239 @@
{
"format": 1,
"case": "managed-named-address-only",
"suite_version": 1,
"shaders": [
{
"fixture": "examples/runtime_examples.ll",
"entry": "scale_and_offset",
"source_sha256": "fbe310c683c1e125803f56d76f76eaceda8d4b7a7f1968715a583b8fad27c7d6"
},
{
"fixture": "examples/runtime_examples.air.ll",
"entry": "scale_and_offset",
"source_sha256": "579cc33e08cdfb18fdb85de70d8d81983d280dd737b2ed4894483ca0faa6e880"
},
{
"fixture": "ab_pointers.ll",
"entry": "ab_address",
"source_sha256": "7e51361c89fa9dc5f98df57f99923c3a734abb96253a55bf992370f088c01315"
},
{
"fixture": "ab_pointers.air.ll",
"entry": "ab_address",
"source_sha256": "1fdd7761a65caebbf70a505edfcb95c4627ae1a8a2ec5eb856adc270f18206a2"
}
],
"answers": [
{
"key": {
"chip": "apple-m3-max",
"os_version": "27.0.1",
"os_build": "26A434",
"metal_level": "27.0.1"
},
"provenance": {
"carried": {
"from": "an AMD Radeon Pro 5300M measurement under macOS 26.7.1, 8 rounds a reader (jobs 81602 and 81644), which found that a named Managed range reaches the GPU at the first commit whose encoders name the buffer, with its bytes as of that commit, and that a buffer no encoder names keeps the bytes its GPU copy last took",
"measured_on": "amd-radeon-pro-5300m"
}
},
"device": "apple-m3-max",
"runs": 8,
"outcomes": [
{
"runs": 8,
"transcript": {
"root": {
"name": "case",
"observed": {
"value": "absent"
},
"children": [
{
"name": "inputs",
"observed": {
"value": "absent"
},
"children": [
{
"name": "air:examples",
"observed": {
"value": "absent",
"digest": {
"kind": "sha256",
"hex": "fbe310c683c1e125803f56d76f76eaceda8d4b7a7f1968715a583b8fad27c7d6"
}
}
},
{
"name": "air-typed:examples",
"observed": {
"value": "absent",
"digest": {
"kind": "sha256",
"hex": "579cc33e08cdfb18fdb85de70d8d81983d280dd737b2ed4894483ca0faa6e880"
}
}
},
{
"name": "air:pointers",
"observed": {
"value": "absent",
"digest": {
"kind": "sha256",
"hex": "7e51361c89fa9dc5f98df57f99923c3a734abb96253a55bf992370f088c01315"
}
}
},
{
"name": "air-typed:pointers",
"observed": {
"value": "absent",
"digest": {
"kind": "sha256",
"hex": "1fdd7761a65caebbf70a505edfcb95c4627ae1a8a2ec5eb856adc270f18206a2"
}
}
},
{
"name": "contents:Synced",
"observed": {
"value": "absent",
"digest": {
"kind": "sha256",
"hex": "20c32b58f9dbd5416fe908e078a5ba1d76c369e08dc3c9d62c5c4e71ec4c9b05"
}
}
},
{
"name": "contents:Named",
"observed": {
"value": "absent",
"digest": {
"kind": "sha256",
"hex": "2391a11b1f9ea5ba826528ca3c097c8d2144c199a679efe81e425ec575ee514e"
}
}
},
{
"name": "contents:Later",
"observed": {
"value": "absent",
"digest": {
"kind": "sha256",
"hex": "a18573742f763887800bcc4744b72900125a1b2c0e4b7a5f7f894aa3f9121d72"
}
}
},
{
"name": "reader",
"observed": {
"value": "absent",
"digest": {
"kind": "sha256",
"hex": "d80c9bf910f144738ef983724bc04bd6bd3f17c5c83ed57bedee1b1b9278e811"
}
}
}
]
},
{
"name": "examples",
"observed": {
"value": {
"variant": {
"name": "Ok",
"payload": "absent"
}
}
}
},
{
"name": "pointers",
"observed": {
"value": {
"variant": {
"name": "Ok",
"payload": "absent"
}
}
}
},
{
"name": "sequence",
"observed": {
"value": {
"variant": {
"name": "Ok",
"payload": "absent"
}
}
}
},
{
"name": "reads",
"observed": {
"value": {
"lines": [
"the bytes the GPU's copy last took"
]
}
}
},
{
"name": "notices",
"observed": {
"value": "absent"
},
"children": [
{
"name": "set",
"observed": {
"value": {
"nothing": "announced_nothing"
}
}
},
{
"name": "counts",
"observed": {
"value": {
"fields": {}
}
}
}
]
}
]
}
}
}
],
"validated": "not_run"
}
],
"times": [
{
"venue": "native Metal",
"chip": "apple-m3-max",
"os_build": "26A434",
"rounds": 8,
"measured": "8 round(s) of the whole selection, in the case set's own order; a figure is the median of the rounds' own medians; Metal's leg ran at a one-minute load average of 11.59",
"instrument": 240,
"times": {
"case": "managed-named-address-only",
"calls": 0,
"in_calls": 0,
"on_cpu": 0,
"blocked": 0,
"elsewhere": 0,
"spend": 0,
"spend_least": 0,
"spend_most": 0,
"stopped": "the case forbids running its Metal leg here: the oracle keeps one copy of a Managed buffer (hasUnifiedMemory true), so its run answers what one copy holds, not which commit takes a range to a second copy",
"per_call": []
}
}
]
}
@@ -0,0 +1,239 @@
{
"format": 1,
"case": "managed-named-blit-source",
"suite_version": 1,
"shaders": [
{
"fixture": "examples/runtime_examples.ll",
"entry": "scale_and_offset",
"source_sha256": "fbe310c683c1e125803f56d76f76eaceda8d4b7a7f1968715a583b8fad27c7d6"
},
{
"fixture": "examples/runtime_examples.air.ll",
"entry": "scale_and_offset",
"source_sha256": "579cc33e08cdfb18fdb85de70d8d81983d280dd737b2ed4894483ca0faa6e880"
},
{
"fixture": "ab_pointers.ll",
"entry": "ab_address",
"source_sha256": "7e51361c89fa9dc5f98df57f99923c3a734abb96253a55bf992370f088c01315"
},
{
"fixture": "ab_pointers.air.ll",
"entry": "ab_address",
"source_sha256": "1fdd7761a65caebbf70a505edfcb95c4627ae1a8a2ec5eb856adc270f18206a2"
}
],
"answers": [
{
"key": {
"chip": "apple-m3-max",
"os_version": "27.0.1",
"os_build": "26A434",
"metal_level": "27.0.1"
},
"provenance": {
"carried": {
"from": "an AMD Radeon Pro 5300M measurement under macOS 26.7.1, 8 rounds a reader (jobs 81602 and 81644), which found that a named Managed range reaches the GPU at the first commit whose encoders name the buffer, with its bytes as of that commit, and that a buffer no encoder names keeps the bytes its GPU copy last took",
"measured_on": "amd-radeon-pro-5300m"
}
},
"device": "apple-m3-max",
"runs": 8,
"outcomes": [
{
"runs": 8,
"transcript": {
"root": {
"name": "case",
"observed": {
"value": "absent"
},
"children": [
{
"name": "inputs",
"observed": {
"value": "absent"
},
"children": [
{
"name": "air:examples",
"observed": {
"value": "absent",
"digest": {
"kind": "sha256",
"hex": "fbe310c683c1e125803f56d76f76eaceda8d4b7a7f1968715a583b8fad27c7d6"
}
}
},
{
"name": "air-typed:examples",
"observed": {
"value": "absent",
"digest": {
"kind": "sha256",
"hex": "579cc33e08cdfb18fdb85de70d8d81983d280dd737b2ed4894483ca0faa6e880"
}
}
},
{
"name": "air:pointers",
"observed": {
"value": "absent",
"digest": {
"kind": "sha256",
"hex": "7e51361c89fa9dc5f98df57f99923c3a734abb96253a55bf992370f088c01315"
}
}
},
{
"name": "air-typed:pointers",
"observed": {
"value": "absent",
"digest": {
"kind": "sha256",
"hex": "1fdd7761a65caebbf70a505edfcb95c4627ae1a8a2ec5eb856adc270f18206a2"
}
}
},
{
"name": "contents:Synced",
"observed": {
"value": "absent",
"digest": {
"kind": "sha256",
"hex": "20c32b58f9dbd5416fe908e078a5ba1d76c369e08dc3c9d62c5c4e71ec4c9b05"
}
}
},
{
"name": "contents:Named",
"observed": {
"value": "absent",
"digest": {
"kind": "sha256",
"hex": "2391a11b1f9ea5ba826528ca3c097c8d2144c199a679efe81e425ec575ee514e"
}
}
},
{
"name": "contents:Later",
"observed": {
"value": "absent",
"digest": {
"kind": "sha256",
"hex": "a18573742f763887800bcc4744b72900125a1b2c0e4b7a5f7f894aa3f9121d72"
}
}
},
{
"name": "reader",
"observed": {
"value": "absent",
"digest": {
"kind": "sha256",
"hex": "1b2e19108e54dc09c92e23b90c30f27cda0ce0147bdaaf8c3971fff9b8f730b5"
}
}
}
]
},
{
"name": "examples",
"observed": {
"value": {
"variant": {
"name": "Ok",
"payload": "absent"
}
}
}
},
{
"name": "pointers",
"observed": {
"value": {
"variant": {
"name": "Ok",
"payload": "absent"
}
}
}
},
{
"name": "sequence",
"observed": {
"value": {
"variant": {
"name": "Ok",
"payload": "absent"
}
}
}
},
{
"name": "reads",
"observed": {
"value": {
"lines": [
"the bytes as of the reader's commit"
]
}
}
},
{
"name": "notices",
"observed": {
"value": "absent"
},
"children": [
{
"name": "set",
"observed": {
"value": {
"nothing": "announced_nothing"
}
}
},
{
"name": "counts",
"observed": {
"value": {
"fields": {}
}
}
}
]
}
]
}
}
}
],
"validated": "not_run"
}
],
"times": [
{
"venue": "native Metal",
"chip": "apple-m3-max",
"os_build": "26A434",
"rounds": 8,
"measured": "8 round(s) of the whole selection, in the case set's own order; a figure is the median of the rounds' own medians; Metal's leg ran at a one-minute load average of 11.59",
"instrument": 240,
"times": {
"case": "managed-named-blit-source",
"calls": 0,
"in_calls": 0,
"on_cpu": 0,
"blocked": 0,
"elsewhere": 0,
"spend": 0,
"spend_least": 0,
"spend_most": 0,
"stopped": "the case forbids running its Metal leg here: the oracle keeps one copy of a Managed buffer (hasUnifiedMemory true), so its run answers what one copy holds, not which commit takes a range to a second copy",
"per_call": []
}
}
]
}
@@ -0,0 +1,239 @@
{
"format": 1,
"case": "managed-named-compute-slot",
"suite_version": 1,
"shaders": [
{
"fixture": "examples/runtime_examples.ll",
"entry": "scale_and_offset",
"source_sha256": "fbe310c683c1e125803f56d76f76eaceda8d4b7a7f1968715a583b8fad27c7d6"
},
{
"fixture": "examples/runtime_examples.air.ll",
"entry": "scale_and_offset",
"source_sha256": "579cc33e08cdfb18fdb85de70d8d81983d280dd737b2ed4894483ca0faa6e880"
},
{
"fixture": "ab_pointers.ll",
"entry": "ab_address",
"source_sha256": "7e51361c89fa9dc5f98df57f99923c3a734abb96253a55bf992370f088c01315"
},
{
"fixture": "ab_pointers.air.ll",
"entry": "ab_address",
"source_sha256": "1fdd7761a65caebbf70a505edfcb95c4627ae1a8a2ec5eb856adc270f18206a2"
}
],
"answers": [
{
"key": {
"chip": "apple-m3-max",
"os_version": "27.0.1",
"os_build": "26A434",
"metal_level": "27.0.1"
},
"provenance": {
"carried": {
"from": "an AMD Radeon Pro 5300M measurement under macOS 26.7.1, 8 rounds a reader (jobs 81602 and 81644), which found that a named Managed range reaches the GPU at the first commit whose encoders name the buffer, with its bytes as of that commit, and that a buffer no encoder names keeps the bytes its GPU copy last took",
"measured_on": "amd-radeon-pro-5300m"
}
},
"device": "apple-m3-max",
"runs": 8,
"outcomes": [
{
"runs": 8,
"transcript": {
"root": {
"name": "case",
"observed": {
"value": "absent"
},
"children": [
{
"name": "inputs",
"observed": {
"value": "absent"
},
"children": [
{
"name": "air:examples",
"observed": {
"value": "absent",
"digest": {
"kind": "sha256",
"hex": "fbe310c683c1e125803f56d76f76eaceda8d4b7a7f1968715a583b8fad27c7d6"
}
}
},
{
"name": "air-typed:examples",
"observed": {
"value": "absent",
"digest": {
"kind": "sha256",
"hex": "579cc33e08cdfb18fdb85de70d8d81983d280dd737b2ed4894483ca0faa6e880"
}
}
},
{
"name": "air:pointers",
"observed": {
"value": "absent",
"digest": {
"kind": "sha256",
"hex": "7e51361c89fa9dc5f98df57f99923c3a734abb96253a55bf992370f088c01315"
}
}
},
{
"name": "air-typed:pointers",
"observed": {
"value": "absent",
"digest": {
"kind": "sha256",
"hex": "1fdd7761a65caebbf70a505edfcb95c4627ae1a8a2ec5eb856adc270f18206a2"
}
}
},
{
"name": "contents:Synced",
"observed": {
"value": "absent",
"digest": {
"kind": "sha256",
"hex": "20c32b58f9dbd5416fe908e078a5ba1d76c369e08dc3c9d62c5c4e71ec4c9b05"
}
}
},
{
"name": "contents:Named",
"observed": {
"value": "absent",
"digest": {
"kind": "sha256",
"hex": "2391a11b1f9ea5ba826528ca3c097c8d2144c199a679efe81e425ec575ee514e"
}
}
},
{
"name": "contents:Later",
"observed": {
"value": "absent",
"digest": {
"kind": "sha256",
"hex": "a18573742f763887800bcc4744b72900125a1b2c0e4b7a5f7f894aa3f9121d72"
}
}
},
{
"name": "reader",
"observed": {
"value": "absent",
"digest": {
"kind": "sha256",
"hex": "55407f997e7be480140400a823d6eaf8df8b9088782e4e0399c05d73705f6c38"
}
}
}
]
},
{
"name": "examples",
"observed": {
"value": {
"variant": {
"name": "Ok",
"payload": "absent"
}
}
}
},
{
"name": "pointers",
"observed": {
"value": {
"variant": {
"name": "Ok",
"payload": "absent"
}
}
}
},
{
"name": "sequence",
"observed": {
"value": {
"variant": {
"name": "Ok",
"payload": "absent"
}
}
}
},
{
"name": "reads",
"observed": {
"value": {
"lines": [
"the bytes as of the reader's commit"
]
}
}
},
{
"name": "notices",
"observed": {
"value": "absent"
},
"children": [
{
"name": "set",
"observed": {
"value": {
"nothing": "announced_nothing"
}
}
},
{
"name": "counts",
"observed": {
"value": {
"fields": {}
}
}
}
]
}
]
}
}
}
],
"validated": "not_run"
}
],
"times": [
{
"venue": "native Metal",
"chip": "apple-m3-max",
"os_build": "26A434",
"rounds": 8,
"measured": "8 round(s) of the whole selection, in the case set's own order; a figure is the median of the rounds' own medians; Metal's leg ran at a one-minute load average of 11.59",
"instrument": 240,
"times": {
"case": "managed-named-compute-slot",
"calls": 0,
"in_calls": 0,
"on_cpu": 0,
"blocked": 0,
"elsewhere": 0,
"spend": 0,
"spend_least": 0,
"spend_most": 0,
"stopped": "the case forbids running its Metal leg here: the oracle keeps one copy of a Managed buffer (hasUnifiedMemory true), so its run answers what one copy holds, not which commit takes a range to a second copy",
"per_call": []
}
}
]
}
@@ -0,0 +1,239 @@
{
"format": 1,
"case": "managed-named-declared",
"suite_version": 1,
"shaders": [
{
"fixture": "examples/runtime_examples.ll",
"entry": "scale_and_offset",
"source_sha256": "fbe310c683c1e125803f56d76f76eaceda8d4b7a7f1968715a583b8fad27c7d6"
},
{
"fixture": "examples/runtime_examples.air.ll",
"entry": "scale_and_offset",
"source_sha256": "579cc33e08cdfb18fdb85de70d8d81983d280dd737b2ed4894483ca0faa6e880"
},
{
"fixture": "ab_pointers.ll",
"entry": "ab_address",
"source_sha256": "7e51361c89fa9dc5f98df57f99923c3a734abb96253a55bf992370f088c01315"
},
{
"fixture": "ab_pointers.air.ll",
"entry": "ab_address",
"source_sha256": "1fdd7761a65caebbf70a505edfcb95c4627ae1a8a2ec5eb856adc270f18206a2"
}
],
"answers": [
{
"key": {
"chip": "apple-m3-max",
"os_version": "27.0.1",
"os_build": "26A434",
"metal_level": "27.0.1"
},
"provenance": {
"carried": {
"from": "an AMD Radeon Pro 5300M measurement under macOS 26.7.1, 8 rounds a reader (jobs 81602 and 81644), which found that a named Managed range reaches the GPU at the first commit whose encoders name the buffer, with its bytes as of that commit, and that a buffer no encoder names keeps the bytes its GPU copy last took",
"measured_on": "amd-radeon-pro-5300m"
}
},
"device": "apple-m3-max",
"runs": 8,
"outcomes": [
{
"runs": 8,
"transcript": {
"root": {
"name": "case",
"observed": {
"value": "absent"
},
"children": [
{
"name": "inputs",
"observed": {
"value": "absent"
},
"children": [
{
"name": "air:examples",
"observed": {
"value": "absent",
"digest": {
"kind": "sha256",
"hex": "fbe310c683c1e125803f56d76f76eaceda8d4b7a7f1968715a583b8fad27c7d6"
}
}
},
{
"name": "air-typed:examples",
"observed": {
"value": "absent",
"digest": {
"kind": "sha256",
"hex": "579cc33e08cdfb18fdb85de70d8d81983d280dd737b2ed4894483ca0faa6e880"
}
}
},
{
"name": "air:pointers",
"observed": {
"value": "absent",
"digest": {
"kind": "sha256",
"hex": "7e51361c89fa9dc5f98df57f99923c3a734abb96253a55bf992370f088c01315"
}
}
},
{
"name": "air-typed:pointers",
"observed": {
"value": "absent",
"digest": {
"kind": "sha256",
"hex": "1fdd7761a65caebbf70a505edfcb95c4627ae1a8a2ec5eb856adc270f18206a2"
}
}
},
{
"name": "contents:Synced",
"observed": {
"value": "absent",
"digest": {
"kind": "sha256",
"hex": "20c32b58f9dbd5416fe908e078a5ba1d76c369e08dc3c9d62c5c4e71ec4c9b05"
}
}
},
{
"name": "contents:Named",
"observed": {
"value": "absent",
"digest": {
"kind": "sha256",
"hex": "2391a11b1f9ea5ba826528ca3c097c8d2144c199a679efe81e425ec575ee514e"
}
}
},
{
"name": "contents:Later",
"observed": {
"value": "absent",
"digest": {
"kind": "sha256",
"hex": "a18573742f763887800bcc4744b72900125a1b2c0e4b7a5f7f894aa3f9121d72"
}
}
},
{
"name": "reader",
"observed": {
"value": "absent",
"digest": {
"kind": "sha256",
"hex": "f833228cb8681bbf3e38af9de7a212dfc542b3e3ba1312ec8a45bb2b67605dc7"
}
}
}
]
},
{
"name": "examples",
"observed": {
"value": {
"variant": {
"name": "Ok",
"payload": "absent"
}
}
}
},
{
"name": "pointers",
"observed": {
"value": {
"variant": {
"name": "Ok",
"payload": "absent"
}
}
}
},
{
"name": "sequence",
"observed": {
"value": {
"variant": {
"name": "Ok",
"payload": "absent"
}
}
}
},
{
"name": "reads",
"observed": {
"value": {
"lines": [
"the bytes as of the reader's commit"
]
}
}
},
{
"name": "notices",
"observed": {
"value": "absent"
},
"children": [
{
"name": "set",
"observed": {
"value": {
"nothing": "announced_nothing"
}
}
},
{
"name": "counts",
"observed": {
"value": {
"fields": {}
}
}
}
]
}
]
}
}
}
],
"validated": "not_run"
}
],
"times": [
{
"venue": "native Metal",
"chip": "apple-m3-max",
"os_build": "26A434",
"rounds": 8,
"measured": "8 round(s) of the whole selection, in the case set's own order; a figure is the median of the rounds' own medians; Metal's leg ran at a one-minute load average of 11.59",
"instrument": 240,
"times": {
"case": "managed-named-declared",
"calls": 0,
"in_calls": 0,
"on_cpu": 0,
"blocked": 0,
"elsewhere": 0,
"spend": 0,
"spend_least": 0,
"spend_most": 0,
"stopped": "the case forbids running its Metal leg here: the oracle keeps one copy of a Managed buffer (hasUnifiedMemory true), so its run answers what one copy holds, not which commit takes a range to a second copy",
"per_call": []
}
}
]
}
@@ -0,0 +1,239 @@
{
"format": 1,
"case": "managed-named-vertex-slot",
"suite_version": 1,
"shaders": [
{
"fixture": "examples/runtime_examples.ll",
"entry": "scale_and_offset",
"source_sha256": "fbe310c683c1e125803f56d76f76eaceda8d4b7a7f1968715a583b8fad27c7d6"
},
{
"fixture": "examples/runtime_examples.air.ll",
"entry": "scale_and_offset",
"source_sha256": "579cc33e08cdfb18fdb85de70d8d81983d280dd737b2ed4894483ca0faa6e880"
},
{
"fixture": "ab_pointers.ll",
"entry": "ab_address",
"source_sha256": "7e51361c89fa9dc5f98df57f99923c3a734abb96253a55bf992370f088c01315"
},
{
"fixture": "ab_pointers.air.ll",
"entry": "ab_address",
"source_sha256": "1fdd7761a65caebbf70a505edfcb95c4627ae1a8a2ec5eb856adc270f18206a2"
}
],
"answers": [
{
"key": {
"chip": "apple-m3-max",
"os_version": "27.0.1",
"os_build": "26A434",
"metal_level": "27.0.1"
},
"provenance": {
"carried": {
"from": "an AMD Radeon Pro 5300M measurement under macOS 26.7.1, 8 rounds a reader (jobs 81602 and 81644), which found that a named Managed range reaches the GPU at the first commit whose encoders name the buffer, with its bytes as of that commit, and that a buffer no encoder names keeps the bytes its GPU copy last took",
"measured_on": "amd-radeon-pro-5300m"
}
},
"device": "apple-m3-max",
"runs": 8,
"outcomes": [
{
"runs": 8,
"transcript": {
"root": {
"name": "case",
"observed": {
"value": "absent"
},
"children": [
{
"name": "inputs",
"observed": {
"value": "absent"
},
"children": [
{
"name": "air:examples",
"observed": {
"value": "absent",
"digest": {
"kind": "sha256",
"hex": "fbe310c683c1e125803f56d76f76eaceda8d4b7a7f1968715a583b8fad27c7d6"
}
}
},
{
"name": "air-typed:examples",
"observed": {
"value": "absent",
"digest": {
"kind": "sha256",
"hex": "579cc33e08cdfb18fdb85de70d8d81983d280dd737b2ed4894483ca0faa6e880"
}
}
},
{
"name": "air:pointers",
"observed": {
"value": "absent",
"digest": {
"kind": "sha256",
"hex": "7e51361c89fa9dc5f98df57f99923c3a734abb96253a55bf992370f088c01315"
}
}
},
{
"name": "air-typed:pointers",
"observed": {
"value": "absent",
"digest": {
"kind": "sha256",
"hex": "1fdd7761a65caebbf70a505edfcb95c4627ae1a8a2ec5eb856adc270f18206a2"
}
}
},
{
"name": "contents:Synced",
"observed": {
"value": "absent",
"digest": {
"kind": "sha256",
"hex": "20c32b58f9dbd5416fe908e078a5ba1d76c369e08dc3c9d62c5c4e71ec4c9b05"
}
}
},
{
"name": "contents:Named",
"observed": {
"value": "absent",
"digest": {
"kind": "sha256",
"hex": "2391a11b1f9ea5ba826528ca3c097c8d2144c199a679efe81e425ec575ee514e"
}
}
},
{
"name": "contents:Later",
"observed": {
"value": "absent",
"digest": {
"kind": "sha256",
"hex": "a18573742f763887800bcc4744b72900125a1b2c0e4b7a5f7f894aa3f9121d72"
}
}
},
{
"name": "reader",
"observed": {
"value": "absent",
"digest": {
"kind": "sha256",
"hex": "af7ad0b82e4819d2859b5a0ef4a1f6f77d03e74795f9bf8595785db2a066ef30"
}
}
}
]
},
{
"name": "examples",
"observed": {
"value": {
"variant": {
"name": "Ok",
"payload": "absent"
}
}
}
},
{
"name": "pointers",
"observed": {
"value": {
"variant": {
"name": "Ok",
"payload": "absent"
}
}
}
},
{
"name": "sequence",
"observed": {
"value": {
"variant": {
"name": "Ok",
"payload": "absent"
}
}
}
},
{
"name": "reads",
"observed": {
"value": {
"lines": [
"the bytes as of the reader's commit"
]
}
}
},
{
"name": "notices",
"observed": {
"value": "absent"
},
"children": [
{
"name": "set",
"observed": {
"value": {
"nothing": "announced_nothing"
}
}
},
{
"name": "counts",
"observed": {
"value": {
"fields": {}
}
}
}
]
}
]
}
}
}
],
"validated": "not_run"
}
],
"times": [
{
"venue": "native Metal",
"chip": "apple-m3-max",
"os_build": "26A434",
"rounds": 8,
"measured": "8 round(s) of the whole selection, in the case set's own order; a figure is the median of the rounds' own medians; Metal's leg ran at a one-minute load average of 11.59",
"instrument": 240,
"times": {
"case": "managed-named-vertex-slot",
"calls": 0,
"in_calls": 0,
"on_cpu": 0,
"blocked": 0,
"elsewhere": 0,
"spend": 0,
"spend_least": 0,
"spend_most": 0,
"stopped": "the case forbids running its Metal leg here: the oracle keeps one copy of a Managed buffer (hasUnifiedMemory true), so its run answers what one copy holds, not which commit takes a range to a second copy",
"per_call": []
}
}
]
}
@@ -0,0 +1,324 @@
{
"format": 1,
"case": "sample-positions-8x-custom-left",
"suite_version": 1,
"shaders": [
{
"fixture": "rt6_restart.ll",
"entry": "rt6_restart_vertex+rt6_restart_count",
"source_sha256": "ee3fb102a9172fb5214a2c468b5fb177a7000fb169043ed578a12dd5b43c0464"
},
{
"fixture": "rt6_restart.air.ll",
"entry": "rt6_restart_vertex+rt6_restart_count",
"source_sha256": "08138096f5f8bef1f56267558b5bbbf1c9780e08bae5d84b87f3da4025ab6d09"
}
],
"answers": [
{
"key": {
"chip": "apple-m3-max",
"os_version": "27.0.1",
"os_build": "26A434",
"metal_level": "27.0.1"
},
"provenance": {
"carried": {
"from": "an AMD Radeon Pro 5300M under macOS 26.7.1 (job 82284): the family's pass at 8 samples, plain and under Metal's API validation layer, one run each",
"measured_on": "amd-radeon-pro-5300m"
}
},
"device": "apple-m3-max",
"runs": 1,
"outcomes": [
{
"runs": 1,
"transcript": {
"root": {
"name": "case",
"observed": {
"value": "absent"
},
"children": [
{
"name": "inputs",
"observed": {
"value": "absent"
},
"children": [
{
"name": "air",
"observed": {
"value": "absent",
"digest": {
"kind": "sha256",
"hex": "ee3fb102a9172fb5214a2c468b5fb177a7000fb169043ed578a12dd5b43c0464"
}
}
},
{
"name": "air-typed",
"observed": {
"value": "absent",
"digest": {
"kind": "sha256",
"hex": "08138096f5f8bef1f56267558b5bbbf1c9780e08bae5d84b87f3da4025ab6d09"
}
}
},
{
"name": "render-pipeline",
"observed": {
"value": "absent",
"digest": {
"kind": "sha256",
"hex": "03f5943fa208ea15062a63d582f15aae90bb31a792f25b55a2e32f5d92791dfc"
}
}
},
{
"name": "target",
"observed": {
"value": "absent",
"digest": {
"kind": "sha256",
"hex": "46be23a3b9ab948bd0549700811244dda8e20f669e98aec2361cbff5c3cae246"
}
}
},
{
"name": "resolve",
"observed": {
"value": "absent",
"digest": {
"kind": "sha256",
"hex": "84d9f4366da2d180bd2c9a0c0c0ec5a5f91d7e745b28088b7971335c2aa913fb"
}
}
},
{
"name": "pass",
"observed": {
"value": "absent",
"digest": {
"kind": "sha256",
"hex": "93c0b0f95c6553ffab21916ad615f43281c739a17cb231feff569c06f875698f"
}
}
},
{
"name": "vertices",
"observed": {
"value": "absent",
"digest": {
"kind": "sha256",
"hex": "f2df32a2160f721d5a70c07c8cbc9134e1e986712ebd31c961c3bac754d632d2"
}
}
}
]
},
{
"name": "library",
"observed": {
"value": {
"variant": {
"name": "Ok",
"payload": "absent"
}
}
}
},
{
"name": "render-pipeline",
"observed": {
"value": {
"variant": {
"name": "Ok",
"payload": "absent"
}
}
}
},
{
"name": "target",
"observed": {
"value": {
"variant": {
"name": "Ok",
"payload": "absent"
}
}
}
},
{
"name": "resolve",
"observed": {
"value": {
"variant": {
"name": "Ok",
"payload": "absent"
}
}
}
},
{
"name": "vertices",
"observed": {
"value": {
"variant": {
"name": "Ok",
"payload": "absent"
}
}
}
},
{
"name": "read-back",
"observed": {
"value": {
"variant": {
"name": "Ok",
"payload": "absent"
}
}
}
},
{
"name": "calls",
"observed": {
"value": "absent"
},
"children": [
{
"name": "0-renderCommandEncoder",
"observed": {
"value": {
"variant": {
"name": "Ok",
"payload": "absent"
}
}
}
},
{
"name": "1-copyFromTextureToBuffer",
"observed": {
"value": {
"variant": {
"name": "Ok",
"payload": "absent"
}
}
}
}
]
},
{
"name": "status",
"observed": {
"value": {
"variant": {
"name": "Ok",
"payload": {
"variant": {
"name": "Completed",
"payload": "absent"
}
}
}
}
}
},
{
"name": "coverage",
"observed": {
"value": {
"lines": [
"8 of 8 samples"
]
}
}
},
{
"name": "resolved",
"observed": {
"value": {
"bytes": "AQAA/w=="
},
"shape": {
"bytes": {
"region": {
"buffer": {
"offset": 0,
"length": 4
}
},
"element": "u8",
"row_offset": 0,
"row_elements": 4,
"row_pitch": 4,
"rows": 1,
"image_pitch": 4,
"images": 1,
"gaps": "ignored"
}
}
}
},
{
"name": "notices",
"observed": {
"value": "absent"
},
"children": [
{
"name": "set",
"observed": {
"value": {
"nothing": "announced_nothing"
}
}
},
{
"name": "counts",
"observed": {
"value": {
"fields": {}
}
}
}
]
}
]
}
}
}
],
"validated": "not_run"
}
],
"times": [
{
"venue": "native Metal",
"chip": "apple-m3-max",
"os_build": "26A434",
"rounds": 8,
"measured": "8 round(s) of the whole selection, in the case set's own order; a figure is the median of the rounds' own medians; Metal's leg ran at a one-minute load average of 7.63",
"instrument": 288,
"times": {
"case": "sample-positions-8x-custom-left",
"calls": 0,
"in_calls": 0,
"on_cpu": 0,
"blocked": 0,
"elsewhere": 0,
"spend": 0,
"spend_least": 0,
"spend_most": 0,
"stopped": "the case forbids running its Metal leg here: the oracle renders no 8 samples (an Apple M3 Max answers supportsTextureSampleCount: no for 8), so a record run there must not encode an 8-sample texture",
"per_call": []
}
}
]
}
@@ -0,0 +1,324 @@
{
"format": 1,
"case": "sample-positions-8x-custom-mixed",
"suite_version": 1,
"shaders": [
{
"fixture": "rt6_restart.ll",
"entry": "rt6_restart_vertex+rt6_restart_count",
"source_sha256": "ee3fb102a9172fb5214a2c468b5fb177a7000fb169043ed578a12dd5b43c0464"
},
{
"fixture": "rt6_restart.air.ll",
"entry": "rt6_restart_vertex+rt6_restart_count",
"source_sha256": "08138096f5f8bef1f56267558b5bbbf1c9780e08bae5d84b87f3da4025ab6d09"
}
],
"answers": [
{
"key": {
"chip": "apple-m3-max",
"os_version": "27.0.1",
"os_build": "26A434",
"metal_level": "27.0.1"
},
"provenance": {
"carried": {
"from": "an AMD Radeon Pro 5300M under macOS 26.7.1 (job 82284): the family's pass at 8 samples, plain and under Metal's API validation layer, one run each",
"measured_on": "amd-radeon-pro-5300m"
}
},
"device": "apple-m3-max",
"runs": 1,
"outcomes": [
{
"runs": 1,
"transcript": {
"root": {
"name": "case",
"observed": {
"value": "absent"
},
"children": [
{
"name": "inputs",
"observed": {
"value": "absent"
},
"children": [
{
"name": "air",
"observed": {
"value": "absent",
"digest": {
"kind": "sha256",
"hex": "ee3fb102a9172fb5214a2c468b5fb177a7000fb169043ed578a12dd5b43c0464"
}
}
},
{
"name": "air-typed",
"observed": {
"value": "absent",
"digest": {
"kind": "sha256",
"hex": "08138096f5f8bef1f56267558b5bbbf1c9780e08bae5d84b87f3da4025ab6d09"
}
}
},
{
"name": "render-pipeline",
"observed": {
"value": "absent",
"digest": {
"kind": "sha256",
"hex": "03f5943fa208ea15062a63d582f15aae90bb31a792f25b55a2e32f5d92791dfc"
}
}
},
{
"name": "target",
"observed": {
"value": "absent",
"digest": {
"kind": "sha256",
"hex": "46be23a3b9ab948bd0549700811244dda8e20f669e98aec2361cbff5c3cae246"
}
}
},
{
"name": "resolve",
"observed": {
"value": "absent",
"digest": {
"kind": "sha256",
"hex": "84d9f4366da2d180bd2c9a0c0c0ec5a5f91d7e745b28088b7971335c2aa913fb"
}
}
},
{
"name": "pass",
"observed": {
"value": "absent",
"digest": {
"kind": "sha256",
"hex": "d87c873f5ca0e3476ac05aaa450b32d24bb1d91d199500d0fb52aa62b7ffdcc1"
}
}
},
{
"name": "vertices",
"observed": {
"value": "absent",
"digest": {
"kind": "sha256",
"hex": "f2df32a2160f721d5a70c07c8cbc9134e1e986712ebd31c961c3bac754d632d2"
}
}
}
]
},
{
"name": "library",
"observed": {
"value": {
"variant": {
"name": "Ok",
"payload": "absent"
}
}
}
},
{
"name": "render-pipeline",
"observed": {
"value": {
"variant": {
"name": "Ok",
"payload": "absent"
}
}
}
},
{
"name": "target",
"observed": {
"value": {
"variant": {
"name": "Ok",
"payload": "absent"
}
}
}
},
{
"name": "resolve",
"observed": {
"value": {
"variant": {
"name": "Ok",
"payload": "absent"
}
}
}
},
{
"name": "vertices",
"observed": {
"value": {
"variant": {
"name": "Ok",
"payload": "absent"
}
}
}
},
{
"name": "read-back",
"observed": {
"value": {
"variant": {
"name": "Ok",
"payload": "absent"
}
}
}
},
{
"name": "calls",
"observed": {
"value": "absent"
},
"children": [
{
"name": "0-renderCommandEncoder",
"observed": {
"value": {
"variant": {
"name": "Ok",
"payload": "absent"
}
}
}
},
{
"name": "1-copyFromTextureToBuffer",
"observed": {
"value": {
"variant": {
"name": "Ok",
"payload": "absent"
}
}
}
}
]
},
{
"name": "status",
"observed": {
"value": {
"variant": {
"name": "Ok",
"payload": {
"variant": {
"name": "Completed",
"payload": "absent"
}
}
}
}
}
},
{
"name": "coverage",
"observed": {
"value": {
"lines": [
"1 of 8 samples"
]
}
}
},
{
"name": "resolved",
"observed": {
"value": {
"bytes": "AAAAIA=="
},
"shape": {
"bytes": {
"region": {
"buffer": {
"offset": 0,
"length": 4
}
},
"element": "u8",
"row_offset": 0,
"row_elements": 4,
"row_pitch": 4,
"rows": 1,
"image_pitch": 4,
"images": 1,
"gaps": "ignored"
}
}
}
},
{
"name": "notices",
"observed": {
"value": "absent"
},
"children": [
{
"name": "set",
"observed": {
"value": {
"nothing": "announced_nothing"
}
}
},
{
"name": "counts",
"observed": {
"value": {
"fields": {}
}
}
}
]
}
]
}
}
}
],
"validated": "not_run"
}
],
"times": [
{
"venue": "native Metal",
"chip": "apple-m3-max",
"os_build": "26A434",
"rounds": 8,
"measured": "8 round(s) of the whole selection, in the case set's own order; a figure is the median of the rounds' own medians; Metal's leg ran at a one-minute load average of 7.63",
"instrument": 288,
"times": {
"case": "sample-positions-8x-custom-mixed",
"calls": 0,
"in_calls": 0,
"on_cpu": 0,
"blocked": 0,
"elsewhere": 0,
"spend": 0,
"spend_least": 0,
"spend_most": 0,
"stopped": "the case forbids running its Metal leg here: the oracle renders no 8 samples (an Apple M3 Max answers supportsTextureSampleCount: no for 8), so a record run there must not encode an 8-sample texture",
"per_call": []
}
}
]
}
@@ -0,0 +1,324 @@
{
"format": 1,
"case": "sample-positions-8x-default",
"suite_version": 1,
"shaders": [
{
"fixture": "rt6_restart.ll",
"entry": "rt6_restart_vertex+rt6_restart_count",
"source_sha256": "ee3fb102a9172fb5214a2c468b5fb177a7000fb169043ed578a12dd5b43c0464"
},
{
"fixture": "rt6_restart.air.ll",
"entry": "rt6_restart_vertex+rt6_restart_count",
"source_sha256": "08138096f5f8bef1f56267558b5bbbf1c9780e08bae5d84b87f3da4025ab6d09"
}
],
"answers": [
{
"key": {
"chip": "apple-m3-max",
"os_version": "27.0.1",
"os_build": "26A434",
"metal_level": "27.0.1"
},
"provenance": {
"carried": {
"from": "an AMD Radeon Pro 5300M under macOS 26.7.1 (job 82284): the family's pass at 8 samples, plain and under Metal's API validation layer, one run each",
"measured_on": "amd-radeon-pro-5300m"
}
},
"device": "apple-m3-max",
"runs": 1,
"outcomes": [
{
"runs": 1,
"transcript": {
"root": {
"name": "case",
"observed": {
"value": "absent"
},
"children": [
{
"name": "inputs",
"observed": {
"value": "absent"
},
"children": [
{
"name": "air",
"observed": {
"value": "absent",
"digest": {
"kind": "sha256",
"hex": "ee3fb102a9172fb5214a2c468b5fb177a7000fb169043ed578a12dd5b43c0464"
}
}
},
{
"name": "air-typed",
"observed": {
"value": "absent",
"digest": {
"kind": "sha256",
"hex": "08138096f5f8bef1f56267558b5bbbf1c9780e08bae5d84b87f3da4025ab6d09"
}
}
},
{
"name": "render-pipeline",
"observed": {
"value": "absent",
"digest": {
"kind": "sha256",
"hex": "03f5943fa208ea15062a63d582f15aae90bb31a792f25b55a2e32f5d92791dfc"
}
}
},
{
"name": "target",
"observed": {
"value": "absent",
"digest": {
"kind": "sha256",
"hex": "46be23a3b9ab948bd0549700811244dda8e20f669e98aec2361cbff5c3cae246"
}
}
},
{
"name": "resolve",
"observed": {
"value": "absent",
"digest": {
"kind": "sha256",
"hex": "84d9f4366da2d180bd2c9a0c0c0ec5a5f91d7e745b28088b7971335c2aa913fb"
}
}
},
{
"name": "pass",
"observed": {
"value": "absent",
"digest": {
"kind": "sha256",
"hex": "332dff968c8d5130d43c6b0e1a050413da9aefb004b8c46bd9344136283bb30d"
}
}
},
{
"name": "vertices",
"observed": {
"value": "absent",
"digest": {
"kind": "sha256",
"hex": "1a2ae8d6b0ceafa23db4dce5d5c4df98fa10a8ab3c8e382a230e022c63501385"
}
}
}
]
},
{
"name": "library",
"observed": {
"value": {
"variant": {
"name": "Ok",
"payload": "absent"
}
}
}
},
{
"name": "render-pipeline",
"observed": {
"value": {
"variant": {
"name": "Ok",
"payload": "absent"
}
}
}
},
{
"name": "target",
"observed": {
"value": {
"variant": {
"name": "Ok",
"payload": "absent"
}
}
}
},
{
"name": "resolve",
"observed": {
"value": {
"variant": {
"name": "Ok",
"payload": "absent"
}
}
}
},
{
"name": "vertices",
"observed": {
"value": {
"variant": {
"name": "Ok",
"payload": "absent"
}
}
}
},
{
"name": "read-back",
"observed": {
"value": {
"variant": {
"name": "Ok",
"payload": "absent"
}
}
}
},
{
"name": "calls",
"observed": {
"value": "absent"
},
"children": [
{
"name": "0-renderCommandEncoder",
"observed": {
"value": {
"variant": {
"name": "Ok",
"payload": "absent"
}
}
}
},
{
"name": "1-copyFromTextureToBuffer",
"observed": {
"value": {
"variant": {
"name": "Ok",
"payload": "absent"
}
}
}
}
]
},
{
"name": "status",
"observed": {
"value": {
"variant": {
"name": "Ok",
"payload": {
"variant": {
"name": "Completed",
"payload": "absent"
}
}
}
}
}
},
{
"name": "coverage",
"observed": {
"value": {
"lines": [
"5 of 8 samples"
]
}
}
},
{
"name": "resolved",
"observed": {
"value": {
"bytes": "AQAAnw=="
},
"shape": {
"bytes": {
"region": {
"buffer": {
"offset": 0,
"length": 4
}
},
"element": "u8",
"row_offset": 0,
"row_elements": 4,
"row_pitch": 4,
"rows": 1,
"image_pitch": 4,
"images": 1,
"gaps": "ignored"
}
}
}
},
{
"name": "notices",
"observed": {
"value": "absent"
},
"children": [
{
"name": "set",
"observed": {
"value": {
"nothing": "announced_nothing"
}
}
},
{
"name": "counts",
"observed": {
"value": {
"fields": {}
}
}
}
]
}
]
}
}
}
],
"validated": "not_run"
}
],
"times": [
{
"venue": "native Metal",
"chip": "apple-m3-max",
"os_build": "26A434",
"rounds": 8,
"measured": "8 round(s) of the whole selection, in the case set's own order; a figure is the median of the rounds' own medians; Metal's leg ran at a one-minute load average of 7.63",
"instrument": 288,
"times": {
"case": "sample-positions-8x-default",
"calls": 0,
"in_calls": 0,
"on_cpu": 0,
"blocked": 0,
"elsewhere": 0,
"spend": 0,
"spend_least": 0,
"spend_most": 0,
"stopped": "the case forbids running its Metal leg here: the oracle renders no 8 samples (an Apple M3 Max answers supportsTextureSampleCount: no for 8), so a record run there must not encode an 8-sample texture",
"per_call": []
}
}
]
}
@@ -0,0 +1,351 @@
{
"format": 1,
"case": "sparse-status-plain",
"suite_version": 1,
"shaders": [
{
"fixture": "a2_sparse_status.ll",
"entry": "a2_sparse_status",
"source_sha256": "2be5a69bf51b85f711ea5cacf20dfed7108513c4298a7527c3ad4c37a457cf7e"
},
{
"fixture": "a2_sparse_status.air.ll",
"entry": "a2_sparse_status",
"source_sha256": "6a51e0c342640c58c9d39bbf70bb0cc28c230053e0ecaa9ccd64322030f032c2"
}
],
"answers": [
{
"key": {
"chip": "apple-m3-max",
"os_version": "27.0.1",
"os_build": "26A434",
"metal_level": "27.0.1"
},
"provenance": "metal_run",
"device": "Apple M3 Max",
"runs": 3,
"outcomes": [
{
"runs": 3,
"transcript": {
"root": {
"name": "case",
"observed": {
"value": "absent"
},
"children": [
{
"name": "inputs",
"observed": {
"value": "absent"
},
"children": [
{
"name": "air",
"observed": {
"value": "absent",
"digest": {
"kind": "sha256",
"hex": "2be5a69bf51b85f711ea5cacf20dfed7108513c4298a7527c3ad4c37a457cf7e"
}
}
},
{
"name": "air-typed",
"observed": {
"value": "absent",
"digest": {
"kind": "sha256",
"hex": "6a51e0c342640c58c9d39bbf70bb0cc28c230053e0ecaa9ccd64322030f032c2"
}
}
},
{
"name": "texture:sampled",
"observed": {
"value": "absent",
"digest": {
"kind": "sha256",
"hex": "75d705f39f984107bafb11e9d2fbd2d7e187e5ce1a52cda14d4bd685d09aebb0"
}
}
},
{
"name": "texture:read",
"observed": {
"value": "absent",
"digest": {
"kind": "sha256",
"hex": "9aa2a2bacda0da1efd1381c19ff13a66add7b19ea2be8c3b9dbb2065d27e5206"
}
}
}
]
},
{
"name": "library",
"observed": {
"value": {
"variant": {
"name": "Ok",
"payload": "absent"
}
}
}
},
{
"name": "pipeline",
"observed": {
"value": {
"variant": {
"name": "Ok",
"payload": "absent"
}
}
}
},
{
"name": "texture/sampled",
"observed": {
"value": {
"variant": {
"name": "Ok",
"payload": "absent"
}
}
}
},
{
"name": "texture/read",
"observed": {
"value": {
"variant": {
"name": "Ok",
"payload": "absent"
}
}
}
},
{
"name": "buffer/out",
"observed": {
"value": {
"variant": {
"name": "Ok",
"payload": "absent"
}
}
}
},
{
"name": "dispatch",
"observed": {
"value": {
"variant": {
"name": "Ok",
"payload": "absent"
}
}
}
},
{
"name": "status",
"observed": {
"value": {
"variant": {
"name": "Ok",
"payload": {
"variant": {
"name": "Completed",
"payload": "absent"
}
}
}
}
}
},
{
"name": "read-back",
"observed": {
"value": {
"variant": {
"name": "Ok",
"payload": "absent"
}
}
}
},
{
"name": "stored",
"observed": {
"value": {
"bytes": "AACAPgAAAD8AAAAAAACAPwAAgD4AAKA/AACgPwAAgD4AAEA/AACAPgAAAD8AAAA/AQAAAAEAAAABAAAAogAAAAAAoD8AAAA/AACAPQAAgD8AAKA/AAAQQAAAEEAAAKA/AADgPwAAgD4AABA/AAAAPwEAAAABAAAAAQAAAKIAAAAAABBAAAAAPwAAAD4AAIA/AAAQQAAAUEAAAFBAAAAQQAAAMEAAAIA+AAAgPwAAAD8BAAAAAQAAAAEAAACiAAAAAABQQAAAAD8AAEA+AACAPwAAUEAAAFBAAABQQAAAUEAAAHBAAACAPgAAMD8AAAA/AQAAAAEAAAABAAAAogAAAAAAgD4AAMA/AACAPgAAgD8AAIA+AACgPwAAoD8AAIA+AABAPwAAoD8AAEA/AAAAPwEAAAABAAAAAQAAAKIAAAAAAKA/AADAPwAAoD4AAIA/AACgPwAAEEAAABBAAACgPwAA4D8AAKA/AABQPwAAAD8BAAAAAQAAAAEAAACiAAAAAAAQQAAAwD8AAMA+AACAPwAAEEAAAFBAAABQQAAAEEAAADBAAACgPwAAYD8AAAA/AQAAAAEAAAABAAAAogAAAAAAUEAAAMA/AADgPgAAgD8AAFBAAABQQAAAUEAAAFBAAABwQAAAoD8AAHA/AAAAPwEAAAABAAAAAQAAAKIAAAAAAIA+AAAgQAAAAD8AAIA/AACAPgAAoD8AAKA/AACAPgAAQD8AABBAAACAPwAAAD8BAAAAAQAAAAEAAACiAAAAAACgPwAAIEAAABA/AACAPwAAoD8AABBAAAAQQAAAoD8AAOA/AAAQQAAAiD8AAAA/AQAAAAEAAAABAAAAogAAAAAAEEAAACBAAAAgPwAAgD8AABBAAABQQAAAUEAAABBAAAAwQAAAEEAAAJA/AAAAPwEAAAABAAAAAQAAAKIAAAAAAFBAAAAgQAAAMD8AAIA/AABQQAAAUEAAAFBAAABQQAAAcEAAABBAAACYPwAAAD8BAAAAAQAAAAEAAACiAAAAAACAPgAAYEAAAEA/AACAPwAAgD4AAKA/AACgPwAAgD4AAEA/AABQQAAAoD8AAAA/AQAAAAEAAAABAAAAogAAAAAAoD8AAGBAAABQPwAAgD8AAKA/AAAQQAAAEEAAAKA/AADgPwAAUEAAAKg/AAAAPwEAAAABAAAAAQAAAKIAAAAAABBAAABgQAAAYD8AAIA/AAAQQAAAUEAAAFBAAAAQQAAAMEAAAFBAAACwPwAAAD8BAAAAAQAAAAEAAACiAAAAAABQQAAAYEAAAHA/AACAPwAAUEAAAFBAAABQQAAAUEAAAHBAAABQQAAAuD8AAAA/AQAAAAEAAAABAAAAogAAAA=="
},
"shape": {
"bytes": {
"region": {
"buffer": {
"offset": 0,
"length": 1024
}
},
"element": "u32",
"row_offset": 0,
"row_elements": 16,
"row_pitch": 64,
"rows": 16,
"image_pitch": 1024,
"images": 1,
"gaps": "ignored"
}
}
}
},
{
"name": "notices",
"observed": {
"value": "absent"
},
"children": [
{
"name": "set",
"observed": {
"value": {
"nothing": "announced_nothing"
}
}
},
{
"name": "counts",
"observed": {
"value": {
"fields": {}
}
}
}
]
}
]
}
}
}
],
"validated": "ran"
}
],
"times": [
{
"venue": "native Metal",
"chip": "apple-m3-max",
"os_build": "26A434",
"rounds": 8,
"measured": "8 round(s) of the whole selection, in the case set's own order; a figure is the median of the rounds' own medians; Metal's leg ran at a one-minute load average of 12.22",
"instrument": 293,
"times": {
"case": "sparse-status-plain",
"calls": 8,
"in_calls": 33759586,
"on_cpu": 1273917,
"blocked": 32451042,
"elsewhere": 3828042,
"spend": 37595586,
"spend_least": 34959540,
"spend_most": 364203333,
"per_call": [
{
"call": "buffer",
"least_calls": 1,
"most_calls": 1,
"wall": 13708,
"on_cpu": 13875,
"blocked": 0,
"wall_least": 12250,
"wall_most": 47250,
"wall_total": 13708,
"on_cpu_total": 13875,
"blocked_total": 0
},
{
"call": "compute_pipeline",
"least_calls": 1,
"most_calls": 1,
"wall": 131167,
"on_cpu": 131584,
"blocked": 0,
"wall_least": 123667,
"wall_most": 1615167,
"wall_total": 131167,
"on_cpu_total": 131584,
"blocked_total": 0
},
{
"call": "dispatch_threads",
"least_calls": 1,
"most_calls": 1,
"wall": 175417,
"on_cpu": 175584,
"blocked": 0,
"wall_least": 168916,
"wall_most": 404667,
"wall_total": 175417,
"on_cpu_total": 175584,
"blocked_total": 0
},
{
"call": "library",
"least_calls": 1,
"most_calls": 1,
"wall": 28968709,
"on_cpu": 773792,
"blocked": 28153626,
"wall_least": 26733333,
"wall_most": 353416250,
"wall_total": 28968709,
"on_cpu_total": 773792,
"blocked_total": 28153626
},
{
"call": "read_buffer",
"least_calls": 1,
"most_calls": 1,
"wall": 8250,
"on_cpu": 8500,
"blocked": 0,
"wall_least": 6875,
"wall_most": 9666,
"wall_total": 8250,
"on_cpu_total": 8500,
"blocked_total": 0
},
{
"call": "texture",
"least_calls": 2,
"most_calls": 2,
"wall": 38083,
"on_cpu": 38291,
"blocked": 0,
"wall_least": 35333,
"wall_most": 45000,
"wall_total": 127791,
"on_cpu_total": 128251,
"blocked_total": 0
},
{
"call": "wait",
"least_calls": 1,
"most_calls": 1,
"wall": 4287167,
"on_cpu": 23834,
"blocked": 4256334,
"wall_least": 4153250,
"wall_most": 4337500,
"wall_total": 4287167,
"on_cpu_total": 23834,
"blocked_total": 4256334
}
]
}
}
]
}
@@ -0,0 +1,760 @@
{
"format": 1,
"case": "srgb-storage-fragment-writes",
"suite_version": 1,
"shaders": [
{
"fixture": "fpv_srgb_draw_storage.ll",
"entry": "fpv_srgb_cover+fpv_srgb_fragment_write",
"source_sha256": "35dd732c5dc27582830992b27dfeed05647e9bd9c9977b23f103df3122ae225e"
},
{
"fixture": "fpv_srgb_draw_storage.air.ll",
"entry": "fpv_srgb_cover+fpv_srgb_fragment_write",
"source_sha256": "b4b2a37ad65ae7d5ac0619d7fd5786601468a85a3047bcde7e854f8412f6ab7b"
},
{
"fixture": "fpv_srgb_draw_storage.ll",
"entry": "fpv_srgb_cover+fpv_srgb_fragment_write_half",
"source_sha256": "35dd732c5dc27582830992b27dfeed05647e9bd9c9977b23f103df3122ae225e"
},
{
"fixture": "fpv_srgb_draw_storage.air.ll",
"entry": "fpv_srgb_cover+fpv_srgb_fragment_write_half",
"source_sha256": "b4b2a37ad65ae7d5ac0619d7fd5786601468a85a3047bcde7e854f8412f6ab7b"
}
],
"answers": [
{
"key": {
"chip": "apple-m3-max",
"os_version": "27.0.1",
"os_build": "26A434",
"metal_level": "27.0.1"
},
"provenance": "metal_run",
"device": "Apple M3 Max",
"runs": 3,
"outcomes": [
{
"runs": 3,
"transcript": {
"root": {
"name": "case",
"observed": {
"value": "absent"
},
"children": [
{
"name": "inputs",
"observed": {
"value": "absent"
},
"children": [
{
"name": "air",
"observed": {
"value": "absent",
"digest": {
"kind": "sha256",
"hex": "35dd732c5dc27582830992b27dfeed05647e9bd9c9977b23f103df3122ae225e"
}
}
},
{
"name": "air-typed",
"observed": {
"value": "absent",
"digest": {
"kind": "sha256",
"hex": "b4b2a37ad65ae7d5ac0619d7fd5786601468a85a3047bcde7e854f8412f6ab7b"
}
}
},
{
"name": "buffer:1",
"observed": {
"value": "absent",
"digest": {
"kind": "sha256",
"hex": "bf5e8ffa51a9e748985800c1d3d7f1a2a6ae7435136593ca8d9637e3f87c699c"
}
}
},
{
"name": "attachment",
"observed": {
"value": "absent",
"digest": {
"kind": "sha256",
"hex": "467d04c4e816c2c655992d28052cef204b216322e750da6f61201b8e84d48de4"
}
}
},
{
"name": "fpv_srgb_fragment_write/pipeline",
"observed": {
"value": "absent",
"digest": {
"kind": "sha256",
"hex": "aab2a1df4bf3fe9258270f83d86ecdec0b44cf044aefa24905a0cd235ffb24e4"
}
}
},
{
"name": "fpv_srgb_fragment_write/buffer:0",
"observed": {
"value": "absent",
"digest": {
"kind": "sha256",
"hex": "d04922fa8a9a89e9e7154b13f86ee53b8577a55039d63b1841a9dc09fcbac3a8"
}
}
},
{
"name": "fpv_srgb_fragment_write_half/pipeline",
"observed": {
"value": "absent",
"digest": {
"kind": "sha256",
"hex": "35846d793c51f78a7c1040ea71fceee7c1e410a48e6271c8103236711ea9041c"
}
}
},
{
"name": "fpv_srgb_fragment_write_half/buffer:0",
"observed": {
"value": "absent",
"digest": {
"kind": "sha256",
"hex": "d08866127ea15fb18bb754e0c61bc3c2e4392333b9cd28f4544b6e77aee06506"
}
}
},
{
"name": "MTLPixelFormatRGBA8Unorm_sRGB",
"observed": {
"value": "absent",
"digest": {
"kind": "sha256",
"hex": "f62e7fbd0b56f442221d9b2f93366fbe85bbc0c083bc9fff4589f79e1dde7803"
}
}
},
{
"name": "MTLPixelFormatBGRA8Unorm_sRGB",
"observed": {
"value": "absent",
"digest": {
"kind": "sha256",
"hex": "751eae77ae9d671d3c66bec6eb1b0e6359b8be839b8a93e5702d71e528297757"
}
}
}
]
},
{
"name": "library",
"observed": {
"value": {
"variant": {
"name": "Ok",
"payload": "absent"
}
}
}
},
{
"name": "buffer/width",
"observed": {
"value": {
"variant": {
"name": "Ok",
"payload": "absent"
}
}
}
},
{
"name": "fpv_srgb_fragment_write/pipeline",
"observed": {
"value": {
"variant": {
"name": "Ok",
"payload": "absent"
}
}
}
},
{
"name": "fpv_srgb_fragment_write/buffer/0",
"observed": {
"value": {
"variant": {
"name": "Ok",
"payload": "absent"
}
}
}
},
{
"name": "MTLPixelFormatRGBA8Unorm_sRGB/fpv_srgb_fragment_write/texture",
"observed": {
"value": {
"variant": {
"name": "Ok",
"payload": "absent"
}
}
}
},
{
"name": "MTLPixelFormatRGBA8Unorm_sRGB/fpv_srgb_fragment_write/attachment",
"observed": {
"value": {
"variant": {
"name": "Ok",
"payload": "absent"
}
}
}
},
{
"name": "MTLPixelFormatRGBA8Unorm_sRGB/fpv_srgb_fragment_write/draw",
"observed": {
"value": {
"variant": {
"name": "Ok",
"payload": {
"variant": {
"name": "Completed",
"payload": "absent"
}
}
}
}
}
},
{
"name": "MTLPixelFormatRGBA8Unorm_sRGB/fpv_srgb_fragment_write/pass",
"observed": {
"value": {
"variant": {
"name": "Ok",
"payload": "absent"
}
}
}
},
{
"name": "MTLPixelFormatRGBA8Unorm_sRGB/fpv_srgb_fragment_write/texels",
"observed": {
"value": {
"variant": {
"name": "Ok",
"payload": "absent"
}
}
}
},
{
"name": "MTLPixelFormatRGBA8Unorm_sRGB/fpv_srgb_fragment_write/stored",
"observed": {
"value": {
"bytes": "AP8AAAH+JQEC/UoCA/xvAwT7lAQF+rkFBvneBgf4AwcI9ygICfZNCQr1cgoL9JcLDPO8DA3y4Q0O8QYOD/ArDxDvUBAR7nUREu2aEhPsvxMU6+QUFeoJFRbpLhYX6FMXGOd4GBnmnRka5cIaG+TnGxzjDBwd4jEdHuFWHh/gex8g36AgId7FISLd6iIj3A8jJNs0JCXaWSUm2X4mJ9ijJyjXyCgp1u0pKtUSKivUNyss01wsLdKBLS7Rpi4v0MsvMM/wMDHOFTEyzToyM8xfMzTLhDQ1yqk1NsnONjfI8zc4xxg4OcY9OTrFYjo7xIc7PMOsPD3C0T0+wfY+P8AbP0C/QEBBvmVBQr2KQkO8r0NEu9RERbr5RUa5HkZHuENHSLdoSEm2jUlKtbJKS7TXS0yz/ExNsiFNTrFGTk+wa09Qr5BQUa61UVKt2lJTrP9TVKskVFWqSVVWqW5WV6iTV1inuFhZpt1ZWqUCWlukJ1tco0xcXaJxXV6hll5foLtfYJ/gYGGeBWFinSpiY5xPY2SbdGRlmpllZpm+ZmeY42dolwhoaZYtaWqVUmprlHdrbJOcbG2SwW1ukeZub5ALb3CPMHBxjlVxco16cnOMn3N0i8R0dYrpdXaJDnZ3iDN3eIdYeHmGfXl6haJ6e4THe3yD7Hx9ghF9foE2fn+AW3+Af4CAgX6lgYJ9yoKDfO+DhHsUhIV6OYWGeV6Gh3iDh4h3qIiJds2JinXyiot0F4uMczyMjXJhjY5xho6PcKuPkG/QkJFu9ZGSbRqSk2w/k5RrZJSVaomVlmmulpdo05eYZ/iYmWYdmZplQpqbZGebnGOMnJ1isZ2eYdaen2D7n6BfIKChXkWhol1qoqNcj6OkW7SkpVrZpaZZ/qanWCOnqFdIqKlWbamqVZKqq1S3q6xT3KytUgGtrlEmrq9QS6+wT3CwsU6VsbJNurKzTN+ztEsEtLVKKbW2SU62t0hzt7hHmLi5Rr25ukXiurtEB7u8Qyy8vUJRvb5Bdr6/QJu/wD/AwME+5cHCPQrCwzwvw8Q7VMTFOnnFxjmexsc4w8fIN+jIyTYNyco1MsrLNFfLzDN8zM0yoc3OMcbOzzDrz9AvENDRLjXR0i1a0tMsf9PUK6TU1SrJ1dYp7tbXKBPX2Cc42NkmXdnaJYLa2ySn29wjzNzdIvHd3iEW3t8gO9/gH2Dg4R6F4eIdquLjHM/j5Bv05OUaGeXmGT7m5xhj5+gXiOjpFq3p6hXS6usU9+vsExzs7RJB7e4RZu7vEIvv8A+w8PEO1fHyDfry8wwf8/QLRPT1Cmn19gmO9vcIs/f4B9j4+Qb9+foFIvr7BEf7/ANs/P0Ckf3+Abb+/wDb/wD/AP8A//8AAP///wAA/wD7lFH7+vlQ+vleU/n4w1L49yhd9/aNXPb18l/19Fde9PO8WfPyIVjy8YZb8fDrWvDvUEXv7rVE7u0aR+3sf0bs6+RB6+pJQOrprkPp6BNC6Od4Tefm3Uzm5UJP5eSnTuTjDEnj4nFI4uHWS+HgO0rg36B1394FdN7danfd3M923Ns0cdvamXDa2f5z2dhjctjXyH3X1i181tWSf9XU937U01x509LBeNLRJnvR0It60M/wZc/OVWTOzbpnzcwfZszLhGHLyulgyslOY8nIs2LIxxhtx8Z9bMbF4m/FxEduxMOsacPCEWjCwXZrwcDbasC/QBW/vqUUvr0KF728bxa8u9QRu7o5ELq5nhO5uAMSuLdoHbe2zRy2tTIftbSXHrSz/BmzsmEYsrHGG7GwKxqwr5AFr671BK6tWgetrL8GrKskAauqiQCqqe4DqahTAqinuA2nph0MpqWCD6Wk5w6ko0wJo6KxCKKhFguhoHsKoJ/gNZ+eRTSenao3nZwPNpybdDGbmtkwmpk+M5mYozKYlwg9l5ZtPJaV0j+VlDc+lJOcOZOSATiSkWY7kZDLOpCPMCWPjpUkjo36J42MXyaMi8Qhi4opIIqJjiOJiPMiiIdYLYeGvSyGhSIvhYSHLoSD7CmDglEogoG2K4GAGyqAf4DVf37l1H59Std9fK/WfHsU0Xt6edB6ed7TeXhD0nh3qN13dg3cdnVy33V01950czzZc3Kh2HJxBttxcGvacG/QxW9uNcRubZrHbWz/xmxrZMFrasnAamkuw2lok8JoZ/jNZ2ZdzGZlws9lZCfOZGOMyWNi8chiYVbLYWC7ymBfIPVfXoX0Xl3q911cT/ZcW7TxW1oZ8FpZfvNZWOPyWFdI/VdWrfxWVRL/VVR3/lRT3PlTUkH4UlGm+1FQC/pQT3DlT07V5E5NOudNTJ/mTEsE4UtKaeBKSc7jSUgz4khHmO1HRv3sRkVi70VEx+5EQyzpQ0KR6EJB9utBQFvqQD/AlT8+JZQ+PYqXPTzvljw7VJE7OrmQOjkekzk4g5I4N+idNzZNnDY1sp81NBeeNDN8mTMy4ZgyMUabMTCrmjAvEIUvLnWELi3ahy0sP4YsK6SBKyoJgCopboMpKNOCKCc4jScmnYwmJQKPJSRnjiQjzIkjIjGIIiGWiyEg+4ogH2C1Hx7FtB4dKrcdHI+2HBv0sRsaWbAaGb6zGRgjshgXiL0XFu28FhVSvxUUt74UExy5ExKBuBIR5rsREEu6EA+wpQ8OFaQODXqnDQzfpgwLRKELCqmgCgkOowkIc6IIB9itBwY9rAYFoq8FBAeuBANsqQMC0agCATarAQCbqgA="
},
"shape": {
"bytes": {
"region": {
"texture": {
"level": 0,
"slice": 0,
"aspect": "color",
"sample": 0,
"origin": [
0,
0,
0
],
"size": [
256,
2,
1
]
}
},
"element": "u8",
"row_offset": 0,
"row_elements": 1024,
"row_pitch": 1024,
"rows": 2,
"image_pitch": 2048,
"images": 1,
"gaps": "ignored"
}
}
}
},
{
"name": "MTLPixelFormatBGRA8Unorm_sRGB/fpv_srgb_fragment_write/texture",
"observed": {
"value": {
"variant": {
"name": "Ok",
"payload": "absent"
}
}
}
},
{
"name": "MTLPixelFormatBGRA8Unorm_sRGB/fpv_srgb_fragment_write/attachment",
"observed": {
"value": {
"variant": {
"name": "Ok",
"payload": "absent"
}
}
}
},
{
"name": "MTLPixelFormatBGRA8Unorm_sRGB/fpv_srgb_fragment_write/draw",
"observed": {
"value": {
"variant": {
"name": "Ok",
"payload": {
"variant": {
"name": "Completed",
"payload": "absent"
}
}
}
}
}
},
{
"name": "MTLPixelFormatBGRA8Unorm_sRGB/fpv_srgb_fragment_write/pass",
"observed": {
"value": {
"variant": {
"name": "Ok",
"payload": "absent"
}
}
}
},
{
"name": "MTLPixelFormatBGRA8Unorm_sRGB/fpv_srgb_fragment_write/texels",
"observed": {
"value": {
"variant": {
"name": "Ok",
"payload": "absent"
}
}
}
},
{
"name": "MTLPixelFormatBGRA8Unorm_sRGB/fpv_srgb_fragment_write/stored",
"observed": {
"value": {
"bytes": "AP8AACX+AQFK/QICb/wDA5T7BAS5+gUF3vkGBgP4Bwco9wgITfYJCXL1CgqX9AsLvPMMDOHyDQ0G8Q4OK/APD1DvEBB17hERmu0SEr/sExPk6xQUCeoVFS7pFhZT6BcXeOcYGJ3mGRnC5Roa5+QbGwzjHBwx4h0dVuEeHnvgHx+g3yAgxd4hIerdIiIP3CMjNNskJFnaJSV+2SYmo9gnJ8jXKCjt1ikpEtUqKjfUKytc0ywsgdItLabRLi7L0C8v8M8wMBXOMTE6zTIyX8wzM4TLNDSpyjU1zsk2NvPINzcYxzg4PcY5OWLFOjqHxDs7rMM8PNHCPT32wT4+G8A/P0C/QEBlvkFBir1CQq+8Q0PUu0RE+bpFRR65RkZDuEdHaLdISI22SUmytUpK17RLS/yzTEwhsk1NRrFOTmuwT0+Qr1BQta5RUdqtUlL/rFNTJKtUVEmqVVVuqVZWk6hXV7inWFjdpllZAqVaWiekW1tMo1xccaJdXZahXl67oF9f4J9gYAWeYWEqnWJiT5xjY3SbZGSZmmVlvplmZuOYZ2cIl2hoLZZpaVKVamp3lGtrnJNsbMGSbW3mkW5uC5BvbzCPcHBVjnFxeo1ycp+Mc3PEi3R06Yp1dQ6JdnYziHd3WId4eH2GeXmihXp6x4R7e+yDfHwRgn19NoF+fluAf3+Af4CApX6Bgcp9goLvfIODFHuEhDl6hYVeeYaGg3iHh6h3iIjNdomJ8nWKihd0i4s8c4yMYXKNjYZxjo6rcI+P0G+QkPVukZEabZKSP2yTk2RrlJSJapWVrmmWltNol5f4Z5iYHWaZmUJlmppnZJubjGOcnLFinZ3WYZ6e+2CfnyBfoKBFXqGhal2ioo9co6O0W6Sk2Vqlpf5ZpqYjWKenSFeoqG1WqamSVaqqt1Srq9xTrKwBUq2tJlGurktQr69wT7CwlU6xsbpNsrLfTLOzBEu0tClKtbVOSba2c0i3t5hHuLi9Rrm54kW6ugdEu7ssQ7y8UUK9vXZBvr6bQL+/wD/AwOU+wcEKPcLCLzzDw1Q7xMR5OsXFnjnGxsM4x8foN8jIDTbJyTI1yspXNMvLfDPMzKEyzc3GMc7O6zDPzxAv0NA1LtHRWi3S0n8s09OkK9TUySrV1e4p1tYTKNfXOCfY2F0m2dmCJdrapyTb28wj3NzxIt3dFiHe3jsg399gH+DghR7h4aod4uLPHOPj9Bvk5Bka5eU+GebmYxjn54gX6OitFunp0hXq6vcU6+scE+zsQRLt7WYR7u6LEO/vsA/w8NUO8fH6DfLyHwzz80QL9PRpCvX1jgn29rMI9/fYB/j4/Qb5+SIF+vpHBPv7bAP8/JEC/f22Af7+2wD//wD/AP///wAA//8A//8AAABRlPv7UPn6+lNe+flSw/j4XSj391yN9vZf8vX1Xlf09Fm88/NYIfLyW4bx8Vrr8PBFUO/vRLXu7kca7e1Gf+zsQeTr60BJ6upDrunpQhPo6E145+dM3ebmT0Ll5U6n5ORJDOPjSHHi4kvW4eFKO+DgdaDf33QF3t53at3dds/c3HE029twmdrac/7Z2XJj2Nh9yNfXfC3W1n+S1dV+99TUeVzT03jB0tJ7JtHReovQ0GXwz89kVc7OZ7rNzWYfzMxhhMvLYOnKymNOyclis8jIbRjHx2x9xsZv4sXFbkfExGmsw8NoEcLCa3bBwWrbwMAVQL+/FKW+vhcKvb0Wb7y8EdS7uxA5uroTnrm5EgO4uB1ot7cczba2HzK1tR6XtLQZ/LOzGGGyshvGsbEaK7CwBZCvrwT1rq4HWq2tBr+srAEkq6sAiaqqA+6pqQJTqKgNuKenDB2mpg+CpaUO56SkCUyjowixoqILFqGhCnugoDXgn580RZ6eN6qdnTYPnJwxdJubMNmamjM+mZkyo5iYPQiXlzxtlpY/0pWVPjeUlDmck5M4AZKSO2aRkTrLkJAlMI+PJJWOjif6jY0mX4yMIcSLiyApioojjomJIvOIiC1Yh4csvYaGLyKFhS6HhIQp7IODKFGCgiu2gYEqG4CA1YB/f9Tlfn7XSn191q98fNEUe3vQeXp60955edJDeHjdqHd33A12dt9ydXXe13R02Txzc9ihcnLbBnFx2mtwcMXQb2/ENW5ux5ptbcb/bGzBZGtrwMlqasMuaWnCk2hozfhnZ8xdZmbPwmVlzidkZMmMY2PI8WJiy1ZhYcq7YGD1IF9f9IVeXvfqXV32T1xc8bRbW/AZWlrzfllZ8uNYWP1IV1f8rVZW/xJVVf53VFT53FNT+EFSUvumUVH6C1BQ5XBPT+TVTk7nOk1N5p9MTOEES0vgaUpK485JSeIzSEjtmEdH7P1GRu9iRUXux0RE6SxDQ+iRQkLr9kFB6ltAQJXAPz+UJT4+l4o9PZbvPDyRVDs7kLk6OpMeOTmSgzg4neg3N5xNNjafsjU1nhc0NJl8MzOY4TIym0YxMZqrMDCFEC8vhHUuLofaLS2GPywsgaQrK4AJKiqDbikpgtMoKI04JyeMnSYmjwIlJY5nJCSJzCMjiDEiIouWISGK+yAgtWAfH7TFHh63Kh0dto8cHLH0GxuwWRoas74ZGbIjGBi9iBcXvO0WFr9SFRW+txQUuRwTE7iBEhK75hERuksQEKWwDw+kFQ4Op3oNDabfDAyhRAsLoKkKCqMOCQmicwgIrdgHB6w9BgavogUFrgcEBKlsAwOo0QICqzYBAaqbAAA="
},
"shape": {
"bytes": {
"region": {
"texture": {
"level": 0,
"slice": 0,
"aspect": "color",
"sample": 0,
"origin": [
0,
0,
0
],
"size": [
256,
2,
1
]
}
},
"element": "u8",
"row_offset": 0,
"row_elements": 1024,
"row_pitch": 1024,
"rows": 2,
"image_pitch": 2048,
"images": 1,
"gaps": "ignored"
}
}
}
},
{
"name": "fpv_srgb_fragment_write_half/pipeline",
"observed": {
"value": {
"variant": {
"name": "Ok",
"payload": "absent"
}
}
}
},
{
"name": "fpv_srgb_fragment_write_half/buffer/0",
"observed": {
"value": {
"variant": {
"name": "Ok",
"payload": "absent"
}
}
}
},
{
"name": "MTLPixelFormatRGBA8Unorm_sRGB/fpv_srgb_fragment_write_half/texture",
"observed": {
"value": {
"variant": {
"name": "Ok",
"payload": "absent"
}
}
}
},
{
"name": "MTLPixelFormatRGBA8Unorm_sRGB/fpv_srgb_fragment_write_half/attachment",
"observed": {
"value": {
"variant": {
"name": "Ok",
"payload": "absent"
}
}
}
},
{
"name": "MTLPixelFormatRGBA8Unorm_sRGB/fpv_srgb_fragment_write_half/draw",
"observed": {
"value": {
"variant": {
"name": "Ok",
"payload": {
"variant": {
"name": "Completed",
"payload": "absent"
}
}
}
}
}
},
{
"name": "MTLPixelFormatRGBA8Unorm_sRGB/fpv_srgb_fragment_write_half/pass",
"observed": {
"value": {
"variant": {
"name": "Ok",
"payload": "absent"
}
}
}
},
{
"name": "MTLPixelFormatRGBA8Unorm_sRGB/fpv_srgb_fragment_write_half/texels",
"observed": {
"value": {
"variant": {
"name": "Ok",
"payload": "absent"
}
}
}
},
{
"name": "MTLPixelFormatRGBA8Unorm_sRGB/fpv_srgb_fragment_write_half/stored",
"observed": {
"value": {
"bytes": "AP8AAAH+JQEC/UoCA/xvAwT7lAQF+rkFBvneBgf4AwcI9ygICfZNCQr1cgoL9JcLDPO8DA3y4Q0O8QYOD/ArDxDvUBAR7nUREu2aEhPsvxMU6+QUFeoJFRbpLhYX6FMXGOd4GBnmnRka5cIaG+TnGxzjDBwd4jEdHuFWHh/gex8g36AgId7FISLd6iIj3A8jJNs0JCXaWSUm2X4mJ9ijJyjXyCgp1u0pKtUSKivUNyss01wsLdKBLS7Rpi4v0MsvMM/wMDHOFTEyzToyM8xfMzTLhDQ1yqk1NsnONjfI8zc4xxg4OcY9OTrFYjo7xIc7PMOsPD3C0T0+wfY+P8AbP0C/QEBBvmVBQr2KQkO8r0NEu9RERbr5RUa5HkZHuENHSLdoSEm2jUlKtbJKS7TXS0yz/ExNsiFNTrFGTk+wa09Qr5BQUa61UVKt2lJTrP9TVKskVFWqSVVWqW5WV6iTV1inuFhZpt1ZWqUCWlukJ1tco0xcXaJxXV6hll5foLtfYJ/gYGGeBWFinSpiY5xPY2SbdGRlmpllZpm+ZmeY42dolwhoaZYtaWqVUmprlHdrbJOcbG2SwW1ukeZub5ALb3CPMHBxjlVxco16cnOMn3N0i8R0dYrpdXaJDnZ3iDN3eIdYeHmGfXl6haJ6e4THe3yD7Hx9ghF9foE2fn+AW3+Af4CAgX6lgYJ9yoKDfO+DhHsUhIV6OYWGeV6Gh3iDh4h3qIiJds2JinXyiot0F4uMczyMjXJhjY5xho6PcKuPkG/QkJFu9ZGSbRqSk2w/k5RrZJSVaomVlmmulpdo05eYZ/iYmWYdmZplQpqbZGebnGOMnJ1isZ2eYdaen2D7n6BfIKChXkWhol1qoqNcj6OkW7SkpVrZpaZZ/qanWCOnqFdIqKlWbamqVZKqq1S3q6xT3KytUgGtrlEmrq9QS6+wT3CwsU6VsbJNurKzTN+ztEsEtLVKKbW2SU62t0hzt7hHmLi5Rr25ukXiurtEB7u8Qyy8vUJRvb5Bdr6/QJu/wD/AwME+5cHCPQrCwzwvw8Q7VMTFOnnFxjmexsc4w8fIN+jIyTYNyco1MsrLNFfLzDN8zM0yoc3OMcbOzzDrz9AvENDRLjXR0i1a0tMsf9PUK6TU1SrJ1dYp7tbXKBPX2Cc42NkmXdnaJYLa2ySn29wjzNzdIvHd3iEW3t8gO9/gH2Dg4R6F4eIdquLjHM/j5Bv05OUaGeXmGT7m5xhj5+gXiOjpFq3p6hXS6usU9+vsExzs7RJB7e4RZu7vEIvv8A+w8PEO1fHyDfry8wwf8/QLRPT1Cmn19gmO9vcIs/f4B9j4+Qb9+foFIvr7BEf7/ANs/P0Ckf3+Abb+/wDb/wD/AP8A//8AAP///wAA/wD7lFH7+vlQ+vleU/n4w1L49yhd9/aNXPb18l/19Fde9PO8WfPyIVjy8YZb8fDrWvDvUEXv7rVE7u0aR+3sf0bs6+RB6+pJQOrprkPp6BNC6Od4Tefm3Uzm5UJP5eSnTuTjDEnj4nFI4uHWS+HgO0rg36B1394FdN7danfd3M923Ns0cdvamXDa2f5z2dhjctjXyH3X1i181tWSf9XU937U01x509LBeNLRJnvR0It60M/wZc/OVWTOzbpnzcwfZszLhGHLyulgyslOY8nIs2LIxxhtx8Z9bMbF4m/FxEduxMOsacPCEWjCwXZrwcDbasC/QBW/vqUUvr0KF728bxa8u9QRu7o5ELq5nhO5uAMSuLdoHbe2zRy2tTIftbSXHrSz/BmzsmEYsrHGG7GwKxqwr5AFr671BK6tWgetrL8GrKskAauqiQCqqe4DqahTAqinuA2nph0MpqWCD6Wk5w6ko0wJo6KxCKKhFguhoHsKoJ/gNZ+eRTSenao3nZwPNpybdDGbmtkwmpk+M5mYozKYlwg9l5ZtPJaV0j+VlDc+lJOcOZOSATiSkWY7kZDLOpCPMCWPjpUkjo36J42MXyaMi8Qhi4opIIqJjiOJiPMiiIdYLYeGvSyGhSIvhYSHLoSD7CmDglEogoG2K4GAGyqAf4DVf37l1H59Std9fK/WfHsU0Xt6edB6ed7TeXhD0nh3qN13dg3cdnVy33V01950czzZc3Kh2HJxBttxcGvacG/QxW9uNcRubZrHbWz/xmxrZMFrasnAamkuw2lok8JoZ/jNZ2ZdzGZlws9lZCfOZGOMyWNi8chiYVbLYWC7ymBfIPVfXoX0Xl3q911cT/ZcW7TxW1oZ8FpZfvNZWOPyWFdI/VdWrfxWVRL/VVR3/lRT3PlTUkH4UlGm+1FQC/pQT3DlT07V5E5NOudNTJ/mTEsE4UtKaeBKSc7jSUgz4khHmO1HRv3sRkVi70VEx+5EQyzpQ0KR6EJB9utBQFvqQD/AlT8+JZQ+PYqXPTzvljw7VJE7OrmQOjkekzk4g5I4N+idNzZNnDY1sp81NBeeNDN8mTMy4ZgyMUabMTCrmjAvEIUvLnWELi3ahy0sP4YsK6SBKyoJgCopboMpKNOCKCc4jScmnYwmJQKPJSRnjiQjzIkjIjGIIiGWiyEg+4ogH2C1Hx7FtB4dKrcdHI+2HBv0sRsaWbAaGb6zGRgjshgXiL0XFu28FhVSvxUUt74UExy5ExKBuBIR5rsREEu6EA+wpQ8OFaQODXqnDQzfpgwLRKELCqmgCgkOowkIc6IIB9itBwY9rAYFoq8FBAeuBANsqQMC0agCATarAQCbqgA="
},
"shape": {
"bytes": {
"region": {
"texture": {
"level": 0,
"slice": 0,
"aspect": "color",
"sample": 0,
"origin": [
0,
0,
0
],
"size": [
256,
2,
1
]
}
},
"element": "u8",
"row_offset": 0,
"row_elements": 1024,
"row_pitch": 1024,
"rows": 2,
"image_pitch": 2048,
"images": 1,
"gaps": "ignored"
}
}
}
},
{
"name": "MTLPixelFormatBGRA8Unorm_sRGB/fpv_srgb_fragment_write_half/texture",
"observed": {
"value": {
"variant": {
"name": "Ok",
"payload": "absent"
}
}
}
},
{
"name": "MTLPixelFormatBGRA8Unorm_sRGB/fpv_srgb_fragment_write_half/attachment",
"observed": {
"value": {
"variant": {
"name": "Ok",
"payload": "absent"
}
}
}
},
{
"name": "MTLPixelFormatBGRA8Unorm_sRGB/fpv_srgb_fragment_write_half/draw",
"observed": {
"value": {
"variant": {
"name": "Ok",
"payload": {
"variant": {
"name": "Completed",
"payload": "absent"
}
}
}
}
}
},
{
"name": "MTLPixelFormatBGRA8Unorm_sRGB/fpv_srgb_fragment_write_half/pass",
"observed": {
"value": {
"variant": {
"name": "Ok",
"payload": "absent"
}
}
}
},
{
"name": "MTLPixelFormatBGRA8Unorm_sRGB/fpv_srgb_fragment_write_half/texels",
"observed": {
"value": {
"variant": {
"name": "Ok",
"payload": "absent"
}
}
}
},
{
"name": "MTLPixelFormatBGRA8Unorm_sRGB/fpv_srgb_fragment_write_half/stored",
"observed": {
"value": {
"bytes": "AP8AACX+AQFK/QICb/wDA5T7BAS5+gUF3vkGBgP4Bwco9wgITfYJCXL1CgqX9AsLvPMMDOHyDQ0G8Q4OK/APD1DvEBB17hERmu0SEr/sExPk6xQUCeoVFS7pFhZT6BcXeOcYGJ3mGRnC5Roa5+QbGwzjHBwx4h0dVuEeHnvgHx+g3yAgxd4hIerdIiIP3CMjNNskJFnaJSV+2SYmo9gnJ8jXKCjt1ikpEtUqKjfUKytc0ywsgdItLabRLi7L0C8v8M8wMBXOMTE6zTIyX8wzM4TLNDSpyjU1zsk2NvPINzcYxzg4PcY5OWLFOjqHxDs7rMM8PNHCPT32wT4+G8A/P0C/QEBlvkFBir1CQq+8Q0PUu0RE+bpFRR65RkZDuEdHaLdISI22SUmytUpK17RLS/yzTEwhsk1NRrFOTmuwT0+Qr1BQta5RUdqtUlL/rFNTJKtUVEmqVVVuqVZWk6hXV7inWFjdpllZAqVaWiekW1tMo1xccaJdXZahXl67oF9f4J9gYAWeYWEqnWJiT5xjY3SbZGSZmmVlvplmZuOYZ2cIl2hoLZZpaVKVamp3lGtrnJNsbMGSbW3mkW5uC5BvbzCPcHBVjnFxeo1ycp+Mc3PEi3R06Yp1dQ6JdnYziHd3WId4eH2GeXmihXp6x4R7e+yDfHwRgn19NoF+fluAf3+Af4CApX6Bgcp9goLvfIODFHuEhDl6hYVeeYaGg3iHh6h3iIjNdomJ8nWKihd0i4s8c4yMYXKNjYZxjo6rcI+P0G+QkPVukZEabZKSP2yTk2RrlJSJapWVrmmWltNol5f4Z5iYHWaZmUJlmppnZJubjGOcnLFinZ3WYZ6e+2CfnyBfoKBFXqGhal2ioo9co6O0W6Sk2Vqlpf5ZpqYjWKenSFeoqG1WqamSVaqqt1Srq9xTrKwBUq2tJlGurktQr69wT7CwlU6xsbpNsrLfTLOzBEu0tClKtbVOSba2c0i3t5hHuLi9Rrm54kW6ugdEu7ssQ7y8UUK9vXZBvr6bQL+/wD/AwOU+wcEKPcLCLzzDw1Q7xMR5OsXFnjnGxsM4x8foN8jIDTbJyTI1yspXNMvLfDPMzKEyzc3GMc7O6zDPzxAv0NA1LtHRWi3S0n8s09OkK9TUySrV1e4p1tYTKNfXOCfY2F0m2dmCJdrapyTb28wj3NzxIt3dFiHe3jsg399gH+DghR7h4aod4uLPHOPj9Bvk5Bka5eU+GebmYxjn54gX6OitFunp0hXq6vcU6+scE+zsQRLt7WYR7u6LEO/vsA/w8NUO8fH6DfLyHwzz80QL9PRpCvX1jgn29rMI9/fYB/j4/Qb5+SIF+vpHBPv7bAP8/JEC/f22Af7+2wD//wD/AP///wAA//8A//8AAABRlPv7UPn6+lNe+flSw/j4XSj391yN9vZf8vX1Xlf09Fm88/NYIfLyW4bx8Vrr8PBFUO/vRLXu7kca7e1Gf+zsQeTr60BJ6upDrunpQhPo6E145+dM3ebmT0Ll5U6n5ORJDOPjSHHi4kvW4eFKO+DgdaDf33QF3t53at3dds/c3HE029twmdrac/7Z2XJj2Nh9yNfXfC3W1n+S1dV+99TUeVzT03jB0tJ7JtHReovQ0GXwz89kVc7OZ7rNzWYfzMxhhMvLYOnKymNOyclis8jIbRjHx2x9xsZv4sXFbkfExGmsw8NoEcLCa3bBwWrbwMAVQL+/FKW+vhcKvb0Wb7y8EdS7uxA5uroTnrm5EgO4uB1ot7cczba2HzK1tR6XtLQZ/LOzGGGyshvGsbEaK7CwBZCvrwT1rq4HWq2tBr+srAEkq6sAiaqqA+6pqQJTqKgNuKenDB2mpg+CpaUO56SkCUyjowixoqILFqGhCnugoDXgn580RZ6eN6qdnTYPnJwxdJubMNmamjM+mZkyo5iYPQiXlzxtlpY/0pWVPjeUlDmck5M4AZKSO2aRkTrLkJAlMI+PJJWOjif6jY0mX4yMIcSLiyApioojjomJIvOIiC1Yh4csvYaGLyKFhS6HhIQp7IODKFGCgiu2gYEqG4CA1YB/f9Tlfn7XSn191q98fNEUe3vQeXp60955edJDeHjdqHd33A12dt9ydXXe13R02Txzc9ihcnLbBnFx2mtwcMXQb2/ENW5ux5ptbcb/bGzBZGtrwMlqasMuaWnCk2hozfhnZ8xdZmbPwmVlzidkZMmMY2PI8WJiy1ZhYcq7YGD1IF9f9IVeXvfqXV32T1xc8bRbW/AZWlrzfllZ8uNYWP1IV1f8rVZW/xJVVf53VFT53FNT+EFSUvumUVH6C1BQ5XBPT+TVTk7nOk1N5p9MTOEES0vgaUpK485JSeIzSEjtmEdH7P1GRu9iRUXux0RE6SxDQ+iRQkLr9kFB6ltAQJXAPz+UJT4+l4o9PZbvPDyRVDs7kLk6OpMeOTmSgzg4neg3N5xNNjafsjU1nhc0NJl8MzOY4TIym0YxMZqrMDCFEC8vhHUuLofaLS2GPywsgaQrK4AJKiqDbikpgtMoKI04JyeMnSYmjwIlJY5nJCSJzCMjiDEiIouWISGK+yAgtWAfH7TFHh63Kh0dto8cHLH0GxuwWRoas74ZGbIjGBi9iBcXvO0WFr9SFRW+txQUuRwTE7iBEhK75hERuksQEKWwDw+kFQ4Op3oNDabfDAyhRAsLoKkKCqMOCQmicwgIrdgHB6w9BgavogUFrgcEBKlsAwOo0QICqzYBAaqbAAA="
},
"shape": {
"bytes": {
"region": {
"texture": {
"level": 0,
"slice": 0,
"aspect": "color",
"sample": 0,
"origin": [
0,
0,
0
],
"size": [
256,
2,
1
]
}
},
"element": "u8",
"row_offset": 0,
"row_elements": 1024,
"row_pitch": 1024,
"rows": 2,
"image_pitch": 2048,
"images": 1,
"gaps": "ignored"
}
}
}
},
{
"name": "notices",
"observed": {
"value": "absent"
},
"children": [
{
"name": "set",
"observed": {
"value": {
"nothing": "announced_nothing"
}
}
},
{
"name": "counts",
"observed": {
"value": {
"fields": {}
}
}
}
]
}
]
}
}
}
],
"validated": "ran"
}
],
"times": [
{
"venue": "native Metal",
"chip": "apple-m3-max",
"os_build": "26A434",
"rounds": 8,
"measured": "8 round(s) of the whole selection, in the case set's own order; a figure is the median of the rounds' own medians; Metal's leg ran at a one-minute load average of 10.89",
"instrument": 403,
"times": {
"case": "srgb-storage-fragment-writes",
"calls": 22,
"in_calls": 35642498,
"on_cpu": 1511293,
"blocked": 33999251,
"elsewhere": 5715708,
"spend": 41352665,
"spend_least": 40894126,
"spend_most": 42391958,
"per_call": [
{
"call": "buffer",
"least_calls": 3,
"most_calls": 3,
"wall": 8542,
"on_cpu": 8708,
"blocked": 0,
"wall_least": 6417,
"wall_most": 20000,
"wall_total": 42750,
"on_cpu_total": 43251,
"blocked_total": 0
},
{
"call": "library",
"least_calls": 1,
"most_calls": 1,
"wall": 27575542,
"on_cpu": 701708,
"blocked": 26745333,
"wall_least": 26782125,
"wall_most": 27968500,
"wall_total": 27575542,
"on_cpu_total": 701708,
"blocked_total": 26745333
},
{
"call": "read_texture",
"least_calls": 4,
"most_calls": 4,
"wall": 1333,
"on_cpu": 1458,
"blocked": 0,
"wall_least": 1083,
"wall_most": 1584,
"wall_total": 7459,
"on_cpu_total": 8084,
"blocked_total": 0
},
{
"call": "render",
"least_calls": 4,
"most_calls": 4,
"wall": 383792,
"on_cpu": 27542,
"blocked": 344167,
"wall_least": 345500,
"wall_most": 677500,
"wall_total": 7677876,
"on_cpu_total": 332917,
"blocked_total": 7175833
},
{
"call": "render_pipeline",
"least_calls": 2,
"most_calls": 2,
"wall": 123583,
"on_cpu": 123875,
"blocked": 0,
"wall_least": 112750,
"wall_most": 172458,
"wall_total": 294958,
"on_cpu_total": 295458,
"blocked_total": 0
},
{
"call": "target",
"least_calls": 4,
"most_calls": 4,
"wall": 5708,
"on_cpu": 5834,
"blocked": 0,
"wall_least": 4917,
"wall_most": 7250,
"wall_total": 25749,
"on_cpu_total": 26292,
"blocked_total": 0
},
{
"call": "texture",
"least_calls": 4,
"most_calls": 4,
"wall": 14042,
"on_cpu": 14208,
"blocked": 0,
"wall_least": 6625,
"wall_most": 16250,
"wall_total": 73918,
"on_cpu_total": 74750,
"blocked_total": 0
}
]
}
}
]
}
@@ -390,6 +390,36 @@
"hex": "32f0cae59a0afb15a1b89edfa2a946c79a2e8b91d811e665f84560da4d62ef0d"
}
}
},
{
"name": "row:xi_rate2_o1_r3_g8",
"observed": {
"value": "absent",
"digest": {
"kind": "sha256",
"hex": "59645711db9e3d94ae3333cfb98a0ee8e5829833c3548b476a2b2a1dfccc1887"
}
}
},
{
"name": "row:xi_rate3_o2_r4_g12",
"observed": {
"value": "absent",
"digest": {
"kind": "sha256",
"hex": "439d3c3b1a1155cd8a6c1c643adc0646c9f6e00ea60cfc0aa836dcf3f50d943d"
}
}
},
{
"name": "row:yi_rate2_o1_r2_g2x8",
"observed": {
"value": "absent",
"digest": {
"kind": "sha256",
"hex": "978597d33189d31952da85e0fa8d77e209511a2ad4140734f62661dc425a389e"
}
}
}
]
},
@@ -3377,6 +3407,321 @@
}
]
},
{
"name": "xi_rate2_o1_r3_g8/pipeline",
"observed": {
"value": {
"variant": {
"name": "Ok",
"payload": "absent"
}
}
}
},
{
"name": "xi_rate2_o1_r3_g8/buffer/0",
"observed": {
"value": {
"variant": {
"name": "Ok",
"payload": "absent"
}
}
}
},
{
"name": "xi_rate2_o1_r3_g8/buffer/region",
"observed": {
"value": {
"variant": {
"name": "Ok",
"payload": "absent"
}
}
}
},
{
"name": "xi_rate2_o1_r3_g8/dispatch",
"observed": {
"value": {
"variant": {
"name": "Ok",
"payload": "absent"
}
}
}
},
{
"name": "xi_rate2_o1_r3_g8/status",
"observed": {
"value": {
"variant": {
"name": "Ok",
"payload": {
"variant": {
"name": "Completed",
"payload": "absent"
}
}
}
}
}
},
{
"name": "xi_rate2_o1_r3_g8/read-back",
"observed": {
"value": {
"variant": {
"name": "Ok",
"payload": "absent"
}
}
}
},
{
"name": "xi_rate2_o1_r3_g8",
"observed": {
"value": "absent"
},
"children": [
{
"name": "output",
"observed": {
"value": {
"bytes": "JQEAACUBAAAnAQAAJwEAACkBAAApAQAAKQEAACkBAADu7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7g=="
},
"shape": {
"bytes": {
"region": {
"buffer": {
"offset": 0,
"length": 1024
}
},
"element": "u32",
"row_offset": 0,
"row_elements": 8,
"row_pitch": 32,
"rows": 1,
"image_pitch": 1024,
"images": 1,
"gaps": "compared"
}
}
}
}
]
},
{
"name": "xi_rate3_o2_r4_g12/pipeline",
"observed": {
"value": {
"variant": {
"name": "Ok",
"payload": "absent"
}
}
}
},
{
"name": "xi_rate3_o2_r4_g12/buffer/0",
"observed": {
"value": {
"variant": {
"name": "Ok",
"payload": "absent"
}
}
}
},
{
"name": "xi_rate3_o2_r4_g12/buffer/region",
"observed": {
"value": {
"variant": {
"name": "Ok",
"payload": "absent"
}
}
}
},
{
"name": "xi_rate3_o2_r4_g12/dispatch",
"observed": {
"value": {
"variant": {
"name": "Ok",
"payload": "absent"
}
}
}
},
{
"name": "xi_rate3_o2_r4_g12/status",
"observed": {
"value": {
"variant": {
"name": "Ok",
"payload": {
"variant": {
"name": "Completed",
"payload": "absent"
}
}
}
}
}
},
{
"name": "xi_rate3_o2_r4_g12/read-back",
"observed": {
"value": {
"variant": {
"name": "Ok",
"payload": "absent"
}
}
}
},
{
"name": "xi_rate3_o2_r4_g12",
"observed": {
"value": "absent"
},
"children": [
{
"name": "output",
"observed": {
"value": {
"bytes": "JgEAACYBAAAmAQAAKAEAACgBAAAoAQAAKgEAACoBAAAqAQAALAEAACwBAAAsAQAA7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7g=="
},
"shape": {
"bytes": {
"region": {
"buffer": {
"offset": 0,
"length": 1024
}
},
"element": "u32",
"row_offset": 0,
"row_elements": 12,
"row_pitch": 48,
"rows": 1,
"image_pitch": 1024,
"images": 1,
"gaps": "compared"
}
}
}
}
]
},
{
"name": "yi_rate2_o1_r2_g2x8/pipeline",
"observed": {
"value": {
"variant": {
"name": "Ok",
"payload": "absent"
}
}
}
},
{
"name": "yi_rate2_o1_r2_g2x8/buffer/0",
"observed": {
"value": {
"variant": {
"name": "Ok",
"payload": "absent"
}
}
}
},
{
"name": "yi_rate2_o1_r2_g2x8/buffer/region",
"observed": {
"value": {
"variant": {
"name": "Ok",
"payload": "absent"
}
}
}
},
{
"name": "yi_rate2_o1_r2_g2x8/dispatch",
"observed": {
"value": {
"variant": {
"name": "Ok",
"payload": "absent"
}
}
}
},
{
"name": "yi_rate2_o1_r2_g2x8/status",
"observed": {
"value": {
"variant": {
"name": "Ok",
"payload": {
"variant": {
"name": "Completed",
"payload": "absent"
}
}
}
}
}
},
{
"name": "yi_rate2_o1_r2_g2x8/read-back",
"observed": {
"value": {
"variant": {
"name": "Ok",
"payload": "absent"
}
}
}
},
{
"name": "yi_rate2_o1_r2_g2x8",
"observed": {
"value": "absent"
},
"children": [
{
"name": "output",
"observed": {
"value": {
"bytes": "JQEAACUBAAAlAQAAJQEAACcBAAAnAQAAJwEAACcBAAAnAQAAJwEAACcBAAAnAQAAJwEAACcBAAAnAQAAJwEAAO7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7g=="
},
"shape": {
"bytes": {
"region": {
"buffer": {
"offset": 0,
"length": 1024
}
},
"element": "u32",
"row_offset": 0,
"row_elements": 2,
"row_pitch": 8,
"rows": 8,
"image_pitch": 1024,
"images": 1,
"gaps": "compared"
}
}
}
}
]
},
{
"name": "notices",
"observed": {
@@ -3406,7 +3751,12 @@
}
}
],
"validated": "not_run"
"validated": {
"stopped": {
"call": "dispatch_threads",
"message": "unused binding in compute encoder at Buffer index 2.\nunused binding in compute encoder at Buffer index 3."
}
}
}
],
"times": [
+43 -9
View File
@@ -20,8 +20,8 @@ use crate::transcript::{Node, NodeName, Observed, Sites, Transcript, Value};
use crate::verdict::device_gap_of;
use metal2vulkan::metal::state::DepthStencilDescriptor;
use metal2vulkan::metal::{
AttributeFormat, BindingAccess, CompareFunction, IndexType, PixelFormat, RenderStages,
SamplerAddressMode, SamplerBorderColor, SamplerMinMagFilter, SamplerMipFilter,
AttributeFormat, BindingAccess, CompareFunction, IndexType, IndirectCommandType, PixelFormat,
RenderStages, SamplerAddressMode, SamplerBorderColor, SamplerMinMagFilter, SamplerMipFilter,
SamplerReductionMode, StepFunction,
};
@@ -715,10 +715,11 @@ pub struct Venue {
pub lossless_compression: bool,
/// For a CPU implementation (`DeviceKind::Cpu`), the host's widest vector instruction set
/// ([`host_vector_isa`]), which its shader compiler targets; `None` for a GPU. The device's
/// name and driver do not carry it, and its answers follow it: one llvmpipe build (Mesa 26.2.6,
/// LLVM 23.1.4) stored a code from Metal's at 6,496 texels of `fetch-ordered-rgba8unorm-srgb`'s
/// `x3` on a host with AVX-512 (a Ryzen 7 7840HS) and at 6,304 on one with AVX2 alone (an
/// i9-13900H).
/// name and driver do not carry it. Answers can also part by a finer property of the host than
/// this: llvmpipe of Mesa 26.2.4 and LLVM 23.1.1 stored a code from Metal's at 6,304 texels of
/// `fetch-ordered-rgba8unorm-srgb`'s `x3` on the x86-64 AVX-512 runner of one CI run and at
/// 6,496 on those of two others, so the ledger's row there lists both answers
/// ([`crate::known_gaps::KnownGap::answers`]).
pub host: Option<String>,
}
@@ -787,6 +788,16 @@ pub trait Side {
/// Where the side runs.
fn venue(&self) -> Venue;
/// The macOS release and build the side runs on, as `sw_vers -productVersion` and
/// `-buildVersion` answer them on this host (empty where it does not answer): what record mode
/// holds against the oracle the suite names before it takes an answer
/// ([`crate::record::record`]). Every side runs on its host's; a test's stub states the one it
/// stands for.
#[cfg(target_os = "macos")]
fn macos_release(&self) -> (String, String) {
crate::record::sw_vers()
}
/// A library of the shader's AIR, from whichever of its forms the side reads
/// ([`ShaderSource`]).
fn library(&mut self, source: &ShaderSource<'_>) -> Answer<Handle>;
@@ -2155,6 +2166,22 @@ pub trait Side {
Err(Failure::unavailable("empty_command_buffers"))
}
/// The sequence of [`crate::managed_naming`] with `way`'s reader, made of `libraries`: a
/// Managed buffer's contents synced, named and passed by a commit that does not name the
/// buffer, then written again after the reader is encoded, and the reader's command buffer
/// committed. Answers the bytes the reader wrote ([`crate::managed_naming::Way::reads`]). A
/// side whose device keeps one copy of a Managed buffer answers a reader that reaches the
/// buffer through its address alone with the venue's gap: the row asks what the device's
/// second copy holds.
fn managed_naming(
&mut self,
way: crate::managed_naming::Way,
libraries: crate::managed_naming::Libraries,
) -> Answer<Vec<u8>> {
let _ = (way, libraries);
Err(Failure::unavailable("managed_naming"))
}
/// A command queue's limit on uncompleted command buffers, by the probe both sides run
/// ([`crate::queue_slots`]): the queue is made with `max` as its
/// `maxCommandBufferCount` (`newCommandQueue` where `max` is `None`), and at most `cap` command
@@ -3159,9 +3186,9 @@ pub struct FragmentFilled {
}
/// One execution of a kernel-encoded indirect command buffer over a range a buffer holds, which
/// the GPU writes first: the one shape of indirect command buffer both sides build, indexed
/// triangle draws that inherit the pipeline state and bind their own buffers, encoded by a
/// kernel through the buffer's `gpuResourceID`.
/// the GPU writes first: the one shape of indirect command buffer both sides build, plain or
/// indexed triangle draws or plain or indexed patch draws that inherit the pipeline state and bind
/// their own buffers, encoded by a kernel through the buffer's `gpuResourceID`.
#[derive(Clone, Copy, Debug)]
pub struct EncodedRange<'a> {
/// The library of the kernel and of the drawing functions.
@@ -3174,6 +3201,8 @@ pub struct EncodedRange<'a> {
pub buffers: &'a [Handle],
/// The commands the indirect command buffer holds, which the kernel's threads encode.
pub commands: u32,
/// The buffer's `commandTypes`: one kind alone, the kind the kernel encodes.
pub command_types: IndirectCommandType,
/// `maxVertexBufferBindCount` and `maxFragmentBufferBindCount`.
pub bind_counts: [u32; 2],
/// The pipeline the commands inherit: these vertex and fragment functions over one color
@@ -3181,6 +3210,11 @@ pub struct EncodedRange<'a> {
pub vertex: &'a str,
pub fragment: &'a str,
pub format: PixelFormat,
/// That pipeline's `vertexDescriptor` and tessellation state, where the case states them (a
/// post-tessellation vertex function that reads control points under a control-point index
/// type); `None` leaves Metal's defaults.
pub vertex_layout: Option<crate::render::VertexLayout<'a>>,
pub tessellation: Option<crate::render::TessellationState>,
/// The target's extent in texels, cleared to zero, and the row pitch of its read-back.
pub size: [u32; 2],
pub row_pitch: u32,
@@ -47,6 +47,7 @@ pub mod blend_interactions;
pub mod blend_sweeps;
pub mod blit_encoder_commands;
pub mod blit_indirect_commands;
pub mod block_writes_only;
pub mod border_swizzles;
pub mod buffer_bind_off_alignment;
pub mod buffer_blits;
@@ -71,6 +72,7 @@ pub mod compute_render_chains;
pub mod compute_threadgroups;
pub mod copy_out_strides;
pub mod denormal_word_fetches;
pub mod depth_colour_reads;
pub mod depth_resolve_pairs;
pub mod depth_stencil_copies;
pub mod depth_stencil_space;
@@ -110,6 +112,7 @@ pub mod heap_metal_sizes;
pub mod host_detach;
pub mod host_page_writes;
pub mod imageblock_sizes;
pub mod imageblock_slice_past_grid;
pub mod indirect_command_depth;
pub mod indirect_commands;
pub mod indirect_private_types;
@@ -118,6 +121,7 @@ pub mod int_attributes;
pub mod layered_targets;
pub mod level_sizes;
pub mod library_facts;
pub mod managed_naming;
pub mod math_routines;
pub mod mesh_barriers;
pub mod mesh_commands;
@@ -182,8 +186,10 @@ pub mod simdgroup_lockstep;
pub mod snorm_tile_store;
pub mod sparse_heaps;
pub mod sparse_mappings;
pub mod sparse_status;
pub mod sparse_tiles;
pub mod srgb_fetch;
pub mod srgb_storage_fragment_writes;
pub mod srgb_storage_writes;
pub mod stage_in_regions;
pub mod stage_in_unread;
@@ -384,6 +390,9 @@ pub fn all() -> Vec<Box<dyn Case>> {
for case in depth_texel_reads::all() {
cases.push(Box::new(case));
}
for case in depth_colour_reads::all() {
cases.push(Box::new(case));
}
for case in extended_range_two_planes::all() {
cases.push(Box::new(case));
}
@@ -590,6 +599,7 @@ pub fn all() -> Vec<Box<dyn Case>> {
cases.extend(sparse_mappings::all());
cases.extend(command_buffer_facts::all());
cases.extend(empty_command_buffers::all());
cases.extend(managed_naming::all());
cases.extend(fresh_contents::all());
cases.extend(sample_positions::all());
cases.extend(
@@ -615,6 +625,11 @@ pub fn all() -> Vec<Box<dyn Case>> {
cases.push(Box::new(case));
}
cases.push(Box::new(srgb_storage_writes::SrgbStorageWrites));
cases.push(Box::new(block_writes_only::BlockWritesOnlyWrites));
cases.push(Box::new(sparse_status::SparseStatusPlain));
cases.push(Box::new(
srgb_storage_fragment_writes::SrgbStorageFragmentWrites,
));
cases.extend(norm_storage_writes::NormStorageWrites::all());
cases.extend(texel_swizzles::all());
for case in swizzled_storage::all() {
@@ -656,6 +671,9 @@ pub fn all() -> Vec<Box<dyn Case>> {
cases.push(Box::new(buffer_bind_off_alignment::BufferBindOffAlignment));
cases.push(Box::new(threadgroup_start::ThreadgroupStart));
cases.push(Box::new(imageblock_sizes::ImageblockSizes));
cases.push(Box::new(
imageblock_slice_past_grid::ImageblockSlicePastGrid,
));
cases.push(Box::new(nan_integer_conversions::NanIntegerConversions));
cases.push(Box::new(function_constants_half3::FunctionConstantsHalf3));
cases.push(Box::new(bicubic_texel_classes::BicubicTexelClasses));
@@ -0,0 +1,205 @@
//! `block-writes-only-writes`: what a kernel's `access::write` stores into a texture whose usage
//! holds the private bit `BlockWritesOnly` (`0x10000`) and no `ShaderWrite`.
//!
//! The public `MTLTexture.h` of macOS 27.0.1 does not define the bit. On an Apple M3 Max under
//! macOS 27.0.1 (job m3-max-83917), a kernel's write to an `RGBA8Unorm` texture of `ShaderRead |
//! RenderTarget | BlockWritesOnly` (`0x10005`) lands, in Shared and Private storage, plain and
//! under Metal's validation layer, which passes it, where it stops the same write to a texture of
//! `ShaderRead | RenderTarget` (`0x5`): `writes texture (t[1]) whose usage (0x05) doesn't specify
//! MTLTextureUsageShaderWrite (0x02)`. This case records the write's texels for that usage and for
//! the bit alone (`0x10000`).
//!
//! The kernel is the owned fixture `fpv_srgb_storage`'s `fpv_srgb_write`, which writes buffer 0's
//! `float4` at the thread's texel of a row [`WIDTH`] texels wide (buffer 1). Each value is a code
//! over 255, so the stored byte is that code exactly, away from where a device's conversion rounds.
//!
//! One compute pass a usage, one thread a texel, no loop and no sampling: nothing here can fault a
//! GPU.
use crate::case::{call, made, Abort, Bindings, Case, Failure, Input, MetalSource, Side};
use crate::fixture::{Fixture, METAL_TEXT, RUNTIME_TEXT};
use crate::recording::ShaderRef;
use crate::texture::TextureRequest;
use crate::transcript::{Aspect, ByteLayout, Digest, Element, Gaps, Node, Observed, Region, Sites};
use metal2vulkan::metal::{PixelFormat, TextureUsage};
/// The fixture the kernel lives in.
const FIXTURE: &str = "fpv_srgb_storage";
/// The kernel the case runs.
const KERNEL: &str = "fpv_srgb_write";
/// The texture's width, which buffer 1 holds.
pub const WIDTH: u32 = 16;
/// The texture's height.
pub const HEIGHT: u32 = 1;
/// The usages the case writes a texture of: the guest's `ShaderRead | RenderTarget |
/// BlockWritesOnly`, and the bit alone.
pub fn usages() -> [TextureUsage; 2] {
let block = TextureUsage::BLOCK_WRITES_ONLY;
[
TextureUsage::SHADER_READ | TextureUsage::RENDER_TARGET | block,
block,
]
}
/// Texel `i`'s four codes.
pub fn codes(i: u32) -> [u32; 4] {
[i * 16, 255 - i * 16, (i * 37) & 255, 255 - i]
}
/// Buffer 0's bytes: each texel's codes over 255, as `float4`s.
fn values() -> Vec<u8> {
(0..WIDTH * HEIGHT)
.flat_map(codes)
.flat_map(|code| (code as f32 / 255.0).to_bits().to_le_bytes())
.collect()
}
/// Buffer 1's bytes: the row's width, as the kernel's `constant uint &width`.
fn width_bytes() -> Vec<u8> {
WIDTH.to_le_bytes().to_vec()
}
/// The texture a write of `usage` reaches: shared storage, so the host reads it back.
fn request(usage: TextureUsage) -> TextureRequest<'static> {
TextureRequest::read_2d(PixelFormat::RGBA8Unorm.as_raw(), WIDTH, HEIGHT).used(usage)
}
/// The layout the stored bytes are read under: one row a texel row, one code a channel.
fn stored_layout() -> ByteLayout {
let pitch = WIDTH * 4;
ByteLayout {
region: Region::Texture {
level: 0,
slice: 0,
aspect: Aspect::Color,
sample: 0,
origin: [0, 0, 0],
size: [WIDTH, HEIGHT, 1],
},
element: Element::U8,
row_offset: 0,
row_elements: pitch,
row_pitch: pitch,
rows: HEIGHT,
image_pitch: pitch * HEIGHT,
images: 1,
// Four codes a texel cover every byte of a row, so there is no gap.
gaps: Gaps::Ignored,
}
}
/// The case.
pub struct BlockWritesOnlyWrites;
impl Case for BlockWritesOnlyWrites {
fn name(&self) -> &'static str {
"block-writes-only-writes"
}
fn metal_source(&self) -> MetalSource {
MetalSource::Run
}
fn shaders(&self) -> Result<Vec<ShaderRef>, String> {
let fixture = Fixture {
name: FIXTURE,
entry: KERNEL,
};
let mut shaders = Vec::new();
for extension in [RUNTIME_TEXT, METAL_TEXT] {
shaders.push(ShaderRef {
fixture: format!("{FIXTURE}{extension}"),
entry: KERNEL.to_owned(),
source_sha256: crate::sha256_hex(fixture.text(extension)?.as_bytes()),
});
}
Ok(shaders)
}
fn inputs(&self) -> Result<Vec<Input>, String> {
let fixture = Fixture::new(FIXTURE);
let mut inputs = vec![
Input {
name: "air".to_owned(),
digest: Digest::sha256(fixture.text(RUNTIME_TEXT)?.as_bytes()),
},
Input {
name: "air-typed".to_owned(),
digest: Digest::sha256(fixture.text(METAL_TEXT)?.as_bytes()),
},
Input::bytes("buffer:0", &values()),
Input::bytes("buffer:1", &width_bytes()),
];
for usage in usages() {
inputs.push(Input::bytes(
format!("usage-{:#x}", usage.as_raw()),
&request(usage).words(),
));
}
Ok(inputs)
}
fn run(&self, side: &mut dyn Side, sites: &mut Sites) -> Result<(), Abort> {
let loaded = Fixture::new(FIXTURE).loaded().map_err(|why| Abort {
at: "library".to_owned(),
failure: Failure::named("FixtureNotRead", why),
})?;
let library = made(sites, "library", side.library(&loaded.source()))?;
let pipeline = made(sites, "pipeline", side.compute_pipeline(library, KERNEL))?;
let values = made(sites, "buffer/0", side.buffer(&values()))?;
let shape = made(sites, "buffer/width", side.buffer(&width_bytes()))?;
for usage in usages() {
let at = |site: &str| format!("usage-{:#x}/{site}", usage.as_raw());
let texture = made(sites, &at("texture"), side.texture(&request(usage)))?;
let command_buffer = made(
sites,
&at("dispatch"),
side.dispatch(
pipeline,
&Bindings::new(&[texture], &[values, shape]),
[WIDTH / 16, HEIGHT, 1],
[16, 1, 1],
),
)?;
call(
sites,
&at("status"),
side.wait(command_buffer),
Clone::clone,
)?;
let stored = call(
sites,
&at("texels"),
side.read_texture(texture, [WIDTH, HEIGHT], WIDTH * 4),
|_| crate::transcript::Value::Absent,
)?;
sites.push(Node::leaf(
at("stored"),
Observed::bytes(stored, stored_layout()),
));
}
Ok(())
}
}
#[cfg(test)]
mod tests {
use super::*;
/// Every code's value lands on the code itself: its product with 255 is within a hundredth of
/// it, far from the half-code where a conversion rounds.
#[test]
fn every_value_stores_its_code() {
for i in 0..WIDTH * HEIGHT {
for code in codes(i) {
assert!(code <= 255, "texel {i}: {code}");
let back = f64::from(code as f32 / 255.0) * 255.0;
assert!((back - f64::from(code)).abs() < 0.01, "{code}: {back}");
}
}
}
}
@@ -4,7 +4,10 @@
//! Metal's answer here is a **rule**, not a table — "each copy unit of the buffer lands in its
//! sample by the layout measured for colour, texel `(x, y)` sample `s` at
//! `offset + y * bytesPerRow + (x * n + s) * bpp`, the samples outside a region keep the clear, and
//! the copy back out returns the buffer bit for bit" — measured by a probe on an **Apple M4**.
//! the copy back out returns the buffer bit for bit" — measured by a probe on an **Apple M3 Max**
//! under macOS 27.0.1 and on a **Radeon Pro 5300M** and an **Intel UHD Graphics 630** under macOS
//! 26.7.1, each plainly and under Metal's API validation layer; Apple's documentation of the two
//! calls says nothing of a multisample texture.
//! Every call on the path is public: a render pass that clears and draws nothing,
//! `copyFromBuffer:toTexture:` into the depth or stencil aspect, a dispatch that reads every
//! sample, and `copyFromTexture:toBuffer:` back. So record mode **runs** these cases on the oracle,
@@ -38,7 +41,9 @@
//! Nothing here faults a GPU, hangs one or trips a watchdog: one command buffer a row, a clear that
//! draws nothing, two blits and one dispatch of a thread a sample.
use crate::allowance::Allowance;
use crate::case::{call, Abort, Case, Input, MetalSource, Side};
use crate::degradation::Degradation;
use crate::fixture::{Fixture, RUNTIME_TEXT};
use crate::recording::ShaderRef;
use crate::transcript::{ByteLayout, Element, Gaps, Node, Observed, Region, Sites, Value};
@@ -124,12 +129,10 @@ const fn part(name: &'static str, format: u32) -> Row {
/// The rows: the stencil aspect at both sample counts and over a region inside the texture, and
/// the 16-bit depth aspect at both sample counts.
///
/// The two `Depth16Unorm` rows are **open gaps of ours**, each with a `known-gaps-rt.tsv` row:
/// Metal copies the buffer into the 16-bit aspect and back, and we refuse the copy in
/// (`RuntimeGap::MultisampledBufferCopy`, on a device without `maintenance8` or carrying the
/// measured copy defect). A refusal of something plain Metal does is a bug of ours by the owner's
/// standing rule, so the rows stay here and stay red in the ledger's own way: the run prints them
/// as refusals, counts them as refusals, and fails the day either stops refusing.
/// The runtime copies each row as its own work (the runtime's README, the blit encoder's copies):
/// a draw into each sample, and a dispatch out of them. Its copy into a 16-bit depth carries the
/// static note `rounded-sample-depth-copy` (`Texture::SAMPLE_DEPTH_COPY_NOTE`), which the
/// `Depth16Unorm` rows declare.
///
/// # The four rows this family does not yet hold, and what measuring them found
///
@@ -140,12 +143,11 @@ const fn part(name: &'static str, format: u32) -> Row {
/// - **`Depth32Float`, four rows** (54 x 54 and 80 x 80 at 4 samples, 54 x 54 at 2, and a region
/// inside 8 x 8). Metal returns the buffer **bit for bit**, every edge value included: both
/// denormals, every NaN payload, both infinities, -1, 1, the float after 1, 2 and the largest
/// float all come back unchanged, and the samples outside a region keep the clear. Ours differs
/// at **one element of all four rows** — copy unit 1, the edge value **-0**, which Metal keeps
/// and we answer as +0. The suite has no way to allow that alone: an
/// [`Allowance`](crate::allowance::Allowance) covers a **site**, and loosening a 46,656-byte site
/// to tolerate four bytes would throw away the comparison that makes the row worth having. A
/// per-element allowance on a bytes site is what these rows are waiting for.
/// float all come back unchanged, and the samples outside a region keep the clear. The runtime
/// refuses the copy of a multisample 32-bit float depth (`Gap::TextureBytes` of
/// `TextureBytesCause::MultisampleFloatDepth`): the draw that would write it takes no value
/// outside `[0, 1]` through `FragDepth`, and Metal's answer for those values is to be read on a
/// Mac again first.
const ROWS: [Row; 5] = [
whole("buffer-depth-samples-s8-54-4", STENCIL8, 4, 54),
whole("buffer-depth-samples-s8-54-2", STENCIL8, 2, 54),
@@ -371,6 +373,16 @@ impl Case for BufferDepthSamples {
MetalSource::Run
}
fn allowances(&self) -> Vec<Allowance> {
// The runtime's copy into a multisample 16-bit depth carries its static note
// (`rounded-sample-depth-copy`), which moves no code on a device that rounds to nearest
// or toward zero: one declaration, which loosens the notices site alone.
(self.row.format == DEPTH16UNORM)
.then(|| crate::replay::notice_allowance(Degradation::RoundedSampleDepthCopy.code()))
.into_iter()
.collect()
}
fn shaders(&self) -> Result<Vec<ShaderRef>, String> {
let fixture = Fixture::new(KERNELS);
Ok(vec![ShaderRef {
@@ -0,0 +1,569 @@
//! What a kernel reads of a `Depth32Float` texture bound to a `texture2d<float>` slot: its
//! samples, its gathers of green and alpha, and the same reads through a view swizzled
//! `(Green, Red, One, Zero)`, beside the texture's `depth2d` sample and comparison.
//!
//! The owned fixture `dvw_depth_views` holds the five kernels. Each reads slot 0 through the
//! runtime sampler at slot 0 at lane `i`'s normalized coordinate (buffer 1) and writes one
//! `float4` (buffer 0): the sample, the gather of green (`component::y`) or of alpha
//! (`component::w`), the `depth2d` sample in red, or the `depth2d` comparison against 0.5 in red.
//! The texture is 8 by 5, columns 0 to 3 holding 0.25 and columns 4 to 7 holding 0.75, and the
//! five lanes sit on row 2's centre at texel-space `x` 1.5, 3.75, 4.25, 6.5 and -3: two texel
//! centres, a quarter texel each side of the edge between the values, and one past the left edge.
//! Every coordinate is exact in `float`, and so is every weight they make. The M3 Max filters a
//! comparison at a quarter exactly; at 7/32 its sum is 0.2188725 (a recording at other lanes),
//! where a device of exact weights answers 0.21875.
//!
//! **Metal's GPU families answer the colour channels three ways.** Metal states no channels for a
//! depth texture read as a colour texture. Probed with the same kernels on a 6 by 5 texture of the
//! same halves at `x` 1.5, 2.75, 3.25, 4.5 and -3 (`d` is the texel's depth):
//!
//! | Read | Apple M3 Max | AMD Radeon Pro 5300M | Intel UHD Graphics 630 |
//! |---|---|---|---|
//! | sample | `(d, d, d, 1)` | `(d, d, d, d)` | `(d, 0, 0, 1)` |
//! | sample past the edge, opaque white border | `(1, 1, 1, 1)` | `(1, 1, 1, 1)` | `(1, 0, 0, 1)` |
//! | gather of green | `d` | `d` | `0` |
//! | gather of alpha | `1` | `d` | `1` |
//! | sample through the swizzled view | `(d, d, 1, 0)` | `(d, d, 1, 0)` | `(0, d, 1, 0)` |
//! | gather of green through the swizzled view | `d` | `d` | `d` |
//!
//! The M3 Max under macOS 27.0.1 (job m3-max-84755), the 5300M and the 630 in one MacBook Pro
//! under macOS 26.7.1 (job m3-max-84762); `Depth16Unorm` read the same way on each. The red channel
//! is the depth on every Mac, and each composes a view's swizzle over its own answer. The
//! `depth2d` sample and comparison answered alike on all three.
//!
//! **What is compared.** The recording is the M3 Max's. Every element compares exactly, except
//! where the 630's answer differs from the M3 Max's: there the element may hold the 630's value as
//! well, under docs/API.md's accepted difference `DEPTH_AS_COLOUR`. The runtime's answer is the
//! device's view of the depth aspect, Vulkan's `(D, 0, 0, 1)` (the specification's conversion to
//! RGBA and component substitution), which is the 630's. The `depth2d` reads compare exactly.
//!
//! Nothing here can fault a GPU: thirteen compute passes of five threads each, one sample a
//! thread.
use crate::allowance::{Allowance, Justification, Loosening};
use crate::case::{
call, made, Abort, Bindings, Case, Failure, Input, MetalSource, SamplerSpec, Side,
};
use crate::degradation::Degradation;
use crate::fixture::{Fixture, METAL_TEXT, RUNTIME_TEXT};
use crate::recording::ShaderRef;
use crate::replay::notice_allowance;
use crate::texture::{TextureRequest, Upload};
use crate::transcript::{ByteLayout, Digest, Element, FloatWidth, Node, Observed, Sites, Value};
use metal2vulkan::metal::{
CompareFunction, PixelFormat, SamplerAddressMode, SamplerBorderColor, SamplerMinMagFilter,
TextureSwizzle, TextureSwizzleChannels, TextureUsage,
};
/// The fixture the five kernels live in.
const FIXTURE: &str = "dvw_depth_views";
/// The accepted difference the colour channels' allowances name, by its slug.
const DEPTH_AS_COLOUR: &str = "a-depth-texture-read-through-a-colour-texture-slot-reads-d-0-0-1";
/// The texture's width and height.
const SIZE: [u32; 2] = [8, 5];
/// Each lane's texel-space `x` on row 2's centre.
const LANES: [f32; 5] = [1.5, 3.75, 4.25, 6.5, -3.0];
/// The byte every output word holds before the pass.
const BLANK: u8 = 0xab;
/// The depth of column `x`.
fn depth(x: u32) -> f32 {
if x >= 4 {
0.75
} else {
0.25
}
}
/// The texture a read takes: the parent, or the view swizzled `(Green, Red, One, Zero)`.
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
enum Through {
Plain,
Swizzled,
}
/// A sampler state the reads take.
#[derive(Clone, Copy, PartialEq, Eq)]
enum Sampler {
Nearest,
Linear,
NearestWhiteBorder,
LinearWhiteBorder,
NearestLess,
LinearLess,
}
impl Sampler {
const ALL: [Sampler; 6] = [
Sampler::Nearest,
Sampler::Linear,
Sampler::NearestWhiteBorder,
Sampler::LinearWhiteBorder,
Sampler::NearestLess,
Sampler::LinearLess,
];
fn name(self) -> &'static str {
match self {
Sampler::Nearest => "nearest",
Sampler::Linear => "linear",
Sampler::NearestWhiteBorder => "nearest-white-border",
Sampler::LinearWhiteBorder => "linear-white-border",
Sampler::NearestLess => "nearest-less",
Sampler::LinearLess => "linear-less",
}
}
fn spec(self) -> SamplerSpec {
let filter = match self {
Sampler::Nearest | Sampler::NearestWhiteBorder | Sampler::NearestLess => {
SamplerMinMagFilter::Nearest
}
Sampler::Linear | Sampler::LinearWhiteBorder | Sampler::LinearLess => {
SamplerMinMagFilter::Linear
}
};
let spec = SamplerSpec::filtered(filter);
match self {
Sampler::NearestWhiteBorder | Sampler::LinearWhiteBorder => spec
.addressed(SamplerAddressMode::ClampToBorderColor)
.bordered(SamplerBorderColor::OpaqueWhite),
Sampler::NearestLess | Sampler::LinearLess => spec.comparing(CompareFunction::Less),
Sampler::Nearest | Sampler::Linear => spec,
}
}
}
/// One read of the case: its site, its kernel, its sampler, the texture it reads, and the
/// components (0 red to 3 alpha) where the 630's answer differs from the M3 Max's, which hold
/// 0 there.
struct Read {
site: &'static str,
kernel: &'static str,
sampler: Sampler,
through: Through,
unlike: &'static [usize],
}
/// The reads, in order.
const READS: [Read; 13] = [
Read {
site: "sample/nearest",
kernel: "dvw_sample",
sampler: Sampler::Nearest,
through: Through::Plain,
unlike: &[1, 2],
},
Read {
site: "sample/linear",
kernel: "dvw_sample",
sampler: Sampler::Linear,
through: Through::Plain,
unlike: &[1, 2],
},
Read {
site: "sample/nearest-white-border",
kernel: "dvw_sample",
sampler: Sampler::NearestWhiteBorder,
through: Through::Plain,
unlike: &[1, 2],
},
Read {
site: "sample/linear-white-border",
kernel: "dvw_sample",
sampler: Sampler::LinearWhiteBorder,
through: Through::Plain,
unlike: &[1, 2],
},
Read {
site: "gather-green/nearest",
kernel: "dvw_gather_green",
sampler: Sampler::Nearest,
through: Through::Plain,
unlike: &[0, 1, 2, 3],
},
Read {
site: "gather-alpha/nearest",
kernel: "dvw_gather_alpha",
sampler: Sampler::Nearest,
through: Through::Plain,
unlike: &[],
},
Read {
site: "swizzled-sample/nearest",
kernel: "dvw_sample",
sampler: Sampler::Nearest,
through: Through::Swizzled,
unlike: &[0],
},
Read {
site: "swizzled-sample/nearest-white-border",
kernel: "dvw_sample",
sampler: Sampler::NearestWhiteBorder,
through: Through::Swizzled,
unlike: &[0],
},
Read {
site: "swizzled-gather-green/nearest",
kernel: "dvw_gather_green",
sampler: Sampler::Nearest,
through: Through::Swizzled,
unlike: &[],
},
Read {
site: "depth/nearest",
kernel: "dvw_depth",
sampler: Sampler::Nearest,
through: Through::Plain,
unlike: &[],
},
Read {
site: "depth/linear",
kernel: "dvw_depth",
sampler: Sampler::Linear,
through: Through::Plain,
unlike: &[],
},
Read {
site: "compare/nearest",
kernel: "dvw_compare",
sampler: Sampler::NearestLess,
through: Through::Plain,
unlike: &[],
},
Read {
site: "compare/linear",
kernel: "dvw_compare",
sampler: Sampler::LinearLess,
through: Through::Plain,
unlike: &[],
},
];
/// The kernels, each once.
const KERNELS: [&str; 5] = [
"dvw_sample",
"dvw_gather_green",
"dvw_gather_alpha",
"dvw_depth",
"dvw_compare",
];
/// The view's swizzle: `(Green, Red, One, Zero)`.
fn swizzle() -> TextureSwizzleChannels {
TextureSwizzleChannels::new(
TextureSwizzle::Green,
TextureSwizzle::Red,
TextureSwizzle::One,
TextureSwizzle::Zero,
)
}
/// The texture's texels, row major, four bytes each.
fn texels() -> Vec<u8> {
(0..SIZE[1])
.flat_map(|_| (0..SIZE[0]).flat_map(|x| depth(x).to_le_bytes()))
.collect()
}
/// The coordinates the kernels read at buffer 1: each lane's normalized `(x, y)`.
fn coords() -> Vec<u8> {
let [w, h] = SIZE.map(|s| s as f32);
LANES
.iter()
.flat_map(|x| [x / w, 2.5 / h])
.flat_map(f32::to_le_bytes)
.collect()
}
/// The output buffer before a pass: one `float4` a lane.
fn blank() -> Vec<u8> {
vec![BLANK; LANES.len() * 16]
}
/// The layout a read-back is read under: one row a lane, its four `float`s.
fn layout() -> ByteLayout {
let row = 16u32;
ByteLayout {
region: crate::transcript::Region::Buffer {
offset: 0,
length: u64::from(row) * LANES.len() as u64,
},
element: Element::F32,
row_offset: 0,
row_elements: 4,
row_pitch: row,
rows: LANES.len() as u32,
image_pitch: row * LANES.len() as u32,
images: 1,
gaps: crate::transcript::Gaps::Ignored,
}
}
/// The parent texture: `Depth32Float`, shader-read, and viewable as another texture, as the
/// probe made it.
fn texture() -> TextureRequest<'static> {
let mut request = TextureRequest::read_2d(PixelFormat::Depth32Float.as_raw(), SIZE[0], SIZE[1]);
request.usage = TextureUsage::SHADER_READ.union(TextureUsage::PIXEL_FORMAT_VIEW);
request
}
/// The case.
pub struct DepthColourReads;
/// The one case of the family.
pub fn all() -> Vec<DepthColourReads> {
vec![DepthColourReads]
}
impl Case for DepthColourReads {
fn name(&self) -> &'static str {
"depth-colour-reads"
}
fn metal_source(&self) -> MetalSource {
MetalSource::Run
}
fn allowances(&self) -> Vec<Allowance> {
// The samples are through a runtime sampler slot, which the runtime's pipelines note as
// scaled (`crate::replay::pixel_sampler_scaling_notice` holds why).
let mut allowances = vec![crate::replay::pixel_sampler_scaling_notice()];
// The comparing stage records that its texels hold no value outside [0, 1]
// (`restricted-depth-range`), and the upload into a 32-bit float depth carries its note
// (`restricted-depth-upload`). Every texel is 0.25 or 0.75, so neither moves a value:
// measured through the rt side on lavapipe, the notices site was the whole of their
// difference (job m3-max-84879).
allowances.push(notice_allowance(Degradation::RestrictedDepthRange.code()));
allowances.push(notice_allowance(Degradation::RestrictedDepthUpload.code()));
let zero = Value::Float {
bits: 0,
width: FloatWidth::Single,
};
for read in &READS {
for lane in 0..LANES.len() {
for &component in read.unlike {
let at = (lane * 4 + component) * 4;
allowances.push(Allowance::new(
format!("case/{}/words/{at}", read.site),
Loosening::AnyOf(vec![zero.clone()]),
Justification::accepted(DEPTH_AS_COLOUR),
));
}
}
}
allowances
}
fn shaders(&self) -> Result<Vec<ShaderRef>, String> {
let mut shaders = Vec::new();
for kernel in KERNELS {
let fixture = Fixture {
name: FIXTURE,
entry: kernel,
};
for extension in [RUNTIME_TEXT, METAL_TEXT] {
shaders.push(ShaderRef {
fixture: format!("{FIXTURE}{extension}"),
entry: kernel.to_owned(),
source_sha256: crate::sha256_hex(fixture.text(extension)?.as_bytes()),
});
}
}
Ok(shaders)
}
fn inputs(&self) -> Result<Vec<Input>, String> {
let fixture = Fixture::new(FIXTURE);
let bytes = texels();
let uploads = [Upload::level_0(SIZE, SIZE[0] * 4, SIZE[1], &bytes)];
let parent = texture().loaded(&uploads);
let mut view = parent;
view.swizzle = swizzle();
let mut inputs = vec![
Input {
name: "air".to_owned(),
digest: Digest::sha256(fixture.text(RUNTIME_TEXT)?.as_bytes()),
},
Input {
name: "air-typed".to_owned(),
digest: Digest::sha256(fixture.text(METAL_TEXT)?.as_bytes()),
},
Input::bytes("buffer:coords", &coords()),
Input::bytes("buffer:blank", &blank()),
Input::bytes("texture", &parent.words()),
Input::bytes("texture:swizzled-view", &view.words()),
];
for sampler in Sampler::ALL {
inputs.push(Input::bytes(
format!("sampler:{}", sampler.name()),
&sampler.spec().words(),
));
}
Ok(inputs)
}
fn run(&self, side: &mut dyn Side, sites: &mut Sites) -> Result<(), Abort> {
let stop = |at: &str, why: String| Abort {
at: at.to_owned(),
failure: Failure::named("FixtureNotRead", why),
};
let loaded = Fixture::new(FIXTURE)
.loaded()
.map_err(|why| stop("library", why))?;
let library = made(sites, "library", side.library(&loaded.source()))?;
let mut pipelines = Vec::with_capacity(KERNELS.len());
for kernel in KERNELS {
let at = format!("pipeline/{kernel}");
pipelines.push(made(sites, &at, side.compute_pipeline(library, kernel))?);
}
let bytes = texels();
let uploads = [Upload::level_0(SIZE, SIZE[0] * 4, SIZE[1], &bytes)];
let parent = made(sites, "texture", side.texture(&texture().loaded(&uploads)))?;
let mut view = texture().viewing(parent);
view.swizzle = swizzle();
let swizzled = made(sites, "texture/swizzled-view", side.texture(&view))?;
let mut samplers = Vec::with_capacity(Sampler::ALL.len());
for sampler in Sampler::ALL {
let at = format!("sampler/{}", sampler.name());
samplers.push(made(sites, &at, side.sampler(&sampler.spec()))?);
}
let coords = made(sites, "buffer/coords", side.buffer(&coords()))?;
for read in &READS {
let at = |site: &str| format!("{}/{site}", read.site);
let Some(index) = KERNELS.iter().position(|k| *k == read.kernel) else {
return Err(stop(read.site, format!("no kernel {}", read.kernel)));
};
let Some(sampler) = Sampler::ALL.iter().position(|s| *s == read.sampler) else {
return Err(stop(read.site, "no sampler".to_owned()));
};
let texture = match read.through {
Through::Plain => parent,
Through::Swizzled => swizzled,
};
let out = made(sites, &at("buffer/out"), side.buffer(&blank()))?;
let command_buffer = made(
sites,
&at("dispatch"),
side.dispatch_threads(
pipelines[index],
&Bindings::new(&[texture], &[out, coords]).sampled(&[samplers[sampler]]),
&[],
[LANES.len() as u32, 1, 1],
[LANES.len() as u32, 1, 1],
),
)?;
call(
sites,
&at("status"),
side.wait(command_buffer),
Clone::clone,
)?;
let words = call(
sites,
&at("read-back"),
side.read_buffer(out, 0, blank().len()),
|_| Value::Absent,
)?;
sites.push(
Node::branch(read.site, Vec::new())
.with(Node::leaf("words", Observed::bytes(words, layout()))),
);
}
Ok(())
}
}
#[cfg(test)]
mod tests {
use super::*;
/// A Mac family's answer to a read of the case: the probes' table (module docs), as rules of
/// the texel's depth `d`.
#[derive(Clone, Copy, Debug, PartialEq)]
enum Mac {
M3Max,
Radeon5300M,
Uhd630,
}
impl Mac {
/// The texel a sample of depth `d` reads, before a view's swizzle; past the edge under
/// an opaque white border, `d` is 1.
fn texel(self, d: f32) -> [f32; 4] {
match self {
Mac::M3Max => [d, d, d, 1.0],
Mac::Radeon5300M => [d; 4],
Mac::Uhd630 => [d, 0.0, 0.0, 1.0],
}
}
}
/// The `(Green, Red, One, Zero)` swizzle of `t`.
fn swizzled(t: [f32; 4]) -> [f32; 4] {
[t[1], t[0], 1.0, 0.0]
}
/// The components where the 630's sample differs from the M3 Max's are the ones each read
/// lets hold 0, and 0 is the 630's value there, at any depth and past the edge under the
/// white border: the allowances admit the 630's answer and no other.
#[test]
fn the_allowed_components_are_where_the_630_differs_from_the_m3_max() {
for read in &READS {
let unlike: Vec<usize> = match (read.kernel, read.through) {
("dvw_sample", Through::Plain) => {
let (m3, intel) = (Mac::M3Max.texel(0.25), Mac::Uhd630.texel(0.25));
(0..4).filter(|&c| m3[c] != intel[c]).collect()
}
("dvw_sample", Through::Swizzled) => {
let m3 = swizzled(Mac::M3Max.texel(0.25));
let intel = swizzled(Mac::Uhd630.texel(0.25));
(0..4).filter(|&c| m3[c] != intel[c]).collect()
}
// A gather of green reads each tap's green: the 630's is 0, the M3 Max's the
// depth; through the view, green is red, the depth on both.
("dvw_gather_green", Through::Plain) => vec![0, 1, 2, 3],
("dvw_gather_green", Through::Swizzled) => vec![],
// A gather of alpha reads 1 on both; the `depth2d` reads agree on all three.
_ => vec![],
};
assert_eq!(read.unlike, unlike.as_slice(), "{}", read.site);
for &c in &unlike {
let intel = match read.through {
Through::Plain => Mac::Uhd630.texel(0.75),
Through::Swizzled => swizzled(Mac::Uhd630.texel(0.75)),
};
if read.kernel == "dvw_sample" {
assert_eq!(intel[c], 0.0, "{} component {c}", read.site);
}
}
}
}
/// The 5300M answers a sample's alpha with the depth, where the M3 Max and the 630 answer 1:
/// no one answer of the colour channels is every Mac's.
#[test]
fn no_one_answer_is_every_macs() {
let answers = [Mac::M3Max, Mac::Radeon5300M, Mac::Uhd630].map(|m| m.texel(0.25));
assert_ne!(answers[0], answers[1]);
assert_ne!(answers[0], answers[2]);
assert_ne!(answers[1], answers[2]);
assert!(
answers.iter().all(|t| t[0] == 0.25),
"red is the depth on every Mac"
);
}
/// Every coordinate is exact in `float`, so a linear weight is the same on every device.
#[test]
fn the_coordinates_are_exact() {
for x in LANES {
let u = x / SIZE[0] as f32;
assert_eq!(u * SIZE[0] as f32, x, "lane {x}");
}
}
}
@@ -249,19 +249,14 @@ fn unspecialized() -> HeapSizeCase {
}
}
/// The formats Metal describes no texture of alone: `RGBA16Float_XR`, `AnyDepth`, `AnyStencil` and
/// a two-plane YCbCr format. Each answers 0 bytes at its texture type's alignment, and no texture.
/// The formats Metal describes no texture of alone
/// ([`WITHOUT_TEXTURES`](crate::texture_query::WITHOUT_TEXTURES)). Each answers 0 bytes at its texture type's alignment, and no texture.
///
/// `AnyDepth` and `AnyStencil` are asked in the 2D and cube types alone: Metal's validation stops a
/// one-dimensional, 3D or buffer descriptor of either, which ends its process.
fn formats_without_textures() -> HeapSizeCase {
let mut queries = Vec::new();
for format in [
PixelFormat::RGBA16FloatXR,
PixelFormat::AnyDepth,
PixelFormat::AnyStencil,
PixelFormat::YCBCR84202P,
] {
for format in crate::texture_query::WITHOUT_TEXTURES {
let any_depth = matches!(format, PixelFormat::AnyDepth | PixelFormat::AnyStencil);
for (texture_type, depth, slices) in STACKABLE_TYPES {
let one_dimensional =
@@ -0,0 +1,270 @@
//! A kernel's explicit imageblock written through a slice from a partial threadgroup: what the
//! cells of the threads past the grid hold.
//!
//! The owned fixture `tib_imageblock_slices`'s `tib_slot_half_slice` (its source says what each
//! thread does) runs as one compute pass: the encoder sets a 4 by 4 imageblock, then
//! `dispatchThreads:threadsPerThreadgroup:` runs a grid of 6 by 7 threads in 4 by 4 threadgroups,
//! so three of the four threadgroups are partial: one in x, one in y and the corner. Each thread
//! stores its value in its own cell, and after the imageblock barrier the threadgroup's first
//! thread writes the whole 4 by 4 slice at its threadgroup's origin of an 8 by 8 `RGBA16Float`
//! texture, so every slice lies inside it.
//!
//! Metal's documentation says nothing of what a slice holds at the cells of threads a partial
//! threadgroup does not run. This case carries the answer the Apple M3 Max recorded, and claims no
//! more than that: every such cell's texel is zero, as a texel the slice did not write would keep
//! [`SENTINEL`] and a cell some thread stored would hold that thread's value.
//!
//! Every texel holds [`SENTINEL`] before the dispatch, and the texture is compared whole. Every
//! value is exact in a half. Nothing here can fault a GPU: one pass of one dispatch, four
//! threadgroups of at most 16 threads, loop-free, every cell a thread stores its own and every
//! slice inside the texture.
use crate::case::{
call, made, Abort, Case, Failure, Handle, Input, MetalSource, Side, TextureRole, TextureSpec,
};
use crate::compute_pass::{ComputePass, ComputeStep, Dispatching};
use crate::fixture::{Fixture, METAL_TEXT, RUNTIME_TEXT};
use crate::recording::ShaderRef;
use crate::transcript::{
Aspect, ByteLayout, Digest, Element, Gaps, Node, Observed, Region, Sites, Value,
};
use metal2vulkan::metal::PixelFormat;
/// The case.
pub struct ImageblockSlicePastGrid;
/// The case's name.
pub const NAME: &str = "compute-imageblock-slice-past-the-grid";
/// The fixture and the kernel the case runs.
const FIXTURE: Fixture = Fixture {
name: "tib_imageblock_slices",
entry: "tib_slot_half_slice",
};
/// A threadgroup's threads along x and y, which is the imageblock's extent too.
const GROUP: u32 = 4;
/// The grid, in threads: not a whole number of threadgroups along either axis.
const GRID: [u32; 3] = [6, 7, 1];
/// The texture's extent: the grid's threadgroups, whole.
const SIZE: [u32; 2] = [8, 8];
/// Bytes of one `RGBA16Float` texel.
const TEXEL: u32 = 8;
/// The half every channel of every texel holds before the dispatch: -1.
pub const SENTINEL: u16 = 0xbc00;
/// The texture's bytes before the dispatch.
fn fill() -> Vec<u8> {
SENTINEL
.to_le_bytes()
.repeat((SIZE[0] * SIZE[1] * 4) as usize)
}
fn spec() -> TextureSpec {
TextureSpec::new(
PixelFormat::RGBA16Float,
SIZE,
SIZE[0] * TEXEL,
TextureRole::Write,
)
}
/// The layout the texels are compared under: one row a texel, a half a channel, so a difference
/// names the texel (`y * 8 + x`) and the channel.
fn layout() -> ByteLayout {
let texels = SIZE[0] * SIZE[1];
ByteLayout {
region: Region::Texture {
level: 0,
slice: 0,
aspect: Aspect::Color,
sample: 0,
origin: [0, 0, 0],
size: [SIZE[0], SIZE[1], 1],
},
element: Element::U16,
row_offset: 0,
row_elements: 4,
row_pitch: TEXEL,
rows: texels,
image_pitch: texels * TEXEL,
images: 1,
// A row is one texel's channels and the texels abut, so there is no byte outside one.
gaps: Gaps::Ignored,
}
}
/// The pass: the texture at slot 0, the imageblock's size, one dispatch of the grid.
fn steps(pipeline: Handle, texture: Handle) -> Vec<ComputeStep> {
vec![
ComputeStep::Pipeline(pipeline),
ComputeStep::Texture { texture, index: 0 },
ComputeStep::ImageblockSize {
width: GROUP,
height: GROUP,
},
ComputeStep::DispatchThreads {
grid: GRID,
threads: [GROUP, GROUP, 1],
},
]
}
impl Case for ImageblockSlicePastGrid {
fn name(&self) -> &'static str {
NAME
}
fn metal_source(&self) -> MetalSource {
MetalSource::Run
}
fn shaders(&self) -> Result<Vec<ShaderRef>, String> {
let mut shaders = Vec::new();
for extension in [RUNTIME_TEXT, METAL_TEXT] {
shaders.push(ShaderRef {
fixture: format!("{}{extension}", FIXTURE.name),
entry: FIXTURE.entry.to_owned(),
source_sha256: crate::sha256_hex(FIXTURE.text(extension)?.as_bytes()),
});
}
Ok(shaders)
}
fn inputs(&self) -> Result<Vec<Input>, String> {
let steps = steps(Handle(0), Handle(0));
Ok(vec![
Input {
name: "air".to_owned(),
digest: Digest::sha256(FIXTURE.text(RUNTIME_TEXT)?.as_bytes()),
},
Input {
name: "air-typed".to_owned(),
digest: Digest::sha256(FIXTURE.text(METAL_TEXT)?.as_bytes()),
},
Input::bytes("entry", FIXTURE.entry.as_bytes()),
Input::bytes("texture:fill", &fill()),
// The pass, with its grid and threadgroup: a case re-pointed at another grid is
// another question, so its recording cannot stand for this one.
Input::bytes(
"pass",
&ComputePass {
dispatching: Dispatching::Serial,
steps: &steps,
}
.words(),
),
])
}
fn run(&self, side: &mut dyn Side, sites: &mut Sites) -> Result<(), Abort> {
let loaded = FIXTURE.loaded().map_err(|why| Abort {
at: "library".to_owned(),
failure: Failure::named("FixtureNotRead", why),
})?;
let library = made(sites, "library", side.library(&loaded.source()))?;
let pipeline = made(
sites,
"pipeline",
side.compute_pipeline(library, loaded.entry),
)?;
let texture = made(sites, "texture", side.texture_2d_in_role(&spec(), &fill()))?;
let steps = steps(pipeline, texture);
let outcome = made(
sites,
"pass",
side.compute_pass(&ComputePass {
dispatching: Dispatching::Serial,
steps: &steps,
}),
)?;
sites.push(outcome.node("outcome", &steps));
if let Some((at, failure)) = outcome.first_refusal() {
return Err(Abort {
at: format!("outcome/step/{at}/{}", steps[at].call()),
failure: failure.clone(),
});
}
let stored = call(
sites,
"read-back",
side.read_texture(texture, SIZE, SIZE[0] * TEXEL),
|_| Value::Absent,
)?;
sites.push(Node::leaf("texels", Observed::bytes(stored, layout())));
Ok(())
}
}
#[cfg(test)]
mod tests {
use super::*;
/// The half of `x`, which must be a normal value a half holds exactly.
fn half(x: f32) -> u16 {
let bits = x.to_bits();
let exponent = ((bits >> 23) & 0xff) as u16 - (127 - 15);
assert_eq!(bits & 0x1fff, 0, "{x} is not exact in a half");
(exponent << 10) | ((bits >> 13) & 0x3ff) as u16
}
/// The texels Metal's recording holds: at a grid position, the fixture's value
/// `(1 + x + 8 * y) / 64` and three zeros; at a position past the grid, inside a partial
/// threadgroup's slice, four zeros.
fn recorded() -> Vec<u8> {
let mut bytes = Vec::new();
for y in 0..SIZE[1] {
for x in 0..SIZE[0] {
let first = match x < GRID[0] && y < GRID[1] {
true => half((1 + x + 8 * y) as f32 / 64.0),
false => 0,
};
for channel in [first, 0, 0, 0] {
bytes.extend(channel.to_le_bytes());
}
}
}
bytes
}
/// Metal's recorded answer: every grid thread's texel is its own value, and every cell past
/// the grid is zero, neither the sentinel nor any thread's value.
#[test]
fn metal_recorded_zero_past_the_grid() {
let recording =
crate::recording::read(NAME).unwrap_or_else(|e| panic!("{NAME}: no recording: {e}"));
let want = recorded();
let mut answers = 0;
for metal in &recording.answers {
for outcome in &metal.outcomes {
answers += 1;
let got = outcome
.transcript
.root
.child("texels")
.map(|n| &n.observed.value);
assert!(
matches!(got, Some(Value::Bytes(b)) if *b == want),
"{NAME}: Metal's bytes are {got:?}"
);
}
}
assert!(answers > 0, "{NAME}: no Metal answer");
}
/// The grid leaves a partial threadgroup in x, one in y and the corner, every slice lies
/// inside the texture, and the sentinel is none of the answers.
#[test]
fn the_grid_holds_each_partial_threadgroup_inside_the_texture() {
let groups = GRID.map(|n| n.div_ceil(GROUP));
assert_eq!(groups, [2, 2, 1]);
assert!(!GRID[0].is_multiple_of(GROUP) && !GRID[1].is_multiple_of(GROUP));
assert_eq!(SIZE, [groups[0] * GROUP, groups[1] * GROUP]);
assert_ne!(SENTINEL, 0);
assert!((0..64u32).all(|k| half((1 + k) as f32 / 64.0) != SENTINEL));
}
}
@@ -4,36 +4,57 @@
//! The range is read when the execution runs, not when it is encoded, so each row writes it on the
//! GPU in the execution's own command buffer, over a stale range the host wrote first that would
//! draw every command: a side that read the range before the GPU wrote it draws all eight. The
//! commands are the one shape both sides build ([`EncodedRange`]): indexed triangle draws that
//! inherit the pipeline state and bind their own buffers, encoded by the owned fixture's
//! `icb_indexed_16` kernel through the buffer's `gpuResourceID`. Command `i` draws rows `2i` and
//! `2i + 1` of an 8 by 16 `RGBA32Uint` target, each texel its mark, the provoking vertex's
//! `vid`, its `iid` and its tint, so the target names exactly which commands drew.
//! commands are the one shape both sides build ([`EncodedRange`]): triangle draws that inherit the
//! pipeline state and bind their own buffers, encoded by an owned fixture's kernel through the
//! buffer's `gpuResourceID`. Command `i` draws rows `2i` and `2i + 1` of an 8 by 16 `RGBA32Uint`
//! target, so the target names exactly which commands drew:
//!
//! | Row | The range, and what writes it |
//! |---|---|
//! | [`AT_ZERO`] | commands 0 to 2, a blit's copy before the pass |
//! | [`PAST_ZERO`] | commands 5 and 6, a blit's copy before the pass |
//! | [`DRAWN`] | commands 2 to 5, an earlier draw of the same pass, behind a memory barrier |
//! - indexed draws (`MTLIndirectCommandTypeDrawIndexed`) of `icb_merged_indexed`'s
//! `icb_indexed_16`, each texel its mark, the provoking vertex's `vid`, its `iid` and its tint;
//! - plain draws (`MTLIndirectCommandTypeDraw`) of `icb_merged_draws`'s `icb_merged_triangles`,
//! each command six vertices from vertex `6i`, one instance for an even command and two drawn
//! over each other for an odd one, from base instance `i`, each texel its mark, the provoking
//! vertex's `vid`, its `iid` and the base instance;
//! - patch draws (`MTLIndirectCommandTypeDrawPatches`) of `icb_merged_patches`, each command one
//! quad patch of one control point from patch `i`, with no patch index buffer, its factors a
//! record of level 1, one instance for an even command and two drawn over each other for an odd
//! one, from base instance `i`, the patch a rectangle over the command's rows, each texel its
//! mark, the patch index, its `iid` and the base instance;
//! - indexed patch draws (`MTLIndirectCommandTypeDrawIndexedPatches`) of `icb_merged_ipatches`,
//! each command one quad patch of four control points from patch `i`, read through a
//! `PerPatchControlPoint` layout under the `UInt16` control-point index type: the points are
//! stored out of order and the indices name each corner, so a patch drawn over its rectangle
//! read its indices; with no patch index buffer, its factors a record of level 1, instances and
//! base instances as the patch draws', each texel its mark, the patch index, its `iid` and the
//! base instance.
//!
//! Every row is bounded by construction: eight commands of two triangles each, one target of 8
//! by 16, one kernel thread a command, and no function holds a loop.
//! | Row | The draws | The range, and what writes it |
//! |---|---|---|
//! | [`AT_ZERO`] | indexed | commands 0 to 2, a blit's copy before the pass |
//! | [`PAST_ZERO`] | indexed | commands 5 and 6, a blit's copy before the pass |
//! | [`DRAWN`] | indexed | commands 2 to 5, an earlier draw of the same pass, behind a memory barrier |
//! | [`PLAIN`] | plain | commands 1 to 5, a blit's copy before the pass |
//! | [`PATCHES`] | patches | commands 1 to 5, a blit's copy before the pass |
//! | [`INDEXED_PATCHES`] | indexed patches | commands 1 to 5, a blit's copy before the pass |
//!
//! Every row is bounded by construction: eight commands of two triangles each (an odd plain or
//! patch command's two instances, four; a quad patch of level 1 is two triangles), one target of
//! 8 by 16, one kernel thread a command, and no function holds a loop.
use super::indirect_commands::{fixture_inputs, shaders_of};
use crate::allowance::Allowance;
use crate::case::{call, made, Abort, Case, EncodedRange, Failure, Input, MetalSource, RangeWrite};
use crate::case::{Side, TARGET_TEXEL};
use crate::degradation::Degradation;
use crate::fixture::Fixture;
use crate::recording::ShaderRef;
use crate::render::VertexStride;
use crate::render::{TessellationState, VertexAttribute, VertexBufferLayout, VertexLayout};
use crate::transcript::{Aspect, ByteLayout, Element, Gaps, Node, Observed, Region, Sites};
use metal2vulkan::metal::PixelFormat;
/// The owned fixture whose kernel encodes the commands and whose functions they draw with.
const FIXTURE: &str = "icb_merged_indexed";
/// The kernel that encodes command `tid`, and the state's two functions.
const KERNEL: &str = "icb_indexed_16";
const VERTEX: &str = "icb_indexed_vertex";
const FRAGMENT: &str = "icb_indexed_fragment";
use metal2vulkan::metal::{
IndirectCommandType, PixelFormat, TessellationControlPointIndexType, VertexFormat,
VertexStepFunction,
};
/// The owned fixture whose rasterization-disabled vertex function writes
/// `params[0] * (vid + 1) + params[1]` to `out[vid]` (instance 0): the earlier draw that writes
@@ -62,10 +83,243 @@ const TINT: u32 = 0x200;
pub const AT_ZERO: &str = "indirect-range-gpu-written-at-zero";
pub const PAST_ZERO: &str = "indirect-range-gpu-written-past-zero";
pub const DRAWN: &str = "indirect-range-written-by-an-earlier-draw";
pub const PLAIN: &str = "indirect-range-gpu-written-plain-draws";
pub const PATCHES: &str = "indirect-range-gpu-written-patch-draws";
pub const INDEXED_PATCHES: &str = "indirect-range-gpu-written-indexed-patch-draws";
/// One row: its name, the range the GPU writes (location, length), and what writes it.
/// The indexed patches' control point: a `float2` at attribute 0 of vertex buffer 2.
const CORNER: [VertexAttribute; 1] = [VertexAttribute::new(0, VertexFormat::Float2, 0, 2)];
/// Vertex buffer 2 steps per patch control point, 8 bytes a point.
const CORNERS: [VertexBufferLayout; 1] = [VertexBufferLayout {
index: 2,
stride: VertexStride::Bytes(8),
step: VertexStepFunction::PerPatchControlPoint,
rate: 1,
}];
/// Where the indexed patches store corner `j` of a patch among its four points: the indices
/// put them back in order (point `4i + PLACES[j]` is corner `j` of patch `i`).
const PLACES: [u32; 4] = [2, 0, 3, 1];
/// The draws a row's commands make.
#[derive(Clone, Copy, PartialEq, Eq)]
enum Draws {
/// `icb_merged_indexed`'s indexed draws of 16-bit indices.
Indexed,
/// `icb_merged_draws`'s plain draws.
Plain,
/// `icb_merged_patches`'s patch draws.
Patches,
/// `icb_merged_ipatches`'s indexed patch draws of 16-bit control-point indices.
IndexedPatches,
}
impl Draws {
/// The owned fixture whose kernel encodes the commands and whose functions they draw with.
fn fixture(self) -> &'static str {
match self {
Draws::Indexed => "icb_merged_indexed",
Draws::Plain => "icb_merged_draws",
Draws::Patches => "icb_merged_patches",
Draws::IndexedPatches => "icb_merged_ipatches",
}
}
/// The kernel that encodes command `tid`, and the state's vertex and fragment functions.
fn functions(self) -> [&'static str; 3] {
match self {
Draws::Indexed => [
"icb_indexed_16",
"icb_indexed_vertex",
"icb_indexed_fragment",
],
Draws::Plain => [
"icb_merged_triangles",
"icb_merged_vertex",
"icb_merged_fragment",
],
Draws::Patches => [
"icb_merged_patches",
"icb_merged_patch_vertex",
"icb_merged_patch_fragment",
],
Draws::IndexedPatches => [
"icb_merged_ipatches",
"icb_merged_ipatch_vertex",
"icb_merged_ipatch_fragment",
],
}
}
/// The buffer's `commandTypes`.
fn command_types(self) -> IndirectCommandType {
match self {
Draws::Indexed => IndirectCommandType::DRAW_INDEXED,
Draws::Plain => IndirectCommandType::DRAW,
Draws::Patches => IndirectCommandType::DRAW_PATCHES,
Draws::IndexedPatches => IndirectCommandType::DRAW_INDEXED_PATCHES,
}
}
/// `maxVertexBufferBindCount` and `maxFragmentBufferBindCount`: the vertex function's three
/// buffers, and the indexed fragment function's tint.
fn bind_counts(self) -> [u32; 2] {
match self {
Draws::Indexed => [3, 1],
Draws::Plain | Draws::Patches | Draws::IndexedPatches => [3, 0],
}
}
/// The kernel's buffers 1 and up, by name, and how many of them, from the second, the
/// commands read through their bindings.
///
/// Indexed: each command's draw (first index, index count, instances, base vertex, base
/// instance), the marks, the frame (the target's extent and no instance step), the pixel
/// corners of each command's quad, the tints, and two copies of a quad's six 16-bit indices,
/// command `i` drawing from copy `i % 2`. Plain: each command's draw (vertex start, vertex
/// count, instances, base instance), the marks, the frame, and the pixel positions of each
/// command's six vertices, two triangles over its rows. Patches: each command's draw (patch
/// start, patch count, instances, base instance), the marks, the frame, the pixel corners of
/// each patch's rectangle (top left, bottom right), and the factors: a quad factor record of
/// `half` 1.0 (four edges and two inside factors) for each patch position. Indexed patches:
/// the patch draws, the marks, the frame, each patch's four corners in pixels stored at their
/// [`PLACES`], the 16-bit control-point indices that name them in order, and the factors.
fn kernel_buffers(self) -> Vec<(&'static str, Vec<u8>)> {
let marks: Vec<u32> = (0..COMMANDS).map(|i| MARK + i).collect();
let frame = floats(&[SIZE[0] as f32, SIZE[1] as f32, 0.0, 0.0]);
let rows = |i: u32| ((2 * i) as f32, (2 * i + 2) as f32);
match self {
Draws::Indexed => {
let draws: Vec<u32> = (0..COMMANDS)
.flat_map(|i| [6 * (i % 2), 6, 1, 4 * i, i])
.collect();
let xy: Vec<f32> = (0..COMMANDS)
.flat_map(|i| {
let (top, bottom) = rows(i);
[0.0, top, 8.0, top, 0.0, bottom, 8.0, bottom]
})
.collect();
let tints: Vec<u32> = (0..COMMANDS).map(|i| TINT + i).collect();
let indices: Vec<u8> = [0u16, 1, 2, 2, 1, 3]
.repeat(2)
.iter()
.flat_map(|i| i.to_le_bytes())
.collect();
vec![
("buffer:draws", words(&draws)),
("buffer:marks", words(&marks)),
("buffer:frame", frame),
("buffer:xy", floats(&xy)),
("buffer:tints", words(&tints)),
("buffer:indices", indices),
]
}
Draws::Plain => {
let draws: Vec<u32> = (0..COMMANDS)
.flat_map(|i| [6 * i, 6, 1 + i % 2, i])
.collect();
let xy: Vec<f32> = (0..COMMANDS)
.flat_map(|i| {
let (top, bottom) = rows(i);
[
0.0, top, 8.0, top, 0.0, bottom, 0.0, bottom, 8.0, top, 8.0, bottom,
]
})
.collect();
vec![
("buffer:draws", words(&draws)),
("buffer:marks", words(&marks)),
("buffer:frame", frame),
("buffer:xy", floats(&xy)),
]
}
Draws::Patches => {
let draws: Vec<u32> = (0..COMMANDS).flat_map(|i| [i, 1, 1 + i % 2, i]).collect();
let xy: Vec<f32> = (0..COMMANDS)
.flat_map(|i| {
let (top, bottom) = rows(i);
[0.0, top, 8.0, bottom]
})
.collect();
// `half` 1.0 is 0x3c00.
let factors: Vec<u8> = [0x3c00u16; 6]
.repeat(COMMANDS as usize)
.iter()
.flat_map(|f| f.to_le_bytes())
.collect();
vec![
("buffer:draws", words(&draws)),
("buffer:marks", words(&marks)),
("buffer:frame", frame),
("buffer:xy", floats(&xy)),
("buffer:factors", factors),
]
}
Draws::IndexedPatches => {
let draws: Vec<u32> = (0..COMMANDS).flat_map(|i| [i, 1, 1 + i % 2, i]).collect();
let mut corners = vec![0f32; 8 * COMMANDS as usize];
let mut points = Vec::new();
for i in 0..COMMANDS {
let (top, bottom) = rows(i);
let corner = [[0.0, top], [8.0, top], [0.0, bottom], [8.0, bottom]];
for (j, xy) in corner.into_iter().enumerate() {
let at = 4 * i + PLACES[j];
corners[2 * at as usize..][..2].copy_from_slice(&xy);
points.extend((at as u16).to_le_bytes());
}
}
// `half` 1.0 is 0x3c00.
let factors: Vec<u8> = [0x3c00u16; 6]
.repeat(COMMANDS as usize)
.iter()
.flat_map(|f| f.to_le_bytes())
.collect();
vec![
("buffer:draws", words(&draws)),
("buffer:marks", words(&marks)),
("buffer:frame", frame),
("buffer:corners", floats(&corners)),
("buffer:points", points),
("buffer:factors", factors),
]
}
}
}
/// The execution's line among the inputs.
fn execution(self) -> &'static str {
match self {
Draws::Indexed => "DrawIndexed, inherited state, 3 vertex and 1 fragment buffers",
Draws::Plain => "Draw, inherited state, 3 vertex and 0 fragment buffers",
Draws::Patches => "DrawPatches, inherited state, 3 vertex and 0 fragment buffers",
Draws::IndexedPatches => {
"DrawIndexedPatches, inherited state, 3 vertex and 0 fragment buffers, control \
points a float2 at attribute 0 of buffer 2 stepped per patch control point at 8 \
bytes, UInt16 control-point indices"
}
}
}
/// The pipeline's vertex descriptor and tessellation state: the indexed patches' control
/// points and index type; Metal's defaults for the rest.
fn control_points(self) -> (Option<VertexLayout<'static>>, Option<TessellationState>) {
match self {
Draws::IndexedPatches => (
Some(VertexLayout::new(&CORNER, &CORNERS)),
Some(
TessellationState::new().indexed_by(TessellationControlPointIndexType::UInt16),
),
),
Draws::Indexed | Draws::Plain | Draws::Patches => (None, None),
}
}
}
/// One row: its name, its draws, the range the GPU writes (location, length), and what writes it.
pub struct GpuRange {
name: &'static str,
draws: Draws,
range: [u32; 2],
drawn: bool,
}
@@ -78,40 +332,6 @@ fn floats(values: &[f32]) -> Vec<u8> {
values.iter().flat_map(|v| v.to_le_bytes()).collect()
}
/// The kernel's buffers 1 to 6, by name: each command's draw (first index, index count,
/// instances, base vertex, base instance), the marks, the frame (the target's extent and no
/// instance step), the pixel corners of each command's quad, the tints, and two copies of a
/// quad's six 16-bit indices, command `i` drawing from copy `i % 2`.
fn kernel_buffers() -> [(&'static str, Vec<u8>); 6] {
let draws: Vec<u32> = (0..COMMANDS)
.flat_map(|i| [6 * (i % 2), 6, 1, 4 * i, i])
.collect();
let xy: Vec<f32> = (0..COMMANDS)
.flat_map(|i| {
let (top, bottom) = ((2 * i) as f32, (2 * i + 2) as f32);
[0.0, top, 8.0, top, 0.0, bottom, 8.0, bottom]
})
.collect();
let marks: Vec<u32> = (0..COMMANDS).map(|i| MARK + i).collect();
let tints: Vec<u32> = (0..COMMANDS).map(|i| TINT + i).collect();
let indices: Vec<u8> = [0u16, 1, 2, 2, 1, 3]
.repeat(2)
.iter()
.flat_map(|i| i.to_le_bytes())
.collect();
[
("buffer:draws", words(&draws)),
("buffer:marks", words(&marks)),
(
"buffer:frame",
floats(&[SIZE[0] as f32, SIZE[1] as f32, 0.0, 0.0]),
),
("buffer:xy", floats(&xy)),
("buffer:tints", words(&tints)),
("buffer:indices", indices),
]
}
impl GpuRange {
/// The bytes of the buffer the range is written from: a blit's source holds the range itself;
/// the writer's `params` the pair whose two vertices write the location and the length,
@@ -183,10 +403,30 @@ impl Case for GpuRange {
MetalSource::Run
}
fn allowances(&self) -> Vec<Allowance> {
// No value is loosened. The plain draws' vertex function writes `[[point_size]]`, so their
// render state carries the static note `device-point-size` on a device whose largest point
// is below Metal's, whatever primitive it draws; that notice is declared. The indexed
// draws' vertex function writes none. The patch draws' tessellating pipeline announces the
// tessellation notices every row that draws a patch declares
// (`tessellation_sweeps::tessellation_notices`), as do the indexed patch draws': none
// moves a texel of a quad patch of level 1, whose two triangles cover its rectangle in
// any order and winding.
match self.draws {
Draws::Indexed => Vec::new(),
Draws::Plain => vec![crate::replay::notice_allowance(
Degradation::DevicePointSize.code(),
)],
Draws::Patches | Draws::IndexedPatches => {
super::tessellation_sweeps::tessellation_notices()
}
}
}
fn shaders(&self) -> Result<Vec<ShaderRef>, String> {
let mut shaders = Vec::new();
for entry in [KERNEL, VERTEX, FRAGMENT] {
shaders.extend(shaders_of(FIXTURE, entry)?);
for entry in self.draws.functions() {
shaders.extend(shaders_of(self.draws.fixture(), entry)?);
}
if self.drawn {
shaders.extend(shaders_of(WRITER, WRITER)?);
@@ -195,14 +435,14 @@ impl Case for GpuRange {
}
fn inputs(&self) -> Result<Vec<Input>, String> {
let mut inputs = fixture_inputs(FIXTURE)?;
let mut inputs = fixture_inputs(self.draws.fixture())?;
if self.drawn {
for mut input in fixture_inputs(WRITER)? {
input.name = format!("writer-{}", input.name);
inputs.push(input);
}
}
for (name, bytes) in kernel_buffers() {
for (name, bytes) in self.draws.kernel_buffers() {
inputs.push(Input::bytes(name, &bytes));
}
inputs.push(Input::bytes("buffer:range", &words(&STALE)));
@@ -210,8 +450,9 @@ impl Case for GpuRange {
inputs.push(Input::bytes(
"execution",
format!(
"{COMMANDS} commands of DrawIndexed, inherited state, 3 vertex and 1 fragment \
buffers; the range at offset {OFFSET}; {}; target RGBA32Uint {}x{} cleared to 0",
"{COMMANDS} commands of {}; the range at offset {OFFSET}; {}; target RGBA32Uint \
{}x{} cleared to 0",
self.draws.execution(),
match self.drawn {
false => "copied by a blit before the pass",
true => "written by two points of the writer, then a barrier of buffers",
@@ -225,13 +466,13 @@ impl Case for GpuRange {
}
fn run(&self, side: &mut dyn Side, sites: &mut Sites) -> Result<(), Abort> {
let library_handle = library(side, sites, FIXTURE, "library")?;
let library_handle = library(side, sites, self.draws.fixture(), "library")?;
let writer = match self.drawn {
true => Some(library(side, sites, WRITER, "writer-library")?),
false => None,
};
let mut buffers = Vec::new();
for (name, bytes) in kernel_buffers() {
for (name, bytes) in self.draws.kernel_buffers() {
buffers.push(made(sites, name, side.buffer(&bytes))?);
}
let range = made(sites, "buffer:range", side.buffer(&words(&STALE)))?;
@@ -244,17 +485,22 @@ impl Case for GpuRange {
},
None => RangeWrite::Copied { from: source },
};
// The commands read the marks, the frame, the corners, the tints and the indices through
// their bindings; the draws only the kernel reads.
// The commands read every buffer after the draws through their bindings; the draws only
// the kernel reads.
let [kernel, vertex, fragment] = self.draws.functions();
let (vertex_layout, tessellation) = self.draws.control_points();
let run = EncodedRange {
library: library_handle,
kernel: KERNEL,
kernel,
buffers: &buffers,
commands: COMMANDS,
bind_counts: [3, 1],
vertex: VERTEX,
fragment: FRAGMENT,
command_types: self.draws.command_types(),
bind_counts: self.draws.bind_counts(),
vertex,
fragment,
format: PixelFormat::RGBA32Uint,
vertex_layout,
tessellation,
size: SIZE,
row_pitch: SIZE[0] * TARGET_TEXEL,
used: &buffers[1..],
@@ -276,11 +522,21 @@ impl Case for GpuRange {
/// The family's rows, in the order the report lists them.
pub fn boxed() -> Vec<Box<dyn Case>> {
[
(AT_ZERO, [0, 3], false),
(PAST_ZERO, [5, 2], false),
(DRAWN, [2, 4], true),
(AT_ZERO, Draws::Indexed, [0, 3], false),
(PAST_ZERO, Draws::Indexed, [5, 2], false),
(DRAWN, Draws::Indexed, [2, 4], true),
(PLAIN, Draws::Plain, [1, 5], false),
(PATCHES, Draws::Patches, [1, 5], false),
(INDEXED_PATCHES, Draws::IndexedPatches, [1, 5], false),
]
.into_iter()
.map(|(name, range, drawn)| Box::new(GpuRange { name, range, drawn }) as Box<dyn Case>)
.map(|(name, draws, range, drawn)| {
Box::new(GpuRange {
name,
draws,
range,
drawn,
}) as Box<dyn Case>
})
.collect()
}
@@ -0,0 +1,207 @@
//! Which commit takes a Managed buffer's named range to the GPU, one case a reader
//! ([`crate::managed_naming::Way`]): a compute slot, a declaration by `useResource:usage:`, a
//! reach through the buffer's address alone, a vertex slot with a draw, and a blit copy's source.
//! [`crate::managed_naming`] states the sequence and what each reader answers.
//!
//! # Where Metal's answer comes from
//!
//! Carried, from a table measured on an AMD Radeon Pro 5300M under macOS 26.7.1, 8 rounds a
//! reader, by a probe of the same sequence (jobs 81602 and 81644): the readers that name the
//! buffer read the bytes as of their own commit, and the reader through the address the bytes the
//! GPU's copy last took. The oracle keeps one copy of a Managed buffer (`hasUnifiedMemory` true),
//! so its run would answer another question, and record mode keeps the measured table. The site
//! holds which of the sequence's three contents the reader read, which is what the table states;
//! the probe's own bytes are not the case's.
//!
//! # Where it compares
//!
//! On a device that keeps one copy of a Managed buffer the runtime has no second copy to read
//! through an address, and the address row reads the venue's gap there; the other rows read the
//! bytes as of their commit in either form, as the 5300M's and a one-copy Intel UHD Graphics 630's
//! (jobs 81603 and 81645) did.
//!
//! # Why it is safe
//!
//! Every reader reads 256 bytes of a live buffer: two kernels of one thread an element, one
//! triangle over a 4 by 4 target, and blit copies and fills inside their buffers. Every wait is
//! bounded.
use crate::case::{answered, made, Abort, Case, Failure, Input, MetalSource, Side};
use crate::fixture::{Fixture, METAL_TEXT, RUNTIME_TEXT};
use crate::managed_naming::{Content, Libraries, Read, Way};
use crate::recording::ShaderRef;
use crate::replay::NOTICES_SITE;
use crate::transcript::{Sites, Transcript, Value};
/// The fixture of the compute slot's and the vertex slot's readers.
const EXAMPLES: Fixture = Fixture {
name: "examples/runtime_examples",
entry: "scale_and_offset",
};
/// The fixture of the readers through the address.
const POINTERS: Fixture = Fixture {
name: "ab_pointers",
entry: "ab_address",
};
/// The carried measurement, and where it is written down.
const CARRIED_FROM: &str = "an AMD Radeon Pro 5300M measurement under macOS 26.7.1, 8 rounds a \
reader (jobs 81602 and 81644), which found that a named Managed range \
reaches the GPU at the first commit whose encoders name the buffer, \
with its bytes as of that commit, and that a buffer no encoder names \
keeps the bytes its GPU copy last took";
/// Why record mode must not replace the carried table on the oracle.
const NEVER_RE_RECORD: &str = "the oracle keeps one copy of a Managed buffer (hasUnifiedMemory \
true), so its run answers what one copy holds, not which commit \
takes a range to a second copy";
/// The rounds the carried measurement stands on.
const CARRIED_RUNS: u32 = 8;
/// One case of the family: its name, its reader, and what the 5300M's reader read.
pub struct ManagedNaming {
name: &'static str,
way: Way,
metal: Content,
}
/// Every case of the family.
pub fn all() -> Vec<Box<dyn Case>> {
let case = |name, way, metal| -> Box<dyn Case> { Box::new(ManagedNaming { name, way, metal }) };
vec![
case(
"managed-named-compute-slot",
Way::ComputeSlot,
Content::Later,
),
case("managed-named-declared", Way::Declared, Content::Later),
case("managed-named-address-only", Way::Address, Content::Synced),
case("managed-named-vertex-slot", Way::VertexSlot, Content::Later),
case("managed-named-blit-source", Way::BlitSource, Content::Later),
]
}
/// The two fixtures' texts in both dialects.
fn shaders_of() -> Result<Vec<ShaderRef>, String> {
let mut shaders = Vec::new();
for fixture in [EXAMPLES, POINTERS] {
for extension in [RUNTIME_TEXT, METAL_TEXT] {
shaders.push(ShaderRef {
fixture: format!("{}{extension}", fixture.name),
entry: fixture.entry.to_owned(),
source_sha256: crate::sha256_hex(fixture.text(extension)?.as_bytes()),
});
}
}
Ok(shaders)
}
impl ManagedNaming {
/// The sites a run that read `content` emits.
fn transcript(&self, content: Content) -> Result<Transcript, String> {
let mut sites = Sites::new();
sites.push(crate::case::inputs_node(&self.inputs()?));
sites.leaf("examples", answered());
sites.leaf("pointers", answered());
sites.leaf("sequence", answered());
sites.value("reads", reads(Read::Content(content)));
sites.notices(NOTICES_SITE, &[] as &[&str]);
Ok(sites.finish())
}
}
/// The value the `reads` site holds.
fn reads(read: Read) -> Value {
Value::Lines(vec![read.word().to_owned()])
}
impl Case for ManagedNaming {
fn name(&self) -> &'static str {
self.name
}
fn metal_source(&self) -> MetalSource {
MetalSource::carried_only(CARRIED_FROM, NEVER_RE_RECORD)
.measured_on(crate::recording::AMD_RADEON_PRO_5300M)
}
fn shaders(&self) -> Result<Vec<ShaderRef>, String> {
shaders_of()
}
fn inputs(&self) -> Result<Vec<Input>, String> {
let mut inputs = Vec::new();
for (fixture, short) in [(EXAMPLES, "examples"), (POINTERS, "pointers")] {
inputs.push(Input::bytes(
format!("air:{short}"),
fixture.text(RUNTIME_TEXT)?.as_bytes(),
));
inputs.push(Input::bytes(
format!("air-typed:{short}"),
fixture.text(METAL_TEXT)?.as_bytes(),
));
}
for content in Content::ALL {
inputs.push(Input::bytes(
format!("contents:{content:?}"),
&content.bytes(),
));
}
inputs.push(Input::bytes("reader", self.way.name().as_bytes()));
Ok(inputs)
}
fn carried_transcript(&self) -> Result<Option<(u32, Transcript)>, String> {
Ok(Some((CARRIED_RUNS, self.transcript(self.metal)?)))
}
fn run(&self, side: &mut dyn Side, sites: &mut Sites) -> Result<(), Abort> {
let load = |fixture: Fixture, at: &str| {
fixture.loaded().map_err(|why| Abort {
at: at.to_owned(),
failure: Failure::named("FixtureNotRead", why),
})
};
let (examples, pointers) = (load(EXAMPLES, "examples")?, load(POINTERS, "pointers")?);
let examples = made(sites, "examples", side.library(&examples.source()))?;
let pointers = made(sites, "pointers", side.library(&pointers.source()))?;
let libraries = Libraries { examples, pointers };
let read = made(sites, "sequence", side.managed_naming(self.way, libraries))?;
sites.value("reads", reads(self.way.read(&read)));
Ok(())
}
}
#[cfg(test)]
mod tests {
use super::*;
/// Five cases, one a reader, each named once, carrying the 5300M's answer: the bytes the
/// GPU's copy last took for the reader through the address alone, the bytes as of the
/// reader's commit for every other.
#[test]
fn every_reader_is_a_case_carrying_the_5300m_answer() {
let cases = all();
assert_eq!(cases.len(), 5);
let mut names: Vec<&str> = cases.iter().map(|case| case.name()).collect();
names.sort_unstable();
names.dedup();
assert_eq!(names.len(), 5);
for case in &cases {
let (runs, transcript) = (case.carried_transcript())
.expect("a carried answer")
.expect("carried");
assert_eq!(runs, CARRIED_RUNS);
assert!(case.allowances().is_empty());
let words = format!("{transcript:?}");
let address = case.name() == "managed-named-address-only";
let word = match address {
true => Content::Synced.word(),
false => Content::Later.word(),
};
assert!(words.contains(word), "{}: {words}", case.name());
}
}
}
@@ -47,12 +47,23 @@
//! outside the pixel is a value Metal asserts on and that reaches the sample grid. So they have no
//! oracle value here. [`crate::render::forbidden_positions`] refuses the two
//! fatal shapes from the input's own shape, so a case cannot build one by accident.
//!
//! **Carried from a discrete Mac** — the `EIGHT` table, the family's pass at 8 samples. The oracle
//! renders no 8 samples (an Apple M3 Max under macOS 27.0.1 answers `supportsTextureSampleCount:`
//! no for 8, job 82550), and a Mac with an AMD GPU does: an AMD Radeon Pro 5300M under macOS 26.7.1
//! ran the family's pass at 8 samples, plain and under Metal's API validation layer, which passed
//! it (job 82284, the probe `sample_positions_8.m` of the usage-edges probes). Each row carries the
//! resolved texel the probe read, so the bytes compare as a recorded row's do. Every row's coverage
//! avoids a resolve that halves a code: where the 5300M's average lies halfway between two codes it
//! rounds to the even one (4 of 8 samples: red 0, alpha 128), the M3 Max rounds a half up (2 of 4:
//! red 1), and that rounding is the device's own (`PrecisionNote::DeviceRoundedResolve`), so a row
//! there would compare two devices' rounding rather than where the samples are.
use crate::allowance::{Allowance, Justification, Loosening};
use crate::case::{answered, Abort, Case, Failure, Input, MetalSource, Side};
use crate::degradation::Degradation;
use crate::fixture::{Fixture, METAL_TEXT, RUNTIME_TEXT};
use crate::recording::{ShaderRef, APPLE_M4};
use crate::recording::{ShaderRef, AMD_RADEON_PRO_5300M, APPLE_M4};
use crate::render::{
ColorState, PassColor, Plane, ReadAt, RenderPass, RenderPipelineSpec, RenderStep, RenderWork,
TargetSpec,
@@ -223,6 +234,71 @@ const FEWER: &[Shape] = &[
),
];
/// Eight positions at `(x, 0.5)`.
macro_rules! eight {
($x:expr) => {
&[
at($x, 0.5),
at($x, 0.5),
at($x, 0.5),
at($x, 0.5),
at($x, 0.5),
at($x, 0.5),
at($x, 0.5),
at($x, 0.5),
]
};
}
/// One row of the family at 8 samples, and the resolved texel an AMD Radeon Pro 5300M read.
struct Measured {
shape: Shape,
texel: [u8; TEXEL as usize],
}
/// The rows at 8 samples, carried from the 5300M (job 82284).
///
/// The device's own positions are Vulkan's standard 8 (each `x` an odd sixteenth, as the 5300M's
/// `getDefaultSamplePositions:count:` answers too), so an edge at 5/8 of the pixel covers five of
/// them: alpha 5/8 of 255 and red 5/8 of a code, each to the nearest code.
const EIGHT: &[Measured] = &[
Measured {
shape: Shape::new("sample-positions-8x-default", 8, &[], 0.25, 5),
texel: [1, 0, 0, 0x9f],
},
Measured {
shape: Shape::new("sample-positions-8x-custom-left", 8, eight!(0.25), 0.0, 8),
texel: [1, 0, 0, 0xff],
},
Measured {
shape: Shape::new(
"sample-positions-8x-custom-mixed",
8,
&[
at(0.25, 0.5),
at(0.75, 0.5),
at(0.75, 0.5),
at(0.75, 0.5),
at(0.75, 0.5),
at(0.75, 0.5),
at(0.75, 0.5),
at(0.75, 0.5),
],
0.0,
1,
),
texel: [0, 0, 0, 0x20],
},
];
/// Where the 8-sample rows' Metal answer was measured, and why record mode must not replace it.
const EIGHT_FROM: &str =
"an AMD Radeon Pro 5300M under macOS 26.7.1 (job 82284): the family's pass \
at 8 samples, plain and under Metal's API validation layer, one run each";
const EIGHT_NEVER_RE_RECORD: &str = "the oracle renders no 8 samples (an Apple M3 Max answers \
supportsTextureSampleCount: no for 8), so a record run there \
must not encode an 8-sample texture";
/// Where the carried rows' Metal answer was measured, and why record mode must not replace it.
const CARRIED_FROM: &str = "a Metal probe of custom sample positions on an Apple M4";
const NEVER_RE_RECORD: &str = "fewer custom sample positions than the pass's samples is a count \
@@ -535,26 +611,7 @@ impl Case for Fewer {
}
fn carried_transcript(&self) -> Result<Option<(u32, Transcript)>, String> {
let mut sites = Sites::new();
sites.push(crate::case::inputs_node(&self.inputs()?));
for call in SETUP_SITES {
sites.leaf(call, answered());
}
let mut calls = Node::branch("calls", Vec::new());
for (piece, call) in ["renderCommandEncoder", "copyFromTextureToBuffer"]
.into_iter()
.enumerate()
{
calls = calls.with(Node::leaf(
format!("{piece}-{call}"),
Observed::value(Value::ok(Value::Absent)),
));
}
sites.push(calls);
sites.leaf(
"status",
Observed::value(Value::ok(Value::unit_variant("Completed"))),
);
let mut sites = carried_sites(self.shape)?;
sites.leaf(
"coverage",
Observed::value(Value::Lines(vec![format!(
@@ -576,6 +633,83 @@ impl Case for Fewer {
}
}
/// The sites a carried row's run emits before its answer: the inputs, every set-up call answered,
/// both pieces of work answered and the command buffer completed.
fn carried_sites(shape: &Shape) -> Result<Sites, String> {
let mut sites = Sites::new();
sites.push(crate::case::inputs_node(&inputs(shape)?));
for call in SETUP_SITES {
sites.leaf(call, answered());
}
let mut calls = Node::branch("calls", Vec::new());
for (piece, call) in ["renderCommandEncoder", "copyFromTextureToBuffer"]
.into_iter()
.enumerate()
{
calls = calls.with(Node::leaf(
format!("{piece}-{call}"),
Observed::value(Value::ok(Value::Absent)),
));
}
sites.push(calls);
sites.leaf(
"status",
Observed::value(Value::ok(Value::unit_variant("Completed"))),
);
Ok(sites)
}
/// One row at 8 samples, whose Metal answer is carried from the 5300M: the resolved texel and the
/// coverage it comes to, as a recorded row holds them.
pub struct Eight {
row: &'static Measured,
}
impl Case for Eight {
fn name(&self) -> &'static str {
self.row.shape.name
}
fn metal_source(&self) -> MetalSource {
MetalSource::carried_only(EIGHT_FROM, EIGHT_NEVER_RE_RECORD)
.measured_on(AMD_RADEON_PRO_5300M)
}
fn allowances(&self) -> Vec<Allowance> {
allowances()
}
fn shaders(&self) -> Result<Vec<ShaderRef>, String> {
shaders()
}
fn inputs(&self) -> Result<Vec<Input>, String> {
inputs(&self.row.shape)
}
fn carried_transcript(&self) -> Result<Option<(u32, Transcript)>, String> {
let shape = &self.row.shape;
let mut sites = carried_sites(shape)?;
sites.leaf(
"coverage",
Observed::value(coverage(&self.row.texel, shape.samples)),
);
sites.leaf(
"resolved",
Observed::bytes(self.row.texel.to_vec(), layout()),
);
sites.notices(NOTICES_SITE, &[] as &[&str]);
Ok(Some((MEASURED_RUNS, sites.finish())))
}
fn run(&self, side: &mut dyn Side, sites: &mut Sites) -> Result<(), Abort> {
Coverage {
shape: &self.row.shape,
}
.run(side, sites)
}
}
/// Every case of the family, in the order the report lists them.
pub fn all() -> Vec<Box<dyn Case>> {
let mut cases: Vec<Box<dyn Case>> = Vec::new();
@@ -585,6 +719,9 @@ pub fn all() -> Vec<Box<dyn Case>> {
for shape in FEWER {
cases.push(Box::new(Fewer { shape }));
}
for row in EIGHT {
cases.push(Box::new(Eight { row }));
}
cases
}
@@ -695,13 +832,56 @@ mod tests {
}
}
/// Every 8-sample row carries the 5300M's texel at the coverage its table states, alpha and red
/// each the covered fraction of its full code to the nearest code, never halfway; forbids record mode from
/// replacing it; and states the sites a run of the row emits, the resolved texel's included.
#[test]
fn every_eight_sample_row_carries_the_5300m_texel_at_its_coverage() {
for row in EIGHT {
let shape = &row.shape;
assert_eq!(shape.samples, 8, "{}", shape.name);
let nearest = |code: u64| {
let eighths = code * shape.covered;
assert_ne!(eighths % 8, 4, "{}: halfway between two codes", shape.name);
((code * shape.covered + 4) / 8) as u8
};
assert_eq!(
row.texel,
[nearest(1), 0, 0, nearest(255)],
"{}",
shape.name
);
let case = Eight { row };
assert!(case.metal_source().forbidden().is_some(), "{}", shape.name);
let (runs, transcript) = case
.carried_transcript()
.unwrap()
.unwrap_or_else(|| panic!("{}: no carried transcript", shape.name));
assert_eq!(runs, MEASURED_RUNS);
assert_eq!(
site(shape.name, &transcript, "coverage").observed.value,
Value::Lines(vec![format!("{} of 8 samples", shape.covered)])
);
assert_eq!(
site(shape.name, &transcript, "resolved").observed.value,
Value::Bytes(row.texel.to_vec())
);
for call in SETUP_SITES {
site(shape.name, &transcript, call);
}
site(shape.name, &transcript, "calls/1-copyFromTextureToBuffer");
site(shape.name, &transcript, "status");
}
}
/// Every row of the family states positions the Metal leg's guard takes, or none at all.
///
/// This is the separation made mechanical: a row whose count passes the pass's samples, or
/// whose coordinate leaves the pixel, cannot be added to either table without failing here.
#[test]
fn no_row_states_a_shape_the_metal_leg_may_not_encode() {
for shape in COVERAGE.iter().chain(FEWER) {
let eight = EIGHT.iter().map(|row| &row.shape);
for shape in COVERAGE.iter().chain(FEWER).chain(eight) {
assert!(
crate::render::forbidden_positions(shape.positions, shape.samples).is_none(),
"{}: the guard refuses its positions",
@@ -717,8 +897,11 @@ mod tests {
/// a near-equivalent. A case that loosened its coverage or its texel would fail here.
#[test]
fn every_case_is_tabled_and_loosens_its_notices_alone() {
let named: Vec<&str> = COVERAGE.iter().chain(FEWER).map(|row| row.name).collect();
assert_eq!(named.len(), COVERAGE.len() + FEWER.len());
let eight = EIGHT.iter().map(|row| &row.shape);
let named: Vec<&str> = (COVERAGE.iter().chain(FEWER).chain(eight))
.map(|row| row.name)
.collect();
assert_eq!(named.len(), COVERAGE.len() + FEWER.len() + EIGHT.len());
for case in all() {
assert!(
named.contains(&case.name()),
@@ -111,13 +111,23 @@
//! format cannot part them. Three distinct answers of the three colours under **both** modes, and
//! `ClampToZero` reads exactly what `ClampToBorderColor` reads for every one of the three.
//!
//! **`cubic`** — one row, a `Cubic` min and mag filter, which is the third value of
//! `MTLSamplerMinMagFilter` and no device's own. The coordinates are a quarter of a texel past
//! each texel's lower corner, where a sixteen-texel kernel's weights all differ rather than
//! collapsing onto the texel a symmetric kernel would read at a centre. Every one of the sixteen
//! samples compares with Metal bit for bit; the case's verdict is `announced` and not `exact`
//! because the runtime emulates the footprint and says its arithmetic is its own, which the case
//! declares and which loosens nothing.
//! **`cubic`** — one row, a `Cubic` min and mag filter: `MTLSamplerMinMagFilter`'s raw value 2,
//! which the SDK headers do not declare. The coordinates are a quarter of a texel past each
//! texel's lower corner, where a nearest filter reads the lane's own texel and a filter of a wider
//! footprint blends in its neighbours. Metal makes the state on every Mac measured, and what a
//! sample through it reads is the Mac's. The case's own inputs on three Macs (jobs m3-max-85003
//! and m3-max-85004), the runtime sampler's red channel at the sixteen lanes:
//!
//! | Mac | macOS | Red, lanes 0 to 15 |
//! |---|---|---|
//! | Apple M3 Max | 27.0.1 | 1, 1.75, 2.75, 3.75, 4, 4.75, 5.75, 6.75, 8, ..., 14.75: a filter of a wider footprint, the linear filter's values at these coordinates |
//! | Radeon Pro 5300M | 26.7.1 | 1 to 16, each lane's own texel: nearest |
//! | Intel UHD Graphics 630 | 26.7.1 | 1 to 16: nearest |
//!
//! The recording is the M3 Max's. The runtime filters such a state as nearest on every device,
//! the x86 Macs' answer (`docs/API.md`'s accepted difference `CUBIC_AS_NEAREST`), so each lane's
//! runtime red may also hold its own texel, the 5300M's and the 630's value. Lane 0's footprint
//! reads texel (0, 0) alone at the clamped edge on all three Macs, so it compares exactly.
//!
//! # What is not here, and why
//!
@@ -146,7 +156,7 @@
//! and `cubic` families sample at is inside its texture; the `r-address` and `border` families'
//! coordinates reach outside on purpose, which is what an address mode and a border are for.
use crate::allowance::Allowance;
use crate::allowance::{Allowance, Justification, Loosening};
use crate::case::{
call, made, Abort, Bindings, Case, Failure, Handle, Input, MetalSource, SamplerSpec, Side,
TextureRole, TextureSpec,
@@ -156,7 +166,9 @@ use crate::fixture::{Fixture, METAL_TEXT, RUNTIME_TEXT};
use crate::recording::ShaderRef;
use crate::replay::notice_allowance;
use crate::texture::{TextureRequest, Upload};
use crate::transcript::{ByteLayout, Digest, Element, Gaps, Node, Observed, Region, Sites, Value};
use crate::transcript::{
ByteLayout, Digest, Element, FloatWidth, Gaps, Node, Observed, Region, Sites, Value,
};
use metal2vulkan::metal::{
CompareFunction, PixelFormat, SamplerAddressMode, SamplerBorderColor, SamplerMinMagFilter,
SamplerMipFilter, SamplerReductionMode, TextureType, TextureUsage,
@@ -292,6 +304,20 @@ fn centres() -> Vec<[f32; 2]> {
.collect()
}
/// The accepted difference the `cubic` family's allowances name, by its slug.
const CUBIC_AS_NEAREST: &str = "a-sampler-of-minfilter-or-magfilter-2-filters-as-nearest";
/// The lanes of the `cubic` family whose nearest texel is not the M3 Max's answer, each with that
/// texel's value: every lane but lane 0, whose footprint is texel (0, 0) alone (module docs).
fn cubic_as_nearest() -> Vec<(usize, f32)> {
(0..SIDE)
.flat_map(|y| (0..SIDE).map(move |x| (x, y)))
.enumerate()
.filter(|&(_, (x, y))| (x, y) != (0, 0))
.map(|(lane, (x, y))| (lane, level_texel(0, x, y)))
.collect()
}
/// The coordinates the `cubic` family samples at: a quarter of a texel past each texel's lower
/// corner, so the footprint is never centred on a texel.
///
@@ -565,7 +591,7 @@ enum Family {
/// Six rows: each `MTLSamplerBorderColor` on each of the two address modes that read a
/// border.
Border,
/// One row: a `Cubic` min and mag filter, the third value of `MTLSamplerMinMagFilter`.
/// One row: a `Cubic` min and mag filter, `MTLSamplerMinMagFilter`'s undeclared raw value 2.
Cubic,
}
@@ -853,17 +879,11 @@ impl Case for SamplerFiltering {
}
fn allowances(&self) -> Vec<Allowance> {
// Metal announces nothing, so a notice of ours is a difference at the notices site. One
// family here provokes one: a `Cubic` min and mag filter, which no device's own sampler
// has, so the runtime emulates Metal's bicubic footprint and announces that its arithmetic
// is its own (`bicubic-filter-arithmetic`).
// Metal announces nothing, so a notice of ours is a difference at the notices site. No
// family here declares one of its own but the border and compare rows' below, so a notice
// any other starts announcing reads as divergent at once.
//
// It is a **declaration and loosens nothing**: measured on the M3 Max, every one of the
// sixteen samples of `sampler-cubic-filter` compares with Metal bit for bit, and the
// notices site is the whole of the difference. The other families provoke no notice and
// declare none, so a notice any of them starts announcing reads as divergent at once.
//
// And every family samples through the runtime sampler at `[[sampler(0)]]`, which the
// Every family samples through the runtime sampler at `[[sampler(0)]]`, which the
// runtime's pipelines note as scaled (`crate::replay::pixel_sampler_scaling_notice` holds
// why). Measured through the rt side on lavapipe, the Radeon 780M and the RX 550: it fired
// for every row the side does not refuse (the mip, third-address-mode, reduction and
@@ -874,10 +894,19 @@ impl Case for SamplerFiltering {
if matches!(self.family, Family::Border) {
named.push(crate::replay::swizzled_border_notice());
}
// A `Cubic` filter reads as nearest (module docs): each lane's runtime red may hold the
// lane's own texel, the x86 Macs' answer, where it differs from the M3 Max's.
if matches!(self.family, Family::Cubic) {
named.push(notice_allowance(
Degradation::BicubicFilterArithmetic.code(),
));
for (lane, value) in cubic_as_nearest() {
named.push(Allowance::new(
format!("case/cubic/sampled/{}", lane * SLOT_LANE as usize + 16),
Loosening::AnyOf(vec![Value::Float {
bits: u64::from(value.to_bits()),
width: FloatWidth::Single,
}]),
Justification::accepted(CUBIC_AS_NEAREST),
));
}
}
// A `compare` row's comparing stage records that its texels hold no value outside
// [0, 1] (`restricted-depth-range`). Every texel of the family lies in [0, 1], so it moves
@@ -1239,6 +1268,26 @@ mod tests {
/// of each other by Metal's own behaviour, and this asserts it rather than leaving a reader to
/// read three rows as three compared answers. An implementation that applied a minimum here
/// would diverge from the recording, which is what the rows are for.
/// The M3 Max's recording of a `Cubic` filter reads the linear control's red at every lane,
/// and its own texel, the x86 Macs' nearest answer, exactly at the lanes the allowances leave
/// out: the allowances admit the nearest answer wherever the recording differs from it.
#[test]
fn the_cubic_allowances_are_the_lanes_nearest_moves() {
let Some(outcomes) = recorded("sampler-cubic-filter", "cubic") else {
return;
};
let allowed: Vec<usize> = cubic_as_nearest().iter().map(|&(lane, _)| lane).collect();
for bytes in outcomes {
for lane in 0..(SIDE * SIDE) as usize {
let (x, y) = (lane as u32 % SIDE, lane as u32 / SIDE);
let red = runtime_sample(&bytes, lane)[0];
assert_eq!(red, control_sample(&bytes, lane)[0], "lane {lane}");
let nearest = level_texel(0, x, y);
assert_eq!(red != nearest, allowed.contains(&lane), "lane {lane}");
}
}
}
#[test]
fn the_three_reductions_are_one_answer() {
let case = all()
@@ -0,0 +1,195 @@
//! `sparse-status-plain`: what `sparse_sample`, `sparse_gather` and `sparse_read` answer over a
//! texture that is not sparse: each one's colour, and its residency (`sparse_color::resident()`).
//!
//! The kernel is the owned fixture `a2_sparse_status`. Thread `i` of [`THREADS`] takes texel
//! `(i & 3, i >> 2)` of two 4 × 4 `RGBA32Float` textures: it samples the first at the texel's
//! centre through a constexpr nearest, clamp-to-edge sampler at level 0, gathers the first's red
//! channel there, and reads the second at the texel. It stores the three colours' words, then the
//! three residencies (1 for resident) and a tag word, `0xA2`.
//!
//! Metal's answer over a texture that is not sparse is not the same on every Mac. Our own probe of
//! this kernel, plain and under Metal's validation layer (which reported nothing), read every
//! residency as resident on the Apple M3 Max (macOS 27.0.1) and on the AMD Radeon Pro 5300M (macOS
//! 26.7.1), and as not resident on the Intel UHD Graphics 630 of the same MacBook (macOS 26.7.1),
//! with the same colours on all three. Both answers are Metal's. The runtime answers resident, the
//! M3 Max's and the 5300M's, so the recording, which is the M3 Max's, holds it to that answer, and
//! the colours compare on every venue.
//!
//! One compute pass of [`THREADS`] threads, no loop, and every coordinate inside the textures:
//! nothing here can fault a GPU.
use crate::case::{call, made, Abort, Bindings, Case, Failure, Input, MetalSource, Side};
use crate::fixture::{Fixture, METAL_TEXT, RUNTIME_TEXT};
use crate::recording::ShaderRef;
use crate::texture::{TextureRequest, Upload};
use crate::transcript::{ByteLayout, Digest, Element, Gaps, Node, Observed, Region, Sites};
use metal2vulkan::metal::PixelFormat;
/// The fixture the kernel lives in, and the kernel.
const FIXTURE: &str = "a2_sparse_status";
/// The textures' width and height.
const SIDE: u32 = 4;
/// The threads: one a texel.
pub const THREADS: u32 = SIDE * SIDE;
/// The bytes a thread stores: four `uint4`s.
const STORED: u32 = 64;
/// The byte every output word holds before the dispatch.
const BLANK: u8 = 0xab;
/// The sampled texture's texel at `(x, y)`, and the read texture's: distinct within and between
/// them, and exact in `float`.
pub fn texel(read: bool, x: u32, y: u32) -> [f32; 4] {
let (x, y) = (x as f32, y as f32);
match read {
false => [x + 0.25, y + 0.5, (x + 4.0 * y) / 16.0, 1.0],
true => [x + 0.75, y + 0.25, (x + 4.0 * y) / 16.0 + 0.5, 0.5],
}
}
/// A texture's bytes, row by row.
fn texels(read: bool) -> Vec<u8> {
(0..SIDE)
.flat_map(|y| (0..SIDE).map(move |x| (x, y)))
.flat_map(|(x, y)| texel(read, x, y))
.flat_map(f32::to_le_bytes)
.collect()
}
/// The upload of `bytes` into level 0.
fn upload(bytes: &[u8]) -> [Upload<'_>; 1] {
[Upload::level_0([SIDE, SIDE], SIDE * 16, SIDE, bytes)]
}
/// A plain texture of `uploads`.
fn request<'a>(uploads: &'a [Upload<'a>]) -> TextureRequest<'a> {
TextureRequest::read_2d(PixelFormat::RGBA32Float.as_raw(), SIDE, SIDE).loaded(uploads)
}
/// The layout the stored words compare under: one row a thread.
fn stored_layout() -> ByteLayout {
let length = THREADS * STORED;
ByteLayout {
region: Region::Buffer {
offset: 0,
length: u64::from(length),
},
element: Element::U32,
row_offset: 0,
row_elements: STORED / 4,
row_pitch: STORED,
rows: THREADS,
image_pitch: length,
images: 1,
gaps: Gaps::Ignored,
}
}
/// The case.
pub struct SparseStatusPlain;
impl Case for SparseStatusPlain {
fn name(&self) -> &'static str {
"sparse-status-plain"
}
fn metal_source(&self) -> MetalSource {
MetalSource::Run
}
fn shaders(&self) -> Result<Vec<ShaderRef>, String> {
let fixture = Fixture {
name: FIXTURE,
entry: FIXTURE,
};
let mut shaders = Vec::new();
for extension in [RUNTIME_TEXT, METAL_TEXT] {
shaders.push(ShaderRef {
fixture: format!("{FIXTURE}{extension}"),
entry: FIXTURE.to_owned(),
source_sha256: crate::sha256_hex(fixture.text(extension)?.as_bytes()),
});
}
Ok(shaders)
}
fn inputs(&self) -> Result<Vec<Input>, String> {
let fixture = Fixture::new(FIXTURE);
let (sampled, read) = (texels(false), texels(true));
Ok(vec![
Input {
name: "air".to_owned(),
digest: Digest::sha256(fixture.text(RUNTIME_TEXT)?.as_bytes()),
},
Input {
name: "air-typed".to_owned(),
digest: Digest::sha256(fixture.text(METAL_TEXT)?.as_bytes()),
},
Input::bytes("texture:sampled", &request(&upload(&sampled)).words()),
Input::bytes("texture:read", &request(&upload(&read)).words()),
])
}
fn run(&self, side: &mut dyn Side, sites: &mut Sites) -> Result<(), Abort> {
let loaded = Fixture::new(FIXTURE).loaded().map_err(|why| Abort {
at: "library".to_owned(),
failure: Failure::named("FixtureNotRead", why),
})?;
let library = made(sites, "library", side.library(&loaded.source()))?;
let pipeline = made(sites, "pipeline", side.compute_pipeline(library, FIXTURE))?;
let (sampled, read) = (texels(false), texels(true));
let (sampled, read) = (upload(&sampled), upload(&read));
let sampled = made(sites, "texture/sampled", side.texture(&request(&sampled)))?;
let read = made(sites, "texture/read", side.texture(&request(&read)))?;
let blank = vec![BLANK; (THREADS * STORED) as usize];
let out = made(sites, "buffer/out", side.buffer(&blank))?;
let command_buffer = made(
sites,
"dispatch",
side.dispatch_threads(
pipeline,
&Bindings::new(&[sampled, read], &[out]),
&[],
[THREADS, 1, 1],
[THREADS, 1, 1],
),
)?;
call(sites, "status", side.wait(command_buffer), Clone::clone)?;
let stored = call(
sites,
"read-back",
side.read_buffer(out, 0, blank.len()),
|_| crate::transcript::Value::Absent,
)?;
sites.push(Node::leaf(
"stored",
Observed::bytes(stored, stored_layout()),
));
Ok(())
}
}
#[cfg(test)]
mod tests {
use super::*;
use std::collections::BTreeSet;
/// Every texel of the two textures is distinct, so a sample, gather or read of the wrong texel
/// or the wrong texture shows as a value.
#[test]
fn every_texel_is_distinct() {
let mut seen = BTreeSet::new();
for read in [false, true] {
for y in 0..SIDE {
for x in 0..SIDE {
let bits = texel(read, x, y).map(f32::to_bits);
assert!(seen.insert(bits), "{read} ({x}, {y})");
}
}
}
assert_eq!(texels(false).len(), (SIDE * SIDE * 16) as usize);
}
}
@@ -0,0 +1,185 @@
//! `srgb-storage-fragment-writes`: what a fragment function's `access::write` stores into an 8-bit
//! sRGB texture, the fragment twin of [`srgb_storage_writes`](super::srgb_storage_writes).
//!
//! The promise is that case's: Metal writes `RGBA8Unorm_sRGB` and `BGRA8Unorm_sRGB` on every Metal
//! 3 device, and the Metal Shading Language specification (8.7.7) encodes the write from linear to
//! sRGB, alpha linear. `read_write` access is not promised for either format, so this case writes
//! only.
//!
//! The functions are the owned fixture `fpv_srgb_draw_storage`'s `fpv_srgb_fragment_write` and
//! `fpv_srgb_fragment_write_half`, drawn behind `fpv_srgb_cover`, one triangle over the whole of
//! a [`WIDTH`] by [`HEIGHT`] `RGBA8Unorm` attachment: each pixel's fragment writes buffer 0's
//! `float4` or `half4` of its pixel, element `y * WIDTH + x`, at its own texel of the texture at
//! fragment texture slot 0. The values, the formats, the texture and the layout its bytes are read
//! under are the kernel case's, so the two cases' stored bytes compare one to one: the case
//! records the texture's bytes by `getBytes:`, one code a channel.
//!
//! One pass a sweep, one fragment a texel, no loop and no sampling: nothing here can fault a GPU.
use super::srgb_storage_writes::{
request, stored_layout, values, width_bytes, FORMATS, HEIGHT, WIDTH,
};
use crate::case::{call, made, Abort, Case, Failure, Input, MetalSource, Side};
use crate::fixture::{Fixture, METAL_TEXT, RUNTIME_TEXT};
use crate::recording::ShaderRef;
use crate::render::{
ColorState, PassColor, RenderPass, RenderPipelineSpec, RenderStep, RenderWork, TargetSpec,
};
use crate::transcript::{Digest, Node, Observed, Sites, Value};
use metal2vulkan::metal::{PixelFormat, PrimitiveType};
/// The fixture the functions live in.
const FIXTURE: &str = "fpv_srgb_draw_storage";
/// The vertex function: one triangle over the whole viewport.
const COVER: &str = "fpv_srgb_cover";
/// The fragment functions the case draws: a `float4` write and a `half4` write.
const FRAGMENTS: [&str; 2] = ["fpv_srgb_fragment_write", "fpv_srgb_fragment_write_half"];
/// The attachment's format, which the fragments' returned colour lands in and nothing reads.
const ATTACHMENT: PixelFormat = PixelFormat::RGBA8Unorm;
/// The one colour attachment every pipeline carries.
const COLORS: [Option<ColorState>; 1] = [Some(ColorState::new(ATTACHMENT))];
/// The attachment: [`WIDTH`] by [`HEIGHT`], so a fragment is a texel of the written texture.
fn attachment() -> TargetSpec {
TargetSpec::read(ATTACHMENT, [WIDTH, HEIGHT])
}
/// The case.
pub struct SrgbStorageFragmentWrites;
impl Case for SrgbStorageFragmentWrites {
fn name(&self) -> &'static str {
"srgb-storage-fragment-writes"
}
fn metal_source(&self) -> MetalSource {
MetalSource::Run
}
fn shaders(&self) -> Result<Vec<ShaderRef>, String> {
let fixture = Fixture::new(FIXTURE);
let mut shaders = Vec::new();
for fragment in FRAGMENTS {
for extension in [RUNTIME_TEXT, METAL_TEXT] {
shaders.push(ShaderRef {
fixture: format!("{FIXTURE}{extension}"),
entry: format!("{COVER}+{fragment}"),
source_sha256: crate::sha256_hex(fixture.text(extension)?.as_bytes()),
});
}
}
Ok(shaders)
}
fn inputs(&self) -> Result<Vec<Input>, String> {
let fixture = Fixture::new(FIXTURE);
let mut inputs = vec![
Input {
name: "air".to_owned(),
digest: Digest::sha256(fixture.text(RUNTIME_TEXT)?.as_bytes()),
},
Input {
name: "air-typed".to_owned(),
digest: Digest::sha256(fixture.text(METAL_TEXT)?.as_bytes()),
},
Input::bytes("buffer:1", &width_bytes()),
Input::bytes("attachment", &attachment().words()),
];
for fragment in FRAGMENTS {
let pipeline = RenderPipelineSpec::new(COVER, fragment, &COLORS);
inputs.push(Input::bytes(
format!("{fragment}/pipeline"),
&pipeline.words(),
));
inputs.push(Input::bytes(
format!("{fragment}/buffer:0"),
&values(fragment),
));
}
for format in FORMATS {
inputs.push(Input::bytes(format.name(), &request(format).words()));
}
Ok(inputs)
}
fn run(&self, side: &mut dyn Side, sites: &mut Sites) -> Result<(), Abort> {
let loaded = Fixture::new(FIXTURE).loaded().map_err(|why| Abort {
at: "library".to_owned(),
failure: Failure::named("FixtureNotRead", why),
})?;
let library = made(sites, "library", side.library(&loaded.source()))?;
let shape = made(sites, "buffer/width", side.buffer(&width_bytes()))?;
for fragment in FRAGMENTS {
let pipeline = made(
sites,
&format!("{fragment}/pipeline"),
side.render_pipeline(library, &RenderPipelineSpec::new(COVER, fragment, &COLORS)),
)?;
let values = made(
sites,
&format!("{fragment}/buffer/0"),
side.buffer(&values(fragment)),
)?;
for format in FORMATS {
let at = |site: &str| format!("{}/{fragment}/{site}", format.name());
let texture = made(sites, &at("texture"), side.texture(&request(format)))?;
let into = made(sites, &at("attachment"), side.target(&attachment()))?;
let steps = vec![
RenderStep::Pipeline(pipeline),
RenderStep::FragmentTexture { texture, index: 0 },
RenderStep::FragmentBuffer {
buffer: values,
offset: 0,
index: 0,
},
RenderStep::FragmentBuffer {
buffer: shape,
offset: 0,
index: 1,
},
RenderStep::Draw {
primitive: PrimitiveType::Triangle,
first: 0,
count: 3,
instances: 1,
},
];
let pass = RenderWork::Pass(
RenderPass::clearing(vec![PassColor::cleared(into, [0.0; 4])]).drawing(steps),
);
let outcome = call(sites, &at("draw"), side.render(&[pass]), |outcome| {
outcome.status.clone()
})?;
let refused = outcome.refused.first().and_then(Option::as_ref);
sites.push(Node::leaf(
at("pass"),
Observed::value(match refused {
Some(failure) => failure.recorded(),
None => Value::ok(Value::Absent),
}),
));
if let Some(failure) = refused {
return Err(Abort {
at: at("pass"),
failure: failure.clone(),
});
}
let stored = call(
sites,
&at("texels"),
side.read_texture(texture, [WIDTH, HEIGHT], WIDTH * 4),
|_| Value::Absent,
)?;
sites.push(Node::leaf(
at("stored"),
Observed::bytes(stored, stored_layout()),
));
}
}
Ok(())
}
}
@@ -35,8 +35,9 @@ const FIXTURE: &str = "fpv_srgb_storage";
/// The kernels the case runs: a `float4` write and a `half4` write.
const KERNELS: [&str; 2] = ["fpv_srgb_write", "fpv_srgb_write_half"];
/// The formats the case writes.
const FORMATS: [PixelFormat; 2] = [PixelFormat::RGBA8UnormSRGB, PixelFormat::BGRA8UnormSRGB];
/// The formats the case, and its fragment twin, write.
pub(crate) const FORMATS: [PixelFormat; 2] =
[PixelFormat::RGBA8UnormSRGB, PixelFormat::BGRA8UnormSRGB];
/// The texture's width, which buffer 1 holds.
pub const WIDTH: u32 = 256;
@@ -86,9 +87,11 @@ pub fn texels() -> Vec<[f32; 4]> {
out
}
/// Buffer 0's bytes for `kernel`: each texel's `float4`, or its `half4`.
fn values(kernel: &str) -> Vec<u8> {
let half = kernel.ends_with("_half");
/// Buffer 0's bytes for `function`, a kernel here or a fragment function of the fragment twin
/// (`srgb-storage-fragment-writes`): each texel's `float4`, or its `half4` where the name ends in
/// `_half`.
pub(crate) fn values(function: &str) -> Vec<u8> {
let half = function.ends_with("_half");
let mut bytes = Vec::new();
for value in texels().into_iter().flatten() {
match half {
@@ -100,17 +103,17 @@ fn values(kernel: &str) -> Vec<u8> {
}
/// Buffer 1's bytes: the row's width, as the kernels' `constant uint &width`.
fn width_bytes() -> Vec<u8> {
pub(crate) fn width_bytes() -> Vec<u8> {
WIDTH.to_le_bytes().to_vec()
}
/// The texture a sweep writes: shared storage, written by shaders alone.
fn request(format: PixelFormat) -> TextureRequest<'static> {
pub(crate) fn request(format: PixelFormat) -> TextureRequest<'static> {
TextureRequest::read_2d(format.as_raw(), WIDTH, HEIGHT).used(TextureUsage::SHADER_WRITE)
}
/// The layout the stored bytes are read under: one row a texel row, one code a channel.
fn stored_layout() -> ByteLayout {
pub(crate) fn stored_layout() -> ByteLayout {
let pitch = WIDTH * 4;
ByteLayout {
region: Region::Texture {
@@ -191,7 +191,8 @@ impl Row {
/// The family is exhaustive in the directions that matter and small in every other: a step on x
/// and on y, a step rate of 1, 2 and 3, an origin inside and past the buffer's elements, a size of
/// 0, a size of 1, a size below the grid and a size equal to it, both axes of a 2D region, the
/// indexed steps, a constant step, a region set indirectly and a region set twice.
/// indexed steps at a step rate of 1, 2 and 3, a constant step, a region set indirectly and a
/// region set twice.
const ROWS: &[Row] = &[
Row {
name: "x_r8_g8",
@@ -454,6 +455,33 @@ const ROWS: &[Row] = &[
group: [4, 1],
how: How::Direct,
},
Row {
name: "xi_rate2_o1_r3_g8",
layouts: &[(StepFunction::ThreadPositionInGridXIndexed, 2)],
origin: [1, 0, 0],
size: [3, 1, 1],
grid: [8, 1],
group: [8, 1],
how: How::Direct,
},
Row {
name: "xi_rate3_o2_r4_g12",
layouts: &[(StepFunction::ThreadPositionInGridXIndexed, 3)],
origin: [2, 0, 0],
size: [4, 1, 1],
grid: [12, 1],
group: [12, 1],
how: How::Direct,
},
Row {
name: "yi_rate2_o1_r2_g2x8",
layouts: &[(StepFunction::ThreadPositionInGridYIndexed, 2)],
origin: [0, 1, 0],
size: [1, 2, 1],
grid: [2, 8],
group: [2, 8],
how: How::Direct,
},
];
/// Source buffer `index`'s bytes: buffer 1 holds `0x10 + e`, buffer 2 `0x200 + e`, and buffer 3
@@ -212,6 +212,10 @@ pub enum ComputeStep {
offset: u64,
threads: [u32; 3],
},
/// `dispatchThreads:threadsPerThreadgroup:`: a grid of `grid` threads, which need not be a
/// whole number of threadgroups, so the last threadgroup along an axis may run only the
/// threads left.
DispatchThreads { grid: [u32; 3], threads: [u32; 3] },
}
impl ComputeStep {
@@ -247,6 +251,7 @@ impl ComputeStep {
ComputeStep::DispatchThreadgroupsIndirect { .. } => {
"dispatchThreadgroupsWithIndirectBuffer"
}
ComputeStep::DispatchThreads { .. } => "dispatchThreads",
}
}
@@ -382,6 +387,11 @@ impl ComputeStep {
words.extend(axis.to_le_bytes());
}
}
ComputeStep::DispatchThreads { grid, threads } => {
for axis in grid.iter().chain(threads) {
words.extend(axis.to_le_bytes());
}
}
}
words
}
@@ -392,6 +402,7 @@ impl ComputeStep {
self,
ComputeStep::DispatchThreadgroups { .. }
| ComputeStep::DispatchThreadgroupsIndirect { .. }
| ComputeStep::DispatchThreads { .. }
)
}
}
@@ -627,7 +638,11 @@ mod tests {
offset: 0,
threads: [8, 1, 1],
},
ComputeStep::DispatchThreadgroupsIndirect { .. } => return None,
ComputeStep::DispatchThreadgroupsIndirect { .. } => ComputeStep::DispatchThreads {
grid: [9, 1, 1],
threads: [8, 1, 1],
},
ComputeStep::DispatchThreads { .. } => return None,
})
}
@@ -717,7 +732,7 @@ mod tests {
);
}
/// Both dispatch steps say they dispatch and no other step does, so a guard that bounds a
/// The three dispatch steps say they dispatch and no other step does, so a guard that bounds a
/// case's grids reads every dispatch and nothing else.
#[test]
fn only_the_dispatch_steps_dispatch() {
@@ -730,7 +745,8 @@ mod tests {
dispatching,
[
"dispatchThreadgroups",
"dispatchThreadgroupsWithIndirectBuffer"
"dispatchThreadgroupsWithIndirectBuffer",
"dispatchThreads"
]
);
}
+177 -215
View File
@@ -1,5 +1,6 @@
//! The degrade-notice codes the suite's cases name: `metal2vulkan-degrade-<kind>`, one per kind,
//! and the kind each of the runtime's precision notes announces as.
//! each its precision note's code as the translator states it (`PrecisionNote::code`), and the
//! kind each of the runtime's precision notes announces as.
//!
//! A case loosens a field by naming a code ([`crate::allowance`]), and the comparison holds it
//! there only where the run announced that code. The runtime's side announces the codes of
@@ -11,170 +12,168 @@ use metal2vulkan::pipeline::PrecisionNote;
/// A kind of degrade notice, by its code ([`Degradation::code`]).
#[derive(Clone, Copy, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
pub enum Degradation {
/// `metal2vulkan-degrade-device-rounded-resolve`.
/// [`PrecisionNote::DeviceRoundedResolve`].
DeviceRoundedResolve,
/// `metal2vulkan-degrade-device-reconvergence`.
/// [`PrecisionNote::DeviceReconvergence`].
DeviceReconvergence,
/// `metal2vulkan-degrade-simdgroup-access-order`.
/// [`PrecisionNote::SimdgroupAccessOrder`].
SimdgroupAccessOrder,
/// `metal2vulkan-degrade-device-filtered-mipmaps`.
/// [`PrecisionNote::DeviceFilteredMipmaps`].
DeviceFilteredMipmaps,
/// `metal2vulkan-degrade-capped-lod-bias`.
/// [`PrecisionNote::CappedLodBias`].
CappedLodBias,
/// `metal2vulkan-degrade-snorm-minimum-kept`.
/// [`PrecisionNote::SnormMinimumKept`].
SnormMinimumKept,
/// `metal2vulkan-degrade-shared-exponent-kept`.
/// [`PrecisionNote::SharedExponentKept`].
SharedExponentKept,
/// `metal2vulkan-degrade-compressed-texel-decode`.
/// [`PrecisionNote::CompressedTexelDecode`].
CompressedTexelDecode,
/// `metal2vulkan-degrade-depth-denormals`.
/// [`PrecisionNote::DepthDenormals`].
DepthDenormals,
/// `metal2vulkan-degrade-f16-fma-double-rounding`.
/// [`PrecisionNote::F16FmaDoubleRounding`].
F16FmaDoubleRounding,
/// `metal2vulkan-degrade-f16-int-conv-double-rounding`.
/// [`PrecisionNote::F16IntConvDoubleRounding`].
F16IntConvDoubleRounding,
/// `metal2vulkan-degrade-grad-from-bias`.
/// [`PrecisionNote::GradFromBias`].
GradFromBias,
/// `metal2vulkan-degrade-device-transcendentals`.
/// [`PrecisionNote::DeviceTranscendentals`].
DeviceTranscendentals,
/// `metal2vulkan-degrade-reduction-order`.
/// [`PrecisionNote::ReductionOrder`].
ReductionOrder,
/// `metal2vulkan-degrade-device-denormals`.
/// [`PrecisionNote::DeviceDenormals`].
DeviceDenormals,
/// `metal2vulkan-degrade-pixel-sampler-scaling`.
/// [`PrecisionNote::PixelSamplerScaling`].
PixelSamplerScaling,
/// `metal2vulkan-degrade-device-arithmetic`.
/// [`PrecisionNote::DeviceArithmetic`].
DeviceArithmetic,
/// `metal2vulkan-degrade-device-signed-zero-inf-nan`.
/// [`PrecisionNote::DeviceSignedZeroInfNan`].
DeviceSignedZeroInfNan,
/// `metal2vulkan-degrade-device-ray-intersection`.
/// [`PrecisionNote::DeviceRayIntersection`].
DeviceRayIntersection,
/// `metal2vulkan-degrade-fast-math-rewrites`.
/// [`PrecisionNote::FastMathRewrites`].
FastMathRewrites,
/// `metal2vulkan-degrade-tessellation-winding`.
/// [`PrecisionNote::TessellationWinding`].
TessellationWinding,
/// `metal2vulkan-degrade-tessellation-fractional-spacing`.
/// [`PrecisionNote::TessellationFractionalSpacing`].
TessellationFractionalSpacing,
/// `metal2vulkan-degrade-tessellation-factor-edge-cases`.
/// [`PrecisionNote::TessellationFactorEdgeCases`].
TessellationFactorEdgeCases,
/// `metal2vulkan-degrade-tessellation-factor-scale`.
/// [`PrecisionNote::TessellationFactorScale`].
TessellationFactorScale,
/// `metal2vulkan-degrade-tessellation-factor-instance`.
/// [`PrecisionNote::TessellationFactorInstance`].
TessellationFactorInstance,
/// `metal2vulkan-degrade-fp8-value`.
/// [`PrecisionNote::Fp8Value`].
Fp8Value,
/// `metal2vulkan-degrade-multisample-position`.
/// [`PrecisionNote::MultisamplePosition`].
MultisamplePosition,
/// `metal2vulkan-degrade-bicubic-filter-arithmetic`.
/// [`PrecisionNote::BicubicFilterArithmetic`].
BicubicFilterArithmetic,
/// `metal2vulkan-degrade-sparse-residency`.
SparseResidency,
/// `metal2vulkan-degrade-device-nan-encoding`.
/// [`PrecisionNote::DeviceNanEncoding`].
DeviceNanEncoding,
/// `metal2vulkan-degrade-restricted-depth-range`.
/// [`PrecisionNote::RestrictedDepthRange`].
RestrictedDepthRange,
/// `metal2vulkan-degrade-cube-gradient-footprint`.
/// [`PrecisionNote::CubeGradientFootprint`].
CubeGradientFootprint,
/// `metal2vulkan-degrade-half-texel-conversion`.
/// [`PrecisionNote::HalfTexelConversion`].
HalfTexelConversion,
/// `metal2vulkan-degrade-srgb-texel-decode`.
/// [`PrecisionNote::SrgbTexelDecode`].
SrgbTexelDecode,
/// `metal2vulkan-degrade-function-storage-assumed`.
/// [`PrecisionNote::FunctionStorageAssumed`].
FunctionStorageAssumed,
/// `metal2vulkan-degrade-quads-counted-before-discard`.
/// [`PrecisionNote::QuadsCountedBeforeDiscard`].
QuadsCountedBeforeDiscard,
/// `metal2vulkan-degrade-view-base-texel-offset`.
/// [`PrecisionNote::ViewBaseTexelOffset`].
ViewBaseTexelOffset,
/// `metal2vulkan-degrade-device-color-conversion`.
/// [`PrecisionNote::DeviceColorConversion`].
DeviceColorConversion,
/// `metal2vulkan-degrade-device-interpolation`.
/// [`PrecisionNote::DeviceInterpolation`].
DeviceInterpolation,
/// `metal2vulkan-degrade-device-interpolation-offset`.
/// [`PrecisionNote::DeviceInterpolationOffset`].
DeviceInterpolationOffset,
/// `metal2vulkan-degrade-extrapolated-interpolation`.
/// [`PrecisionNote::ExtrapolatedInterpolation`].
ExtrapolatedInterpolation,
/// `metal2vulkan-degrade-quads-split-by-clipping`.
/// [`PrecisionNote::QuadsSplitByClipping`].
QuadsSplitByClipping,
/// `metal2vulkan-degrade-fragment-simdgroup-grouping`.
/// [`PrecisionNote::FragmentSimdgroupGrouping`].
FragmentSimdgroupGrouping,
/// `metal2vulkan-degrade-blended-write-rounding`.
/// [`PrecisionNote::BlendedWriteRounding`].
BlendedWriteRounding,
/// `metal2vulkan-degrade-rotated-blend-rounding`.
/// [`PrecisionNote::RotatedBlendRounding`].
RotatedBlendRounding,
/// `metal2vulkan-degrade-linked-sampler-numbering`.
/// [`PrecisionNote::LinkedSamplerNumbering`].
LinkedSamplerNumbering,
/// `metal2vulkan-degrade-argument-pixel-sampler-scaling`.
/// [`PrecisionNote::ArgumentPixelSamplerScaling`].
ArgumentPixelSamplerScaling,
/// `metal2vulkan-degrade-half-output-precision`.
/// [`PrecisionNote::HalfOutputPrecision`].
HalfOutputPrecision,
/// `metal2vulkan-degrade-anisotropic-filter`.
AnisotropicFilter,
/// `metal2vulkan-degrade-device-anisotropic-filter`.
DeviceAnisotropicFilter,
/// `metal2vulkan-degrade-device-point-size`.
/// [`PrecisionNote::DevicePointSize`].
DevicePointSize,
/// `metal2vulkan-degrade-clipped-coverage-split`.
/// [`PrecisionNote::ClippedCoverageSplit`].
ClippedCoverageSplit,
/// `metal2vulkan-degrade-looped-sample-outputs`.
/// [`PrecisionNote::LoopedSampleOutputs`].
LoopedSampleOutputs,
/// `metal2vulkan-degrade-half-output-fast-math-blend`.
/// [`PrecisionNote::HalfOutputFastMathBlend`].
HalfOutputFastMathBlend,
/// `metal2vulkan-degrade-device-sampling`.
/// [`PrecisionNote::DeviceSampling`].
DeviceSampling,
/// `metal2vulkan-degrade-native-transcendentals`.
/// [`PrecisionNote::NativeTranscendentals`].
NativeTranscendentals,
/// `metal2vulkan-degrade-native-division`.
/// [`PrecisionNote::NativeDivision`].
NativeDivision,
/// `metal2vulkan-degrade-native-fma`.
/// [`PrecisionNote::NativeFma`].
NativeFma,
/// `metal2vulkan-degrade-device-texel-conversion`.
/// [`PrecisionNote::DeviceTexelConversion`].
DeviceTexelConversion,
/// `metal2vulkan-degrade-device-vertex-conversion`.
/// [`PrecisionNote::DeviceVertexConversion`].
DeviceVertexConversion,
/// `metal2vulkan-degrade-native-half-conversion`.
/// [`PrecisionNote::NativeHalfConversion`].
NativeHalfConversion,
/// `metal2vulkan-degrade-native-half-quantize`.
/// [`PrecisionNote::NativeHalfQuantize`].
NativeHalfQuantize,
/// `metal2vulkan-degrade-native-nan-encoding`.
/// [`PrecisionNote::NativeNanEncoding`].
NativeNanEncoding,
/// `metal2vulkan-degrade-native-min-max`.
/// [`PrecisionNote::NativeMinMax`].
NativeMinMax,
/// `metal2vulkan-degrade-native-dot`.
/// [`PrecisionNote::NativeDot`].
NativeDot,
/// `metal2vulkan-degrade-native-mix`.
/// [`PrecisionNote::NativeMix`].
NativeMix,
/// `metal2vulkan-degrade-device-pack-conversion`.
/// [`PrecisionNote::DevicePackConversion`].
DevicePackConversion,
/// `metal2vulkan-degrade-tessellation-triangle-order`.
/// [`PrecisionNote::TessellationTriangleOrder`].
TessellationTriangleOrder,
/// `metal2vulkan-degrade-unmeasured-group-speculation`.
/// [`PrecisionNote::UnmeasuredGroupSpeculation`].
UnmeasuredGroupSpeculation,
/// `metal2vulkan-degrade-device-sample-level`.
/// [`PrecisionNote::DeviceSampleLevel`].
DeviceSampleLevel,
/// `metal2vulkan-degrade-coverage-reads-rounded-alpha`.
/// [`PrecisionNote::CoverageReadsRoundedAlpha`].
CoverageReadsRoundedAlpha,
/// `metal2vulkan-degrade-device-alpha-coverage`.
/// [`PrecisionNote::DeviceAlphaCoverage`].
DeviceAlphaCoverage,
/// `metal2vulkan-degrade-unordered-fetch-within-draw`.
/// [`PrecisionNote::UnorderedFetchWithinDraw`].
UnorderedFetchWithinDraw,
/// `metal2vulkan-degrade-native-logic-operation`.
/// [`PrecisionNote::NativeLogicOperation`].
NativeLogicOperation,
/// `metal2vulkan-degrade-device-depth-bias`.
/// [`PrecisionNote::DeviceDepthBias`].
DeviceDepthBias,
/// `metal2vulkan-degrade-swizzled-opaque-black-border`.
/// [`PrecisionNote::SwizzledOpaqueBlackBorder`].
SwizzledOpaqueBlackBorder,
/// `metal2vulkan-degrade-device-line-rasterization`.
/// [`PrecisionNote::DeviceLineRasterization`].
DeviceLineRasterization,
/// `metal2vulkan-degrade-device-fragment-runs`.
/// [`PrecisionNote::DeviceFragmentRuns`].
DeviceFragmentRuns,
/// `metal2vulkan-degrade-device-occlusion-count`.
/// [`PrecisionNote::DeviceOcclusionCount`].
DeviceOcclusionCount,
/// `metal2vulkan-degrade-vertex-simdgroup-grouping`.
/// [`PrecisionNote::VertexSimdgroupGrouping`].
VertexSimdgroupGrouping,
/// `metal2vulkan-degrade-restricted-depth-upload`.
/// [`PrecisionNote::RestrictedDepthUpload`].
RestrictedDepthUpload,
/// `metal2vulkan-degrade-stencil-output-overlap`.
/// [`PrecisionNote::StencilOutputOverlap`].
StencilOutputOverlap,
/// [`PrecisionNote::DeviceHalfDenormals`].
DeviceHalfDenormals,
/// [`PrecisionNote::RoundedSampleDepthCopy`].
RoundedSampleDepthCopy,
}
impl Degradation {
@@ -208,7 +207,6 @@ impl Degradation {
Degradation::Fp8Value,
Degradation::MultisamplePosition,
Degradation::BicubicFilterArithmetic,
Degradation::SparseResidency,
Degradation::DeviceNanEncoding,
Degradation::RestrictedDepthRange,
Degradation::CubeGradientFootprint,
@@ -228,8 +226,6 @@ impl Degradation {
Degradation::LinkedSamplerNumbering,
Degradation::ArgumentPixelSamplerScaling,
Degradation::HalfOutputPrecision,
Degradation::AnisotropicFilter,
Degradation::DeviceAnisotropicFilter,
Degradation::DevicePointSize,
Degradation::ClippedCoverageSplit,
Degradation::LoopedSampleOutputs,
@@ -262,135 +258,102 @@ impl Degradation {
Degradation::VertexSimdgroupGrouping,
Degradation::RestrictedDepthUpload,
Degradation::StencilOutputOverlap,
Degradation::DeviceHalfDenormals,
Degradation::RoundedSampleDepthCopy,
];
/// The kind's code, `metal2vulkan-degrade-<kind>`.
/// The kind's code, `metal2vulkan-degrade-<kind>`: its precision note's, which the translator
/// states ([`PrecisionNote::code`]).
pub const fn code(self) -> &'static str {
self.note().code()
}
/// The precision note the kind is: [`Degradation::from_precision_note`] taken back.
pub const fn note(self) -> PrecisionNote {
match self {
Degradation::DeviceRoundedResolve => "metal2vulkan-degrade-device-rounded-resolve",
Degradation::DeviceReconvergence => "metal2vulkan-degrade-device-reconvergence",
Degradation::SimdgroupAccessOrder => "metal2vulkan-degrade-simdgroup-access-order",
Degradation::DeviceFilteredMipmaps => "metal2vulkan-degrade-device-filtered-mipmaps",
Degradation::CappedLodBias => "metal2vulkan-degrade-capped-lod-bias",
Degradation::SnormMinimumKept => "metal2vulkan-degrade-snorm-minimum-kept",
Degradation::SharedExponentKept => "metal2vulkan-degrade-shared-exponent-kept",
Degradation::CompressedTexelDecode => "metal2vulkan-degrade-compressed-texel-decode",
Degradation::DepthDenormals => "metal2vulkan-degrade-depth-denormals",
Degradation::F16FmaDoubleRounding => "metal2vulkan-degrade-f16-fma-double-rounding",
Degradation::F16IntConvDoubleRounding => {
"metal2vulkan-degrade-f16-int-conv-double-rounding"
}
Degradation::GradFromBias => "metal2vulkan-degrade-grad-from-bias",
Degradation::DeviceTranscendentals => "metal2vulkan-degrade-device-transcendentals",
Degradation::ReductionOrder => "metal2vulkan-degrade-reduction-order",
Degradation::DeviceDenormals => "metal2vulkan-degrade-device-denormals",
Degradation::PixelSamplerScaling => "metal2vulkan-degrade-pixel-sampler-scaling",
Degradation::DeviceArithmetic => "metal2vulkan-degrade-device-arithmetic",
Degradation::DeviceSignedZeroInfNan => {
"metal2vulkan-degrade-device-signed-zero-inf-nan"
}
Degradation::DeviceRayIntersection => "metal2vulkan-degrade-device-ray-intersection",
Degradation::FastMathRewrites => "metal2vulkan-degrade-fast-math-rewrites",
Degradation::TessellationWinding => "metal2vulkan-degrade-tessellation-winding",
Degradation::DeviceRoundedResolve => PrecisionNote::DeviceRoundedResolve,
Degradation::DeviceReconvergence => PrecisionNote::DeviceReconvergence,
Degradation::SimdgroupAccessOrder => PrecisionNote::SimdgroupAccessOrder,
Degradation::DeviceFilteredMipmaps => PrecisionNote::DeviceFilteredMipmaps,
Degradation::CappedLodBias => PrecisionNote::CappedLodBias,
Degradation::SnormMinimumKept => PrecisionNote::SnormMinimumKept,
Degradation::SharedExponentKept => PrecisionNote::SharedExponentKept,
Degradation::CompressedTexelDecode => PrecisionNote::CompressedTexelDecode,
Degradation::DepthDenormals => PrecisionNote::DepthDenormals,
Degradation::F16FmaDoubleRounding => PrecisionNote::F16FmaDoubleRounding,
Degradation::F16IntConvDoubleRounding => PrecisionNote::F16IntConvDoubleRounding,
Degradation::GradFromBias => PrecisionNote::GradFromBias,
Degradation::DeviceTranscendentals => PrecisionNote::DeviceTranscendentals,
Degradation::ReductionOrder => PrecisionNote::ReductionOrder,
Degradation::DeviceDenormals => PrecisionNote::DeviceDenormals,
Degradation::PixelSamplerScaling => PrecisionNote::PixelSamplerScaling,
Degradation::DeviceArithmetic => PrecisionNote::DeviceArithmetic,
Degradation::DeviceSignedZeroInfNan => PrecisionNote::DeviceSignedZeroInfNan,
Degradation::DeviceRayIntersection => PrecisionNote::DeviceRayIntersection,
Degradation::FastMathRewrites => PrecisionNote::FastMathRewrites,
Degradation::TessellationWinding => PrecisionNote::TessellationWinding,
Degradation::TessellationFractionalSpacing => {
"metal2vulkan-degrade-tessellation-fractional-spacing"
PrecisionNote::TessellationFractionalSpacing
}
Degradation::TessellationFactorEdgeCases => {
"metal2vulkan-degrade-tessellation-factor-edge-cases"
}
Degradation::TessellationFactorScale => {
"metal2vulkan-degrade-tessellation-factor-scale"
}
Degradation::TessellationFactorInstance => {
"metal2vulkan-degrade-tessellation-factor-instance"
}
Degradation::Fp8Value => "metal2vulkan-degrade-fp8-value",
Degradation::MultisamplePosition => "metal2vulkan-degrade-multisample-position",
Degradation::BicubicFilterArithmetic => {
"metal2vulkan-degrade-bicubic-filter-arithmetic"
}
Degradation::SparseResidency => "metal2vulkan-degrade-sparse-residency",
Degradation::DeviceNanEncoding => "metal2vulkan-degrade-device-nan-encoding",
Degradation::RestrictedDepthRange => "metal2vulkan-degrade-restricted-depth-range",
Degradation::CubeGradientFootprint => "metal2vulkan-degrade-cube-gradient-footprint",
Degradation::HalfTexelConversion => "metal2vulkan-degrade-half-texel-conversion",
Degradation::SrgbTexelDecode => "metal2vulkan-degrade-srgb-texel-decode",
Degradation::FunctionStorageAssumed => "metal2vulkan-degrade-function-storage-assumed",
Degradation::QuadsCountedBeforeDiscard => {
"metal2vulkan-degrade-quads-counted-before-discard"
}
Degradation::ViewBaseTexelOffset => "metal2vulkan-degrade-view-base-texel-offset",
Degradation::DeviceColorConversion => "metal2vulkan-degrade-device-color-conversion",
Degradation::DeviceInterpolation => "metal2vulkan-degrade-device-interpolation",
Degradation::DeviceInterpolationOffset => {
"metal2vulkan-degrade-device-interpolation-offset"
}
Degradation::ExtrapolatedInterpolation => {
"metal2vulkan-degrade-extrapolated-interpolation"
}
Degradation::QuadsSplitByClipping => "metal2vulkan-degrade-quads-split-by-clipping",
Degradation::FragmentSimdgroupGrouping => {
"metal2vulkan-degrade-fragment-simdgroup-grouping"
}
Degradation::BlendedWriteRounding => "metal2vulkan-degrade-blended-write-rounding",
Degradation::RotatedBlendRounding => "metal2vulkan-degrade-rotated-blend-rounding",
Degradation::LinkedSamplerNumbering => "metal2vulkan-degrade-linked-sampler-numbering",
Degradation::ArgumentPixelSamplerScaling => {
"metal2vulkan-degrade-argument-pixel-sampler-scaling"
}
Degradation::HalfOutputPrecision => "metal2vulkan-degrade-half-output-precision",
Degradation::AnisotropicFilter => "metal2vulkan-degrade-anisotropic-filter",
Degradation::DeviceAnisotropicFilter => {
"metal2vulkan-degrade-device-anisotropic-filter"
}
Degradation::DevicePointSize => "metal2vulkan-degrade-device-point-size",
Degradation::ClippedCoverageSplit => "metal2vulkan-degrade-clipped-coverage-split",
Degradation::LoopedSampleOutputs => "metal2vulkan-degrade-looped-sample-outputs",
Degradation::HalfOutputFastMathBlend => {
"metal2vulkan-degrade-half-output-fast-math-blend"
}
Degradation::DeviceSampling => "metal2vulkan-degrade-device-sampling",
Degradation::NativeTranscendentals => "metal2vulkan-degrade-native-transcendentals",
Degradation::NativeDivision => "metal2vulkan-degrade-native-division",
Degradation::NativeFma => "metal2vulkan-degrade-native-fma",
Degradation::DeviceTexelConversion => "metal2vulkan-degrade-device-texel-conversion",
Degradation::DeviceVertexConversion => "metal2vulkan-degrade-device-vertex-conversion",
Degradation::NativeHalfConversion => "metal2vulkan-degrade-native-half-conversion",
Degradation::NativeHalfQuantize => "metal2vulkan-degrade-native-half-quantize",
Degradation::NativeNanEncoding => "metal2vulkan-degrade-native-nan-encoding",
Degradation::NativeMinMax => "metal2vulkan-degrade-native-min-max",
Degradation::NativeDot => "metal2vulkan-degrade-native-dot",
Degradation::NativeMix => "metal2vulkan-degrade-native-mix",
Degradation::DevicePackConversion => "metal2vulkan-degrade-device-pack-conversion",
Degradation::TessellationTriangleOrder => {
"metal2vulkan-degrade-tessellation-triangle-order"
}
Degradation::UnmeasuredGroupSpeculation => {
"metal2vulkan-degrade-unmeasured-group-speculation"
}
Degradation::DeviceSampleLevel => "metal2vulkan-degrade-device-sample-level",
Degradation::CoverageReadsRoundedAlpha => {
"metal2vulkan-degrade-coverage-reads-rounded-alpha"
}
Degradation::DeviceAlphaCoverage => "metal2vulkan-degrade-device-alpha-coverage",
Degradation::UnorderedFetchWithinDraw => {
"metal2vulkan-degrade-unordered-fetch-within-draw"
}
Degradation::NativeLogicOperation => "metal2vulkan-degrade-native-logic-operation",
Degradation::DeviceDepthBias => "metal2vulkan-degrade-device-depth-bias",
Degradation::SwizzledOpaqueBlackBorder => {
"metal2vulkan-degrade-swizzled-opaque-black-border"
}
Degradation::DeviceLineRasterization => {
"metal2vulkan-degrade-device-line-rasterization"
}
Degradation::DeviceFragmentRuns => "metal2vulkan-degrade-device-fragment-runs",
Degradation::DeviceOcclusionCount => "metal2vulkan-degrade-device-occlusion-count",
Degradation::VertexSimdgroupGrouping => {
"metal2vulkan-degrade-vertex-simdgroup-grouping"
}
Degradation::RestrictedDepthUpload => "metal2vulkan-degrade-restricted-depth-upload",
Degradation::StencilOutputOverlap => "metal2vulkan-degrade-stencil-output-overlap",
Degradation::TessellationFactorEdgeCases => PrecisionNote::TessellationFactorEdgeCases,
Degradation::TessellationFactorScale => PrecisionNote::TessellationFactorScale,
Degradation::TessellationFactorInstance => PrecisionNote::TessellationFactorInstance,
Degradation::Fp8Value => PrecisionNote::Fp8Value,
Degradation::MultisamplePosition => PrecisionNote::MultisamplePosition,
Degradation::BicubicFilterArithmetic => PrecisionNote::BicubicFilterArithmetic,
Degradation::DeviceNanEncoding => PrecisionNote::DeviceNanEncoding,
Degradation::RestrictedDepthRange => PrecisionNote::RestrictedDepthRange,
Degradation::CubeGradientFootprint => PrecisionNote::CubeGradientFootprint,
Degradation::HalfTexelConversion => PrecisionNote::HalfTexelConversion,
Degradation::SrgbTexelDecode => PrecisionNote::SrgbTexelDecode,
Degradation::FunctionStorageAssumed => PrecisionNote::FunctionStorageAssumed,
Degradation::QuadsCountedBeforeDiscard => PrecisionNote::QuadsCountedBeforeDiscard,
Degradation::ViewBaseTexelOffset => PrecisionNote::ViewBaseTexelOffset,
Degradation::DeviceColorConversion => PrecisionNote::DeviceColorConversion,
Degradation::DeviceInterpolation => PrecisionNote::DeviceInterpolation,
Degradation::DeviceInterpolationOffset => PrecisionNote::DeviceInterpolationOffset,
Degradation::ExtrapolatedInterpolation => PrecisionNote::ExtrapolatedInterpolation,
Degradation::QuadsSplitByClipping => PrecisionNote::QuadsSplitByClipping,
Degradation::FragmentSimdgroupGrouping => PrecisionNote::FragmentSimdgroupGrouping,
Degradation::BlendedWriteRounding => PrecisionNote::BlendedWriteRounding,
Degradation::RotatedBlendRounding => PrecisionNote::RotatedBlendRounding,
Degradation::LinkedSamplerNumbering => PrecisionNote::LinkedSamplerNumbering,
Degradation::ArgumentPixelSamplerScaling => PrecisionNote::ArgumentPixelSamplerScaling,
Degradation::HalfOutputPrecision => PrecisionNote::HalfOutputPrecision,
Degradation::DevicePointSize => PrecisionNote::DevicePointSize,
Degradation::ClippedCoverageSplit => PrecisionNote::ClippedCoverageSplit,
Degradation::LoopedSampleOutputs => PrecisionNote::LoopedSampleOutputs,
Degradation::HalfOutputFastMathBlend => PrecisionNote::HalfOutputFastMathBlend,
Degradation::DeviceSampling => PrecisionNote::DeviceSampling,
Degradation::NativeTranscendentals => PrecisionNote::NativeTranscendentals,
Degradation::NativeDivision => PrecisionNote::NativeDivision,
Degradation::NativeFma => PrecisionNote::NativeFma,
Degradation::DeviceTexelConversion => PrecisionNote::DeviceTexelConversion,
Degradation::DeviceVertexConversion => PrecisionNote::DeviceVertexConversion,
Degradation::NativeHalfConversion => PrecisionNote::NativeHalfConversion,
Degradation::NativeHalfQuantize => PrecisionNote::NativeHalfQuantize,
Degradation::NativeNanEncoding => PrecisionNote::NativeNanEncoding,
Degradation::NativeMinMax => PrecisionNote::NativeMinMax,
Degradation::NativeDot => PrecisionNote::NativeDot,
Degradation::NativeMix => PrecisionNote::NativeMix,
Degradation::DevicePackConversion => PrecisionNote::DevicePackConversion,
Degradation::TessellationTriangleOrder => PrecisionNote::TessellationTriangleOrder,
Degradation::UnmeasuredGroupSpeculation => PrecisionNote::UnmeasuredGroupSpeculation,
Degradation::DeviceSampleLevel => PrecisionNote::DeviceSampleLevel,
Degradation::CoverageReadsRoundedAlpha => PrecisionNote::CoverageReadsRoundedAlpha,
Degradation::DeviceAlphaCoverage => PrecisionNote::DeviceAlphaCoverage,
Degradation::UnorderedFetchWithinDraw => PrecisionNote::UnorderedFetchWithinDraw,
Degradation::NativeLogicOperation => PrecisionNote::NativeLogicOperation,
Degradation::DeviceDepthBias => PrecisionNote::DeviceDepthBias,
Degradation::SwizzledOpaqueBlackBorder => PrecisionNote::SwizzledOpaqueBlackBorder,
Degradation::DeviceLineRasterization => PrecisionNote::DeviceLineRasterization,
Degradation::DeviceFragmentRuns => PrecisionNote::DeviceFragmentRuns,
Degradation::DeviceOcclusionCount => PrecisionNote::DeviceOcclusionCount,
Degradation::VertexSimdgroupGrouping => PrecisionNote::VertexSimdgroupGrouping,
Degradation::RestrictedDepthUpload => PrecisionNote::RestrictedDepthUpload,
Degradation::StencilOutputOverlap => PrecisionNote::StencilOutputOverlap,
Degradation::DeviceHalfDenormals => PrecisionNote::DeviceHalfDenormals,
Degradation::RoundedSampleDepthCopy => PrecisionNote::RoundedSampleDepthCopy,
}
}
@@ -418,7 +381,6 @@ impl Degradation {
PrecisionNote::Fp8Value => Degradation::Fp8Value,
PrecisionNote::MultisamplePosition => Degradation::MultisamplePosition,
PrecisionNote::BicubicFilterArithmetic => Degradation::BicubicFilterArithmetic,
PrecisionNote::SparseResidency => Degradation::SparseResidency,
PrecisionNote::DeviceNanEncoding => Degradation::DeviceNanEncoding,
PrecisionNote::RestrictedDepthRange => Degradation::RestrictedDepthRange,
PrecisionNote::CubeGradientFootprint => Degradation::CubeGradientFootprint,
@@ -438,8 +400,6 @@ impl Degradation {
PrecisionNote::LinkedSamplerNumbering => Degradation::LinkedSamplerNumbering,
PrecisionNote::ArgumentPixelSamplerScaling => Degradation::ArgumentPixelSamplerScaling,
PrecisionNote::HalfOutputPrecision => Degradation::HalfOutputPrecision,
PrecisionNote::AnisotropicFilter => Degradation::AnisotropicFilter,
PrecisionNote::DeviceAnisotropicFilter => Degradation::DeviceAnisotropicFilter,
PrecisionNote::DevicePointSize => Degradation::DevicePointSize,
PrecisionNote::ClippedCoverageSplit => Degradation::ClippedCoverageSplit,
PrecisionNote::LoopedSampleOutputs => Degradation::LoopedSampleOutputs,
@@ -481,6 +441,8 @@ impl Degradation {
PrecisionNote::VertexSimdgroupGrouping => Degradation::VertexSimdgroupGrouping,
PrecisionNote::RestrictedDepthUpload => Degradation::RestrictedDepthUpload,
PrecisionNote::StencilOutputOverlap => Degradation::StencilOutputOverlap,
PrecisionNote::DeviceHalfDenormals => Degradation::DeviceHalfDenormals,
PrecisionNote::RoundedSampleDepthCopy => Degradation::RoundedSampleDepthCopy,
}
}
}
@@ -47,6 +47,16 @@
//! A row is held only against the cases a run selected, so replaying one case does not read every
//! other row as fixed.
//!
//! # More than one answer
//!
//! A row's answer is one answer, except where the hosts a venue's description covers answer the
//! site differently by a property that description does not state: llvmpipe of one Mesa and LLVM
//! stores the `x3` sites of `fetch-ordered-*-srgb` at 6,304 elements on one x86-64 AVX-512 host
//! and at 6,496 on others. Such a row lists each answer recorded there, with [`ANSWER_SEPARATOR`]
//! between them, and its gap names the run each came from. It covers each answer it lists and no
//! other, and is held while the run answers any of them ([`KnownGap::answers`]): a third answer is
//! still a new gap, and a site that no longer diverges still reads the row as fixed.
//!
//! # Typed reasons
//!
//! Three reasons are the ledger's own vocabulary ([`Reason`]), stated at the head of a row's last
@@ -74,6 +84,9 @@ pub const LEDGER_FILE: &str = "known-gaps-rt.tsv";
/// The venue field of a row that applies to every venue.
pub const EVERY_VENUE: &str = "*";
/// What stands between the answers of a row that lists more than one ([`KnownGap::answers`]).
pub const ANSWER_SEPARATOR: &str = " | ";
/// The verdict a row expects at its site.
///
/// Only these two. A case with no Metal answer, a stale recording and a case the venue could not
@@ -135,7 +148,9 @@ pub struct KnownGap {
/// What the run answers there, as the report prints it: our typed error for a refusal, and for
/// a divergence the one leaf fact that moved, which names Metal's value and ours. Part of the
/// row's identity, so a gap that changed into another gap at the same site is a new gap rather
/// than this one.
/// than this one. Where the venue's hosts answer the site differently by a property its
/// description does not state, it lists each answer recorded there, with [`ANSWER_SEPARATOR`]
/// between them ([`KnownGap::answers`]).
pub answer: String,
/// The gap the row is waiting on, in words: what Metal does, what we do instead, and where the
/// fix belongs. Not compared — it is what a reader needs — but a row must carry one.
@@ -150,10 +165,17 @@ impl KnownGap {
Reason::of(&self.waiting_on).unwrap_or(Reason::Words)
}
/// What identifies the row within a venue: the case, the verdict it expects, the site and the
/// answer there.
fn key(&self) -> (&str, Expects, &str, &str) {
(&self.case, self.expects, &self.site, &self.answer)
/// The answers the row covers at its site: its answer, or each of the answers it lists with
/// [`ANSWER_SEPARATOR`] between them.
pub fn answers(&self) -> impl Iterator<Item = &str> {
self.answer.split(ANSWER_SEPARATOR).map(str::trim)
}
/// Whether the row, within a venue it covers, is the gap a run held: the same case, verdict
/// and site, and one of its answers.
fn covers(&self, (case, expects, site, answer): (&str, Expects, &str, &str)) -> bool {
(self.case.as_str(), self.expects, self.site.as_str()) == (case, expects, site)
&& self.answers().any(|listed| listed == answer)
}
/// Whether the row is expected on `venue`.
@@ -623,7 +645,7 @@ pub fn against(rows: &[Replayed], ledger: &[KnownGap]) -> Vec<Expectation> {
for (case, expects, site, answer) in gaps {
let listed = ledger.iter().any(|gap| {
gap.covers_venue(&row.venue)
&& gap.key() == (case, *expects, site.as_str(), answer.as_str())
&& gap.covers((case, *expects, site.as_str(), answer.as_str()))
});
if !listed {
let listed = ledger
@@ -654,7 +676,7 @@ pub fn against(rows: &[Replayed], ledger: &[KnownGap]) -> Vec<Expectation> {
continue;
}
let still = gaps.iter().any(|(case, expects, site, answer)| {
(*case, *expects, site.as_str(), answer.as_str()) == gap.key()
gap.covers((case, *expects, site.as_str(), answer.as_str()))
});
if !still {
let now = if matches!(row.verdict, Verdict::LacksFeature { .. }) {
@@ -72,6 +72,7 @@ pub mod host_pages;
pub mod indirect_commands;
pub mod known_gaps;
pub mod library_facts;
pub mod managed_naming;
pub mod measured;
pub mod mesh_descriptors;
pub mod pass_descriptors;
@@ -0,0 +1,180 @@
//! Which commit takes a Managed buffer's named range to the GPU, on a device that keeps two copies
//! of it.
//!
//! `MTLBuffer.h` has a write into a Managed buffer's `contents` make the range "undefined for any
//! accesses by the GPU" until a `didModifyRange:` "followed by a commit of the MTLCommandBuffer that
//! will access the buffer". What a discrete Mac GPU answers beyond that is measured: one sequence
//! a row, each the same up to its reader.
//!
//! 1. A Managed buffer of [`LENGTH`] bytes, [`Content::Synced`] written, named and taken by a
//! committed blit that copies it, waited for.
//! 2. [`Content::Named`] written and named; a command buffer whose one blit fills another buffer
//! is committed and waited for.
//! 3. The row's reader ([`Way`]) is encoded into a command buffer, [`Content::Later`] is written
//! with no second name, and that command buffer is committed and waited for.
//!
//! The reader answers what it read ([`Way::reads`]), so the row's site is which of the three
//! contents it saw ([`Read`]). On an AMD Radeon Pro 5300M under macOS 26.7.1, 8 rounds each, the
//! readers that name the buffer (a compute slot, `useResource:`, a vertex slot with a draw, a blit
//! copy's source) read [`Content::Later`]: the range is taken at the first commit whose encoders
//! name the buffer, with its bytes as of that commit, and the commit of step 2 took nothing. A
//! reader that reaches the buffer through its address alone reads [`Content::Synced`], the bytes
//! the GPU's copy last took. An Intel UHD Graphics 630, which keeps one copy, read
//! [`Content::Later`] everywhere.
/// The bytes of the Managed buffer: 16 `float4` colours.
pub const LENGTH: usize = 256;
/// The `float4` elements the buffer holds.
pub const ELEMENTS: usize = LENGTH / 16;
/// The side of the render row's target, in texels.
pub const TARGET_SIDE: u32 = 4;
/// The three contents the sequence writes, each [`LENGTH`] bytes of one colour.
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum Content {
/// Written, named and taken first: opaque red.
Synced,
/// Written and named after it, before a commit that does not name the buffer: opaque green.
Named,
/// Written after the reader is encoded, with no second name: opaque blue.
Later,
}
impl Content {
/// The contents in the order the sequence writes them.
pub const ALL: [Content; 3] = [Content::Synced, Content::Named, Content::Later];
/// The colour every element holds.
pub const fn color(self) -> [f32; 4] {
match self {
Content::Synced => [1.0, 0.0, 0.0, 1.0],
Content::Named => [0.0, 1.0, 0.0, 1.0],
Content::Later => [0.0, 0.0, 1.0, 1.0],
}
}
/// The buffer's bytes.
pub fn bytes(self) -> Vec<u8> {
let element: Vec<u8> = self.color().iter().flat_map(|c| c.to_le_bytes()).collect();
element.repeat(ELEMENTS)
}
/// The word the row's site holds where the reader read this content.
pub const fn word(self) -> &'static str {
match self {
Content::Synced => "the bytes the GPU's copy last took",
Content::Named => "the bytes as the range was named",
Content::Later => "the bytes as of the reader's commit",
}
}
}
/// The reader of a row: how its command buffer reaches the Managed buffer.
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum Way {
/// `scale_and_offset` (`examples/runtime_examples`) with the buffer at its slot 0, scale 1:
/// its output is each element's word plus its index.
ComputeSlot,
/// `ab_address` (`ab_pointers`), the buffer's `gpuAddress` in a constant buffer at slot 0, the
/// buffer declared by `useResource:usage:` read: its output is the buffer's words.
Declared,
/// `ab_address` as [`Way::Declared`], the buffer named to no encoder.
Address,
/// `colored_vertex` and `colored_fragment` (`examples/runtime_examples`) with the buffer as
/// the colours at vertex slot 1, a triangle over the whole [`TARGET_SIDE`] square target
/// drawn: its target's texels, copied out by a blit.
VertexSlot,
/// A blit copy of the buffer's [`LENGTH`] bytes into a Shared buffer.
BlitSource,
}
impl Way {
/// The word a row's name and inputs carry.
pub const fn name(self) -> &'static str {
match self {
Way::ComputeSlot => "compute-slot",
Way::Declared => "declared",
Way::Address => "address",
Way::VertexSlot => "vertex-slot",
Way::BlitSource => "blit-source",
}
}
/// What the reader answers where the buffer holds `content`.
pub fn reads(self, content: Content) -> Vec<u8> {
match self {
Way::ComputeSlot => {
let bytes = content.bytes();
let (words, _) = bytes.as_chunks::<4>();
let floats = (words.iter().enumerate())
.map(|(index, word)| f32::from_le_bytes(*word) + index as f32);
floats.flat_map(f32::to_le_bytes).collect()
}
Way::Declared | Way::Address | Way::BlitSource => content.bytes(),
Way::VertexSlot => {
let texel = content.color().map(|c| (c * 255.0) as u8);
texel.repeat((TARGET_SIDE * TARGET_SIDE) as usize)
}
}
}
/// Which content `read` is, where it is one.
pub fn read(self, read: &[u8]) -> Read {
match Content::ALL.into_iter().find(|&c| self.reads(c) == read) {
Some(content) => Read::Content(content),
None => Read::Other,
}
}
}
/// What a row's reader read.
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum Read {
/// One of the three contents.
Content(Content),
/// None of them.
Other,
}
impl Read {
/// The word the row's site holds.
pub const fn word(self) -> &'static str {
match self {
Read::Content(content) => content.word(),
Read::Other => "none of the three contents",
}
}
}
/// The libraries a row's reader is made of, as the side made them.
#[derive(Clone, Copy, Debug)]
pub struct Libraries {
/// `examples/runtime_examples`: `scale_and_offset`, `colored_vertex`, `colored_fragment`.
pub examples: crate::case::Handle,
/// `ab_pointers`: `ab_address`.
pub pointers: crate::case::Handle,
}
#[cfg(test)]
mod tests {
use super::*;
/// Every reader tells the three contents apart.
#[test]
fn every_reader_tells_the_contents_apart() {
for way in [
Way::ComputeSlot,
Way::Declared,
Way::Address,
Way::VertexSlot,
Way::BlitSource,
] {
for content in Content::ALL {
assert_eq!(way.read(&way.reads(content)), Read::Content(content));
}
assert_eq!(way.read(&[]), Read::Other, "{way:?}");
}
}
}
@@ -2051,6 +2051,33 @@ fn linked_counts(linked: &Retained<MTLLinkedFunctions>) -> LinkedCounts {
}
}
/// Every tessellation field of `state` on `descriptor`.
fn set_tessellation(
descriptor: &MTLRenderPipelineDescriptor,
state: &crate::render::TessellationState,
) {
// SAFETY: each value is an enumerator of the SDK's own table or, for the factor, a count the
// case keeps inside `MTLDevice`'s documented 1..=64, and the descriptor is the caller's own.
// The three setters `objc2` marks unsafe take a raw `NSUInteger`.
unsafe {
descriptor.setMaxTessellationFactor(state.max_factor as usize);
descriptor.setTessellationPartitionMode(MTLTessellationPartitionMode(
state.partition.as_raw() as usize,
));
descriptor.setTessellationControlPointIndexType(MTLTessellationControlPointIndexType(
state.control_point_index_type.as_raw() as usize,
));
}
descriptor.setTessellationFactorFormat(MTLTessellationFactorFormat(
state.factor_format.as_raw() as usize,
));
descriptor.setTessellationFactorStepFunction(MTLTessellationFactorStepFunction(
state.factor_step.as_raw() as usize,
));
descriptor.setTessellationOutputWindingOrder(MTLWinding(state.winding.as_raw() as usize));
descriptor.setTessellationFactorScaleEnabled(state.factor_scale_enabled);
}
/// Metal's vertex descriptor for `layout`. The case's enumerations are Metal's own, so each one
/// crosses as its raw value.
fn vertex_descriptor(layout: &crate::render::VertexLayout<'_>) -> Retained<MTLVertexDescriptor> {
@@ -4603,6 +4630,15 @@ impl Side for MetalSide {
descriptor.setFragmentFunction(fragment);
descriptor.setRasterizationEnabled(fragment.is_some());
descriptor.setSupportIndirectCommandBuffers(fragment.is_some());
// The commands' state takes the run's vertex descriptor and tessellation state.
if fragment.is_some() {
if let Some(state) = &run.tessellation {
set_tessellation(&descriptor, state);
}
if let Some(layout) = &run.vertex_layout {
descriptor.setVertexDescriptor(Some(&vertex_descriptor(layout)));
}
}
// SAFETY: attachment 0 is inside the eight every Metal pipeline descriptor holds.
let attachment =
unsafe { descriptor.colorAttachments().objectAtIndexedSubscript(0) };
@@ -4631,7 +4667,9 @@ impl Side for MetalSide {
}
};
let descriptor = MTLIndirectCommandBufferDescriptor::new();
descriptor.setCommandTypes(MTLIndirectCommandType::DrawIndexed);
descriptor.setCommandTypes(MTLIndirectCommandType::from_bits_retain(
run.command_types.as_raw() as usize,
));
descriptor.setInheritPipelineState(true);
descriptor.setInheritBuffers(false);
descriptor.setMaxVertexBufferBindCount(run.bind_counts[0] as usize);
@@ -8567,29 +8605,7 @@ impl MetalSide {
// tessellation state leaves Metal's own defaults alone, which is what every other family's
// pipeline has always been made with.
if let Some(state) = &spec.tessellation {
// SAFETY: each value is an enumerator of the SDK's own table or, for the factor, a
// count the case keeps inside `MTLDevice`'s documented 1..=64, and the descriptor is
// this call's own. The three setters `objc2` marks unsafe take a raw `NSUInteger`.
unsafe {
descriptor.setMaxTessellationFactor(state.max_factor as usize);
descriptor.setTessellationPartitionMode(MTLTessellationPartitionMode(
state.partition.as_raw() as usize,
));
descriptor.setTessellationControlPointIndexType(
MTLTessellationControlPointIndexType(
state.control_point_index_type.as_raw() as usize
),
);
}
descriptor.setTessellationFactorFormat(MTLTessellationFactorFormat(
state.factor_format.as_raw() as usize,
));
descriptor.setTessellationFactorStepFunction(MTLTessellationFactorStepFunction(
state.factor_step.as_raw() as usize,
));
descriptor
.setTessellationOutputWindingOrder(MTLWinding(state.winding.as_raw() as usize));
descriptor.setTessellationFactorScaleEnabled(state.factor_scale_enabled);
set_tessellation(&descriptor, state);
}
if let Some(layout) = &spec.vertex_layout {
descriptor.setVertexDescriptor(Some(&vertex_descriptor(layout)));
@@ -10792,6 +10808,9 @@ impl MetalSide {
);
}
}
ComputeStep::DispatchThreads { grid, threads } => {
encoder.dispatchThreads_threadsPerThreadgroup(size(*grid), size(*threads));
}
}
Ok(())
}
+22 -15
View File
@@ -93,7 +93,7 @@ pub fn record(
reason: reason.to_owned(),
});
}
check_host()?;
check_host(&*side)?;
let inputs = case.inputs().map_err(|why| RecordError::Case {
case: case.name().to_owned(),
why,
@@ -213,21 +213,12 @@ fn add(outcomes: &mut Vec<Outcome>, transcript: Transcript) {
}
}
/// Refuse to record on a host that is not the oracle the suite names.
/// Refuse to record on a host that is not the oracle the suite names: `side`'s macOS release and
/// build ([`Side::macos_release`]).
#[cfg(target_os = "macos")]
fn check_host() -> Result<(), RecordError> {
let read = |flag: &str| {
std::process::Command::new("/usr/bin/sw_vers")
.arg(flag)
.output()
.ok()
.filter(|output| output.status.success())
.map(|output| String::from_utf8_lossy(&output.stdout).trim().to_owned())
.unwrap_or_default()
};
fn check_host(side: &dyn Side) -> Result<(), RecordError> {
use crate::recording::{ORACLE_CHIP, ORACLE_OS_BUILD, ORACLE_OS_VERSION};
let version = read("-productVersion");
let build = read("-buildVersion");
let (version, build) = side.macos_release();
if version == ORACLE_OS_VERSION && build == ORACLE_OS_BUILD {
return Ok(());
}
@@ -237,8 +228,24 @@ fn check_host() -> Result<(), RecordError> {
})
}
/// This host's macOS release and build, as `sw_vers -productVersion` and `-buildVersion` answer
/// them; each empty where it does not answer.
#[cfg(target_os = "macos")]
pub(crate) fn sw_vers() -> (String, String) {
let read = |flag: &str| {
std::process::Command::new("/usr/bin/sw_vers")
.arg(flag)
.output()
.ok()
.filter(|output| output.status.success())
.map(|output| String::from_utf8_lossy(&output.stdout).trim().to_owned())
.unwrap_or_default()
};
(read("-productVersion"), read("-buildVersion"))
}
/// There is no Metal to record from off macOS.
#[cfg(not(target_os = "macos"))]
fn check_host() -> Result<(), RecordError> {
fn check_host(_side: &dyn Side) -> Result<(), RecordError> {
Err(RecordError::NoMetal)
}
@@ -43,6 +43,12 @@ pub const ORACLE_CHIP: &str = "apple-m3-max";
/// recordings say which chip they came from rather than implying the oracle's.
pub const APPLE_M4: &str = "apple-m4";
/// The discrete Mac GPU two families' carried answers were measured on: the Managed-buffer family's
/// table ([`crate::cases::managed_naming`]), as the oracle keeps one copy of a Managed buffer and
/// this one two, and the sample positions family's rows at 8 samples
/// ([`crate::cases::sample_positions`]), as the oracle renders no 8 samples and this one does.
pub const AMD_RADEON_PRO_5300M: &str = "amd-radeon-pro-5300m";
/// The macOS release this round records on, as macOS names it.
pub const ORACLE_OS_VERSION: &str = "27.0.1";
@@ -452,7 +452,9 @@ pub fn reads_opaque_black_border(spec: &crate::case::SamplerSpec) -> bool {
/// - **maths**: the native-maths class (`native-transcendentals`, `native-division`, `native-fma`,
/// `native-dot`, `native-mix`, `native-min-max`, `native-nan-encoding`), the device's functions
/// and precision bounds (`device-transcendentals`, `device-arithmetic`), the device's denormals
/// and NaN bits (`device-denormals`, `device-nan-encoding`), and the device's compiler's grouping
/// and NaN bits (`device-denormals`, `device-nan-encoding`), the device's half denormals where
/// it computes `half` under the 16-bit float controls without `DenormPreserve` for 16 bits, the
/// one form built there (`device-half-denormals`), and the device's compiler's grouping
/// and fusion of the fast-math arithmetic the AIR's flags let it rewrite (`fast-math-rewrites`:
/// the module states each operation in the AIR's order and reproduces no grouping of Metal's);
/// - **rounding**: the native-half class (`native-half-conversion`, `native-half-quantize`), and
@@ -477,8 +479,8 @@ pub fn reads_opaque_black_border(spec: &crate::case::SamplerSpec) -> bool {
/// visibility result (`device-occlusion-count`), announced by every such mode set.
///
/// **What is not here**, and stays each case's to declare: a note of what the device **lacks**
/// (`device-signed-zero-inf-nan`, `device-anisotropic-filter`, `device-point-size`,
/// `restricted-depth-range`, `restricted-depth-upload`), of an emulation's own precision (`grad-from-bias`,
/// (`device-signed-zero-inf-nan`, `device-point-size`, `restricted-depth-range`,
/// `restricted-depth-upload`), of an emulation's own precision (`grad-from-bias`,
/// `pixel-sampler-scaling`, `bicubic-filter-arithmetic`), of a Metal form not measured or not built
/// (`blended-write-rounding`, `device-interpolation`, `reduction-order`), a native answer whose
/// catalogue entry states the bound the cases that read it hold it to (the device's decode of a
@@ -505,6 +507,7 @@ pub const NATIVE_NOTES: &[crate::degradation::Degradation] = {
D::DeviceTranscendentals,
D::DeviceArithmetic,
D::DeviceDenormals,
D::DeviceHalfDenormals,
D::DeviceNanEncoding,
D::FastMathRewrites,
D::NativeHalfConversion,
+94 -12
View File
@@ -20,8 +20,9 @@
//! block-compressed format ([`metal2vulkan_runtime::Texture::precision_note`]) and a sampler state that
//! reads an opaque-black border ([`metal2vulkan_runtime::SamplerState::precision_note`]). This side
//! announces the notes of each state its case dispatched or drew with, of each texture and
//! sampler state it made, and of each upload into a 32-bit float depth (`upload_note`), by the
//! codes the suite's allowances name (`metal2vulkan-degrade-<kind>`).
//! sampler state it made, and of each upload into a 32-bit float depth or a multisample texture's
//! 16-bit depth (`upload_note`), by the codes the suite's allowances name
//! (`metal2vulkan-degrade-<kind>`).
use crate::case::{
Answer, ArgumentSlot, Bindings, Failure, Handle, SamplerSpec, ShaderSource, Side,
@@ -50,6 +51,7 @@ mod fences;
pub(crate) mod fields;
mod functions;
mod heap_sizes;
mod managed_naming;
mod render;
mod state_facts;
mod states;
@@ -206,11 +208,14 @@ impl RtDevice {
}
/// The next texture index ([`RtDevice::next_index`]) for a texture of `pf` and `usage` where a
/// shader reaches it (shader read or write, no bit, which the runtime takes as every usage, or
/// a colour render target, which a fragment function reads through its attachment), and
/// `None` where none does, as the runtime's texture makers take an index.
/// shader reaches it (shader read or write, the private bit `BlockWritesOnly`, which the
/// runtime takes as a write, no bit, which it takes as every usage, or a colour render target,
/// which a fragment function reads through its attachment), and `None` where none does, as the
/// runtime's texture makers take an index.
fn texture_index(&self, pf: rt::PixelFormat, usage: rt::TextureUsage) -> Option<u32> {
let reached = rt::TextureUsage::SHADER_READ | rt::TextureUsage::SHADER_WRITE;
let reached = rt::TextureUsage::SHADER_READ
| rt::TextureUsage::SHADER_WRITE
| rt::TextureUsage::BLOCK_WRITES_ONLY;
let color_target = usage.contains(rt::TextureUsage::RENDER_TARGET)
&& !metal2vulkan::metal::format::is_depth_stencil(pf);
(usage.is_empty() || usage.intersects(reached) || color_target)
@@ -357,6 +362,9 @@ pub struct RtSide<'a> {
/// Each buffer, with the block it lies in, which it alone takes.
buffers: Vec<(rt::Buffer, rt::Block)>,
textures: Vec<rt::Texture>,
/// The textures of [`textures`](Self::textures) that are shareable: each the shared creator
/// made ([`Side::shared_texture`]), and each a handle opened ([`Side::shared_texture_handle`]).
shareable: BTreeSet<u32>,
command_buffers: Vec<rt::CommandBuffer>,
samplers: Vec<rt::SamplerState>,
render_pipelines: Vec<rt::RenderPipelineState>,
@@ -393,6 +401,7 @@ impl<'a> RtSide<'a> {
pipelines: Vec::new(),
buffers: Vec::new(),
textures: Vec::new(),
shareable: BTreeSet::new(),
command_buffers: Vec::new(),
samplers: Vec::new(),
render_pipelines: Vec::new(),
@@ -519,9 +528,14 @@ impl<'a> RtSide<'a> {
/// The static note of an upload into `texture` of `option`, where it reaches a 32-bit float depth:
/// `Depth32Float`'s, or `Depth32Float_Stencil8`'s under its depth option
/// ([`rt::Texture::FLOAT_DEPTH_UPLOAD_NOTE`]).
/// ([`rt::Texture::FLOAT_DEPTH_UPLOAD_NOTE`]); or the 16-bit depth of a multisample texture, which
/// the runtime's own draw writes ([`rt::Texture::SAMPLE_DEPTH_COPY_NOTE`]).
fn upload_note(texture: &rt::Texture, option: rt::BlitOption) -> Option<rt::PrecisionNote> {
let pixel_format = texture.descriptor().pixel_format;
let d = texture.descriptor();
let pixel_format = d.pixel_format;
if pixel_format == PixelFormat::Depth16Unorm && d.sample_count > 1 {
return Some(rt::Texture::SAMPLE_DEPTH_COPY_NOTE);
}
let depth = pixel_format == PixelFormat::Depth32Float
|| (pixel_format == PixelFormat::Depth32FloatStencil8
&& option == rt::BlitOption::DepthFromDepthStencil);
@@ -1118,11 +1132,11 @@ impl Side for RtSide<'_> {
Ok(self.keep_texture(view))
}
/// The view's shape and swizzle, read of its descriptor; its parent's facts are the
/// consumer's own
/// The view's shape and swizzle, read of its descriptor; its parent's facts and `shareable` are
/// the consumer's own
/// ([`ConsumerObject::TextureViewParents`](crate::known_gaps::ConsumerObject::TextureViewParents)):
/// the runtime's view keeps the texture whose image it reads and no getter, and makes no
/// shareable texture.
/// the runtime's view keeps the texture whose image it reads and no getter, and the consumer
/// keeps what it shared.
fn texture_view_facts(
&mut self,
texture: Handle,
@@ -1145,6 +1159,66 @@ impl Side for RtSide<'_> {
})
}
/// `newSharedTextureWithDescriptor:` as the runtime's consumer answers it on the runtime's one
/// device, which every guest process shares: the texture `newTextureWithDescriptor:` makes,
/// kept as shareable. Metal answers nil outside `Private` storage and for a format it makes no
/// texture of from a descriptor alone
/// ([`WITHOUT_TEXTURES`](crate::texture_query::WITHOUT_TEXTURES)), measured on an Apple M3 Max
/// (`shared-creator-padded-format-storage`, `shared-creator-extended-range-samples`), and so
/// does this.
fn shared_texture(&mut self, query: &crate::texture_query::HeapTextureQuery) -> Answer<Handle> {
let unshared = query.storage != crate::texture_query::Storage::Private;
if unshared || crate::texture_query::WITHOUT_TEXTURES.contains(&query.format) {
return Err(Failure::named(
"Nil",
format!(
"newSharedTextureWithDescriptor: answers nil for {}",
query.site()
),
));
}
let descriptor = queried(query);
let index = (self.on).texture_index(descriptor.pixel_format, descriptor.usage);
let texture = (self.on.device.new_texture(&descriptor, index))
.map_err(|error| Failure::of_rt(&error))?;
let shared = self.keep_texture(texture);
self.shareable.insert(shared.0);
Ok(shared)
}
/// `newSharedTextureHandle` and `newSharedTextureWithHandle:` as the runtime's consumer
/// answers them on the runtime's one device: the handle is the consumer's own, of that device,
/// and the texture it opens is a clone of the same `Texture`, shareable as its texture is. A
/// texture that is not shareable answers nil, as the cases model Metal (they never ask one).
fn shared_texture_handle(
&mut self,
texture: Handle,
) -> Answer<crate::texture_views::SharedHandleFacts> {
if !self.shareable.contains(&texture.0) {
return Err(Failure::named(
"Nil",
format!(
"newSharedTextureHandle of texture {}, which is not shareable",
texture.0
),
));
}
let opened = self.held_texture(texture)?.clone();
let d = opened.descriptor();
let facts = crate::texture_views::SharedHandleFacts {
own_device: true,
opens: true,
opened_shareable: true,
opened_width: d.width.into(),
opened_height: d.height.into(),
opened_levels: d.mipmap_level_count.into(),
};
// Kept as the Metal side keeps the texture it opened.
let held = keep(&mut self.textures, opened);
self.shareable.insert(held.0);
Ok(facts)
}
fn dispatch(
&mut self,
pipeline: Handle,
@@ -1809,6 +1883,14 @@ impl Side for RtSide<'_> {
Ok(keep(&mut self.textures, texture))
}
fn managed_naming(
&mut self,
way: crate::managed_naming::Way,
libraries: crate::managed_naming::Libraries,
) -> Answer<Vec<u8>> {
self.managed_naming_run(way, libraries)
}
fn empty_command_buffers(&mut self) -> Answer<EmptyCommandBuffers> {
let of_rt = |error: rt::Error| Failure::of_rt(&error);
let order: Arc<Mutex<Vec<String>>> = Arc::default();
@@ -173,15 +173,55 @@ impl RtSide<'_> {
*threads,
))
.map_err(of_rt),
// The attribute-stride setters, the stage-in region and heaps: the runtime has no
// counterpart yet.
ComputeStep::BufferWithStride { .. }
| ComputeStep::BuffersWithStrides { .. }
| ComputeStep::BufferOffsetWithStride { .. }
| ComputeStep::BytesWithStride { .. }
| ComputeStep::StageInRegion { .. }
| ComputeStep::UseHeap { .. }
| ComputeStep::UseHeaps { .. } => Err(Failure::unavailable(step.call())),
ComputeStep::DispatchThreads { grid, threads } => {
(encoder.dispatch_threads(*grid, *threads)).map_err(of_rt)
}
ComputeStep::BufferWithStride {
buffer,
offset,
stride,
index,
} => (encoder.set_buffer_with_attribute_stride(
Some(self.held(*buffer)?),
*offset,
*stride,
*index,
))
.map_err(of_rt),
ComputeStep::BuffersWithStrides { buffers, first } => {
for (at, (buffer, offset, stride)) in (*first..).zip(buffers) {
(encoder.set_buffer_with_attribute_stride(
Some(self.held(*buffer)?),
*offset,
*stride,
at,
))
.map_err(of_rt)?;
}
Ok(())
}
ComputeStep::BufferOffsetWithStride {
offset,
stride,
index,
} => (encoder.set_buffer_offset_with_attribute_stride(*offset, *stride, *index))
.map_err(of_rt),
ComputeStep::BytesWithStride {
bytes,
stride,
index,
} => (encoder.set_bytes_with_attribute_stride(bytes, *stride, *index)).map_err(of_rt),
ComputeStep::StageInRegion { origin, size } => {
encoder.set_stage_in_region(rt::Region {
origin: *origin,
size: *size,
});
Ok(())
}
// Heaps: the runtime has no counterpart yet.
ComputeStep::UseHeap { .. } | ComputeStep::UseHeaps { .. } => {
Err(Failure::unavailable(step.call()))
}
}
}
@@ -76,7 +76,7 @@ pub(crate) fn pipeline_fields(spec: &RenderPipelineSpec<'_>) -> Answer<PipelineF
/// The runtime's `TessellationDescriptor` for `state`: every field the case names, since the
/// vocabulary is Metal's own and there is no second spelling to keep in step.
fn tessellation_descriptor(
pub(crate) fn tessellation_descriptor(
state: &crate::render::TessellationState,
) -> metal2vulkan::pipeline::TessellationDescriptor {
let mut descriptor = metal2vulkan::pipeline::TessellationDescriptor::default();
@@ -92,7 +92,7 @@ fn tessellation_descriptor(
/// The runtime's vertex descriptor for `layout`: the same attribute indices, buffer indices and
/// step functions the case states, so both sides fetch the same way.
fn vertex_descriptor(layout: &crate::render::VertexLayout<'_>) -> VertexDescriptor {
pub(crate) fn vertex_descriptor(layout: &crate::render::VertexLayout<'_>) -> VertexDescriptor {
let mut descriptor = VertexDescriptor::new();
for attribute in layout.attributes {
descriptor.attributes.insert(
@@ -7,18 +7,20 @@
//! places by before it answers it, and answers the failure where it does not hold:
//!
//! 1. the alignment is a power of two, for every query;
//! 2. for a Private query, a heap of `align + size` bytes takes a texture of the descriptor at
//! offset `align`;
//! 2. for a Private or Shared query, a heap of its storage mode, `align + size` bytes, takes a
//! texture of the descriptor at offset `align` (a Shared one on a device without unified
//! memory, as an image of its own, and on one with it where the device's image of it takes
//! the Shared memory type; it is held to the first alone where the placement is
//! `Gap::HeapTexture`);
//! 3. there, where the runtime moves the format's bytes, level 0's first slice written from a
//! buffer reads back unchanged: a `Depth32Float` slice's bytes are depths within `[0, 1]`, the
//! only ones a copy into a depth aspect keeps on every device
//! (`Texture::FLOAT_DEPTH_UPLOAD_NOTE`), and any other's a pattern of bytes.
//!
//! A Shared, Managed or Memoryless query is held to the first alone: the runtime places a heap
//! texture in a Private block only (`Gap::HeapTexture`), and placing the descriptor in a Private
//! heap would answer another query. A query whose bytes the runtime does not move, which its copy
//! answers `Gap::TextureBytes` (depth and stencil both, or multisample) for, is held to the first
//! two.
//! A Managed or Memoryless query is held to the first alone: no heap of either mode is made, and
//! placing the descriptor in a heap of another mode would answer another query. A query whose
//! bytes the runtime does not move, which its copy answers `Gap::TextureBytes` (depth and stencil
//! both, or multisample) for, is held to the first two.
use super::{waited_for, work, RtDevice, WAIT};
use crate::case::{Answer, Failure};
@@ -41,7 +43,7 @@ pub(super) fn hold(
format!("step 1: the alignment {align} is not a power of two"),
));
}
if query.storage != Storage::Private {
if !matches!(query.storage, Storage::Private | Storage::Shared) {
return Ok(());
}
let heap_size = align.checked_add(size).ok_or_else(|| {
@@ -50,10 +52,19 @@ pub(super) fn hold(
format!("step 2: a heap of {align} + {size} bytes"),
)
})?;
let (_block, heap) = work::heap_of(on, heap_size, Storage::Private)?;
let (_block, heap) = work::heap_of(on, heap_size, query.storage)?;
let index = on.texture_index(descriptor.pixel_format, descriptor.usage);
let texture = (on.device.new_heap_texture(descriptor, index, heap, align))
.map_err(|error| on.failure(&error))?;
let texture = match on.device.new_heap_texture(descriptor, index, heap, align) {
Ok(texture) => texture,
// A device with unified memory whose image of the descriptor takes no Shared memory type
// sizes it, and places none of it in a Shared heap: the answer is held to step 1 there.
Err(rt::Error::Unsupported(rt::Gap::HeapTexture { .. }))
if query.storage == Storage::Shared =>
{
return Ok(());
}
Err(error) => return Err(on.failure(&error)),
};
round_trip(on, queue, descriptor, &texture)
}
@@ -0,0 +1,246 @@
//! The runtime's side of [`crate::managed_naming`]: the sequence through the runtime's
//! Metal-shaped API, its Managed buffer in the form the device's memory-type query picks
//! (`Device::has_unified_memory`).
use super::work::{read_buffer, write};
use super::{waited_for, RtSide, WAIT};
use crate::case::{Answer, Failure};
use crate::managed_naming::{Content, Libraries, Way, LENGTH, TARGET_SIDE};
use metal2vulkan::metal::PixelFormat;
use metal2vulkan_runtime as rt;
/// What the venue lacks for a reader that reaches the buffer through its address alone, on a
/// device that keeps one copy of a Managed buffer.
const ONE_COPY: &str = "a device copy of each Managed buffer (Device::has_unified_memory false): \
with one copy a reader through the address reads the buffer's own bytes";
impl RtSide<'_> {
/// [`crate::case::Side::managed_naming`] on the runtime.
pub(super) fn managed_naming_run(&mut self, way: Way, libraries: Libraries) -> Answer<Vec<u8>> {
let on = self.on;
let device = &on.device;
let of_rt = |error: rt::Error| on.failure(&error);
let two = !device.has_unified_memory();
if way == Way::Address && !two {
let mut failure = Failure::named("OneCopy", ONE_COPY);
failure.lacks = Some(ONE_COPY.to_owned());
return Err(failure);
}
let length = LENGTH as u64;
let shared = |length: u64| -> Answer<(rt::Buffer, rt::Block)> {
let block = (device.take_block(rt::MemoryClass::Shared, length)).map_err(of_rt)?;
let buffer = (device.new_buffer(block.id, 0, length, Some(0))).map_err(of_rt)?;
Ok((buffer, block))
};
let bytes = (device.take_block(rt::MemoryClass::Shared, length)).map_err(of_rt)?;
let copy = match two {
true => Some((device.take_block(rt::MemoryClass::Private, length)).map_err(of_rt)?),
false => None,
};
let at = |block: &rt::Block| (block.id, 0);
let managed = (device.new_managed_buffer(at(&bytes), copy.as_ref().map(at), length, 0))
.map_err(of_rt)?;
let (scratch, scratch_block) = shared(length)?;
let (out, out_block) = shared(length)?;
let queue = (device.new_command_queue(4)).map_err(of_rt)?;
let run = |command_buffer: &rt::CommandBuffer| -> Answer<()> {
command_buffer.commit().map_err(of_rt)?;
match waited_for(command_buffer, WAIT) {
Some(_) => match command_buffer.error() {
None => Ok(()),
Some(error) => Err(Failure::named("CommandBufferError", format!("{error:?}"))),
},
None => Err(Failure::named(
"NeverCompleted",
"a command buffer of the sequence",
)),
}
};
let blit = |source: &rt::Buffer, destination: &rt::Buffer| -> Answer<()> {
let command_buffer = queue.command_buffer().map_err(of_rt)?;
let mut blit = command_buffer.blit_command_encoder().map_err(of_rt)?;
(blit.copy_from_buffer_to_buffer(source, 0, destination, 0, length)).map_err(of_rt)?;
blit.end_encoding();
run(&command_buffer)
};
// 1. Synced: written, named, and taken by a blit that copies the buffer.
write(&managed, &Content::Synced.bytes())?;
(managed.did_modify_range(0, length)).map_err(of_rt)?;
blit(&managed, &scratch)?;
// 2. Named: written and named; a commit whose one blit fills another buffer.
write(&managed, &Content::Named.bytes())?;
(managed.did_modify_range(0, length)).map_err(of_rt)?;
let elsewhere = queue.command_buffer().map_err(of_rt)?;
let mut fill = elsewhere.blit_command_encoder().map_err(of_rt)?;
(fill.fill_buffer(&scratch, 0..length, 0)).map_err(of_rt)?;
fill.end_encoding();
run(&elsewhere)?;
// 3. The reader encoded, Later written with no second name, its commit.
let reader = queue.command_buffer().map_err(of_rt)?;
// The reader's own buffers' blocks, given back once it completed.
let mut blocks = vec![bytes, scratch_block, out_block];
blocks.extend(copy);
let held = match way {
Way::ComputeSlot => {
self.slot_reader(&reader, libraries, &managed, &out)?;
None
}
Way::Declared | Way::Address => {
let (address, block) =
self.address_reader(&reader, way, libraries, &managed, &out)?;
blocks.push(block);
Some(address)
}
Way::VertexSlot => {
let (positions, block) = self.vertex_reader(&reader, libraries, &managed, &out)?;
blocks.push(block);
Some(positions)
}
Way::BlitSource => {
let mut blit = reader.blit_command_encoder().map_err(of_rt)?;
(blit.copy_from_buffer_to_buffer(&managed, 0, &out, 0, length)).map_err(of_rt)?;
blit.end_encoding();
None
}
};
write(&managed, &Content::Later.bytes())?;
run(&reader)?;
let read = match way {
Way::VertexSlot => (TARGET_SIDE * TARGET_SIDE * 4) as usize,
_ => LENGTH,
};
let read = read_buffer(&out, 0, read)?;
drop((held, reader, elsewhere, queue, managed, scratch, out));
for block in blocks {
device.release_block(block).map_err(of_rt)?;
}
Ok(read)
}
/// `scale_and_offset` over `managed` at slot 0 into `out` at slot 1, scale 1, one thread an
/// element's word.
fn slot_reader(
&mut self,
reader: &rt::CommandBuffer,
libraries: Libraries,
managed: &rt::Buffer,
out: &rt::Buffer,
) -> Answer<()> {
let on = self.on;
let of_rt = |error: rt::Error| on.failure(&error);
let state = self.compute_state(libraries.examples, "scale_and_offset")?;
let mut encoder =
(reader.compute_command_encoder(rt::DispatchType::Serial)).map_err(of_rt)?;
encoder.set_compute_pipeline_state(&state).map_err(of_rt)?;
encoder.set_buffer(Some(managed), 0, 0).map_err(of_rt)?;
encoder.set_buffer(Some(out), 0, 1).map_err(of_rt)?;
(encoder.set_bytes(&1.0f32.to_le_bytes(), 2)).map_err(of_rt)?;
let words = (LENGTH / 4) as u32;
(encoder.dispatch_threads([words, 1, 1], [words, 1, 1])).map_err(of_rt)?;
encoder.end_encoding();
Ok(())
}
/// `ab_address` reading `managed` through its address, which a Shared buffer at slot 0 holds,
/// into `out` at slot 1; `managed` declared by `use_resource` where `way` is
/// [`Way::Declared`]. Answers the buffer that holds the address, which the reader needs until
/// it completes.
fn address_reader(
&mut self,
reader: &rt::CommandBuffer,
way: Way,
libraries: Libraries,
managed: &rt::Buffer,
out: &rt::Buffer,
) -> Answer<(rt::Buffer, rt::Block)> {
let on = self.on;
let of_rt = |error: rt::Error| on.failure(&error);
let state = self.compute_state(libraries.pointers, "ab_address")?;
let block = (on.device.take_block(rt::MemoryClass::Shared, 8)).map_err(of_rt)?;
let address = (on.device.new_buffer(block.id, 0, 8, Some(0))).map_err(of_rt)?;
write(&address, &managed.gpu_address().to_le_bytes())?;
let mut encoder =
(reader.compute_command_encoder(rt::DispatchType::Serial)).map_err(of_rt)?;
encoder.set_compute_pipeline_state(&state).map_err(of_rt)?;
encoder.set_buffer(Some(&address), 0, 0).map_err(of_rt)?;
encoder.set_buffer(Some(out), 0, 1).map_err(of_rt)?;
if way == Way::Declared {
let read = rt::ResourceUsage::READ;
(encoder.use_resource(rt::Resource::Buffer(managed), read)).map_err(of_rt)?;
}
let words = (LENGTH / 4) as u32;
(encoder.dispatch_threads([words, 1, 1], [words, 1, 1])).map_err(of_rt)?;
encoder.end_encoding();
Ok((address, block))
}
/// `colored_vertex` and `colored_fragment` drawing one triangle over the whole target, its
/// colours `managed` at vertex slot 1, then a blit of the target's texels into `out`. Answers
/// the positions' buffer and the target, which the reader needs until it completes.
fn vertex_reader(
&mut self,
reader: &rt::CommandBuffer,
libraries: Libraries,
managed: &rt::Buffer,
out: &rt::Buffer,
) -> Answer<(rt::Buffer, rt::Block)> {
let on = self.on;
let of_rt = |error: rt::Error| on.failure(&error);
let mut d =
rt::RenderPipelineDescriptor::new(self.kernel(libraries.examples, "colored_vertex")?);
d.fragment = Some(self.kernel(libraries.examples, "colored_fragment")?);
d.color_attachments[0] = Some(rt::ColorAttachmentDescriptor::new(PixelFormat::RGBA8Unorm));
let state = (on.device)
.new_render_pipeline_state(&d, |samplers| Ok(on.sampler_ids(samplers)))
.map_err(of_rt)?;
let mut t = rt::TextureDescriptor::new(
rt::TextureType::Type2D,
PixelFormat::RGBA8Unorm,
TARGET_SIDE,
TARGET_SIDE,
);
t.usage = rt::TextureUsage::RENDER_TARGET;
let index = on.texture_index(PixelFormat::RGBA8Unorm, t.usage);
let target = (on.device.new_texture(&t, index)).map_err(of_rt)?;
let corners: [f32; 6] = [-1.0, -1.0, 3.0, -1.0, -1.0, 3.0];
let block = (on.device.take_block(rt::MemoryClass::Shared, 24)).map_err(of_rt)?;
let positions = (on.device.new_buffer(block.id, 0, 24, Some(0))).map_err(of_rt)?;
let corners: Vec<u8> = corners.iter().flat_map(|c| c.to_le_bytes()).collect();
write(&positions, &corners)?;
let mut pass = rt::RenderPassDescriptor::default();
let color = &mut pass.color_attachments[0];
color.texture = Some(target.clone());
color.load_action = rt::LoadAction::Clear;
let mut encoder = (reader.render_command_encoder(&pass)).map_err(of_rt)?;
encoder.set_render_pipeline_state(&state).map_err(of_rt)?;
(encoder.set_vertex_buffer(Some(&positions), 0, 0)).map_err(of_rt)?;
(encoder.set_vertex_buffer(Some(managed), 0, 1)).map_err(of_rt)?;
(encoder.draw_primitives(rt::PrimitiveType::Triangle, 0, 3, 1, 0)).map_err(of_rt)?;
encoder.end_encoding();
let mut blit = reader.blit_command_encoder().map_err(of_rt)?;
let layout = rt::BufferLayout {
offset: 0,
bytes_per_row: u64::from(TARGET_SIDE) * 4,
bytes_per_image: 0,
};
let size = [TARGET_SIDE, TARGET_SIDE, 1];
let place = rt::TexturePlace::default();
(blit.copy_from_texture_to_buffer(&target, place, size, out, layout)).map_err(of_rt)?;
blit.end_encoding();
Ok((positions, block))
}
/// The compute pipeline state of `entry` of library `library`.
fn compute_state(
&mut self,
library: crate::case::Handle,
entry: &str,
) -> Answer<rt::ComputePipelineState> {
let descriptor = rt::ComputePipelineDescriptor::new(self.kernel(library, entry)?);
let on = self.on;
(on.device)
.new_compute_pipeline_state(&descriptor, |samplers| Ok(on.sampler_ids(samplers)))
.map_err(|error| on.failure(&error))
}
}
@@ -456,9 +456,9 @@ impl RtSide<'_> {
VisibilityResultType::Reset => rt::VisibilityResultType::Reset,
VisibilityResultType::Accumulate => rt::VisibilityResultType::Accumulate,
};
if !pass.positions.is_empty() {
return Err(Failure::unavailable("setSamplePositions:count:"));
}
descriptor.sample_positions = (pass.positions.iter())
.map(|p| rt::SamplePosition::new(p.x, p.y))
.collect();
let mut encoder = (command_buffer.render_command_encoder(&descriptor)).map_err(of_rt)?;
let encoded = (pass.steps.iter()).try_for_each(|step| self.step(&mut encoder, step));
encoder.end_encoding();
@@ -773,6 +773,35 @@ impl RtSide<'_> {
))
.map_err(of_rt)
}
RenderStep::DrawIndexedPatches {
control_points,
first,
count,
patch_indices,
patch_index_offset,
control_point_indices,
control_point_index_offset,
instances,
base_instance,
} => {
let patches = match patch_indices {
Some(held) => Some((buffer(*held)?, *patch_index_offset)),
None => None,
};
let indices = rt::PatchIndexBuffers {
patches,
control_points: (buffer(*control_point_indices)?, *control_point_index_offset),
};
(encoder.draw_indexed_patches(
*control_points,
*first,
*count,
indices,
*instances,
*base_instance,
))
.map_err(of_rt)
}
// The scope and the stages only narrow what Metal orders: the runtime's barrier orders
// every access of the encoder's draws so far before its later ones.
RenderStep::BarrierScope { .. } => encoder.memory_barrier().map_err(of_rt),
@@ -199,6 +199,13 @@ impl RtSide<'_> {
descriptor.rasterization_enabled = rasterizes;
descriptor.support_indirect_command_buffers = rasterizes;
descriptor.color_attachments[0] = Some(rt::ColorAttachmentDescriptor::new(run.format));
// The commands' state takes the run's vertex descriptor and tessellation state.
if rasterizes {
descriptor.vertex_descriptor =
(run.vertex_layout.as_ref()).map(super::fields::vertex_descriptor);
descriptor.tessellation =
(run.tessellation.as_ref()).map(super::fields::tessellation_descriptor);
}
(on.device)
.new_render_pipeline_state(&descriptor, |samplers| Ok(on.sampler_ids(samplers)))
.map_err(|error| on.failure(&error))
@@ -224,7 +231,8 @@ impl RtSide<'_> {
),
};
let mut descriptor = rt::IndirectCommandBufferDescriptor::new();
descriptor.command_types = rt::IndirectCommandType::DRAW_INDEXED;
descriptor.command_types =
rt::IndirectCommandType::from_bits(u64::from(run.command_types.as_raw()));
descriptor.inherit_pipeline_state = true;
descriptor.max_vertex_buffer_bind_count = run.bind_counts[0];
descriptor.max_fragment_buffer_bind_count = run.bind_counts[1];
+149 -1
View File
@@ -41,6 +41,10 @@ struct StubSide {
/// The device name the side's venue answers, so a test can hold a venue-scoped ledger row
/// against one venue and not another.
device: &'static str,
/// The macOS release and build the side stands for (`Side::macos_release`): the oracle's,
/// so record mode's logic runs on any Mac, where a test does not move it (`on_release`).
#[cfg(target_os = "macos")]
release: (&'static str, &'static str),
made: u32,
}
@@ -52,10 +56,22 @@ impl StubSide {
notices: Vec::new(),
refuse: Vec::new(),
device: "stub",
#[cfg(target_os = "macos")]
release: (
crate::recording::ORACLE_OS_VERSION,
crate::recording::ORACLE_OS_BUILD,
),
made: 0,
}
}
/// The same side on another macOS release and build.
#[cfg(target_os = "macos")]
fn on_release(mut self, version: &'static str, build: &'static str) -> Self {
self.release = (version, build);
self
}
/// The same side on a venue of another name.
fn on(mut self, device: &'static str) -> Self {
self.device = device;
@@ -91,6 +107,11 @@ impl Side for StubSide {
venue_named(self.device)
}
#[cfg(target_os = "macos")]
fn macos_release(&self) -> (String, String) {
(self.release.0.to_owned(), self.release.1.to_owned())
}
fn library(&mut self, _source: &ShaderSource<'_>) -> Answer<Handle> {
match self.refusal("library") {
Some(failure) => Err(failure),
@@ -1030,6 +1051,16 @@ fn one_word_moving_names_its_row_and_index() {
assert!(printed.contains("Metal 3"), "{printed}");
}
/// Each kind is one precision note's: [`Degradation::note`] takes
/// [`Degradation::from_precision_note`] back, so a kind's code is its note's
/// (`PrecisionNote::code`).
#[test]
fn every_kind_is_its_notes_kind() {
for &kind in Degradation::ALL {
assert_eq!(Degradation::from_precision_note(kind.note()), kind);
}
}
/// Every kind a case can name is a precision note's: `docs/API.md` section 9, the catalogue of
/// the notes the runtime carries, lists its code. The runtime's side announces only the codes of
/// those notes, so a kind outside the catalogue would never be announced, and a case that
@@ -2367,6 +2398,36 @@ fn record_mode_counts_the_outcomes_it_saw_with_their_runs() {
}
}
/// Record mode refuses to take an answer on a Mac that is not the oracle the suite names, naming
/// both, and the host it holds is the side's (`Side::macos_release`): Metal's side reads this
/// host's, and the stub states the oracle's but here, so the record-mode tests above check record
/// mode's logic on any Mac, the CI runner's macOS among them.
#[cfg(target_os = "macos")]
#[test]
fn record_mode_refuses_a_host_that_is_not_the_oracle() {
use crate::recording::{ORACLE_CHIP, ORACLE_OS_BUILD, ORACLE_OS_VERSION};
let case = WordsCase::new("words", 2);
let mut moved = StubSide::new(words(&[1, 2])).on_release("26.7.2", "25G332");
let error = record(&case, &mut moved, 1, Validated::Ran).unwrap_err();
assert_eq!(
error,
RecordError::HostMoved {
found: "macOS 26.7.2 (25G332)".to_owned(),
named: format!("{ORACLE_CHIP} on macOS {ORACLE_OS_VERSION} ({ORACLE_OS_BUILD})"),
}
);
assert!(
format!("{error}").contains("re-record every case"),
"{error}"
);
// The oracle's release on another build is moved too: a recording is keyed by both.
let mut rebuilt = StubSide::new(words(&[1, 2])).on_release(ORACLE_OS_VERSION, "26A999");
assert!(matches!(
record(&case, &mut rebuilt, 1, Validated::Ran),
Err(RecordError::HostMoved { .. })
));
}
#[test]
fn a_set_diff_prints_what_is_missing_and_what_is_extra() {
let metal = Transcript::new(vec![Node::leaf(
@@ -2896,10 +2957,16 @@ fn a_carried_answer_taken_on_another_chip_names_it() {
// - `sample-positions-fewer-*`: the M4's coverage for fewer custom sample positions than the
// pass's samples, which stays carried because one position **past** the pass's samples is
// measured to end Metal's process, so a record run may not walk that family.
const KNOWN: [&str; 3] = [
// - `managed-named-*`: an AMD Radeon Pro 5300M's answer for which commit takes a Managed
// buffer's named range to its second copy, which the oracle, keeping one copy, cannot give.
// - `sample-positions-8x-*`: the 5300M's resolved texels of the sample positions family's pass
// at 8 samples, which the oracle, rendering no 8 samples, cannot give.
const KNOWN: [&str; 5] = [
"texture-fills-",
crate::cases::compute_threadgroups::PAST_METALS_LIMIT,
"sample-positions-fewer-",
"managed-named-",
"sample-positions-8x-",
];
for family in KNOWN {
assert!(
@@ -4115,6 +4182,87 @@ fn a_divergence_row_is_held_in_both_directions() {
assert!(printed.contains("drop the row"), "{printed}");
}
/// A row may list more than one answer at its site, with ` | ` between them, for a venue whose
/// hosts answer the site differently by a property its description does not state: llvmpipe of
/// one Mesa and LLVM stores the `x3` sites of `fetch-ordered-*-srgb` at 6,304 elements on one
/// x86-64 AVX-512 host and at 6,496 on others. The row covers each answer it lists and no other,
/// and is held while the run answers any of them; a row of one answer is held as before.
#[test]
fn a_ledger_row_of_two_answers_covers_either_and_no_third() {
use crate::known_gaps::{against, parse, Expectation, Now};
let case = LedgerCase::new("ledger-two-answers");
let recording = recording_of(&case, case.metal(7), 3);
let answering = |ours: u32| {
let mut side = StubSide::new(words(&[ours]));
let row = replay_against(&case, &mut side, &recording).unwrap();
let found = against(std::slice::from_ref(&row), &[]);
let [Expectation::Unlisted { site, answer, .. }] = found.as_slice() else {
panic!("{found:?}");
};
(row, site.clone(), answer.clone())
};
let (nine, site, first) = answering(9);
let (eight, at, second) = answering(8);
let (six, _, third) = answering(6);
assert_eq!(at, site);
assert!(first != second && second != third && first != third);
let row = |answers: &str| {
parse(&format!(
"{}\t*\tdivergent\t{site}\t{answers}\ta difference this test writes down on purpose\n",
case.name()
))
.unwrap()
};
// Either listed answer is the row's, so neither run is a surprise.
let two = row(&format!("{first} | {second}"));
assert_eq!(two.len(), 1, "{two:?}");
assert_eq!(against(std::slice::from_ref(&nine), &two), Vec::new());
assert_eq!(against(std::slice::from_ref(&eight), &two), Vec::new());
// A third answer is a new gap, and the row, none of whose answers the run held, looks fixed.
let found = against(std::slice::from_ref(&six), &two);
assert!(
matches!(
found.as_slice(),
[
Expectation::Unlisted { answer, listed: Some(_), .. },
Expectation::NoLongerHeld { now: Now::Differs, .. },
] if *answer == third
),
"{found:?}"
);
// A run that no longer diverges reads the row as fixed, whichever answer it listed.
let mut fixed = StubSide::new(words(&[7]));
let exact = replay_against(&case, &mut fixed, &recording).unwrap();
let found = against(std::slice::from_ref(&exact), &two);
assert!(
matches!(
found.as_slice(),
[Expectation::NoLongerHeld {
now: Now::Matches,
..
}]
),
"{found:?}"
);
// A row of one answer covers that answer alone, in both directions, as before.
let one = row(&first);
assert_eq!(against(std::slice::from_ref(&nine), &one), Vec::new());
let found = against(std::slice::from_ref(&eight), &one);
assert!(
matches!(
found.as_slice(),
[
Expectation::Unlisted { answer, .. },
Expectation::NoLongerHeld { now: Now::Differs, .. },
] if *answer == second
),
"{found:?}"
);
}
/// A divergence never launders a refusal of the same case: the verdict carries both, and the
/// ledger holds a refusal row against a case that also diverges.
///
@@ -15,6 +15,20 @@
use metal2vulkan::metal::{PixelFormat, TextureType, TextureUsage};
/// The formats Metal makes no texture of from a descriptor alone: `RGBA16Float_XR`, `AnyDepth`,
/// `AnyStencil` and a two-plane YCbCr format.
///
/// Measured on an Apple M3 Max under macOS 27.0.1: `newTextureWithDescriptor:` answers nil for
/// each (`heap-sizes-formats-without-textures`), and `newSharedTextureWithDescriptor:` answers nil
/// for `RGBA16Float_XR` in `Private` storage at 1, 4 and 8 samples
/// (`shared-creator-extended-range-samples`).
pub const WITHOUT_TEXTURES: [PixelFormat; 4] = [
PixelFormat::RGBA16FloatXR,
PixelFormat::AnyDepth,
PixelFormat::AnyStencil,
PixelFormat::YCBCR84202P,
];
/// The storage mode a case asks a resource for: three of Metal's four modes, and the suite's one
/// spelling of them.
///
@@ -111,6 +111,11 @@ impl<S: Side, W: Watcher> Side for Watching<S, W> {
self.inner.venue()
}
#[cfg(target_os = "macos")]
fn macos_release(&self) -> (String, String) {
self.inner.macos_release()
}
fn library(&mut self, source: &ShaderSource<'_>) -> Answer<Handle> {
let _span = self.watch("library");
self.inner.library(source)
@@ -795,6 +800,15 @@ impl<S: Side, W: Watcher> Side for Watching<S, W> {
self.inner.empty_command_buffers()
}
fn managed_naming(
&mut self,
way: crate::managed_naming::Way,
libraries: crate::managed_naming::Libraries,
) -> Answer<Vec<u8>> {
let _span = self.watch("managed_naming");
self.inner.managed_naming(way, libraries)
}
fn sparse_tile_size_in_bytes(&mut self, page: crate::sparse_query::QueryPage) -> Answer<u64> {
let _span = self.watch("sparse_tile_size_in_bytes");
self.inner.sparse_tile_size_in_bytes(page)
+3 -11
View File
@@ -61,19 +61,12 @@ pub const THREAD_COUNTS: [u32; 2] = [32, 64];
pub struct Target {
/// Threads in the dispatch's one threadgroup, one of [`THREAD_COUNTS`].
pub threads: u32,
/// Whether the device reaches buffers by device address (Profile A): a pointer loaded from a
/// buffer can be dereferenced. Without it the engine refuses such a program as
/// `Unsupported{DereferenceLoadedPointer}`, honestly, so no generator builds one.
pub addressed: bool,
}
impl Default for Target {
/// [`THREADS`] threads on a device with device addresses.
/// [`THREADS`] threads.
fn default() -> Target {
Target {
threads: THREADS,
addressed: true,
}
Target { threads: THREADS }
}
}
@@ -81,8 +74,7 @@ impl Default for Target {
/// index the generators build is a small non-negative `i32`, so the three spellings name the same
/// element; they reach different index forms of the engine (a zero-extended word, a
/// sign-extended word, and an `i32` index the GEP itself extends), and [`IndexForm::Narrow32`]
/// programs compute no 64-bit index or offset, which a profile without `shaderInt64` (`vk12-floor`)
/// runs without two-word emulation.
/// programs compute no 64-bit index or offset.
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum IndexForm {
/// `zext i32 %v to i64`, the Metal front end's spelling of an unsigned index.
@@ -20,14 +20,11 @@
//! **parked** form, between the same roots stored into and loaded back from a private aggregate
//! (private pointer cells); and, in the **loaded** form, between wide pointers whose roots are
//! LOADED from a pointer table ([`Input::Addresses`]: the guest addresses of the three buffers), so
//! every choice, GEP, and access goes through the resident-set search and the root table, and a
//! lookup that missed would be counted and fail the run. The loaded form is built only for a
//! [`Target`] with device addresses (Profile A): without them the engine refuses a loaded
//! pointer's dereference, honestly. Every form may take the nullable choice.
//! every choice, GEP, and access goes through the device address the pointer holds. Every form may
//! take the nullable choice.
use super::{
air_header, kernel_metadata_written, Execute, IndexForm, Input, Kernel, Report, Target,
Xorshift, OPS,
air_header, kernel_metadata_written, Execute, IndexForm, Input, Kernel, Report, Xorshift, OPS,
};
/// The index mask the generated program applies. A power of two, so the mask is exact.
@@ -99,7 +96,7 @@ struct Program {
}
impl Program {
fn generate(seed: u64, target: Target, form: IndexForm) -> Self {
fn generate(seed: u64, form: IndexForm) -> Self {
let mut rng = Xorshift(seed | 1);
let steps = (0..STEPS)
.map(|_| {
@@ -130,7 +127,7 @@ impl Program {
// program are the same whichever form it takes.
let roots = match indirect {
false => Roots::Params,
true if target.addressed && rng.below(2) == 1 => Roots::Loaded,
true if rng.below(2) == 1 => Roots::Loaded,
true => Roots::Parked,
};
Program {
@@ -412,7 +409,7 @@ pub fn check(executor: &mut dyn Execute, seeds: std::ops::RangeInclusive<u64>) -
let mut report = Report::default();
for seed in seeds {
let form = IndexForm::of(seed);
let program = Program::generate(seed.wrapping_mul(0x9e3779b97f4a7c15), target, form);
let program = Program::generate(seed.wrapping_mul(0x9e3779b97f4a7c15), form);
let mut want: Vec<u32> = fill
.as_chunks::<4>()
.0
@@ -477,37 +474,23 @@ pub fn check(executor: &mut dyn Execute, seeds: std::ops::RangeInclusive<u64>) -
mod tests {
use super::*;
/// The engine's programs take every root form over the gate seeds, the loaded form only
/// on a device with device addresses, and nullable choices in all of them.
/// The engine's programs take every root form over the gate seeds, and nullable choices in
/// all of them.
#[test]
fn the_engine_programs_cover_every_root_form_the_device_can_run() {
let program = |seed: u64, target: Target| {
Program::generate(
seed.wrapping_mul(0x9e3779b97f4a7c15),
target,
IndexForm::Zext64,
)
};
let count = |target: Target| {
let mut counts = [0usize; 3];
for seed in crate::fuzz::GATE_SEEDS {
counts[program(seed, target).roots as usize] += 1;
}
counts
};
let addressed = count(Target::default());
assert!(addressed.iter().all(|&n| n > 0), "{addressed:?}");
fn the_engine_programs_cover_every_root_form() {
let program =
|seed: u64| Program::generate(seed.wrapping_mul(0x9e3779b97f4a7c15), IndexForm::Zext64);
let mut counts = [0usize; 3];
for seed in crate::fuzz::GATE_SEEDS {
counts[program(seed).roots as usize] += 1;
}
assert!(counts.iter().all(|&n| n > 0), "{counts:?}");
let nullable = crate::fuzz::GATE_SEEDS
.filter(|&seed| {
let p = program(seed, Target::default());
let p = program(seed);
p.roots != Roots::Params && p.steps.iter().any(|s| s.nullable && !s.phi)
})
.count();
assert!(nullable > 0);
let floor = count(Target {
addressed: false,
..Target::default()
});
assert!(floor[Roots::Loaded as usize] == 0 && floor[Roots::Parked as usize] > 0);
}
}
@@ -0,0 +1,483 @@
//! The authored kernels (inline AIR text, for `llvm-as`) of Metal's `half` simdgroup sums and
//! products, and what Metal answers: the product's CPU-interpreter tests and the runtime's device
//! test both run them ([`module`]).
//!
//! Metal's `simd_sum` and `simd_product` of `half` operands are a tree of `half` operations: in
//! round `d` (1, 2, 4, 8, 16) each aligned block of `2d` lanes holds its lower and upper halves'
//! results combined and rounded to `half`, and a lane that takes no part counts as the operation's
//! identity. Measured on an M3 Max (macOS 27.0.1), fast math on and off alike, with our own MSL:
//! [`SUMS`] (potluck job m3-max-80839), [`PRODUCTS`] (m3-max-80879), and [`MASKED_SUMS`] and
//! [`MASKED_PRODUCTS`] (m3-max-80890). Each answer is that tree's on every vector; the `float`
//! result rounded once differs on five of the sums (`0x3c10` for `0x3c0f` on the first), four of
//! the products and ten of the 48 masked results, and the tree over the active lanes packed
//! together differs on three masked sums.
//!
//! - [`FULL`] (`half_simd_reductions`): one threadgroup of [`THREADS`] threads, eight
//! simdgroups. Thread `t` takes [`SUM_OPERANDS`] and [`PRODUCT_OPERANDS`] of its simdgroup
//! `t / 32` at its lane `t % 32` and writes `simd_sum`'s bits in the low half of its word and
//! `simd_product`'s in the high half ([`full`]).
//! - [`MASKED`] (`half_simd_reductions_masked`): one threadgroup of `3 * THREADS` threads. Thread
//! `t` takes [`SUM_OPERANDS`]'s value of thread `t % 256` and, where bit `lane` of
//! [`MASKS`]`[t / 256]` is set, writes the sum and the product of that operand over those lanes
//! as [`FULL`] does; every other thread writes `0xffff_ffff` ([`masked`]).
//! - [`QUADS`] (`half_quad_reductions`): one threadgroup of [`THREADS`] threads. Thread `t` takes
//! entry `t` of [`SUM_OPERANDS`] and of [`PRODUCT_OPERANDS`] and writes [`QUAD_WORDS`] words
//! ([`quads`]): its `quad_sum` and `quad_product`, its quad's inclusive and exclusive prefix sums,
//! its quad's inclusive and exclusive prefix products, and the same four prefix operations over
//! its simdgroup, each word a pair of `half` bits, low then high. Metal's quad answers are
//! `(x0 op x1) op (x2 op x3)` and the lane-order chain over the quad's lanes, each operation
//! rounded to `half`, the empty exclusive sum `-0` and product 1 (measured on all 256 threads,
//! fast math on and off: m3-max-81130; the `float` result rounded once differs on 48 of the quad
//! sums and 64 of the products). Metal's simdgroup prefix order is none this crate models (the
//! lane-order chain, the Hillis and Steele scan and the `float` result rounded once each differ
//! on 60 to 137 of the 256 threads), so [`quads`] does not answer those two words: they make
//! the kernel a simdgroup user, which a device whose subgroups are narrower than a simdgroup
//! runs on its emulated tier, quad operations included.
/// The full kernel.
pub const FULL: &str = "half_simd_reductions";
/// The masked kernel.
pub const MASKED: &str = "half_simd_reductions_masked";
/// The threads of [`FULL`]'s threadgroup: eight simdgroups.
pub const THREADS: u32 = 256;
/// The quad kernel.
pub const QUADS: &str = "half_quad_reductions";
/// The words each thread of [`QUADS`] writes.
pub const QUAD_WORDS: u32 = 5;
/// The `half` bits each simdgroup sums: a 1 among `2^-11`s (first and last lane), a cancellation,
/// `2048` and `-2048` among ones, and four vectors of mixed signs and exponents.
pub const SUM_OPERANDS: [[u16; 32]; 8] = [
[
0x3c00, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000,
0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000,
0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000,
],
[
0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000,
0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000,
0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x3c00,
],
[
0x63d0, 0xe3d0, 0x63d0, 0xe3d0, 0x63d0, 0xe3d0, 0x63d1, 0xe3d0, 0x63d1, 0xe3d0, 0x63d1,
0xe3d0, 0x63d2, 0xe3d0, 0x63d2, 0xe3d0, 0x63d2, 0xe3d0, 0x63d2, 0xe3d0, 0x63d2, 0xe3d0,
0x63d3, 0xe3d0, 0x63d3, 0xe3d0, 0x63d3, 0xe3d0, 0x63d4, 0xe3d0, 0x63d4, 0xe3d0,
],
[
0x6800, 0x3c00, 0x3c00, 0x3c00, 0x3c00, 0x3c00, 0x3c00, 0x3c00, 0x3c00, 0x3c00, 0x3c00,
0x3c00, 0x3c00, 0x3c00, 0x3c00, 0x3c00, 0xe800, 0x3c00, 0x3c00, 0x3c00, 0x3c00, 0x3c00,
0x3c00, 0x3c00, 0x3c00, 0x3c00, 0x3c00, 0x3c00, 0x3c00, 0x3c00, 0x3c00, 0x3c00,
],
[
0x4f70, 0xc411, 0x3994, 0xceaa, 0x307c, 0xceb6, 0x3477, 0xcd6b, 0x476a, 0xc795, 0x42b3,
0xb86f, 0x487b, 0xcd7d, 0x3c4e, 0xb9c2, 0x39e4, 0xc1b3, 0x47f8, 0xc841, 0x3fff, 0xc864,
0x42bd, 0xc983, 0x3076, 0xc013, 0x4eb4, 0xb6d3, 0x3476, 0xc80b, 0x48ae, 0xb519,
],
[
0x45e3, 0xbdcc, 0x30e8, 0xc7cb, 0x4b7f, 0xc580, 0x4ebb, 0xc6df, 0x3c21, 0xbd66, 0x3b48,
0xb3ba, 0x40e5, 0xc444, 0x372d, 0xb120, 0x3257, 0xbad7, 0x3f33, 0xc225, 0x34a7, 0xc045,
0x3bfe, 0xc019, 0x4ad9, 0xb989, 0x44bc, 0xcf7f, 0x4cf3, 0xc3e4, 0x40d7, 0xcff5,
],
[
0x3d2e, 0xb651, 0x48a3, 0xbf2b, 0x4026, 0xbdf0, 0x4511, 0xbecf, 0x340a, 0xb578, 0x325b,
0xc97d, 0x3acc, 0xbfa8, 0x4db7, 0xcab2, 0x4b53, 0xb0b5, 0x3605, 0xb9b9, 0x4da5, 0xbabc,
0x3382, 0xbb9b, 0x421e, 0xb130, 0x3e73, 0xc412, 0x479d, 0xbb4c, 0x38da, 0xc575,
],
[
0x40b2, 0xd980, 0x4f25, 0xc3ab, 0x47d1, 0xc1e6, 0x4bda, 0xc21a, 0x5a83, 0xdbad, 0x564e,
0xcc98, 0x3f90, 0xc18b, 0x504c, 0xcf58, 0x4c37, 0xd72d, 0x5ace, 0xbddd, 0x5057, 0xbda9,
0x55a8, 0xbce9, 0x45a3, 0xd6e9, 0x4238, 0xcb6c, 0x49d3, 0xbc21, 0x3d18, 0xca78,
],
];
/// Metal's `simd_sum` of each vector of [`SUM_OPERANDS`].
pub const SUMS: [u16; 8] = [
0x3c0f, 0x3c0f, 0x4b80, 0x4f40, 0xd238, 0xc57c, 0x51eb, 0x5124,
];
/// The `half` bits each simdgroup multiplies: `1 + 2^-10` in every lane, that and `1 - 2^-11` in
/// turn, three vectors of `1 + k 2^-10`, and three of magnitudes in `[0.75, 1.5)` of mixed signs.
pub const PRODUCT_OPERANDS: [[u16; 32]; 8] = [
[
0x3c01, 0x3c01, 0x3c01, 0x3c01, 0x3c01, 0x3c01, 0x3c01, 0x3c01, 0x3c01, 0x3c01, 0x3c01,
0x3c01, 0x3c01, 0x3c01, 0x3c01, 0x3c01, 0x3c01, 0x3c01, 0x3c01, 0x3c01, 0x3c01, 0x3c01,
0x3c01, 0x3c01, 0x3c01, 0x3c01, 0x3c01, 0x3c01, 0x3c01, 0x3c01, 0x3c01, 0x3c01,
],
[
0x3c01, 0x3bff, 0x3c01, 0x3bff, 0x3c01, 0x3bff, 0x3c01, 0x3bff, 0x3c01, 0x3bff, 0x3c01,
0x3bff, 0x3c01, 0x3bff, 0x3c01, 0x3bff, 0x3c01, 0x3bff, 0x3c01, 0x3bff, 0x3c01, 0x3bff,
0x3c01, 0x3bff, 0x3c01, 0x3bff, 0x3c01, 0x3bff, 0x3c01, 0x3bff, 0x3c01, 0x3bff,
],
[
0x3c01, 0x3bfa, 0x3bf2, 0x3bf4, 0x3bf6, 0x3bfa, 0x3bf8, 0x3bf2, 0x3bf2, 0x3bfa, 0x3bf2,
0x3c05, 0x3bf4, 0x3c03, 0x3bf0, 0x3bf2, 0x3bf8, 0x3c01, 0x3c02, 0x3bf4, 0x3c06, 0x3c01,
0x3c07, 0x3c01, 0x3c08, 0x3c02, 0x3bf0, 0x3c04, 0x3bf6, 0x3c04, 0x3bf4, 0x3bfe,
],
[
0x3c06, 0x3c08, 0x3c04, 0x3c06, 0x3c07, 0x3c02, 0x3bfa, 0x3bfa, 0x3bf4, 0x3c06, 0x3c05,
0x3bf6, 0x3bf8, 0x3c04, 0x3bf6, 0x3bfe, 0x3c02, 0x3bfc, 0x3bf4, 0x3c07, 0x3bf6, 0x3c05,
0x3bfa, 0x3c05, 0x3c01, 0x3bf0, 0x3bf6, 0x3bf2, 0x3bf6, 0x3c07, 0x3c05, 0x3c05,
],
[
0x3c07, 0x3bf8, 0x3bfa, 0x3bf8, 0x3c00, 0x3c06, 0x3bf2, 0x3c06, 0x3bf6, 0x3bf0, 0x3c00,
0x3bfc, 0x3bf2, 0x3bf0, 0x3c07, 0x3c05, 0x3bf0, 0x3c02, 0x3c00, 0x3bfa, 0x3bf8, 0x3bf4,
0x3c06, 0x3bf2, 0x3c08, 0x3c06, 0x3bfa, 0x3bf6, 0x3c00, 0x3bfc, 0x3c08, 0x3c03,
],
[
0x3bb8, 0x3bd0, 0xbd43, 0xbccd, 0xba35, 0x3de2, 0xbc89, 0x3a23, 0xbaab, 0xbcbb, 0xba56,
0xbaf0, 0xbdcb, 0x3b88, 0x3ae4, 0x3c3a, 0xbcfd, 0xba91, 0x3c90, 0x3b0d, 0x3cc9, 0xbc15,
0x3ccf, 0xbda9, 0x3b6e, 0x3c3a, 0x3a1a, 0x3d68, 0x3b24, 0xbc11, 0xbd67, 0xbcb0,
],
[
0x3d3a, 0x3c7f, 0xbc34, 0xbc71, 0xbb70, 0x3c79, 0xbc35, 0x3cc6, 0xbb25, 0xbb95, 0xba13,
0xbc58, 0xbac1, 0x3d14, 0x3bcc, 0x3d04, 0xbb3f, 0xba28, 0x3b0b, 0x3b76, 0x3cc5, 0xba53,
0x3abc, 0xbca9, 0x3c95, 0x3a2d, 0x3d15, 0x3b33, 0x3b67, 0xbc07, 0xbd33, 0xbc98,
],
[
0x3c7b, 0x3dd1, 0xbc18, 0xbdd7, 0xba1b, 0x3c7e, 0xbd30, 0x3dd5, 0xbcac, 0xbc07, 0xbc65,
0xbdbd, 0xbd48, 0x3ac6, 0x3dd4, 0x3d0c, 0xbd58, 0xbb80, 0x3b84, 0x3d76, 0x3ced, 0xba1f,
0x3dd0, 0xbd0a, 0x3c04, 0x3cc6, 0x3c6d, 0x3b26, 0x3d1a, 0xbce0, 0xbc8d, 0xbc41,
],
];
/// Metal's `simd_product` of each vector of [`PRODUCT_OPERANDS`].
pub const PRODUCTS: [u16; 8] = [
0x3c20, 0x3c00, 0x3b8e, 0x3c11, 0x3bd3, 0x43b1, 0x3e11, 0x55cb,
];
/// The active lanes of [`MASKED`]'s three cases: the odd lanes, lanes 5 to 27 but 16, and lanes 0,
/// 15, 16 and 31.
pub const MASKS: [u32; 3] = [0xaaaa_aaaa, 0x0ffe_ffe0, 0x8001_8001];
/// Metal's `simd_sum` of each vector of [`SUM_OPERANDS`] over the lanes of each of [`MASKS`].
pub const MASKED_SUMS: [[u16; 8]; 3] = [
[
0x2000, 0x3c07, 0xf3d0, 0x4c00, 0xd8c1, 0xd663, 0xd1a8, 0xe1c8,
],
[
0x2180, 0x2180, 0xe7c6, 0x4d80, 0xd272, 0xc3d4, 0x4d19, 0x5933,
],
[
0x3c01, 0x3c01, 0x3c00, 0x3c00, 0x4f5d, 0xce7a, 0xc1d0, 0xcdc7,
],
];
/// Metal's `simd_product` of each vector of [`SUM_OPERANDS`] over the lanes of each of [`MASKS`].
pub const MASKED_PRODUCTS: [[u16; 8]; 3] = [
[
0x0000, 0x0000, 0x7c00, 0x3c00, 0x7c00, 0x7c00, 0x51f1, 0x7c00,
],
[
0x0000, 0x0000, 0x7c00, 0x3c00, 0x7c00, 0x7c00, 0x611c, 0x7c00,
],
[
0x0000, 0x0000, 0x7c00, 0xfc00, 0x4506, 0x45f2, 0x656a, 0x7358,
],
];
/// What thread `t` of [`FULL`] writes.
pub fn full(t: u32) -> u32 {
let v = (t / 32) as usize;
u32::from(SUMS[v]) | (u32::from(PRODUCTS[v]) << 16)
}
/// What thread `t` of [`MASKED`] writes.
pub fn masked(t: u32) -> u32 {
let (case, v, lane) = (
(t / THREADS) as usize,
((t % THREADS) / 32) as usize,
t % 32,
);
if (MASKS[case] >> lane) & 1 == 0 {
return 0xffff_ffff;
}
u32::from(MASKED_SUMS[case][v]) | (u32::from(MASKED_PRODUCTS[case][v]) << 16)
}
/// Metal's word `w` of [`QUADS`]' output (thread `w / QUAD_WORDS`), where this crate models it:
/// the quad's reductions and prefix operations, each `half` operation rounded; `None` for the
/// simdgroup prefix operations' two words.
pub fn quads(w: u32) -> Option<u32> {
let (t, k) = (w / QUAD_WORDS, w % QUAD_WORDS);
let operand = |table: &[[u16; 32]; 8], u: u32| table[(u / 32) as usize][(u % 32) as usize];
let base = t & !3;
let lanes = |table| (base..base + 4).map(move |u| value(operand(table, u)));
let tree = |table, op: Operation| {
let x: Vec<f64> = lanes(table).collect();
let (low, high) = (round(op(x[0], x[1])), round(op(x[2], x[3])));
round(op(value(low), value(high)))
};
// The lane-order chain over the quad's lanes below the thread's (and its own when
// `inclusive`), from the empty answer `empty`.
let chain = |table, op: Operation, empty: u16, inclusive: bool| {
let upto = (t - base) + u32::from(inclusive);
lanes(table)
.take(upto as usize)
.fold(empty, |acc, x| round(op(value(acc), x)))
};
let (add, mul): (Operation, Operation) = (|a, b| a + b, |a, b| a * b);
let pair = |low: u16, high: u16| u32::from(low) | (u32::from(high) << 16);
match k {
0 => Some(pair(tree(&SUM_OPERANDS, add), tree(&PRODUCT_OPERANDS, mul))),
1 => Some(pair(
chain(&SUM_OPERANDS, add, 0x8000, true),
chain(&SUM_OPERANDS, add, 0x8000, false),
)),
2 => Some(pair(
chain(&PRODUCT_OPERANDS, mul, 0x3c00, true),
chain(&PRODUCT_OPERANDS, mul, 0x3c00, false),
)),
_ => None,
}
}
/// [`QUADS`]' word `w` as `float` arithmetic rounded to `half` once gives it, where this crate
/// models it: each operation of [`quads`]' tree or lane-order chain in `f32` (the empty answers
/// `-0` and 1), and the result rounded to `half` at the end. The answer
/// `PrecisionNote::NativeHalfConversion` admits for a word fed by `half` arithmetic where a driver
/// computes the device's 16-bit operations in `float` (Intel's Windows driver 101.2145 on a UHD
/// Graphics 630: every half of these words Metal's or this one).
pub fn quads_once(w: u32) -> Option<u32> {
let (t, k) = (w / QUAD_WORDS, w % QUAD_WORDS);
let operand = |table: &[[u16; 32]; 8], u: u32| table[(u / 32) as usize][(u % 32) as usize];
let base = t & !3;
// A `half` is exact in `f32`.
let lanes = |table| (base..base + 4).map(move |u| value(operand(table, u)) as f32);
let tree = |table, op: FloatOperation| {
let x: Vec<f32> = lanes(table).collect();
round(f64::from(op(op(x[0], x[1]), op(x[2], x[3]))))
};
let chain = |table, op: FloatOperation, empty: f32, inclusive: bool| {
let upto = (t - base) + u32::from(inclusive);
round(f64::from(lanes(table).take(upto as usize).fold(empty, op)))
};
let (add, mul): (FloatOperation, FloatOperation) = (|a, b| a + b, |a, b| a * b);
let pair = |low: u16, high: u16| u32::from(low) | (u32::from(high) << 16);
match k {
0 => Some(pair(tree(&SUM_OPERANDS, add), tree(&PRODUCT_OPERANDS, mul))),
1 => Some(pair(
chain(&SUM_OPERANDS, add, -0.0, true),
chain(&SUM_OPERANDS, add, -0.0, false),
)),
2 => Some(pair(
chain(&PRODUCT_OPERANDS, mul, 1.0, true),
chain(&PRODUCT_OPERANDS, mul, 1.0, false),
)),
_ => None,
}
}
/// A `half` operation of the model, on the operands' exact values.
type Operation = fn(f64, f64) -> f64;
/// A `float` operation of [`quads_once`], rounded to `f32`.
type FloatOperation = fn(f32, f32) -> f32;
/// The value of the `half` bits `h`.
fn value(h: u16) -> f64 {
let sign = if h & 0x8000 == 0 { 1.0 } else { -1.0 };
let (e, m) = (i32::from((h >> 10) & 0x1f), f64::from(h & 0x3ff));
sign * match e {
0 => m * 2f64.powi(-24),
31 if m == 0.0 => f64::INFINITY,
31 => f64::NAN,
e => (1024.0 + m) * 2f64.powi(e - 25),
}
}
/// The bits of the `half` nearest `x`, ties to even, where `x` is exact in `f64` (a sum or product
/// of two `half` values is): a magnitude from 65520 up is the infinity of its sign.
fn round(x: f64) -> u16 {
let sign = if x.is_sign_negative() { 0x8000 } else { 0 };
let a = x.abs();
if a.is_nan() {
return 0x7e00;
}
if a == 0.0 {
return sign;
}
if a >= 65520.0 {
return sign | 0x7c00;
}
// The binade's exponent, no lower than the smallest normal's: a `half` there is a multiple of
// `2^(e - 10)`.
let binade = i32::try_from((a.to_bits() >> 52) & 0x7ff).unwrap_or(0) - 1023;
let e = binade.max(-14);
let units = (a * 2f64.powi(10 - e)).round_ties_even();
let (e, units) = if units >= 2048.0 {
(e + 1, units / 2.0)
} else {
(e, units)
};
let units = units as u16;
if units < 1024 {
// A denormal (or zero): the units are its bits.
return sign | units;
}
let biased = u16::try_from(e + 15).unwrap_or(31);
if biased >= 31 {
return sign | 0x7c00;
}
sign | (biased << 10) | (units - 1024)
}
/// A table of `half` bits as an AIR constant array.
fn halves(table: &[[u16; 32]; 8]) -> String {
let cells: Vec<String> = table
.iter()
.flatten()
.map(|h| format!("half 0xH{h:04X}"))
.collect();
format!("[256 x half] [{}]", cells.join(", "))
}
/// [`QUADS`]' definition: ten operations on the thread's two operands, packed two to a word.
fn quads_function() -> String {
const CALLS: [(&str, &str); 10] = [
("quad_sum", "x"),
("quad_product", "y"),
("quad_prefix_inclusive_sum", "x"),
("quad_prefix_exclusive_sum", "x"),
("quad_prefix_inclusive_product", "y"),
("quad_prefix_exclusive_product", "y"),
("simd_prefix_inclusive_sum", "x"),
("simd_prefix_exclusive_sum", "x"),
("simd_prefix_inclusive_product", "y"),
("simd_prefix_exclusive_product", "y"),
];
let mut body = format!(
"define void @{QUADS}(ptr addrspace(1) noundef \"air-buffer-no-alias\" %out, i32 noundef %t) #0 {{\n\
%i = zext i32 %t to i64\n\
%px = getelementptr inbounds [256 x half], ptr addrspace(2) @sum_operands, i64 0, i64 %i\n\
%x = load half, ptr addrspace(2) %px, align 2\n\
%py = getelementptr inbounds [256 x half], ptr addrspace(2) @product_operands, i64 0, i64 %i\n\
%y = load half, ptr addrspace(2) %py, align 2\n\
%base = mul i64 %i, {QUAD_WORDS}\n"
);
for (n, (op, operand)) in CALLS.iter().enumerate() {
body.push_str(&format!(
" %r{n} = tail call half @air.{op}.f16(half %{operand}) #1\n\
%b{n} = bitcast half %r{n} to i16\n\
%z{n} = zext i16 %b{n} to i32\n"
));
}
for k in 0..CALLS.len() / 2 {
let (low, high) = (2 * k, 2 * k + 1);
body.push_str(&format!(
" %h{k} = shl i32 %z{high}, 16\n\
%w{k} = or i32 %z{low}, %h{k}\n\
%at{k} = add i64 %base, {k}\n\
%o{k} = getelementptr inbounds i32, ptr addrspace(1) %out, i64 %at{k}\n\
store i32 %w{k}, ptr addrspace(1) %o{k}, align 4\n"
));
}
body.push_str(" ret void\n}\n\n");
for (op, _) in CALLS {
body.push_str(&format!("declare half @air.{op}.f16(half) #1\n"));
}
body
}
/// The module holding [`FULL`], [`MASKED`] and [`QUADS`].
pub fn module() -> String {
let masks: Vec<String> = MASKS.iter().map(|m| format!("i32 {}", *m as i32)).collect();
format!(
r#"target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v16:16:16-v24:32:32-v32:32:32-v48:64:64-v64:64:64-v96:128:128-v128:128:128-v192:256:256-v256:256:256-v512:512:512-v1024:1024:1024-n8:16:32"
target triple = "air64_v28-apple-macosx26.0.0"
@sum_operands = internal addrspace(2) constant {sums}, align 2
@product_operands = internal addrspace(2) constant {products}, align 2
@masks = internal addrspace(2) constant [3 x i32] [{masks}], align 4
define void @{FULL}(ptr addrspace(1) noundef "air-buffer-no-alias" %out, i32 noundef %t) #0 {{
%i = zext i32 %t to i64
%px = getelementptr inbounds [256 x half], ptr addrspace(2) @sum_operands, i64 0, i64 %i
%x = load half, ptr addrspace(2) %px, align 2
%py = getelementptr inbounds [256 x half], ptr addrspace(2) @product_operands, i64 0, i64 %i
%y = load half, ptr addrspace(2) %py, align 2
%s = tail call half @air.simd_sum.f16(half %x) #1
%p = tail call half @air.simd_product.f16(half %y) #1
%sb = bitcast half %s to i16
%pb = bitcast half %p to i16
%sw = zext i16 %sb to i32
%pw = zext i16 %pb to i32
%ph = shl i32 %pw, 16
%w = or i32 %sw, %ph
%o = getelementptr inbounds i32, ptr addrspace(1) %out, i64 %i
store i32 %w, ptr addrspace(1) %o, align 4
ret void
}}
define void @{MASKED}(ptr addrspace(1) noundef "air-buffer-no-alias" %out, i32 noundef %t, i32 noundef %lane) #0 {{
entry:
%i = zext i32 %t to i64
%v = and i32 %t, 255
%vi = zext i32 %v to i64
%px = getelementptr inbounds [256 x half], ptr addrspace(2) @sum_operands, i64 0, i64 %vi
%x = load half, ptr addrspace(2) %px, align 2
%case = lshr i32 %t, 8
%ci = zext i32 %case to i64
%pm = getelementptr inbounds [3 x i32], ptr addrspace(2) @masks, i64 0, i64 %ci
%m = load i32, ptr addrspace(2) %pm, align 4
%shifted = lshr i32 %m, %lane
%bit = and i32 %shifted, 1
%on = icmp ne i32 %bit, 0
br i1 %on, label %active, label %done
active:
%s = tail call half @air.simd_sum.f16(half %x) #1
%p = tail call half @air.simd_product.f16(half %x) #1
%sb = bitcast half %s to i16
%pb = bitcast half %p to i16
%sw = zext i16 %sb to i32
%pw = zext i16 %pb to i32
%ph = shl i32 %pw, 16
%w = or i32 %sw, %ph
br label %done
done:
%r = phi i32 [ %w, %active ], [ -1, %entry ]
%o = getelementptr inbounds i32, ptr addrspace(1) %out, i64 %i
store i32 %r, ptr addrspace(1) %o, align 4
ret void
}}
declare half @air.simd_sum.f16(half) #1
declare half @air.simd_product.f16(half) #1
{quads}
attributes #0 = {{ convergent mustprogress nounwind willreturn }}
attributes #1 = {{ convergent mustprogress nounwind willreturn }}
!llvm.module.flags = !{{!0, !1, !2, !3, !4, !5, !6, !7, !8}}
!air.kernel = !{{!9, !21, !23}}
!air.version = !{{!19}}
!air.language_version = !{{!20}}
!0 = !{{i32 2, !"SDK Version", [2 x i32] [i32 26, i32 5]}}
!1 = !{{i32 1, !"wchar_size", i32 4}}
!2 = !{{i32 7, !"frame-pointer", i32 2}}
!3 = !{{i32 7, !"air.max_device_buffers", i32 31}}
!4 = !{{i32 7, !"air.max_constant_buffers", i32 31}}
!5 = !{{i32 7, !"air.max_threadgroup_buffers", i32 31}}
!6 = !{{i32 7, !"air.max_textures", i32 128}}
!7 = !{{i32 7, !"air.max_read_write_textures", i32 8}}
!8 = !{{i32 7, !"air.max_samplers", i32 16}}
!9 = !{{ptr @{FULL}, !10, !11}}
!10 = !{{}}
!11 = !{{!12, !13}}
!12 = !{{i32 0, !"air.buffer", !"air.location_index", i32 0, i32 1, !"air.read_write", !"air.address_space", i32 1, !"air.arg_type_size", i32 4, !"air.arg_type_align_size", i32 4, !"air.arg_type_name", !"uint", !"air.arg_name", !"out"}}
!13 = !{{i32 1, !"air.thread_index_in_threadgroup", !"air.arg_type_name", !"uint", !"air.arg_name", !"t"}}
!14 = !{{i32 2, !"air.thread_index_in_simdgroup", !"air.arg_type_name", !"uint", !"air.arg_name", !"lane"}}
!19 = !{{i32 2, i32 8, i32 0}}
!20 = !{{!"Metal", i32 4, i32 0, i32 0}}
!21 = !{{ptr @{MASKED}, !10, !22}}
!22 = !{{!12, !13, !14}}
!23 = !{{ptr @{QUADS}, !10, !11}}
"#,
sums = halves(&SUM_OPERANDS),
products = halves(&PRODUCT_OPERANDS),
masks = masks.join(", "),
quads = quads_function(),
)
}
+4 -1
View File
@@ -10,7 +10,9 @@
//! both run ([`loop_kernels`]), the inputs and answer of the vector word-phase fixture the product's
//! interpreter test, the runtime's device test and the conformance suite all hold
//! ([`vector_word_phases`]), the dispatches and answer of the threadgroup-memory fixture the
//! runtime's device test and the conformance suite both hold ([`threadgroup_start`]), and the
//! runtime's device test and the conformance suite both hold ([`threadgroup_start`]), the `half`
//! simdgroup sums and products and Metal's answers to them, which the product's interpreter tests
//! and the runtime's device test both run ([`half_simd_reductions`]), and the
//! counter of a thread's user-space instructions the matrix's
//! instructions-per-draw records are measured with ([`instructions`]).
//!
@@ -32,6 +34,7 @@ use std::path::{Path, PathBuf};
use std::process::Stdio;
pub mod fuzz;
pub mod half_simd_reductions;
pub mod instructions;
pub mod linked_signatures;
pub mod litmus;
+1 -1
View File
@@ -85,7 +85,7 @@ pub fn metallib_2_2(functions: &[MtlbFunction<'_>]) -> Vec<u8> {
write(functions, &MtlbLinkage::default(), 0, Format::V2_2)
}
/// The container layout [`write`] writes.
/// The container layout [`write()`] writes.
#[derive(Clone, Copy, PartialEq, Eq)]
enum Format {
/// Today's toolchain's: format 2.9, `MDSZ` in every entry, an extended header.
+400 -3
View File
@@ -4,7 +4,7 @@
use crate::plan::{
seeded_words as words, Binding, BufferPlan, Constant, Dispatch, Expect, Filter, Grid, Plan,
SamplerPlan, Scaled, Source, TextureExpect, TexturePlan, Values,
SamplerPlan, Scaled, Source, TextureExpect, TexturePlan, TextureSource, Values,
};
use crate::{Result, Storage};
use metal2vulkan::metal::{PixelFormat, TextureType, TextureUsage};
@@ -21,7 +21,7 @@ pub struct Workload {
}
/// The authored workloads.
pub const WORKLOADS: [Workload; 40] = [
pub const WORKLOADS: [Workload; 53] = [
Workload {
name: "bandwidth",
plan: bandwidth,
@@ -150,6 +150,30 @@ pub const WORKLOADS: [Workload; 40] = [
name: "vote_loop",
plan: vote_loop,
},
Workload {
name: "row_tail_224",
plan: row_tail_224,
},
Workload {
name: "row_tail_27730",
plan: row_tail_27730,
},
Workload {
name: "row_tail_49",
plan: row_tail_49,
},
Workload {
name: "row_tail_224_private",
plan: row_tail_224_private,
},
Workload {
name: "row_tail_27730_private",
plan: row_tail_27730_private,
},
Workload {
name: "row_tail_49_private",
plan: row_tail_49_private,
},
Workload {
name: "constant_managed",
plan: constant_managed,
@@ -182,6 +206,34 @@ pub const WORKLOADS: [Workload; 40] = [
name: "bind_2000",
plan: bind_2000,
},
Workload {
name: "texel_buffer_r8_write",
plan: texel_buffer_r8_write,
},
Workload {
name: "texel_buffer_r8_read",
plan: texel_buffer_r8_read,
},
Workload {
name: "texel_buffer_r16_read",
plan: texel_buffer_r16_read,
},
Workload {
name: "texel_buffer_rgba16_read",
plan: texel_buffer_rgba16_read,
},
Workload {
name: "texel_buffer_bgra8_read",
plan: texel_buffer_bgra8_read,
},
Workload {
name: "texel_buffer_b5g6r5_write",
plan: texel_buffer_b5g6r5_write,
},
Workload {
name: "texel_buffer_b5g6r5_read",
plan: texel_buffer_b5g6r5_read,
},
];
/// A creation workload: objects of one kind made and released in turn (`Session::create`).
@@ -286,10 +338,39 @@ pub enum OwnRow {
/// command buffers held for room (`Metrics::held_for_room`). Every command buffer is to complete, and
/// each of B's to end after its signaller, or the row fails.
TwoQueues,
/// The kinds a long-running VM makes and releases all day, made and released together in each
/// of 200 iterations: a host memory import with a buffer over it, an exported block with a
/// buffer over it, a video surface of each decoder route the device exports (a dma-buf at the
/// VA-API layout, the host's opaque handle at NVIDIA's), as the replay player's video
/// surfaces are made, with a view of each plane at an index, its buffer and plane 0 kept past
/// the surface's release, as an exported surface's plane outlives it; a two-plane `RGBA8Unorm`
/// surface of the opaque handle whose plane 0 a pass renders beside another colour attachment
/// (a plane stand-in, where the device takes the plane as a linear colour attachment only in
/// a pass of planes alone); two render pipeline states; and two targets a pass each draws
/// into, then reads through a texture after a memory barrier, a Private one (an attachment
/// view, and a shadow on a device without the attachment feedback loop) and one over a Shared
/// buffer (a shadow where the device's linear image takes it in place, an image of no feedback
/// usage). Its gauges ([`OwnReport::gauges`]) are read settled after the 100th and the 200th
/// iterations, and after its device drops.
///
/// [`OwnReport::gauges`]: crate::run::OwnReport::gauges
ChurnAllDay,
/// The other kinds a program makes, made and released together in each of 200 iterations: a
/// compute pipeline state of one of 40 contents in turn, more than the device keeps stage
/// entries for; a pass that draws under a `Counting` visibility mode into a target of 4
/// samples and resolves it into a texture over a Shared buffer (a resolve image, where the
/// device's linear image of the texture takes no attachment usage); a texture over a buffer in
/// an exported block, which the device holds in an image of its own, read by a blit; a texture
/// in a heap of a Shared block, read by a blit, where the device places one; and an indirect
/// command buffer, executed whole in a pass of its own with a state made for indirect command
/// buffers, its commands as the commit resets them (each drawing nothing).
/// Its gauges, with the bytes of the preprocess regions the executions hold, are read as
/// [`ChurnAllDay`](Self::ChurnAllDay)'s are.
ChurnRest,
}
/// The rows of one runtime's own.
pub const OWN_ROWS: [Own; 5] = [
pub const OWN_ROWS: [Own; 7] = [
Own {
name: "idle_frees",
row: OwnRow::IdleFrees,
@@ -310,6 +391,14 @@ pub const OWN_ROWS: [Own; 5] = [
name: "two_queues",
row: OwnRow::TwoQueues,
},
Own {
name: "churn_all_day",
row: OwnRow::ChurnAllDay,
},
Own {
name: "churn_rest",
row: OwnRow::ChurnRest,
},
];
/// The kernel of a compute pipeline state row's warm-up
@@ -381,6 +470,13 @@ pub fn render_library_air() -> Result<Vec<u8>> {
assemble("examples/runtime_examples.ll")
}
/// The indirect command buffers' library's AIR bitcode: the owned fixture
/// `engine/icb_merged_indexed.ll`, whose `icb_indexed_vertex` and `icb_indexed_fragment` draw
/// the commands a kernel encodes, assembled by `llvm-as`.
pub fn icb_library_air() -> Result<Vec<u8>> {
assemble("engine/icb_merged_indexed.ll")
}
/// The public fixture at `file`, LLVM text, assembled by `llvm-as`.
fn assemble(file: &str) -> Result<Vec<u8>> {
let ll = metal2vulkan_devtools::fixtures_dir().join(file);
@@ -1178,6 +1274,106 @@ fn vote_loop() -> Plan {
}
}
/// Rows of 224 `float`s into a `Shared` buffer, four a thread (`row_tail`): every row starts at a
/// multiple of 16 bytes, and every thread writes four.
fn row_tail_224() -> Plan {
row_tail("row_tail_224", 224, Storage::Shared, 1)
}
/// Rows of 27,730 `float`s (2 mod 4) into a `Shared` buffer, four a thread (`row_tail`): every
/// other row starts at a multiple of 16 bytes, the others 8 past one, and a row's last thread
/// writes two.
fn row_tail_27730() -> Plan {
row_tail("row_tail_27730", 27_730, Storage::Shared, 1)
}
/// Rows of 49 `float`s into a `Shared` buffer, four a thread (`row_tail`): one row in four starts at
/// a multiple of 16 bytes, and a row's last thread writes one.
fn row_tail_49() -> Plan {
row_tail("row_tail_49", 49, Storage::Shared, 1)
}
/// [`row_tail_224`] into a `Private` buffer, 16 times the threads.
fn row_tail_224_private() -> Plan {
row_tail("row_tail_224_private", 224, Storage::Private, 16)
}
/// [`row_tail_27730`] into a `Private` buffer, 16 times the threads.
fn row_tail_27730_private() -> Plan {
row_tail("row_tail_27730_private", 27_730, Storage::Private, 16)
}
/// [`row_tail_49`] into a `Private` buffer, 16 times the threads.
fn row_tail_49_private() -> Plan {
row_tail("row_tail_49_private", 49, Storage::Private, 16)
}
/// `row_tail` over rows of `w` `float`s: about 381,000 threads times `scale` in threadgroups of
/// 1,024, as many rows as `ceil(w / 4)` threads a row make of them, each thread reading a `float4`
/// of a `Private` buffer and writing its lanes from column `4 (i mod threads a row)` of its row of
/// a buffer of `storage` and about 6.1 MB times `scale` that nothing else writes: the first lane,
/// then the three, two or one more the row holds.
fn row_tail(name: &str, w: u32, storage: Storage, scale: u32) -> Plan {
const THREADS: u32 = 381_952;
let per_row = w.div_ceil(4);
let rows = scale * THREADS / per_row;
let threads = rows * per_row;
let input: Vec<f32> = (words(15, 4 * threads as usize).into_iter())
.map(|word| (word & 0xFFFF) as f32)
.collect();
let mut output = vec![0u32; (rows * w) as usize];
for index in 0..threads {
let (row, col) = (index / per_row, (index % per_row) << 2);
let lanes = (w - col).min(4) as usize;
let at = (row * w + col) as usize;
let from = 4 * index as usize;
for lane in 0..lanes {
output[at + lane] = input[from + lane].to_bits();
}
}
let length = (4 * u64::from(rows * w)).next_multiple_of(16);
Plan {
name: name.to_owned(),
library: Source::Authored,
buffers: vec![
private(float_bytes(&input)),
BufferPlan {
length,
storage,
contents: None,
modified: None,
},
],
dispatches: vec![Dispatch {
blits: Vec::new(),
function: "row_tail".to_owned(),
linked: Vec::new(),
constants: Vec::new(),
bindings: vec![
buffer(0, 0),
buffer(1, 1),
bytes(2, word_bytes(&[w, per_row])),
],
grid: Grid::Threads {
threads: [u64::from(threads), 1, 1],
per_group: [1024, 1, 1],
},
}],
expect: vec![Expect {
buffer: 1,
values: Values::Words(output),
}],
textures: Vec::new(),
expect_textures: Vec::new(),
outputs: Vec::new(),
per_command_buffer: None,
per_encoder: None,
commit_to_complete: false,
frames: false,
scaled: None,
}
}
/// Reads of a 64 KiB table as constants (`constant_reads`): 2^20 threads in threadgroups of 256,
/// each folding 64 of the table's 4,096 entries into a word, the table `Managed`, and the first
/// 256 bytes of it written again by the CPU before each run and marked with `didModifyRange:`, as
@@ -1683,3 +1879,204 @@ fn texture_read() -> Plan {
scaled: None,
}
}
/// The texels of the texel-buffer workloads: 2^24, one a thread for a write and 16 a thread for a
/// read.
const TEXEL_BUFFER_TEXELS: u32 = 1 << 24;
/// A texture buffer (`MTLTextureTypeTextureBuffer`) of `pixel_format` and `usage` over the plan's
/// buffer 0, of [`TEXEL_BUFFER_TEXELS`] texels.
fn texel_buffer(pixel_format: PixelFormat, usage: TextureUsage) -> TexturePlan {
TexturePlan {
texture_type: TextureType::TextureBuffer,
pixel_format,
width: TEXEL_BUFFER_TEXELS,
height: 1,
array_length: 1,
sample_count: 1,
usage,
storage: Storage::Private,
source: TextureSource::Buffer { buffer: 0 },
texels: None,
bytes: None,
}
}
/// Writes of an `R8Unorm` texture buffer, one texel a thread (`texel_buffer_write`): each texel
/// the code its index's hash names, which its value `c / 255` stores. Where a device holds the
/// format's texels four to a word, neighbouring threads write one word.
fn texel_buffer_r8_write() -> Plan {
let codes: Vec<u8> = (0..TEXEL_BUFFER_TEXELS).map(texel_buffer_code).collect();
let stored = (codes.chunks(4))
.map(|word| u32::from_le_bytes([word[0], word[1], word[2], word[3]]))
.collect();
texel_buffer_write("texel_buffer_r8_write", PixelFormat::R8Unorm, stored)
}
/// The code `texel_buffer_write` writes at texel `i`: its index's hash.
fn texel_buffer_code(i: u32) -> u8 {
(i.wrapping_mul(2_654_435_761) >> 24) as u8
}
/// Writes of a `B5G6R5Unorm` texture buffer, one texel a thread (`texel_buffer_write`): each
/// texel's red, green and blue the value `c / 255` of its index's code `c` (the kernel's `float`
/// product of `c` and `1 / 255`), each channel of `n` bits its value times `2^n - 1` rounded to
/// nearest even, as Metal writes a normalized channel. A device that holds the format as words
/// writes two texels to a word, each by two atomics; one that holds it directly, its own view.
fn texel_buffer_b5g6r5_write() -> Plan {
let texels: Vec<u16> = (0..TEXEL_BUFFER_TEXELS)
.map(|i| {
let value = f64::from(f32::from(texel_buffer_code(i)) * (1.0f32 / 255.0f32));
let code = |bits: u32| (value * f64::from((1u32 << bits) - 1)).round_ties_even() as u16;
code(5) << 11 | code(6) << 5 | code(5)
})
.collect();
let stored = (texels.chunks(2))
.map(|pair| u32::from(pair[0]) | u32::from(pair[1]) << 16)
.collect();
texel_buffer_write(
"texel_buffer_b5g6r5_write",
PixelFormat::B5G6R5Unorm,
stored,
)
}
/// Writes of a texture buffer of `pixel_format` (`texel_buffer_write`), whose bytes, as words,
/// are `stored`.
fn texel_buffer_write(name: &str, pixel_format: PixelFormat, stored: Vec<u32>) -> Plan {
let bytes = crate::plan::element_bytes(pixel_format).unwrap_or(4);
Plan {
name: name.to_owned(),
library: Source::Authored,
buffers: vec![unset(u64::from(TEXEL_BUFFER_TEXELS) * u64::from(bytes))],
textures: vec![texel_buffer(pixel_format, TextureUsage::SHADER_WRITE)],
dispatches: vec![Dispatch {
blits: Vec::new(),
function: "texel_buffer_write".to_owned(),
linked: Vec::new(),
constants: Vec::new(),
bindings: vec![texture(0, 0)],
grid: Grid::groups_of_256(u64::from(TEXEL_BUFFER_TEXELS / 256)),
}],
expect: vec![Expect {
buffer: 0,
values: Values::Words(stored),
}],
expect_textures: Vec::new(),
outputs: Vec::new(),
per_command_buffer: None,
per_encoder: None,
commit_to_complete: false,
frames: false,
scaled: None,
}
}
/// [`texel_buffer_read`] of `R8Unorm`.
fn texel_buffer_r8_read() -> Plan {
texel_buffer_read("texel_buffer_r8_read", PixelFormat::R8Unorm)
}
/// [`texel_buffer_read`] of `R16Unorm`.
fn texel_buffer_r16_read() -> Plan {
texel_buffer_read("texel_buffer_r16_read", PixelFormat::R16Unorm)
}
/// [`texel_buffer_read`] of `RGBA16Unorm`.
fn texel_buffer_rgba16_read() -> Plan {
texel_buffer_read("texel_buffer_rgba16_read", PixelFormat::RGBA16Unorm)
}
/// [`texel_buffer_read`] of `BGRA8Unorm`.
fn texel_buffer_bgra8_read() -> Plan {
texel_buffer_read("texel_buffer_bgra8_read", PixelFormat::BGRA8Unorm)
}
/// [`texel_buffer_read`] of `B5G6R5Unorm`.
fn texel_buffer_b5g6r5_read() -> Plan {
texel_buffer_read("texel_buffer_b5g6r5_read", PixelFormat::B5G6R5Unorm)
}
/// Reads of a texture buffer of `pixel_format` (`R8Unorm`, `R16Unorm`, `RGBA16Unorm`,
/// `BGRA8Unorm` or `B5G6R5Unorm`), 16 texels a thread (`texel_buffer_sum16`), of seeded bytes: each thread's sum of
/// its texels' lanes, against the CPU's decode of the bytes (`c / (2^n - 1)` a channel, 1 for a
/// missing alpha).
fn texel_buffer_read(name: &str, pixel_format: PixelFormat) -> Plan {
let bytes = crate::plan::element_bytes(pixel_format).unwrap_or(4) as usize;
let length = TEXEL_BUFFER_TEXELS as usize * bytes;
let data: Vec<u8> = (words(29, length / 4).into_iter())
.flat_map(u32::to_le_bytes)
.collect();
let channels = |texel: &[u8]| -> [f64; 4] {
let u16_at = |i: usize| f64::from(u16::from_le_bytes([texel[2 * i], texel[2 * i + 1]]));
match pixel_format {
PixelFormat::R8Unorm => [f64::from(texel[0]) / 255.0, 0.0, 0.0, 1.0],
PixelFormat::R16Unorm => [u16_at(0) / 65535.0, 0.0, 0.0, 1.0],
PixelFormat::RGBA16Unorm => [0, 1, 2, 3].map(|i| u16_at(i) / 65535.0),
// Red in bits 11 to 15, green in 5 to 10, blue in 0 to 4.
PixelFormat::B5G6R5Unorm => {
let t = u16_at(0) as u32;
let field = |shift: u32, bits: u32| {
let max = (1u32 << bits) - 1;
f64::from(t >> shift & max) / f64::from(max)
};
[field(11, 5), field(5, 6), field(0, 5), 1.0]
}
// Blue, green, red, alpha in memory.
_ => [2, 1, 0, 3].map(|i| f64::from(texel[i]) / 255.0),
}
};
let sums: Vec<f32> = (data.chunks(16 * bytes))
.map(|texels| {
let total: f64 = texels.chunks(bytes).flat_map(channels).sum();
total as f32
})
.collect();
Plan {
name: name.to_owned(),
library: Source::Authored,
buffers: vec![
private(data),
unset(4 * u64::from(TEXEL_BUFFER_TEXELS / 16)),
],
textures: vec![texel_buffer(pixel_format, TextureUsage::SHADER_READ)],
dispatches: vec![Dispatch {
blits: Vec::new(),
function: "texel_buffer_sum16".to_owned(),
linked: Vec::new(),
constants: Vec::new(),
bindings: vec![texture(0, 0), buffer(0, 1)],
grid: Grid::groups_of_256(u64::from(TEXEL_BUFFER_TEXELS / 16 / 256)),
}],
expect: vec![Expect {
buffer: 1,
values: Values::Floats {
values: sums,
tolerance: TEXEL_BUFFER_TOLERANCE + 16.0 * narrow_channels(pixel_format),
},
}],
expect_textures: Vec::new(),
outputs: Vec::new(),
per_command_buffer: None,
per_encoder: None,
commit_to_complete: false,
frames: false,
scaled: None,
}
}
/// How far a texel-buffer read's sum may be from the CPU's: 64 values of at most 1, summed in
/// `float` in the kernel's order.
const TEXEL_BUFFER_TOLERANCE: f32 = 1.0 / 1024.0;
/// How far a texel of `pixel_format` read through its own view may be from the CPU's in all its
/// channels together: `PrecisionNote::DeviceTexelConversion`'s recorded bound (docs/API.md), 0.18
/// of a code for each 5- or 6-bit channel, which a device that widens it by replicating its bits
/// reaches (ANV, NVIDIA); an 8- or 16-bit code's one `f32` ulp is inside
/// [`TEXEL_BUFFER_TOLERANCE`]. A sum reads 16 texels.
fn narrow_channels(pixel_format: PixelFormat) -> f32 {
match pixel_format {
PixelFormat::B5G6R5Unorm => 0.18 * (2.0 / 31.0 + 1.0 / 63.0),
_ => 0.0,
}
}
Loaded 100 of 1099 files, more files were not shown because too many files have changed in this diff. Show more