Commit Graph
6613 Commits
Author SHA1 Message Date
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 0bd101945f rt: Work::flush submits the upload at once, and Done::wait waits for its batch
For a call that reads back what the upload copied (get_bytes): Work::flush has the pending
upload submitted at once, alone where no segment is ready, and returns the progress value of the
batch that takes it (or of the last batch, where no upload is pending). Done::wait waits on the
progress semaphore for that value, and fails with VK_ERROR_DEVICE_LOST where the device is lost
first (it checks for a loss every 100 ms of waiting, since a lost device's pending batches never
signal). The upload's own barrier now reaches the host, so what it copied is visible to the host
once its batch completes.

Lands with its first caller (get_bytes); alone, both are unused.
2026-11-17 14:22:15 -08:00
Anees Iqbal 6a96ce1f76 rt: tests read the crate's sources from the test process's crate directory
product_sources (one_path, readback) and the floor README test read files under
env!("CARGO_MANIFEST_DIR"), the build host's path, so an archive run on another node (the GPU legs
of jobs m3-max-42474 and 42477) found no sources and failed three tests. They now read under
tests::crate_dir: the test process's CARGO_MANIFEST_DIR where it holds the crate's sources (cargo
and nextest set it, and nextest's --workspace-remap points it at the workspace the archive runs
in), else the build's directory.
2026-11-17 14:07:01 -08:00
Anees Iqbal 9c61460b3d Guard fixes: a private rustdoc link, the vector-word-phases cases' timing, unique gauge labels
The guard commits left three failures on every leg of the matrix at 100b92d608:

- rustdoc (exit 101): the vector_word_phases case's module doc linked `tests`, a private
  cfg(test) module rustdoc cannot see. It now says this module's tests in plain words.
- lavapipe, times::every_case_is_timed::every_case_carries_its_timing: the four
  vector-word-phases cases carried no timing. `conformance times --runs 8 --write` over the four
  on the M3 (job m3-max-42508, "4 case(s) carry their timing") adds each recording's times and
  changes nothing else in them.
- every device leg, "record gauge compute_translated/...@drop: recorded twice": the vector
  placement test reused the label compute_translated, which is the gauge record key; it is
  compute_vector_words now. push_window's test called each_device("push_window", ...) once per
  buffer count, repeating the key on lavapipe and the UHD 630; each count is
  push_window_{buffers} now.

Checked by clippy of rt and conformance (plain and --cfg m2v_gpu), rustdoc of the workspace with
warnings denied, and the rt and conformance suites on msi.
2026-11-17 14:01:59 -08:00
Anees Iqbal 8b15f6574b harness: frame_5cb, a frame of five command buffers, with each command buffer's commit-to-complete time
The recordings of a game commit a median of five command buffers a frame, against the one of a
desktop session's frame that the frame row has. frame_5cb is that frame in compute alone: five
command buffers of frame's shape (four lcg_step dispatches each, bindings set per dispatch, the
increment from a Managed buffer), committed back to back and waited for once, 20 dispatches a
run. Of the two rows, this one decides how many batches a runtime may keep in flight: with five
commits and two in flight, three join a later batch.

Beside the run's GPU span and its submissions, the row prints each command buffer's
commit-to-complete time, at the 50th and 99th percentiles of the timed runs' command buffers: a
plan that asks for it (Plan::commit_to_complete, frame_5cb alone) gives each command buffer of
its timed runs a completed handler (addCompletedHandler:, the harness's CommandBuffer trait's new
add_completed_handler) that reads the time from just before its commit until the handler runs.
The warm-up, the first run and the counted run take no handler, and the other rows' command
buffers take none, so their measurement is as before. After the timed runs the harness waits up
to ten seconds for every handler to have run (a handler may run after the wait for its command
buffer returns) and fails the row otherwise. The table gains two columns, c2c_us_p50 and
c2c_us_p99, "-" for rows without the handlers.

