Commit Graph
44 Commits
Author SHA1 Message Date
Anees Iqbal e323ba2f72 Run tile threadgroups of every even shape in Metal's thread layout
The steps this packet landed as, in order:
- Read the coverage after the early depth test for [[sample_mask, post_depth_coverage]]
- Copy a stencil view's texels by the CPU as plain Metal does
- Give multisampled fragment imageblocks a block per sample, and test before writes a test may drop

Content: the tree of `development` at becd3e74a9, unchanged.
2026-10-26 13:19:05 +02:00
Anees Iqbal 1400c9049f Resolve a NaN clear as Metal does in a pass whose draw calls draw nothing
The steps this packet landed as, in order:
- Leave a resolve texture untouched where Metal's tile is not stored into its format
- Take setDepthCleared, setStencilCleared and setVertexAmplificationMode as Metal does
- Run the private alpha test in the fragment function as Metal tests it
- Clamp depth comparison references as Metal's fragmentDepthCompareClampMask says
- Take vertexAmplificationMode and explicitVisibilityGroupID as Metal does
- Record no restricted depth range where the driver keeps depth values outside [0, 1]
- Draw Metal's private logic operation: copy and no-op everywhere, the rest through logicOp
- Leave the default alpha test and clamp mask out of the inputs encoding test's derived Debug
- Clamp the reference of a depth comparison the shader makes under the clamp mask
- Key each Vulkan logic operation's pipeline apart
- Refuse a multisampled extended-range resolve naming its format and Metal's rule

Content: the tree of `development` at 0231dbbd54, unchanged.
2026-10-26 13:19:05 +02:00
Anees Iqbal 123a9919fc List argument samplers at each batch's submission, and retire resource-id-takeover
The steps this packet landed as, in order:
- Refuse the private option bit where Metal ends the process, and take it where Metal ignores it
- Drop the GPU's writes to no-copy memory of the private option bit on macOS
- Let a host step ask the driver for a heap set's layout support
- Run a command that leaves a live sampler state out, announced, instead of failing it
- Record what a read-only view of no-copy pages costs

Content: the tree of `development` at abc094a6c3, unchanged.
2026-10-26 13:19:05 +02:00
Anees Iqbal 766ba91b30 Keep a heap's two-plane array and mipmapped texture in the heap's bytes
The steps this packet landed as, in order:
- Give the 3D two-plane heap texture test a Private descriptor
- Lay a heap's depth and stencil textures out in Metal's tiles on MoltenVK
- Answer Metal's heap size for PVRTC textures and tile them under 27.0.1
- Lay a heap's Depth32Float_Stencil8 texture out in Metal's two tiled planes
- Make a host heap's uncompressed multisample texture in memory of its own
- List the two-plane array fixture in the engine inventory, with its printout
- Let the no-copy heap lane find a compressed texture's texels in Metal's tiles
- Name the depth heap lane's aspect list type for clippy
- Announce a device heap's textures whose bytes are not Metal's layout
- Lay a heap's X32_Stencil8 texture out in a Stencil8 texture's tiles

Content: the tree of `development` at b3c694ad82, unchanged.
2026-10-26 13:19:05 +02:00
Anees Iqbal ee21fca2f4 Write Metal's bytes in texture fills and two-plane buffer blits
The steps this packet landed as, in order:
- Hold RGB10A2Unorm_sRGB textures with Metal's conversions
- Name the runtime's gap, not a missing feature, for fetch on interlock devices
- Take clippy's forms in the RGB10A2Unorm_sRGB tests
- Fill multisample textures' samples as Metal's private fills write them
- Check fill units only for the formats the crate holds textures of
- Hold a two-plane texture's bytes between rows, which Metal's buffer blits read back
- Fill texture buffers as Metal does: bytes of the buffer, the pattern streamed
- Drop the multisample fill from apple_only's refusals, which fills it
- Meet the rows of a two-plane buffer blit into the texture in Metal's order
- Announce narrow two-plane row meetings across groups of 32 rows as one of Metal's

Content: the tree of `development` at 9d3447dec9, unchanged.
2026-10-26 13:19:05 +02:00
Anees Iqbal 9516e41497 Say what an indirect command holds of the pipeline state set on it
The steps this packet landed as, in order:
- Time indirect commands' CPU setters and getters in host_ab
- Read and write one field of an indirect command's record
- Set and read an indirect command's fields one at a time
- Call an indirect execution's check where it may see something, and run the CPU's later writes
- Load vkGetDescriptorSetLayoutSupport inside the exit guard's sections
- Hand out indirect command buffer IDs to 2^31 - 1 and place every one's records, as an M3 Max does
- Refuse an indirect command buffer reservation Metal hangs at as such
- Place an indirect command buffer's records at any length, found only at their start
- Leave a resource ID pool made after a reservation of 0 alone, as Metal does
- Ignore a late reservation call before looking at what it holds, as Metal does
- Expect the merged-draw tests' pipeline makings' notices on every device
- Keep an indirect compute command's threadgroup lengths where Metal keeps them
- Take the pieces of the ICB identifier range Metal's encoders take
- Answer a GPU-written command's state identifier as the state its ID named then
- Run a GPU-written record's released state as Metal does, from the buffer's kept programs
- State and test the bound on the programs a GPU-writable buffer keeps
- Record the earlier-window record of a re-held ID as a known gap

Content: the tree of `development` at 7d31ebb207, unchanged.
2026-10-26 13:19:05 +02:00
Anees Iqbal c83dcdd384 Give the predication step ops that drop, hold and resume a range, and check a unit's end
The steps this packet landed as, in order:
- Answer command predication as Metal does on an M3 Max under macOS 27.0.1
- Probe Metal's command predication from the validation crate's Metal platform
- Wait for the predication probe's command buffers through the bounded wait
- Name the record a predication block left open came from in its command buffer's failure
- Refuse a run's first indirect dispatch of another dispatch type at Metal level 26.7
- Read an encodeEndDoWhile's word only where it closes a live DoWhile
- Run command predication on devices without buffer device addresses
- Nest predicated loops to any depth, their copies bounded by what they lay down
- Read a predication word past its buffer as Metal reads it
- Halt a predication unit where a loop runs past its copies
- Name the lane's fixed loop case type, which clippy found too complex

Content: the tree of `development` at ef8b74ec1b, unchanged.
2026-10-26 13:19:05 +02:00
Anees Iqbal 0d9e71903b Read VK_EXT_provoking_vertex: provokingVertexLast and provokingVertexModePerPipeline
The steps this packet landed as, in order:
- Write the index rewrite pass's primitives in either provoking vertex order
- Draw Apple's last provoking vertex: a last-vertex pipeline, else lists led by it
- Test Apple's provoking vertex modes against Metal's on the device
- Describe the provoking third way as pipeline-dependent; fix the table test
- Check the last provoking vertex through a geometry stage; key its slice notice on stages
- Test that executions keep the first vertex; scale the weights check by the values
- Register rt6_provoking in the engine inventory and golden printouts
- Add host_ab's provoking workload: flat-shaded draws at provoking vertex modes 0 and 1
- Add the index gather pass: one dispatch for a run of direct draws' lists
- Gather direct indexed draws' lists in runs: one dispatch per run, not three per draw
- Add the rotated-weights variant: Metal's barycentric weights from a rotated triangle
- Count private lists' gathers under a last-vertex pipeline; take the open runs whole
- Draw listed triangles' barycentric weights through the rotated-weights variant
- Draw every provoking vertex mode past 1 the third way, its top bit set or not
- Announce nothing for a provoking-mode draw that makes no primitive

