Commit Graph
1535 Commits
Author SHA1 Message Date
Anees Iqbal 8e39e812e5 rt: a blit encoder copies between a buffer and a texture, one copy command an image of the region
copy_from_buffer (copyFromBuffer:sourceOffset:sourceBytesPerRow:sourceBytesPerImage:sourceSize:
toTexture:destinationSlice:destinationLevel:destinationOrigin:) and copy_from_texture_to_buffer
(copyFromTexture:sourceSlice:sourceLevel:sourceOrigin:sourceSize:toBuffer:destinationOffset:
destinationBytesPerRow:destinationBytesPerImage:) record vkCmdCopyBufferToImage or
vkCmdCopyImageToBuffer against the buffer's own range of its block, nothing staged, between the
two barriers a texture copy records. One region per image of the region, each at its own offset
(offset + image x bytesPerImage), so an image stride of no whole number of rows copies too;
bufferRowLength is bytesPerRow in texels, 0 for one row. The second barrier also makes a buffer
write visible to every later command, and a write into a Shared buffer marks the segment, whose
end barrier reaches the host. BufferLayout carries the offset and the two strides.

Refusals follow probe blit_buffer_copy_rules.m on an Apple M3 Max, macOS 27.0.1 (jobs
m3-max-43541, m3-max-43545): Metal's validation stops an offset or a row stride of no whole
texels, rows or images closer than the region's and a region past the buffer's end
(Refusal::BufferCopyLayout); it takes an R8Unorm offset of 2, a row stride of 0 for one row, image
strides of no whole rows, and bytesPerImage on 2D and 1D-array copies. Where Metal takes bytes a
copy command cannot address (a depth or stencil offset not a multiple of 4, as a 16-bit depth at
2; a compressed offset or row stride of no whole blocks, as BC1 rows 20 apart, which Metal takes)
it is Gap::BufferCopyAlignment. TextureBytes and FloatDepthUpload now name the blit copies too.

Tests: pure checks of the regions (padded rows, one row, a 3D region's images at their own
offsets, a 1D array slice, BC1 blocks) and of each refusal and gap; a device test copying into a
mipmap level, out of an array slice and a 3D region at padded strides, into a 1D array slice and
BC1 blocks, each result held to plain Metal's FNV-1a 64 (probe blit_copy_layouts.m, job
m3-max-43555, plain and under the validation layer), and one copy into a Shared buffer alone at
one submission, three barriers, no byte of the runtime's own.
2026-11-17 18:36:53 -08:00
Anees Iqbal 2105fa114e rt: heap textures, bound at the consumer's offsets in a heap's range of a Private block
A heap is a range of a Private block the consumer took at the heap's creation
(HeapRange: block, offset, length), as the plan decided: one Private range per
heap, resources at the offsets the guest's first-fit allocator picks.

Device::heap_texture_size_and_align answers heapTextureSizeAndAlignWithDescriptor:
with this device's image requirements (vkGetDeviceImageMemoryRequirements of the
same create info new_texture uses), never Metal's: the size rounded up to and
the alignment raised to bufferImageGranularity, so a buffer placed by the same
answers never shares a granularity page with the image. Replay showed why: one
vendor's image for a recorded heap texture is larger than the recording
device's (7.47 MB in a 5.9 MB heap), so the guest places by this answer.

