Commit Graph
558 Commits
Author SHA1 Message Date
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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 1b3bd24aba Runtime: a Direct3D 11 plane past its import's maxExtent is Limit::TextureSize
A plane's extent was checked only against the image format query without the handle type
(plane_plan's prepare). VUID-VkImageCreateInfo-extent-02252 bounds an image's extent by
imageCreateMaxExtent, which for an image made with VkExternalMemoryImageCreateInfo is the query's
answer with VkPhysicalDeviceExternalImageFormatInfo naming the handle type: a device may make an
imported image smaller than a plain one, and a plane between the two would be created past the
limit.

The import query (d3d11::import_query) now answers the image's properties with the handle too, and
d3d11_plane_form checks the plane's extent against them once its usage and format list are
final: past it, Limit::TextureSize carries the import's maxExtent. The existing kind has the
same meaning (an extent past what the device makes of the image), so no new variant; its doc and
basis name the import's query, and docs/REFUSALS.md is regenerated (a second NoImport site, the
query failing at the final form, which the earlier checks make unreachable on a conforming
driver). The extent check itself is one function now (texture::size_within), the plain path's
included, unchanged there.

The Windows refusal test asks for a luma one texel wider than the import query's maxExtent and
expects TextureSize at that answer or the plain query's below it, printing both. On a device
whose two answers are equal the plain check refuses first, so that run does not show the import
check firing on its own.
2026-11-26 22:55:11 -08:00
Anees Iqbal 981d1c0d81 Runtime docs: a state drawn without the colours past its pass's last attachment, and its costs
README, Render encoders: a pipeline state that names colours past its pass's last colour
attachment, the rest of its formats and its sample count the pass's, is drawn as plain
Metal draws it (pass-pipeline-color-unattached, Apple M3 Max, macOS 27.0.1, job
m3-max-75903), through the state of its descriptor without those colours. The costs, each
from a run:
- the first such set and draw: about 3.3 ms once per state and pass shape on an RTX 5080
  Laptop card, from a proxy (a state of the same functions with colour 0 alone; jobs
  m3-max-75918 and m3-max-75925);
- each later such set: about 14,500 user-space instructions on lavapipe (job m3-max-75974,
  release, five runs, 14,510 to 14,517), where a set of a state that renders into its pass
  is 140;
- the descriptor each render state keeps: in states-only plays of two recorded replay
  streams on lavapipe it kept no library alive that was not alive without it (jobs
  m3-max-75968 and m3-max-75969: the bytes of released libraries still alive, at each
  change, equal at this tree and at its base, 29 and 140 changes).
The between shape stays refused (job m3-max-75934). The Gap::Draw list's "a pipeline state
whose formats are not the pass's attachments'" now excepts the shape drawn, and the
first-use list names that state's pipeline under first_use_unfinished_waits.

docs/REFUSALS.md is regenerated (refusal_surface.py): Gap::Draw gains its site in
render.rs (without_colors).
2026-11-26 20:48:06 -08:00
Anees Iqbal f6aa8dbdf1 Runtime: a dma-buf import is refused where the Shared type is not host-coherent
What: the dma-buf rule (import.rs, dma_buf_type) now takes the device's Shared
coherence, keyed by the query that already decides it (the Shared type's
HOST_COHERENT flag; the device holds a coherence state exactly where it lacks
it). On a device that holds one, every dma-buf is refused with the new
Limit::ImportCoherence { handle }, whatever the fd's query offers, before any
allocation: Device::import_dma_buf and Device::import_dma_bufs (each fd's rule;
the sparse buffer is destroyed, as for Limit::ImportType). Basis: device. The
pointer import (import_host_memory) is unchanged, so the consumer's fallback
imports those pages by pointer. No new route: the refusal sits inside the
existing rule.