The device test of every authored workload checks that a run reports one commit-to-complete
time per command buffer where the plan asks for them, and none elsewhere; a unit test checks
that frame_5cb is frame's command buffer five times over.
2026-11-17 13:56:34 -08:00
Anees Iqbal 1ce1d97f2c harness: waves, the fixed cost of a wave: 735,000 one-wave threadgroups of a load and a store
A dispatch of many threadgroups that each do almost nothing pays mostly for its waves: their
start, their end, and whatever a translated kernel adds before its work. The waves workload is
one dispatch of 175 by 4,200 threadgroups of 32 threads (wave_store), 735,000 one-wave
threadgroups, each thread one load from a constant buffer argument (a 16-byte Private buffer)
and one 4-byte store of base + index into a 94 MB Private buffer, checked against its CPU
reference. A run's GPU time over 735,000 is a per-wave budget, which catches a per-wave prologue
cost on either runtime.

wave_store is ours, in the harness's workloads.metal; scripts/regen-air-fixtures/regen-air-fixtures.sh
--dir harness regenerated workloads.ll and workloads.air.ll with the recorded toolchain (Apple
metal 32023.922, macOS SDK 27.2, LLVM 21.1.8), and --check passes.
2026-11-17 13:56:34 -08:00
Anees Iqbal 35a64f2bbf Re-bless the golden hash table at 069e4753ac
core-r added the unit_axes_walk fixture. This adds its two golden rows, its two engine
expectation rows and its air_input printout. Additions only: no row changed and no profile
fingerprint moved.

Verified: M3 bless job m3-max-42450 (bless-job.sh at 069e4753ac): golden_hashes_match_the_table
passes on the blessed table.
2026-11-17 13:55:17 -08:00
Anees Iqbal 069e4753ac rt: the unit-axes test runs unit_axes_walk, whose emulated walk states the relief
simd_divergent's trip_k (a trip count from the thread's index) states no unit-axes relief on any
device: the legs (m3-max-42278) ran its sums right and found neither its plain module nor its
emulated variant stating UnitAxes, so the test did not show that a module stating it ran. The
relief follows a position along an axis, so the test now runs the owned fixture unit_axes_walk:
a loop of (y & 3) + 1 iterations at grid row y around a simdgroup sum, in one threadgroup of
8 x 8 and one of 8 x 10 threads.

The fixture's companions are regenerated by scripts/regen-air-fixtures on the M3 Max
(m3-max-42286), where Metal (macOS 27.0.1) answers every thread of both threadgroups as the test
expects: the sum over its iterations i of i + 1 times the threads of its simdgroup whose own trip
count exceeds i.
2026-11-17 13:50:21 -08:00
Anees Iqbal 1bb19ba769 fixtures: unit_axes_walk, a loop of the thread's row in trip count around a simdgroup sum (MSL) 2026-11-17 13:50:21 -08:00
Anees Iqbal 5adc675ca3 rt: RowLockstep stays refused until a device test runs a kernel that states it
The previous commit accepted RowLockstep (lockstep barriers that a one-row region could skip)
with no owned fixture that states it and no device test that ran one. Until one exists it is
refused as before: the fact match's catch-all answers Gap::KernelInput for it, as for every
fact the match does not name.
2026-11-17 13:50:21 -08:00
Anees Iqbal 935f87025b rt: a kernel whose walk unit axes could relieve runs on its plain module
The translator states RuntimeFact::UnitAxes with no axes beside a predicated walk that a
unit-axes variant would make less divergent: the module is the general one, and the fact only
offers the variant. rt's fact match did not name it, so every such kernel was refused as
Gap::KernelInput: on a device whose tier emulates SIMD groups its plain module, and elsewhere
its emulated variant, which left threadgroups of partial SIMD groups refused.