Device::new_heap_texture binds the image at the heap offset: no allocation and
no texture block, bytes not zeroed (as Metal's heap textures), aliasing allowed.
A placement past the heap's end, an offset in the block off the image's
alignment, or a heap range past its block is Refusal::HeapTexturePlace at
creation; the image is never bound outside its heap. A Shared block, or an image
that requires an allocation of its own or does not take the Private type, is
Gap::HeapTexture (every optimal image measured takes the Private type). The
image holds the block, so a released block returns to the pool only once its
heap textures' images are gone.

new_texture's checks move into Device::prepare, shared with the size query, and
the image's create info into image_info. README: heap textures leave the
not-built line; REFUSALS.md and the signatures table updated.

Test: tests::heap::every_device_places_heap_textures_at_the_consumer_s_offsets
(answer equals the image's own size rounded to granularity; first-fit
placements allocate nothing and keep their own bytes; an alias; refusals for
past the end, off the alignment, a heap past its block, and a Shared block).
2026-11-17 18:26:07 -08:00
Anees Iqbal 8fc4064da5 rt: Managed textures, an image and the consumer's named bytes, uploaded by a device copy
A Managed texture is a Private image plus a range the consumer names, on every
device. Device::new_managed_texture takes a Shared buffer and, per level and
slice, a BytesPlace (offset, bytes per row, bytes per image) laid out as the
consumer chooses; rt never picks the layout. Places that a buffer-to-image copy
cannot read in place (rows not whole texel blocks apart, images not whole rows
apart, a first byte off the block's bytes or off 4 for depth/stencil, a level
leaving the buffer, a wrong count, a buffer the host does not reach) are
refused with Refusal::ManagedTextureBytes.

Texture::upload_region(region, level, slice) records one vkCmdCopyBufferToImage
from the named place into the image in the upload, ahead of every command
buffer committed after the call on every queue, as did_modify_range copies a
Managed buffer: no CPU copy, no staging. On such a texture replace_region
writes the named bytes (Metal's CPU copy) and uploads them; get_bytes reads the
named bytes with no submission. The texture copy's record() now takes a buffer
and region, so staging and named copies share it.

README, the API.md accepted difference (the copy reads the bytes when the GPU
reaches it), REFUSALS.md and the signatures table updated.

Test: tests::managed::every_device_copies_a_managed_texture_s_named_regions
(whole-level uploads, a sub-region upload with an unmarked change outside it,
get_bytes reading the named bytes, replace_region writing them, six refusals).
2026-11-17 18:26:07 -08:00
Anees Iqbal 60fe8aacaf rt: TextureCopyMismatch quotes Metal's messages as code
Rustdoc read "[destinationTexture sampleCount](1)" as a link and failed -D warnings (job
m3-max-43474).
2026-11-17 18:10:36 -08:00
Anees Iqbal f10ed213a0 rt: the blit device test holds each copy's expected bytes to plain Metal's
Each expected result's FNV-1a 64 is the hash probe blit_copy_layouts.m printed on an Apple M3 Max,
macOS 27.0.1 (job m3-max-43464, at 31f5a93c4b), plain and under the validation layer alike: a
level into an array slice, a cube face into a 3D slice, a 3D slice into 2D, slice to slice and
BC1 blocks. The format-pair probe's sample-count case ran too (job m3-max-43465): Metal's
validation stops four samples into one with "[sourceTexture sampleCount](4) must equal
[destinationTexture sampleCount](1)", which Refusal::TextureCopyMismatch's basis now cites.
2026-11-17 18:10:36 -08:00
Anees Iqbal 42d274f91a rt: a blit texture copy takes one pixel format and one sample count, as Metal's validation does
Metal's validation layer stops copyFromTexture between any two pixel formats (Apple M3 Max,
macOS 27.0.1, probe blit_copy_format_pairs.m, job m3-max-43433): RGBA8Unorm into sRGB, Uint,
R32Uint and BGRA8Unorm, R32Uint into R32Float, Depth32Float into R32Float and BC1 into RG32Uint all
fail with "[sourceTexture pixelFormat] must equal [destinationTexture pixelFormat]"; the same
format is taken. So Refusal::TextureCopyMismatch is now every pair of two formats (basis
metal-measured, was metal-takes), and the rules for copying between formats of one unit's bytes
are gone: no alpha special case, no block, aspect or unit comparison. What stays a gap: a
multisample texture, depth and stencil both, a 1D texture with another type, one subresource
into itself, and, new, one pixel format held in two Vulkan formats by the textures' usages, whose
texels may sit in two layouts.

The device test's array is RGBA8Unorm now (the copy into it was RGBA8Unorm into R32Uint), and the
slice-past-the-array check copies into a texture of its format: on 7f2a3c5cb1 it met the format
check first on every device (legs m3-max-43406, 43407, 43408: RX 550, 780M HawkPoint, 3090, XTX,
2080, 780M Phoenix, lavapipe; every assertion before it passed, validation errors 0).
The probes add the sample-count case and make the layout probe's array RGBA8Unorm; their runs
follow.
2026-11-17 18:10:36 -08:00
Anees Iqbal 247ed69da0 rt: a blit encoder copies a region of one texture into another, one vkCmdCopyImage between two barriers
CommandBuffer::blit_command_encoder (blitCommandEncoder) and BlitCommandEncoder::copy_from_texture
(copyFromTexture:sourceSlice:sourceLevel:sourceOrigin:sourceSize:toTexture:destinationSlice:
destinationLevel:destinationOrigin:, the only texture-to-texture selector the compute recordings
use: 2,736 copies in one, 3 in the other, none multisample, compressed or within one texture).

The copy is recorded at once into the current segment: no staging and no byte beyond the region.
The first barrier moves each texture's level and slice from home to its transfer layout and carries
the global barrier (every earlier write visible to every later command), so it pays what an encoder
owed and the hazard sets start again; the second moves them home with the copy's writes visible to
every later command. A command buffer of one copy is one submission and three barriers (the
segment's end among them), and Metrics::bytes_copied does not move.

Bytes move as they are between formats whose units have the same bytes; a compressed region is
whole blocks or reaches the level's edge on both sides; a 3D image copies to and from a 2D slice.
Refusal::TextureCopyMismatch for units of different bytes or different sample counts (Metal stores
its GPU's own layout there); Gap::TextureCopy for what one vkCmdCopyImage in the floor does not
make (multisample, depth and stencil both, depth or stencil with another format, compressed with
another block extent, A8_UNORM with another format, 1D with another type, one level and slice into
itself). The texture's region check is shared with replace_region and get_bytes (texture::place).

Tests: tests::blit (the rules, no device) and on every device of the cfg's kind
tests::blit::on_device::every_device_copies_between_textures (bytes of a level into an array slice
of another format, a cube face into a 3D image, a 3D image into a 2D texture, one array slice into
another, BC1 blocks where made; 1 submission, 3 barriers, 0 bytes copied, 1 pass for one copy; an
owed barrier paid by the copy: 3 barriers, 4 without the fold).
2026-11-17 18:10:04 -08:00
Anees Iqbal 4732ce6cd7 rt: a buffer bound off its argument's alignment runs at the address rounded down to it
The binder (ComputeCommandEncoder::fill_parameters) pushes each bound buffer's address,
its gpuAddress plus the bind offset, rounded down to a multiple of the alignment the
kernel takes it to have (FieldValue::BufferAddress's mask, from
RuntimeFact::AddressAlignment: the argument's air.arg_type_align_size, at most 16), for
every slot. Refusal::MisalignedBuffer and the dispatch it skipped are deleted, so
fill_parameters cannot fail.

Why: Metal's API validation refuses such a bind offset, and without validation an Apple
M3 Max (macOS 27.0.1) reaches each element at its address rounded down to the smaller of
the element's alignment and 4, for loads, stores and pointers stored in a buffer alike.
The probe that measured it is committed as
crates/metal2vulkan-conformance/probes/misaligned_buffer_binds.m. The two agree at
alignments 2 and 4 and for 8- and 16-byte arguments bound 1 to 3 bytes off a multiple of
4; an 8- or 16-byte argument bound at a multiple of 4 that is not a multiple of its
alignment is reached at the rounded address where the M3 reaches it exactly there, a bind
Metal's validation rejects. docs/API.md section 10 lists that as an accepted difference.

Tests: rt's every_device_rounds_a_bound_address_down_to_its_alignment steps a buffer bound
off each alignment (2, 4, 8 and 16; 15 binds) through the step kernel with the mask set,
and checks the words stepped start at the rounded address; at the 8- and 16-byte binds 4,
8 or 12 bytes off, an unrounded bind would step other words on any device.
an_argument_bound_off_its_alignment_runs_at_the_address_rounded_down binds
vector_word_phases' vwp_words 1 and 3 bytes and vwp_vec16 4 and 12 bytes off their
alignment and expects Metal's words for the rounded binds. They replace
an_argument_bound_off_its_alignment_is_refused and
a_misaligned_dispatch_refused_leaves_its_encoder_and_command_buffer_usable.

Docs: REFUSALS.md and api_signatures.tsv regenerated (the variant's row goes), the rt
README's compute encoders say what the binder pushes, the translator's
RuntimeFact::AddressAlignment doc and the mechanism comment say the binder rounds.
2026-11-17 18:07:45 -08:00
Anees Iqbal ee7c4a5173 rt: Managed buffers, a device copy where Shared memory is not device-local
newBufferWithLength:options: and newBufferWithBytes:length:options: with Managed storage over a
range of a Shared block the consumer names: Device::new_managed_buffer(block, offset, length,
copied). The device's memory-type query picks the form. Where the Shared type is device-local the
buffer is its bytes, as a Shared buffer is, and didModifyRange does nothing. Elsewhere shaders
reach a device copy in Private memory, as Metal keeps one on a Mac with a discrete GPU.

The device copy is a place in a copy block: a Private block of the pool, or a dedicated one past
BLOCK_LEN, in a set apart from the texture blocks, so no buffer lies beside an optimal image. Its
first `copied` bytes are copied from the consumer's and the rest zero-filled, in the upload.
Buffer::did_modify_range(start, length) marks a range changed: the upload, which goes ahead of
every command buffer committed after the call on every queue, copies it from the consumer's bytes
into the device copy as it is submitted, one vkCmdCopyBuffer per buffer with its ranges merged
where they overlap or touch, after a counted barrier that puts the upload's earlier fills first.
No CPU copy, no staging, nothing sized by the call. Each change is one of the upload's 4,096 calls,
so changes past them submit it and wait. The copy reads the bytes when the GPU reaches it, which
docs/API.md records as an accepted difference.

A command buffer keeps each device copy it uses, and an upload each one it copies into, until it
retires; the copy's place is freed then. An indirect dispatch reads its arguments from the device
copy. Places take a core and give a block back once it empties where it is dedicated or another
pooled block of the set is empty; Core::take_memory chooses a pooled or dedicated block for both
take_block and the places.

Refusals: ManagedBlockNotShared (a Private block) and ModifiedRange (a range past the buffer),
both ours; docs/REFUSALS.md and the signatures table regenerated.

Tests: changed ranges merge where they overlap or touch; on every device, in the form its query
picks, the device copy holds the first bytes and zeros, a changed range reaches it at the next
submission and an unmarked change does not, changes past the upload's calls submit it (none
without a copy), both refusals, and every gauge zero after teardown.
2026-11-17 18:00:53 -08:00
Anees Iqbal bf3d3c1ebb rt: GPU times placed by calibrated timestamps on one host clock, the anchor deleted
VK_EXT_calibrated_timestamps joins the floor's device extensions under that one name, and the
floor requires the device to calibrate its own clock (VK_TIME_DOMAIN_DEVICE_EXT) with the host
clock's domain, HOST_DOMAIN: CLOCK_MONOTONIC on Linux and other Unix systems, CLOCK_MONOTONIC_RAW
on macOS, the performance counter on Windows. A device that does not is below the floor
(floor::Missing::TimeDomain). host_time() reads that same clock, so a command buffer's GPU times
and its kernel times are on one clock with no bridge; on macOS it counts while the system sleeps,
where Metal's mach_absolute_time does not, which host_time()'s doc and the README state.

The completion thread calibrates once as the device starts, and again at a completion once
100 ms (CALIBRATION_PERIOD) have passed since the last: one vkGetCalibratedTimestampsEXT call of
the two domains, no deviation loop, never per command buffer. Each completed command buffer's two
timestamps are placed by the last calibration, the tick difference taken signed within the valid
bits. The anchor estimate, which took the host time a completion was seen as an end and moved
later only by the least lateness of 64 passes, is deleted with its rule.

Tests: the times test now holds each command buffer's GPU start and end between host_time() read
before its commit and the host time its completed handler reads; a new test holds that the device
calibrated at start, not while idle for 150 ms, and once at the first completion of a 32-buffer
burst plus at most one per 100 ms it ran; a floor test names a missing host or device time domain.
No conformance or harness check compares rt's GPU times with Metal's in absolute terms
(conformance relates the old runtime's times; the harness compares durations and spans).
2026-11-17 17:59:18 -08:00
Anees Iqbal f34c4a22d2 rt: every memory allocation counts against the device's maxMemoryAllocationCount, refused before the driver past it
rt never counted its vkAllocateMemory calls, so it could pass the device's
maxMemoryAllocationCount, which VUID-vkAllocateMemory-maxMemoryAllocationCount-04101
forbids: blocks, each texture's own memory, each staging buffer of replace_region
and get_bytes, the parameter ring's blocks and the zero source.

Every allocation now goes through memory::allocate, the one vkAllocateMemory call.
The live count is the blocks gauge, which already counted exactly these
allocations: allocate raises it only while it is below the device's count, else
returns Limit::MemoryAllocations { max } without calling the driver, and gives the
count back where the driver fails. Each site's own rise of the gauge after its
allocation is gone; the texture's and the staging buffer's failure paths after the
allocation now lower it as they free it.

Device::new is Device::open with the device's limits as queried; a test opens a
device with maxMemoryAllocationCount answered as 8. With the zero source and the
two ready blocks live, five 4x4 textures are made and the sixth is refused with the
typed limit, the gauges unchanged; a replace_region then is refused the same way
for its staging buffer; once a texture is dropped and its memory freed, a texture
is made again; every gauge reads zero after teardown.

The Err docs of Device::new, take_block, new_texture, replace_region (get_bytes
takes its list), set_bytes and the dispatches name the limit, and the runtime's
README states what counts and the limits measured: about 4.29 billion on RADV,
NVIDIA's Linux driver and ANV, 8,401,685 on Intel's Windows driver for the UHD
Graphics 630, 4,096 at Vulkan's minimum. docs/REFUSALS.md and the API signature
table are regenerated for the new Limit variant.
2026-11-17 17:43:57 -08:00
Anees Iqbal 76ddb7ed45 matrix: a harness row over its budget is re-timed in its leg, three alternating pairs, judged by the median
The matrix at 4e02a34a38 failed vote_loop on the HawkPoint 780M at 1.123, new over old, from one
timed window each. Five alternating rounds on that GPU read a median of 0.992, one new window
held a slow state throughout (662.8 us against 415.5 to 415.9), and the Phoenix 780M read 0.999:
one window caught in a clock episode decided the row.

- harness_runs keeps each runtime's output (tee) and, after the last runtime's run, before its
  suite's line, chooses the rows over their limit (results.RETIME_SELECT, awk over both outputs:
  each listed row's ceiling times HARNESS_BUDGET, else HARNESS_BUDGET, the same comparison of the
  same decimals as harness_budget), at most RETIME_ROWS (8), the furthest over first. Each is
  re-timed alone in RETIME_PAIRS (3) pairs, old then new, the second pair new then old, and only
  its time records are kept, as harness-retime/<row>/<pair>/<runtime>.
- harness_budget judges a row past its limit by the median of its pairs' ratios where all three
  pairs are there: a problem past the limit, else named with its pairs; a row the leg did not
  re-time is judged by its one time as before. The pairs are parked records for the time rule.
- docs/VALIDATION.md states the rule beside the budget.

Verified (job 43277, msi, GNU awk 5.4.1): the matrix's rule tests, 28 of 28, among them an
episode in one pair that does not decide a row, a regression in every pair that fails it, a row
with a pair missing judged by its one time, a listed row judged against its ceiling's limit, and
the leg's awk choosing exactly the rows harness_budget fails on their one time, at the 2.06 edge
of a 2.0 ceiling; then the rendered harness_runs run under bash with a fake harness for an unlisted
and a listed leg: it re-timed burst_160 (2.0 in every pair) and frame (1.0, 1.5, 1.0), and
harness_budget failed burst_160 on its median and named frame within, judged by the median.
2026-11-17 16:59:41 -08:00
Anees Iqbal f3c0008bac translator: a slot held to its narrow unit is reached from its address as it is
Under the identity domains a buffer argument whose alignment is below 4 (a uchar or ushort
buffer, air.arg_type_align_size 1 or 2) took the word form: each access rounded its 64-bit
address down to the word below it. Where every access of the slot is one narrow unit no wider
than its alignment (an i8 access of a uchar buffer, an i16 one of a ushort buffer, on a profile
with that width's storage access), the unit lies at its own address, so the slot now takes the
direct form, as a slot held to 4 does.

AccessPlan::reach records the granularity each slot's static-root accesses reach: a OneWord
leaf of a narrow unit the profile has, its size; any other leaf, a copy's endpoint and an
atomic, 4. A slot is reached from its address as it is where its alignment is at least that
(capped at 4). address_alignment now answers 1 for an argument with no alignment or one of 1;
the AddressAlignment fact is still stated only from 2 up.

engine_narrow_direct checks buffer_end_byte_load, buffer_end_byte_store and
buffer_end_half_load on every identity profile: no 64-bit and (the word form's rounding) where
the profile has the unit, the word form where it does not, L3 passes, and the narrow access
claims its unit's alignment. SEMANTICS_VERSION 2167.
2026-11-17 16:52:34 -08:00
Anees Iqbal 4232d4ed9b translator: every slot held to 4 is reached from its address as it is
Under the identity domains a device-address slot whose argument's alignment is at least 4 now
takes the direct form whatever its window: each access is the slot's address plus its 32-bit
byte offset from the bind address, sign-extended. The runtime makes no buffer longer than 2 GiB
(MAX_BUFFER_LENGTH), so every byte of a buffer lies within 2^31 bytes of each bind address in it
and the sign extension is exact. The window no longer picks the form, and the offset is taken
from the bind address rather than the window's start, so the start's 64-bit add and 32-bit
subtract go and the start need not be a multiple of 16 (the alignment proofs are from the bind
address). DIRECT_WINDOW and direct_window are deleted, and so is the test of accesses past
2 GiB, which the 2 GiB cap puts outside every buffer; the interpreter test of accesses up to
2 GiB stays. Slots held to less than 4 keep the word form.

The word-phase alignment test now expects one uvec4 in every slot held to 16, its Whole window
included. SEMANTICS_VERSION 2166: identity-domain modules change.
2026-11-17 16:50:10 -08:00
Anees Iqbal d48c2bfc78 rt: the longest buffer is 2 GiB
MAX_BUFFER_LENGTH drops from 4 GiB to 2 GiB, so every byte of a buffer lies within 2^31 bytes of
each bind address in it, which lets the translator read a buffer argument's 32-bit offsets as
signed for every slot. A buffer of 2 GiB is made; one a byte longer is refused with
BufferTooLong. The consumer states Metal's maxBufferLength no larger than this.

The device test is renamed to its 2 GiB length (a 2 GiB Private block, made where a block
allows it, then 2 GiB and a byte refused, gauges zero at drop), and the interpreter test now
loads and stores up to the last word below 2 GiB of the bind address and checks that each lands
at its own word. REFUSALS.md and api_signatures.tsv regenerated.
2026-11-17 16:50:10 -08:00
Anees Iqbal 661b97c6e8 rt: a buffer longer than 4 GiB is refused
A shader reaches a buffer argument's bytes by 32-bit offsets from its bind
address: every access form adds the u32 Metal offset to the slot's 64-bit
address, so an access 4 GiB or more past the bind offset lands 4 GiB
below, inside the buffer, with no fault. Device::new_buffer now refuses a
length past MAX_BUFFER_LENGTH (4 GiB, one constant) with
Refusal::BufferTooLong, before the block's range is looked at; heap
buffers and a consumer's no-copy placements go through the same call.
Metal answers nil past a device's maxBufferLength, which the consumer
states no larger than this (the README's contract line).

Tests: rt's every-device memory test refuses 4 GiB and a byte and
u64::MAX on a pooled block, typed; a test of its own makes a buffer of
exactly 4 GiB in a Private block of that length where the device has one
(skipping visibly where its largest block or memory is smaller), refuses
one a byte longer, and ends with every gauge at zero. The translator's
interpreter test loads and stores up to the last word below 4 GiB through
a Whole window under the identity domains, each landing at its own word.

REFUSALS.md and api_signatures.tsv regenerated.
2026-11-17 16:50:10 -08:00
Anees Iqbal 0a82834fd2 rt: a kernel that does not observe its threadgroup partition runs its grid in fitted tiles, with no division
A kernel that does not observe its threadgroup partition reads only thread_position_in_grid and
threads_per_grid, so only the set of positions matters. Its partial-threadgroups variant used to
answer Metal's partial threadgroups in rt's tiles (256x1, or the grid's width rounded down to a
power of two): each thread rebuilt its position by UDiv/UMod of its index by the threads left, and
tiles fitted only by width launched 1.68x to 4x the grid's threads on 3D grids of 8x8
threadgroups. On the RX 550 such rows ran up to 3.67x the old runtime's time.

On Device::from_queries' profile under the identity domains (ProfileFacts' new ObliviousEdge,
Grid there, Partial on Device::new's, whose modules stay byte-equal), such a variant states
RuntimeFact::GridTiles and runs its grid in tiles:
- Under MultiRegion 1 its workgroup of GRID_TILE_THREADS (256) is one tile whose power-of-two
  sides the region's nominal size gives. Its position is ((base + WorkgroupId) << s) +
  (idx & m.x, (idx >> s.x) & m.y, idx >> (s.x + s.y)), with m = L - 1, s = bitCount(m), and idx =
  LocalInvocationIndex: masks and shifts of uniform values, no division, nothing new pushed.
- Where the region is flagged NONUNIFORM, an invocation past the grid returns before the body.
  On the RX 550 the driver folds the flag into the exit's exec mask, so the three compares issue
  on every wave; the prologue to that exit is 10 VALU (7 for the position, 3 compares) and 18
  SALU, where the old runtime's is 14 VALU. One pipeline and one form: no second pipeline for
  whole grids.
- Under MultiRegion 0 (an indirect dispatch) it runs at its pipeline's size, as a plain kernel:
  the specialization folds the tile and the exit away.

pipeline::grid_tile(threads) picks the tile from the grid's extents alone, with no device input:
sides 2^a, 2^b, 2^c with a + b + c = 8, the first in one total order over those 45 tiles:
1. the fewest threads launched;
2. then the fewest tiles partly past the grid;
3. then the shallowest (z side 1 first);
4. then, where the grid has two rows or more, the height nearest 2 (|b - 1| smallest);
5. then the widest.
A one-row grid takes 256x1 by its waste. Why this order: among tiles of equal waste the shape
measured within 3% of the best everywhere is 128x2. On the UHD 630, the slowest GPU, 256x1 was
first on every image row and 64x4 cost 5% to 10%; 128x2 stayed within 3% of 256x1 on every such
row. On the 780M avoiding wide tiles helped (sampling 1.028 of the old runtime), and on the RX 550
having more than one row did (texture_write 1.024). The measured rows are its budgets: the RX 550's
21 rows of 3D grids of 8x8 threadgroups, waves, sample_down and sample_up, and the texture
rows on the 780M, 3090 and RX 550.

grid_tile's paths:
- Where the powers of two that divide the extents reach 256 it takes the first tile that
  divides the grid.
- Where one tile holds the grid it takes the first tile that holds it.
- Otherwise it tries the 45 tiles in the order, computing each tile's counts as it goes. It
  passes over a depth 2^c whose bound, ceil(z / 2^c) * ceil(x*y / 2^(8 - c)), exceeds the fewest
  tiles found so far.
24x24x252 and 8x8x360 take 8x8x4 with no waste, 8x8x22 8x8x4 (1.09x), 304x304 16x16,
1024x1024 128x2, 5600x4200 32x8, a row 256x1 and a column 1x256.

rt runs every direct dispatch of such a kernel on one VkPipeline (256x1x1, MultiRegion 1, made
with the state), each region carrying its tile. The indirect pipeline is made at the state's
first indirect dispatch, a first-use wait, and is counted in the pipeline gauge. The
translator's binder plans a GridTiles kernel's Threads and Threadgroups dispatches the same way,
and a ThreadgroupRange at its own size with MultiRegion 0.

Tests:
- lower::dispatch: the rule's table (whole and ragged square, wide, tall, deep, one-row and
  one-tile grids, each with its tile), and grid_tile against the order taken over every tile on
  12,850 grids.
- engine_identity: on the interpreter, ragged-in-3D, whole, z-ragged, row and column grids store
  each of Metal's positions once and nothing past the grid; an indirect dispatch runs at its own
  size; from_queries' module divides by no run-time value, Device::new's still does.
- rt translate: the narrow threadgroup dispatch now shares the tiles' pipeline. The tiles test's
  indirect dispatch makes one more pipeline by one first-use wait, and every gauge, pipelines
  included, is zero at the device's drop.

SEMANTICS_VERSION 2166; ARTIFACT_FORMAT_VERSION 533 (the new fact).
2026-11-17 16:30:42 -08:00
Anees Iqbal eea1ef870e matrix: harness first uses compile cold on a fresh driver cache, and warm on a second run
The matrix at 691b0e43d1 failed four legs on harness-new/authored/first_use_wait_total against
9c61460b3d: on AMD it went from 0.3-0.5 ms to 7.9-33 ms. The driver's shader cache explains it. The
matrix gave the harness the node's own cache (~/.cache/mesa_shader_cache held 260 entries on the
XTX's node), so a commit whose modules the node had compiled before read hits, and one that changed
them read misses. Run with a fresh empty cache directory, then again on it (jobs 42912 and 42913),
authored first_use_wait_total in us:

  XTX   base 9c61460b3d cold 5,833 warm 411; tip 691b0e43d1 cold 5,551 warm 390; the base on the
        tip's warm directory 7,198 (its modules differ, so they miss); the node's own cache 446
  2080  base cold 34,062 warm 4,178; tip cold 75,715 (one slow cold run) warm 4,479;
        the node's own cache 32,555 (~/.cache/nvidia/GLCache held 2 entries, so NVIDIA read cold
        at both commits)

and base and tip alternating cold on the 2080 (job 42933): 36.7, 34.3, 36.7, 33.0 ms; the 75.7 did
not recur when 42913's runs were repeated (job 42945: tip cold 34.9).

The Intel driver on the Windows host keeps one too: three runs in a row on the UHD 630 read 54.9,
1.9 and 2.0 ms (job 42935), and with LOCALAPPDATA and USERPROFILE pointed at a fresh directory,
58.8 then 1.3 ms, its entry written there, then 1.4 ms on its own cache (job 42950).

So each runtime's harness run now has a fresh empty cache directory, MESA_SHADER_CACHE_DIR for
Mesa, __GL_SHADER_DISK_CACHE_PATH for NVIDIA, and on the Windows host LOCALAPPDATA and USERPROFILE
pointed into it, and its first uses compile cold whatever ran on the node before: those records
stay as they are and are judged. For the new runtime (HARNESS_WARM; the old runtime counts no
first uses), a short second run on the same directory (--runs 5
--warmup 1 --no-settle) follows before the suite's line, and its first-use records are kept as
harness-new-warm/<set>/first_use_*, the same first uses with the cache warm. PARKED_RECORDS parks
them: the cold ones gate.

docs/VALIDATION.md says so.

Verified: the matrix's rule tests, among them a warm first-use outlier parked beside a cold one
that fails; and the rendered harness_runs against a fake harness that reports how many files its
cache directory held when it started: the old and new runs each started on an empty
directory (cold 0), the new runtime's warm run on the one its cold run wrote (warm 1), the warm
records in the harness-new suite and none for the old runtime, every directory removed; in the
Windows form (cygpath faked) both variables in the run's directory; and the rendered GPU and
Windows scripts parse (bash -n).
2026-11-17 16:03:43 -08:00
Anees Iqbal 0f854aef98 translator: the direct form adds the sign-extended offset in 64-bit integers, with no pointer bitcast
A bounded slot's access was a byte array's element at its 32-bit offset, the
element pointer bitcast to a pointer to the unit's one-member Block. The
UHD 630's Windows driver (Vulkan 1.3.215) ends the process in that shape
(exit 139, every kind), and passes the integer address with OpConvertUToPtr
to the same Block. Each access is now the slot's address plus its offset
sign-extended (OpSConvert), then one OpConvertUToPtr: the integer form of the
access chain's signed index, which RADV lowers alike (iadd of an i2i64), with
no zero-extended offset for GFX11 to split into a scalar base and a vector
offset. The window is at most 2 GiB (direct_window, tested at 2^31 and one
byte past), so the sign extension is exact.

The byte array and its element place (device_byte_place, device_element)
have no other user and are deleted, and the identity domains no longer need
storageBuffer8BitAccess.
2026-11-17 15:30:39 -08:00
Anees Iqbal 643271b319 rt: refuse a dispatch whose buffer address breaks its argument's alignment
A kernel states RuntimeFact::AddressAlignment for each buffer argument with an alignment of 2
or more, and reaches one of 4 or more from its address as it is. Metal's API validation refuses
such a bind offset (measured on an Apple M3 Max by the conformance crate's
vector_access_placement probe: "must be a multiple of 4 but was set to 2" for a uint *
argument, "of 16 but was set to 4" for a float4 *). The pipeline records each such slot's mask
with its BufferAddress field, and fill_parameters tests address & mask where it forms the pushed
address, refusing the dispatch with Refusal::MisalignedBuffer { index, address, align } before
any work is recorded.

The test an_argument_bound_off_its_alignment_is_refused binds a float4 argument at offset 4
(refused, naming index 0, align 16 and the address) and 16 (runs), and a uint argument at 2
(refused, align 4) and 4 (runs). docs/REFUSALS.md is regenerated and the api_signatures table
gains the variant.
2026-11-17 15:30:38 -08:00
Anees Iqbal 28f9b1db27 translator: identity slots aligned by their argument are reached from their address as it is
Under the identity domains every buffer slot access rounded its address down to a word
(64-bit add, and 3, sub, subb per access) and moved 8- and 16-byte values as words. On the
RX 550's one-wave dispatches that rounding is about 20 scalar instructions per wave.

Metal's API validation refuses a buffer bound at an offset that is not a multiple of its
argument type's alignment (air.arg_type_align_size): measured on an Apple M3 Max by the
conformance crate's vector_access_placement probe, "must be a multiple of 4 but was set to 2"
for a uint * argument (constant too, and a struct of two uints), "of 16 but was set to 8" (and
4) for a float4 *, "of 2 but was set to 1" for a ushort *; a uint * at 4, a ushort * at 2 and a
uchar * at 1 pass. So each plain buffer argument with an alignment of 2 or more states
RuntimeFact::AddressAlignment { slot, align } (at most 16), for a binder to refuse what Metal
refuses. Where that alignment is at least 4 and the slot's window starts at a multiple of 16,
the slot's address is a word memory's base as it is: each access is the 32-bit byte offset
m - start from address + start, through a PhysicalStorageBuffer byte array whose element
pointer is bitcast to a pointer to a one-member Block of the unit (NonWritable for an unwritten
slot's load), then member 0; nothing is rounded, and an 8- or 16-byte access at an offset proven
a multiple of its size is one uvec2 or uvec4. OpBitcast between PhysicalStorageBuffer pointers
is valid SPIR-V (SPV_KHR_physical_storage_buffer). Every other identity slot (no alignment, 1
or 2, a buffer-table element, an argument buffer) keeps the word below each access, as before.
Atomics take their word place the same way. The default policy, so Device::new and the old
runtime, is unchanged.

The identity domains now need storageBuffer8BitAccess (in the new runtime's floor).
SEMANTICS_VERSION and ARTIFACT_FORMAT_VERSION are bumped for the new output and fact.

Measured before this change on the scratch forms (the same SPIR-V shape, the byte view at the
pushed address, no rounding, no anchor):
- the constant-reads probe's 13 columns, against the identity form before it (geomean / worst
  column): RX 7900 XTX -4.3% / +0.5%, RX 550 -6.6% / +0.1%, RTX 3090 -54.2% / 0.0%. The
  64-bit add without rounding failed the XTX by 8.9%;
- short-wave rows on the RX 550 (ladder job 42427, emulated module, against the old runtime):
  k130 2.567x -> 2.295x, k106 1.656x -> 1.537x, k109 1.377x -> 1.233x, k171 1.342x -> 1.315x,
  waves 2.461x -> 2.377x.
2026-11-17 15:30:38 -08:00
Anees Iqbal fe9dd3d6da matrix: a listed row's ceiling has parity's 3% allowance; a row the old runtime failed is named and not compared
Two follow-ups to the harness budget.

The allowance. A ceiling is the row's ratio when it was listed, so run-to-run spread put rows just
past it: over the runs one commit before the seeds (08ff6ed59c), five rows came 0.1 to 3% past
their ceilings. A listed row now fails its leg only past its ceiling times HARNESS_BUDGET, the same
3% allowance parity gets. The ceilings stay the measured ratios and only go down.

Old-runtime failures. The old runtime is frozen and its regressions are parked, but a workload it
failed (on the UHD 630 at 8b15f6574b, one burst_2000x5 run ended in a GPU recovery,
GpuRecoveryVictim, in job 42642) failed the leg through the harness suite's exit code. PARKED_RECORDS
covered the old runtime's gauges and time outliers, not its failures. Now:
- the harness names the runtime of a failure: run_each wraps a session's error other than a
  refusal in Failed { runtime, why }, as is the creation workloads' error, and beside the FAILED
  line the command prints `M2V-FAILED harness-<runtime>/<workload>` (for each runtime of the
  command where the failure names none: a plan that could not be made, outputs that differ);
- the matrix runs each runtime's harness as a suite of its own, harness-old and harness-new, so a
  suite's exit belongs to one runtime, and a leg whose job reported either suite missing fails;
- results.py reads M2V-FAILED lines as a suite's failed tests; one under PARKED_RECORDS
  (harness-old/) is parked, so a harness-old suite that failed only by them has not failed, and
  harness_budget names the row "old failed, not compared". A harness-new failure still fails its
  suite, and a crash of either runtime's run, with no M2V-FAILED line, still fails its suite.

docs/VALIDATION.md says both.

Verified: the matrix's rule tests (24) pass, among them the allowance at its boundary (a ceiling
of 2.0: 206 over 100 passes, 206.1 fails) and an old-runtime failure parked beside a new-runtime
failure that fails its suite; the harness's unit test checks that a session's failure names its
runtime and that outputs that differ name none; and the rendered GPU and Windows scripts parse
(bash -n).
2026-11-17 15:10:34 -08:00
Anees Iqbal 37f0bf51f8 rt encoder arms: textures, sampler states and constexpr samplers by pushed index
ComputeCommandEncoder::set_texture (128 slots, Refusal::TextureArgumentIndex past them) and
set_sampler_state (16 slots, Refusal::SamplerArgumentIndex) bind as Metal's calls do, and
use_resource takes a texture as it takes a buffer. A dispatch pushes, for each texture and sampler
slot its kernel reads, the bound object's gpuResourceID (0 for none), whose index names its
elements of set 1; for a texture slot an integer write saturates through, the channel widths of
the bound texture's format (metal::format::integer_channels_word, now public); and for each
constexpr sampler, the index the consumer gave it. Nothing is written into set 1 at bind or
dispatch time, and every texture stays in its home layout. A texture's sample and read are reads
in the hazard sets, a texture one resource, with a hazard id from core's ids.

Each command buffer binds set 1 (vkCmdBindDescriptorSets, firstSet 1) once, before its first
pipeline; without it the lavapipe run reported VUID-vkCmdDispatch-None-08600. The command
buffer keeps each texture and sampler state an encoder binds or declares, in command.rs's Gpu
next to its blocks and pipelines, dropped with them at retire, so their elements stay theirs
while work may read them.

Device::new_compute_pipeline_state takes sampler_ids: the samplers the kernel numbers, in
Metal's order (NumberedSampler: each constexpr sampler, then one for a texture read and one for a
texture write), answered with an index each from the consumer's sampler grants
(Refusal::SamplerIds for another count). A constexpr sampler takes, before the call returns, the
device sampler of each use the kernel has (CombinedSampler::constexpr_sampler, canonical, shared
by create info with sampler states') at its index of the three sampler arrays; states that number
one constexpr sampler at one index share it, another sampler there is Refusal::IndexInUse, and
the last of them writes the defaults back and frees the index. Set 1's layout is checked against
the translator's (IdentityArray bindings). A kernel whose texture or sampler the translator would
take from the bound object rather than its resource ID stays Gap::KernelInput.

The harness grants its own texture and sampler indices on the new runtime and numbers constexpr
samplers by their words, so constexpr_sampling runs on it.

README: the encoder's texture and sampler arms, the numbering paragraph, the KernelInput gap.
REFUSALS.md regenerated; api_signatures and api_surface carry integer_channels_word and the new
refusals.

Verified:
- m3-max-42749 (msi), this tree: clippy of metal2vulkan-rt plain, --cfg m2v_gpu and --cfg
  m2v_cpu_icd green; rustdoc -D warnings green; nextest 37 of 37; the device tests on lavapipe
  under the validation layer 79 of 79, 0 validation errors (tests::sampling: sample_down through a
  runtime sampler, then sample_up through a constexpr sampler, against the linear filter's
  answers; the constexpr index shared, refused to a sampler state and freed with the last state).
- The same change on the sampler landing before development's region commits (tree
  ed71d2de2e): m3-max-42714 (780M, radv) and m3-max-42716 (3090), its archive under the
  validation layer, 76 of 76 each (the three source-reading tests skipped off the building
  machine), 0 validation errors, every gauge zero at drop; m3-max-42735 (UHD 630, Windows), its
  cross-built archive, 79 of 79, every gauge zero at drop.
- m3-max-42638 (msi), tree ed71d2de2e: clippy of metal2vulkan-harness plain and --cfg m2v_gpu green;
  the api_signatures and api_surface tests green.
2026-11-17 15:03:53 -08:00
Anees Iqbal bbf8fbb29a matrix: the harness budget, new over old per row on each GPU at most 1.03, with the rows over it held to ceilings
results.harness_budget compares the two runtimes within one leg. For every harness row timed on
both runtimes in the leg (harness-new/<row> and harness-old/<row>), the new runtime's time over the
old's is at most HARNESS_BUDGET, 1.03. HARNESS_CEILINGS lists the rows over it, per GPU, each
with its ratio as its ceiling. A listed row past its ceiling fails its leg, and a listed row within
it is named on the leg's line (with the parked items), so an open row can neither hide nor grow. A
fix lowers its row's ceiling, and a row within 1.03 is named as leaving the list.

This rule is separate from TIME_OUTLIER and PARKED_RECORDS, which judge a time against its base
commit's across GPUs and park the old runtime's outliers. The budget reads the old runtime's times
as its reference. It ends with the cutover, with the old runtime.

A time recorded more than once has no single value to judge: twice in one suite, where parse_suite
keeps the first and now lists the key in `duplicated`, or once each by two suites, where
leg_records keeps the later. Such a row is a problem of the budget's own, named and not compared,
beside the record problem the leg already has.

The matrix's harness suite now runs one job per GPU. Each job holds its node alone (--exclusive)
and times that one GPU. Before, one exclusive job per node timed the node's GPUs in turn.
docs/VALIDATION.md says both.

Ceilings: one run per GPU of the harness's full set, both runtimes, as the matrix runs it, two
passes, each run an exclusive job timing one GPU, at development 8b15f6574b. Each ceiling is the
worse of the two passes' ratios, rounded up to three places. The latest matrix run, 100b92d608,
predates the barrier commits 7edbf84c8f and 8d160c12ac, which moved rows a long way (the 2080's
dispatch_chain from 1.816 to 0.34, the 3090's frame from 1.156 to 0.38), and its 2080 leg ended
with the GPU gone. The Iris Xe has no run (its node is down), so its rows over 1.03 fail its first
matrix run and are listed from it.

The seed runs, by leg (job): RX 550 1002:699f (42513), RX 7900 XTX 1002:744c (42512), RTX 2080
10de:1e87 (42523), RTX 3090 10de:2204 (42518), UHD 630 8086:3e9b (42642, the harness cross-built
on the Linux builder for x86_64-pc-windows-gnullvm and run there), the 780M 1002:15bf (42515) and
the 780M 1002:1900 (42517), whose rows are all within 1.03. On the UHD 630 the old runtime's
burst_2000x5 ended in the second pass with GpuRecoveryVictim, so that row's ceiling is the first
pass's.

Verified: the rule tests, 22 of them, pass (python3 -m unittest discover -s scripts/matrix).
Replaying harness_budget over each seed run's two passes gives no problem on any GPU. The same
ceilings over the runs one commit earlier (08ff6ed59c, before the SIMD-group commits) put five
rows 0.1 to 3% past their ceilings: run-to-run spread that a ceiling at the current ratio does not
absorb.
2026-11-17 14:55:21 -08:00
Anees Iqbal 66a5a2c9ab translator: on from_queries' profile a kernel reads its region's base on every dispatch and its size by MultiRegion
Under the identity domains a kernel that reads a grid builtin decoded its
dispatch region on every dispatch: the base and Metal's threadgroup size
were selected by a test of the region's grid (region[1].xyz != 0), and the
size was unpacked from region[0].w. On the RX 550 that decode is 19 scalar
instructions per wave on k130 against the old runtime's 1, and making the
region constants saved 5.65 ms of k130's 2.57.

A new profile fact, IdentityRegion, gives the form. Device::new keeps
Grid, today's form, so its modules are byte-equal. Device::from_queries
takes Sized:
- the base is region[0].xyz on every dispatch: 0 where the dispatch is not
  split, and for an indirect one, which pushes a zero region;
- the kernel declares MultiRegion (default 0): at 0, L is the pipeline's
  WorkgroupSize, a constant the driver folds; at 1, L is the region's
  packed nominal size. This is the form for a region whose workgroup size
  is not Metal's, as the binder's edge regions are;
- the grid builtins' single-region form for an indirect dispatch is still
  chosen by the region's grid.

The binder is public and runs on any device's plan, a from_queries one
included, and it sets MultiRegion 1 on every region whose workgroup size
or base is not the dispatch's. So the constant stays rather than the
decoded path being dropped.

The new runtime pushes the pipeline's own size on every launch, so it
leaves MultiRegion at its default: its constant mapping skips the key.

SEMANTICS_VERSION 2163.

Docs: API.md (the identity domains' region) and the runtime README.

Test: engine_identity's
from_queries_reads_every_regions_base_and_its_size_by_multi_region. On
from_queries' profile the grid kernel declares MultiRegion with default
0. On the CPU interpreter, the whole, split (base [0,1,0]) and indirect
dispatches at 0 store Metal's answers, and so does a ragged 7x6 grid
split as the binder splits it: a region of 4x2 at 0, and an edge of 3x2
at base [1,0,0] at 1.
2026-11-17 14:35:03 -08:00
Anees Iqbal 4f8a7db4c8 rt sampler states: device samplers shared by create info at the consumer's index
Device::new_sampler_state is newSamplerStateWithDescriptor: at an index of a live Sampler grant.
Each state takes the device sampler of each use it can be used in, from the translator's
metal::sampler::vk_sampler with its create info chained by ash_interop::sampler_create_info:
the plain one always, the comparison one where its compare function is not Never, and the
integer-texture one (nearest, the integer border colour). It writes them into set 1's three
sampler arrays at its index before the call returns; the comparison array keeps its default
where the state has no compare function.

Device samplers are shared by create info across uses and states (SamplerTable), and a border
colour no address mode reads is no part of a create info (canonical), so a state whose
integer-texture use reads as a plain sampler shares it: a nearest state takes one sampler, and a
linear compare state two more beside it. The table holds at most maxSamplerAllocationCount
minus the arrays' two defaults; past it a state is Limit::DeviceSamplers. Gauges::samplers and
Gauges::device_samplers count them. When the last handle goes, the state's elements read the
defaults again, its index is free, and each device sampler no other state holds goes to the
reaper (Free::Sampler).

A cubic filter is Gap::CubicSampler. samplerAnisotropy joins the floor's features (every lab
device and capture has it). SamplerState::gpu_resource_id is the index and the translator's
SamplerWord. IndexInUse and IndicesInUse now name sampler states too.

README: a "Sampler states" section and the floor's feature row. REFUSALS.md regenerated;
api_signatures blessed.

Verified:
- m3-max-42632 (msi), this tree: clippy of metal2vulkan-rt plain, --cfg m2v_gpu and --cfg
  m2v_cpu_icd green; rustdoc -D warnings green; nextest 37 of 37; the device tests on lavapipe
  under the validation layer 78 of 78, 0 validation errors.
- m3-max-42611 (780M, radv) and m3-max-42612 (3090), the same sampler change on the textures tip
  before the rebase onto development, its archive under the validation layer: 75 of 75 each, 0
  validation errors; every gauge zero at drop.
- `python3 scripts/api-signatures/signatures.py --check` and
  `python3 scripts/refusal-surface/refusal_surface.py --check` clean.
2026-11-17 14:33:40 -08:00
Anees Iqbal 21a01acb33 rt textures: device images at the consumer's index, their bytes in and out
Device::new_texture is newTextureWithDescriptor: at an index of a live grant: an optimal image
in device-local memory of its own (the first memoryTypeBits type that is DEVICE_LOCAL), usage
the descriptor's plus transfer source and destination, so any texture can be replaced, read
back or blitted as in Metal. Its home layout is GENERAL where it has a storage element,
SHADER_READ_ONLY_OPTIMAL for shader read alone, the attachment layout for render target alone,
GENERAL otherwise; the first move from UNDEFINED goes through core's Work::upload, ahead of
every command buffer committed after the call. The sampled view's components are Metal's
swizzle composed over the format mapping; a depth or stencil format's view takes depth, else
stencil. The storage element exists where the format's emulation is Direct and the device
stores it through a storage image without a format. Size, layer and sample limits come from
vkGetPhysicalDeviceImageFormatProperties2. Admitted emulations: Direct, SwizzledView,
AlphaInRed, RotatedView, XChannel, DepthInCombined, StencilInCombined; any other format is
Gap::TextureFormat.

Texture::gpu_resource_id is the index and the translator's TextureWord, so the guest computes
it. replace_region and get_bytes copy through a staging buffer per call (Shared memory type,
counted in Metrics::bytes_copied); get_bytes submits at once (Work::flush, carried in the
commit before this one and landing with it) and waits (Done::wait). get_bytes's read of the
staging buffer is in readback.rs with its bound, under the readback rule test.

An upload into a 32-bit float depth is Gap::FloatDepthUpload (the planner's ruling): Metal keeps
any float there, Vulkan copies no depth outside [0, 1] without VK_EXT_depth_range_unrestricted,
which the Intel captures lack so the floor cannot take it, and no recorded stream uploads one.
get_bytes still reads such a texture.

The index frees at the last Texture handle's drop (its elements written null, the index
vacated), and grants now track occupancy: Refusal::IndexInUse and Refusal::IndicesInUse. The
Vulkan objects are an Image the uploads hold, freed by the reaper (Free::Texture) once the last
upload that moves or copies it retires. Gauges::textures and Gauges::descriptor_slots count
them, back to zero at drop.

Refusals carry Basis lines; docs/REFUSALS.md regenerated; api_signatures blessed. The README's
"Textures" section and its known gaps say the contract.

Verified:
- m3-max-42550 (msi), this tree: clippy of metal2vulkan-rt plain, --cfg m2v_gpu and --cfg
  m2v_cpu_icd green; rustdoc -D warnings green; nextest 36 of 36; the device tests on lavapipe
  under the validation layer 76 of 76, 0 validation errors.
- m3-max-42601 (780M, radv) and m3-max-42602 (3090), this tree's archive under the validation
  layer: 73 of 73 each (the three source-reading tests skipped off the building machine), 0
  validation errors; every gauge zero at drop.
- Not yet run on Intel: the UHD 630 (Windows) build, m3-max-42551, is running without the GPU
  lease; its run follows.
- `python3 scripts/api-signatures/signatures.py --check` and
  `python3 scripts/refusal-surface/refusal_surface.py --check` clean.
2026-11-17 14:22:16 -08:00
Anees Iqbal b78f8163f9 translator: a half fma is the device's 16-bit Fma on from_queries' profile under the 16-bit float controls
On every device the new runtime makes, Metal's fma on half was the device's float Fma on the
operands held in float, rounded to half by the controlled conversion pair (two OpFConvert
decorated NoContraction). On a chain of 1,024 dependent half4 fmas over 2^19 threads, the
device's 16-bit Fma took 437.5 against 1,818-1,832 us on an RTX 3090, 284 against 377-389 us on an
RX 7900 XTX, and 22.0 against 114.2 ms on a UHD 630 (probe jobs 42069, 42068, 42070).

The translator: a new profile fact, HalfFma. Device::new keeps Measured, the routes it took (the
measured 16-bit Fma on MoltenVK, OpFmaKHR on 16 bits under the controls where shaderFmaFloat16 is
enabled, else the float Fma rounded), which ROWS renders as nothing, so every Device::new
fingerprint and module is unchanged. Device::from_queries takes Native: a half fma is
fma::Route::F16Native, the device's GLSL.std.450 Fma on 16-bit floats, wherever the profile
computes half under the 16-bit float controls (shaderFloat16, with 16-bit RoundingModeRTE,
DenormPreserve and SignedZeroInfNanPreserve); spirv::half_hold then removes its exact conversions,
so the kernel carries no NoContraction pair for it. Elsewhere today's float Fma rounded to half
stays: on the RX 550, without shaderFloat16, and on lavapipe, which does not preserve 16-bit
denormals. OpFmaKHR is not taken on that profile: shaderFmaFloat16 is not one of the queries that
may choose a second form, and the new runtime does not enable VK_KHR_shader_fma.

The note is PrecisionNote::NativeFma, the float fma's. It is per operation, not per width: it
already covers both formats with a bound for each, and Vulkan gives the 16-bit Fma the precision
of the 32-bit one (a multiply and an add, each rounded), so its float bound holds in half. A half
twin would add a Degradation kind to the frozen old runtime and a row to the conformance suite's
native notes for the same statement. Every half fma on from_queries' profile records it, on
either route, and none requires VkProperty::MetalHalfFma.

RADV (Mesa 26.2.6, RX 7900 XTX) does not round the 16-bit Fma once: 1,622,016 lanes of that
chain ended up to 9 half ulp from Metal's (42068). NVIDIA's driver on an RTX 3090 and Intel's
Windows driver on a UHD 630 matched Metal in every lane (42069, 42070). The new runtime's README
lists it among the known gaps of pipeline states.

Tests: engine_arith's a_half_fused_multiply_add_is_the_devices_16_bit_fma_on_from_queries
compiles a half fma through Device::from_queries on five captures: on RADV's, ANV's and NVIDIA's
it is one 16-bit Fma with no NoContraction decoration, no MetalHalfFma requirement and NativeFma
recorded, rounding once on the interpreter; on lavapipe's and vk12-floor's it is the float Fma
rounded, NativeFma recorded, rounding twice. The profile facts test covers HalfFma and its
fingerprint; the fused emit test takes the new route. docs/API.md's native-fma entry and
PrecisionNote::NativeFma's doc state the 16-bit form and its bound.
2026-11-17 13:27:41 -08:00
Anees Iqbal 1b97a620c8 rt: set 1 and index grants
Every pipeline of the new runtime takes set 1, one descriptor set the device makes at creation:
65,536 sampled textures (binding 0), 4,096 storage-capable textures (binding 1) and 4,000
samplers of each use, plain, depth comparison and integer texture (bindings 2, 3 and 4), each
partially bound, updated after bind and while unused elements are pending, seen by every stage.
Set 0 is empty. The pipeline layout is made once from it, in Device::new, and every pipeline and
dispatch uses that layout.

Every element no object owns is defined: a texture element is a null descriptor
(VK_EXT_robustness2 nullDescriptor, which joins the floor; the robust buffer and image access
beside it stay off), and a sampler element is its array's default sampler, nearest and clamped to
the edge, the comparison array's comparing with NEVER. The device writes every element at
creation and holds the two default VkSamplers (Gauges::device_samplers). The translator is told
of VK_EXT_robustness2, so its profile has nullDescriptor.

Device::grant_indices(class, first, count) grants the consumer the range it names, so the IDs it
picks reproduce in replay: storage-capable textures 1 to 4,095, other textures 4,096 to 65,535,
samplers 1 to 3,999, 0 nil and never granted (IndexClass, IndexGrant). Limit::IndexRange,
Refusal::IndicesGranted and Refusal::IndicesNotGranted, with Basis lines; docs/REFUSALS.md
regenerated. The floor's sampler limits are now three arrays' (12,000 samplers per stage and set,
81,632 update-after-bind descriptors in all pools). README: "Set 1 and index grants", and the
floor's extension, feature and limit rows.

Device::new output is unchanged: no translator source changes.

Verified:
- m3-max-42273 (msi): clippy -p metal2vulkan-rt --all-targets --all-features, plain, --cfg
  m2v_gpu and --cfg m2v_cpu_icd, green; rustdoc -D warnings green; rt tests 33/33; every device
  test on lavapipe with the Khronos validation layer, 0 validation errors; making a second set 1
  takes 106 ms there. refusal_surface.py --check clean.
- m3-max-42305 (Radeon 780M, RADV, gem10) and m3-max-42306 (RTX 3090, um870), validation layer
  on: every device test passes with 0 validation errors, gauges zero at drop; a second set 1
  takes 15.1 ms on the 780M and 4.6 ms on the 3090. The three tests that read the source tree
  fail on those nodes only because the carried archive names msi's paths; they pass on msi.
2026-11-17 13:23:55 -08:00
Anees Iqbal 100b92d608 identity: constexpr samplers by a pushed index into set 1's sampler arrays
Under the identity domains a texture slot sampled through a constexpr sampler takes the sampler
from the set-1 sampler array of its use (binding 2 plain, 3 compare, 4 integer texture) at an
index the consumer pushes: PushField::ConstexprSampler(CombinedSampler), one u32. The consumer
makes the device sampler that the new public CombinedSampler::constexpr_sampler(profile)
describes, places it at an index of that array, and pushes the index. The index is a push word,
not a specialization constant: an index allocated at run time would key the driver's and the
pipeline cache's entries. Link's immutable sampler for the default domains now goes through the
same method, with the same result.

Under the identity domains every device sampler is normalized: a constexpr pixel sampler's
coordinate is scaled in the shader, as a runtime sampler's is, never handed to the device's
unnormalized sampler. A linear sample or gather through it records
PrecisionNote::PixelSamplerScaling, which is static. No address-mode-map variant applies there
(no binder picks a variant), so the sampler keeps its own modes and the slot records no
ConstexprSampled fact.

Still refused as Unsupported{IdentityDomains}: an argument buffer's sampler, arrays of samplers,
bicubic and anisotropy emulation. The refusal test now uses engine/a2_bicubic_weights.

Translation output changes only under the identity domains (Device::from_queries). Device::new
output is unchanged: golden_hashes_match_the_table passes at this tip (job m3-max-42192), with no
"changed under an unchanged key" and no "profile changed:" line.

Public surface: PushField::ConstexprSampler and CombinedSampler::constexpr_sampler are added
(api_signatures blessed); nothing is removed or changed.

SEMANTICS_VERSION 2162: identity-domain modules of constexpr-sampling kernels change.
ARTIFACT_FORMAT_VERSION 531: PushField gains a variant.

Verified:
- m3-max-42097 (msi), this change on cd5a76a757: clippy -p metal2vulkan --all-targets
  --all-features and rustdoc -D warnings green; nextest all() of metal2vulkan, 3,689 of 3,693
  passed. The four failures were development's own (the new pad_simd_shape and
  vector_word_phases fixtures had no table rows), re-blessed at 74669c0552.
- m3-max-42098 (msi): clippy --cfg m2v_gpu and --cfg m2v_cpu_icd green.
- m3-max-42192 (msi), this tip on the samplers landing on 58891b9ce5: golden_hashes_match_the_table,
  public_fixtures_engine inventory and llvm_as part 8, and air_input's engine golden printouts
  pass.
- engine_identity a_constexpr_sampler_is_the_set_1_element_its_pushed_index_names: sample_up and
  the same kernel through a linear pixel sampler link and pass L3 on every profile and on
  moltenvk-m3 without robustImageAccess2. Their push fields are the two texture IDs and
  ConstexprSampler(c) of the normalized use, with no spec constant but LocalSize, no immutable
  sampler and no ConstexprSampled fact; set 1 bindings 0, 1 and 2 are used; constexpr_sampler
  gives a normalized device sampler. PixelSamplerScaling is recorded for the pixel kernel under
  identity, and under the default domains, which hand that kernel the unnormalized sampler, it is
  not.
2026-11-17 12:46:53 -08:00
Anees Iqbal 445b720f78 identity: texture slots sampled through runtime sampler slots from set 1's sampler arrays
Under the identity domains a kernel samples a texture slot through a runtime sampler slot. The
texture is its class's set-1 element at the index of its pushed gpuResourceID, as a read's is.
The sampler is the element of a set-1 sampler array at the index of the sampler slot's pushed
gpuResourceID (SlotGuestBase of the sampler slot), joined to the texture by OpSampledImage. The
array is picked by the use: binding 2 for a plain sample, 3 for a depth comparison, 4 for a
texture of an integer format; 4,000 SAMPLER descriptors each, PARTIALLY_BOUND |
UPDATE_AFTER_BIND | UPDATE_UNUSED_WHILE_PENDING, every stage, the same set 1 for every pipeline.
The sampler's word (pixel coordinates, a nearest pixel sampler) is read from the ID's high word,
so no specialization constant and no SamplerReduction, SamplerCoordinates, CubicSampler or
ConstantLanes fact remains; every precision note is static. An integer write to a storage slot
without a format saturates to the channel widths the consumer pushes
(PushField::TextureIntegerChannels, a u32), with no fact.

Still refused as Unsupported{IdentityDomains}: constexpr samplers (next change: a pushed index),
an argument buffer's sampler, arrays of samplers, bicubic and anisotropy emulation, a slot's
minimum level.

Translation output changes only under the identity domains (Device::from_queries). Device::new
output is unchanged: golden_hashes_match_the_table passes at this tip (job m3-max-42189), with no
"changed under an unchanged key" and no "profile changed:" line.

For the runtime's side (the planner's three facts):
a. The runtime must dedupe device samplers by create info across the three arrays' uses.
   Exhausting maxSamplerAllocationCount (4,000 on the 2080, 3090 and UHD 630; 32,768 on
   lavapipe; 65,536 on the others) must be a typed refusal, with a fill-past-capacity test.
b. The update-after-bind limits for 65,536 sampled images, 4,096 storage images and 12,000
   samplers hold on all nine profiles (the smallest is lavapipe's 1,015,808); the floor must
   check them by query.
c. The count of cubic sampler descriptors is asked of the replay lane; if any exist it goes back
   to the planner before step 5 closes.

SEMANTICS_VERSION 2161: identity-domain modules of sampling kernels and integer writes change.

Verified:
- m3-max-42094 (msi), this change on cd5a76a757: clippy -p metal2vulkan --all-targets
  --all-features and rustdoc -D warnings green; nextest all() of metal2vulkan and metal2vulkan-rt,
  3,719 of 3,723 passed. The four failures were development's own (the new pad_simd_shape and
  vector_word_phases fixtures had no table rows), re-blessed at 74669c0552.
- m3-max-42096 (msi): clippy --cfg m2v_gpu and --cfg m2v_cpu_icd green.
- m3-max-42189 (msi), this tip on 58891b9ce5: golden_hashes_match_the_table,
  public_fixtures_engine inventory and llvm_as part 8, and air_input's engine golden printouts
  pass.
- engine_identity: sample_down links and passes L3 on every profile and on moltenvk-m3 without
  robustImageAccess2, with set 1 bindings 0, 1 and 2 used, no spec constant but LocalSize, and no
  sampler fact; an integer write of (300, 70000, 5, 2^31) stores (255, 255, 5, 255) under the
  RGBA8Uint word and the raw lanes under word 0, on the CPU interpreter.
2026-11-17 12:46:10 -08:00
Anees Iqbal cd5a76a757 docs: conformance coverage with the vector word-phase cases 2026-11-17 12:15:37 -08:00
Anees Iqbal da5fd7da0b push window: 256 bytes on from_queries' profile, the new runtime's floor
A kernel's push window held 128 bytes, what Vulkan guarantees: a dispatch region and 12 buffer
addresses. A kernel of more buffers put the rest in a parameter block that the new runtime writes
into its ring on every dispatch, and whose address the window holds.

The translator: a new profile fact, PushWindow. Device::new keeps Guaranteed (a 128-byte kernel
window, the value ROWS renders as nothing, so every Device::new fingerprint and module is
unchanged); Device::from_queries takes Floor, a 256-byte kernel window: a dispatch region and 28
buffer addresses. lower::push::{window, place, spills} take it; the render windows are the same on
both. The push range is still the function's own need, and a module whose block passes 128 bytes
requires maxPushConstantsSize to cover it, as before.

The new runtime: the floor requires maxPushConstantsSize >= 256 (every captured device reports
256), a typed refusal below it; its pipeline layout declares 256 bytes, and a dispatch pushes the
kernel's own bytes. A new metric, Metrics::ring_writes, counts each parameter block and each
set_bytes copy written into the ring. README: the floor's limit row and the parameters paragraph.

The harness gains wide_bindings: 256 small dispatches of a kernel that binds 24 buffers.

Tests: push.rs places a region and 28 addresses in the floor window and spills a 29th, with the
first 12 placed as the guaranteed window places them; engine_identity's many-buffer kernel on
from_queries pushes all 21 addresses with no block, and one of 33 slots spills 2, both answering
on the interpreter; the floor tests move to 256; the profile facts test covers the new fact; an rt
device test dispatches a 24-buffer kernel with no ring write and a 30-buffer one with one a
dispatch. The signatures table gains Metrics::ring_writes.
2026-11-17 12:09:37 -08:00
Anees Iqbal fdc3fd3907 rt: threadgroups of partial SIMD groups run the kernel's emulated module, lowered on the reaper
A kernel whose tier runs each SIMD group as one subgroup (a pinned subgroup of 32, the device's
own 32, or half of a 64-lane subgroup) runs only threadgroups of whole groups of that width. Such
a state now has its emulated-SIMD-group variant (LoweringInputs::emulated_simdgroups), which the
reaper lowers once new_compute_pipeline_state has returned, through the cache directory like
every lowering (a refusal is kept too). A dispatch whose threadgroup is not whole groups runs that
module at its own size; one that comes before the reaper is done waits for the lowering, which the
reaper takes next (Reaper::hurry), counted as a first-use wait. Nothing translates on an encoding
thread. A state made after quiesce, or whose lowering the reaper's end leaves, is marked not
lowered (Error::Quiesced at such a dispatch).

The emulated module's threadgroup memory is its arena (metal2vulkan::pipeline::arena_bytes, now
public) holding the lengths set, the scratch of each SIMD group, and a vote word: the dispatch's
total is checked against maxComputeSharedMemorySize (Limit::ThreadgroupMemory).
ComputePipelineState::precision_notes returns the emulated module's notes too once it is lowered.

Gap::PartialSimdgroups stays for a state with no emulated module: a kernel the consumer compiled,
or one whose emulated variant the translator refuses. A ragged dispatchThreads grid at such a size
is Gap::PartialThreadgroups: the partial-threadgroups variant does not take the emulated tier.
2026-11-17 11:48:14 -08:00
Anees Iqbal c1b123813f docs: under the identity domains unwritten and constant arguments are read-only memory 2026-11-17 11:31:25 -08:00
Anees Iqbal 8ec8cbbc20 old-runtime regression fix: a half color output is 16-bit again under Device::new
6f5bd20321 removed the 16-bit `half` color output form on every device. That moved Device::new's
output, which the old runtime builds on: 111 golden cells on each RADV, ANV and MoltenVK profile
(5c47b9c867 -> bfe63b5097). The form comes back for Device::new alone, as a profile fact:
ProfileFacts::half_outputs is HalfOutputs::Sixteen in Device::new's facts (ROWS) and
HalfOutputs::Widened in Device::from_queries' (EVERY). Under Sixteen a `half` color output is
declared with 16-bit `float` lanes where the profile enables storageInputOutput16 and
shaderFloat16, as before 6f5bd20321. storageInputOutput16 is not one of the queries rule 2 lets
choose a second form, so the new runtime keeps one 32-bit form for every stage output. The fact
renders into no ROWS fingerprint, so Device::new's profile keys do not move.

- lower::stage_io: plan::half_variable (now reading the fact and the enabled feature),
  IoObject::User::half, the 16-bit store and io_elem's width are back. StageIo::half_outputs and
  the link contract's 16-bit lanes are back.
- The HalfOutputPrecision and HalfOutputFastMathBlend note texts, docs/API.md's degrade
  catalogue, docs/FAST-PATHS.md and the half-output-blends case say what they said for the old
  path, each scoped to Device::new, with Device::from_queries handing every device the `float`.
- known-gaps.tsv: the 52 MoltenVK rows for the M3 Max's half-output-blends-r16f, -rg16f and
  -rgba16f go, as before 6f5bd20321: with the 16-bit output MoltenVK stored Metal's codes there.
  docs/CONFORMANCE-COVERAGE.md is regenerated (3,783 -> 3,731 ledger rows).
- The Iris Xe's 62 half-output rows (6769c2eaaf) were measured with the 32-bit form on ANV, which
  gets the 16-bit form again under Device:🆕 they are owed a re-run with it.
- SEMANTICS_VERSION 2157 (the 111 cells per profile change under unchanged keys) and
  ARTIFACT_FORMAT_VERSION 530 (the artifact codec has StageIo::half_outputs again).
- The engine_stage_io test is back. It also checks that the profile from Device::from_queries is
  HalfOutputs::Widened and keeps the output 32-bit on MoltenVK, RADV and lavapipe, with no
  StorageInputOutput16.

Verified at 8e0e199a12 on 00ca405504, whose tree is this commit's but for SEMANTICS_VERSION (2156
there; development took it meanwhile) and development's later commits (03a3741772 and the
harness's), which touch none of this commit's files:
- msi 41897: golden_hashes_match_the_table with every difference listed, compared with the
  tables at 5c47b9c867 and bfe63b5097. All 504 stage-io cells on the .ll rows that Linux compares
  (56 on each of the 4 RADV, 4 ANV and MoltenVK profiles) are back at their 5c47b9c867 values,
  none elsewhere. On ANV and MoltenVK those are the only cells that moved (280, under unchanged
  keys). The RADV and NVIDIA columns are stale under profile fingerprints that development's
  e0f567a8bc moved back before this commit (12,705 cells, the table not yet blessed for it); in
  them only the stage-io cells above and 185 cells on each of nvidia-rtx50-linux and
  nvidia-rtx5080-laptop (e0f567a8bc's NVIDIA restore) moved. No ROWS fingerprint moved with
  this commit. The 55 stage-io cells per profile on .air.ll rows need metal-as and wait for the
  M3 bless.
- msi 41813: clippy -p metal2vulkan --all-targets --all-features -D warnings, rustdoc
  -D warnings, nextest -p metal2vulkan -p metal2vulkan-conformance in full: 4,719 of 4,722 pass.
  The failures: golden_hashes_match_the_table, for the bless above;
  the_public_signatures_are_the_committed_table, development's degradations! row, fixed since by
  489bc24c4e; the_authored_4096_step_kernel_compiles_inside_the_budget, which passed alone on
  the same build (41862) and is not in this commit's scope.
- msi 41814: clippy under --cfg m2v_gpu and --cfg m2v_cpu_icd.
2026-11-17 11:30:29 -08:00
Anees Iqbal b206c48b2a matrix: only a subject that opens with the phrase lets the old path move
a17eb26a6b's matrix run did not report OLD PATH MOVED although its golden test counted 7260
cells under a changed profile fingerprint (the stage-bound change): the check commit's own
message quotes "old-runtime regression fix", and the rule looked for the phrase anywhere in a
message since the last bless. It now takes only a subject that starts with it, as each fix's
does.

Tests: scripts/matrix/test_results.py, 17 pass; the old-path test now also feeds a message that
quotes the phrase in its body and expects the problem to stand.
2026-11-17 11:24:09 -08:00
Anees Iqbal aa8d6ac6f5 old-runtime regression fix: a stage's reconvergence note only on from_queries' profile; the old runtime's extra kind goes
6e08f5aaef made every stage of implementation-defined reconvergence
record PrecisionNote::DeviceReconvergence on the shared translator
path. The old runtime (Device::new) then announced a second kind,
Degradation::DeviceReconvergence ("device-reconvergence"), for a
tangled stage on a device without maximal reconvergence. Before that
commit it announced ImplementationDefinedReconvergence alone, from the
stage's reconvergence field.

Route (a) of the planner's two: the note is a third profile fact.
- ProfileFacts gains reconvergence_note: ReconvergenceNote::Field for
  Device::new (ROWS), ReconvergenceNote::Noted for
  Device::from_queries (EVERY).
- pipeline::compile records the note only where the profile notes it.
- A Device::new stage again carries the field alone, its notes as
  before 6e08f5aaef.
- The fingerprint renders the facts only off ROWS, so no Device::new
  fingerprint moves.

The old runtime's Degradation::DeviceReconvergence kind is deleted: no
Device::new stage records the note. Its catalogue entry in API.md and
its API-table row go with it. from_precision_note maps the note, which
none of its stages hold, onto ImplementationDefinedReconvergence, as the
closed match requires. The note stays in the translator's vocabulary,
codec and validation allowance for metal2vulkan-rt, which forwards it
through ComputePipelineState::precision_notes.

Tests:
- engine_simd's reconvergence_follows_the_profile and
  uniform_control_flow_mode_without_maximal_reconvergence assert the
  field alone through Device::new and the note through
  Device::from_queries; the guaranteed stage records none.
- the_profiles_facts_follow_its_constructor covers the third fact.

SEMANTICS_VERSION 2155.
2026-11-17 10:57:34 -08:00
Anees Iqbal e0f567a8bc old-runtime regression fix: the two half rows return to Device::new; from_queries' profile notes every controlled pair
07e62aa306 deleted DriverWorkaround::HalfConversionPairFolded (NVIDIA)
and HalfConversionFusedWithArithmetic (RADV) on the shared translator
path. That changed the old runtime's modules:
- NVIDIA's moved from the Converted form to the Controlled one: 333
  golden cells each on nvidia-rtx50-linux and nvidia-rtx5080-laptop,
  bless 7fa6662170.
- The NVIDIA and RADV fingerprints moved (six profiles).
- Every controlled module gained NativeHalfConversion.

Restored for Device::new, as before 07e62aa306: both identity rows,
narrow::quantize_form's fold check (NVIDIA takes Converted),
narrow::rounds_arithmetic, and the note on a controlled pair only where
RADV's row fuses f32 arithmetic into the narrowing. The validation lanes
(half_conversions, native_maths) and the translator's tests go back to
their text before 07e62aa306.

rt keeps what landed, carried with no switch. The note's form is a
second profile fact beside the stage bound:
- device::profile::ProfileFacts holds { stage_bound, half_pair_note }.
- Device::new builds ProfileFacts::ROWS (Defects, Fused).
- Device::from_queries builds ProfileFacts::EVERY (Every, Every).
- pipeline::compile reads half_pair_note: Every records the note on
  every module that keeps a controlled pair. Fused is the old rule.
- from_queries profiles name neither row, so quantize_form gives them
  Controlled on every device with the controls, NVIDIA's included.
- The fingerprint renders the facts only when they differ from ROWS, so
  Device::new's NVIDIA and RADV fingerprints return to their values
  before 07e62aa306.

Tests:
- The identity tests are back.
- New from_queries_half_rounding_follows_the_queries_alone and
  from_queries_notes_every_controlled_pair.
- The facts test covers both facts.

Docs: PrecisionNote::NativeHalfConversion, API.md's degrade catalogue
and HOWTO.md name both paths; the API table regains the two variants.

SEMANTICS_VERSION 2154.
2026-11-17 10:57:34 -08:00
Anees Iqbal d5a475f1a0 old-runtime regression fix: the stage bounds return to Device::new's ANV rows; the bound on every device is a fact of from_queries' profile
576a7348bc put one stage bound on every device on the shared translator
path, so the old runtime (Device::new) newly refused what it compiled
before: on the UHD 630 and on every committed profile without maximal
reconvergence, 6 corpus modules (12 rows) went from compiled (emulated
simdgroups, entry weights 104,424 to 188,554) to Needs::StageBound.
Measured on gem10 through Device::new at 9cb90de8cc (job m3-max-41747).

Restored for Device::new, as before 576a7348bc:
DriverWorkaround::SerializedStageWrapsLargeModules and
CompilerMemoryGrowsWithStageSize on ANV's identity row, their bounds
(786,432 and 99,109), the re-plan keeping the widest pin, and the
refusal as Needs::DriverDefect naming the defect; no bound elsewhere.
The old runtime's heap-trim test, warm-refusal kinds and their tests go
back to their text before 576a7348bc.

rt keeps what landed, carried with no switch. The bound is a fact of
the profile (device::profile::StageBound): Device::new builds
StageBound::Defects (the bounds of its rows), Device::from_queries
builds StageBound::Every (99,109 on every device, refused as
Needs::StageBound). stage_bound::emit reads that one field. The
fingerprint renders the fact only when it is Every, so every
Device::new fingerprint is byte-identical to before 576a7348bc. Every
from_queries fingerprint moves, so an rt profile is never one of the
old path's.

Tests:
- The pre-576a7348bc ANV tests are back (both defects' bounds, and the
  same profile without them emitting under every bound).
- New every_stage_from_queries_keeps_the_widest_pin_or_is_refused:
  re-planned, then StageBound; the serialized bound is none there; RADV
  through Device::new is unbounded.
- the_stage_bound_fixture_keeps_the_pin_or_is_refused covers both
  paths. Iris pinned through both. Without maximal reconvergence:
  StageBound through from_queries, DriverDefect on ANV through
  Device::new, and emitted emulated through Device::new under Intel's
  Windows driver (the UHD 630's case).
- New the_stage_bound_is_a_fact_of_the_profile checks every committed
  profile.

Docs:
- FAST-PATHS' known gap is ANV's again.
- The rt README's known gaps gain the every-device bound.
- API.md and the Needs::StageBound and Feature::StageSize docs name
  both paths.
- REFUSALS.md regenerated; the API table regains the two variants.

SEMANTICS_VERSION 2153.
2026-11-17 10:57:34 -08:00
Anees Iqbal 75b422338a identity: argument-buffer textures are the set-1 elements their resource IDs name
Under the identity domains an argument buffer's texture handle is the gpuResourceID its member
holds: the handle is the ID's index, the element of the class's set-1 array (0 is nil, the null
descriptor), with no handle table, no search and no descriptor. Where the shader checks a read
itself (no robustImageAccess2) the handle carries the word's missing-alpha bit (word bit 12) at
HANDLE_ALPHA_ONE, so the handle form is Lookup::Element or Lookup::Flagged{alpha} only.

The handle tables' variant forms are off under these domains (`texture::tabled`): reads of a
member of another numeric class, raw-texel decodes, storage conversions (red-blue, sRGB alias),
A8 alpha-in-red, unreadable-storage nulls, YCbCr write marks, and the HeapCrossClassNeutral,
HeapStorageReads and HeapResidency facts. A slot and a member of one class index one array, so
the class's volatility now merges the slots' uses with the groups'. The admission takes heap
groups whose declaration is their identity class with no plain, raw or cross classes; anything
else stays Unsupported{IdentityDomains}.

Translation output changes only under the identity domains: the default domains plan and emit
as before (no golden re-bless needed). SEMANTICS_VERSION 2153.

The test kernel `tex` gains an argument-buffer form (`texture_kernel(true)`), checked on
lavapipe, moltenvk-m3 and moltenvk-m3 without robustImageAccess2: same answers at the same
elements, set 0 empty, and the handle form Element or Flagged{alpha} as the profile checks reads.

Verified (this commit's tree, as 657e2245c2 on 2872c419e0):
- msi 41756: clippy -p metal2vulkan --all-targets --all-features -D warnings, rustdoc
  -D warnings, nextest -p metal2vulkan -p metal2vulkan-rt in full: 3,701 of 3,702 pass; the one
  failure is golden_hashes_match_the_table, stale under development's own profile change.
- msi 41800: that golden test with every difference listed: 7,260 cells under a changed profile
  fingerprint (development's at 2872c419e0; this commit changes no profile field), no cell whose
  value moved, no cell changed under an unchanged key. Fixtures that need metal-as (macOS) are
  not compared there.
- msi 41757: clippy under --cfg m2v_gpu and --cfg m2v_cpu_icd.
- msi 41712, 41713 and 41752: the same at 160a3c5bae on 9cb90de8cc (SEMANTICS 2152 there), the
  golden test matching 1,815 rows x 19 profiles.
2026-11-17 10:56:25 -08:00
Anees Iqbal 4ac52bf082 rt: a kernel's threadgroup memory arguments come from its length constants
The device legs of the tile (m3-max-41638/41639/41640) refused every
observing kernel with Gap::KernelInput: the runtime took a kernel's
[[threadgroup(n)]] arguments from PipelineInterface::threadgroup, which the
translator leaves empty, so a TgLength specialization found no argument. The
arguments are now the TgLength constants the module specializes on, by
their index.

With threadgroup memory reaching a pipeline, a dispatch checks it: the
kernel's static part (and a predicated walk's 4-byte vote word,
RuntimeFact::PredicationVote, now accepted) plus each length set rounded up
to 16 bytes must be within maxComputeSharedMemorySize, else the new
Limit::ThreadgroupMemory, Metal's maxThreadgroupMemoryLength counterpart.

The precise kernel's test found on the 780M and the XTX one word apart
between a tile and the app's shape: a NaN/NaN division (0xffb86e83 /
0x7f9fc206) answers the first operand's payload in one pipeline and the
second's in the other. The state carries NativeNanEncoding, so two NaNs are
alike there; every other word must be equal.

README: the threadgroup memory limit, and NVIDIA 615.71.09's sign-extended
narrow clamped sum on GA10x (the planner's wording). REFUSALS.md and the API
signatures regenerated.
2026-11-17 10:46:51 -08:00
Anees Iqbal 2930583b47 rt: the cache directory keeps lowered kernels and pipeline data
DeviceOptions::pipeline_cache_dir names a directory a device keeps two
things in, for compute pipeline states. translations/ holds each lowering,
named by its FunctionCompileKey (the kernel's AIR, entry, constants and linked
functions, its lowering inputs, the profile fingerprint and the translator's
semantics version), in the translator's self-checking encoding; a state reads
a lowering there in place of lowering (Metrics::translations_loaded beside
the new Metrics::translations), and a partial-threadgroups variant the
translator refused is kept as a marker so it is not tried again. The files
take at most 256 MiB, least recently used evicted first. pipelines-<uuid>
holds the VkPipelineCache data, framed with a length and a checksum since
the initial data must be exactly what vkGetPipelineCacheData returned; every
VkPipeline is made through the device's cache, the reaper writes the data 10
seconds after a VkPipeline was made at most once per 10 seconds, and the
device's end writes it a last time. Writes go through a temporary file
renamed over the name; a file that does not check is a miss and nothing the
cache does fails a call.

The tile commit's README, refusal table and API signatures follow here:
direct dispatches past maxComputeWorkGroupCount are split, and
Gap::PartialThreadgroups names the variant refusals by the deciding queries.

Tests: a store filled past its cap keeps the most recently used files within
it, stores on one directory share files, and pipeline data cut short or
flipped is a miss (host); a second device on the same directory lowers
nothing at creation, reading all three lowerings, and the pipeline data file
is there (device). Not yet compiled: the lint follows.
2026-11-17 10:46:51 -08:00
Anees Iqbal 37cc7ac829 matrix: harness counts compare under one harness; six old-runtime lavapipe flakes parked
The 7fa6662170 run failed every GPU leg on harness-old/authored/pipelines_created 8 -> 10. That
was the harness itself gaining two workloads (eddc9b80bf), not the runtime. The harness's counts
sum over its workloads, so like its times they now compare only with a base whose harness tree is
the same; the other records still compare.

Its lavapipe leg failed on one old-runtime test that passed in the runs around it, as a different
one did in most runs today (cfa389aa9b, c944d63548, bfe63b5097, 73e0af4b66), the old runtime's
code unchanged between them. The old runtime is frozen and its regressions parked, so the six met
so far join PARKED_TESTS with the run each failed at; they stay named on the leg's line.

Tests: scripts/matrix/test_results.py, 17 pass (the new one: a harness count compares under the
same harness and not under a changed one, while a runtime count compares in both).
2026-11-17 10:45:01 -08:00
Anees Iqbal a17eb26a6b matrix: the old path moving fails a leg unless its fix says so
The old runtime is frozen until the cutover: the translator's output through Device::new must not
move. Today it moved three times through the shared path (half outputs widened, the half pair
workarounds dropped, the stage-size rows dropped) and nothing caught it, because the golden table's
failure read as "needs a bless" whatever moved.

The golden table compiles through Device::new. Its test's stale message now counts each kind
(new, gone, under a changed fixture source, under a changed profile fingerprint), from one tested
function. The matrix reads the counts: a cell changed under an unchanged key, or one under a
changed profile fingerprint, fails the leg with OLD PATH MOVED, unless a commit since the table's
last bless says "old-runtime regression fix" (the fix of such a move, or a fix the old-runtime
lane lands). New, gone and re-keyed fixture rows still only need a bless.

Tests: scripts/matrix/test_results.py (16 pass; the new one feeds both panics as nextest prints
them, a new-rows-only failure and a passing run, with and without the phrase);
golden_hashes::only_a_cell_changed_under_its_key_needs_a_bump checks the counts' text.
2026-11-17 10:37:10 -08:00
Anees Iqbal 576a7348bc translator: one stage bound on every device; the two stage-size workarounds go
A module whose entry weighs more than COMPILED_STAGE_WEIGHT (99,109, the
heaviest stage measured to compile within host-sized memory, on ANV) is
now handed to no driver, whatever its identity. A kernel that emulated
its simdgroups only in place of the widest mode's pin (the subgroup size
range decides it) is planned again keeping the pin, as before; every
other module past the bound is refused with Feature::StageSize and a new
Needs::StageBound, its symbol naming the weight and the bound. The
refusal is permanent for the input on the device (its plan decides the
weight), so it is not NotImplemented; validation reads it as the
translator's own gap.

DriverWorkaround::SerializedStageWrapsLargeModules and
CompilerMemoryGrowsWithStageSize go, with ANV's identity entries for
them and the serialized bound (786,432), which the single bound sits
far below. Why: the workaround ladder takes one form for every device,
the slowest compiler's; a device whose compiler would take a heavier
stage is refused it, recorded in FAST-PATHS' known gaps.

Measured before this change, with a scratch build that applied the
bounds and the re-plan to every profile: the corpus on the Iris Xe's
description without its identity refused nothing (largest planned
module 91,399, job m3-max-41496), and RADV and NVIDIA nothing either;
without maximal reconvergence 12 rows were refused, 6 distinct
simdgroup-matrix modules of 198 to 285 products whose lockstep pairs
force emulated simdgroups (jobs m3-max-41474, m3-max-41523).

The owned fixture stage_bound/stage_bound_matrix (512 simdgroup matrix
products beside a lockstep pair in divergent flow, our own MSL) has
their structure: on the Iris Xe its emulated module weighs 123,307 and
its pinned one 37,646; without maximal reconvergence it is refused at
123,308 (scratch weighing, job m3-max-41602). The new test
the_stage_bound_fixture_keeps_the_pin_or_is_refused asserts both paths
and that the re-planned kernel is under the bound.

The old runtime's heap-trim test loses its long chain, now refused on
every device; it asks for a trim where the making left more than the
floor free (NVIDIA's compile never does under the bound, 189 MB at
most measured). SEMANTICS_VERSION 2150; REFUSALS.md regenerated; the
API table loses the two variants and gains Needs::StageBound.
2026-11-17 10:24:59 -08:00
Anees Iqbal 9cb90de8cc replay: a group that held a Private-range split reports its executed counts apart
Leaving out what the runtime counted while the player's own calls ran
did not keep the split out of the executed counts: the old runtime
records the barriers a split needs at the program's next command and at
the commit. Device legs at 0b882f337c (jobs m3-max-41605, m3-max-41608)
counted 8 barriers on the RX 7900 XTX, RX 550, 780M and lavapipe and 10
on the RTX 2080 for the test stream, against 5 for the same stream
without the records. A background pipeline that landed inside an
uncounted window also left pipelines_made out (RX 550, 780M,
lavapipe).

The runtime's work for a split cannot be told apart from the program's,
so a group whose command buffers held a split now reports no executed
counts. Those counts are added up apart, in Report::split_executed and
on the `split N executed COUNTS` line, and the total leaves them out
with the readbacks. The player's own calls around the dispatch are no
longer measured on their own.
2026-11-17 10:12:59 -08:00
Anees Iqbal 4862a521e0 replay: the player's encoder splits are in no count; the report counts them
The encoders, blits, buffer and fence the player adds around a dispatch
an m2v.privateBytes record names are its own work: what the runtime
counts while those calls run is left out of the group and total
executed counts, as its readbacks are, and the report counts the splits
(split N). The comparison takes its completed snapshots from a queue.
2026-11-17 09:58:05 -08:00
Anees Iqbal 68789f62a5 replay: the player puts a Private range's bytes in before its dispatch and compares them after
The host records m2v.privateBytes for each dispatch of a pipeline with
linked functions: each bound Private buffer range's bytes before and
after the dispatch, which no CPU can read and no other record holds.
The player played these records as nothing.

It now reads the stream ahead once (a second reader of the same
segments) and indexes the records by the dispatch each names, since
they come after it, at the command buffer's completion. At that
dispatch it puts each range's bytes before (relocated as a write's
are) in a Shared buffer of its own, ends the guest's compute encoder,
copies them into the ranges in a blit encoder, makes the compute
encoder again by the call that made it with every set.../use... call
the program made on it, dispatches, then ends it, copies the ranges
out in a second blit encoder and makes it again. A fence of the
player's own orders each piece after the one before, so untracked
resources are ordered too. Once the command buffer completed it reads
the bytes after back, counts the 4-byte words of each range that
differ from the recording's, and reports a `private ID DISPATCH
LOCATION+LENGTH match|differs N/WORDS` line; the play goes on.

The readback helper check() and the comparison share now shifts the
group baseline by the readback's own growth rather than setting it to
the counters after it, so work recorded since the last group stays in
the next group's executed counts.

REPLAY-STREAM.md sections 8 and 10 state the read-ahead, the split,
the report line and what the counts include.
2026-11-17 09:58:05 -08:00
Anees Iqbal 31c1161940 rt: SIMD groups at Metal's width, and robustImageAccess, at the floor
The floor requires Vulkan 1.3's subgroupSizeControl, computeFullSubgroups and
robustImageAccess, enabled on every device; the translator's profile takes
them through the enable set. Where a device lists compute in
requiredSubgroupSizeStages with 32 between its sizes, the translator pins a
kernel's SIMD groups to subgroups of 32 (the Direct tier); the compute
pipeline state now takes such a kernel: each VkPipeline chains
VkPipelineShaderStageRequiredSubgroupSizeCreateInfo where the tier pins a size
(the translator pins only a stage the device lists, VUID-...-pNext-02755) and
carries the stage's REQUIRE_FULL_SUBGROUPS. "A stage that pins a subgroup
size" leaves Gap::KernelInput. A flattened tier's LocalSizeConstraint is
supplied: a dispatch whose threadgroup is not whole SIMD groups is refused at
the dispatch as the new Gap::PartialSimdgroups, since the emulated-SIMD-group
variant is not built. With robustImageAccess on, the translator drops its
image write and atomic guards on every device; robustImageAccess2,
robustBufferAccess, robustBufferAccess2 and nullDescriptor stay off.

Tests: the floor names each new missing feature; the translator's enable set
holds robustImageAccess and none of a reported geometryShader,
samplerMirrorClampToEdge or VK_EXT_robustness2 (host); every device's
translator profile has robustImageAccess and none of robustImageAccess2,
robustBufferAccess, robustBufferAccess2, nullDescriptor (device); and
simd_float_products runs Direct, pinned at 32, wherever compute can pin 32,
refusing a 16-thread threadgroup and answering Metal's products (device).

REFUSALS.md and the API signatures regenerated. Verified: cargo fmt; the lint
and the device legs follow.
2026-11-17 09:55:14 -08:00