Commit Graph
9954 Commits
Author SHA1 Message Date
Anees Iqbal 3fbaca0b9b Translator and rt tests: a control point's attribute on a Constant layout reads its one element (red)
A post-tessellation vertex function may read a control-point attribute
whose vertex buffer layout has the Constant step function (step rate 0).
Metal makes such a pipeline, and on an Apple M3 Max every control point of
every patch reads the layout's element 0 at the attribute's offset (an
Objective-C probe, Mac job m3-max-80062; the other elements held other
values and none was read). That matches Apple's documentation of
MTLVertexStepFunctionConstant ("fetches attribute data once and uses that
data for every vertex"). The translator refuses the pair,
NotImplemented(Tessellation), and a walk met that refusal behind the
array-field one.

- a_control_point_attribute_on_a_constant_layout_reads_its_one_element
  (engine_tessellation): tess_triangle_points with its control points'
  half2 from buffer 2 at offset 4, on a Constant layout, compiles. It
  pushes no stride of buffer 2 and passes L3.
- every_device_reads_a_constant_layout_s_one_element_at_each_control_point
  (rt, patch): the same draw as
  every_device_draws_patches_from_their_factors, with that half2 shifting
  the third control point's x. Element 0's half2 at offset 4 is 0;
  element e's is e, with 5 at offset 0. So a control point that reads
  another element, or the element's first bytes, moves the patch and
  changes the texels.

Red: lavapipe (llvmpipe), job m3-max-80108: both refused, "Tessellation;
needs NotImplemented at function tess_triangle_points"; the control draw
passes.
2026-12-02 14:41:34 -08:00
Anees Iqbal a992aa6929 Translator: a GEP into an array field of a thread variable stays inside its array
A thread struct that holds pointers or heap handles beside an array field
indexed at run time was open to pointer forwarding: provenance made the
offset of any run-time index unknown, so the data access could overlap a
pointer slot. A heap handle stored into such a struct then fell to the
handle family's catch-all, Lowering(Access). That is the refusal of a
post-tessellation vertex function a walk met (two render pipeline states
refused).

The Metal Shading Language leaves an index past an array undefined. So a
thread-space getelementptr whose first index is a constant, each of whose
run-time indices steps over an array its own type path names, and whose
every use is a load or store address, is a GEP into an array field
(provenance::array_geps). Over a base whose roots are stack allocations at
constant offsets, its offsets are its displacement plus at most
(len - 1) * stride per run-time index. These keep unknown offsets: a
flattened offset (a run-time pointer index), a run-time vector lane, an
address another GEP offsets or that is merged or stored, a base that may
be null, and memory outside the thread space. A run-time index at a struct
level has no IR form.

Lowering holds every run to the bound. In the private arena, where
objects lie side by side, such a GEP takes each run-time index as
min(index, len - 1) (access.private.gep.array). A typed object's access
already never leaves its levels. docs/API.md records the accepted
difference: an index past the end of an array field of a local struct
does not reach its neighbouring fields; it is undefined in MSL. The
struct then closes as a forwarding cell, and its heap-handle stores that
no load reads take the cell's unread store (the previous commit).

Verified:
- red: m3-max-80079, b9d9dfc9ba (parked_heap_handles refused at its
  handle store, block 0 instruction 11).
- green: gate m3-max-80143 at the same tree on a scratch branch
  (lavapipe tests 47 passed; validation 1315 passed, 3 skipped;
  conformance 1047 passed; the translator suite's only failures are the
  tables development re-blesses: the engine inventory with four new
  parked_heap_handles rows, the golden printout, and 315 golden hash
  cells under SEMANTICS_VERSION 2319).
- L0: a_gep_into_an_array_field_is_bounded_to_the_array (the bound, and
  each disqualifying shape staying unknown).
- read-back, whole-struct copy (a memcpy) and a stepped address stay
  Lowering(Access).
- the walk's two metallibs on the XTX node (m3-max-80156): the handle
  store's refusal is gone; the vertex function next met the two
  refusals the following commits remove.

Cost: one UMin per run-time index into a private-arena array, the bound
itself. The device-arena budget test's word bounds move by one each (13
for a word load, 12 for a word store, 24 for a float4 load).
SEMANTICS_VERSION 2320 (development holds 2319).
2026-12-02 14:41:34 -08:00
Anees Iqbal 728e4c9b1d Translator test: heap handles parked in a thread struct with run-time-indexed array fields compile (red)
The owned fixture engine/parked_heap_handles now matches the shape a
post-tessellation vertex function was refused for: a thread struct holds
heap handles (a sampler and a texture loaded from argument buffers, also
sampled directly) beside two array fields a loop writes at a run-time
index, and the out-of-line callee reads one array at a run-time index.
Every run-time index sits at an array level of its GEP's own type path.
Such a data access at an unknown offset opens the struct today, so the
handle stores fall to the handle family's catch-all, Lowering(Access).

heap_handles_parked_where_nothing_reads_them_compile expects the kernel
to compile with both handle stores unread and the three run-time array
indices clamped in the private arena. The read-back, copied and stepped
kernels (an address offset by a second GEP after the array GEP) must
stay Lowering(Access).

Companions regenerated with Apple metal 32023.922, macOS SDK 27.2
(Mac job m3-max-80076).
2026-12-02 14:41:34 -08:00
Anees Iqbal a13b16fd4c Translator: a store into a cell slot no load reads needs no encoding; a heap handle stored there writes nothing
A heap texture or sampler handle (a handle loaded from an argument
buffer, whose root is Dynamic) stored into a field of a thread struct
that is a forwarding cell was refused at the store, Lowering(Access)
NotImplemented, because no cell encoding carries a heap handle. A
post-tessellation vertex function seen in a guest's render pipeline
parks three samplers and three textures from its argument buffers in a
struct that nothing ever reads them back from, so the whole pipeline
was refused at the first of those stores.

cell::select's store arm now asks the store's slot group for its
loads before it needs an encoding: where the group holds no load
(cell_reads has no entry for it), a pointer no cell encodes writes
nothing (CellStrategy::Unread, census name access.cell.unread). A
store whose value has an encoding still writes it, as before, so pools
(which data loads may read) are untouched: a pool holds arena pointers
alone, each of which a cell encodes.

Why "no load in the group" means nothing observes the slot: the
group is formed over every access of a closed forwarding cell, and a
cell is closed only while nothing else reaches it
(memory/provenance/cells.rs, Round::walk):
- a store of the cell's address into memory that does not forward it
  opens it (line 1218);
- any other operand use, a call the translator does not inline, a
  ptrtoint, an atomic or an aggregate, opens it (line 1241);
- a memcpy or memmove whose bytes meet a pointer slot is a data
  access and opens it (line 1146), unless it is a slot copy between
  two cells (line 1134), which joins the source and destination slots
  into one group (CellFacts::groups, line 172), so a load of the copy
  is a load of the group.

Still refused, by the same Lowering(Access): a heap handle in a slot
that a load reads, directly or through a copy. Carrying a heap handle
through a cell to a load would take a cell encoding for the looked-up
handle, whose form (flagged or indexed) follows its uses; that form is
not built here.

The test of the previous commit pins both: parked_heap_handles
compiles, with its two handle stores as access.cell.unread, and the
read-back and memcpy controls stay Lowering(Access).
2026-12-02 14:41:34 -08:00
Anees Iqbal 462379121d Translator test: heap handles parked in a thread struct whose handle fields nothing reads compile (red)
The owned fixture parked_heap_handles loads a sampler and a texture from
argument buffers, passes them by value to a thread struct's constructor,
which stores each as a pointer into its field, and hands the struct by
reference to a function compiled out of line. Once the call is inlined
the struct is a forwarding cell, and no load reads the handle fields.
The translator refuses the first such store today as Lowering(Access)
NotImplemented, at the cell encoding of a handle with a Dynamic root.