Content: the tree of `development` at 91b1df7b21, unchanged.
2026-10-26 13:19:05 +02:00
Anees Iqbal 9adc8a867a Draw Metal's private primitive types 5 to 8 as the lists Metal draws
The steps this packet landed as, in order:
- Test the private primitive types' draws against Metal's lists on the device
- Check the private draws through the weights' geometry stage too
- Use is_multiple_of and as_chunks in the private lists
- Fail a draw of primitive type 9 as Metal's GPU does
- Give the private-types fixture its golden printout and inventory rows
- Discard what a hang's queue schedules during it, and time the hang as measured
- Regenerate REFUSALS for the type-9 runtime changes
- Read Metal's quad primitive ID under private quads and quad strips
- Read a type-9 hang's Scheduled at Metal's time, not at its held last batch
- Schedule a hang's queue's command buffers from the hang's Scheduled on
- Stop a hang's thread waiting on a failed command buffer; keep storage-form commits on their last batch
- Hold a hang's joined command buffers behind a closure, so Rustdoc ends

Content: the tree of `development` at 5441a97bda, unchanged.
2026-10-26 13:19:05 +02:00
Anees Iqbal 7b8ebc5b3e Use AtomicU64::try_update, the name fetch_update now has
The steps this packet landed as, in order:
- Refuse buffer-texture copy layouts whose rows pass u64::MAX instead of wrapping
- Wait without a deadline for a timeout past the host's clock, and test copies at the buffer's edge
- Place a multisampled buffer copy's rows where plain Metal does, staging off-texel rows
- Say that Metal copies the multisampled layouts the runtime still refuses
- Count the rows a compressed-texture blit rewrites, and test a copy out off the texel

Content: the tree of `development` at e5ff75b136, unchanged.
2026-10-26 13:19:05 +02:00
Anees Iqbal 1d15b13eb7 Complete a queued commit its own work refused
The steps this packet landed as, in order:
- Pin the runtime sources with a refused queued commit's completion

Content: the tree of `development` at a62e8a365f, unchanged.
2026-10-26 13:19:05 +02:00
Anees Iqbal 3f1c1e60d1 End the auto-trait walk at a render lowering slot, at the default recursion limit
The steps this packet landed as, in order:
- Pin the runtime sources with the lowering slot's auto-trait boundary

Content: the tree of `development` at a6fba3966c, unchanged.
2026-10-26 13:19:05 +02:00
Anees Iqbal 6da0b55c4b Leave a commit's own work behind a render encoder's end in flight, on request
The steps this packet landed as, in order:
- Regenerate the refusal surface and pin the runtime sources with commits behind the lowering thread

Content: the tree of `development` at 770f8bce10, unchanged.
2026-10-26 13:19:05 +02:00
Anees Iqbal 36eac8adf5 Give a memoryless texture of several levels or layers device memory on MoltenVK
The steps this packet landed as, in order:
- Set the artifact format and runtime versions and pin the runtime sources for MoltenVK 1.4.2
- Bless the census's product line and regenerate the refusal surface at the MoltenVK 1.4.2 tree

Content: the tree of `development` at 6267cde0be, unchanged.
2026-10-26 13:19:05 +02:00
Anees Iqbal e3ade73ace Run a fragment's quads whole through MoltenVK 1.4.2 without shaderQuadControl
The steps this packet landed as, in order:
- Withhold MoltenVK 1.4.2's blend warning of attachments it cannot blend
- Measure the M3 Max at MoltenVK 1.4.2, named apart from the M4
- Say what queue_storms measured at MoltenVK 1.4.2 plainly
- Make a heap's set layout MoltenVK's support query refuses only where it runs it, announced

Content: the tree of `development` at 285be2f493, unchanged.
2026-10-26 13:19:04 +02:00
Anees Iqbal 1505f4f5b3 Lower a render encoder's end on the device's lowering thread, on request
The steps this packet landed as, in order:
- Regenerate the refusal surface and pin the runtime sources with the end on the lowering thread

Content: the tree of `development` at bf576119ea, unchanged.
2026-10-26 13:19:04 +02:00
Anees Iqbal 59f83d5bd4 Lower a render encoder's logged calls on the device's lowering thread, on request
The steps this packet landed as, in order:
- Regenerate the refusal surface and pin the runtime sources with the lowering thread

Content: the tree of `development` at e282080dd5, unchanged.
2026-10-26 13:19:04 +02:00
Anees Iqbal 19ccb91916 Log a render encoder's calls and lower them after they return, on request
The steps this packet landed as, in order:
- Regenerate the refusal surface and pin the runtime sources with the logged render encoder

Content: the tree of `development` at f3cfaa3feb, unchanged.
2026-10-26 13:19:04 +02:00
Anees Iqbal cc7d0f3e3c Share the draw replay's eligibility rules in metal2vulkan::bind
The steps this packet landed as, in order:
- Draw GPU-written render executions on the device in the validation executor
- Shard the M3 Max pass-chain tables so no test nears nextest's limit
- Set the semantics and runtime versions and pin the runtime sources at the merged tree
- Bless the golden hashes for the merged-draw ICB fixture
- Bless the authored compile census at semantics 1809
- Regenerate the refusal surface at the merged tree

Content: the tree of `development` at 3bb4f250ea, unchanged.
2026-10-26 13:19:04 +02:00
Anees Iqbal 8237c45cab Refuse a shadowed pass's GPU-written execution only where a reach past its call meets a shadow
The steps this packet landed as, in order:
- Run GPU-written render executions on the GPU alone in passes with shadowed textures

Content: the tree of `development` at 3349566ac4, unchanged.
2026-10-26 13:19:04 +02:00
Anees Iqbal b30642f159 Merge a GPU replay's draws of one list type or points into one draw in the translator
The steps this packet landed as, in order:
- Draw a GPU-written render execution of one list type or points as one merged draw
- Reset an indirect command buffer's records on the GPU with one fill
- Regenerate the refusal surface after the merged draws, rebased onto development
- Regenerate the refusal surface over the host-step cause

Content: the tree of `development` at 99ae896ad5, unchanged.
2026-10-26 13:19:04 +02:00
Anees Iqbal 4a286a459a Send GPU-written compute executions to the host step where it runs them faster
The steps this packet landed as, in order:
- Set the runtime version and pin the runtime sources at the merged tree
- Set the semantics version and pin the runtime sources after the render GPU form
- Bless the golden hashes at the merged tree
- Bless the authored compile census at the merged tree
- Regenerate the refusal surface at the merged tree
- Pin the runtime sources after the compute indirect command cost rule
- Regenerate the refusal surface after the compute indirect command cost rule

Content: the tree of `development` at f4a0642491, unchanged.
2026-10-26 13:19:04 +02:00
Anees Iqbal f05f8a5a94 Count a replayed draw's misses of the buffers its slot tables do not hold
The steps this packet landed as, in order:
- Run GPU-written render commands on the GPU alone, and let a check state what it looks for
- Say that a check of every kind runs on the GPU alone where the records rule out both kinds
- Pass what the check looks for in the compute lane's checked execution
- Add host_ab's icb_draws workload: a kernel writes the draws of Apple's GPU-encoded ICB sample

Content: the tree of `development` at 665d587ae2, unchanged.
2026-10-26 13:19:04 +02:00
Anees Iqbal 7b5fc45e15 Add host_ab's burst workload: calm frames and bursts measured apart
The steps this packet landed as, in order:
- Keep the recycler's proven parked objects through a run of one-off makings
- Remember usage answers by hash, 1024 of them, least recently asked going first
- Pin the runtime sources after the recycler's protected eviction and the usage answers' LRU
- Regenerate the refusal surface at the merged tree

