Commit Graph
16 Commits
Author SHA1 Message Date
Anees Iqbal f8af954378 Emulate Metal's anisotropic filter as one routine per shape, its offset the taps' Offset operand
Metal's anisotropic filter is emulated as one routine per shape, with its calls kept where the
driver keeps them (the RTX 5080), and an anisotropic sample's texel offset reaches the routine as
the taps' Offset operand.

Folds in:
- Emulate Metal's anisotropic filter as one routine per shape, its calls kept on the RTX 5080
- Pass an anisotropic sample's texel offset to its routine as the taps' Offset operand

Verified by each folded change's own checks; the tree this series ends on is the one verified
at the tip on six GPUs, the CPU suites and lint (see the tables commit).
2026-10-19 00:16:00 +03:00
Anees Iqbal 930d746df7 Read ASTC, ETC2/EAC, PVRTC and 4:2:2 textures the device lacks through twins of Metal's decode
On a device without a texture's compressed or chroma format, the runtime now makes the texture and
reads it as Metal does. Before, such a texture was refused at its making (ASTC, ETC2/EAC) or at its
first read (PVRTC, 4:2:2, held for copies alone). The consumer's guest on the RTX 5080 stopped at
ASTC_8x8_LDR, PVRTC_RGB_2BPP and EAC_R11Unorm. NVIDIA, RADV and lavapipe have none of these formats,
and Vulkan's 4:2:2 formats need a sampler Y'CbCr conversion whose chroma reconstruction is the
implementation's.

What changes:
- The store. The blocks lie in a carrier image of the same block bytes and shape (a compressed
  format the device copies: BC1, BC4, BC7, BC3, BC2, BC5, ETC2, EAC or ASTC 4x4; R8G8 for 4:2:2).
  replace_region, get_bytes, blits, fills and texture copies move Metal's blocks unchanged.
- The twin. Reads go to a decoded twin holding Metal's decode, kept in step on the GPU as a BC
  texture's twin is: a decode pass after a blit, a texture copy or a submitted CPU copy, and a CPU
  decode on the device's decode thread after a host write. No write costs a GPU-to-CPU round trip.
  A write's decode covers whole levels for PVRTC and whole rows for 4:2:2, whose texels read their
  neighbours. A new texture's twin starts at the decode of zero blocks (magenta for ASTC's error
  block), not at zeros.
- The decoders, our own, written from the Khronos ASTC specification, the Khronos Data Format
  Specification's ETC2 and EAC chapters, and Metal's measured answers for PVRTC1 and 4:2:2:
  bind::AstcDecode, EtcDecode, PvrtcDecode and ChromaDecode, with their GPU kernels
  astc_decode_module, etc_decode_module, pvrtc_decode_module and chroma_decode_module on the block
  decode's bindings (new api_surface rows, with AstcTexels, EtcTexels and DecodedTexelsPolicy).
- Metal's decode, matched: an ASTC LDR channel is (C >> 4) / 4095 of the 16-bit interpolated C;
  an 8-bit ETC2/EAC channel c / 255, an 11-bit one c / 2047 (signed c / 1023); PVRTC upscales
  colours A and B from the four block centres around a texel and blends them by its index; a 4:2:2
  texel takes its own green, and red and blue (3c + n + 2) >> 2 of its pair and the pair beside it.
- sRGB forms. The ASTC, PVRTC and ETC2/EAC sRGB formats read their twin's codes raw through an
  R8G8B8A8_UNORM view and decode them through Metal's table, as the 8-bit and BC sRGB formats do:
  reads, nearest samples and gathers exact, with no precision notice. Linear samples keep the
  device's sRGB filter (the exact sum under SamplingPolicy::Exact). A device that has the ASTC
  block keeps its own sRGB decode. The linear PVRTC and 8-bit linear ETC2/EAC formats take BC1 to
  BC3's Argb8 texel class, so under TexelConversionPolicy::Exact their reads are Metal's c / 255.
- The switch: DevicePolicy::decoded_texels, DecodedTexelsPolicy { Compact (default), Exact };
  exact_answers() selects Exact. Compact holds an ASTC LDR twin in 8-bit codes nearest Metal's
  12-bit value (at most 1/510 off) and an EAC 11-bit twin in the nearest 16-bit codes, announced
  decoded-texel-precision. Exact holds their floats. PVRTC, the 8-bit ETC2/EAC formats, the ASTC
  sRGB formats and 4:2:2 are exact under both. Tested by fast_paths; a FAST-PATHS row.
- Views in the other colour space. An ASTC texture viewed in its other colour space reads a second
  twin, made at the first such view: Metal reads that view exactly as a texture of the view's
  format over the same blocks, and the two forms widen endpoints apart, so one twin cannot serve
  both. Its decodes are queued on the device and recorded by the next batch with work. Counted by
  WorkCounts::second_twins, second_twin_checks and second_twin_decodes. PVRTC and 8-bit ETC2/EAC
  views of the other colour space share the one twin.
- Copies between a compressed texture and an uncompressed one whose texel is the block's bytes
  (BC1 or ETC2 with RG32Uint, BC7 or ASTC with RGBA32Uint) run with Metal's rule: every coordinate
  in the destination's texels, a block per texel. They were refused as formats of different units.
- Notices: carried-decoded-twin (Performance) on every twinned texture; decoded-texel-precision
  (Precision) only for an ASTC LDR or EAC 11-bit twin under Compact.
- Typed refusals: RuntimeGap::DecodedHeapTexture (a heap's ASTC texture, a sparse heap's carried
  texture; the heap size query refuses alike); views of the ASTC HDR form, of another footprint or
  PVRTC block, and of an EAC 11-bit format as its other signedness (Unsupported(TextureView));
  copies between PVRTC and an uncompressed format, between two compressed formats of one block size
  and different extents, and level or slice copies between compressed and uncompressed formats
  (NotImplemented(Format)). A device with the native format keeps the direct path.
- Docs: the API.md catalogue entries, the FAST-PATHS decoded_texels row and known gaps, and the
  module docs of astc.rs, etc.rs, pvrtc.rs, chroma_pairs.rs and decoded_twin.rs.

Why: Metal makes, reads and samples these textures on Apple GPUs, and the consumer's guest uses
them; the desktop Vulkan drivers have no such formats.

Verified:
- Metal's answers, probed on an M3 Max under macOS 27.0.1: ASTC (seeded random blocks, all 14
  footprints, linear and sRGB, read as float and half) bit for bit, digests pinned by
  seeded_blocks_read_as_metal_read_them; ETC2/EAC (4096 random blocks of each of the ten formats)
  digests equal; PVRTC (all eight formats) every digest equal; 4:2:2 every read, sample and gather
  bit for bit what an RGBA8Unorm texture of the decoded codes answers; the copy rule on every listed
  pair both ways.
- On the CPU SPIR-V interpreter each GPU kernel writes the CPU decode on every texel: ASTC on every
  footprint, linear and sRGB, Float and Unorm8, with blocks covering all 16 endpoint modes, every
  partition count, dual plane and void extent; ETC on every decode and both texel forms; PVRTC on
  every format. The kernels are valid on every committed profile.