The test expects the kernel to compile and pass L3 on every committed
profile with the sampled heap, its two handle stores selected as
unread cell stores, and ArgumentBufferTextures elsewhere. Two controls
read the parked handles back, from the cell and through a whole-struct
memcpy into a second cell, and must stay Lowering(Access).

The companions come from scripts/regen-air-fixtures on Metal
32023.922, SDK 27.2 (jobs m3-max-79932 and m3-max-79936).
2026-12-02 14:41:33 -08:00
Anees Iqbal c261fef463 Translator: link holds an evaluation stage's outputs to maxTessellationEvaluationOutputComponents
A post-tessellation vertex function's module is a tessellation evaluation entry, whose output
interface the Vulkan specification limits to maxTessellationEvaluationOutputComponents / 4
locations (19.1.4, Table 21, Shader Input and Output Locations). Link's check_limits held every
vertex stage's outputs to maxVertexOutputComponents / 4, so on a device whose evaluation limit is
below its vertex limit link placed an evaluation stage's varyings past its locations, and on one
whose evaluation limit is above it refused (or packed) varyings that fit.

check_limits now takes the pre-fragment stage's limit, output_limit: the evaluation limit for a
vertex stage whose interface names an evaluation stage (StageInterface::tessellation), the vertex
limit for any other. Its packing and refusals are otherwise unchanged, and a refusal names the
limit it met. The module doc's Limits paragraph says so.

No committed profile at the floor changes: each has the two limits equal; the below-floor vk12
profile, the one that differs, has no tessellation. The lowering's own check of a
post-tessellation function's output components (lower/stage_io/plan.rs) already used the
evaluation limit.
2026-12-02 14:36:11 -08:00
Anees Iqbal 00b405cff9 Translator test: an evaluation stage's outputs fit maxTessellationEvaluationOutputComponents (red)
Link's check_limits (pipeline/link/varyings.rs) holds the outputs of a render pipeline's vertex
stage to maxVertexOutputComponents / 4 locations, a post-tessellation vertex function's too. That
function's module is a tessellation evaluation entry, whose output interface the Vulkan
specification limits to maxTessellationEvaluationOutputComponents / 4 locations (19.1.4, Table 21,
Shader Input and Output Locations). Every committed profile at the floor has the two equal; the
below-floor vk12 profile has 64 and 0.

The test links three four-component varyings, which no packing shares, from a vertex stage whose
interface names an evaluation stage (`PipelineInterface::tessellation`) into a fragment stage:
- with the vertex limit 8 and the evaluation limit 12 they must take locations 0, 1 and 2;
- with the vertex limit 12 and the evaluation limit 8 they must be refused as
  InterfaceComponents needing MaxTessellationEvaluationOutputComponents, 12 of 8.
Red today at the first half: link refuses them naming MaxVertexOutputComponents.
2026-12-02 14:35:10 -08:00
Anees Iqbal 787fbbb061 Translator docs: remove_dead's doc in 100 columns, and IndexType's and UnfixedLocation's docs say what their sites refuse
Three doc nits from the audit lane's cold read of today's landings:

- TypedModule::remove_dead's doc (spirv/ir/edit.rs) had one 120-column line since dead removal
  took any type; it is rewrapped within 100 columns, word for word.
- AccessCause::IndexType said "an index of a type other than an integer". Its one site,
  index_form (lower/access/mod.rs), refuses every type but an integer of 1 to 64 bits: a 0-bit
  integer and an integer wider than 64 bits too. The doc now names them.
- AccessCause::UnfixedLocation listed "a table's count". A threadgroup argument's count is
  checked in check_tables (memory/plan.rs), which names ArgumentTable for any count that is not
  a constant 1, a constant or not; the doc now says so and names an argument table's count
  alone.

Docs only; no generated doc carries these comments (docs/REFUSALS.md, API.md and the coverage
tables do not), and neither file is a runtime or classifier input of the validation crate.
2026-12-02 14:26:46 -08:00
Anees Iqbal 3d45f3ff9b rt: texel_texture_copy takes each side with its texel buffer, a type of its own for clippy
50170636e7 passed both sides' texel buffers to texel_texture_copy as one
(Option<(Buffer, u64)>, Option<(Buffer, u64)>), which clippy's type_complexity refuses under
-D warnings (blit.rs:344, all three clippy configurations, job m3-max-80104 on ms01). Each side
is now one TexelSide (the texture, its place, and its Texture::texel_buffer where it is a texture
buffer), as the two sides were (texture, place) pairs before. No behaviour changes.
2026-12-02 14:24:14 -08:00
Anees Iqbal 4fe41c795d rt: a blit copy with a texture buffer on either side copies its buffer's bytes
Metal makes copyFromTexture:...toTexture: with a texture buffer as the source or the destination.
copy_from_texture refused it as Gap::TextureCopy ("A texture buffer's texels are its buffer's
bytes, which no image copy reaches"). Under the rule that a refusal of what Metal makes is built,
it now copies a texture buffer's texels as the bytes of its buffer (texel_texture_copy):

- Checked as Metal checks any copy: one pixel format and one sample count
  (Refusal::TextureCopyMismatch), and each region inside its texture's level and slice (`place`,
  Refusal::TextureRegion), sizes of 0 taken as copy_from_texture takes them.
- Between two texture buffers: the region's bytes copied between their buffers by
  copy_from_buffer_to_buffer, from each one's offset plus origin.x texels. The same bytes copy
  nothing, as the same region of one image does, and bytes that meet are
  Refusal::BufferCopyOverlap, as that call refuses them.
- Between a texture buffer and another texture: copy_from_buffer into the texture from the texture
  buffer's row in its buffer, or copy_from_texture_to_buffer out of it into that row. That is one
  vkCmdCopyBufferToImage or vkCmdCopyImageToBuffer region, checked and ordered as those calls are.

The command buffer keeps both textures. Gap::TextureCopy's doc drops the texture buffer case, and
docs/REFUSALS.md is regenerated. Buffer::new_texture's doc, copy_from_texture's doc and the runtime
README's texture buffer contract say what such a copy does. The texture buffer refusal test no
longer expects the gap from a copy of one into itself; that copy of the same bytes now copies
nothing.
2026-12-02 14:24:14 -08:00
Anees Iqbal 0c4777ead7 rt test: blit copies between texture buffers and a texture move the region's texels (red)
Metal makes copyFromTexture:...toTexture: with a texture buffer on either side; the runtime refuses
it as Gap::TextureCopy (blit.rs, copy_from_texture: "A texture buffer's texels are its buffer's
bytes, which no image copy reaches"). The test makes two RGBA8Unorm texture buffers of 64 texels
over one Shared buffer (A at offset 0 with known bytes, B at 1024 holding 0x5a) and a Private 2D
texture of 16 x 4. A blit copies texels 8 to 23 of A into texels 4 to 19 of B, texels 0 to 15 of A
into the texture's row 2, and that row back into texels 32 to 47 of B. B must hold A's bytes at
both places and 0x5a around them, and A must keep its own. Red today at the first copy.
2026-12-02 14:24:14 -08:00
Anees Iqbal 5874017899 rt docs: the host-memory over-copy's second measurement on the M3, and what would give it another form
The runtime README's host-memory bullet gains a second measurement and the condition under which
that copy would have another form on KosmicKrisp.

The second measurement is the consumer's census on the M3 Max (KosmicKrisp, Mesa 26.3.1), at rt
d122da6ae3:
- run A, m3-max-80100, software decode;
- run B, m3-max-80121, the host's decoder;
- two 30 s 1080p screen recordings in each run.

Metrics::over_copy_bytes_host_memory came to 12,178,324,736 bytes in run A and 12,624,820,212 in
run B. The census's other over-copies in run B are 10 Linear copies of 8,294,400 bytes (a 1080p
BGRA8Unorm render target) and Pitch copies of small textures, which it does not total. So the 99.3%
share is derived here from the census's counts: 12,624,820,212 / (12,624,820,212 + 82,944,000).
It covers the host-memory and Linear bytes.