Content: the tree of `development` at bde1abe95b, unchanged.
2026-10-26 13:19:04 +02:00
Anees Iqbal d564d7836f Order a blit encoder's untracked uses by key and range, not as one class
The steps this packet landed as, in order:
- Pin the runtime sources after the blit commands' byte-range order
- Regenerate the refusal surface at the merged tree

Content: the tree of `development` at 1f2b48f345, unchanged.
2026-10-26 13:19:03 +02:00
Anees Iqbal 4d9b17a359 Run a batch's first work in its work's VkSubmitInfo, not one of its own
The steps this packet landed as, in order:
- Count render encoders' render pass instances by where they began, and their splits by cause
- Set the runtime version and pin the runtime sources at the merged tree
- Bless the golden output hashes at the merged tree
- Bless the authored compile census at the merged tree
- Regenerate the refusal surface at the merged tree

Content: the tree of `development` at effa414f26, unchanged.
2026-10-26 13:19:03 +02:00
Anees Iqbal d01ed34d37 Add DeviceOptions::assume_unmeasured_identity: run a measured device as an unmeasured GPU
The steps this packet landed as, in order:
- Pin the runtime sources at the switch on the development base
- Blend fast-math colors into BGR10_XR_sRGB and RGB10A8_2P_XR10_sRGB as the linear forms do
- Name a placement heap texture the heap does not make at an offset inside it

Content: the tree of `development` at 3386fdcac8, unchanged.
2026-10-26 13:19:03 +02:00
Anees Iqbal f6442761df Let an indirect command buffer's execution check the commands its host step records
Content: the tree of `development` at 480957f307, unchanged.
2026-10-26 13:19:02 +02:00
Anees Iqbal 62cad6be54 Regenerate the tables and set the versions at the landed tree
The generated and blessed files, and the three version constants, as of the tree this series ends
on. They come last so that no packet commit before this one claims a version or a table, and so
the final tree is exactly the tree verified at the tip.

- docs/REFUSALS.md regenerated.
- crates/metal2vulkan/tests/golden_hashes.tsv and the air_input printouts as blessed (the table
  tests 25 of 25 on the M3 Max host, with xcrun metal-as for the typed-pointer fixtures).
- crates/metal2vulkan-validation/corpus/authored-compile.tsv as blessed: 2256 authored cases on 21
  profiles, 47376 cells, 46245 compiled and 1131 refused, 0 failed, 0 differences, 0 regressions.
- crates/metal2vulkan-validation/runtime-sources.sha256 recomputed.
- SEMANTICS_VERSION 1798, RUNTIME_VERSION 1496, ARTIFACT_FORMAT_VERSION 431.

Verified at this tree: the full suites on the RTX 5080 Laptop, RTX 3090, RX 7900 XTX, Radeon 780M,
Iris Xe and the M3 Max through MoltenVK, the CPU suites (product, validation, lavapipe's CPU ICD),
fmt, clippy in every configuration, rustdoc, the API reference and refusal-surface checks,
packaging and doctests; the failures those runs found were fixed in this series and their lanes
run again green.
2026-10-19 00:16:01 +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 b7da00074a Filter a two-plane YCbCr texture with the device's sampler by default, Metal's filter behind YCbCrFilterPolicy::Exact
A draw that bound a two-plane YCbCr texture (YCBCR8_420_2P and its kin) at a
linearly sampled slot made a second VkPipeline at the draw. The slot's YCbCr
variant (RuntimeFact::YCbCrTexture) emulated Metal's filter of the format, and
the state's creation never predicts it, since the predicted key binds no
texture. On ANV, CoreAnimation's A2Xghfc paid 37.8 s for that second making,
inside a command buffer, past the x86 guest's 10 s watchdog.

Under the owner's rule (fast by default, exact on request, both kept, the
difference logged), the default is now the device's own filter. A new
DevicePolicy field, ycbcr_filter, selects the form:

- YCbCrFilterPolicy::Device, the default.
  - On a device that samples natively (ANV, RADV, NVIDIA, lavapipe),
    ProfileFields::ycbcr_variant is false. The slot records no fact and is
    filtered by the device like any other, and a draw takes the pipeline its
    state's creation made. The module's PrecisionNote::DeviceSampling
    (device-sampling) states the bound.
  - On MoltenVK, Metal's own sampler filters the slot's converted view
    (RGBA16Float on the 1/2048 grid, RGBA32Float on 1/8192).
    lower::sampler::linear::metal_filtered_ycbcr records the
    HalfSampleFilter/FloatSampleFilter note under the bound format alone
    (SpecKey::BoundTexelFormat). The runtime's degrade_bound_formats
    announces it as ycbcr-filter-not-exact, naming the slot and the format.
    A one-texel half sample on the 8192 grid records HalfTexelConversion
    under that format and is announced at the draw.
- YCbCrFilterPolicy::Exact keeps the variant: Metal's filter, through one
  pipeline made at the first draw binding such a texture.
  DevicePolicy::exact_answers() sets it. On MoltenVK, SamplingPolicy::Exact
  takes the variant too. Over a compiler limit, the native-sampling fallback
  (ReducedForms) drops it with sampling and reports it.

Bound of the default, in codes of 1/255. Each figure is the largest
difference of any channel over five surfaces (420v/420f; BT.601, BT.709,
BT.2020), 65,536 random coordinates and 960 on the 1/256 grid, float and half
results. Measured against Metal's sum (checked equal to metal_step):
- NVIDIA RTX 3090 (615.71.09): 1.183
- ANV Iris Xe RPL-P (Mesa 26.2.4): 1.058
- RADV 780M and RX 7900 XTX (Mesa 26.0.8): 0.877
- lavapipe (Mesa 26.2.4): 0.872
- MoltenVK against Metal's own YCbCr filter (M3 Max, macOS 27.0.1, plain
  Metal): 0.1245 for RGBA16Float and half results; 0.0157 for RGBA32Float
  float results.

Reproducer (corpus-draw-ab on ANV, cold, a2x-s96 with
RGBA8Unorm:linear@3=YCBCR8_420_2P): before, two pipelines (13.9 s at
creation, 37.8 s at the draw), 52.3 s wall, 3.23 GB. After, one pipeline
(13.9 s), 14.3 s wall, 1.30 GB.

Tests of both settings:
- a_device_takes_the_ycbcr_variant_only_under_the_exact_filter (lavapipe and
  MoltenVK).
- The runtime lane's default tests on native-sampling devices and on
  MoltenVK: no pipeline at the YCbCr draw, bit for bit the RGBA16Float twin's
  draw, the expected announcements once. The exact twins expect the variant.
- fingerprint_covers_every_policy_field.
- metal_s_own_answers_key_the_same_under_either_choice.
- The notes test helper (engine_linear_half::notes_bound) now gives
  BoundTexelFormat the bound texture's class, as the runtime does.

Docs: the FAST-PATHS row and its MoltenVK bound, the API.md
ycbcr-filter-not-exact, device-sampling and half-texel-conversion entries,
the policy, profile-field, fact, lowering and runtime-kind rustdoc, and
REFUSALS regenerated. SEMANTICS_VERSION 1757, RUNTIME_VERSION 1314, runtime
pin recomputed.

Tables: the golden hashes (38 cells per natively sampling column, both tables;
every profile's fingerprint for the new policy field, MoltenVK's again for its
default) and the authored compile census (187 cases on 10 native-sampling
columns, 193 on moltenvk-m3). All are artifact hashes, with no status change.