- Runtime unit filters 63 passed and translator unit filters 183 passed (ETC2/EAC); the runtime's
  unit suite 952 of 953 (the one failure the recorder's module-list test, fixed with the recorder).
- On lavapipe: chroma_pairs, pvrtc_textures, the mipmap, fill, buffer-texture and degrade-notice
  lanes, 45 passed; format_copies, the whole module. A lavapipe batch caught PVRTC codes read one
  ulp high under exact answers, fixed by the Argb8 class.
- clippy -D warnings (plain, m2v_gpu, m2v_cpu_icd) and rustdoc on ms01 and gem10.
2026-10-19 00:15:59 +03:00
Anees Iqbal 6b322fb50f Cut the cold making of half-heavy shaders on ANV and RADV: controlled half rounding and the device's half widening
On Intel's ANV, CoreAnimation's A2Xghfc fragment shader (313k words) took
about 14 s to make cold, for each of three states. The consumer's x86 macOS
guest stalled with "no completion in 10 s" on its first boot. Native Metal
makes it in 0.48-0.56 s on the M3. brw (Mesa's Intel backend) spends that
time in its register allocator. Its interference build is quadratic in
instruction count, it spills, and it retries several scheduling modes. Most
of its input was our half arithmetic. Two cuts, each the cheaper form, are
taken on ANV and RADV.

1. A half result computed in float rounds through the device's conversion
   pair under the float controls (QuantizeForm::Controlled). It replaces
   OpQuantizeToF16 plus a denormal arm, about 11 NIR operations per lane.
   - The form: an OpFConvert to 16 bits and back, each decorated
     NoContraction, in an entry that declares RoundingModeRTE,
     DenormPreserve and SignedZeroInfNanPreserve for 16 bits, plus the
     modes the device's independence ties to them (ANV: RTE for 32 and 64
     bits; RADV: RTE and DenormPreserve for 64 bits). The modes are
     declared post-lowering (new ExecMode kinds), and the requirements
     carry the FloatControl properties.
   - Exact by the Vulkan spec under either HalfRoundingPolicy: conversions
     are correctly rounded, and NoContraction forbids folding the pair. No
     fact, no note.
   - A new DriverWorkaround, HalfConversionPairFolded, keyed on NVIDIA's
     proprietary driver, keeps NVIDIA on its previous forms. NVIDIA
     615.71.09 on the RTX 3090 folds the pair even under NoContraction and
     every mode combination, and the PackHalf2x16 and u16-bitcast forms
     fold the same way: 2,231,288,832 of 2^32 narrowings unrounded. A
     plain-Vulkan repro gives 16,775,680 of 2^24 unrounded on the 3090 and
     0 on ANV.
2. A half read from its bits (a load, a reinterpretation, a texel's bits) is
   the device's widening under NanMinMaxPolicy::Native, the default: each
   u32 lane is bitcast to f16x2 and converted to 32 bits, in place of a
   12-op integer decode. A half texel takes that conversion's NaN (no keep).
   - Every non-NaN half is exact by the spec: DenormPreserve covers
     "values obtained via unpacking an integer into a vector of values
     with smaller bit width".
   - A NaN's bits are the device's, recorded as NativeNanEncoding
     (native-nan-encoding), now also announced on ANV and RADV pipelines
     that decode halves. A half stored back unchanged keeps its bits.
   - NanMinMaxPolicy::Exact keeps the integer decode and the keep. There,
     every half widened to float answers Metal's 0x7fc00000 for a NaN, as
     the M3 does over every pattern from memory, constant memory, selects
     and texels.

Where brw's time went, measured on A2X (a2x-s96): after cut 1, 49.6k NIR
operations, of which the rounding pairs were about 10.7k, half decodes from
memory 8.6k and texel NaN keeps 2.6k. The rest was below 5% each.

Exactness probes:
- Cut 1 (candidate half(x) over all 2^32 f32, and half + - * over every
  pair): 0 non-NaN mismatches on ANV Iris Xe (Mesa 26.2.4), RADV 780M
  (Mesa 26.2.4), and the 780M and RX 7900 XTX (Mesa 26.0.8).
- Cut 2 (every half pattern): 0 non-NaN differences on ANV and RADV.
- The M3 confirms Metal equals the integer reference everywhere.

Cold making (A2X, base against each cut):
- ANV Iris Xe: 13.6-14.3 s, then 5.75-6.16 s, then 4.06-4.36 s. Peak RSS
  1.28 GB, then 0.50, then 0.35. GPU time per draw 4.62 -> 4.48 ms.
- RADV 780M: 0.80-0.84 s, then 0.53-0.55 s, then 0.38-0.47 s. GPU time per
  draw 4.05 -> 3.43 ms after cut 1, then within its clock states' spread.
In the consumer's cold boots on ms01 (Iris Xe), A2X went from 14 s per
state, plus two 38 s remakes, to 4.0-4.3 s. The suite's pipeline making went
from 126 s to 16.7 s, with no stall. Repeat boots show metalwin unaffected:
its frame rate follows other GPU work at session start, not this change.

Tests:
- engine_native_half: the controlled conversion, and a half read from memory
  under both NaN settings, NaNs stored back.
- device::tests::profile::nvidia_carries_the_folded_half_conversion_pair.
- lower::arith::tests: narrow, round_texel, half_texel, texel_round.
- spirv::requirements; spirv::builder::ops.
- Updated expectations: engine_arith half rounding, engine_spirv_cross_forms
  fma, engine_metal_routines frexp (the device's NaN under the default,
  Metal's under Exact).
- The validation lanes driver_deviations and native_maths expect the
  controlled form.

Docs: the FAST-PATHS half-rounding row (scope) and a new row for the
widening; the NativeHalfConversion and NativeNanEncoding entries in API.md and
their rustdoc; HalfRoundingPolicy and NanMinMaxPolicy rustdoc; HOWTO's driver
note; REFUSALS regenerated. A known gap is added to the texel-NaN row: on
ANV a 16-bit float NaN texel kept as half reads back 0xFE00 from ANV's image
decode, even under Exact (announced as device-nan-encoding). SEMANTICS_VERSION
1759, runtime pin recomputed, RUNTIME_VERSION unchanged.

Tables: the golden hashes, 274-389 cells on each ANV and RADV column across
both cuts, and NVIDIA's profile fingerprints, whose words are unchanged. The
authored compile census: artifact hashes on the 780M and RPL-P ANV columns,
with no status change. No MoltenVK, lavapipe or floor cell moves.

Verified on development-fast (batches f18-f24): every lane green on the RTX
3090, ANV Iris Xe, RX 7900 XTX, both 780Ms, lavapipe and the M3 Max, plus the
CPU suites, case qualification, clippy in every configuration, docs and
packaging. Not run on the RTX 5080 Laptop (host offline; whether its driver
keeps the pair is unmeasured).
2026-10-17 11:14:51 +03:00
Anees Iqbal 0175289314 Batch the development-fast round: tessellation without tessellationShader, primitive ids, mesh tooling, color groups, the vk12 floor, runtime timing and teardown fixes
One commit of the 247 on development-fast (720ef1ce9a..9f46fdf80d), squashed at the user's request.

Translator:
- Tessellation on a device without tessellationShader: Metal's tessellator emitted as SPIR-V, a
  one-workgroup scan placing each patch's triangles in Metal's order, and the post-tessellation
  function as a plain vertex stage (EmulatedTessellationDraws; SEMANTICS 1739, ARTIFACT_FORMAT 419).
- [[primitive_id]] on a device without geometry or tessellation shaders, as a flat varying the
  vertex function writes; indexed lists, lines and points drawn de-indexed (RuntimeGap::PrimitiveIdIndices).
- Fragment functions of more colors than the device draws at once, compiled in color groups
  (PrecisionNote::ColorAttachmentGroups).
- Object functions' threadgroup memory from the render encoder; a kernel's mesh draws from an
  indirect command buffer; mesh payload sizing.
- The Vulkan 1.2 floor profile (vk12-floor) and the gates it needs; Metal 27.0.1 answers as the M3 Max.
- Overflow tests in the runtime-built modules by the product's high word (NVIDIA's compiler fails
  the division form), guarded crate-wide by tests::owned_divisions.

Runtime:
- Color-group passes replayed per group over twin depth/stencil; snapshot and copy-back cost cuts.
- Command buffers finish on the queue waiter that saw them; the waiter holds no device handle, so
  a program's drop after its wait is the device's last.
- Every object an encoder was handed held until its command buffer completes; deallocator order
  and announcements.
- Driver defects recorded and announced: ANV counts a visibility sample once per color output
  (visibility-count-per-color); MoltenVK fails pending work when memory that held a device-address
  buffer is freed, so freed memory waits for the work in flight (host-deallocator-delayed).
- RenderCommandEncoder::set_object_threadgroup_memory_length; Visibility::counting().

Validation: mesh tooling (object, mesh and ICB-mesh cases on both executors), the authoring
census closed, the queue storm judged in Metal's unit, load-robust exits and indirect-census
bounds, and the golden hashes, printouts, fixture inventory and authored compile census blessed.

Docs: FAST-PATHS.md trimmed to a ledger of what is true now; API.md's catalogue and accepted
differences, REFUSALS.md and METAL-COVERAGE.md current.

Verified on development-fast before the squash: the full suites on the RTX 5080, RTX 3090,
RX 7900 XTX, Radeon 780M, Iris Xe, lavapipe and the M3 (MoltenVK and the Metal oracle), lint in
every configuration, rustdoc, doc tests, packaging and public case qualification; the timing and
teardown lanes x5 on every venue; the authoring-capability census 16656/16656 with 0 unresolved,
the vk12-floor translation census at 6139 translated with the slowest row 794 ms and peak 126 MiB.
The tree is development-fast's at 9f46fdf80d.
2026-10-16 11:12:03 +03:00
Anees Iqbal c05c380139 Match the M3 Max under macOS 27.0.1: measurements, profile, Metal rows and MoltenVK venue
The macOS 27 work packet: the M3 Max moved to macOS 27.0.1, where MoltenVK gives it the M4's
deviceID. Its measurements, its MoltenVK profile, its Metal rows (now the C3 reference) and its
MoltenVK venue rows are taken again, and the tests follow.

Read Metal's NotMipmapped anisotropic footprint through MoltenVK at level 0:
On macOS 27 Metal's anisotropic filter reads a sampler without a mip filter
differently once its level clamp reaches 1/64: the runtime's NotMipmapped form
(nearest mip, lod [0, 0.25]) handed MoltenVK an anisotropic footprint that
was not Metal's NotMipmapped one, and the anisotropic lane failed on the M3
Max under macOS 27.0.1. Through Metal's own sampler (VkProperty::MetalSampler)
with anisotropy and equal min and mag filters the sampler now clamps to
[0, 0]: with equal filters the level has no filter left to choose, and Metal
answers that sampler as NotMipmapped bit for bit. With filters that differ no
clamp reads Metal's answer at maxAnisotropy 2 to 16; that stays a known gap in
docs/FAST-PATHS.md.

RUNTIME_VERSION moves (renumbered once for the composed batch): a run of an unchanged
artifact samples differently.

Verified: metal::sampler unit tests (24, including the new
metals_own_anisotropic_sampler_reads_not_mipmapped_at_level_zero) at a release
build; runtime_lane::anisotropic_filter::anisotropic_samples_answer_within_
their_bounds_of_metals passes on the M3 Max, macOS 27.0.1, MoltenVK 1.4.1
(it failed at the round's first composed tree and at 61a2efc7d3).

Take the M3 Max's macOS 27 measurements on MoltenVK's shared Apple identity:
MoltenVK's deviceID on an Apple GPU is the macOS release and the GPU's
highest families (MVKPhysicalDevice::getHighestGPUCapability), so under
macOS 27.0.1 the M3 Max reports 0x1B000209, the M4's identity, and takes the
M4's driver facts. The owner's rule: an answer fact holds on the shared
identity only where measured on both GPUs; a cost fact follows the M3 Max.

- MetalNormStorageWrites and DepthTestKeepsDenormals, measured on the M4:
  re-measured on the M3 Max under macOS 27.0.1 with the fact taken, every
  channel and texel Metal's; kept, the evidence in their docs.
- GraphicsCubeGradientRoute stays measured on the macOS 26.7 identity alone;
  the shared identity's graphics route stays unmeasured.
- The interlocked pass: on the M3 Max under macOS 27.0.1 split ran about a
  quarter faster than whole (wall 721-769 us against 974-1045, GPU 671-719
  against 914-964, two runs of three rounds of 30 frames at 1920x1080
  RGBA16Float), so the shared identity's row moves from
  InterlockedPassWholeFaster to InterlockedPassSplitNoSlower. The M4's own
  measurement (whole faster) is in the row's doc and in docs/FAST-PATHS.md's
  known gaps. RUNTIME_VERSION 1190 on this branch covers it.
- APPLE_M3_MAX and APPLE_M4 say what the deviceID is.

Verified: the facts and timings on the M3 Max (macOS 27.0.1, MoltenVK 1.4.1)
through runtime-lane tests at the round's first composed tree with these facts; the
device::tests::driver_facts unit tests run at the rebased tip before landing.

Hold the degrade-notice lane to the resolves the device actually makes:
passes_degrade_once_per_kind expected the exact resolve and the device's
rounded one to be announced wherever the driver's RGBA8Unorm average at 4
samples is measured as Metal's, assuming a texture of 8 samples exists. The
M3 Max (macOS 27.0.1, MoltenVK 1.4.1) makes none at 8 samples, so neither
is announced there, and the lane failed. The filter now expects those two
where the average is not measured as Metal's or where the device makes an
8-sample texture.

Verified: runtime_lane::degrade_notices::passes_degrade_once_per_kind passes
on the M3 Max (it failed at 61a2efc7d3 and the round's first composed tree).

Write the tessellation test's vertex output as Metal's compiler does:
authored_tessellation_executes_native_patch_inputs hand-writes its AIR, and
its post-tessellation output carried metadata Metal's compiler does not
write (Xcode 27, every macOS target 13 to 27 checked): air.location_index on
a vertex output. Our AIR reader refused it (Abi(UnknownKey) for
air.location_index on a vertex output), as it should for a key the compiler
never writes there. The output now carries air.vertex_output with its
user(locn0) name, its type name and its argument name, as the compiler emits
it.

Verified: metal::tests::graphics::authored_tessellation_executes_native_
patch_inputs passes on the M3 Max, macOS 27.0.1 (it failed at 61a2efc7d3 and
the round's first composed tree).

Wrap the driver-facts claims test's doc at the line width:
The interlocked-pass sentence the shared-identity commit rewrote ran past
the 100-column doc width. No other change.

Hold the unmeasured-identity test to the macOS 27 identity's split form:
an_unmeasured_identity_takes_its_drivers_defects_alone still expected the
moltenvk-m4 capture to take InterlockedPassWholeFaster, which the shared
macOS 27 identity no longer does (it takes InterlockedPassSplitNoSlower, the
M3 Max's measurement). Found by the device::tests::driver_facts run at the
rebased tip.

Name the format where the formats capture and the product's query differ:
the_formats_capture_is_the_product_queried_formats_of_the_venue_device
compared every format's masks without naming the format, so a failure on
the M3 Max showed two masks and no format. Each assert now names it.
Test-only.

Capture the M3 Max's MoltenVK profile under macOS 27.0.1:
The reference Mac runs macOS 27.0.1 (26A434) now. Its moltenvk-m3 capture
(vulkaninfo --json and corpus-vulkan --capture-formats, Homebrew MoltenVK
1.4.1, vulkan-tools 1.4.350.1) is regenerated through
scripts/regen-device-profiles. Only the identity moved: MoltenVK's deviceID
on an Apple GPU is the macOS release and the GPU family, so the M3 Max now
reports 0x1B000209 (452985353), the M4's identity, and every capability,
limit and format mask is as before. c3-venues.json declares the new
identity.

The two captures now differ only in allocation sizes, which no translation
reads, so they derive one translation key:
- candidate::platform::profiles: a run on the M4 held to the M3 Max venue
  stops on the device name alone (the venue's identity guard, not product
  behaviour), and proceeds where the venue allows the M4.
- c3::tests: the M4's capture passes check_profiles as a second device of
  the venue; the list still refuses it for naming the M3 Max's Metal
  environment.
- device::tests::driver_facts: moltenvk-m3 takes the shared identity's facts;
  the macOS 26.7 identity (APPLE_M3_MAX), measured but with no committed
  capture now, moves to MEASURED_WITHOUT_PROFILE and keeps its coverage
  through a description at that deviceID, graphics cube route included.
- tests::engine_sampler_unk: the graphics cube route's test builds the
  M3 Max under macOS 26.7 the same way.
Docs: API.md and profiles/README.md say what MoltenVK's deviceID is.

Golden hashes and expectation rows that hold moltenvk-m3's translation key
are left for the round's bless. Verified: the capture on the M3 Max
(regen_device_profiles.py --only moltenvk-m3, check_device_profiles.py);
the unit tests above run at a build of this branch before landing.

Record the Metal rows of the M3 Max under macOS 27.0.1:
The reference Mac's Metal answers, apple-m3-max-macos27.0.1 (Apple M3 Max,
40 GPU cores, macOS 27.0.1 26A434, Xcode 27A266a, Metal toolchain 32023.921,
ORACLE_ABI metal-literal-resources-v48): corpus-metal --batch over every
case the 26.7 environment holds, in three maclock holds of about 6.5
minutes, then --batch-install. 2227 cases ran: 2223 qualified, 4 reference
gaps (the simdgroup_matrix 16x16 cases, GPUFamily10, as on 26.7), no
failure. The 26.7 rows stay.

Against the 26.7 rows: no status changed and 8 outputs moved, every one a
cube-gradient case with identical AIR and inputs (a54af728, 315ca8b0,
391fac4d, 6ce71712, ae7aa91b, b3e5b4ef, dd39e2e5, 649c204a). Those 8 ran a
second time identically. Every other case answers as on 26.7.

Expect the M3 Max's and the M4's MoltenVK captures to share a fingerprint:
fingerprints_distinguish_committed_profiles listed only the two Intel
captures as sharing a fingerprint, kept apart for the Apple GPUs by the
graphics cube route measured on the M3 Max's macOS 26.7 deviceID. Under
macOS 27 MoltenVK gives the M3 Max and the M4 one deviceID, and the captures
differ only in allocation sizes, so moltenvk-m3 and moltenvk-m4 now derive
one fingerprint; the test lists the pair.

Found by device::tests at a build of this branch; device:: (104) and
tests::engine_sampler_unk (8) pass with it on the release build.

Make the M3 Max under macOS 27.0.1 the C3 reference Metal environment:
The reference Mac runs macOS 27.0.1 (26A434), and its Metal rows are
committed (apple-m3-max-macos27.0.1). The switch:
- c3-references.json: the primary is apple-m3-max-macos27.0.1 (Apple M3 Max,
  40 cores, 27.0.1, 26A434, Xcode 27A266a, Metal toolchain 32023.921).
- c3-venues.json: the MoltenVK venue's device compares with it.
- runtime_lane::METAL_ENVIRONMENT, the reference and venue tests, and
  scripts/rerecord-venue's default name it.
- The parity lines: record_metal and the sequences' record_metal on the M3
  Max under macOS 27.0.1. The four scenarios recorded 68, 240, 95 and 36
  records; the 64 sequence seeds 8534 records, 0 differences from the model
  and no Metal-side gap (seeds 32, 51 and 62 crashed Metal's driver under
  26.7; they run under 27.0.1). The 26.7 lines and rows stay.

Verified on the M3 Max (release, --cfg m2v_gpu, the validation layer on):
runtime_lane::driver_deviations::cube_gradients_through_an_anisotropic_
sampler_answer_as_metal passes against the 27 rows (MoltenVK answers Metal
27's cube gradients; it failed against the 26.7 rows); parity::tests::
committed_records_are_current and the 14 parity and sequence lanes pass (their
2 recorders are ignored); the
c3::, candidate::platform::profiles::, candidate::engine::guards:: and
parity::tests:: modules pass (98 tests).

Record the M3 Max's MoltenVK venue under macOS 27.0.1 at product 15b6df4e2bd0:
Rows and refusals recorded by one build (executor vulkan-engine-v181, product
15b6df4e2bd0cb440724ffe07ba95f1ccf6d0a5dd7fb5055598e70c877596734, semantics 1698, oracle
metal-literal-resources-v48) at this commit's product, on the Apple M3 Max under macOS 27.0.1 (MoltenVK
1.4.1, deviceID 0x1B000209). They are judged against the apple-m3-max-macos27.0.1 Metal rows and
were installed by scripts/rerecord-commit --no-commit. No later commit changes the product, so every row installed here stays current.

- apple-m3-max-moltenvk (moltenvk): 4389 rows, 56 refusals, over 2223 cases in two legs
- stated: 2168 match, 23 mismatch, 31 refused, 1 failed
- robustness-off: 2175 match, 23 mismatch, 25 refused

Against the macOS 26.7 rows, per case and leg:
- Of the earlier matches, 2965 still match, none mismatches, and 1 failed (below).
- 13 earlier mismatches and 13 earlier refusals now match; 38 mismatches and 42 refusals remain.
- 1374 runs had no 26.7 row: 1352 match, 14 refused, 8 mismatch. The 8 are the robustness-off
  leg of four linked-single radix13 and radix15 zero-write cases whose stated leg was already a
  mismatch, and both legs of the two new cases quad-broadcast-first-in-an-arm-metal-speculates
  and quad-broadcast-first-in-a-fragment-arm-metal-speculates.

The failed run is authored-four-iteration-loop (3cf0a3f024a5), stated leg. Metal's compiler
connection was interrupted while it compiled the compute pipeline (XPC_ERROR_CONNECTION_INTERRUPTED
after MoltenVK's retries), on both the first try and the --retry-failed run. Its robustness-off leg
matches, and under 26.7 it matched in both legs. Its stated slot keeps the 26.7 row, which C3 reads
as stale. Two msl-4-1 cases the venue's selection did not include also keep 26.7 rows that read
stale.

Verified:
- corpus-moltenvk --batch-report reads this_build=yes for the out directory at the recording tree and at the round's
  final tree (the table bless after this commit), which adds only tests, test tables and docs.
- corpus-status --c3 prints the same report at both trees. The MoltenVK slots (stated, then
  robustness-off) read: match 2168 and 2175, reviewed 10 and 10, mismatch 13 and 13, refused 25
  and 19, ray tracing out of scope 6 and 6, stale 3 and 1.

Versions: RUNTIME_VERSION 1205 -> 1211. RUNTIME_VERSION moves: MoltenVK's NotMipmapped anisotropic
footprint is read at level 0, and the macOS 27 Apple identity takes InterlockedPassSplitNoSlower.
crates/metal2vulkan-validation/runtime-sources.sha256 holds
e74792b15fd66114fb4efcc8e281318bfe1e16a3b8532e90d737834ea5a2add3, the hash of this tree's runtime
inputs (runtime-pin.py, which reproduces build.rs's). Version numbers quoted above are the values
the work's branch built with. Each part's Verified lines name the tree it ran at.
2026-10-14 20:17:42 +03:00
Anees Iqbal 3dd70970df Reach the execution status through a binding where the device addresses no buffer
The execution-status work packet: where the device addresses no buffer, the command buffer's status
words are reached through a binding the plan asks for (WriteSource::ExecutionStatus), bound by the
runtime and by both Vulkan executors, documented, with the refusal surface regenerated.

What: a stage that writes the command buffer's ExecutionStatus (an absent argument's read, a
seq_cst fence, an argument buffer's cubic-sampler test) reaches it by device address where the
device addresses buffers (bufferDeviceAddress and shaderInt64), as before, and elsewhere through
a set-0 storage buffer of its own: ResourceSlot { stage, Synthetic(ExecutionStatus), 0 }, a
storage word view the status words are written through. absent::state_status states the form;
the binding counts once in the stage's storage-buffer descriptors, so the per-stage limit check
in lower::select sees it. The ExecutionStatus fact's mechanism is SyntheticBinding on such a
device, PushConstant elsewhere. Profiles that address buffers produce the same modules as before.

Two needs, two answers past a limit (absent::StatusBinding):
- Required (an absent read, a fence): a stage past its storage-buffer limit with the binding is
  refused as DescriptorCount, naming MaxPerStageDescriptorStorageBuffers.
- CubicMark (only the argument samplers' cubic test): absent::finish gives the binding back and
  the stage states no cubic reach, as a fragment stage does. The mark is a may-need: only a cubic
  sampler a command later lists in the argument buffer needs it, and that sampler then meets the
  planner's typed refusal (SamplerBicubicFilter), so nothing is dropped silently. Refusing the
  stage instead would refuse every stage near its limit that samples through an argument
  buffer, cubic sampler or not, all of which compile today.

FunctionConstantArgument and SeqCstFence are now refused only where the stage lacks its stores
and atomics (a vertex or fragment stage without them), no longer for want of buffer addresses.

Why: on vk12-floor, vk12-bare, lunarg-desktop-baseline-2023, roadmap-2022 and swiftshader every
absent read and seq_cst fence was refused (on vk12-floor's census, 22 FunctionConstantArgument
and 9 SeqCstFence rows), though the device can write a storage buffer.

Tests: the absent-read, threadgroup, function-constant, seq_cst and atomics tests compile on
every profile and assert the status's reach per profile (testing::status_reach_on); a floor
interpreter run of device_fence_store binds the status by slot (word 0 is 42);
an_absent_reads_binding_counts_against_the_storage_buffer_limit (vk12-floor at its count less
one: DescriptorCount on MaxPerStageDescriptorStorageBuffers);
the_cubic_tests_binding_gives_way_to_the_storage_buffer_limit (lunarg, the limit lowered step by
step: the binding given back below the kernel's own count, every compile within the limit and
L3-valid); the kernel tests its argument samplers for a cubic filter on every heap profile.

Verified on msi-laptop (Linux, debug, LLVM 21) on this change with the binder, runtime and
validation commits that follow: clippy --workspace --all-targets --all-features -D warnings clean
by default, under --cfg m2v_cpu_icd and under --cfg m2v_gpu; rustdoc -D warnings clean; the
focused tests (engine_absent*, engine_seq_cst, engine_atomics, engine_dispatch, engine_handles,
engine_binder, engine_function_constant*, mechanism) 122/122; the metal2vulkan, air, runtime and
devtools suites 4592/4598, the 6 reds the table moves below.

Moves (blessed elsewhere, on macOS): public_fixture_expectations_engine.tsv, .ll rows, exactly 50
cells, 10 rows x the 5 profiles above, none on a profile that addresses buffers: 42 from
Unsupported{FunctionConstantArgument|SeqCstFence} to ok, and 8 to
NeedsInput{StorageTextureFormat} (absent_texture_reads_zero, fc_kernel_absent_resources,
fc_kernel_absent_sampler, fc_kernel_sampler_select on roadmap-2022 and vk12-bare: the next gate
there, which the refusal hid). golden_hashes.tsv: 104 cells, those 50 plus 54 hash changes, 18
argument-sampler rows (msf_runtime_samplers, tail_argument_samplers,
tail_argument_cube_gradient, unv_runtime_levels) on lunarg-desktop-baseline-2023, roadmap-2022
and swiftshader, which now test the cubic bit; no cell of a profile that addresses buffers.
Expected, not run here (metal-as needs macOS): the .air.ll rows of function_constant_interface
and rfs_absent_reads.

Plan the execution status's binding as WriteSource::ExecutionStatus:
What: a compute or render plan writes a stage's SyntheticBinding::ExecutionStatus binding as the
new WriteSource::ExecutionStatus: the command buffer's ExecutionStatus buffer, the one every
command of it writes, ExecutionStatus::BYTES bound. The bind module docs say how a command
reaches the status on each kind of device. WriteSource is #[non_exhaustive] and not encoded, so
neither the cache codec nor the api_surface table changes.

Why: the previous part binds the status on devices that address no buffer; the planner
refused such a binding as internal ("a compute binding ExecutionStatus").

Tests: a_seq_cst_fence_reaches_the_status_by_binding_or_address_as_the_device_allows runs
dispatch_builtins' device_fence_store through the binder harness on vk12-floor and
lunarg-desktop-baseline-2023 (one ExecutionStatus write, no status push hole) and moltenvk-m3
(the push hole, no write): each of the 24 threads increments StatusWord::SeqCstFences of the one
status (24), and the store after the fence lands (42).

Verified on msi-laptop (Linux, debug, LLVM 21) with the change's other commits: the test passes
among the 122 focused tests; clippy clean in the three cfgs; rustdoc -D warnings clean.

Bind the command buffer's status words where a plan asks for them:
What: the runtime's descriptor writer binds WriteSource::ExecutionStatus to the command buffer's
status words (command_buffer::State::status_words), the buffer whose address it pushes on a device
that addresses buffers, whole. The command buffer reads and reports it on completion as before.

Why: on a device that addresses no buffer a stage with an absent read, a seq_cst fence or an
argument-sampler cubic test now binds the status (the translator commit before); the runtime has
to bind the same buffer it reads.

Verified on msi-laptop (Linux, lavapipe, --cfg m2v_cpu_icd, debug) with the validation commit
that follows: runtime_lane::absent_reads, 3/3, on the device as it is (the status reached by
address), without shaderInt64 and restricted to vk12-floor by VK_LAYER_KHRONOS_profiles (both by
binding): each of rfs_absent_query, rfs_absent_read and rfs_absent_sampler reads zero at flag 1,
its command buffer completes with no error, and its status report states the absent read.

Bind the execution status in the Vulkan executors and prove the bound form on lavapipe:
What: the candidate executors (compute, its replays, render) hand plan_resources the status
buffer they already keep (Guest::status), and plan_resources binds WriteSource::ExecutionStatus
to it, ExecutionStatus::BYTES; device replay has none. runtime_lane::absent_reads checks, for
each of rfs_absent_query, rfs_absent_read and rfs_absent_sampler, the reach the executed pipeline
took (Ran's Reach: a SyntheticBinding::ExecutionStatus binding in its layout or the status
address in its push fields) at both flags, besides reading zero, the command buffer completing
and the report stating the absent read at flag 1. Three tests: the device as it is (address where
it addresses buffers, binding elsewhere), the device without shaderInt64 (binding), and the
device restricted to vk12-floor by VK_LAYER_KHRONOS_profiles (binding; it prints RESTRICTED and
skips visibly without the layer). device::lane_restriction (tests only) builds that restriction
for a committed profile stem, through the same restricting() runtime_restriction now uses.

Why: the translator now binds the status on devices that address no buffer; the executors must
bind it, and the evidence has to show the binding was the path that ran.

Verified on msi-laptop (Linux, lavapipe llvmpipe LLVM 23.1.1, --cfg m2v_cpu_icd, debug,
LP_NUM_THREADS=1): runtime_lane::absent_reads 3/3 with --no-capture: ABSENT-READ-COMPLETED
"reached Address" for the device as it is, "reached Binding" for the other two, RESTRICTED printed
for vk12-floor; clippy --workspace --all-targets --all-features -D warnings clean by default,
under --cfg m2v_cpu_icd and under --cfg m2v_gpu. The whole validation suites run after the
rebase onto the round.

Document the execution status's binding and regenerate the refusal surface:
What: docs/API.md section 5 says how a stage reaches the command buffer's ExecutionStatus (its
device address where the device addresses buffers, else a set-0 storage buffer of its own,
SyntheticBinding::ExecutionStatus, which counts against the stage's storage-buffer limits), and
what happens past a limit: an absent read or a fence is refused as DescriptorCount, and a stage
that would bind it only for the cubic test binds nothing, so the plan refuses a cubic sampler
listed beside it (SamplerBicubicFilter). Section 6's Status bullet says to bind the same status
buffer where a plan asks for WriteSource::ExecutionStatus. reach.tsv's SeqCstFence line now
reads "a seq_cst fence in a vertex or fragment stage without its stores and atomics".
docs/REFUSALS.md is regenerated at 43578ea93: FunctionConstantArgument and SeqCstFence no longer
list devices without buffer device addresses, and lose the sites that refused them; the rest of
the diff is the line moves since the table's last generation (f28f418da).

Verified on msi-laptop: scripts/refusal-surface/refusal_surface.py regenerates the table, then
--check and --missing-reach pass, at 43578ea93 with these docs.

Versions: SEMANTICS_VERSION 1696 -> 1698 and RUNTIME_VERSION 1203 -> 1204. SEMANTICS_VERSION moves:
absent reads and seq_cst fences compile where they were refused, and argument-sampler stages test
the cubic bit through the status. RUNTIME_VERSION moves: the status's binding is planned and bound.
ARTIFACT_FORMAT_VERSION stays: no encoded type or codec changed (WriteSource is not encoded;
SyntheticBinding::ExecutionStatus and Mechanism::SyntheticBinding already existed).
ENGINE_EXECUTOR_ABI stays: the executors bind WriteSource::ExecutionStatus only where a plan asks
for it, and no plan an earlier row recorded asks for it, so running those rows is unchanged.
crates/metal2vulkan-validation/runtime-sources.sha256 holds
d92b3692f9ec6dd09aa276901b3e5e2ca89520a9fe474835a57c7a22aeb4b85e, the hash of this tree's runtime
inputs (runtime-pin.py, which reproduces build.rs's). Version numbers quoted above are the values
the work's branch built with. Each part's Verified lines name the tree it ran at.
2026-10-14 20:17:39 +03:00
Anees Iqbal 4079f17441 Fix the translator review's findings: moved color writes, cubic refusals, bicubic inferences
The translator review's work packet: a moved color write that stores nothing selects no depth or
stencil tests (with the format components it needs generated), a cubic sampler word Metal's bicubic
filter is not measured under is refused when planning, and the extended-range bicubic reading lists
its inferences.

Generate each Vulkan format's color components into its texel block:
vk::FormatBlock gains color_components: the R, G, B and A components the registry's <format>
names for the format (empty for a depth or stencil format), which a color write mask's bits name.
Vulkan writes nothing to a component the mask leaves out or the format lacks, so a plain color
attachment's write stores something exactly where its mask intersects these components; the
binder needs that to decide whether a moved writer stores anything (next part). The data comes
from the pinned registry (Vulkan-Headers vulkan-sdk-1.4.341.0) through
scripts/regen-vk-types: format_blocks reads each format's component names, render_format_blocks
writes them as `components [R G B A]`, and vk_format_blocks! builds the flags in const context.
No hand table.

Verified: the generator's unit tests pass (python3 -m unittest discover -s scripts/regen-vk-types,
9 tests, the FormatBlock expectations updated for the new column); regen_vk_types.py --check
against the pinned registry (SHA-256 verified by the script) reports generated.rs current; the
crate builds and its suites run on homelab-gem10 (with the next parts).

Select no depth or stencil tests for a moved color write that stores nothing:
What: the interlocked storage form's plan counted a moved color's write as a
store under any write mask, and the binder's moved-writer fallback
(RuntimeFact::MovableStorageWrites) ignored the pipeline's write mask. A moved
writer whose mask covers none of its attachment's channels (a depth prepass, a
stencil mask with discard) therefore had depth and stencil tests chosen for a
write that stores nothing: a slower variant, or a refusal under
FragmentTests::Any, a non-D32 depth format or a stencil-only test, and the
runtime then split the pass or ended the shadow. A declared but unused
[[color(n)]] input that is written reached the same path.

Why and how: whether a write stores is decided from the pipeline's state, the
same rule StorageView::stores_nothing applies to the storage view. fetch.rs
counts a write as storing only when its view stores something (the moved
override is gone), and bind/graphics.rs moves a color only when its ordinary
attachment state's write mask meets the format's color components
(vk::FormatBlock::color_components, generated in the previous part). The
MovableStorageWrites and module docs say so, including that a moved plain
writer takes its tests from MovableStorageWrites.

New fixture engine/smw_unread (our MSL, compiled by scripts/regen-air-fixtures
with Metal 32023.921, SDK 27.0) declares a color input it never reads; its
expectations rows and air_input printout are added.

SEMANTICS_VERSION 1694: binding-plan facts and variant choices change for
mask-none moved writers. RUNTIME_VERSION 1190: a run of such a pipeline no
longer selects tests, splits the pass or ends the shadow.

Verified:
- New CPU tests in tests::engine_moved_writers, run before the fix (debug,
  homelab-gem10): a_moved_writer_that_stores_nothing_selects_no_tests failed,
  864 states on 12 profiles: 96 refused (Any), 384 selected tests, 480 asked
  for a variant that states a store before its tests;
  an_unread_color_input_that_stores_nothing_selects_no_tests failed, 72 draws:
  12 stated a store before the tests, 48 asked for a variant, 12 refused (Any).
  Both pass with the fix, and the existing moved-writer test still passes.
- runtime_lane::moved_writers gains a write-mask-none case. Release,
  --cfg m2v_gpu, on AMD Radeon 780M (RADV PHOENIX, Mesa 26.2.4) at the tree
  rebased on fleet/round: all 9 cases keep Metal's answer in the pixel
  interlock with the shadow held; the masked case counted 12 runs.
- Golden hashes are left stale for the round's single bless.
No hot-path loop is added (one write-mask check per color per plan), so no
release translation timing was taken.

Refuse a cubic sampler word Metal's bicubic filter is not measured under when planning:
What: a runtime sampler whose min or mag filter is Cubic, bound at an
extended-range slot, makes the plan name the cubic-sampler variant
(VariantKey::cubic_samplers) for any word. A word with a mip filter,
anisotropy or another reduction (or an unnamed border color, or a
MirrorClampToEdge axis) is one the variant's function always refuses
(lower::sampler::bicubic's cubic_state and check), so the refusal arrived only
after a variant compile, and since the runtime keeps only compiled variants,
every draw under that word translated the variant again.

Why and how: metal::bicubic::runtime_cubic_measured states the words Metal's
bicubic filter is measured under, whatever the function samples: no mip
filter, isotropic, the weighted-average reduction, a border color Metal names,
and address modes the bicubic readings cover. bind::plan::slots::cubic_variant
now refuses any other bound cubic word with
NotImplemented(SamplerBicubicFilter), the class the variant's compile gives,
so graphics and compute plans refuse the draw before any variant.
cubic_state applies the same rule first, so the binder and the lowering
cannot drift; the state it builds is therefore always mip-filter none,
isotropic, weighted average.

SEMANTICS_VERSION 1695: a plan for such a word is now a refusal instead of a
variant request. RUNTIME_VERSION 1191: a draw under such a word is refused at
planning, with no variant compile.

Verified (debug, homelab-gem10):
- New test tests::engine_extended_range::bicubic::
  an_unmeasured_cubic_sampler_is_refused_before_any_variant (mip filter
  Nearest, max anisotropy 4, reduction Minimum, at BGRA10_XR,
  RGB10A8_2P_XR10 and RGBA8Unorm, on every committed profile) failed before
  the fix: the plan named the variant with cubic_samplers {sampler 0: 8}. It
  passes with the fix; a device without sampler anisotropy refuses the
  anisotropic word earlier with SamplerAnisotropy, which the test counts and
  requires to leave other refusals.
- The extended-range bicubic tests and runtime_lane::extended_range_bicubic
  (release, --cfg m2v_gpu, AMD Radeon 780M, RADV PHOENIX, Mesa 26.2.4) pass.
- Golden hashes are left stale for the round's single bless.
No hot-path loop is added (one predicate per bound cubic sampler per plan),
so no release translation timing was taken.

List the inferences in the extended-range formats' bicubic reading:
What: lower/sampler/extended.rs states Metal's bicubic reading on the
extended-range formats as one paragraph, without saying which parts no reading
of those formats covers. bicubic.rs keeps such an "except inferences" list for
its own formats; this adds the same list here: a runtime Cubic sampler with a
non-Cubic other filter; a runtime sampler under another address mode, a border
color or pixel coordinates; a half result outside clamp to edge; explicit
level, bias, gradient and fragment implicit-level samples; and textures of more
than one level. Each is the other formats' reading carried to these formats'
decoded taps.

Why: a reviewer of the extended-range bicubic work asked for the inferences to
be named where a reader of the module meets them. No Metal measurement was
taken for this change.

Verified: documentation only (a module comment); cargo fmt --all is clean and
the translator suite passes at the branch tip (see the branch's last commit).

Versions: SEMANTICS_VERSION 1694 -> 1695 and RUNTIME_VERSION 1200 -> 1202. SEMANTICS_VERSION and
RUNTIME_VERSION move: translated modules and their planned refusals change under unchanged keys.
crates/metal2vulkan-validation/runtime-sources.sha256 holds
a090937f1eca50599031bb56159f5d0ece5b30d133251621f54fc645dc4f167a, the hash of this tree's runtime
inputs (runtime-pin.py, which reproduces build.rs's). Version numbers quoted above are the values
the work's branch built with. Each part's Verified lines name the tree it ran at.
2026-10-14 20:17:37 +03:00
Anees Iqbal 0307fb8c9d Run every Linux CI step in the gate's container, and fix what the gate caught
The Linux gate's work packet: CI's Linux steps now run in the gate's own container, and the failures
that run found are fixed: depth and stencil formats over a DRM_FORMAT_MOD_LINEAR image, test IR that
LLVM 21 rejects, and a frame-cost check that allocated.

Run every Linux step of ci.yml in the Linux gate's container:
What: scripts/linux-gate-ci gains the three steps ci.yml's Linux job runs and it did not:
"Clippy under each feature alone" (metal2vulkan with no feature and with serde, ash and cli each
alone; metal2vulkan-runtime; metal2vulkan-air with no feature and with serde), "Build the new
API's consumer reference" (scripts/api-docs) and "Package the published crates". Its "Test
metal2vulkan" step now tests the packages ci.yml's does (metal2vulkan, -air, -runtime and
-devtools), where it tested metal2vulkan alone. The steps run in ci.yml's order, each with the
container's build share.

Why: the script's header says every Linux run: step of ci.yml has one step here, and
docs/VALIDATION.md presents the container as ci.yml's Linux job; a change that broke only a
feature-alone build, the reference, packaging, or the AIR front end's, runtime's or dev tools'
tests passed the container and failed CI.

Verified: bash -n; the steps compared one by one with ci.yml at fd22785008. A full container run
of the script follows on msi-laptop.

Make no DRM_FORMAT_MOD_LINEAR image of a depth or stencil format:
What: Device::modifier_image_checks, which every DRM_FORMAT_MOD_LINEAR image the runtime makes
passes (host_pitched_image's at Metal's row pitch over host pages since 1cf79a9617, and
dma_buf_image's and dma_buf_natural_layout's over dma-buf pages since 11715e2a3f), refuses a
format with a depth or stencil component (FormatBlock::depth / ::stencil of the image's format).
Such a texture takes the shadow (`shadowed-texture`, naming why), as it already did on every driver
that lists no linear modifier for the format. RUNTIME_VERSION 1187; the runtime-sources pin moves
with it. docs/API.md (the dma-buf paragraph and the shadowed-texture notice), docs/HOWTO.md and
Degradation::ShadowedTexture's rustdoc say so.

Why: the runtime asks the layout of every such image of memory plane 0, and Vulkan has no valid
such query of a depth or stencil format. Vulkan 1.4.357's validusage.json: of a DRM format
modifier's tiling the aspect "must be VK_IMAGE_ASPECT_MEMORY_PLANE_i_BIT_EXT"
(VUID-vkGetImageSubresourceLayout-tiling-09433), of a format with a depth component it "must
contain VK_IMAGE_ASPECT_DEPTH_BIT" (-format-04462; stencil, -format-04463), and it "must only have
a single bit set" (-aspectMask-00997). lavapipe (Mesa 26.2.4) lists the linear modifier for
D16_UNORM, D32_SFLOAT and D32_SFLOAT_S8_UINT, so since 1cf79a9617 a depth or stencil texture over a
no-copy buffer's surface plane was made at Metal's row pitch and the validation layer reported
-format-04462/-04463, failing CI's CPU-ICD step:
runtime_lane::buffer_texture_blits::a_planar_surface_s_depth_or_stencil_texture_reads_and_stores_the_plane
and ..._s_passes_write_metal_s_elements_alone. The dma-buf paths had the same gap, reached only
where a driver refuses the host pointer and lists the modifier for such a format.

Test: runtime_lane::buffer_texture_blits::no_depth_or_stencil_texture_over_a_buffer_asks_for_a_modifier_image
makes each depth or stencil format's texture over a surface plane (ordinary and no-copy buffers,
read and render usage, rows 64 and 256 bytes apart) and checks that WorkCounts'
pitched_host_images, pitched_host_image_refusals and dma_buf_images do not move (each layout query
follows such an image), and that the validation layer reports nothing.

Verified on msi-laptop, lavapipe (llvmpipe, LLVM 23.1.1, 256 bits; Mesa 26.2.4, validation layer
1.4.357), --cfg m2v_cpu_icd, LP_NUM_THREADS=1, VK_DRIVER_FILES=lvp_icd.json: without the
modifier_image_checks change the new test fails ("NoCopy Depth16Unorm MTLTextureUsageShaderRead,
rows 64 bytes apart": (1, 0, 0) against (0, 0, 0)) beside the old one; with it, every test of
runtime_lane::{buffer_texture_blits, no_copy_textures, dma_buf_imports, surface_texture_costs,
pitched_surfaces} passes (47 of 49 selected) except
pitched_surfaces::a_half_float_tile_reads_writes_and_renders_as_metal, the known-open lavapipe
padding-bytes failure 1cf79a9617 names (fleet/fix-pitched owns it), and the runtime-sources pin,
which printed the hash written here.

Write the handle tests' sample coordinates as floats LLVM 21 reads:
What: tests::engine_handles' sampled-handle kernels (the 2D and 3D sample calls of
heap_gathers_and_nearest_samples_fetch_by_the_handle_s_class, heap_half_texels_convert_by_the_handle_s_class
and heap_linear_samples_are_emulated_by_the_handle_s_class) state their coordinates as the hex
of the floats they meant, 0x3FD3333340000000, 0x3FE3333340000000 and 0x3FDCCCCCC0000000, in place
of the decimals 0.3, 0.6 and 0.45.

Why: LLVM 21's llvm-as, which CI's Linux job (Ubuntu 26.04) assembles with, refuses a float
decimal that is not exactly a float ("floating point constant invalid for type"), so the three
tests failed there; LLVM 23 rounds it to the nearest float, which is the value the hex states
(checked on msi-laptop: `ret float 0.3` under llvm-as 23 and `ret float 0x3FD3333340000000` under
llvm-as 21 disassemble alike), so the modules are unchanged where they assembled before. These
were the only float or half decimals in crates/ that a float does not hold exactly (a scan of
every .rs and .ll).

Verified on msi-laptop with /opt/llvm-21.1.8 first on PATH and
METAL2VULKAN_TEST_REQUIRE_PINNED_LLVM=1, as CI runs: the three tests failed at fd22785008 and pass
here.

Check a stage table brought in place slot by slot, allocating nothing:
What: the debug builds' check in ArgumentTable::refresh_reading, that the table it brought in
place is the table the stage's function reads whole, is ArgumentTable::check_reading. It compares
slot by slot, with no table read whole made and nothing printed unless a slot differs: every
kept buffer, texture and sampler slot against the binding stage_table_reading would derive for it
(and the sampler as the address maps bind it), every slot that reading has against the kept
table, and the kept threadgroup lengths and acceleration structures against none. A sampler is
compared as it prints (same_as_printed: every field by `==`, the LOD clamps as bits or both NaN,
since `{:?}` tells -0.0 from 0.0 and prints every NaN alike). A slot that differs is named in the
panic. Builds without debug assertions compile none of it: their behaviour is unchanged, so
RUNTIME_VERSION stays; the runtime-sources pin moves.

Why: the check read the whole table again and compared the two as format!("{:?}") strings at
every draw, so a debug build's draw made several times the allocations of a release build's, and
CI's CPU-ICD step (a debug build) failed
runtime_lane::frame_costs::a_frame_s_draws_and_pass_ends_allocate_within_their_bounds at every
sha since its bound came: 86.60 allocations a draw on lavapipe against the bound's 27, where the
same build with CARGO_PROFILE_DEV_DEBUG_ASSERTIONS=false makes 24.62. With this, a debug build's
draw makes 35.93; the rest of the difference is LiveBind::shape's checks, which build whole bind
shapes and stay exact (the next part bounds a debug draw with them).

Tests: tests::argument_table::samplers_compare_as_they_print holds same_as_printed equal to
comparing the printed forms (opposite zero signs, NaNs of other sign and payload, a NaN against a
number, f32::MAX against infinity, and other fields); the_check_compares_every_field fails when
StageTable, BoundSampler or SamplerDescriptor gains a field, until the check compares it.

Verified on msi-laptop (Linux, debug, LLVM 21): clippy --workspace --all-targets --all-features
-D warnings clean; the two unit tests pass; on lavapipe (--cfg m2v_cpu_icd), the frame_costs
draws count 35.93 (86.60 before) and runtime_lane::{render_state, function_tables,
buffer_texture_blits}, whose draws run the check, pass (32 tests); the runtime-sources pin test
passes with the hash written here.

Bound a debug build's draw allocations by what its shape checks add:
What: runtime_lane::frame_costs::a_frame_s_draws_and_pass_ends_allocate_within_their_bounds holds
a build with debug assertions' draws to DRAW_ALLOCATIONS_DEBUG (38) and other builds' to
DRAW_ALLOCATIONS (27, unchanged). The new bound states what it holds: the draw path's
allocations and those of LiveBind::shape's two debug_assert!s, which build the state's whole bind
shape at each draw to compare the kept or the found one with it; measured 35.93 on lavapipe
(llvmpipe, LLVM 23.1.1, Mesa 26.2.4), where a build without debug assertions makes 24.62. The pass
end, pass open and commit bounds hold unchanged in both builds.

Why: CI's tests are debug builds, and its CPU-ICD step failed this test at every sha since the
bound came (86.60 allocations a draw; 35.93 since the previous part made the stage table's check
allocation-free). The shape checks stay exact: making them allocation-free would compare through
BindState::has_shape, the function the found-shape check exists to cross-check, and a reusable
shape would need new public API in the published crate. With a debug bound the CPU-ICD step keeps
holding the draw path in CI: a new allocation in it moves both counts alike, and the bound keeps
the release bound's slack (about 2.4 allocations).

Verified on msi-laptop, lavapipe, --cfg m2v_cpu_icd, debug, LP_NUM_THREADS=1, twice: the four
a_frame_s_ bound tests pass (draws 35.93 of 38, pass ends 38.63 of 40, opens 13.00 of 14, commits
5.00 of 6 and 17.08 / 17.24 of 20 on the other threads); the same tests with
CARGO_PROFILE_DEV_DEBUG_ASSERTIONS=false at fd22785008 gave 24.62, 38.63, 13.00 and 4.99; clippy
--workspace --all-targets --all-features under --cfg m2v_gpu is clean.

Versions: RUNTIME_VERSION 1186 -> 1195. RUNTIME_VERSION moves: a depth or stencil texture over a
buffer no longer gets a linear image. crates/metal2vulkan-validation/runtime-sources.sha256 holds
4a161b14058fa3e4c4b039726845c4bb221965a409dae3153e6232d213f22330, the hash of this tree's runtime
inputs (runtime-pin.py, which reproduces build.rs's). Version numbers quoted above are the values
the work's branch built with. Each part's Verified lines name the tree it ran at.
2026-10-14 20:17:35 +03:00
Anees Iqbal 965eb0b538 Wake the scheduler thread at once for a check a commit's pass finds
A commit whose pass finds a submission check or a host step for the scheduler thread now wakes that
thread at once, instead of after its own later passes and submission handlers. The scheduler thread
runs one check or host step at a time, taking in waiting commits between them, and a commit handed
to another thread waits at most for that thread's current pass and its handlers. The commit-latency
lane measures a checked commit's wait for its submission under a consumer-like load (400 host
imports, checked command buffers from one and three threads, event waits).

Gain: the consumer's guest A/B on a Radeon 780M and an RX 7900 XTX (RADV): window drags +13-20%
frames/s, and the commit's off-CPU wait from 9.3 to 0 ms a frame. The new test's hold fell from
71-75 ms (RADV, ANV) to prompt.

Verified on the original branch: the scheduler lanes, 62 of 62 on RADV and ANV, and the runtime
crate's tests. This squashed commit was not re-tested on its own.
2026-10-14 12:15:42 +03:00
Anees Iqbal 8963e1871b Submit a commit's work without waiting for the scheduler's lock
A commit no longer blocks on the scheduler's lock while another thread's pass holds it across its
vkQueueSubmit calls: it leaves its batches in a commit inbox that the pass under way takes in, in
commit order. A batch's first work rides in the batch's own vkQueueSubmit, a batch with nothing to
end submits no command buffer, and the runtime counts its queue submissions and live memory blocks
per commit.

Gain: on an Intel Iris Xe host (ANV on i915), the consumer's guest A/B measured a Finder window drag
at 22.1 -> 34.4 frames/s and Safari at 39.1 -> 42.7 frames/s.

Verified on the original branch: the runtime lanes on ANV and lavapipe. This squashed commit was not
re-tested on its own.
2026-10-14 12:15:22 +03:00
Anees Iqbal ecb80e019d Place heap textures needing up to 256 KiB alignment instead of refusing them
A heap's memory started at a multiple of 64 KiB of the runtime's block, and a
heap texture whose image needed a coarser alignment was refused
NotImplemented(HeapTextureAlignment), by heapTextureSizeAndAlign and
newTexture alike. On an RX 7900 XTX that refused nearly every depth texture a
program puts in a heap: four runtime-lane tests failed there on every run,
each with `alignment: 131072`, while the Radeon 780M in the same machine,
under the same driver, passed them.

Measured with a raw Vulkan probe on homelab-um780 (vkGetImageMemoryRequirements,
optimal tiling, attachment|sampled|transfer usage, 11 formats, sides 1 to
16384, 1/2/4/8 samples, one level or full mips), RADV under Mesa 26.0.8:
- RX 7900 XTX: 128 KiB for D16, D32F and D32FS8 images of 8 x 8 texels or
  more; 256 KiB for multisample depth, stencil and color images from about
  128 x 128 texels; single-sample color, storage and BC1 images at most
  64 KiB. Nothing past 256 KiB.
- Radeon 780M: at most 64 KiB for every shape.

The base is now 256 KiB (HEAP_BASE_ALIGNMENT), the largest alignment measured.
The check moves into check_heap_base, which a GPU-free test can reach, and the
typed refusal stays for anything past the base. A heap over host pages
already starts at offset 0 of its own import, which meets any alignment.

Whole units of the base would have pushed the largest heaps past one
allocation: heap_size admits a heap up to maxMemoryAllocationSize in whole
16 KiB, and where that limit is no whole number of 256 KiB the largest heaps
asked more than the device allocates. RADV (4 GiB less 4 bytes) asked a 4 GiB
allocation for every heap from 4 GiB less 240 KiB, with a block's buffer of
addresses past maxBufferSize; MoltenVK (41,747,087,360 on the M3 Max,
9,534,832,640 on the M4, multiples of 128 KiB but not 256 KiB) would have
asked 128 KiB past the limit for its largest 128 KiB of sizes. So a buffer
past half a pooled block (32 MiB) now keeps its own size (buffer.rs's
`placed`). Such a buffer always takes a block of its own, where nothing
follows it; whole units exist only so the next placement in a pooled block
starts where the last ends. Buffers up to half a block still take whole
units, and half a block is a whole number of 256 KiB.

Cost: a heap of up to 32 MiB now starts at a multiple of 256 KiB of its pooled
block and takes whole 256 KiB units of it, up from 64 KiB units, so a small
heap can hold up to 240 KiB more of its block, on every device. A heap or
buffer past 32 MiB takes exactly its size, no longer rounded up. Programs see
no change where their images need 64 KiB or less. On the 7900 XTX the shapes
past 64 KiB now answer 128 or 256 KiB, are placed, and announce
heap-texture-larger-than-metal.

RUNTIME_VERSION 1179 -> 1181: heapTextureSizeAndAlign and newTexture answer
and refuse differently on such devices, heap buffers lie at other offsets in
the runtime's blocks, and every buffer and heap past half a pooled block
allocates its own size (WorkCounts::device_memory_allocated answers it).
runtime-sources.sha256 is re-pinned. docs/REFUSALS.md is regenerated, and the
reach mark's text says 256 KiB.

Tests:
- tests::heap::every_image_alignment_measured_fits_a_heap_s_base (GPU-free):
  the measured alignments fit the base, and one past it is refused typed.
  With the constant back at 64 KiB it fails (Err(NotImplemented(
  HeapTextureAlignment { alignment: 131072 }))).
- tests::heap::the_largest_heap_asks_one_allocation_of_its_device (GPU-free):
  every committed profile's largest heap asks at most one allocation and one
  buffer. With `placed` rounding every size it fails on amd-780m-radv
  (4,294,950,912 bytes asking 4294967296).
- runtime_lane::heaps::the_largest_heap_lies_in_one_allocation: where the
  largest heap is at most 4 GiB, making it grows the runtime's memory by at
  least its size and at most one allocation, with no validation message.
  Without the size fix it failed on the 7900 XTX ("the largest heap,
  4294950912 bytes, took 4294967296 bytes, past one allocation of
  4294967292"). It reserves the memory without touching it: on Iris Xe a 4 GiB
  heap took 0.04 s and a 53 MiB peak RSS; on lavapipe (debug) a 2 GiB heap
  took 127 MiB.

Verified (release, --cfg m2v_gpu, one GPU pinned):
- The heap set (`test(/heap/) | test(/rebind/) | test(/no_copy/) |
  test(/alias/)`, metal2vulkan-validation and metal2vulkan-runtime), before ->
  after: RX 7900 XTX (RADV, Mesa 26.0.8) 176/180 -> 183/183 (the four
  refusals pass); Radeon 780M (same host and Mesa), RTX 3090 and RTX 5080
  Laptop (NVIDIA 615.71.09) and Iris Xe RPL-P (ANV, Mesa 26.2.4) 180/180 ->
  183/183; lavapipe (--cfg m2v_cpu_icd, debug) 134/134. No kernel GPU
  messages.
- Apple M3 Max (MoltenVK 1.4.1): the heap set plus `test(/buffer/)`. Every
  failure fails identically at the base: heap_textures_answer_and_place_as_
  metal_s_do, argument_buffer_intersection_table_is_encoded_at_reflected_field,
  frees_while_the_gpu_is_busy_fail_no_command_buffer and
  every_case_of_buffers_alone_runs_from_a_command_as_its_dispatch_2.
- Full GPU suites: RX 7900 XTX 3528/3531 and RTX 3090 3526/3531. Every
  failure fails at the base or passes on rerun: on the XTX,
  float_denormals_read_as_metal_reads_them and the two generated_executions
  tests, which fail on the 780M too; on the 3090,
  render_commands_and_render_states_run_as_the_executor_compiles_them and
  the_runtime_probe_measures_the_test_device_consistently fail at the base,
  and three timing tests pass on rerun.
- On the 7900 XTX, the heap lane's output shows answers and placements at
  0x20000 and 0x40000 alignment and no HeapTextureAlignment.
- The runtime crate's GPU-free suite: 856/856. Clippy (workspace, all
  targets, all features, and --cfg m2v_gpu) and rustdoc are clean,
  refusal_surface.py --check passes, and the runtime-sources guard passes.
2026-10-12 20:57:59 +03:00
Anees Iqbal 13b279df1b Squash 11203 commits of translator, runtime, and validation work
Rolls up everything since 43c46ac8 into a single commit. Its tree is
identical to the tree of private master at
b3c77f2d2b20a432be10591a2129547c10b1c24b.

- A Cargo workspace of five crates under crates/: metal2vulkan (the
  translator and the metal2vulkan command), metal2vulkan-runtime (the
  Metal API on Vulkan), metal2vulkan-air (the AIR front end),
  metal2vulkan-validation and metal2vulkan-devtools.
- Dual license: GPL-2.0-or-later OR LGPL-3.0-or-later.
- docs/: API, architecture, fast paths, how-to, Metal coverage,
  refusals, runtime porting and validation guides.

Private-Commit: b3c77f2d2b20a432be10591a2129547c10b1c24b
2026-10-11 20:09:13 +03:00
Anees Iqbal 08970cacd2 Consolidate translation, linkage, and validation work
Squash 147 commits (2026-08-20 through 2026-08-31) into one change on top
of the exact-kernel-grid work. Covers native lowering and pointer/layout
construction, AIR intrinsic and funnel-shift coverage, BDA address
preservation across aggregate calls, CFG structurization, function-constant
and visible-function specialization, the 30-second translation ceiling, the
authored-case corpus and linkage validation suite, and refreshed byte-exact
MoltenVK evidence.

The kernel-grid lowering in this tree supersedes the 324-line variant in
the parent commit; that file is reduced to its current 139-line form here.

Resulting tree is identical to 7174c7b. Prior history remains reachable at
tag pre-squash-backup and branch backup/pre-squash-7174c7b.

Claude-Session: https://claude.ai/code/session_01D1u4vU7Mr5QNWrnnRHC8iS
2026-08-31 09:03:42 +03:00
Anees Iqbal 8b78eaca3b Expand macOS 26 AIR translation coverage
Overhaul the validation workflow around sharded authored cases, dependency-exact observations, incremental indexed corpus audits, bounded parallel translation, and native Metal/Vulkan comparison.\n\nExpand native AIR lowering, reflection, linked-function specialization, resource and stage-interface support, and structural CFG/pointer repair across the harvested macOS 26 corpus. Add exact intrinsic inventory, distributed 16x16x16 matrix lowering, explicit opaque tensor linkage, and regression coverage for the newly supported feature classes.\n\nThe final corpus verification accounts for all 88,819 indexed AIR modules under the current product fingerprint: 65,355 translate and validate directly, 23,464 require exact authored linkage, and zero fail or remain unresolved.
2026-08-13 21:46:27 +02:00
Anees Iqbal 6a14365536 Rework validation corpus workflow around ledgers
Replace the old drift/harvest scripts and generated corpus-test path with
Rust validation binaries that use JSONL ledgers as the durable corpus and
execution record.

- Move translate banking from validation/corpus/drift-ledger.jsonl to
  validation/corpus/metal2vulkan-ledger.jsonl, and seed tracked Metal and
  MoltenVK execution ledgers with hash-identified rows and output_b64
  payloads.
- Add corpus-harvest, corpus-mint, corpus-remint, corpus-why, corpus-triage,
  and corpus-run-{metal,vulkan,moltenvk} binaries for shard harvesting,
  additive/remint translate banking, single-case fallback inspection,
  status triage, and backend execution.
- Rework corpus runners to infer execution plans from shard-backed AIR at run
  time, merge per-run deltas into sorted ledgers, support focused reruns, and
  keep Metal oracle coverage available for translate FALLBACK rows while SPIR-V
  backends remain gated on translate status=ok.
- Bound control-parameter seeding and add loop-budget instrumentation,
  quarantine handling, subprocess timeouts, Ctrl-C worker cleanup, slow-case
  logging, panic backtraces, and MoltenVK/Homebrew Vulkan discovery for safer
  offline execution.
- Consolidate validation helpers for AIR stage/entry parsing, corpus source and
  shard resolution, hashing, JSONL I/O, texture shape policy, translate-ledger
  rows, runner status rows, and triage summaries.
- Remove obsolete Python drift/harvest scripts, generated corpus stubs,
  broken/tolerances sidecars, TOOLCHAIN.lock, and unused validation harness
  modules from the repo surface.
- Update validation, corpus, A/B, architecture, contributing, and agent docs,
  plus gitignore rules, to describe the shard-backed ledger workflow and its
  expected generated artifacts.
2026-07-23 20:01:24 +03:00
Anees Iqbal 3007485352 🆕 Open Source metal2vulkan 2026-07-22 13:15:24 +03:00