The condition comes from probe m3-max-80267 (Apple M3 Max, KosmicKrisp Mesa 26.3.1; queries only):
- The one handle type with an owner the driver offers is MTLHEAP: importable and exportable for a
  plain buffer and for linear sampled BGRA8 and R8 images.
- It lists no VK_EXT_queue_family_foreign. An acquire of another driver's writes would name its
  queue family; VK_QUEUE_FAMILY_EXTERNAL covers only the same driver.
- It makes no linear image with COLOR_ATTACHMENT, with or without a handle type.
The bullet says the copy has no other form on that driver until it lists that extension or offers
that attachment.

Docs only. refusal-surface --check passes.
2026-12-02 14:24:14 -08:00
Anees Iqbal 08b385ddc5 Translator: dead removal drops every type nothing that stays refers to, and its capability with it
Dead removal dropped only vector and function types, and a module's
requirements were derived from every type its interner ever held, a
forgotten one included. So once a slot's direct base and address left
(fd8b132834), their OpTypeInt 64 and { uint, uint } struct stayed declared,
and the module still declared OpCapability Int64 and required shaderInt64.

Now:
- unread_types drops any declared type nothing that stays refers to (a kept
  instruction or phi result, a function that stays, a variable of one, a
  global, a push member, a kept constant, or a type itself referred to), of
  any kind, after the sweep and the offers' weighing;
- an array type's length is no longer counted as a use up front, since
  which array types stay is known only then: the length of each array type
  that stays is revived (a scalar constant, which reads nothing), and a
  length only a removed array type read leaves with it;
- TypedModule::remove_dead accepts any type, and Types::iter lists only the
  types still interned, so the requirements and spec_bits walk the types
  the module declares, not the ones it forgot.

This starts from the L155 seat's partial patch (its three changes), which
lacked the lengths list and the edit's check.

Tests: the dead-removal
tests change where more types now leave: the constants kernel's array type
nothing has leaves with its length while a private variable's array type
keeps its own; the offers kernel's pointer type no value has leaves with
the uvec3 only it names (3 types, was 1); the routines kernel without r's
call loses the float type too (3, was 2).

Module words change where an unused type was declared: SEMANTICS_VERSION
2318 -> 2319. The golden tables re-bless on development.

Verified: job m3-max-79992 (no card) at this tree. The previous commit's
test fails there alone, left (2, 0) against (2, 2): two dead instructions,
no type removed. Here all 7 dead-removal tests pass; clippy plain, cpu-icd
and gpu cfg, doc and privdoc exit 0; rt on lavapipe 933 passed, 3 skipped;
translator and AIR 3402 passed, 37 skipped (golden tables excluded, due);
validation 1315 passed, 3 skipped; conformance 1047 passed. Release-mode
translation time and peak memory were not measured.
2026-12-02 14:24:14 -08:00
Anees Iqbal 95199bb968 Translator test: a type only dead values had leaves with its capability (red)
After fd8b132834 made a slot's direct base and address in the entry block,
dead removal leaves the ones no access reads, but not their types: an
unused OpTypeInt 64 and a { uint, uint } struct stay declared, and with
the 64-bit type the module's OpCapability Int64 (3 of 8 sampled modules in
the byte-identity probe). Dead removal drops only vector and function
types.

The test builds that shape: a kernel that widens a loaded word to a 64-bit
integer and pairs the word with itself in a { uint, uint } struct, and
reads neither. After dead removal both types must leave, and the module
must no longer require Int64 or shaderInt64. Red here: no type leaves, so
the report counts 0 types and Int64 stays.
2026-12-02 14:24:14 -08:00
Anees Iqbal 6ae0f8244b rt docs: the identity domains' refusal of a resource bound through a descriptor names the test that reaches it
The runtime README listed that form with no test. tests::reflection_answers (d8efdd3e20) reaches
it: the device's translator refuses the tile pipeline of engine/k10ts_tile_grid with
"unsupported: IdentityDomains (a resource bound through a descriptor)" on lavapipe (job
m3-max-80179) and an RX 7900 XTX (job m3-max-80228), and the test compares that text across every
make.

Docs only. Verified: cargo fmt.
2026-12-02 14:24:14 -08:00
Anees Iqbal aea3a53ea1 rt test: the reflection guard's subjects hold their descriptors boxed, as clippy's large_enum_variant asks
Job m3-max-80136: clippy under m2v_cpu_icd and m2v_gpu flagged the Subject enum's variants'
size difference. Verified: cargo fmt; clippy follows as a job.
2026-12-02 14:24:14 -08:00
Anees Iqbal 480d162ce8 rt test: a tile pipeline's refusal is its answer in the reflection guard, as every make must give the same
The first lavapipe run (job m3-max-80136) panicked at the translator's compile of the tile
pipeline on the device, before any comparison. The tile answer is now the refusal's text where
the translator refuses it, compared like every other answer.

Verified: cargo fmt. The runs follow as jobs.
2026-12-02 14:24:13 -08:00
Anees Iqbal aa2ef691b2 rt test: every make of a pipeline answers its reflection alike
A pipeline's reflection answers must not depend on the make. This test makes each pipeline
seven times:
- three times on one device;
- once on a second device;
- once on a fresh cache directory, which lowers and keeps each translation;
- once on a device after it on that directory, which reads them;
- once in a second process on the directory.
It compares the answers byte for byte.

The pipelines:
- compute states:
  - a tiling kernel;
  - an observing kernel;
  - one with static threadgroup memory;
  - one that declares its thread limit;
  - fold_config, specialized by function constants.
  It compares maxTotalThreadsPerThreadgroup, threadExecutionWidth, staticThreadgroupMemoryLength,
  imageblockMemoryLengthForDimensions:, supportIndirectCommandBuffers and
  requiredThreadsPerThreadgroup.
- render states:
  - one colour attachment;
  - two attachments;
  - made for indirect command buffers;
  - a fragment function specialized by function constants.
  It compares imageblockSampleLength, the memory length and supportIndirectCommandBuffers.
- the translator's tile pipeline of k10ts_tile_grid with threadgroupSizeMatchesTileSize: its
  ComputePipelineMetalInfo and the flag. The runtime makes no tile state.

The device after the first on the directory must read translations, which shows the hit path
ran.

The consumer's row reported reflections that differed between two makes of one identity. Their
logs hold no observed difference, so this test is the property's guard.