Verified on development-fast (batches f15-f19, f24): every lane green on the
RTX 3090, ANV Iris Xe, RX 7900 XTX, both 780Ms, lavapipe and the M3 Max
(MoltenVK), plus the CPU suites, case qualification, clippy in every
configuration, docs and packaging. Not run on the RTX 5080 Laptop (host
offline). The consumer measured YCbCrFilterPolicy::Exact on MoltenVK as byte
for byte the previous variant (80 of 80 tests on the M3).
2026-10-17 11:14:19 +03:00
Anees Iqbal 01841476dd Compute Metal's 8-bit unorm blend of a fetched attachment for every factor, mask and blend color
Through the pixel interlock (RADV, ANV, NVIDIA, MoltenVK) a fetched attachment is a storage image,
so the shader computes Metal's blend. For R8Unorm, RG8Unorm, RGBA8Unorm and BGRA8Unorm only
premultiplied source-over with every channel written was built; every other blend, any write mask
that keeps a channel, and the blend color stayed FramebufferFetch / NotImplemented at the color.

What: Blend::unorm8 now plans every factor and operation but the second source's, under any write
mask, with the blend color, through the 16-bit planner's forms as Metal's compiler builds them for
an 8-bit unorm attachment (Family::Unorm8, measured, below):
- an inner sum adds the destination's atoms before the source's (Order::Destination);
- a lerp takes y from the destination's product first; alpha takes no lerp of the destination
  alpha beside itself or held by both products;
- of an added pair, the destination's product is rounded first where unorm8_rank(fs) >= rank(fd)
  (tables per half/float arithmetic and color/alpha);
- alpha shares the one minus the blend alpha, source alpha and destination alpha (SourceAlpha-
  Saturated's too) that stored color lanes compute; with no color channel stored, the one minus
  an alpha the color channels' destination factor is; a min or max computes no factor. A shared
  one minus blocks a lerp of the blend or destination alpha and stays whole where added from the
  destination's product;
- a write mask of one color channel plans that channel as a scalar (Order::Scalar: Da, D, Sa,
  S): no splat rules, but a one minus an alpha that its destination factor is, or that alpha's
  factors compute (alpha stored or not), stays whole and takes no lerp.
blend_unorm8 reads the blend color from PushField::HalfBlendColor's f32 words: NaN to 0, clamped
to [0, 1], rounded to half in half arithmetic; OneMinusBlendColor reads h(1 - h(c)) (f(1 - c) in
float) under either math. fetch.rs pushes the field where the blend reads it and merges the
channels the mask leaves out after the blend, as the 16-bit form does. Because Metal's forms depend
on the mask, compiled_write_mask splits a blended RGBA8Unorm/BGRA8Unorm attachment's partial-mask
class in three (alpha alone, one color channel with or without alpha, two or more color channels);
other formats keep one partial class. Without that split a one-channel mask compiled under the
two-channel class and missed Metal's code in 64 of 4096 texels on the 3090 and the 780M. Without fast math every
state takes the rounded forms. Refused, NotImplemented(FramebufferFetch): a second-source factor;
under fast math a lerp, common factor or contracted pair into R8Unorm or RG8Unorm (Metal sums
those in forms of their own, EV FB8-r8-m3); every other format, now named in FAST-PATHS' known
gap with the source-over survey's result (10-bit unorm and RGBA8Snorm fit the 8-bit model with
their clamps; the 16-bit norms and RGBA32Float blend in float even for half4; their factor sets
are not measured). No PrecisionNote or DevicePolicy kind is added: every built blend is exact.

Metal's arithmetic, plain Metal on the M3 Max (macOS 27.0.1), our own MSL, 512 x 512 targets: every
destination code against every source alpha code (two blocks) plus random blocks with sources out
of range, infinite or NaN; half4 and float4, fast and safe; BGRA8Unorm unless named:
- EV FB8-sw2-m3 (seed 388824, blend color 0.3/0.6/0.9/0.45): every factor/operation pair for color
  beside source-over alpha (676), the reverse (676), and the same pair for both (677).
- EV FB8-rnd1-m3 (seed 424242, color 0.7/0.15/0.55/0.8): 600 random state pairs.
- EV FB8-mk1-m3 (seeds 1000 + mask): masks 1 to 14, 300 random states each.
- EV FB8-bc1-m3 (seeds 2001-2003): blend colors past both ends of every channel.
- EV FB8-sc1-m3 (seed 7): one color channel: all 153 color keys with a lerp or common-factor
  candidate beside 13 alpha keys (none, OMSA, OMDA, OMBA, OMSC, OMDC, OMBC, mixes), masks B and B+A.
- EV FB8-ao1-m3 (seed 9): alpha alone: all 432 alpha keys with a lerp, common or contracted form
  beside 8 color keys.
- EV FB8-mk3-m3 (seeds 1000 + mask): masks 1, 2, 3, 4, 5, 8, 9 under two random sets of 300.
- EV FB8-mm1-m3: a min or max beside one-minus factors, full mask, one channel and alpha alone.
- EV FB8-r8-m3 (seed 3001): R8Unorm and RG8Unorm, same/color/random400: safe math exact in every
  state; fast-math misses only lerp, common and contracted forms; single, fused, zero and min/max
  forms exact in every state.
The model fits every state of each EV (0 mismatched channels), and the Rust planner's plans equal
the model's on 240,480 states (each sweep state under ten masks with and without alpha, plus the
explorer states, half/float x fast/safe), compared through a scratch dump.

Tests: arith::tests::blend8 adds the interpreter over a state of each rule (source alpha over,
the blend color's lerps with a color past both ends, blue alone, alpha alone; half and float, fast
and safe) against hand-written Metal arithmetic, and the no-alpha refusals; tests::engine_fetch_blend8
compiles eight other blends and masks (blend color pushes HalfBlendColor, nothing announced) on
every interlock committed profile and keeps second-source factors refused; engine_fragment's
interlock test now expects RGBA8Unorm's blend computed. runtime_lane::framebuffer_fetch::blend8
adds other_blends_masks_and_the_blend_color_store_metals_blend: the four states into BGRA8Unorm
through each fixture's half4 and float4 loads on the device, every texel against the model.

Verified on gem10 at the content of this commit (WIP a395835, plus REFUSALS regenerated):
- cargo fmt --check; clippy --workspace --all-targets --all-features -D warnings in plain,
  --cfg m2v_gpu and --cfg m2v_cpu_icd; rustdoc -D warnings.
- metal2vulkan nextest -E 'test(/eight_bit|blend8|blend16|fetch/)': 90 of 90 passed.
- metal2vulkan-validation -E 'test(/eight_bit|framebuffer_fetch/)' (release, m2v_gpu) on the RTX
  3090: 56 of 56. Every draw went through the pixel interlock with Metal's 4096/4096 texels and
  nothing announced: the 24 source-over draws and the 16 new ones (four states x two fixtures x
  half4/float4). On lavapipe (m2v_cpu_icd): 56 of 56; the device blends through input attachments
  and announces HalfOutputFastMathBlend and DeviceColorConversion.
- The 780M was held by reims-vgpu at the final run. One run earlier, before the mask-class split,
  it agreed texel for texel with the 3090, including the one-channel miss the split fixes.