The match now runs on the general module the two relief facts the translator can state for a
kernel rt lowers: UnitAxes with no axes, and RowLockstep (lockstep barriers that a one-row region
could skip; rt keeps every region's whole groups). It also passes the two facts the translator
checks against the descriptor when it compiles and nothing on the device reads: CallStackDepth
and OpenClMode. RuntimeFact is non-exhaustive, so the match keeps its catch-all: a fact it does
not name stays Gap::KernelInput.

Test: every_device_runs_a_kernel_whose_walk_unit_axes_could_relieve runs simd_divergent's trip_k
(a loop of the thread's own trip count around a SIMD-group sum) in threadgroups of 64 and of 80
on every device, checks Metal's sums, and requires that a module stating UnitAxes with no axes
ran: the plain one, or the emulated variant the reaper made.
2026-11-17 13:50:21 -08:00
Anees Iqbal 46303836b0 rt: whole 32-thread SIMD groups that are not whole subgroups run the emulated module; padding goes
Padding a threadgroup of whole 32-thread SIMD groups to the next whole subgroup on the
partial-threadgroups variant lost to the emulated module on every GPU measured, on the size-1
probe and on real kernels. The emulated module now serves every threadgroup that is not whole
subgroups of a kernel whose tier runs only whole ones, 32 threads on a device of 64-lane
subgroups included, as it did before the padded form.

Gone with it: the encoder's padded choice and its NONUNIFORM flag on a whole grid, pipeline.rs's
padded() and Variant::threads (Constant::Threads is the size's product again), the workgroup
invocation and subgroup limits only padded() read, the test helper Kernel::made, and the
padded assertion of every_device_runs_simd_groups_at_metals_width.

every_device_lays_out_simdgroups_as_metal_does stays: it holds each size to Metal's layout on
whichever module runs it, now the whole module or the emulated one.

The partial-threadgroups variant stays: a kernel that does not observe its threadgroup partition
runs all its dispatches in tiles on it, and a dispatch_threads grid that is not a whole number of
threadgroups runs on it. A ragged grid at a threadgroup that is not whole subgroups of a kernel
whose tier runs only whole ones is refused (Gap::PartialThreadgroups) again, as before the
padded form.
2026-11-17 13:50:21 -08:00
Anees Iqbal 89069698c5 api signatures: bless the set 1 and index grant surface of metal2vulkan-rt
The set 1 landing (1b97a620c8) added public items to metal2vulkan-rt without the table's rows,
so api_signatures failed on development since then. Blessed with
`python3 scripts/api-signatures/signatures.py --bless` on development's tip d5e3efc51b.

For a consumer nothing is removed or changed in signature. Added: IndexClass (Texture,
StorageTexture, Sampler, range), IndexGrant (first, count, class), Device::grant_indices and
Device::release_indices, Gauges::device_samplers, floor::Features::robustness2,
Limit::IndexRange, Refusal::IndicesGranted and Refusal::IndicesNotGranted. The constant
floor::DEVICE_EXTENSIONS gains VK_EXT_robustness2 (its nullDescriptor feature joined the floor
with set 1), so a device without the extension was already below the floor.

Verified:
- `python3 scripts/api-signatures/signatures.py --check` clean locally.
2026-11-17 13:35:59 -08:00
Anees Iqbal d5e3efc51b Re-pin the runtime sources at the landing tip
The landed packet changed a runtime-sources input, so the committed digest no

longer described the sources and `the_runtime_sources_are_the_committed_ones`

would fail. Recomputed over the same inputs and committed by land-pkt.sh.
2026-11-17 13:28:29 -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 d8bd04c7f7 rt: Work::upload records any commands into the upload, keeping what they use until it retires
The upload, the command buffer recorded apart from the guest's command buffers and submitted
ahead of everything in the next batch, took zero fills alone (Work::zero). Work::upload(core,
held, record) now takes any commands: `record` is given the device and the upload's command
buffer, recording under the work lock, and the upload keeps each of `held` (Held::Block today)
until it retires. Work::zero calls it, with its behaviour unchanged. Textures' layout
transitions and replace_region's copies will record through it.

Tests: the zeroed-buffer device tests, unchanged, run through it.
2026-11-17 12:58:35 -08:00
Anees Iqbal 7bc33305e1 rt: encoder.rs drops the record import its dispatch path no longer uses 2026-11-17 12:57:25 -08:00
Anees Iqbal 8d160c12ac rt: a barrier between dispatches reaches indirect argument reads only before an indirect dispatch
The barrier between two dispatches took the indirect-argument stage (DRAW_INDIRECT,
INDIRECT_COMMAND_READ) in its second scope, so that a dispatch after it could read its
arguments from a buffer written before it. On NVIDIA that keeps it as costly as the barrier
that takes every command (m3-max-42161: the 2080's frame and dispatch_chain rows equal with and
without the narrowing), while the harness lane's barrier of compute shader accesses alone took
the 2080's frame row from 22.2 to 8.5 us a command buffer.

The barrier now takes indirect argument reads only where the dispatch it precedes is indirect,
known at the dispatch (Reach::Dispatches { indirect }), and for a barrier an encoder owes, at
the dispatch that records it. A barrier that leaves them out does not order a write before it
against a later indirect dispatch, so the command buffer keeps whether a dispatch wrote since the
last barrier that reached them (cleared by one that did and at the segment's end); an indirect
dispatch after such a write gets a barrier that reaches its argument read, in a serial or a
concurrent encoder.

Test: a dispatch writes the arguments, a direct dispatch reads them (a barrier for shader
accesses), an indirect dispatch that conflicts with neither reads them: three barriers (the two,
and the segment's end), and the indirect dispatch's output is right.
2026-11-17 12:57:25 -08:00
Anees Iqbal 7edbf84c8f rt: a barrier between dispatches reaches dispatches only
A barrier a segment records between its dispatches (at a hazard in a serial encoder, at
memory_barrier, after a write through an address outside every resource, and the one an encoder
that wrote owes the next dispatch) took every command as both scopes: all commands' memory writes,
made visible to all commands' reads and writes. A segment records nothing else that touches memory
(its other commands are the timestamps), so the barrier now takes compute shader writes as its first
scope and compute shader reads and writes and indirect argument reads as its second
(Reach::Dispatches): the stages and accesses a dispatch has, decided by what the segment records,
with no query. The barrier at a segment's end, the upload's and the fill's keep every command.

The test recorder, which records fills and copies, keeps the wide barrier for the owed one before
its commands, and is not followed by a dispatch in any test.

Timed as a probe on the barrier redesign (M2V_PROBE_NARROW_BARRIER, m3-max-42031 to 42036, 42040),
dispatch_chain (512 serial dispatches on one buffer) steady time: 780M Phoenix 509 -> 333 us and
Hawk Point 529 -> 333 us (-35%), XTX 523 -> 492/505, equal on the 2080, 3090, RX 550 and UHD 630;
the 160-command-buffer row lower on both 780Ms and equal elsewhere. Slower on none.
2026-11-17 12:57:25 -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 58891b9ce5 harness: the lcg rows bind their increment from a Managed buffer, as the recordings do; burst_160_shared keeps the Shared row
The recordings bind small constant arguments from Managed buffers
(216,574 dispatches in one, against 94 Shared-backed), so the frame,
burst_160, burst_2000 and burst_2000x5 rows now keep their increment in
a Managed buffer, written through contents and flushed with
didModifyRange:. burst_160_shared keeps it Shared, for the record.

The harness gains Storage::Managed and Buffer::did_modify_range. The old
runtime makes a real Managed buffer. The new runtime has no Managed
storage, so its harness keeps the GPU copy in a Private buffer, written
as a Private one is (through a Shared buffer and the copy kernel), as
didModifyRange: updates a Managed buffer GPU copy on a Mac with a
discrete GPU.
2026-11-17 12:41:44 -08:00
Anees Iqbal 2dfb2f2041 rt README: a loop's unrolling is the driver's unless the kernel asks
The translator gives a loop LoopControl only from its AIR hints (#pragma unroll,
#pragma nounroll) or DontUnroll for a loop it writes itself; every other loop leaves
unrolling to the driver, and we add no hint in either direction to steer it. The known
gap records what that costs on one driver.

Measured with the constant-reads probe (steelbrain/item-a-probe, not landed), read
divergent, 4096 groups of 64, 128 iterations, two processes x 50 samples, rows shuffled
per round: RX 7900 XTX, RADV Mesa 26.2.6, job m3-max-42107. 64 KiB: 105.5 us rolled
(today's word form), 112.9 us rolled (one 16-byte load, DontUnroll), 207.5 / 209.3 us
unrolled (today's form with Unroll / the 16-byte load as RADV unrolls it). 16 KiB:
unrolled 6.7-8.0% faster; 256 KiB: 15.6-16.8% faster. RADV's dump (jobs 42055, 42107)
shows the unrolled kernel issuing 128 global_load_b128 in 13 clauses against one per
iteration rolled.
2026-11-17 12:36:36 -08:00
Anees Iqbal 74669c0552 Re-bless the golden hash table at 53f4a44df7
The engine inventory, the golden hash table and the air_input printouts gain the rows of the two
fixtures that landed since the last bless (vector_word_phases, pad_simd_shape): 6 golden rows, 6
inventory rows, two printouts. Additions only: no existing cell or fingerprint moved.
Blessed on the M3 by job m3-max-42118 at 53f4a44df7.
2026-11-17 12:28:34 -08:00
Anees Iqbal 53f4a44df7 harness: wide_bindings' plan names its per_encoder split
The landing of wide_bindings (1cc0212231) met the harness lane's new
Plan field per_encoder (87e049f422) in the rebase, and the workload
list's conflict was resolved without it, so development's harness
did not compile (E0063, missing field `per_encoder`, authored.rs).
wide_bindings records every dispatch in one encoder, as before: None.

Verified: the harness built at development cd5a76a757 failed with
E0063 at authored.rs:524 (job m3-max-42099); this commit's clippy and
harness tests are in the job named in the hand-off.
2026-11-17 12:18:19 -08:00
Anees Iqbal cd5a76a757 docs: conformance coverage with the vector word-phase cases 2026-11-17 12:15:37 -08:00
Anees Iqbal f2cead2c6c conformance: vector-word-phases recordings (Apple M3 Max, job m3-max-41993); rt: every device places each vector access at its own address 2026-11-17 12:15:36 -08:00
Anees Iqbal fa0d3acc9b conformance: vector-word-phases-{0,4,8,12}, vector accesses at each word phase past a buffer's bound base 2026-11-17 12:15:36 -08:00
Anees Iqbal cbc2a4be13 tests: vector accesses at each word phase claim at most the proven alignment and answer Metal's words on the interpreter 2026-11-17 12:15:36 -08:00
Anees Iqbal 0d55bac1e6 fixtures: vector_word_phases's AIR companions (job m3-max-41960) 2026-11-17 12:15:36 -08:00
Anees Iqbal 3facb9a4bb fixtures: vector_word_phases, vector accesses at each word phase past a 4-aligned bound base (MSL) 2026-11-17 12:15:36 -08:00
Anees Iqbal ef61332bbb rt: every device lays out a threadgroup's simdgroups as Metal does
The fixture pad_simd_shape (simd_shape: simdgroup index, lane, simd_sum(1u) and index in the
threadgroup per thread) with its companions, regenerated by scripts/regen-air-fixtures on the M3
Max (m3-max-41884). Metal's answer, measured there (m3-max-41877, macOS 27.0.1) at threadgroups of
80, 1, 32, 64 and 40 threads: thread i is lane i % 32 of simdgroup i / 32, which holds
min(32, n - 32 (i / 32)) threads; 80 falls 32, 32 and 16. The device test runs the five sizes on
every device and holds each module that runs one (the whole module, padded, or emulated) to it.
2026-11-17 12:14:28 -08:00
Anees Iqbal f33c9a75d9 fixtures: pad_simd_shape, a kernel that writes how its threadgroup's threads fall into simdgroups 2026-11-17 12:14:28 -08:00
Anees Iqbal 93a4728c07 rt: whole 32-thread SIMD groups that are not whole subgroups run padded on the partial-threadgroups variant
A kernel whose tier runs each SIMD group as a 32-lane cluster of a wider subgroup (a device of
64-lane subgroups that cannot pin 32) runs only workgroups of whole subgroups. A direct dispatch
whose threadgroup is whole 32-thread SIMD groups but not whole subgroups (32 threads on such a
device) now runs on the kernel's partial-threadgroups variant in a workgroup of the next whole
subgroup, with its region flagged NONUNIFORM even on a whole grid: the variant answers each
threadgroup's threads from the region's nominal size L, min(L, grid - group * L) per axis, and
an invocation whose lane index (from the subgroup IDs: SubgroupId * SubgroupSize +
SubgroupLocalInvocationId) is at or past their product does not exist. It returns before the
body, or in a body with workgroup barriers walks it predicated, reaching each barrier and running
nothing else, so it loads and stores nothing. Each SIMD group of the threads is one whole cluster
and keeps the native subgroup operations. The workgroup is specialized apart from Metal's size
(Variant::threads, the flattened size), within maxComputeWorkGroupSize, maxComputeWorkGroupInvocations
and maxComputeWorkgroupSubgroups. Any other threadgroup that is not whole subgroups (80 or 1
thread, an indirect dispatch, a kernel without the variant) runs the emulated module.
2026-11-17 12:14:28 -08:00
Anees Iqbal 070d0142ed rt: a teardown begun in a completed handler runs on the reaper on every path
The handler-teardown test failed once on the 3090 (matrix job m3-max-41909 at 03a3741772): the
block was unmapped on the test thread, not the reaper. commit() cloned a device handle for the
call and dropped it, and the command buffer's own handle, only as it returned, after the
command buffer was handed to the submit thread. A command buffer that completed and ran its
handler before commit() returned left the call's handle as the last one, so the teardown ran in
commit() on the consumer's thread.

The contract stands (teardown runs on the thread that drops the last handle, or on the reaper
where that is a handler or a listener), and every path now honours it:
- commit() holds the core, not a handle, and gives the command buffer's handle up before the
  hand-off (Device::release: Arc::into_inner, so a handle that is not the last is let go under
  the lock and the last one is dropped once no lock is held, ending the device in the call only
  where the consumer holds no other handle).
- The consumer's unmap hook runs in the halt, on the thread that tears down, after the other
  threads are joined, at teardown as at quiesce. The memory is freed and the VkDevice destroyed
  where the core's last reference is released, which a call can still hold for a moment as it
  returns (commit's core, a queue's last drop); that runs no consumer code, and the gauges still
  reach zero only after it.

Test: the handler records how many handles exist as it drops its own: one, as commit gave its
handle up before the command buffer could complete; the unmap is on the reaper.
2026-11-17 12:13:31 -08:00
Anees Iqbal 18ba5050d0 rt: the emulated scratch takes two regions only where they cost the kernel nothing Metal shows
Under the identity domains the emulated tier's scratch holds two regions, each exchange and vote
taking the next, only where that costs the kernel nothing a Metal program can observe: two regions
of one simdgroup fit beside the kernel's threadgroup memory under maxComputeSharedMemorySize (with
an emulated object or mesh entry's wrapper words and payload), as many simdgroups fit beside it as
with one region up to Metal's 1024 threads, so the pipeline reports as many threads per threadgroup
and every threadgroup one region runs still runs, and the kernel binds no [[threadgroup(n)]] region,
whose length the encoder sets at each dispatch. Elsewhere the kernel keeps one region and closes
each exchange with a barrier, as before rule 1. The choice reads only the limit query and the
kernel's own plan (workgroup::two_regions_fit).

SEMANTICS_VERSION 2160: an identity-domain emulated module whose threadgroup memory leaves no room
for two regions changes back to one.
2026-11-17 12:11:50 -08:00
Anees Iqbal 1048de46db Re-pin the runtime sources at the landing tip
The landed packet changed a runtime-sources input, so the committed digest no

longer described the sources and `the_runtime_sources_are_the_committed_ones`

would fail. Recomputed over the same inputs and committed by land-pkt.sh.
2026-11-17 12:10:30 -08:00
Anees Iqbal 5c74502072 push window: the identity test's kernels stay within Metal's 31 buffer slots
Gate 41971: a kernel of 33 buffers is invalid input (SlotPastTable): Metal binds 31. The test now
pushes a kernel's 21 and 31 slot addresses through from_queries' 256-byte window with no block;
the spill past it stays covered by push.rs and the new runtime's 30-buffer device test, whose
dispatch region takes 32 bytes.
2026-11-17 12:09:38 -08:00
Anees Iqbal 1cc0212231 harness: the wide_bindings kernel's companions
scripts/regen-air-fixtures/regen-air-fixtures.sh --dir harness on the M3 (job 41966, LLVM 21 as
TOOLCHAIN pins it): the new kernel, and the other kernels' metadata renumbered around it.
2026-11-17 12:09:38 -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 03bfd0f318 harness: the parts test compares bounds, not one-range arrays (clippy single_range_in_vec_init) 2026-11-17 12:01:16 -08:00
Anees Iqbal d395a2b125 harness: the frame rows take recorded shapes: a burst of 160, a burst of 2,000, and 2,000 at five encoders
The 160-command-buffer frame is renamed burst_160 for what it is, a burst
of small command buffers. burst_2000 is the burst a recording commits
most: 2,000 command buffers of one compute encoder of one lcg_step
dispatch, committed with no wait between and waited for once.
burst_2000x5 is that burst at five compute encoders a command buffer
(a plan now cuts a command buffer into encoders by per_encoder). frame
stays the desktop session shape, one command buffer of four dispatches.

A run is now waited for as a program waits for a burst: its last command
buffer first, then the rest (each then complete), rather than each in
order, which woke the waiter once per command buffer.
2026-11-17 12:01:16 -08:00
Anees Iqbal 87e049f422 harness: frame takes a desktop session's shape; the 160-command-buffer frame is frame_stress
The recorded desktop sessions commit a median of one command buffer a
frame (two at the 90th percentile) with a few dispatches each, not 160.
frame is now that shape in compute alone, one command buffer of four
lcg_step dispatches a run; the form it had, 160 command buffers of two
dispatches, stays as frame_stress, a stress row judged only where a
recording commits at that rate. Both bind as before: the words and a
Shared increment by setBuffer, no setBytes.
2026-11-17 12:01:16 -08:00
Anees Iqbal af6a048de1 rt: the emulated tier's exchanges and votes take two scratch regions in turn
Under the identity domains the emulated simdgroup tier's scratch holds two regions, and each
exchange and vote takes the next by a per-invocation turn (a Private u32 from 0 that each flips;
every invocation executes the same exchanges, so it is workgroup uniform). An exchange writes the
region the one before it did not; every lane read this region's last words before the barrier
that opened the exchange in between, and that barrier orders those reads before this exchange's
writes. So no exchange or vote closes with a barrier: a shuffle or broadcast is one barrier, a
five-round reduction or scan five (from ten), a vote or ballot two (from three), a matrix
multiply-add one (from two), a predicated loop's workgroup vote two (from three).

Vulkan's memory model: a control barrier with release and acquire semantics makes each
invocation's release synchronize with every invocation's acquire after it ("If A is a release
barrier, B is an acquire barrier, and C is a control barrier ... then A synchronizes-with B"), and
a read is location-ordered before a non-private write it happens before, so it does not see it.

The scratch takes twice its bytes per simdgroup (RuntimeFact::SimdgroupEmulation), so a kernel
whose threadgroup memory is near maxComputeSharedMemorySize reports fewer threads per threadgroup
or is refused where one region fit. The default domains (Device::new) keep one region and every
closing barrier.

SEMANTICS_VERSION 2159: the emulated modules of the identity domains change.
2026-11-17 11:54:16 -08:00
Anees Iqbal ec8d82744d rt: the emulated module boxed in its lowering; the reaper's end takes the lowerings left
Clippy: Lowered::Made held a Kernel beside three small variants (large_enum_variant), and the
reaper's end drained the queue into a new one (drain_collect).
2026-11-17 11:48:14 -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 57ab393bd1 Re-bless the golden hash table at f29eb171a4
M3 bless job m3-max-41933 (every assembler) at development f29eb171a4, after the four
old-runtime regression fixes (d5a475f1a0, e0f567a8bc, aa8d6ac6f5, 8ec8cbbc20).

Against this morning's table (5c47b9c867, before the shared-path changes that moved the old
runtime): 3,412 rows kept, 0 cells changed on every one of the 19 profiles, 20 rows new (the
widest-pin shuffle fixture). Every profile's fingerprint differs from 5c47b9c867's: they are the
values 6f5bd20321 gave them when the profile lost its 16-bit-output field, which the restore
carries as a profile fact the fingerprint does not render for Device::new. A fingerprint is a
cache key, so a cached artifact of the old runtime misses once; no output differs.
2026-11-17 11:37:28 -08:00
Anees Iqbal f29eb171a4 harness: gauges at runs 100 and 200 are read with the device idle
The matrix at a17eb26a6b failed harness-new/frame/command_buffers
flatness: 63 at run 100 against 60 at run 200 on the Hawk Point, 62
against 64 on the RX 550. The new runtime's command_buffers gauge counts
command buffers made and not yet retired: the work in flight when it is
read, which moves with completion timing. The harness now waits for the
runs committed so far before it reads the gauges at runs 100 and 200, so
they count what the runs left behind; a leak still grows between them.
2026-11-17 11:33:28 -08:00
Anees Iqbal 307949a788 cache: SEMANTICS_VERSION 2158, one above each of the two changes that both took 2157
8ec8cbbc20 (a half color output 16-bit again under Device::new) and 45da84cc5a (NonWritable
loads under the identity domains) each raised SEMANTICS_VERSION from 2156 to 2157 on separate
branches; the identical edits merged without a conflict, so a cached artifact made at
8ec8cbbc20 would be keyed the same as the output of the NonWritable change. One more bump
separates them. No output changes.
2026-11-17 11:32:34 -08:00