Verified: cargo fmt. The lavapipe and card runs and clippy follow as jobs.
2026-12-02 14:24:13 -08:00
Anees Iqbal c55fd4603c Validation: a video picture landed is the surface's mark of the other API's writes, not an acquire
The play calls Surface::external_writes_done once a picture lands on a video surface's pages. That
call records no acquire: each submission part that uses the planes acquires and releases them
itself, and the call marks the other API's writes on the host side. videos.rs' module doc already
said so, but its counter and report line still named the call an acquire, as did
docs/REPLAY-STREAM.md (the `m2v.externalWriteDone` row in section 4, and the video surface
paragraph and its counters in section 10) and the replay test's doc.

The executed counter video_surface_acquires is now video_surface_writes_done, and the report's
`video surfaces` line says "N writes marked done" for "N acquires". Its one reader in the tree is
rt_replay.rs' a_video_surface_is_waited_for_at_its_ready_point_once, updated; no script in the
tree names it (grep for surface_acquires over *.rs, *.md, *.py and *.sh). The count is unchanged:
one a picture landed in a surface.

Wording and naming only; no behaviour changes.
2026-12-02 14:24:13 -08:00
Anees Iqbal 463921d7df rt test: the texture buffer blit test binds its kernel's output at the kernel's buffer slot 0
tb_blit_read declares its output buffer at buffer index 0 (`air.location_index` 0), but the test
bound it at slot 1, so the kernel wrote nowhere and its output read zero. Both blit reads (the
copy out and the buffer's bytes) were already exact on lavapipe at 65ea05bf4a (job m3-max-80061).
2026-12-02 14:24:13 -08:00
Anees Iqbal dd453f5731 rt: a texture buffer's buffer handle is Texture::texel_buffer, apart from TextureObject::texel_bytes
d80c9eb173 named the new inherent method Texture::texel_bytes, which shadowed TextureObject's
texel_bytes (a texel's bytes, u64) where render_encoder.rs reads it for a shadowed attachment, so
the crate did not compile (lavapipe job m3-max-80035). The method is now texel_buffer.
2026-12-02 14:24:13 -08:00
Anees Iqbal 772441372c rt: a blit between a buffer and a texture buffer copies the region's bytes between the two buffers
A guest's 3D model window stayed blank: it fills an RGBA8Unorm texture buffer placed in a heap by
copyFromBuffer:...toTexture:, which BlitCommandEncoder::buffer_copy refused as Gap::TextureBytes
("A texture buffer's texels are its buffer's bytes, which no image copy reaches"). A texture
buffer has no image: its texels are its buffer's bytes from its offset. So a copy between it and a
buffer, in either direction (copy_from_buffer into it, copy_from_texture_to_buffer out of it), is
now checked as any texture's copy is, by the same checker (`buffer_copy`: the region inside its one
row, level 0 and slice 0, Refusal::TextureRegion past it; Metal's measured layout rules,
Refusal::BufferCopyLayout), and then the region's bytes (origin.x and width in texels times the
texel's bytes, at the texture buffer's offset) are copied between the two buffers by
copy_from_buffer_to_buffer. That path keeps both buffers, takes the Managed copies and the heap
places, and orders the copy as any copy between buffers. A texture buffer's uses take its buffer's
id in the hazard sets, so a later kernel's read is ordered after it. The command buffer also keeps
the texture. Two parts of the generic check don't apply: an image's rows or memory meeting the
region (it has none), and a copy command's offset alignment (vkCmdCopyBuffer takes any). The check
runs without them. Bytes of the texture buffer that meet the other buffer's region are
Refusal::BufferCopyOverlap, as copy_from_buffer_to_buffer refuses them.

Gap::TextureBytes's doc drops the texture buffer case and its basis line ("nor a texture buffer's
copy as a buffer copy; no recorded stream copies a texture buffer"), and docs/REFUSALS.md is
regenerated. Buffer::new_texture's doc, copy_from_buffer's and copy_from_texture_to_buffer's docs
and the runtime README's texture buffer contract now say what a blit with a buffer does. The
texture buffer refusal test no longer expects the gap from copy_from_buffer_with_options. A copy
between a texture buffer and a texture (Gap::TextureCopy) is left as it is.
2026-12-02 14:24:13 -08:00
Anees Iqbal 8f6c24c41b rt test: the texture buffer blit test's source words take a name of their own, apart from words()
9d3249b1f8's test named its source words `words`, which shadowed the module's `words` function
its reads call, so the test did not compile (lavapipe job m3-max-79857). Still red at the copy in.
2026-12-02 14:24:13 -08:00
Anees Iqbal afec366ab3 rt test: a texture buffer filled by a blit reads back through a blit, its buffer and a kernel (red)
A guest's 3D model window stays blank: it fills an RGBA8Unorm texture buffer placed in a heap by
copyFromBuffer:...toTexture:, which the runtime refuses as Gap::TextureBytes (blit.rs, buffer_copy:
"A texture buffer's texels are its buffer's bytes, which no image copy reaches"). The test makes
an RGBA8Unorm texture buffer of 64 texels at offset 256 in a buffer placed in a Private heap,
fills the buffer with 0x5a, copies 32 texels of a Shared buffer into texels 16 to 47, copies
texels 8 to 55 out into a Shared buffer, copies the heap buffer's bytes into another, and reads
every texel in a kernel (an owned AIR kernel over texture_buffer<float, read>). Each read must
hold the source's bytes at texels 16 to 47 and 0x5a around them. Red today at the copy in.
2026-12-02 14:24:13 -08:00
Anees Iqbal 5a3e25fb31 Fixtures: dic_post_process's rows in the engine inventory and its printout, blessed on the M3
Blessed with bless_engine_inventory and bless_engine_goldens (job m3-max-80148 on the M3, which has
every assembler) at 066d192863: the fixture's two entries, dic_full_screen and dic_post_process,
compile (ok) on all 15 profiles from both its typed .air.ll and its .ll, and tests/air_input gets
dic_post_process.txt. No other row or printout moved; both bless tests passed.
2026-12-02 14:24:12 -08:00
Anees Iqbal 4d82322e18 rt test: each texture over a buffer takes the form Buffer::texture_copy_cause answered
On every device of the cfg's kind: asked twice, then made, the form equals the answer, and the asking makes no texture and counts no copy. A guest's four textures at offset 32, rows 3648 apart, over a Private buffer (copied for Alignment on lavapipe), and RGBA8Unorm controls over a Shared and a Private buffer at the device's pitch (in place over Shared on every device) and one rounding past it (copied for Pitch everywhere).

The test keeps every texture it makes until it ends. A texture's release is asynchronous, so when
the 3090 dropped one case's texture before the next case asked, the textures gauge moved during
the ask (m3-max-79921, copy_cause.rs:82).

Passed at this change on 4c613f389b, with each case printing its answer and its form:
- RTX 3090 (m3-max-79946): Pitch for the guest's four.
- RX 7900 XTX (m3-max-79947): Pitch for the guest's four.
- Iris Xe (m3-max-79948): in place for the guest's four.
- lavapipe (m3-max-79982): Alignment for the guest's four.
- On all four, the controls were in place at the pitch and Pitch past it.

On the tree rebased onto 8c927efe94 (m3-max-79985), the runtime suite on lavapipe ran 934 tests:
934 passed, 3 skipped.
2026-12-02 14:24:12 -08:00
Anees Iqbal d7e4b5154c rt: Buffer::texture_copy_cause answers whether new_texture makes a texture over a buffer in place
A consumer that keeps its own copy form for textures over a buffer asks rt only where rt would
place the texture in place. The answer is new_texture's own decision, with no texture made:
Device::over_cause takes the descriptor's checks (prepare), check_over, the bind texture() lays
(over_bind, factored out of texture()), and the linear image's fit with and without the feedback
usage (without_loop_where_unfit, which texture() now takes too). The fit is one function, unfit(),
that Made::make and the query both call: the pitch and the memory alignment are the linear image's
own, so the query makes the image new_texture would bind (linear_info, shared with make), reads its
layout and memory requirements, and destroys it, never bound, as minimum_linear_texture_alignment
does. None where in place, else the OverCause its copies count under; a texture buffer is never
copied. The answer holds for the life of the buffer's block.