SEMANTICS_VERSION 1754 -> 1755: the translation of these blends and the mask classes changes.
RUNTIME_VERSION and the runtime-sources pin are unchanged. docs: the FAST-PATHS known gap (what is
built, what is refused, and the other formats' survey), the API.md degrade catalogue, and
REFUSALS.md regenerated.
2026-10-17 11:13:19 +03:00
Anees Iqbal bc90b127f1 Compute Metal's 8-bit unorm source-over blend of a fetched attachment in the shader
The x86 macOS guest refused a render pipeline on every interlock device (RADV, ANV, NVIDIA,
MoltenVK): framebuffer fetch of a BGRA8Unorm color 0 blended One / OneMinusSourceAlpha (add,
color and alpha, mask 0xf) beside an RGBA16Float color 1 of mask none was
FramebufferFetch / NotImplemented at Color(0). Through the pixel interlock the fetched attachment
is a storage image, so no Vulkan blend applies and the shader must compute Metal's blend; only
the extended-range and 16-bit float blends were built.

What: Blend::unorm8 plans premultiplied source-over into R8Unorm, RG8Unorm, RGBA8Unorm and
BGRA8Unorm storing every channel, half4 and float4 outputs, fast and safe math, through the 16-bit
float planner's forms. blend_unorm8 clamps the output to [0, 1] (NaN to 0), reads the texel's code
exactly (RoundEven(texel * 255), then the existing exact division to f32, then half for a half4
output), and blends in the output's type: fast math fuses (h(fma(d, h(1 - a), s))), safe math
rounds each step (h(s + h(d * h(1 - a))), likewise in float). fetch::unorm8_blended then rounds the
result's code by Metal's 8-bit unorm write (color_write's Unorm{8} rule). The blend takes channels
in Metal's order from read_texel and hands them to emit_return's metal_order exchange, so ANV's
RGBA twin of a BGRA8Unorm attachment takes it unchanged. Any other blend of an 8-bit unorm
attachment, a write mask that keeps one of its channels, and every other format stay refused as
before (FramebufferFetch / NotImplemented). The color write plan treats a shader-blended 8-bit
channel as rounded in the shader, so it records no device-conversion note. No PrecisionNote or
DevicePolicy kind is added: the blend is exact.

Metal's arithmetic, measured with plain Metal on the M3 Max (macOS 27.0.1), our own MSL of the
guest's shape:
- EV FB8-dec1-m3 (seed 1): a fetch of every code reads h(c / 255) as half4 and f(c / 255) as
  float4, every channel of every format. A plain write stores the code of the value clamped to
  [0, 1] (NaN to 0) times 255, the exact product rounded half up.
- EV FB8-sw1-m3 (seeds 1000 * run + (output is float), runs 0 to 3; 4096 x 961 targets): every
  half alpha in [0, 1] (15,361) against every destination code of each channel, four source draws
  per pair (aimed within four ulps of a code midpoint, 2% out of range, infinite or NaN). That is
  63 million channels per variant (BGRA8Unorm, RGBA8Unorm, RG8Unorm, R8Unorm x half4, float4 x
  fast, safe), and the model above gives Metal's code in every channel: 0 mismatches.
- EV FB8-fold1-m3 (seed 7, 2048 x 2048): nine products and sums of the output, the fetched color
  among them, half4 and float4, fast and safe. The clamp keeps all of them out of the blend, so
  fbl8_over_product is exact too (16-bit float folds it).

Tests: arith::tests::blend8 runs the interpreter over every alpha code's value against every
destination code (half and float, fast and safe, BGRA8Unorm and R8Unorm), and checks that another
blend, mask or format is refused. tests::engine_fetch_blend8 compiles the guest's shape on every
interlock committed profile (BGRA8Unorm on each, the ANV profile asserted, no skip) for four
formats and six entries, plus the whole guest pipeline. It asserts the storage form, no note,
link and validation, and that other blends stay refused at Color(0). At d188d8b771 (before this
change) a_blended_eight_bit_unorm_fetch_computes_metals_blend fails with the guest's refusal
("unsupported: FramebufferFetch; needs NotImplemented ... color attachment 0", amd-780m-radv
BGRA8Unorm). The fixtures fbl_fetch_blend8 and fbl_fetch_blend8_safe (our own MSL, regenerated
by scripts/regen-air-fixtures) feed runtime_lane::framebuffer_fetch::blend8, which draws each
entry into the four formats on the device and compares every texel with the model; their
golden printouts (tests/air_input) come from bless_engine_goldens under the pinned LLVM 21.

Verified (gem10, release where a GPU runs):
- clippy --workspace --all-targets --all-features -D warnings in plain, --cfg m2v_gpu and
  --cfg m2v_cpu_icd; rustdoc -D warnings.
- metal2vulkan nextest -E 'test(/eight_bit|blend16|fetch/)': 87 of 87 passed; -E 'test(/air_input/)'
  with METAL2VULKAN_TEST_REQUIRE_PINNED_LLVM=1: 7 of 7 passed.
- metal2vulkan-validation -E 'test(/eight_bit|framebuffer_fetch/)', 55 of 55 passed, on the RTX
  3090 (NVIDIA ICD) and on lavapipe (m2v_cpu_icd, LP_NUM_THREADS=1). On the 3090 every one of
  the 24 fixture x format draws went through the pixel interlock with Metal's 4096/4096 texels
  and nothing announced.

SEMANTICS_VERSION 1753 -> 1754 (translation of this shape changes). RUNTIME_VERSION and the
runtime-sources pin are unchanged. docs: FAST-PATHS known gaps (the interlock blend's coverage),
the API.md degrade catalogue (HalfOutputFastMathBlend), REFUSALS.md regenerated.


The blessed tables come in the same commit: golden_hashes.tsv gains 16 rows for
fbl_fetch_blend8 and fbl_fetch_blend8_safe, public_fixture_expectations_engine.tsv their 16
inventory rows in fixture order, and authored-compile.tsv only its product fingerprint (no cell
moves). Batch verification on development-fast: the fetch and blend filters green on the RX 7900
XTX, the 780M, the Iris Xe, the RTX 3090, lavapipe and the M3; the full suites at the bless green
on the Iris Xe, the XTX, the 780M and the M3 (7259 and 7274 tests). The RTX 5080 was not run.
2026-10-17 06:13:23 +03:00
Anees Iqbal fc9147534d Fetch a BGRA-order attachment through its RGBA twin without format-less reads
On a device that orders framebuffer fetch through the pixel interlock but
has no shaderStorageImageReadWithoutFormat (ANV), a fetched BGRA8Unorm or
BGR10A2Unorm color attachment was refused: SPIR-V names no image format
for B8G8R8A8_UNORM or A2R10G10B10_UNORM_PACK32, so neither the typed nor
the format-less declaration reached it. A guest pipeline of a fetched
BGRA8Unorm color 0 beside an RGBA16Float color 1 was refused on the Iris
Xe and aborted the consumer.

What changed:

- One public decision for the fetch storage view's format,
  StorageAttachmentUse::view_alias_of(format, profile) (the old
  uint_view_of took no profile). An 8-bit sRGB attachment keeps its
  unsigned-integer view. A BGRA-order format the device accesses without
  a format keeps its own format (RADV, NVIDIA, MoltenVK unchanged). One
  no declaration reaches takes its RGBA-order twin (R8G8B8A8_UNORM,
  A2B10G10R10_UNORM_PACK32) where the twin declares and stores. The
  compile layer (lower/fragment/fetch.rs) and the runtime
  (framebuffer_fetch::storage_view_format) both call it.
- The fragment reads and writes such an attachment through the twin,
  exchanging red and blue in the shared read and write helpers
  (read_texel, metal_order), so every read, written value, kept channel
  and per-sample plane sees Metal's channel order.
- The runtime makes the views: a BGRA8Unorm render target's free STORAGE
  candidate is made mutable to the twin (so ANV fetches it in place),
  and stand-ins and sample planes take the twin as their storage view.
- StorageAttachmentUse::format_usages names the view's format (the one
  the storage image is bound in), not the attachment's.
- Public rename: StorageAttachmentUse::uint_view and
  WriteSource::TileAttachment::uint_view become view_alias (serde keeps
  the old name as an alias), with StorageAttachmentUse::with_view_alias
  and view_alias_of.
- The refusal names both routes where neither reaches (a BGR10A2Unorm
  attachment without shaderStorageImageExtendedFormats).

The class, on a device without format-less storage reads: a fetch of a
16-bit packed attachment (B5G6R5Unorm, A1BGR5Unorm, ABGR4Unorm,
BGR5A1Unorm) stays a typed FramebufferFetch refusal, and a read of an
argument buffer's writable texture a typed ArgumentBufferTextures one;
both are FAST-PATHS known gaps. Kernel slots, tile passes and the depth
and stencil stand-ins already declare typed first.

SEMANTICS_VERSION 1753, RUNTIME_VERSION 1313, runtime-sources pin
recomputed. REFUSALS.md regenerated; docs/API.md says which view the
storage form binds.

Verified:

- Metal (M3 Max, macOS 27.0.1, our own MSL probe under the Mac GPU
  lock): BGRA8Unorm and RGBA8Unorm targets, 1x and 4x, masks of every
  channel and of red and alpha, one to three fetch_ordered draws: every
  byte matches the model the device test checks (c read as c/255,
  halved, written as the exact product with 255 rounded to nearest).
- ms01, Iris Xe (ANV, Mesa 26.2.4), release, --cfg m2v_gpu:
  runtime_lane::framebuffer_fetch::bgra passes with Metal's bytes in
  every case beside an RGBA16Float color 1 that keeps its clear. The
  BGRA8Unorm pipelines are made with view_alias R8G8B8A8_UNORM (4
  pipelines); single-sampled targets are fetched in place (no storage
  form switch, no fetch-through-scratch notice), 4x through sample
  planes viewed in R8G8B8A8_UNORM. The fetch lane
  (runtime_lane::framebuffer_fetch::, 47 tests) and
  tests::srgb_fetch_images pass there too: 48 of 48.
- ms01, debug: lower::fragment::fetch::tests (new: the twin on each
  of four ANV profiles for BGRA8Unorm and BGR10A2Unorm at 1x, in planes, under
  reads, writes and a red-and-blue mask; format-less profiles
  unchanged; both routes named; the refused class),
  engine_fragment::a_fetched_bgra_attachment_is_viewed_in_its_rgba_twin
  (the consumer's two-attachment shape on intel-irisxe-anv, 1x, 4x and
  a partial mask, the SPIR-V validated against the profile), with
  engine_fragment, engine_tile, cache::tests, pipeline::api_tests,
  pipeline::link::tests, fast_paths and api_surface: 217 of 217 pass.
  With the twin decision forced off, the five new translator tests
  fail, the consumer shape refused as on the Iris Xe (FramebufferFetch
  needs AnyOf([[ShaderStorageImageReadWithoutFormat]])).
- clippy --workspace --all-targets --all-features -D warnings clean
  plain, with --cfg m2v_gpu and with --cfg m2v_cpu_icd.
2026-10-17 06:13:23 +03:00
Anees Iqbal 20bd3793f3 Exact tiny products and fma, Metal's 16-bit blend zeros and new depth pattern, new notices, the ANV compiler-bound fallback, exit and barrier fixes
One squash of development-fast c66863112e..d8546c940b (27 commits); the
tree equals d8546c940b.

Exact float maths (FloatMathsPolicy::Exact only; the fast default is
unchanged):
- A tiny float product and OpFmaKHR flush to zero as Metal does; the
  native default announces the device's rounding first
  (float-tininess-after-rounding). The check is the compact form; its
  compile cost is recorded in docs/FAST-PATHS.md, and the check's own
  scaling multiply is NoContraction.

Now Metal's:
- A fetched 16-bit float blend's lone term takes Metal's zero under fast
  math (R16Float and RG16Float read alpha as 1).
- A new Private Depth32Float or Depth32Float_Stencil8 target's NaN pattern
  is switched on at the pass that loads it; where the device's test is not
  Metal's it is announced (signed-depth-test), and a clamping device
  announces fresh-pattern-zeroed.
- A render-target barrier from the fragment stage to an earlier stage
  orders the later passes' attachments.

New notices for differences that were silent: unmeasured group
speculation, an anisotropic sampler without mips (MoltenVK), a draw's
attachment read in place, a sample level the device's arithmetic chooses
(exact sampling off MoltenVK), and exact forms dropped to fit ANV's
compiler.

Crash and exit fixes:
- ANV: a render pipeline whose largest stage passes 400,000 words under
  exact forms is retranslated with them dropped until it fits
  (ExactFormsOverCompilerLimit), instead of a SIGSEGV in Mesa's register
  allocator.
- The exit hook sees a making that ends as it looks, and drains a CPU
  device's work at its first run only.

Measurements: the commit hand-off cost on the Iris Xe; the M3 under macOS
27.0.1 places heap blocks and copies compressed textures as the M4 does.

Tests fixed (heap-shadow fence, attachment-read routes, freed-memory
thread, depth pattern per device class, the new kind's lane site) and the
golden hashes, engine inventory and authored compile census blessed.

Verified at d8546c940b (batch f7): RTX 5080, M3, Iris Xe, RX 7900 XTX and
780M green; lavapipe 3822/3822, product 4821/4821, CPU validation
1331/1331, fuzz, fmt, clippy (4 configurations), Rustdoc, packaging,
qualification, refusals and the API reference check green; RTX 3090
7244/7245. Stress soaks of the runtime crate x2 clean on the 5080, XTX,
780M and Iris Xe.

Known open: on the RTX 3090 an Exact checked OpFmaKHR can answer -0 where
Metal answers +0 (the kernel's fast math declares no
SignedZeroInfNanPreserve); the fix is in progress. Not yet run: consumer
boots on this tree and the private-corpus translation census.
2026-10-16 18:45:39 +03:00
Anees Iqbal 29d3ebb22e Fix the consumer's first-move SIGBUS and deallocator fatal, restore the release door, announce the tessellator's triangle order
One commit of the 4 on development-fast (0175289314..c66863112e), squashed at the user's request:
the pin reims-vgpu tested clean.

Runtime:
- A texture's first move over host pages writes back only the bytes the move changed, and only
  where the kernel says the process may write them (mach_vm_region on macOS, the maps query on
  Linux). Before, it wrote back every kept byte: a SIGBUS on read-only pages on MoltenVK, and a
  hang under QEMU, whose handler retried the store. A changed byte over pages the host cannot
  write stays as the move left it, announced (unrestored-first-move-bytes; not observed on any
  venue). WorkCounts::first_move_restored_bytes. HostMemory::new states the Linux contract that
  imported pages stay writable.
- A no-copy buffer released while a submitted command buffer's live buffers' table lists its
  pages runs its deallocator at the release when the caller gave a keep-alive, which keeps the
  pages mapped until the import is freed. Only a release without one waits and announces
  host-deallocator-delayed. Before, the keep-alive case was announced too, which the consumer
  treats as fatal.
- Memory::free_then renamed release_then: it calls no Vulkan entry point, so the release door's
  source scan holds again.
(RUNTIME_VERSION 1303.)

Translator: PrecisionNote::TessellationTriangleOrder, recorded on a pipeline drawn through the
device's tessellation stages where the tessellator is not Apple's
(DriverWorkaround::TessellatorNotMetals): a patch's triangle order, first corners and ring joins
are the device's. The emulation without tessellationShader draws Metal's order and records none.
(SEMANTICS 1740, ARTIFACT_FORMAT 420.)

Docs: API.md's catalogue, FAST-PATHS.md's known gaps, REFUSALS.md.

Verified on development-fast:
- the runtime crate and runtime_lane x3 on the RX 7900 XTX, Radeon 780M and RTX 3090 at
  0175289314 (red only on the release-door scan, then fixed and checked);
- the tessellation note's lanes on the RTX 5080 and M3 (111/111 each);
- the keep-alive lanes on the XTX and 780M (152/152 each), the 5080 and lavapipe, its new test
  failing without the fix;
- both fixes' lanes on lavapipe 197/197, RTX 5080 195/195, Iris Xe 195/195 and M3 194/194; the
  read-only test aborts with SIGBUS on the M3 without the fix;
- reims-vgpu at this tree: cold x86-64 macOS 26 boots clean on the Iris Xe and the 780M, 2711/2711
  of its tests.
Not re-blessed here: the golden hashes' profile fingerprints and tessellation cells that the new
workaround moves; the bless is on development-fast.
The tree is development-fast's at c66863112e.
2026-10-16 13:06:03 +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 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 1cf79a9617 Make textures over surface buffers cheaper, laid at Metal's row pitch where drivers allow
A shadow of a texture over a buffer starts as the buffer's memory lies, instead of zeros that the
copy-in then overwrites, and a format's linear-modifier features are asked of the driver once. A
no-copy texture is laid at Metal's row pitch as a linear image over the buffer wherever the driver
takes that explicit pitch, and a driver's refusal is remembered per exact image (up to 256). The
lanes check textures at a browser's padded row pitches and say which pitches each driver takes.
RUNTIME_VERSION 1186.

Gain: a surface texture's shadow on ANV 1048 -> 135 us, RADV 484 -> 90 us. With the pitched images,
every padded surface aliases on ANV with no shadow: a tile 1048 -> 41 us.

Verified on the original branches: the runtime lanes on RADV, ANV and NVIDIA. Known open:
pitched_surfaces::a_half_float_tile_reads_writes_and_renders_as_metal fails on lavapipe (a
clear-blend-store pass writes a few padding bytes past the row), as it did on the original branch.
This squashed commit was not re-tested on its own.
2026-10-14 12:34:30 +03:00
Anees Iqbal 4b564766ec Sample extended-range textures through Metal's bicubic filter
A sample of a BGR10_XR, BGRA10_XR or RGB10A8_2P_XR10 texture (or an sRGB twin) through a constexpr
bicubic sampler, or through a runtime sampler whose bound word states Cubic, was refused
(NotImplemented(SamplerBicubicFilter) in the lowering, NotImplemented(Format) in the binder). It is
now Metal's bicubic filter of the decoded texels, measured on an Apple M3 Max (macOS 26.7) through
the owned fixture xr_bicubic: random codes of each of the six formats at 16x16, 7x5, 3x3, 2x6 and
1x1, 2,304 coordinates each (every texel's centre, then random ones up to 0.15 of the texture past
its edges), through 12 kernels (a runtime Cubic sampler with float and half results; constexpr
samplers under clamp to edge with float and half results, repeat, mirrored repeat, clamp to zero,
the opaque-white and opaque-black borders, pixel coordinates, and an offset under clamp to edge and
repeat): 3,317,760 lanes.

What Metal does, and what the lowering now does: the footprint, weights, addressing, a mirrored
axis and a level below four texels are the other formats' bicubic filter's, each tap the decoded
texel or the border texel through the format's channels; a level below four texels sums as the
extended-range linear filter (terms truncated); otherwise each tap's step is weighed by the
product of Metal's weights and summed exactly (no term truncated, unlike the linear filter), the
step rounded half up, clamped into the steps of the codes 0 and 1023 (a color lane's (0-384)/510
and (1023-384)/510, an sRGB twin's table steps, alpha [0, 1]), and divided by the grid exactly; a
half result rounds as the linear filter's does. The clamp is applied to the rounded result, which
equals clamping the step because each rounding is monotonic. Every lane but 4,050 matches that
model; each of the 4,050 is one step from Metal's (1/8160 a color lane, 1/8192 an sRGB color lane,
1/4080 alpha), its exact sum within 0.014 of a step of a rounding tie that Metal rounds the other
way. No model of Metal's datapath tried closes that residue, so the sample records
PrecisionNote::BicubicFilterArithmetic, and docs/FAST-PATHS.md and docs/API.md say so. A bfloat or
padded form's bicubic sample, a swizzled texture's and a gather through a bicubic sampler were not
measured and are refused.

How: select_extended takes the bicubic state of a constexpr sampler or of the slot's cubic-sampler
variant (LoweringInputs::cubic_samplers) and plans Metal's bicubic filter; the extended sampler emits
it through bicubic::filter with Texels::Extended, which fetches each tap's raw texel and decodes it,
through the exact routines alone, then clamps. The binder takes a cubic word at an extended-range
slot as the cubic-sampler variant's, and gives such a slot the neutral BicubicTexels value in the
plan of the pipeline as compiled, which binds the neutral there (it refused the format before
naming the variant: the device lane found that). SEMANTICS_VERSION 1693; RUNTIME_VERSION 1184, as
a run of an existing artifact with a cubic sampler at an extended-range slot is no longer refused;
the runtime-sources hash re-pinned.

The table: xr_bicubic.tsv (2,067 samples of the probe's, per texture and kernel the middle
texel's centre, four random coordinates, the first sample with a lane at a clamp bound and the
first with a lane at a tie), shared through metal2vulkan_devtools::xr_bicubic with the probe's
texture generator.

Verified on homelab-gem10 (debug builds):
- tests::engine_extended_range::bicubic, on the CPU interpreter on the lavapipe and MoltenVK-M3
  profiles: every lane of the table through the same 12 kernels, compiled under the six forms'
  variants (the runtime ones under the cubic-sampler word the binder plans), is Metal's bits but
  the 136 lanes the table marks, each one step away; each compile validates and its estimate
  bounds it. A padded or bfloat form's bicubic sample, a swizzled texture's and a gather are
  refused as above (a two-plane gather as Format, under any sampler); on every committed profile
  the pipeline as compiled plans the variants with the XR texture and a Cubic sampler bound, and
  the variant's pipeline plans the same key.
- runtime_lane::extended_range_bicubic (new): the 8,268 lanes on the Radeon 780M (RADV), the RTX
  3090 and lavapipe, textures written as the probe wrote them: 0 differ from Metal (136 at a tie,
  one step away), and the state announces bicubic-filter-arithmetic. The extended_range_samples,
  two_plane_samples and two_plane_copies lanes, whose helpers this shares, pass on all three.
- Release build, 12 kernels x 6 forms x 5 profiles (lavapipe, 780M, RTX 5080 Laptop, Arc ANV,
  MoltenVK-M3): 360 translations, mean 1.31 ms, slowest 1.97 ms (xrb_runtime, BGRA10_XR sRGB,
  780M), budget ledger peak at most 935 KiB, process peak RSS 15.6 MB; the linear XR kernels
  take 0.81 ms on average.
- clippy -D warnings (workspace, all features, all targets; validation also under m2v_gpu),
  rustdoc -D warnings and the doctests pass. Suites: metal2vulkan, -air, -runtime and -devtools
  4,566 of 4,567, validation 1,293 of 1,293. The one failure is tests::golden_hashes, whose 380
  stale cells are the two new fixtures' alone (smw_writers 7 and xr_bicubic 12 entries x 20
  profiles), left to be blessed on development.
2026-10-13 17:04:18 +03:00
Anees Iqbal 61a2efc7d3 Fix the GPU test failures seen on the 3090, 5080, XTX, 780M and M3
What and why, per failure (all release, --cfg m2v_gpu):

AMD RADV, Ubuntu Mesa 26.0.8 (RX 7900 XTX, Radeon 780M):
- generated_executions faulted the GPU (amdgpu gfxhub page fault, ring
  reset): RADV before 26.2 skips re-emitting a compute pipeline it thinks
  is bound, so the second execution's implicit preprocess ran our kernel.
  New RuntimeDriverDefect::ImplicitPreprocessAfterExecutionSet (RADV at
  every identity but the measured clean 780M at 26.2.4): the runtime
  preprocesses every execution of a range explicitly, then a barrier, then
  runs them preprocessed. RUNTIME_VERSION 1183.
- The validation executor's generated-commands replay had the same fault;
  it now preprocesses apart on the same defect (runtime's
  generated_commands::preprocess_apart, now public).
- float_denormals under fast math: the test checked a / b, smoothstep and
  (a / b) * c bit for bit, but without VK_KHR_shader_fma (26.0.8) the fast
  reciprocal is the device's OpFDiv(1, y), within 2.5 ulp. Those words are
  now checked at Metal's edges there, in full elsewhere.

NVIDIA 615.71.09 (RTX 3090, RTX 5080 Laptop):
- render_commands_and_render_states_run_as_the_executor_compiles_them: the
  executor used Vulkan device addresses as Metal addresses, and NVIDIA's lie
  below 2^32, where a record's address names no buffer. An addressed
  allocation's guest address is now its device address read signed (RADV's
  are sign-extended) plus 2^47 + 2^32, one translation for every allocation.
- the_runtime_probe_measures_the_test_device_consistently: two driver
  answers Vulkan does not allow (3090: a buffer read after a linear-image
  copy over the same memory in one submission reads stale bytes; both: an
  explicit linear pitch the driver does not lay out is moved, not refused)
  are listed with their evidence in the test; the runtime records neither.
- exits (5 tests): vkDestroyDevice takes ~55 ms alone and up to 2 s beside
  other processes' GPU work on the 3090, so the exit-timing tests run alone
  (.config/nextest.toml); the 1.5 s limit is unchanged.
- pipeline_records (5080): the test assumed the driver finds a pipeline only
  in byte-identical records, but NVIDIA's bytes vary per compile and the two
  formats share entry keys. It now copies a compute pipeline's record over
  the render state's records, which no driver can hit.
- compile_worker (5080, under load): a worker faster than the 1 ms sampler
  left no peak RSS. Each worker now reports its own peak (VmHWM on Linux,
  ru_maxrss on macOS) and the parent takes the larger.
- tests::completion (both, under load): slow rounds were the GPU starting
  late behind another process's ~200 ms busy kernel, or NVIDIA's
  vkQueueSubmit returning up to 64 ms late; the completion was seen within
  1 ms of the moment it could be. A command buffer is now judged from the
  later of its GPU end and its submission's return where the device
  calibrates timestamps (from the commit elsewhere, as before).
- first_use::new_resources_wait_for_no_gpu_work (both, under load): the
  busy kernel's rate came from one wall-clock run, which collapsed under
  load (3 of 28 calibrations), so the busy work lasted milliseconds. The
  rate is now the fastest of every run at every size by GPU time, for all
  four lanes that share it (gpu_times::read_kinds predicts the notice a GPU
  time read emits, for the neutrals test).

Apple M3 Max, MoltenVK 1.4.1:
- heap_textures allows the shadowed-texture route for depth on drivers that
  lay heap depth textures apart.
- The argument-buffer intersection-table test states Metal's own metadata.
- The indirect lane classifies the deferred pipeline-making failure as
  compile-failed alike and keeps only the failed pipeline's error; Apple's
  33-bit closed-form compiler crash is a known gap in docs/FAST-PATHS.md.

Docs: CONTRIBUTING.md and docs/VALIDATION.md say the golden tables and the
compile census are re-blessed on development.

ENGINE_EXECUTOR_ABI is vulkan-engine-v181 (the RADV replay and the Metal
addresses change what the executor submits): every recorded candidate row
and the authored compile census go stale and need re-recording
(scripts/rerecord-venue per venue, rerecord-commit, corpus-status --c3,
corpus-triage --audit authored-compile --bless).

Still open: M3 frees_in_flight, XTX bfloat clears, 780M half NaN blur and
the 5080's one 2 s rebind_bytes_no_copy did not reproduce; the wall-clock
busy calibrations of framebuffer_fetch/storage_forms.rs and queue_storms
remain.

Verified:
- um780 full suites at the AMD fixes (before the executor and NVIDIA
  commits): XTX 3535/3535, 780M 3535/3535, no amdgpu kernel lines.
- Each fix's focused tests before and after on its GPUs (in the agents'
  commits: e.g. generated/indirect 178/178 on XTX and 780M at 26.0.8 and
  26.2.4; candidate 229/229 on 3090, 780M and Iris Xe; the worker peak 0
  of 1440 under 24-way load on the 5080).