Why: on a Meteor Lake GPU under Mesa's Intel driver and the i915 kernel driver
(no LLC), the fd's query offers type 0 (device-local, host-visible,
host-coherent, write-combined) first, so the rule took the import, and the
runtime never flushes an import because its type is host-coherent. That flag
speaks only for mappings Vulkan makes; the consumer writes the pages through
its own cached mapping. In Linux v7.3, i915_gem_prime_import
(drivers/gpu/drm/i915/gem/i915_gem_dmabuf.c:281-337) makes the object with
i915_gem_object_alloc (kmem_cache_zalloc, gem/i915_gem_object.c) and never calls
i915_gem_object_set_cache_coherency, so pat_index 0 and cache_coherent 0; the
only CPU-cache work is one wbinvd_on_all_cpus at get_pages where !HAS_LLC &&
!IS_DG1 (i915_gem_dmabuf.c:249-261, whose comment says only DG1 "still snoops
transactions even with CACHE_NONE"); on MTL PAT 0 is WB with no coherency. So
the GPU reads DRAM without the guest's lines still in the CPU cache: text and
images missing. The pointer import (userptr, I915_CACHE_LLC, PAT 3) snoops.
No Vulkan query says whether a driver's GPU mapping of a foreign dma-buf sees
the CPU's caches, so the Shared type's flag is a proxy that errs to the safe
side: where it refuses, the pointer route is coherent by its type's flag.

Docs: import.rs's header and both dma-buf calls' doc comments; coherence.rs on
imports; the runtime README's Shared memory's coherence ("Imported blocks take
no call"), Imported blocks (the rule, the proxy and its limit) and its known
gaps; docs/VALIDATION.md on the shared view; docs/REFUSALS.md regenerated; the
api_signatures table blessed (one variant added).

Tests: a_dma_buf_is_refused_where_the_shared_type_is_not_host_coherent (pure,
over Meteor Lake's i915 type list and the Iris Xe's);
every_device_under_the_view_refuses_a_dma_buf_and_imports_host_memory (device,
through the refused device's view); the existing dma-buf device tests take the
new refusal. Verified at this commit: cargo fmt only; the build, the pure
tests and the device run are in the jobs the lane reports.
2026-11-26 11:51:26 -08:00
Anees Iqbal b6a57f7958 Translator: LoweringInputs::srgb_storage writes an 8-bit sRGB texture through its UNORM twin
What: a new LoweringInputs field, srgb_storage, names texture slots whose texture is an 8-bit sRGB
texture held for storage through its UNORM twin's view. Such a slot, where storage_images names
no choice for it and its image class is float, declares its storage image without a format, of
class SrgbEncode: a write encodes red, green and blue by the MSL transfer (8.7.7) through the
device's conversion and keeps alpha linear, recording PrecisionNote::DevicePackConversion, and a
read decodes. A device that cannot write or read storage without a format refuses it as
Feature::Format. Under the identity domains the slot's element is the storage array's element of
its declaration's class, as an Unknown-format storage slot of class SrgbEncode now is.

Why: a guest dispatch writes a write-only BGRA8Unorm_sRGB storage texture hundreds of times a
session, and no device the runtime runs on stores an sRGB format; the runtime refused it
(Gap::StorageElement). The runtime's kernels compile from LoweringInputs, not VariantKey, so the
resident-table domain's srgb_textures and storage_images (another meaning) are not reused.

The compile key appends srgb_storage only when it is non-empty, so no existing key moves and no
version is bumped; with the field empty nothing a translation emits changes.

Verified: not yet built; the lane's quick check and suites run next. api_signatures.tsv is
blessed (one record) and docs/REFUSALS.md regenerated (one Feature::Format site more).
2026-11-25 18:08:49 -08:00
Anees Iqbal 31b3470a3e Bitcode: read the pre-LLVM-4 metadata and typed-pointer records of AIR 1.8
A game launcher's metallib (AIR 1.8, language 1.1) parses since the container fix, but each
of its 7 functions stopped in the bitcode reader at METADATA_STRING_OLD. A structure-only census
of its 7 modules (job m3-max-73828) found six refused forms in all and nothing else unknown:
METADATA_STRING_OLD, METADATA_KIND inside the METADATA block, METADATA_OLD_NODE,
FUNC_INBOUNDS_GEP_OLD, LOAD without its type, and CALL without the explicit-type flag.

Each is now read as LLVM's reader reads it at llvmorg-23.1.2:

- STRING_OLD (MetadataLoader.cpp:2424-2433): one MDString of the operands as bytes, the next
  metadata id. Its llvm.vectorizer. loop-key upgrade (AutoUpgrade.cpp:6979-7026) renames keys
  the IR keeps in neither spelling, so the decoded loop hints are unchanged.
- KIND in the METADATA block (2457, parseMetadataKindRecord 2631-2643): the METADATA_KIND
  block's record. Both places now refuse a record with fewer than 2 operands and a kind id
  stated twice, as LLVM does.
- OLD_NODE (1401-1428): a uniqued node of (type, value) pairs. A metadata-typed operand is a
  metadata id, a void one is null, and any other is the module value of that type and id, as
  ValueAsMetadata. LLVM numbers no id for such a value; the arena keeps one Md::Value entry per
  value after the block's own ids, and MdIds moves every id LLVM numbers later (later module
  blocks, function blocks, attachments, call operands) past them.
- INBOUNDS_GEP_OLD (BitcodeReader.cpp:5383-5450), LOAD (6418-6436) and CALL (6886-6964)
  without their types: the source element, loaded or function type is the pointer operand's
  contained type. The reader follows LLVM's type ids (getContainedTypeID, 1510;
  getVirtualTypeID, 1532) for every value: TypeIds keeps the virtual ids for pointers made by
  alloca, GEP and the module's globals and functions, shuffles and cmpxchg; each instruction's
  result takes the id LLVM's reader gives it.

Still refused, by name: METADATA_OLD_FN_NODE; KIND and OLD_NODE in a function's block; an
OLD_NODE value in a module block after one whose old nodes kept values; a load atomic without
its type; GEP_OLD (not inbounds) and STORE_OLD. None is in the file. A typed-pointer load, call
or GEP whose operand has no contained type (an opaque pointer, a non-pointer) is BadType or a
malformed record.

Tests: typed_pointer_records_without_their_types_read_as_with_them decodes one typed-pointer
module in both spellings (a struct field, an array element, a loaded pointer, a cast, an
argument, and a function whose record names a pointer to its type) and asserts the tables are
equal, plus the refusals. legacy_metadata_records_read_as_their_modern_twins decodes the
function-test module with its metadata in the old records, asserts the body equals the modern
twin's, the arena's layout, and the shifted ids in a second module block and in a function
block, plus each refusal. Both fail without the fix: the old records were refused. The tests
that asserted those refusals now assert the remaining ones (OLD_FN_NODE).

docs/REFUSALS.md regenerated. Not yet run at this commit: the suite job follows.
2026-11-25 13:14:58 -08:00
Anees Iqbal 5a722b5c3f Stencil output: a device without VK_EXT_shader_stencil_export draws it by bits, the owner's tenth form
A fragment function's [[stencil]] output is the reference of both faces' stencil test for its
fragment (MSL Table 5.7, 5.2.3.5). On a device without VK_EXT_shader_stencil_export it was refused
at creation (StencilExport). Under the owner's grant (rule 2's tenth form, chosen by that
extension's query alone), such a device now draws it by bits; a device with the extension is
unchanged (FragStencilRefEXT, no fact, no note, the draw issued once).

Translator: the function stores no reference; each return kills the fragment where the draw's new
push field PushField::StencilBit k is below 8 and bit k of the output's low 8 is 0, and keeps
every fragment at 8 or more (one module, no specialization). The function states
RuntimeFact::StencilBitDraws (Mechanism::PushConstant) and its fragment stage the static note
PrecisionNote::StencilOutputOverlap. Refused there, naming the extension (Unsupported
StencilExport): a function that also writes a colour (the colour would be written by every
repeat) or memory, one whose returns cannot kill (an interlocked body, a loop over its covered
samples), a mesh pipeline, and a render pipeline made for indirect command buffers. Where the
device also lacks the pixel interlock, a function writing memory in a raster order group meets
that refusal first (RasterOrderGroups). SEMANTICS_VERSION 2301 -> 2302, ARTIFACT_FORMAT_VERSION
595 -> 596 (new codec members).

Runtime (depth_stencil::BitDraws, render_encoder::draw): with w the low 8 bits of the write masks
of the faces having a Replace operation, a draw whose stencil test is on and w is not 0 is drawn
once with every fragment kept under the reference 0 (Replace zeroes w's bits, every other
operation runs once), then once per bit k of w keeping the fragments whose output holds bit k,
under the reference 255, write mask (1 << k) & mask, Replace kept and every other operation Keep,
and no depth write; where the state writes depth under a compare other than Always and Never, the
first draw writes none and a last draw writes it with stencil write masks of 0. Each draw records
only the dynamic state that differs from the last; the encoder's tests and reference are recorded
again at the next draw. Counted in Metrics::stencil_bit_draws (the draws beyond the first).
Refused at a draw, Gap::Draw of DrawKind::StencilOutput: a face compare other than Always or Never
(the output decides that test), and, where w is not 0, a draw inside a Counting visibility
segment (every draw would add its samples). A Boolean segment is drawn. Vulkan Appendix I: the
repeats change stencil reference, operations and write masks between draws of one pipeline,
which Rule 2 lists as required (write masks) and strongly suggested (stencil parameters) to be
invariant; the note records the one difference the repeats make.

The note (rule 1): fragments of one draw that overlap leave the OR of their values. Where two
fragments of one draw reach one sample under Replace, the sample stores the OR of their outputs'
low 8 bits within the write mask, where Metal stores the later fragment's value; under a depth
test that writes, each fragment's stencil operation is chosen against the depth from before the
draw. Measured on an RTX 3090 (NVIDIA 620.70.06) under the validation layer 1.4.363.0, job
m3-max-73635: two triangles of one draw outputting 0x35 then 0x4a store 0x7f on the 32 texels both
reach, where Metal stores 0x4a, and 0x35 on the 32 one reaches, in 8 bit draws; the 780M (RADV)
and the Iris Xe (ANV), which list the extension, store 0x4a with 0 bit draws.

AGENTS.md rule 2: "for nine only" becomes "for ten only", the list ending with fragment stencil
output (the planner's text, relayed by main, word for word).

Tests: the translator's engine_stencil (every committed profile: the extension or the draws by
bits, L3 both ways; refusals for colour, memory, mesh and indirect command buffers); rt's host test
of BitDraws::of; rt's device cells (stencil_export.rs): the stencil alone and the stencil with the
depth under Always and Less over a quad, exact, texels of stencil 0 among them; the overlap row;
the refusals; the route of a 4-sample Depth32Float_Stencil8 source read at sample 0 into a
single-sample target under Always/Replace 0xff and depth Always with write, beside colour 0
RGBA8 of write mask none; the codec round trip; the mechanism table.

Docs: docs/API.md (the stencil output passage and the catalogue entry
metal2vulkan-degrade-stencil-output-overlap), rt README known gap and floor row,
docs/REFUSALS.md regenerated, api_signatures blessed. The conformance degradation and the
validation allowance (unbounded) of the note. known-gaps-rt.tsv: stencil-output and
stencil-output-loaded on NVIDIA, refused at renderCommandEncoder (draw 3's back face Equal against
the output) and divergent at case/stencil as a result. runtime-sources.sha256: the guard's inputs
changed only by mechanism.rs gaining the new fact's arm, which no existing artifact states, so no
run of an existing artifact changes.

Golden rows and the engine inventory (22 cells) are re-blessed on development: 20 move from the
StencilExport refusal to a module (stx_stencil_by_pixel, stx_stencil_discard,
stx_stencil_with_depth, stx_stencil_ms_by_sample, fragment_depth_stencil on nvidia-pascal-linux,
nvidia-rtx50-linux, nvidia-rtx5080-laptop and runtime-floor), and the 2 cells
stx_stencil_in_order and stx_stencil_ms_in_order on runtime-floor move from StencilExport to
RasterOrderGroups, still refused. Why: the memory-write refusal now runs on the emitted module
(pipeline/compile.rs), after the body's own refusals, so on a profile without the pixel interlock
the raster order group these functions write memory in is refused first; at the base the plan's
entry refused every [[stencil]] output on such a device before any body was lowered.

Verified (this tree, or the rt archive of d6bd77d203 where named; the rt and translator sources
there differ from this tree in the translator's test and a doc comment alone):
- msi check, job m3-max-73648 (this tree): fmt, signatures, refusals, clippy -D warnings with all
  features plain, --cfg m2v_gpu and --cfg m2v_cpu_icd, Rustdoc, the rt nextest archive and the
  conformance binary built; rt's whole suite on lavapipe under the validation layer 1.4.363.0,
  738 tests run: 738 passed, 3 skipped; the lavapipe leg, 7 tests run: 7 passed: export enabled,
  the overlap row storing {4a}, bit draws 0 on every cell.
- RTX 3090 (NVIDIA 620.70.06, layer 1.4.363.0), job m3-max-73635 (d6bd77d203): 7 passed; the
  overlap row above, bit draws 8; the stencil alone and with depth under Always and Less, 64
  texels exact, bit draws [8, 8, 9]; the route exact, bit draws 8; refused a colour beside the
  stencil (StencilExport), Equal and a Counting segment (DrawKind::StencilOutput), a Boolean
  segment drawn. Conformance stencil-output and stencil-output-loaded: refused at
  renderCommandEncoder and divergent at case/stencil (4 elements, largest difference 80), the
  four known-gaps rows.
- RTX 5080 Laptop GPU (NVIDIA 615.71.09, layer 1.4.363.0), job m3-max-73652 (this tree): 7
  passed; overlap {7f} where both reach, {35} where one, bit draws 8; cells exact, bit draws
  [8, 8, 9]; the route exact, bit draws 8; the same refusals; conformance replay with this tree's
  binary matched the four NVIDIA rows (exit 0).
- Radeon 780M (RADV, Mesa 26.2.6), job m3-max-73636 (d6bd77d203), and Iris Xe (ANV, Mesa
  26.2.6), job m3-max-73650 (this tree): 7 passed each, export enabled, overlap {4a}, bit draws 0.
- States-only plays of recorded streams, base 0c9db49765 against d6bd77d203, every play in
  states-only mode, made and refused equal, refused 0: lavapipe, jobs m3-max-73632 and
  m3-max-73631 (two streams: render 10643 and 9014, compute 15299 and 221); the RTX 3090 with
  --device-type gpu, job m3-max-73638 (two streams: render 9834 and 10643, compute 214 and
  15299); the RTX 5080, job m3-max-73652 (two streams: render 9014 and 9645, compute 221 and
  250). Those two carry a library holding a [[stencil]] function that no recorded pipeline state
  uses; no stream on either NVIDIA node makes a [[stencil]] pipeline (job m3-max-73646 and
  m3-max-73652's scan).
- Owed: the translator and validation suites of this tree (the suites of d6bd77d203, job
  m3-max-73627, failed in the memory refusal's test on runtime-floor, the runtime guard's hash
  and the golden and inventory cells above; this tree fixes the first two).
2026-11-25 10:38:03 -08:00
Anees Iqbal 3c52ee1cf1 Render pass: a colour attachment renders one depth plane of a 3D texture's level
What: RenderPassColorAttachmentDescriptor takes `depth_plane` (Metal's `depthPlane`). A 3D
texture of RenderTarget usage is made 2D-array-compatible (VK_IMAGE_CREATE_2D_ARRAY_COMPATIBLE_BIT,
in its image format query too: Plan::flags, from the image's type and its colour attachment usage,
no query). attachment_view then takes the plane of a 3D texture's level as a 2D view of that one
layer (base layer = depthPlane, at the level), checked against the level's depth
(Refusal::AttachmentPlace past it). Every barrier on a 3D texture's image (its attachment's, its
copies' and its moves', texture::barrier_layers) names the image's layers as 0 and
VK_REMAINING_ARRAY_LAYERS, so each moves every plane of the level it names. Before, every such pass
was Gap::RenderPass of RenderPassKind::TextureType.

Still TextureType: a 3D texture in a layered pass (renderTargetArrayLength 2 or more), a depth or
stencil attachment of a 3D texture, a 3D resolve texture, and a resolve's depth plane but 0. A draw
that reads, through a shadow (a device without the attachment feedback loop), a 3D texture whose
plane its pass renders is Gap::Draw of DrawKind::AttachmentRead: a shadow's copies are of layers.
The floor asks a device that lists VK_KHR_portability_subset for imageView2DOn3DImage too
(VUID-VkImageCreateInfo-imageView2DOn3DImage-04459), as it asks multisampleArrayImage.

Why: a guest route meets the refusal. A browser's GL layer clears every 3D texture of an RGB-family
format (RGB8, RGB16F) at creation through a pass on each plane, to set the alpha it emulates; it
also renders into a plane for framebufferTextureLayer(TEXTURE_3D, k) then a clear or a draw, for a
level sampled before a full upload, and for copyTexSubImage3D. The consumer's route showed the key
at 205c8d2398 ("a render pass with TextureType is not built", colour 0 RGBA8Unorm Type3D 32x32x4,
usage 0x7, Managed), and every route that renders into a 3D texture read 0.

Metal (MTLRenderPass.h): `depthPlane` is "The depth plane of the texture to be used for rendering.
Default is zero."; Apple's page for the property, as fetched: "If the texture isn't a 3D texture,
then Metal ignores this property." Every Mac renders into a 3D texture's plane, with nothing to ask,
so it is built.

Vulkan (1.4.366): VK_IMAGE_CREATE_2D_ARRAY_COMPATIBLE_BIT "specifies that the image can be used to
create a VkImageView of type VK_IMAGE_VIEW_TYPE_2D or VK_IMAGE_VIEW_TYPE_2D_ARRAY" (core since 1.1);
the image is 3D (VUID-VkImageCreateInfo-flags-00950) and not sparse (-09403); the format query takes
the same flags (Image Creation Limits). The view is 2D, one level
(VUID-VkImageViewCreateInfo-image-04970), its base layer below the level's depth (-02724, -02725),
of an image made with the flag (-06728).
Such a view "can be used as a framebuffer attachment that refers only to the specified range of
slices of the selected mip level" (VkImageSubresourceRange). Dynamic rendering refuses only a 3D
view type (VUID-VkRenderingAttachmentInfo-imageView-12470). The runtime does not enable
maintenance9, so a barrier on the image moves the whole level
(VUID-VkImageMemoryBarrier2-subresourceRange-01488); with maintenance9 its layers would name depth
slices (-maintenance9-10798), and the layer count that names the whole level either way is
VK_REMAINING_ARRAY_LAYERS, which the validation layer asks for on such an image
(WARNING-VkImageSubresourceRange-layerCount-compatibility, met on lavapipe with layerCount 1, job
m3-max-73446). Load and store "only update values within the defined render area" of the view's
plane. The view is bound to no descriptor
(VUID-VkDescriptorImageInfo-descriptorType-06713).

Portability: KosmicKrisp, Mesa 26.3.1's source (src/kosmickrisp/vulkan), names no portability
subset, so the M3 device is not asked: a source read, unaudited at run time. MoltenVK reports
imageView2DOn3DImage (profiles/moltenvk-m3.json) and is below the floor anyway.

Conformance: the suite's `layered-attachment-places` crosses `depthPlane` over a 3D target of three
planes, recorded on Metal. Its runtime side now sets a colour attachment's `depth_plane` (a depth or
stencil attachment's plane stays Unavailable), and its twelve known-gaps-rt.tsv rows go.
docs/REFUSALS.md, docs/METAL-COVERAGE.md (depthPlane implemented), docs/CONFORMANCE-COVERAGE.md and
api_signatures.tsv are regenerated.

Tests:
- tests::depth_planes (device cfgs): RGBA8Unorm and RGBA16Float, ShaderRead | ShaderWrite |
  RenderTarget, Managed, an 8 x 8 x 4 texture of two levels (the second 4 x 4 x 2) and an 8 x 8 x 1
  one, every plane written first by replace_region. One command buffer: level 0's plane 2 cleared
  and drawn, level 1's plane 1 cleared and drawn, level 0's plane 0 loaded and drawn, level 0's
  plane 1 cleared alone, the one-deep texture cleared and drawn; every plane of both levels copied
  out and sampled at each texel's centre through a nearest sampler state (level 1 through a 3D view
  of it). A plane past level 1's depth is AttachmentPlace, a pass of two layers TextureType.
  tests::layouts records each rendering's colour attachment's view type and range and its image's
  type and create flags, which the cell asserts and prints.
- tests::floor: the portability features asked and enabled include imageView2DOn3DImage.
- The validation layer, which every device test runs under and which fails a test on any warning,
  holds the barriers: without barrier_layers the cell drew
  WARNING-VkImageSubresourceRange-layerCount-compatibility on lavapipe (job m3-max-73446).

Verified (tree of this commit, run as f748e9e8d2 on development 6047a2d8b6):
- msi, lavapipe (Mesa 26.2.4), job m3-max-73464: fmt, clippy (no cfg, m2v_gpu, m2v_cpu_icd),
  rustdoc, the refusal, signature, Metal-coverage and conformance-coverage checks all exit 0; the
  runtime's suite under the validation layer 734 passed, 3 skipped (the cell among them); the
  conformance crate's suite 1037 passed; `conformance replay --cpu` exit 0, the ledger exact,
  layered-attachment-places "announced" (the native-nan-encoding degrade notice alone).
- One leg a vendor, a nextest archive and the conformance command built on msi (job
  m3-max-73466), under the Khronos validation layer 1.4.363.0: the cell (its form printed: a 2D
  view, base layer the plane, at the level, of a 3D image made with 2D_ARRAY_COMPATIBLE, 0x28 for
  RGBA8Unorm with MUTABLE_FORMAT, 0x20 for RGBA16Float; every plane of both levels and of the
  one-deep texture exact, copied out and sampled), the blit, floor, layouts, layered, no
  attachment, over, pass, render, resolve, shadow, texture, view and depth/stencil route and copy
  families (123 tests), and `conformance replay --gpu` (exit 0, the ledger exact,
  layered-attachment-places "announced" as on lavapipe):
  - Intel Iris Xe (ANV, Mesa 26.2.6), job m3-max-73476: cell passed, 123 passed, replay exit 0.
  - AMD Radeon 780M (RADV PHOENIX, Mesa 26.2.6), job m3-max-73477: cell passed, 123 passed,
    replay exit 0. (The XTX's node was held by another job for 47 more minutes.)
  - NVIDIA RTX 3090 (620.70.06), job m3-max-73478: cell passed, 123 passed, replay exit 0.
2026-11-24 01:35:19 -08:00
Anees Iqbal b573e68c11 rt: a Direct3D 11 plane's texture is made by one function of an explicit usage and format list
What: import_d3d11_surface derives every plane's usage and list first (d3d11_plane_form, from
the bind flags and the descriptor, its refusals before any plane is made), then makes each plane's
texture through d3d11_plane_texture(plane, usage, list, unit): the image of the plane's format
with that usage, mutable over that list where it is not empty, imported, bound, and the texture
over it under the plane's descriptor at its index. A plane's error drops the textures made before
it, which frees their images. A test can call the same function with other values, so a cell can
make an image the old way over the same Direct3D 11 texture and read it beside the import's,
with nothing of the old form in product code. docs/REFUSALS.md names the new site functions.

Docs: a plane is viewed in place in the image's own format, the descriptor's and the descriptor's
sRGB sibling. A view in another format has no in-place form on the import
(Gap::TextureView of SurfacePixelFormat), and the consumer takes the copy form of the same call
for it, a counted copy of the plane: the README's plane paragraph and a new entry in the known
gaps of memory blocks say so.

Correction to d310504408: it says the import never receives a view in another format. The
consumer does view a drawn plane (PixelFormatView) on the import itself in any format the guest
asks (surface_shapes.rs:233 and 247-257), so the narrow list does refuse views a guest reaches.
The ruling: the narrow list stays, and the consumer routes a texture over a drawn plane viewed in
another format to its counted copy shape.

Still owed on the same principle: the chroma's uint/unorm pair (R16_UINT under RG8Unorm, R32_UINT
under RG16Unorm) is the one reliance left past the texture Direct3D 11 made, besides the sRGB
sibling and the feedback usage. It is its own row, behind the diagnostic, and goes once the
consumer makes chroma R8G8_UNORM or R16G16_UNORM.

How verified: refusal_surface.py --check passes here. The Windows cross-build, the runtime's
checks, and the device run on the lab's Windows host (red at the parent, green here) are reported
with their job ids to the lander.
2026-11-23 21:13:22 -08:00
Anees Iqbal ed4b0ecd76 rt: storage textures written or read at a run-time level, through runs of set 1's level elements
What: under the identity domains a storage slot written, read or size-queried at a level other
than the constant 0 indexes a run of set 1's storage-image array instead of being refused as
Unsupported{IdentityDomains} ("an encoder value the function reads as TextureLevels(S)"). The
translator pushes the bound texture's level count (PushField::TextureLevels) and the run's first
element (the new PushField::TextureLevelBase, beside it), states no StorageTextureLevels or
StorageTextureLevelViews fact, and an access at level l takes element
first + min(l, max(n, 1) - 1) of the array, NonUniform, inside l < n. A texture of one level
pushes its own index, nil 0 with count 0.

The runtime's binding 1 grows by 65,536 level elements past its 65,536 textures, 4,096 runs of 16
(floor::LEVEL_ELEMENTS, floor::LEVEL_RUN). The first dispatch or draw that binds a texture of more
than one level to such a slot (the encoder's checks, compute and render stages alike) gives it a
run: a single-level storage view of each level, of its storage element's type (a cube's level as
the 2D array of its faces, a view's from its own first level), written at the run's elements. A
later bind takes the texture's lock and pushes the same two words: no Vulkan call. The run goes
back through the pool and reaper once the texture is released and its work retired: elements null,
views destroyed (Gauges::level_elements). Every run held, or a texture of more than 16 levels, is
the new Limit::LevelElements { max: 4096 }, and the dispatch or draw does not run. The floor's
storage-image limits and both totals rise by 65,536: storage 196,608, per-stage resources 327,688,
pools 351,680; every lab device's profile is far above (llvmpipe 1,015,808 storage, the least).

SEMANTICS_VERSION and ARTIFACT_FORMAT_VERSION bump in the branch's last commit (a new PushField).

Why: 17 guest kernels in 6 libraries were refused at state creation by this form.

Docs: REFUSALS.md and the signatures table regenerated, RESOURCE-ID.md (binding 1 past 65,536),
API.md (storage levels under identity), the runtime README (Set 1, the floor table, the known-gap
line replaced by the Limit), the runtime-floor profile's limits, and the conformance ledger's
level-sizes-storage row removed.

Checked by: engine_texture_levels' identity test and the runtime's storage_levels device tests
(red at 6ad1c33124: jobs m3-max-70886 and m3-max-70892 on lavapipe), engine_identity's
a_storage_slot_written_at_a_run_time_level_is_an_element_of_its_run; the lane's jobs report the
runs per card.
2026-11-23 09:04:38 -08:00
Anees Iqbal 312f2866a9 rt: a shader-write texture whose own format does not store takes the storage usage for its views of a format that does
A texture made for shader writes in a format the device does not store (the 8-bit sRGB formats on
every committed Vulkan profile), written through a view of a listed format the device does store
(its unorm sibling), was Gap::StorageElement, case Absent: the image never had the storage usage,
so the view had no storage element. Metal writes it.

The texture's image now takes the storage usage for those views, with
VK_IMAGE_CREATE_EXTENDED_USAGE_BIT (Vulkan 1.1: a usage "supported for at least one of the formats
a VkImageView created from the image can have"), where the device's image format query makes that
image. The decision is the image's, at its creation, from the existing queries alone:

- plan() plans the texture extended where its usage has shader write, it is not multisampled, its
  own format does not store and a format it lists for its views does (view_formats now says so);
  it keeps the extended plan only where the query made it with exactly the plain plan's usage plus
  the storage usage and the same resolves, attachment reads and cube flag (Plan::keeps), else it
  makes the plain plan, as before;
- in place over a buffer (check_over), the linear image is extended where the linear query makes
  it and each listed format's linear tiling holds what storage keeps of its optimal tiling; where
  the plain linear image holds but the extended one does not, the texture stays in place, plain,
  and no copy is made for it. The counted copy form, where a texture over a buffer already took
  it, takes the plan the optimal query took;
- an extended image is at home in the general layout (a storage view's), and its own format's
  views take the usage that format holds (VkImageViewUsageCreateInfo,
  VUID-VkImageViewCreateInfo-usage-02275), so the texture's own sRGB views carry no storage usage;
- a surface plane's image keeps the surface's own rule and is never extended.

What the storage usage costs these images, where the query can say: nothing. Plan::keeps takes the
extended image only where the query keeps every other usage, flag and sample count, so no usage is
ever dropped for it; the test prints each device's image usage. What the query cannot say
(compression or a slower layout for the general home on a given driver) is unaudited.

Where the device does not make the texture extended (optimal query plainly, or in place where the
linear query refuses the extended image and the plain one holds), the texture is made as before and
the dispatch is still Gap::StorageElement, now with the new case StorageElementCase::Unextended in
place of Absent: the view's format is one the device stores and the image lists it, so the gap is
the image's missing extension, not the format's storage. A consumer log then tells "the device
made no extended image" from "the format has no storage on this device". Absent stays for the
texture's own views and for views of formats the device does not store; a surface plane's view is
never Unextended (its image is made by the surface's rule).

The test every_device_writes_an_srgb_texture_through_its_unorm_view now names
StorageElementCase::Unextended in its refused arm. docs/REFUSALS.md (the sites' function renamed
plan -> planned) and the API signatures table (the new variant) regenerated; the runtime README's
view-format and storage-element entries describe the rule.
2026-11-23 04:27:21 -08:00
Anees Iqbal f3bb94275b rt: a bind of a texture reached through its views alone to a texture slot is TextureWithoutIndex
A texture made with no index although its usage reaches shaders (Device::new_texture_for_views,
Device::new_heap_texture_for_views, a surface's or a Direct3D 11 surface's plane made with no
index) is reached through its views, each with an index of its own. Bound directly to a
function's texture slot, a dispatch or draw pushed its resource id, index 0, set 1's null
descriptor, so every read answered zero with no refusal (the consumer saw a D3D11 luma plane read
0.0 for every texel this way). ComputeCommandEncoder::set_texture and RenderCommandEncoder's
set_vertex_texture and set_fragment_texture (the runtime's only texture-slot binds) now refuse it,
binding nothing: Refusal::TextureWithoutIndex { index }, the slot's index. The check reads the
texture's own stored facts at the bind (no index, and its descriptor's usage reaching shaders by
the creation rule); nothing is looked up and nothing runs per draw or dispatch.

A texture no shader reaches (a depth or stencil target whose usage asks neither shader reads nor
writes) also has no index, and still binds: Metal binds it, its usage asks no shader read, and a
read of it answers the null descriptor. The previous commit's test expected that case refused;
it now expects it bound, so a guest's bind of such a texture to a slot its function does not read
meets no refusal.

Texture::gpu_resource_id says what an index-free texture's id is (index 0) and that a shader
reading it from bytes (an argument buffer) reads the null descriptor; nothing refuses that, as
the call returns a ResourceId. ResourceId's encoding is unchanged. The runtime has no argument
encoder, no texture-slot range call and no indirect-command texture bind, so the binds are the
whole Result-returning surface; an attachment read of an index-free texture is already
Gap::Draw (FetchedAttachment).

REFUSALS.md and basis.rs regenerated; the runtime README's texture and compute-encoder entries
updated.
2026-11-23 02:54:00 -08:00
Anees Iqbal eb275a1e87 rt: Refusal::TextureWithoutIndex, and a test that binds a texture made without an index (red)
A texture made without an index (Device::new_texture_for_views, a surface or Direct3D 11 plane
with no index, a depth or stencil target no shader reaches) bound to a function's texture slot
pushes resource id 0, set 1's null descriptor, so every read answers zero with no refusal. This
commit adds the refusal the binds will return, its basis line, REFUSALS.md and the signature
table, and the device test bind_without_index, which binds such textures to compute, vertex and
fragment slots and expects the refusal with the slot's index. The binds do not refuse yet, so the
test is red here; the next commit makes them refuse.
2026-11-23 02:54:00 -08:00
Anees Iqbal f17e07ad07 rt: StorageElement names its case and backing; PartialThreadgroups and ThreadgroupMemory name their site and static bytes
A refusal's sentence stays as it was (the known-gaps ledger keys on it); the new facts are typed
fields.

- Gap::StorageElement gains `case` (StorageElementCase: Absent, WriteWithoutFormat,
  ReadWithoutFormat) and `backing` (TextureBacking: Texture, Buffer, SurfacePlane, D3d11,
  Drawable; a view answers its parent's). TextureObject::storage_gap computes both at the four
  sites, and use_resource keeps it for a declared write. SurfaceImage's `general` flag, which only
  a Direct3D 11 import set, is named `d3d11`, and a surface plane's image keeps it.
- Gap::PartialThreadgroups gains `site` (PartialThreadgroupsSite): VoteWord { static_length, max }
  where the translator refused the variant for its vote word, Translator for its other refusals,
  SimdGroups { width } where the threadgroup is not whole SIMD groups of the variant. The cache
  directory keeps why with the refusal (m2v-refused-vote beside m2v-refused), so a warm boot names
  the site too.
- Limit::ThreadgroupMemory gains `static_length`, the state's staticThreadgroupMemoryLength.
- The translator's vote-word refusal is built through Unsupported::needs_any_of, so the refusal
  table derives its basis.

docs/REFUSALS.md and the api_signatures table are regenerated. Tests: the scan test's shape (i)
at 32,768 reads Limit::ThreadgroupMemory with static_length 0 and the limit; shape (ii) reads
PartialThreadgroups at the VoteWord site with its 32,768 static bytes against the limit; the
vote-word test reads the static length; storage_element, texture_buffers and read_write_tier read
the case and backing. Not yet run.
2026-11-23 02:31:24 -08:00
Anees Iqbal 80187ce5d1 Refusals: the three program-scope shapes Metal was measured to take declare metal-takes
ProgramScopeResource, ProgramScopeSharedSlot and ProgramScopeLinked are refusals Metal does not
make: an Apple M3 Max under macOS 27.0.1 runs each (potluck jobs m3-max-70268 and m3-max-70306).
Each declares it as its doc comment's last line, so the refusal surface counts them under
metal-takes (3 translator rows, from 0). ProgramScopeRead stays derived (ours): Apple's compiler is
not seen to write such a read. docs/REFUSALS.md regenerated; refusal_surface.py --check passes.
2026-11-23 00:51:11 -08:00
Anees Iqbal 058fd25a7b Translator: MSL 3.2 program-scope buffer bindings become buffer parameters; other shapes refused apart
What: `!air.global_bindings` decodes into `AirAbi::global_bindings` (`GlobalBinding`: the
global, and its node's role, type information and name, read by the parameter-node decoder;
the node's index is -1). Canonicalization (`canon::global_binding`, beside the global
built-ins) makes each plain load of a bound buffer's pointer (device or constant space, one
stated slot) a read of a parameter: the entry's own parameter of the binding's role and type
where it takes one, else one appended, shared by the bindings of one role and type. Lowering
then binds it where a `[[buffer(n)]]` parameter binds; the runtime binds nothing new.

Why: the whole module was refused as ProgramScopeBinding (78 functions in 1 library of the
private corpus on runtime-floor and gate-lavapipe: kernels, one constant struct buffer each,
read only by plain loads of its pointer). Metal fills a bound global 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 globals read and write the buffers bound at their indices;
  reflection lists each as a binding at its index; a parameter and a global of one type at one
  index, and two globals of one type at one index, read the one buffer; a vertex and a fragment
  function reading one global each read their own stage's buffer at its index.
- m3-max-70306: Metal also takes a bound texture and sampler, bound threadgroup memory, a bound
  sampler array, and a linked visible function of another library that reads a bound buffer.

What stays refused, each a refusal of its own (docs/REFUSALS.md regenerated):
ProgramScopeResource (a texture, sampler or threadgroup memory, one or an array),
ProgramScopeSharedSlot (a binding at a slot an entry parameter or another binding binds with
another role or type), ProgramScopeLinked (bindings in a linked or dynamic-library module),
ProgramScopeRead (a read of a bound buffer other than a load of its pointer, which
`xcrun metal` 32023.922 does not write). ProgramScopeBinding is gone: a consumer's exhaustive
match on Feature breaks, and a consumer's AirAbi literal needs the new field (git grep of the
consumer's checkout at aed8655a62: 0 hits for ProgramScopeBinding and for `AirAbi {`).

Tests: the ABI decode of a binding (a node with a parameter's index, or a global that is not the
externally initialized undef constant, is malformed); canonicalization over a kernel with three
bound buffers (two appended parameters, one shared with the entry's own) and the refused
shapes; linking and dynamic-library refusals.
2026-11-23 00:51:10 -08:00
Anees Iqbal 3c86a2a45f Translator: a vertex function's slice and viewport index are stored as it writes them
Metal requires the same [[render_target_array_index]] and [[viewport_array_index]] at every
vertex of a primitive ("If values differ, the behavior and value passed to the fragment function
are undefined.", the Metal Shading Language specification), and Vulkan asks the same of Layer and
ViewportIndex (VUID-VkPipelineShaderStageCreateInfo-stage-02596 and -02597). The translator stored
an index only where the function's structure showed it the same among a primitive's vertices
(uniform_varyings over the raw index varyings) and refused every other one,
NotImplemented(LayeredRendering), on every device. A program that keeps Metal's rule keeps
Vulkan's with the index stored as written, and one that breaks it has no Metal answer to match,
so plan::index_store now stores the index to its builtin wherever the device stores it from a
vertex function (shaderOutputLayer, shaderOutputViewportIndex, both in the floor), whatever the
structure shows; a device without the output is refused needing it, as before. The store keeps
index < count ? index : 0 against the pushed length and viewport count, and an index never written
is still stored as 0. uniform_varyings now lists user varyings alone (the raw index keys decided
nothing else), and uniform_index is gone.

Where a program breaks Metal's rule the layer or viewport is the device's choice: the runtime
README's layered line and docs/API.md (section 4 and section 10's accepted differences) say so in
one sentence, the viewport paragraph and set_viewports no longer name a geometry stage, and
docs/REFUSALS.md is regenerated (LayeredRendering is now a device refusal alone). The runtime's
layered device test draws rt6_per_primitive's three triangles into slices 1, 1 and 2 through
viewports 0, 1 and 1 of a 2D array, checking every texel, in place of the refusal it asserted.

SEMANTICS_VERSION 2283: modules for such functions instead of the refusal, and uniform outputs
without the raw index keys.
2026-11-23 00:13:45 -08:00