The runtime README names why a guest's textures at offset 32 with rows 3648 bytes apart copy on
three of the four devices probed: the row rounded up to 128 (RTX 3090) and 256 (RX 7900 XTX) bytes,
and lavapipe's 64-byte memory alignment, from probe jobs m3-max-79849..79852. api_signatures.tsv
blessed; refusal-surface, metal-coverage and conformance-coverage checks pass with no change.

Verified with the next commit's test at this change on 4c613f389b. A guest's four textures over a
Private buffer (offset 32, rows 3648 bytes apart) were answered and made Pitch on the RTX 3090
(m3-max-79946) and RX 7900 XTX (m3-max-79947), in place on Iris Xe (m3-max-79948), and Alignment on
lavapipe (m3-max-79982). The RGBA8Unorm controls were in place at the device's pitch and Pitch one
rounding past it, over Shared and Private, on all four. On the tree rebased onto 8c927efe94
(m3-max-79985), lint passed (generated tables, fmt, clippy plain, m2v_gpu and m2v_cpu_icd, doc and
private doc all exit 0), and the runtime suite on lavapipe ran 934 tests: 934 passed, 3 skipped.
2026-12-02 14:24:12 -08:00
Anees Iqbal f4f5cc33da rt docs: Metal's validation asks ShaderRead and ShaderWrite at every read_write slot; the runtime asks less where the function only writes
The runtime README's rule (Textures: Texture slots and usage), pipeline::slot_usage's doc and
RESOURCE-ID.md's sentence on slot usage said the runtime asks a texture's usage at a slot as
Metal's validation asks it, ShaderWrite alone at a read_write slot the function does not read.
Metal's validation asks both at every read_write slot, by the declared access, whatever the
function does there. Measured on an Apple M3 Max, macOS 27.0.1 (job m3-max-80068, a scratch
probe of runtime-compiled MSL, R32Float 4x4):
- a read_write slot the function only writes, of a ShaderWrite-alone texture, asserts "Compute
  Function(k_rw_write): reads texture (t[0]) whose usage (0x02) doesn't specify
  MTLTextureUsageShaderRead (0x01)";
- one the function only asks the width of asserts the same of 0x02 and the write of 0x01;
- one it only reads asserts the write of 0x01 and the read of 0x02;
- both usages run.
Plain Metal runs every case, and the written one writes its texels.

The runtime keeps its rule: such a slot asks ShaderWrite alone, as its write reaches the texture
through its storage element alone, so a ShaderWrite-alone texture runs there as plain Metal runs
it. The three texts now say what Metal's validation asks and what the runtime asks. They also
name a texture atomic's slot as one that reads. Metal's validation asks both there: a 0x21
texture asserts the write and a 0x22 one the read; 0x03 runs without ShaderAtomic.

Docs only; no behaviour changes. Verified: cargo fmt. Rustdoc runs as a job.
2026-12-02 14:24:12 -08:00
Anees Iqbal 626da2e537 rt test: a copy-form block handed over apart takes the uploads' part and one a member, three vkQueueSubmit2 calls
The test of 12126b64d6 expected one vkQueueSubmit2 a member, two in all. On lavapipe (job
m3-max-79795, llvmpipe, Copy(Pitch { plane: 0 })) the group went as three, with acquires and
releases [2, 2] and B's bytes picture 1's. Three is the design: a group sent member by member
takes one part ahead of the first member's, with the submission's uploads, and one for each
member, and a part left empty is left out (`submit::parts`; the apart count, starts plus one).
Here the over copy into the planes' images is an upload, so the parts are the uploads', A's and
B's. The `read` branch puts the block in the uploads' part, which acquires and releases it once;
A's part takes no hand-over; B's takes one. The Direct3D 11 apart test expects one call a member
because its submissions carry no uploads: its part ahead of the first member is empty and left
out. The test now expects three calls and its doc names the uploads' part; the [2, 2] and texel
asserts stay.
2026-12-02 14:24:12 -08:00
Anees Iqbal d9067a1a24 rt test: a copy-form surface's block is handed over in the first part of a group sent apart, for the upload's copy that reads it
Where a group goes member by member, the uploads' copies into textures over a buffer in a block
another API shares read that block in the first part, which hands it over too (`read` in
submit.rs). No device test covered that: the only test of a group sent apart is Direct3D 11's, on
Windows, whose planes are images with no over copy. On the copy-form row (an opaque handle at a
pitch multiple of 4096) and the 1080p picture, the other device writes picture 1 and the consumer
calls external_writes_done; on one queue behind the busy work, a copy between two buffers that
uses no plane (A) and a blit read of both planes (B) join one group, which goes member by member.
The test asserts two vkQueueSubmit2 calls, one acquire and one release in each part (two of each,
a part handing a block over at most once), B's bytes picture 1's, and no layer message. A device
that takes another form for the row says so and checks nothing. rt_read's blits move into
encode_read, which the new test encodes into a command buffer it commits itself.
2026-12-02 14:24:12 -08:00
Anees Iqbal 003d258843 rt docs: an exported block's textures owe a copy in at external_writes_done's host mark, not at an acquire
Since each submission part that uses shared memory hands it over (acquire at its head, release at
its end), `Block::external_writes_done` records no acquire: it marks the other API's writes on the
host side (`Work::exported_changed`, `ExportedOvers::owe`). ExportedOvers' doc still named "an
acquire" as an event that changes a texture's bytes, as did owe's and exported_changed's docs and
four places in the runtime's README (the copy form's planes "copied at each acquire and release",
"an acquire among them", "after its acquire", "the block's acquire"). They now name the mark, and
say the per-part acquire and release change no byte. Block::external_writes_done,
Surface::external_writes_done and the README's hand-over contract already said so. Wording only;
no behaviour changes.
2026-12-02 14:24:12 -08:00
Anees Iqbal 59d00cd865 Validation: the play's own buffers take each copy-form surface's buffer over its exported block
A surface in the copy form holds a buffer of the runtime's over its exported block
(`Device::copy_form`), which its planes, textures over it, hold too. The play's count of its own
buffers (`NewRuntime::play_holds`) took none of them, so each copy-form surface the program made
between frames 100 and 200 moved `buffers_excess`. The copy-form merge leg's RX 550 (m3-max-79613)
and a rerun on the RTX 5080 Laptop GPU (m3-max-79696, at 2361470bff) failed
the_play_s_own_textures_take_its_video_and_exported_surface_planes on `buffers`: excess 1 at frame
100 and 2 at 200, with both video surfaces copied (Tiling) and both exported surfaces in place.
No leak: the growth is the second video surface's buffer, freed with the surface.