- The combined tip: fmt, clippy (with and without --cfg m2v_gpu) and
  rustdoc on ms01; clippy of the validation crate on macOS; a focused run
  on the 3090 was stopped at 333 of 334 passed, none failed. No full suite
  ran on the combined tip.
- The completion and first_use fixes: 3090 load set 1 of 4 runs failed
  before, 4 of 4 passed after (completion) and 12 runs with no first_use
  failure (84 calibrations, 10.19M-11.24M loads); 5080 6 of 6 and 12 of
  12. fmt and clippy (no cfg, m2v_gpu, m2v_cpu_icd) on ms01.
2026-10-13 01:15:18 +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 11715e2a3f Import no-copy memory a driver refuses from the caller's dma-bufs
RADV imports host pointers through amdgpu userptr with ANONONLY, so it
refuses MAP_SHARED memfd pages (QEMU's memory-backend-memfd guest RAM and
views of it): every no-copy buffer, heap and rebind over them was refused,
and a macOS guest could not boot on AMD. NVIDIA imports the same pages.

What:
- The five no-copy entry points (new_buffer_with_bytes_no_copy, both
  new_heap_with_bytes_no_copy calls, Buffer and Heap rebind_bytes_no_copy)
  take a HostMemory; HostMemory::with_dma_buf adds a retained DmaBufSource.