The play now holds one buffer for each video surface in the copy form while the player keeps it
(`Videos::held_buffers`), and one for each exported surface in the copy form while it or a plane
of it the stream holds lives (`Exported::held_buffers`), as the textures term counts their planes.
The test's first exported surface is a dma-buf's, which NVIDIA's dma-buf takes in the copy form,
so the exported term with a plane outliving its surface runs there too.
2026-12-02 14:24:12 -08:00
Anees Iqbal f124b1489f Translator: an access refusal names the structure it met
Feature::Lowering(LowerFamily::Access) with Needs::NotImplemented covered
about 235 refusal sites behind one name, so a walk's log line could not say
which without the AIR. Unsupported gains `cause: Option<Cause>`; an access
refusal carries Cause::Access(AccessCause), one variant per structure the
sites refuse: the access's shape, the type it moves or the memory it
reaches. Sites that refuse the same structure share a variant, wherever
they are; none is named by a file, a line or a string of its own.

The five helpers that build the refusal (lower/access/mod.rs refuse() and
memory/{alloca,leaf,plan,provenance}.rs not_lowered()) take the cause, so
the compiler makes every site name one; the three direct constructions in
memory/handles.rs and lower/access/handle.rs do too, through
Unsupported::access. Feature stays Lowering(Access), so validation's
outcome key (feature_key, the Debug of the feature) and the census are
unchanged. Display prints the cause after the feature:
"Lowering(Access): PointerStore; needs NotImplemented at ...".

Storage: nothing stores the cause. Validation keys a refusal by
feature_key(&u.feature) (engine.rs); a FALLBACK repro bundle keeps the
failure as text (repro.rs, whose only serde record is the device); the
runtime's cache marks a refused translation with fixed bytes. No version
bump.

A buffer argument of a count other than one outside an argument table
names BufferArray, apart from an index or count the metadata does not fix
(UnfixedLocation).

Tests: the error module's Display test of an access refusal; the plan's
table gaps assert ArgumentTable, and its typed-depth, initializer and
buffer-array refusals PrivateType, Initializer and BufferArray.
runtime-sources.sha256 rewritten: memory/handles.rs's two refusals name
their cause, and no run behaves otherwise. api_signatures blessed (Cause,
AccessCause, Unsupported.cause), api_surface lists the two enums,
REFUSALS.md regenerated (the access refusals are built in error/mod.rs),
docs/API.md's error table names the field.

Consumer uses (consumer-uses.sh, read-only, plus git grep, over the
consumer's development 22cfe51a54 and its lane tips of the last day): no
struct literal or exhaustive destructuring of the translator's Unsupported
("Unsupported {" hits only its video crate's own Unsupported(String),
codec/encode.rs:494-502). Its rt platform builds refusals in tests with
Unsupported::not_implemented (rt_platform/diag.rs:3076, 3078, 3490;
rt_platform/unbuilt.rs:1203, 1293), whose cause is None, so their keys
("Translation-Lowering") hold. It reads u.feature where it names a refusal
(rt_platform/diag.rs:1082) and where it says one (rt_platform/unbuilt.rs:
507); each shows the cause once it reads u.cause too.
2026-12-02 14:24:11 -08:00
Anees Iqbal 8cbec0d80b rt test: every device makes a post-process state of two stage-in buffers and bool constants
The shape of the render pipeline state a guest's model viewer had refused
as a draw input (RenderPipelineKind::DrawInput), from our own MSL:
dic_post_process.metal's full-screen vertex function reads a float4 at
attribute 0 and a float2 at attribute 1, which the test's vertex descriptor
fetches from buffers 0 and 5 at strides 16 and 8, and its fragment function
samples a texture and changes the colour under bool function constants 0, 1,
3 and 4 (set false, true, false, true), into one RGBA16Float colour.

The companions come from scripts/regen-air-fixtures on the oracle Mac's
toolchain (job m3-max-79796; TOOLCHAIN records it). The engine fixture
expectations' bless is due on development for the new fixture.
2026-12-02 14:24:11 -08:00
Anees Iqbal 1cc16eb4da rt: a draw-input refusal names its cause
RenderPipelineKind::DrawInput covered a dozen causes behind one name, so a
walk's log line could not say which without the AIR. It now carries
DrawInputCause, one variant per reason the runtime's draws() (and the
constexpr numbering it hands its gap to) refuses a render pipeline state's
input for:
- pointer translation, handle translation, a descriptor set that is not the device's
- a slot, fact, sampler or pushed parameter of a stage other than vertex and fragment
- a runtime fact the encoder does not supply, by its RuntimeFact::name
- a slot the encoder does not bind (a visible or intersection function table)
- a push field the encoder does not fill
- the stride of a layout of MTLBufferLayoutStrideDynamic
- a constexpr sampler the state does not hold, and an unnormalized one
- a parameter block past one ring chunk, and one without its pushed address
- pushed bytes past the device's push window

The variants follow KernelInputKind's names where a cause is the same.
Gap's Display shows the cause ("a render pipeline state with DrawInput
{ cause: Slot } is not built"), so the conformance ledger's seven DrawInput
rows now name theirs: DynamicStride for the indirect vertex-stride case,
Slot for the visible-table stage cases. The icb_stage_in test asserts
DynamicStride.

api_signatures blessed (DrawInputCause and its variants; DrawInput's
signature). REFUSALS.md regenerates unchanged at this base.