- Where the pointer import is refused, and only there, on any device that
  lists VK_KHR_external_memory_fd and VK_EXT_external_memory_dma_buf, the
  runtime asks the source for dma-bufs of the window's pages (chunks cut at
  the device's sparse granule, sized by the caller within udmabuf's default
  limits) and binds one buffer over them: plain for one chunk, sparse for
  several (vkQueueBindSparse signalling queue 0's timeline; later work waits
  on it, no host wait). Every path that imported before is unchanged.
- Textures over such pages get a dedicated DRM_FORMAT_MOD_LINEAR image import
  of their own pages where the driver takes the plane offset and row pitch
  (multiples of 256 on RADV), with 64-bit modifier features; elsewhere, or on
  a source error, the existing shadow path.
- The extensions are enabled outside the compile profile: no device's enable
  set, fingerprint or ARTIFACT_FORMAT_VERSION changes. The translator crate is
  unchanged.
- Imports free inside exit-guard sections; the source is never called with a
  runtime lock held. WorkCounts gains dma_buf_imports, dma_buf_sparse_buffers,
  dma_buf_images and dma_buf_image_fallbacks.

Verified:
- Product suites 4553/4553, validation suite 1289/1289, clippy in every
  configuration, rustdoc -D warnings, scripts/api-docs.
- runtime_lane::dma_buf_imports and rebinds on RADV Mesa 26.2.4 (validation
  layer clean), the RTX 3090 and lavapipe (pointer imported, source never
  called), and dma_buf_imports on RADV Mesa 26.0.8.
- reims-vgpu on the Radeon 780M (RADV 26.0.8, udmabuf at its defaults): a
  macOS 26 guest cold-boots to the desktop and runs Safari; 5,119 dma-buf
  requests, none refused.
- 64 MiB on RADV 26.2.4, release: pointer import 187 us; one chunk 665 us;
  16 chunks 16.9 ms, about half of it the refused pointer attempt. The old
  host-fence bind waited 1.26 s behind queue-0 work on RADV 26.0.8.
2026-10-12 11:33:41 +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