Consumer uses (consumer-uses.sh, read-only, over the consumer's
development 22cfe51a54 and its lane tips of the last day): one
construction of RenderPipelineKind::DrawInput, in a test of its rt
platform (rt_platform/diag.rs:3494, on development and ten lane tips),
which needs `DrawInput { cause: .. }`; no match on the kind's fields
("DrawInput {" 0 code hits; its IndirectCommandBuffers-DrawInput keys are
another enum's). Its refusal name keys every RenderPipeline gap by the
gap's variant alone (rt_platform/diag.rs:1074), so its counts line names
the cause once an arm for DrawInput { cause } precedes that one.
2026-12-02 14:24:11 -08:00
Anees Iqbal c1f999eb06 rt: pipeline states answer Metal's allocatedSize as their translated SPIR-V's bytes
ComputePipelineState::allocated_size and RenderPipelineState::allocated_size
answer MTLAllocation's allocatedSize, which both Metal pipeline states adopt.
The answer is our code's size, not the driver's compiled binary, which the
runtime does not measure. A compute state answers its kernel's module, the
one its interface is read from. A render state answers its stages' modules,
summed. Both numbers are taken from the translation when the content is made
and kept as a u64 in the content (a compute content's Answers, a field of
RenderCompiled); no module is kept for them. Every device takes the same form.

No variant counts: not the emulated-SIMD-group or partial-threadgroups
variant lowered with a compute state, not one made at a dispatch (the
emulated-partial variant), and not a render content made later for a pass.
So the answer never changes once a state is made, and two states of one
content answer one size.

docs/API.md's accepted differences (Heaps and memory) gets the entry.
MTLAllocation.allocatedSize stays missing in the coverage ledger: buffers,
textures and heaps still lack it. Its note now names the pipeline states'
answers, and docs/METAL-COVERAGE.md is regenerated. api_signatures.tsv is
blessed with the two methods.

Tests:
- state_answers: a new test. block_scan (plain module) and sample_down
  (partial-threadgroups variant) answer non-zero. Each equals the bytes of
  the module the state keeps (a test-only Kernel::module_bytes). The
  render state of first_texel_fragment answers the sum of the translator's
  compile_render_pipeline stages' SPIR-V lengths. Two states of one content
  answer one size.
- translate.rs: the ragged-grid test on emulated SIMD groups now also checks
  that a state's answer is the same after the dispatches that make the
  variant later.

Verified: job m3-max-79929 on lavapipe, a check of this tree.
- signatures --check, coverage --check, clippy (plain, m2v_gpu,
  m2v_cpu_icd), workspace doc and the runtime's private doc: all 0.
- The runtime suite: 928 passed, 3 skipped.
- The two tests rerun with output: both pass. On lavapipe the variant
  already emulates its SIMD groups, so the ragged test makes nothing at a
  dispatch there. No card run yet.
2026-12-02 14:24:11 -08:00
Anees Iqbal 2ae50d2fd5 rt: a draw supplies the vertex amplification count
draws() refused a state whose function reads [[amplification_count]]
(RuntimeFact::AmplificationCount) as DrawInput, though the state's creation
already fixes the fact's SpecKey::AmplificationCount constant at 1 in each
stage's module. 1 is every draw's count: the runtime makes no state whose
maxVertexAmplificationCount is above 1
(RenderPipelineKind::VertexAmplification), and its render encoder sets no
count, so each draw has Metal's default. draws() now names the fact as
supplied, beside the sample count it fixes the same way.

This is the cause of a guest's model viewer's five refusals of three
post-process states in a walk (job m3-max-79894, XTX/RADV, where the
typed cause named it).
2026-12-02 14:24:11 -08:00
Anees Iqbal 8ad387cc0f rt test: every device draws a vertex function that reads its amplification count (red)
A guest's model viewer leaves its window blank because the runtime refused
its post-process states as RenderPipelineKind::DrawInput: their vertex
functions read [[amplification_count]], and draws() named no such fact as
supplied. The fact is RuntimeFact::AmplificationCount, as the typed draw
input cause on steelbrain/fix-rt-causes printed over the walk's refused
states (job m3-max-79894, XTX/RADV).

The owned fixture engine/vertex_amplification.ll's amp_vertex_store reads
[[amplification_count]] and [[amplification_id]] and stores both; drawn
with rasterization disabled in a state whose maxVertexAmplificationCount
is 1, each vertex must write (1 << 16) | 1 to word vid * 8. Red here: the
state's creation refuses it as DrawInput.
2026-12-02 14:24:11 -08:00
Anees Iqbal 06d2d22bf7 Translator: a library keeps each module in an allocation of its own, and a function keeps its module, not its library
A pipeline state keeps its descriptor's functions to lower its later variants from, and a
function held its whole library through an Arc: a guest that made a state of one function of a
metallib of many, then released the library, kept every module of it alive as long as the
state lived.

At load, a library now splits the one copy it makes of the loaded bytes: each module (each run
of bytes one or more functions' bitcode covers, so functions over one module, as a Core Image
kernel library's or a dynamic library's exported functions, share one) in an allocation of its
own, and every other byte (header, function list, metadata, other sections, padding) in one
more. A function holds its library's function table (rows, content hash, type, install name,
dependencies), its own module's allocation and its index, and the library weakly. So a state
keeps exactly its functions' modules whether the library lives or not: while it lives, the
same allocations the library holds, each module once; nothing is copied at a state's make.

Public changes (api_signatures.tsv, docs/API.md, the doc comments):
- Library::bytes() returns an owned Vec<u8>, assembled from the allocations, equal byte for
  byte to the loaded bytes (of a universal file, its AIR slice, as before); content_hash() is
  their SHA-256, computed at load as before.
- Function::library() returns Option<Library>: the library while a Library value of it lives,
  None after; MTLFunction names no library either.
- Function::library_content_hash() (new): the library's content hash, kept with the table.
- Function::bitcode() (now public, infallible): the function's own module (a metallib
  function's wrapped module, a bare module's whole module, a dynamic library's one module); its
  doc says the bytes are the guest's shader, never committed or sent anywhere.
- Function's PartialEq and Eq: equal tables (each holding its library's content hash) and
  indices.
The translator's own uses of a function's library read the table (compile.rs's dependency
order and EntryNotFound's count); linked_sources no longer fails.

The consumer's call sites (reims-vgpu development 53e7385993, read only; search: git grep -n -E
'\.(bytes|library)\(\)' over crates/reims-vgpu-vulkan and crates/reims-vgpu, and \.library\(\)
over the whole tree; every other hit is a string's, a NAL's, a staging buffer's or
graphics().library()): crates/reims-vgpu-vulkan/src/rt_platform/diag.rs:1860 and :1863 (the
kept-AIR bundle: the container while the library lives, else the function's own module through
bitcode(), the line naming which), diag.rs:1934 (FunctionName::of: library_content_hash()),
diag.rs:3495 (test; unchanged, the bytes compare equal) and unbuilt.rs:653 (test; a function
keeps bitcode().len()).

Tests: the red test's two states (lavapipe; their test accessors now read a kept function's
library where it lives, else its own module); a_live_library_and_its_states_hold_each_module_once
(two compute states and a render state share the library's own allocations);
tests/library_modules.rs: bytes() equals the loaded input for a plain metallib, a Core Image
kernel library (shared module), a dynamic library, each universal header and a bare module, the
content hash their SHA-256; a function holds its module (one allocation per module, shared over
a shared module), names no library once it is released, keeps the content hash and compiles
under the same keys to the same words. The runtime's README says what a state keeps.
2026-12-02 14:24:11 -08:00
Anees Iqbal 6e70ad687c rt test: a pipeline state keeps no more of a released library than its functions' modules (red)
A compute state keeps its descriptor to lower its later variants from, and a render state keeps
its descriptor to make a pass's content from; each function there holds its whole library. A
guest that makes a state of one function of a metallib of many, then releases the library,
leaves every module of that library alive as long as the state lives.

Two device tests, each over a metallib of one function and four other kernels, each entry over
a module of its own as Apple's toolchain writes one: a compute state of the kernel pool_reach,
and a render state of a bare module's colored_vertex with the metallib's fragment
a2_front_facing. Each makes the state, drops the libraries and the descriptor, and asserts the
state keeps no more of the metallib than its function's own module (plus 1 KiB); the render
test also asserts the bare module's vertex function stays whole. Test-only accessors on both
states read the bytes kept.
2026-12-02 14:24:11 -08:00
Anees Iqbal e160098eda rt README: Metal makes a texture buffer of formats the runtime refuses
The known gaps of textures say which formats Metal makes a texture
buffer of where the runtime answers Gap::TextureFormat. Plain Metal on
an Apple M3 Max under macOS 27.0.1 (jobs m3-max-79872 and m3-max-79879,
the same answers both runs), asked for each of the 300 formats the
runtime names, over a buffer and from the device, for reading, writing
and both, made one of 99, ended the process for 125 and answered nil
for 71. The runtime's refused sets come from texel_form and the
committed vulkaninfo profiles, not from a card run, and the README
says so. Docs only; no refusal or public item moves.
2026-12-02 14:24:10 -08:00
Anees Iqbal cdadbc8d2f api_signatures.tsv: Metrics' translations_at_encode and translation_at_encode_max_nanos
The widened counter replaced variant_translations_at_dispatch; the table was
not blessed with it (the_public_signatures_are_the_committed_table failed in
the translator suites, job m3-max-79131).
2026-12-02 14:24:10 -08:00
Anees Iqbal e0f63843c4 replay: the longest translation at encode is an end line, not a frame's counter
translation_at_encode_max_nanos is a maximum since the device was made, so a
frame's difference of it means nothing: the report gives it once, as
`translation at encode longest N ns` beside the commit lock's, and keeps
translations_at_encode among the executed counters.
2026-12-02 14:24:10 -08:00
Anees Iqbal adc68cb356 rt tests: dispatches racing for the partial-threadgroups variant on emulated SIMD groups lower it once
Four threads dispatch wps_uint_k40_s32's ragged grid at threadgroups of 48
at once, each through its own queue and buffers: where the kernel's
partial-threadgroups variant runs only whole SIMD groups, one lowers the
variant on emulated SIMD groups and the rest wait for it in its OnceLock
(translations_at_encode moves by 1); every racer's whole SIMD groups have
the CPU's words.
2026-12-02 14:24:10 -08:00
Anees Iqbal 5a16277eb3 rt: one counter for every translation made at encode, with its longest make
The planner widened the counter of the fourth variant made at dispatch to
every translation made at encode, named once: Metrics::translations_at_encode
counts the makes, made or refused, and translation_at_encode_max_nanos holds
the longest (a maximum since the device was made, as maker_wait_max_nanos).

Its sites, each a module or content the state's creation did not make, made on
the encoding thread that waits for it:
- an observing kernel's partial-threadgroups variant on emulated SIMD groups
  lowered by a dispatch (not by prepare_dispatch);
- a compute state's content for a dispatch's buffers bound at a multiple of 4
  below their alignment, or its 8-bit sRGB textures' UNORM twins
  (PipelineInner::variant, one function for both);
- a render state's content for a draw's buffers bound so (for_words);
- a render state's content for a pass it does not render into as made
  (for_pass: a colour attachment the pass lacks, or a fetched colour in a 2D
  array).
The first replaces variant_translations_at_dispatch. A content the map of
contents holds is a reuse and counts nothing; one it forgot counts again. The
replay's metrics report both fields.

Tests: each site counts one make at its first need and none at a reuse:
the word-bound compute variant (and again for a second mask and a forgotten
variant), the sRGB variant, the word-bound render content per draw case, the
pass content of a lacking pass, and the fourth variant's dispatch (with the
maximum above 0).
2026-12-02 14:24:10 -08:00
Anees Iqbal c7f9a58f6e rt: decide's kernel borrows from the content, not from the need
The need now carries the state's descriptor, so the elided lifetime of
decide's returned kernel no longer has one source.
2026-12-02 14:24:10 -08:00
Anees Iqbal fc9ebee2fc rt: a ragged grid at a threadgroup of partial SIMD groups runs the partial-threadgroups variant on emulated SIMD groups
An observing kernel whose partial-threadgroups variant runs only whole SIMD
groups (a subgroup tier) refused a dispatchThreads grid that is not whole
threadgroups at a threadgroup that is not whole SIMD groups
(Gap::PartialThreadgroups, site SimdGroups). The translator now lowers the
partial-threadgroups variant on emulated SIMD groups, so the runtime runs it.

What: a fourth KernelVariant, EmulatedPartialThreadgroups, in ALL, whose
inputs set both partial_threadgroups and emulated_simdgroups. The state's make
does not lower it (the planner's form: made at the first dispatch shape that
needs it). Compiled holds its inputs and a OnceLock for its lowering, made
for a content whose partial-threadgroups variant runs only whole SIMD groups.
encoder::decide takes a Need: prepare_dispatch and a dispatch lower it from
their state's descriptor, once, a racing thread waiting in the OnceLock; the
state's make and dispatch_variant read keys and lower nothing. A dispatch's
lowering counts in Metrics::variant_translations_at_dispatch (also in the
replay's metrics), which a pre-pass that prepares every dispatch keeps at 0.
The lowering is lower_variant's, the same bounded translation through the
cache directory as every variant's; the translator's refusal of it stays the
dispatch's Gap::PartialThreadgroups { site: SimdGroups }, any other failure
is reported as itself. Its dispatches count as emulated SIMD-group
dispatches and partial-variant ragged grids. Compiled's drop releases it.

Docs: prepare_dispatch's and dispatch_variant's docs, the counter's, the
SimdGroups site's, the runtime README (which variant is made when, the gap's
narrowed scope); api_signatures.tsv re-blessed.

Tests: every_device_runs_a_ragged_grid_of_partial_simdgroups_on_emulated_simdgroups
and every_device_frees_a_ragged_grid_s_modules_with_its_content now also read
the counter: 1 for k24_s32's first dispatch on a subgroup-tier card, 0 after
k8_s48's prepare_dispatch, 0 where the variant emulates its SIMD groups
already.
2026-12-02 14:24:10 -08:00
Anees Iqbal adfd60f805 rt tests: a ragged grid at threadgroups of partial SIMD groups runs on emulated SIMD groups (red)
wps_uint_k24_s32 and wps_uint_k8_s48 over dispatchThreads grids of 184
threads in threadgroups of 48: each threadgroup one whole SIMD group and a
partial one. Where the kernel's partial-threadgroups variant runs only whole
SIMD groups (a subgroup tier), the dispatch is refused today with
Gap::PartialThreadgroups { site: SimdGroups }. The tests want the grid run on
emulated SIMD groups, the whole SIMD groups' words equal to the CPU's, the
words past the grid untouched, a prepare_dispatch ahead of k8_s48's
dispatches, and the map of compiled contents, filled past a cap of 1, freeing
the first content's modules with its state.

Red on a subgroup-tier card; passes where the variant emulates its SIMD
groups already (lavapipe, the Intel GPUs).
2026-12-02 14:24:10 -08:00
Anees Iqbal 819d811015 rt README: the Iris Xe places a texture in a Shared heap too
The known gaps of textures named lavapipe and the Radeon 780M as the
devices whose optimal images take the Shared memory type. The Iris Xe
(Mesa 26.2.6) takes it as well: its run of the rt and harness heap,
Shared-heap sampling, export and churn_rest tests at development
30e7be6aff's product code (archive m3-max-79814, run m3-max-79854)
placed a source and a target in a Shared heap, wrote, read back and
sampled them, and churn_rest held every gauge with the kind included.
The same archive on the RTX 2080 (m3-max-79855) took the refusal path
and passed, heap.rs's Shared-descriptor size queries included, and on
the Radeon 780M (m3-max-79856) placed and sampled them: 8 of 8 each.
2026-12-02 14:24:09 -08:00
Anees Iqbal 9e510fa042 rt README: a Shared heap's texture on a discrete device reads and writes across its link, 97 times as long on the RX 7900 XTX
This is the timed row the ruling on Shared heap textures asked for. It was taken on the RX 7900 XTX
(RADV, Mesa 26.2.6, job m3-max-79841), behind a PCIe 4.0 x4 link. That is the narrowest link
upstream of the card: the bridge at 16 GT/s x4. The test is a helper branch's own and does not
land.
- The harness's sample_down kernel sampled a 4096 by 4096 RGBA16Float texture (128 MiB) into a
  2048 by 2048 target, 10 dispatches in each command buffer.
- The texture was placed once in a Private heap and once in a Shared heap, with the same
  descriptor.
- 7 command buffers of each were alternated in one job. The GPU spans are the command buffers'
  own GPU start and end times.
- Private: median 2.099 ms (2.093 to 2.103).
- Shared: median 203.136 ms (203.079 to 203.184).
- The ratio is 96.8: about 640 GB/s against 6.6 GB/s, the link's rate.

A first run (job m3-max-79822) filled the texture with one repeated texel. Its Private arm read
1.28 GB in 0.458 ms, faster than the card's memory, because the image compresses a constant
texel. The row above uses texels from a xorshift64 sequence, which nothing compresses.

The NVIDIA cards place no Shared heap texture (the bullet above), so this cost is the discrete
AMD case. Nothing works around it, as the ruling says. A Mac whose Metal makes Shared heap
textures has unified memory, where the cost does not arise.
2026-12-02 14:24:09 -08:00