Commit Graph
1050 Commits
Author SHA1 Message Date
Anees Iqbal a96bd76fef Keep a draw's shape across scissor rectangle changes
A render encoder's draw takes its settings, draw state and VkPipeline from
its shape memo while the encoder's state keeps its version. Setting a
scissor rectangle took the state mutably, so a program that sets one before
each draw, as a window compositor does, derived every draw's shape again:
settings, draw state, and the pipeline lookup by key.

The scissor rectangles now live beside the versioned EncoderState
(render_state::ScissorRects). No piece of a draw's shape reads them but its
draw state's Vulkan scissors, which each draw now sets from the rectangles
it finds, on a draw state it derives or reuses. The commands recorded are
the same: each draw records its own scissor as before.

Verified: a device test (draw_shape_notices::
draws_after_new_scissor_rectangles_reuse_shapes) draws 8 times through 8
rectangles and finds 7 draws reusing their shape and 8 scissors recorded;
with the version bump put back into set_scissor_rect it fails (0 reused).
render_state unit tests and the draw_shape_notices device tests pass on
MoltenVK (M3 Max).

Release, the per-draw repro on the M3 Max over MoltenVK, flat out, cache
mode, 3000 buffers: draws_shapes_reused goes from 0 to 13 per buffer (35
draws, 6 passes; the others are the first draw of their pipeline state in
their encoder); every other WorkCounts field per buffer is unchanged. A
draw with its setters p50 4.25 -> 4.12 us, mean 4.63 -> 4.42 us; the draw
call alone p50 3.92 -> 3.79 us (two interleaved rounds each).

(cherry picked from commit 603c78fcb85c5d0a732ec6004028d990e0ec8d64)
2026-11-02 05:16:44 -08:00
Anees Iqbal 5602a82d8a Leave out pass-end work a pass of one instance that records now never reads
Three pieces of a render encoder's end that ran at every pass for what only some passes read:

- `shadows::plan` made, before its first instance, the uses of the attachments but the colors
  an instance bounds its writes of, and those colors' target uses and usage shadows: read only
  by an instance that bounds its writes by its draws' scissors, one after the pass's first. A
  pass of one instance never does. They are made now at the first instance that does
  (`BoundedWrites`), from the same layout, so its plan is the same. Each error they could
  return is one `attachment_uses` returned first, over the same targets.
- The pass's shadows' truths (`shadows::pass_shadows`), which a pass that records later holds
  for its executions, were gathered at every pass with a shadowed texture. Only a pass with an
  execution, a pending draw or a tile dispatch can record later; others gather none.
- An encoder's summary (`EncoderUses::finish_parts`) flattened its tracked uses and sorted them
  all by key, stably. A resource's uses are one list, so it now sorts the resources' keys,
  each once, and lists each resource's uses in the order recorded: the same order as before.

A compositor-shaped command buffer (35 draws in 6 passes) on the M3 Max over MoltenVK,
release, flat out, cache surfaces; `end_encoding` against the draws of the same run (the
host's speed moved both by up to 30% from run to run), median of 7 runs each:
p50 ratio 1.207 before, 1.098 after (about 9% less `end_encoding`). A probe build timed the
pieces at about 145 ns (`shadows::plan`'s setup), 50 ns (the truths) and 400 ns (the summary,
its sort included) per pass end before.

Verified: runtime unit tests (tracker, shadows, clear_reach); a new tracker test holds a
summary's order (resources by key, each one's ranges in recorded order) and passes before and
after the change.

(cherry picked from commit a5a8ddf96f1beeeb71e7d9d5708ba2164e143f1b)
2026-11-02 04:58:15 -08:00
Anees Iqbal 101fb7f653 Hold the tile counts' note to its unit test, which a plain test build reads
The thread's note of the tile counts a pass end works out (`clear_reach::made`) was read only
by the device test, so a test build without the device cfgs warned that `so_far` is unused.
The count's unit test now checks that each count is noted, one per call.

Verified: `clear_reach` unit tests pass with no warning in the plain test build.
(cherry picked from commit efc3c67b463d9565576fa439e00ee0c86b92117a)
2026-11-02 04:58:15 -08:00
Anees Iqbal 089bbdfb87 Count a pass's tiles only where a count or a clear reads them
A render pass's end worked out two things about the tiles its draws reach at every pass,
whatever read them:

- the count of the 32-pixel tiles its draws' scissors cover against their bounding rectangle
  (`DrawnArea::covered_tiles`), computed at every pass's first instance before `count_colors`
  looked for a shadowed color attachment, where it feeds only
  `shadow_attachment_tiles_covered` and `_bounded`, counted for a shadowed color the pass loads
  within its draws' scissors; and
- the grid of the tiles the draws reach (`DrawnArea::tiles`), made at every pass whose draws
  reach the tiles their primitives touch, where only a `DontCare` load given a clear reads it
  (`ReachClears::plan`); elsewhere only whether it is empty mattered.

Now `count_colors` counts the tiles at the first shadowed color loaded within, once a pass;
the pass end asks whether the rectangles reach any tile with a scan of them
(`DrawnArea::reaches_no_tile`, no grid made) and makes the grid only for a `DontCare` load it
answered. The count itself goes by bands of rows between the rectangles' edges, setting a row's
tiles a word at a time, where it went row by row and tile by tile. The counters keep their
meaning and their values; the commands recorded are the same.

A compositor-shaped command buffer (35 draws in 6 passes, one 3840x2400 framebuffer pass) on
the M3 Max over MoltenVK, release, flat out, cache surfaces (no shadowed attachment), two
interleaved runs of 5000 buffers each:

  end_encoding p50/p95/mean us: before 6.71/33.67/11.36 and 7.75/43.50/13.18,
                                after  5.75/7.79/5.94  and 5.96/7.83/6.05

The count was 49% of `end_encoding`'s CPU samples before. The work counts per buffer are the
same, with surfaces over host pages too (`shadow_attachment_tiles_bounded` 2597, `_covered`
2308 per buffer, as before).

Verified: `clear_reach` unit tests, the count checked against tiles counted one at a time over
200 sets of rectangles, and the scan against the grid; a device test
(`tests/pass_end_tiles.rs`, `--cfg m2v_gpu`, MoltenVK) counts the tile work done on the
encoding thread: none for a pass with no shadowed attachment, loaded or cleared, one grid for a
`DontCare` load, one count for a shadowed attachment it loads. With the eager work put back the
test fails (covered 1, grids 1 for the loaded pass).

(cherry picked from commit 8f62289f04f367e88e369e6351485d3b69819f71)
2026-11-02 04:58:15 -08:00
Anees Iqbal ddccbfac5a Bump RUNTIME_VERSION to 1722 for ASTC passes, storage slots and 4x2 and 8x4 footprints
What: RUNTIME_VERSION 1721 -> 1722; the runtime-sources pin recomputed on this tree
(3314ddbb...); api_signatures.tsv blessed (Degradation::AstcStorageNeutral and
PlanDiagnostic::AstcStorageNeutral added); docs/CONFORMANCE-COVERAGE.md regenerated (one ledger
row fewer, one more module declaring a notice); `cargo fmt` of the footprint case's allowance.

Why: a run of an unchanged artifact and plan now does something else: a pass over an ASTC
attachment drops it instead of refusing, a storage slot over an ASTC texture binds a neutral and
announces `astc-storage-neutral`, and the 4x2 and 8x4 footprints make textures. docs/REFUSALS.md
and docs/METAL-COVERAGE.md regenerate unchanged.

Verified: `signatures.py --bless`, `refusal_surface.py`, `metal-coverage/coverage.py --check`,
`conformance-coverage/coverage.py` on this tree (rebased onto fbc086020f).

(cherry picked from commit a37ab781870cf9d3c1e9672026f9773f3f6dfdf2)
2026-11-02 02:17:10 -08:00
Anees Iqbal 253dedccc3 Drop ASTC attachments from passes and bind a neutral at ASTC storage slots
What: on every device and for every ASTC form (LDR, sRGB, HDR, every footprint, in its own block
or in a carrier):
- a render pass drops an ASTC color attachment that resolves nothing (`render_pass::layout`): it
  loads, clears and stores nothing into it, its level's extent still bounds the pass, and the
  pass's other attachments run as they would. No notice: that is Metal's answer.
- a draw or dispatch binding an ASTC texture at a storage slot binds the slot's neutral
  (`PlanDiagnostic::AstcStorageNeutral`): its writes leave the blocks as they were, its reads
  answer zero. The runtime announces the new `astc-storage-neutral` (precision) once, catalogued
  in docs/API.md, its lane site `ASTC_STORAGE`.
A render pipeline of an ASTC color attachment stays refused (Metal ends the process), as do a
resolve of an ASTC attachment (unmeasured), 1D and multisampled textures and another footprint's
view.

Why: the runtime answers plain Metal, not its validation layer. Plain Metal (an M3 Max under
macOS 27.0.1, probe `astc_passes_writes_footprints`) completes such a pass for every load and
store action, with a draw and without, leaving the blocks unchanged and the other attachment as
without it; it completes a kernel's `write` and `read_write` and stores bytes no format defines
into the blocks (`read_write` reads their decode). No Vulkan format of a block is an attachment's
or a storage image's, so the pass drop is exact and the neutral differs, announced.

Tests that fail before: the translator's `a_stand_in_compile_is_the_compile_of_its_formats_bind_
and_no_other` (every ASTC format at a storage slot plans the neutral with the diagnostic); the
runtime's `degradation_sites` closure (a lane site for the kind); the lane's
`runtime_lane::astc_passes_and_writes`: every one of the 48 ASTC formats at color 0 of four
passes (clear and store, load and draw, dontcare both and draw, clear and draw) with an RGBA8
color 1: the blocks unchanged and color 1 the pass's without the attachment (192 passes); a
pipeline of an ASTC attachment refused; every format bound to `write` and `read_write` kernels:
blocks and texels unchanged, `astc-storage-neutral` announced once.

Verified: MoltenVK lane on the M3 Max, `runtime_lane::astc*` 9 of 9 (192 passes, 96 dispatches);
runtime touched tests.

(cherry picked from commit 68a296589040b208634abd7b8dfa6ce938cf8c96)
2026-11-02 02:17:10 -08:00
Anees Iqbal e972337dd8 Hold ASTC's 4x2 and 8x4 footprints in a carrier with a decoded twin
What: the six ASTC formats of Apple's 4x2 and 8x4 footprints (LDR, sRGB, HDR), which no Vulkan
format holds, are made on every device as the other ASTC formats are on a device without ASTC:
their blocks in the 16-byte carrier (BC7, BC3, BC2, BC5, ETC2 or EAC; one ASTC block over 4 x 4
carrier texels whatever its footprint), their reads through a decoded twin of 8-bit codes (LDR,
sRGB) or halves (HDR). `AstcDecode::of` takes every footprint from `metal::format::block_extent`;
the format table maps them decoded-only (no direct format); the footprint module answers 26
formats now, and the heap size query takes the modelled ASTC block layout for them. Copies map
regions in blocks (`copy_plan::block_bytes`), a partial last block as Metal rounds it.

Why: plain Metal makes every such texture (2D, 2D array, cube, 3D; Shared and Private; read,
write, render-target usage) and copies them in whole blocks, the last ending at the level's edge
(probe `astc_passes_writes_footprints`). The orchestrator's brief suggested an uncompressed
16-byte-texel carrier; the existing compressed carrier already holds any 16-byte block per 4 x 4
carrier texels, so it serves every footprint with the decode passes, CPU decodes, second twins
and copy paths the other ASTC formats use, with no new image kind.

Tests that fail before: the translator's format tests (`astc_4x2_and_8x4_are_named_and_read_
through_their_twin`, counts and twins), the decode digests of 4x2 and 8x4 against Metal's
(`astc_decode` tests, HDR coverage), the runtime's image-plan, heap and pixel-format tests, and
the lane: `runtime_lane::astc_textures` and `astc_hdr_textures` now take every footprint (32 LDR
and sRGB, 16 HDR), the round trip at every level and slice 4x2 and 8x4 (partial blocks at 37x23
and 29), the colour-space views 4x2 and 8x4. The conformance case
`format-footprints-astc-4x2-and-8x4` now makes and round-trips them: its ledger row (the refusal)
is gone and it declares the three notices the carrier announces.

Verified: translator and runtime touched suites; MoltenVK lane (`runtime_lane::astc*`, 9 of 9 on
the M3 Max); conformance replay on MoltenVK of the footprint case and the ASTC cases, compliant
(the footprint case announced, every byte Metal's); lavapipe replay: every byte Metal's, the
notices undeclared before this commit's declaration.

(cherry picked from commit 2a8dd25c6b9d4cc62ff79816fa61d984969b3c22)
2026-11-02 02:17:10 -08:00
Anees Iqbal 6d884c633d Probe what plain Metal does with ASTC passes, kernel writes and 4x2 and 8x4 footprints
What: conformance/probes/astc_passes_writes_footprints.m, one case a process: render pipelines of
every ASTC colour attachment format (each in a child process), passes over an ASTC attachment for
every load and store action with a draw and without, kernel `write` and `read_write` of ASTC
textures, texel digests of seeded blocks of Apple's 4x2 and 8x4 footprints, partial-block copies
(replaceRegion, getBytes, blits) and texture creation per type.

Why: the runtime refused passes into and kernel writes of ASTC textures as Metal's validation
stops them, and held no image of the 4x2 and 8x4 footprints. Plain Metal's answers decide what
the runtime does instead.

Measured on an Apple M3 Max, macOS 27.0.1, without MTL_DEBUG_LAYER:
- a render pipeline of any ASTC colour attachment (LDR, sRGB, HDR, every footprint tried) ends
  the process;
- every ASTC format, 4x2 and 8x4 included, makes 2D, 2D array, cube and 3D textures, Shared, with
  read, write and render-target usage;
- a pass over an ASTC attachment completes for every load (clear, load, dontcare) and store
  (store, dontcare), with a draw and without: the blocks stay as they were and the other
  attachment is cleared and drawn as without it;
- a kernel `write` completes and changes the blocks to bytes no format defines, the same for
  the same value; `read_write` reads the blocks' decode and answers the right size;
- a copy's region rounds out to whole blocks, its last block ending at the level's edge, the 4x2
  and 8x4 footprints as the others, blits too;
- the texel digests of seeded 4x2 and 8x4 blocks (LDR, sRGB, HDR), with 4x4 and 8x8 controls that
  match the committed digests.

(cherry picked from commit 287319c428d63f8ad849c0d7c4104a85b81e64d2)
2026-11-02 02:17:10 -08:00
Anees Iqbal f7ae5be869 Bless the golden rows of the wsm_samples fixture
The multisampled word lane's owned fixture (wsm_samples: a fullscreen
vertex, a per-sample fill, and two kernels reading every sample as
floats and as a view's words) joins the engine fixtures' golden tables:
its air_input printout (tests/air_input/wsm_samples.txt), 8 rows of
golden_hashes.tsv and 8 of public_fixture_expectations_engine.tsv (its
.ll and .air.ll forms, four functions each). wsm_fill is refused
SampleRateShading on the one profile without it, as every
[[sample_id]] fragment is.

Blessed on the tree rebased onto 9193d3e09f with
PATH=/opt/homebrew/opt/llvm/bin:$PATH by bless_engine_goldens,
bless_golden_hashes and bless_engine_inventory. git diff -U0 shows only
additions, every one a wsm_samples row: nothing moved or was removed.
Verified after: engine_fixtures_match_their_golden_printout,
inventory_lists_every_fixture_in_order, golden_hashes_match_the_table,
public_fixtures_engine::llvm_as::part_1_of_8 and metal_as::part_4_of_4
pass.

(cherry picked from commit fbc086020faa1881132b0921b71933ab6fdbe4f2)
2026-11-02 01:32:20 -08:00
Anees Iqbal 1210972f03 Hold multisampled word-format textures in their word's format
Metal makes 2- and 4-sample textures of R8Unorm_sRGB (11), A1BGR5Unorm
(41), ABGR4Unorm (42) and RGB9E5Float (93) for every usage, memoryless
included (our probe msaa_word_formats.m, M3 Max, macOS 27.0.1). The RTX
5080 samples these formats but renders none, so Vulkan states one
sample for their images and the runtime refused each at creation
(TextureSampleCount, FramebufferColorSampleCount(4)).

What changes:
- image_plan::word_samples: where the device samples the format, renders
  it at no count and renders the word's format (R8_UINT, R16_UINT,
  R32_UINT), a multisampled texture's image is the word's format,
  mutable to the format's sampled view (and an 8-bit sRGB format's UNORM
  twin, for its resolve). Every sample holds Metal's word by
  construction: the existing word lowering writes it, clears write
  Metal's clear word, reads decode through the format's view, copies are
  bitwise. Shader writes stay unavailable (Metal writes no multisampled
  texture from a function). A device that renders the format keeps its
  native image.
- The resolve of such an attachment is the crate-owned one: Metal's for
  RGB9E5Float and 8-bit sRGB, a near-equivalent within one code for the
  packed formats, announced as the new Degradation::WordResolve
  (word-resolve). The NotImplemented(Format) refusal of word resolves in
  resolve.rs is gone; an attachment that takes neither input attachment
  usage nor the copy is still refused.
- DeviceOptions::withheld_attachment_formats (doc hidden, a test hook):
  a device made with formats' color attachments withheld, so the word
  path runs on MoltenVK, which renders all four.
- RUNTIME_VERSION 1721. Docs: API.md (word bullets, the multisampled
  word paragraph, the word-resolve catalogue entry), FAST-PATHS known
  gaps (word resolves no longer refused), word.rs, image_plan.rs and
  resolve.rs module docs; runtime-sources pin recomputed.

Routes over the committed profiles (tests::word_samples, pinned): the
word for all four formats at 2 and 4 on NVIDIA's three profiles, for
R8Unorm_sRGB and RGB9E5Float on ANV's four, and RGB9E5Float at 4 on the
gate's lavapipe; native on MoltenVK and RADV; refused where the word's
format renders one sample or the textures take no such count
(swiftshader, lavapipe's profile, the floors).

Verified:
- cargo nextest run -p metal2vulkan-runtime --all-features: 1188 pass
  (the three word_samples planning tests among them).
- Device lane runtime_lane::word_samples_msaa on the M3 Max through
  MoltenVK (--cfg m2v_gpu, maclock), new owned fixture wsm_samples: the
  device as it is (each format natively) and with the four attachments
  withheld (each held in its word, printed per format). On the word path
  every stored sample is Metal's word (all 32 or 64 per shape), reads
  decode them, the sRGB and RGB9E5 resolves are Metal's in every pixel,
  the packed resolves within a code (7-9 of 16 pixels exact after a
  draw, 13-16 after a load), a packed blend's words Metal's in every
  sample. word-resolve and shader-resolve announced. Negative control:
  with word_samples disabled the lane fails.
- clippy -D warnings (default and --cfg m2v_gpu), rustdoc -D warnings,
  private intra-doc links at their ceilings, refusal_surface --check,
  api_signatures --bless (DeviceOptions field, Degradation::WordResolve
  added), METAL-COVERAGE and CONFORMANCE-COVERAGE --check current.

Not in this change: the golden tables for the new fixture
(golden_hashes, the engine inventory, the air_input printout) are
re-blessed on development. Blends of an 8-bit sRGB or RGB9E5Float word
stay refused as the device lacking the format, as they are at one
sample.

(cherry picked from commit ad8b94cd840f3d0bf4bb9552904fbdf2f253b9af)
2026-11-02 01:32:20 -08:00
Anees Iqbal e86fa9b98f Resolve a word attachment's samples by Metal's rules
The crate-owned color resolve gains word forms (ColorResolveFormat::word):
a multisampled attachment held in its word's format (R16_UINT for the
packed 16-bit formats, R32_UINT for RGB9E5Float) is resolved from the
stored words, since no device's AVERAGE reads them as the format.

- RGB9E5Float: each channel's samples decoded, summed in float, scaled
  by 1/n, rounded to the nearest half (ties to even), then encoded with
  the mantissas rounded half up (the exponent raised where one reaches
  512). Metal's resolve, measured with our probe msaa_word_formats.m on
  an M3 Max under macOS 27.0.1: 256 of 256 pixels at 2 and 4 samples,
  in a drawing pass, a loading pass and after a blend.
- Packed 16-bit: each field's mean of the codes, a tie rounded down (a
  one-bit field's up). Metal averages its tile's halves, finer than the
  codes, so this is a near-equivalent (exact() is false): Metal's code
  in 90-99% of the channels a loading pass resolves, 74-88% of a
  drawing pass's, within one code everywhere; alike samples exact.
- An 8-bit sRGB word has no word form: it resolves by the sRGB rules of
  its format through its UNORM twin's views (the runtime's side).

Verified: cargo nextest run -p metal2vulkan --all-features -E
'test(/color_resolve/)' (24 pass; word_tests checks the modules
validate and need nothing of a device, the shared-exponent rule against
the probe's measured vectors and a model over random words, and the
packed rule per field). api_signatures.tsv takes the two new methods.

(cherry picked from commit 3c3681c8decdd166454b9779bfe1be0c1936f898)
2026-11-02 01:32:20 -08:00
Anees Iqbal a7672e9864 Lane-test ASTC HDR textures against Metal's decode on the device
New runtime_lane::astc_hdr_textures (any(m2v_gpu, m2v_cpu_icd)):

- astc_hdr_texels_read_as_metal_s: each of the fourteen _HDR formats,
  natively where the device holds its SFLOAT block, else through the
  carrier and twin. A new texture's zero blocks, then blocks from a CPU
  copy, a blit from a buffer, a fill of an HDR void-extent block and a
  copy from another texture: every texel's read and nearest sample
  compared with the decoder's Metal values (exact, NaN as NaN) where
  the twin carries them or the device samples through Metal's own
  texture unit; get_bytes and a blit into a buffer give the blocks
  back unchanged. It counts the decode passes, asserts
  carried-decoded-twin was announced exactly for the carried formats
  and decoded-texel-precision never, and prints which route ran.
- astc_hdr_textures_of_every_usage_are_made: an ASTC8x8HDR texture of
  read, write, render-target and pixel-format-view usage is made; a
  render pass into it is refused Unsupported and a kernel's write of it
  refused typed (Bind or Unsupported), where Metal's validation stops
  both; a view in the LDR form is refused on a carrier and otherwise
  reads the LDR decode of the same blocks.

The ASTC LDR lane's helpers it shares become pub(super).

Verified (which path each ran, from the lane's printed route line):
- MoltenVK on the M3 Max (--cfg m2v_gpu, through the GPU lock and
  memcap): both pass; 14 formats in their own block, Metal's sampler.
- lavapipe (scripts/linux-gate, --cfg m2v_cpu_icd): both pass; 0 in
  their own block, 14 in a carrier.
- The other five ASTC lanes pass on both devices.

(cherry picked from commit 9193d3e09fc1e0366e55035fcb29a81b9245ffe5)
2026-11-02 01:09:01 -08:00
Anees Iqbal 7130d5d6e7 Make ASTC HDR textures where Metal makes them: native, else a carrier with a twin of halves
Metal on an M3 Max (macOS 27.0.1) makes every 2D ASTC HDR texture
(MTLPixelFormat 222-236) with read, write and render-target usage; the
runtime refused them on every device without the Vulkan SFLOAT block
(the RTX 5080 among them) as a format it cannot hold.

- Translator: bind::AstcDecode decodes the HDR profile, written from
  the Khronos Data Format Specification's ASTC chapter (new hdr.rs):
  HDR endpoint modes 2, 3, 7, 11, 14 and 15, the LNS-to-half mapping,
  LDR modes and void-extent blocks in an HDR texture, and the HDR
  void extent, on the CPU and in the GPU decode kernel (kernel/hdr.rs).
  Where the probe showed Metal's own answer it is the one taken: an
  LDR channel in the HDR profile is C/65536 truncated to a half (1 for
  65535); a void extent's NaN halves read as the quiet NaN; an error
  block reads NaN in every channel. Public API: AstcDecode gains `hdr`,
  AstcTexels gains `Half` (R16G16B16A16_SFLOAT), AstcDecode::form picks
  a profile's compact form, and AstcDecode::texel_bytes is now a method
  (a consumer calling AstcDecode::texel_bytes(texels) writes
  decode.texel_bytes(texels)); api_signatures.tsv blessed.
- Format table: each ASTC HDR format takes its ASTC_*_SFLOAT_BLOCK
  where the device holds it (the device's decode, rule 1), else
  FormatEmulation::Decoded over R16G16B16A16_SFLOAT.
- Runtime: such a texture is the existing carrier (its 16-byte blocks,
  which copies and getBytes move unchanged) and a decoded twin of
  Metal's halves, exact, kept in step by the same GPU and CPU decodes;
  a new texture's twin starts at the error block's NaN. Notices:
  carried-decoded-twin and cpu-block-decode, as for ASTC LDR; no
  decoded-texel-precision (the halves are Metal's). A view in another
  profile (an HDR texture's LDR or sRGB view, or the reverse) is
  refused on a carrier (Feature::TextureView, as another footprint
  is); render passes into one and kernel writes of one stay refused
  typed (the Vulkan formats take neither), where Metal's validation
  stops each.
- Docs: API.md's carried-decoded-twin entry, FAST-PATHS known gaps,
  module docs of bind::astc_decode, astc.rs and decoded_twin.rs.
- Conformance: the 42 ASTC cases now name the twin notices for HDR rows
  too, and the decoder cross-check holds Metal's recorded HDR reads.

Versions: RUNTIME_VERSION 1720 (an HDR texture is now made and read
where it was refused). No SEMANTICS_VERSION or ARTIFACT_FORMAT_VERSION
bump: translation output is unchanged (the Decoded candidate admits
sampling usages only, so no pipeline's format answer moves) and no
encoded artifact carries AstcDecode. Runtime-sources pin recomputed.

Verified:
- CPU decode bit-exact against Metal for 2048 seeded blocks of each of
  the fourteen footprints (every endpoint mode, partitions, dual plane,
  void extents, error blocks), as float and half reads and nearest
  samples (probe `reads`), checked by per-footprint digests and a
  66-block fixture of Metal's float bits (bind::astc_decode::tests::hdr);
  the GPU kernel equals the CPU decode on every texel; the kernels are
  valid on every committed profile; the conformance suite's recorded
  astc-*-hdr reads equal the decoder's.
- Plans: moltenvk-m3 native for all 14; nvidia-rtx5080-laptop,
  lavapipe, amd-780m-radv and intel-arl-anv in a carrier
  (runtime tests::image_plan).
- conformance replay of the 42 ASTC cases on lavapipe (linux-gate,
  --cpu): the 14 HDR rows `announced` (texels exact, carried-decoded-
  twin and cpu-block-decode fired), exit 0; on MoltenVK the 14 HDR rows
  `exact` with no notice.
- Touched tests in metal2vulkan, metal2vulkan-runtime,
  metal2vulkan-conformance; clippy (plain and --cfg m2v_gpu);
  refusal_surface --check, both coverage docs current; private
  intra-doc link loop at its ceilings.

(cherry picked from commit eb6828adddde978fab87dc7d05ea1a2a55738008)
2026-11-02 01:09:01 -08:00
Anees Iqbal 69f4ad114c Probe what plain Metal does with ASTC HDR textures
A from-scratch Objective-C probe of MTLPixelFormat 221-236 (the _HDR
form of every footprint), one case a process:

- create: which descriptors make a texture, by texture type, storage
  mode and usage (ShaderRead, ShaderWrite, RenderTarget, all three);
  each descriptor in a child process, since Metal ends the process at
  some (1D and multisample compressed textures) even without
  validation.
- reads: each texel's read as float4 and as half4 and its nearest
  sample of self-encoded blocks written by replaceRegion, through an
  optional view of another raw format.
- zero, bytes: a new texture's texels; getBytes and blit round trips.
- render, write: a pass storing a clear and a draw into one, and a
  kernel writing one, and what the blocks hold after.

Measured on an Apple M3 Max, macOS 27.0.1, run through the Mac GPU
lock without MTL_DEBUG_LAYER. The answers are stated in the module docs
the following commit writes (bind::astc_decode, the runtime's astc.rs):
every 2D HDR texture is made with read, write and render-target usage;
reads are half-precision values, exact as float and as half; render
passes and kernel writes are stopped by Metal's validation, and plain
Metal's pass stores nothing while its write leaves bytes no format
defines.

(cherry picked from commit b5e51a65272a2f5db0e73dc50070082054d3e064)
2026-11-02 01:09:01 -08:00
Anees Iqbal 498163f1ad Mend two private doc links this effort broke
CI's private intra-doc link step holds each crate to its ceiling; the lane
was over two of them.

- metal2vulkan-air (4, ceiling 3): `const_taint`'s doc linked
  `entry_block_refusal`, which the undefined-constant change removed. It
  now names `Solver` alone, its one user.
- metal2vulkan-runtime (71, ceiling 70): a redundant explicit target on
  `Problem::UnspecializedFunction` in `Library::new_function_with_name`'s
  doc, added with the by-name refusal.

Verified: the step's loop run locally over all six crates (rustdoc
--document-private-items, -Dwarnings): metal2vulkan 0, air 3, runtime 70,
validation 0, conformance 0, devtools 0, each at its ceiling. The
runtime-sources pin covers both files: recomputed (7f8ad7d3) and
the_runtime_sources_are_the_committed_ones passes.

(cherry picked from commit 7da81ee3d8a80992e65167ff1d2c315bd10715c6)
2026-11-01 23:38:40 -08:00
Anees Iqbal 4aac27a548 Ask supportsPullModelInterpolation in the lane's query census
runtime_lane::capabilities asks every Query::ALL member of the lane's
device and panicked on Query::PullModelInterpolation, a query it did not
ask. It now asks it, as it asks supportsSamplerReductionMode: an answer,
no gap.

Verified on the M3 Max (MoltenVK 1.4.2) through the Mac GPU lock,
--cfg m2v_gpu: runtime_lane::capabilities, msaa_32bit and
pull_model_interpolation 8/8.

(cherry picked from commit a27c863842433fa94ee6ece8ffebd5db2e880077)
2026-11-01 23:38:40 -08:00
Anees Iqbal b2625d5688 Name GraphicsState::interpolates_at_sample's source without a private link
The field's doc linked crate::pipeline::Sampling::Interpolant, which is not
public (pipeline::stage_io is crate-private), so public rustdoc failed on a
broken intra-doc link. The doc names the stage interface's sampling in
plain code instead.

Verified: RUSTDOCFLAGS='-D warnings' cargo doc -p metal2vulkan -p
metal2vulkan-air -p metal2vulkan-runtime --all-features --no-deps is clean;
the runtime-sources pin is unchanged (pin-compute.py).

(cherry picked from commit 313d45dc1cf18685f5d0efd9722e3ceb98fc3796)
2026-11-01 23:38:39 -08:00
Anees Iqbal 81441ca877 Regenerate the surfaces for pull-model interpolation
- RUNTIME_VERSION 1719: the runtime answers supportsPullModelInterpolation
  and refuses a draw reading an interpolant at a sample at custom positions.
- scripts/metal-coverage/coverage.tsv: supportsPullModelInterpolation
  implemented (DeviceProperties::supports_pull_model_interpolation);
  docs/METAL-COVERAGE.md and docs/CONFORMANCE-COVERAGE.md regenerated.
- docs/REFUSALS.md regenerated: feature::PullModelInterpolation and
  gap::InterpolateAtSampleWithPositions (reach rows in reach.tsv).
- crates/metal2vulkan/tests/api_signatures.tsv blessed: additions only but
  Query::ALL's length (8 to 9) and value.
- crates/metal2vulkan-runtime/README.md: the query and what differs.
- runtime-sources pin recomputed (pin-compute.py).

Verified: refusal_surface.py --check, signatures.py --check,
metal-coverage --check and conformance-coverage --check all current.

(cherry picked from commit 2dcbbf39b6e5caeb3e87079d7f2f36540ceb0dd0)
2026-11-01 23:38:39 -08:00
Anees Iqbal a8af53b32a Answer supportsPullModelInterpolation and refuse sample reads at custom positions
The runtime had no answer for supportsPullModelInterpolation (the M3 Max, a
Radeon Pro 5300M and a UHD 630 answer 1), so the consumer passed none.

- DeviceProperties::supports_pull_model_interpolation (Query::
  PullModelInterpolation) answers yes where the compile layer lowers every
  interpolation function: DeviceProfile::interpolation_function_needs is
  empty (sampleRateShading, and MoltenVK's
  shaderSampleRateInterpolationFunctions), the same predicate the lowering
  refuses by.
- A draw at custom sample positions through a pipeline whose fragment
  function reads an interpolant at a sample
  (GraphicsState::interpolates_at_sample) is refused
  NotImplemented(RuntimeGap::InterpolateAtSampleWithPositions) in
  settle_draw, which direct and indirect-command draws share: Vulkan takes
  no InterpolateAtSample in a pipeline made with custom sample locations
  (VUID-VkGraphicsPipelineCreateInfo-sampleLocationsEnable-01524), and
  Metal's answer there is not measured.

Tests:
- runtime tests::capabilities: every committed profile answers from the
  enabled features; every venue (moltenvk-m3, both lavapipe gates, 780M
  RADV, both ANV, RTX 5080) answers yes; vk12-floor no; moltenvk-m3 without
  the portability member no; every query answers on moltenvk-m3.
- validation runtime_lane::pull_model_interpolation (--cfg m2v_gpu or
  m2v_cpu_icd): the probe's lane draws (one triangle of w 1, 2, 4 over 6x6,
  at 1 and 4 samples: center, centroid, each sample, sample_id, five
  offsets, the float2/float/half and half4 interpolants) against Metal's
  reading pull_model_interpolation_m3_max.txt, every sample's coverage
  equal; word for word where the profile takes MetalInterpolation, else
  within the device's interpolation plus the location Vulkan leaves to it;
  the offset pipelines alone record DeviceInterpolationOffset and require
  the device's origin property. A pm_sample draw at custom positions is
  refused; a pm_offset draw there runs.

Verified on the M3 Max (MoltenVK 1.4.2, macOS 27.0.1) through the Mac GPU
lock: 25 draws, 14 samples at 1x and 55 at 4x each, every word Metal's
(most apart 0); the refusal and the offset draw at custom positions as
stated. Negative control: the MoltenVK origin set to 1/2 put every offset
draw 0.06 to 0.11 off Metal's. Not run on lavapipe here (no container
runtime up); CI's lavapipe lane runs it. Runtime capabilities, degradation
and families tests 47/47; clippy all features and --cfg m2v_gpu.

(cherry picked from commit e9f45f7c85309ba6d1e6bc57f3b10fd47585893e)
2026-11-01 23:38:39 -08:00
Anees Iqbal ef7a8d6f08 Lower Metal's pull-model interpolation (interpolant inputs)
A fragment function reading an `interpolant<T, P>` input through
interpolate_at_center, _centroid, _sample or _offset was refused as invalid
input (the AIR key air.interpolation_function was unknown), so a guest whose
device answers supportsPullModelInterpolation could not run one.

AIR: the key marks a fragment input `Sampling::Interpolant`, a device-space
handle (`AbiHandle::Interpolant`); `air.interpolate_{center,centroid,sample,
offset}_{perspective,no_perspective}.{f16,f32 x1..4}` parse as
`AirIntrinsic::Interpolate`, decided from the intrinsic family and the
metadata ABI, never names.

Lowering: the interpolant is a float Input variable of its form (NoPerspective
where not perspective), read only through its calls:
- center: as a center varying is read (its pixel-center form at more than
  one sample where the device has one);
- centroid / sample / offset: GLSL.std.450 InterpolateAtCentroid,
  InterpolateAtSample (index & (SampleCount - 1), Metal's i mod n) and
  InterpolateAtOffset (offset moved to the device's origin and NClamped to
  [minInterpolationOffset, maxInterpolationOffset], which Vulkan requires).
  These need sampleRateShading (and MoltenVK's portability member): without
  them the function is refused Unsupported(PullModelInterpolation).
- MoltenVK's SPIRV-Cross hands InterpolateAtOffset(v) to Metal as
  interpolate_at_offset(v + 7/16): such a device gets the new
  VkProperty::InterpolateAtOffsetFromSevenSixteenths and the module moves
  the offset by 7/16 (a module annotation picks the property).
- An interpolant used any other way (a select of two) stays
  NotImplemented(PullModelInterpolation); on RADV
  (InterpolationNeedsTheWholeQuad) a sample or offset read after a discard
  or outside the first block is refused; lavapipe refuses a multisampled
  centroid read as it refuses a centroid varying.
- GraphicsState::interpolates_at_sample states a fragment stage that reads
  at a sample (Vulkan takes no InterpolateAtSample with custom sample
  locations); Sampling::Interpolant carries center/centroid/sample.

Metal measured on the M3 Max, macOS 27.0.1, with the new probe
probes/pull_model_interpolation.m over the owned fixture
pull_model_interpolants (cases origin, grid, samples, centroid, lane): an
offset is read from the pixel's corner as given, no range, no grid, NaN for
a non-finite one; sample i reads i mod n at Vulkan's standard positions;
centroid is the center when the pixel is covered whole, else the lowest
covered sample. The offset's range and grid are the device's:
PrecisionNote::DeviceInterpolationOffset (validation: Recorded), in
docs/API.md's catalogue and FAST-PATHS.md's device gaps; a centroid read
notes MultisamplePosition as a centroid varying does.

Verified: tests::engine_pull_model (309 pipelines over every committed
profile at 1 and 4 samples: instructions, mask's planned SampleCount,
origin, NClamp, note, property, L3; refusals on vk12-floor, RADV after a
discard, lavapipe centroid at 4x; pm_selected refused everywhere),
engine_multisample, engine_fragment, engine_coverage_loop, fast_paths,
api_tests, codec and cache tests, metal2vulkan-air abi/intrinsics tests and
api_surface; runtime degradation and catalogue tests; clippy all features.
Before: every pull_model_interpolants function failed InvalidInput
(Abi(UnknownKey)). Goldens: only new rows and the moltenvk-m3 profile hash
moved (its new property); inventory 24 new rows, 0 moved cells.

SEMANTICS_VERSION 1941 (refusals became translations), ARTIFACT_FORMAT_VERSION
481 (IoSampling, PrecisionNote, VkProperty and GraphicsState encodings).

(cherry picked from commit 70e01b4bd6f8a0d1421ae07ed710714fb4ce985b)
2026-11-01 23:38:39 -08:00
Anees Iqbal ceb666187a Answer Metal's supports32BitMSAA from the device's own textures
The runtime had no answer for supports32BitMSAA (METAL-COVERAGE listed it
missing), so the consumer passed None through. Metal's answer promises a
multisample texture of each 32-bit integer format and the resolve of
each 32-bit float one; the M3 Max, a Radeon Pro 5300M and a UHD 630 all
answer 1.

What the runtime did before was read first: a multisample texture of each
of the nine formats is planned as any texture is (image_plan), within the
device's limits for the image (vkGetPhysicalDeviceImageFormatProperties2),
and refused as a count its format lacks; draws and texture2d_ms reads of
it, the float formats' AVERAGE resolves (Metal's own on MoltenVK,
device-rounded-resolve elsewhere) and the refusal of an integer resolve
(ResolveFormat, as Metal stops it) were all in place. The render
pipeline, sample planes and interleave all take a format's own counts
beside framebufferIntegerColorSampleCounts. Nothing was wrong; the
query was missing.

Device::supports_32bit_msaa answers yes where the device makes every
texture and resolve the answer promises, each probed exactly as
pixel_format_capabilities probes a capability (the probe closure of
families::formats::answers is now a function both share): the texture
sample counts hold 4, a 2D multisample RenderTarget|ShaderRead texture of
each of the nine formats is made at every count above 1 the textures take,
and each float format resolves (its Resolve capability). A device method,
as supports_family is, because it reads the device's per-format limits:
Vulkan floors an integer format at framebufferIntegerColorSampleCounts,
one sample on RADV and lavapipe, while their 32-bit integer formats each
take 1 to 8 (1, 4, 8 on lavapipe), as the venue profiles' captured
per-format counts state.

Tests:
- runtime tests::msaa_32bit: every committed profile pinned, with the
  limits it states (a venue profile's own per-format color attachment
  counts, else Vulkan's floors). Yes on every venue (moltenvk-m3, both
  780M RADV, both gate lavapipe, the ANV and NVIDIA ones) and on the
  Intel and NVIDIA profiles whose floors cover the counts; no on
  amd-rdna2/rdna3-radv, lavapipe, lunarg-desktop-baseline-2023,
  swiftshader and vk12-floor (R32Uint at the lowest count, naming
  FramebufferIntegerColorSampleCount), and roadmap-2022 (no 4 samples).
  A yes agrees with each format's Msaa and float Resolve capabilities;
  the rule needs 4 and every count, and a missing resolve texture says
  so. A negative control that probes 4 samples alone fails two of them.
- validation runtime_lane::msaa_32bit (--cfg m2v_gpu): the answer is what
  the device makes; R32Uint and RGBA32Uint targets at 2 and 4 drawn at
  sample rate hold every bit, read back through texture2d_ms<uint>
  (Metal: every channel as written); an RG32Float 4-sample target keeps
  its samples and resolves to the probe's Metal texels, exact where the
  driver's average is Metal's; an RGBA32Uint resolve is refused.

Verified: runtime tests msaa_32bit, families and capabilities, the
metal_coverage and runtime-sources pin tests; on the M3 Max (MoltenVK
1.4.2, macOS 27.0.1) through the Mac GPU lock, runtime_lane msaa_32bit,
families and capabilities 7/7: supports32BitMSAA true, counts [2, 4],
nothing refused, 0 integer channels differ, 32 of 32 resolved channels
as Metal's, device-rounded-resolve not announced. clippy with all
features and with --cfg m2v_gpu, rustdoc -D warnings, refusal_surface
--check (no refusal moved), api-signatures (one method added),
METAL-COVERAGE and CONFORMANCE-COVERAGE regenerated (the item now
implemented, not yet exercised by the suite).

RUNTIME_VERSION 1718 (a new answer); runtime sources re-pinned.

(cherry picked from commit 2376157b3bf7bf99221579f42a795ef351b8144c)
2026-11-01 22:35:40 -08:00
Anees Iqbal 90622adb95 Probe Metal's 32-bit multisample textures and float resolves
A probe, written from scratch, of what Metal answers behind
supports32BitMSAA, one shape per process:

- query: supports32BitMSAA and supportsTextureSampleCount:.
- make: a 2D multisample RenderTarget|ShaderRead texture of each of the
  nine formats (R32Uint, R32Sint, RG32Uint, RG32Sint, RGBA32Uint,
  RGBA32Sint, R32Float, RG32Float, RGBA32Float) at 2, 4 and 8 samples.
- int-samples: a draw at sample rate writes every sample of an integer
  target (edge words 0x7fffffff, 0x80000000, 0xffffffff, 0x01000001 and a
  hash), read back through texture2d_ms<T>::read.
- float-resolve: a float target drawn the same way with special values
  (order-dependent sums, NaNs with payloads, infinities, a denormal input
  and a denormal average, signed zeros, an overflowing sum) and
  pseudo-random ones, resolved by StoreAndMultisampleResolve or
  MultisampleResolve into a texture of its format, compared with the
  rule runtime_lane::resolve_rounding states.
- int-resolve: an integer target's resolve.

Measured on the M3 Max under macOS 27.0.1, plain Metal through the Mac
GPU lock:
- supports32BitMSAA 1; supportsTextureSampleCount 1, 2, 4 yes, 8, 16 no.
- Every one of the nine formats made at 2 and 4 samples; at 8 Metal stops
  it ("sampleCount (8) is not supported by device").
- int-samples: 0 channels differ from those written, every integer format
  at 2 and 4 (RGBA32Uint at 4 also with MTL_DEBUG_LAYER=1).
- float-resolve: 0 channels differ from the rule (the samples summed in
  order in float from sample 0, denormals flushed to the zero of their
  sign, a NaN anywhere 0x7fc00000), each float format at 2 and 4 under
  both store actions; the stored samples are bit for bit those written.
- int-resolve RGBA32Uint 4: with the validation layer, "PixelFormat
  MTLPixelFormatRGBA32Uint cannot be a MSAA resolve target"; plain Metal
  writes words no sample holds.

(cherry picked from commit f18cf358da5419ceb41896975ad447ea42cff77a)
2026-11-01 22:35:40 -08:00
Anees Iqbal 03264ce9c2 Pace the CPU writer of the copied-log race test
tests::copied_log::a_cpu_write_the_gpu_did_not_make_survives_both_ways_logged_or_not
spawns a thread that writes one byte of the pages and tells the test log of it
in a tight loop, while the main thread runs 2000 rounds of merge back and copy
in. TestLog keeps every write it is told, and each copy in asks it for the
writes since a stamp by scanning them all, so the run time grew with the
square of how far the writer outran the rounds. It took 28 s to 749 s across
recent gates and timed out at nextest's 1200 s limit under an outside load
of about 30 (a sample showed every stack in TestLog::changed's scan).

The writer now sleeps 20 us after each write it tells. Each write is still
told right after it is made, so the last write is always logged, and the
writes still race the copies; the log stays bounded by the test's length.

Verified: the test passes in 0.085 s under a load average of 51, twice.
The runtime-sources pin is unchanged (79fe4b2f).

(Carried to development from steelbrain/reims-graphics-kext 130513884f.)
2026-11-01 21:26:24 -08:00
Anees Iqbal 6f8ec46671 Draw a draw whose own band the translator refuses at the nearest width
A draw whose own band variant the translator refuses where the state's
first band compiled (a varying or push data the draw's variant adds, such
as a shader-side depth test's window depth and depth range, past
maxTessellationEvaluationOutputComponents or maxPushConstantsSize) was
refused with the translator's Unsupported(WideLines). Only its later
draws took the nearest width. That breaks the owner's rule that an
accuracy note is logged and never fatal: the draw can run at the nearest
width.

The draw now takes the nearest width, announced as a state's refusal is
(lines-at-nearest-width, the translator's refusal the reason). The
refusal is still kept per state and primitive (GraphicsState::refuse_band,
two answers a state). A draw's variant key follows from its bind shape,
and its route sets that shape, so a per-key memo would need the shape
before the route. Recording a draw factors what its lines' route decides
(the route, provoking vertex, listed strip, private form, settings) into
RenderLowering::routed_draw and a RoutedDraw. draw_resident settles in a
loop. Where the settle answers the translator's refusal of the draw's band
(LineRoute::refused), it marks the state's primitive refused and routes
the draw again. Routed again it draws no band of the primitive, so it
settles once more at most. settle_draw hands that refusal back to the
caller before its snapshot and shadow retries, as before.

Docs: line_width.rs, the runtime README, FAST-PATHS's known gap, API.md's
and degradation.rs's lines-at-nearest-width (no refusal named any more).
REFUSALS.md does not move (refusal_surface --check passes): the
translator's refusal stays. RUNTIME_VERSION 1717 (a refusal became an
announced draw); runtime sources re-pinned.

Verified: the new pure test
a_draw_whose_band_the_translator_refuses_takes_the_nearest_width covers
every committed profile under both policies, lines and edges, widths 0 to
16. Each band route takes either refusal (not implemented, and the
evaluation-output limit) as its primitive's. Routed again, it is the
nearest width with the refusal as the reason, or the device's lines, and
never a band. A non-WideLines refusal or a runtime gap stands. It does
not compile against be2d725fdb, which had no such decision. A negative
control that drops the decision for lines fails it ("amd-780m-radv,
Device, Lines at 0: left None, right Some(Lines)"). Runtime line_width
tests 4/4 pass. Also clean: clippy with all features and with
--cfg m2v_gpu, refusal_surface --check, the runtime-sources pin test.
Not run: the GPU lane. No draw on MoltenVK reaches this cheaply: the base
key's band and a draw's differ only by shader-side tests' additions or
push data. The orchestrator's gate covers the restructured draw path.

(Carried to development from steelbrain/reims-graphics-kext 06f08298fd.)
2026-11-01 21:26:24 -08:00
Anees Iqbal b3d483fd72 Draw triangles' wide edges as bands, and refused bands at the nearest width
Metal draws a triangle in fill mode Lines at a width other than 1 as its
three edges, each the line parallelogram, facing as the triangle does and
culled by it, its flat inputs from the provoking vertex (the probe's
`edges` case, committed with the lane before this). The runtime drew
those edges with the device's lines, at the nearest width they draw (1
pixel on MoltenVK), announced.

Translator: the band variant takes a primitive (`BandPrimitive`, in
`VariantKey::line_band`, `LineBandState::primitive`, `BindState` and
`BindShape::line_band`). A triangle's patch is its three vertices in the
quad domain at outer levels (11, 1, 6, 1) and inner levels (3, 2): the
inner ring degenerates to a segment, so the spec's deterministic fans
from its two vertices cover the u = 0 and u = 1 edges, and the
evaluation stage places those fans' vertices at the corners of the
edges' parallelograms (from the vertex of the largest w, which never
moves at the near plane), every other triangle degenerate. The band
faces as the triangle (the sign of its homogeneous determinant, a
zero-area one back) by turning the minor axis, so the draw's own cull
mode, front face and depth bias apply. `LineBandState::PATCH_CONTROL_POINTS`
gives way to `BandPrimitive::patch_control_points`. A pure test checks
the fan tables against the spec's triangulation: every triangle is
degenerate or one of the nine that cover the parallelograms once, and
each winds as a line's band, turned by the facing.

Runtime: a triangle's edges (lists, strips, fans, Metal's private
triangle types) route as lines do: the device's lines where they draw
the width, else the band, on every device with tessellationShader;
strips are listed, the last provoking vertex read from the list led by
it. The band's depth bias is the device's per band triangle: announced
(new `Degradation::WideEdgeDepthBias`) under a slope factor or a
constant over a float depth. A pipeline state whose band variant the
translator refuses (barycentric weights, a selected slice or viewport,
synthesized geometry, multiview, too many outputs) now draws its lines
and edges at the nearest width, announced with the refusal as the
reason, instead of failing the draw: the state's first band compiles
the variant of its base key and remembers a refusal per primitive
(`Unrouted::Refused`). Mesh draws and tessellated patches keep the
nearest width. Docs: line_width.rs, band.rs, the runtime README,
FAST-PATHS (row and known gap), API.md (band variant, catalogue),
REFUSALS.md regenerated; api_signatures blessed (BandPrimitive added,
LineBandState::PATCH_CONTROL_POINTS removed, the three line_band fields
now carry the primitive). SEMANTICS_VERSION 1940, RUNTIME_VERSION 1716;
runtime sources re-pinned.

Verified (M3 Max, MoltenVK, --cfg m2v_gpu, maclock and memcap):
runtime_lane::line_widths 7/7 pass under both policies; 148 cases, 145
drawn as Metal's pixel for pixel, 28 of the 31 wide edge cases (facing,
culling, zero-area, strips, flat IDs and primitive IDs at both provoking
modes, depth across an edge, 4 samples), the other 3 the depth-bias edge
cases, announced (two differ from Metal, by slope and by exponent; the
uniform-depth one matches); 93 draws as bands, 0 at the nearest width.
Before this commit the same lane failed 4 of 7 (31 edge cases at the
nearest width, refused bands refused). Also: engine_line_band and the
band's fan tests, golden_hashes_match_the_table and the engine inventory
parts unchanged (no bless), runtime line_width tests (the route table
for lines and edges on every profile under both policies, refused rows),
api_surface, api_signatures, refusal_surface --check, clippy with all
features and with --cfg m2v_gpu, rustdoc with -D warnings.

(Carried to development from steelbrain/reims-graphics-kext be2d725fdb.)
2026-11-01 21:26:24 -08:00
Anees Iqbal 9c83a06f89 Measure Metal's wide triangle edges and check them in the line-width lane
The line-width probe gains an `edges` case: triangles in fill mode Lines
on a 32x32 target, their front- and back-facing fragments counted apart
under each cull mode and winding at widths 0, 1, 2.5 and 4, a square of
two triangles, a strip of three, zero-area triangles and eight scattered
ones; the flat vertex ID and primitive ID each fragment reads, for two
triangles and a strip of two at provoking vertex modes 0 and 1; which
fragments a depth bias passes against a filled triangle and a line, and
the depth across a sloped triangle's edge; and 4 samples at width 2. Its
output on the M3 Max (macOS 27.0.1) is appended to the lane's record.

What it measured: each edge is the line parallelogram with no joins
(overlaps take two fragments); fragments read the triangle's facing and
the cull mode culls by it under either winding; a zero-area triangle is
back-facing; a strip's triangles face alike; flat inputs come from the
provoking vertex and the primitive ID is the triangle's; the depth is
the edge's, constant across the width; the depth bias applies to edges
(not lines) by the triangle's slope and largest depth exponent.

The lane draws every one of those cases with the runtime and compares
the maps pixel for pixel (front and back fragments apart, the IDs from
rt6_provoking's pv_flat third color, the depth tests against a
Depth32Float), adds a test that a triangle's edges at width 4 draw as a
band (or at the nearest width without tessellationShader), and a test
that a pipeline state whose band the translator refuses (pv_weights)
draws at the nearest width rather than being refused.

Verified: the probe ran on the M3 Max through maclock without the debug
layer. The lane, built at this tree with --cfg m2v_gpu and run on the M3
Max (MoltenVK) through maclock and memcap, fails as expected before the
runtime draws edges as bands: 4 of its 7 tests fail. Both policies: 148
cases, 117 matched, the 31 wide edge cases drawn at the nearest width
(edges_matched 0); edges at width 4 took the nearest width, not the
band; the refused-band draws were refused with Unsupported(WideLines).

(Carried to development from steelbrain/reims-graphics-kext 7a1dae2b87.)
2026-11-01 21:26:23 -08:00
Anees Iqbal 54d78d71c8 Test the nearest-width line route and empty draws on the device lane
runtime_lane::line_widths, for the two commits before:

- run(): nothing is refused any more. Each case's draws are counted by
  route (band, the device's lines, the nearest width:
  WorkCounts::nearest_width_line_draws) and must sum to its wide draws;
  each nearest-width draw announces lines-at-nearest-width (announce_each
  here) and only those do. A case drawn at the nearest width is compared,
  where that width is 1 and the probe has the geometry's width-1 map,
  with Metal's map at width 1, pixel for pixel. On a device without
  wideLines that tessellates, every edges case takes the nearest width
  and matches Metal's width-1 edges. WIDE_LINES holds both kinds.
- a_draw_of_no_complete_primitive_draws_nothing: the consumer's shapes,
  Triangle and TriangleStrip of 1 and 2 vertices, by vertices and by
  16-bit indices, fill mode Lines, width 2, provoking vertex 1: no error,
  no pixel, no route counted, no notice. Draw gains indexed and
  provoking_last.
- edges_draw_at_the_nearest_width_the_device_s_lines_draw: a triangle's
  edges at width 2, twice, under once-per-device announcing: the
  device's lines where they draw 2, else the nearest width, counted at
  each draw, announced at the first alone; at width 1 Metal's width-1
  edges map.
- a_band_needs_tessellation becomes
  without_tessellation_lines_draw_at_the_nearest_width: widths 0 and 2
  without tessellationShader run (the device's lines or the nearest
  width, announced), compared with Metal's LANE lines 1 where drawn at 1.

Verified on the Apple M3 Max over MoltenVK 1.4.2 (no wideLines), RUSTFLAGS
--cfg m2v_gpu, through maclock and memcap.sh: the six line_widths tests and
degrade_notices::every_kind_has_a_site_a_lane_test_takes pass. Both run()
policies: 117 cases, 115 matched at Metal's width, the 2 edges cases
formerly refused (fill Lines widths 4 and 0) drawn at width 1 and equal to
Metal's width-1 edges map; 61 band draws, 2 nearest-width draws. Negative
control: with drawn() ignoring the draw's count,
a_draw_of_no_complete_primitive_draws_nothing fails (routes [0, 0, 1] for
a 1-vertex triangle). clippy -p metal2vulkan-validation -p
metal2vulkan-runtime --all-targets --all-features under --cfg m2v_gpu is
clean.

(Carried to development from steelbrain/reims-graphics-kext 45b3427434.)
2026-11-01 21:26:23 -08:00
Anees Iqbal b5e18d8fb3 Document the nearest-width line route; name its cause in the notice
Follows the previous commit, which drew at the nearest width what neither
line route draws. Its nearest width is Metal's drawn width: w', and 1/16
at w' = 0 (Metal draws 0 as 1/16, the width-0 commit this rebased onto),
clamped into lineWidthRange where the device enables wideLines, else 1.

- line_width.rs: module docs for the Nearest route and what still
  refuses (a strip's band whose segment list cannot be drawn; the band
  variant's forms the translator does not build). The
  lines-at-nearest-width notice's object names the edges or lines drawn,
  its reason the width drawn, lineWidthRange (or no wideLines) and the
  cause.
- The runtime README's line widths, FAST-PATHS.md's wide_lines row
  (counter nearest_width_line_draws) and its known gap (what is drawn at
  the nearest width, announced, instead of refused), RUNTIME-PORTING's
  SetLineWidth row.
- refusal_surface reach.tsv: gap WideLines now reaches only a strip's
  band list; feature WideLines only the translator's band forms.
  REFUSALS.md regenerated (gap::WideLines sites 5 -> 1, the runtime's
  Unsupported(WideLines) site gone).
- api_signatures blessed: Degradation::LinesAtNearestWidth,
  WorkCounts::nearest_width_line_draws.
- RUNTIME_VERSION 1715 (a refusal became a run, a new announcement);
  runtime-sources pin recomputed on this tree (pin-compute.py, which
  reproduces 9ada26c9fa's pin on that tree).

Verified: refusal_surface.py --check exit 0; cargo nextest run -p
metal2vulkan-runtime -p metal2vulkan --all-features -E
'test(/line_width|degradation|api_signatures|api_surface|refusal_surface|apple_only|error_kinds|draw_shape|call_checks/)'
27 passed; cargo clippy --workspace --all-targets --all-features -D
warnings clean.

(Carried to development from steelbrain/reims-graphics-kext 7aed54b621.)
2026-11-01 21:26:23 -08:00
Anees Iqbal 9ccc90d246 Draw at the nearest width what neither line route draws; draw nothing for no primitive
The consumer (reims-vgpu, whose guest process ends at any refusal) measured
two problems with setLineWidth: on an M3 Max over MoltenVK:

1. A draw of no complete primitive was refused. After setLineWidth 2 in fill
   mode Lines, Triangle or TriangleStrip draws of 1 or 2 vertices or indices
   returned NotImplemented(WideLines), where Metal draws nothing. drawn()
   ignored the draw's count. It now takes whether the draw may draw a
   primitive (line_width::draws_primitives: a direct draw whose vertices or
   indices complete none of its type's primitives, RewriteProgram::capacity,
   draws none; an indirect draw's count is the GPU's and keeps its route, as
   do patch and mesh draws), and such a draw is Plain. The shape memo keys
   on it beside the assembly, so a later whole draw does not reuse its
   settings.

2. Every remaining refusal refused a draw that can run. LineRoute gains
   Nearest { width, why }: the device's own lines at the width nearest
   Metal's they draw (w' clamped into lineWidthRange where the device
   enables wideLines, else 1), announced once per device (unless
   announce_each) as the new Degradation::LinesAtNearestWidth
   (lines-at-nearest-width, precision), whose reason names why and both
   widths, and counted in WorkCounts::nearest_width_line_draws. It takes a
   triangle's edges in fill mode Lines and mesh lines the device's lines do
   not draw (Unbanded), lines on a device without tessellationShader
   (Untessellated, formerly Unsupported needing it), an amplified band
   (Amplified), and every wide line in a rate-mapped pass (RateMapped) or of
   an execution's command (Executed: ShapeInputs::executes, the replay's
   lowering), whose width Metal's answer is not measured for. route() is
   infallible now; Device carries whether it differs. The replay's and the
   commit precompile's refusals go: an execution's command draws the
   nearest width and the precompile makes its pipeline; the GPU form still
   leaves such a pass to the host step, which draws and announces it.

RuntimeGap::WideLines stays for the one refusal left: a strip's band whose
list of segments the runtime cannot draw (ListGap::WideLines, as for the
provoking vertex's lists). The band variant's own refusals in the
translator (pipeline::link::band) are unchanged.

Not a speed-for-accuracy switch: the fallback for capability not built, so
no DevicePolicy switch.

Verified: cargo nextest run -p metal2vulkan-runtime -E 'test(/line_width/)'
(3 passed): each_device_routes_each_width_as_its_lines_allow now expects
the nearest width (checked against lineWidthRange) in every former refusal
cell, and rate-mapped and executed draws at the nearest width; the new
a_draw_of_no_complete_primitive_draws_nothing covers every line, triangle
and private type, direct and indexed, 1 and 3 instances, both fill modes,
on four profiles under both policies. Negative control: with drawn()
ignoring the count it fails (left: Lines, right: Nothing).

(Carried to development from steelbrain/reims-graphics-kext 5eecc33ca1.)
2026-11-01 21:26:23 -08:00
Anees Iqbal 7ebe50a2bc Draw width-0 lines as Metal's width 1/16
Metal draws every setLineWidth: width below 1/16 (0, negative widths and
NaN among them) exactly as 1/16: the parallelogram reaching 1/32 pixel
each side of the segment along its minor axis, after snapping the
endpoints to 1/256 pixel. The band drew w' = 0 at a half width of
2^-subPixelPrecisionBits (1/256 on MoltenVK), which lights only the
centres the segment passes within 1/256 of: right where the endpoints
are on pixel centres, as every earlier probe case had them, and short of
Metal's pixels anywhere else (a consumer's scattered draw lit 3 and 5
pixels on Metal and none on the runtime).

The runtime's route now pushes the band's half width as w'.max(1/16)/2,
so width 0 draws as the band of 1/16 does. Width 0 keeps its route (the
band; the device's lines never draw it), and every other width is
unchanged. The translator's band is unchanged but for its docs.

Docs: line_width.rs and band.rs state Metal's rule (snapping to 1/256,
a half rounded up; width 0 as 1/16) in place of "the centres on the
segment"; the runtime README and set_line_width say "at 0 as at 1/16".
RUNTIME_VERSION 1714 (a width-0 draw lights other pixels); the
runtime-sources pin recomputed.

Verified: runtime_lane::line_widths on MoltenVK (Apple M3 Max, macOS
27.0.1), both policies: 117 cases, 115 match Metal pixel for pixel and 2
refused as documented (triangle edges), 61 draws by the band; the 11
width-0 maps that differed at the parent now match (offset rows and
columns 256 pixels, scattered lists 31, the strip 33, the clip-space
list and strip 3 and 5). Runtime line_width unit tests (the band's half
at 0 is 1/32), tests::engine_line_band, golden_hashes_match_the_table,
the engine inventory parts, tests::fast_paths and the runtime-sources
guard pass; clippy clean on all features and on --cfg m2v_gpu.

(Carried to development from steelbrain/reims-graphics-kext 9ada26c9fa.)
2026-11-01 21:26:22 -08:00
Anees Iqbal 2ee9856fa1 Measure Metal's width-0 lines off the pixel centres
The line-width probe's width-0 cases all put the endpoints on pixel
centres, which cannot tell "only the centres on the segment" from a
narrow band. A consumer's scattered draw at setLineWidth:0 lit pixels on
Metal that the runtime did not.

The probe's zero case gains: rows and columns of lines offset from the
centres in steps of 1/512 pixel (64x64, widths 0 and 1/16); 48 lines of
scattered endpoints on a 1/4096 grid (32x32, a 64-bit LCG the lane
test repeats) at widths 0, 1/32, 1/16, -1, NaN and 2.5, the same lines
reversed and drawn as two instances, and a strip of 49 points; and eight
clip-space positions as a list and a strip (a pass-through vertex
function), fragments counted. The probe's draws take an instance count
and clip-space points.

Measured on the M3 Max, macOS 27.0.1 (each case under the GPU lock,
without MTL_DEBUG_LAYER): every width below 1/16 draws exactly as 1/16
(the scattered maps at 0, 1/32, 1/16, -1 and NaN are identical, 31
pixels; the offsets at 0 and 1/16 identical), a line offset from a row
of centres by -15/512 to 16/512 pixel draws them (rows 17 to 48 of
4..59), i.e. the parallelogram reaching 1/32 pixel each side of the
endpoints snapped to 1/256 pixel, a half rounded up. Regenerating every
case reproduces the old record byte for byte; only the new maps are
added.

The lane test (runtime_lane::line_widths) draws the same cases. On
MoltenVK it fails at this commit: 11 of the new width-0 maps differ
(offset rows and columns 32 pixels against Metal's 256; scattered lists
4 against 31, the strip 5 against 33, the clip-space list and strip 0
against 3 and 5); the 1/16 and 2.5 maps match.

(Carried to development from steelbrain/reims-graphics-kext 3e5a376bc4.)
2026-11-01 21:26:22 -08:00
Anees Iqbal 3f5cfb1399 Bless the linked_other_functions fixture's golden rows
The fixture added with the binary-function linking answers had no golden
printout, engine inventory rows or golden-hash cells, so the core suite
failed five tests on it (engine_fixtures_match_their_golden_printout,
inventory_lists_every_fixture_in_order, golden_hashes_match_the_table and
two engine inventory parts).

Blessed with bless_engine_goldens, bless_golden_hashes and
bless_engine_inventory. Every new row is the new fixture's (ok under every
profile); no existing cell moved and no row was removed.

(Carried to development from steelbrain/reims-graphics-kext 31df26ef99.)
2026-11-01 21:26:22 -08:00
Anees Iqbal 815c8af707 Re-pin the runtime sources at the branch tip
The previous commit changed runtime-sources inputs (the runtime's pipeline
sources), so the committed digest no longer described the sources and
`the_runtime_sources_are_the_committed_ones` would fail. Recomputed over the
same inputs with pin-compute.py on the tree rebased onto 7cf79c50ed.

REFUSALS.md regenerated on the same tree: beside nothing of this branch, it
picks up the base's rename of `line_width.rs`'s `line_route` to `route`, which
the base left out of the generated document.

(Carried to development from steelbrain/reims-graphics-kext 6fd1ce74b1.)
2026-11-01 21:26:22 -08:00
Anees Iqbal b2bbc86339 Answer linked binary functions as plain Metal does
Measured on this M3 Max under macOS 27.0.1 (binary_function_linking.m, plain
and with MTL_DEBUG_LAYER=1, source libraries and metallibs alike), the runtime
now answers what plain Metal answers rather than what its validation layer
stops:

- One name in `functions` and `binary_functions`, or twice in
  `binary_functions`, one function or two: made, where the runtime refused
  `Invalid(DuplicateLinkedFunction)`. `duplicate_linked_name` keeps only a name
  `functions` repeats, which plain Metal's creation fails ("error: duplicated
  symbol", code 3). With the previous commit, a call calls the `functions` one
  and a table holds each.
- A function only `binary_functions` holds that a stage calls directly:
  `Compile(NeedsInput(LinkedFunction))`, as Metal fails with code 3, where the
  runtime linked it (previous commit).
- A function not compiled to a binary in a stage's `binary_functions`: plain
  Metal fails the creation once the stage links, code 2 ("Internal error
  during compute pipeline creation", "... tile pipeline creation", an empty
  description for render and mesh-fragment stages), after a reference it
  leaves unresolved (code 3 first). The runtime answered
  `Invalid(BinaryFunctions(NotPrecompiled))` before the compile; it now
  answers `Error::MetalError` with that problem, the M3 Max's domain and
  Metal's code and text, right after the compile (`additions::check_precompiled`).
  Added to a made state's stage: `MetalError` code 1 ("Failed to allocate a new
  pipeline"). Added to a stage the state lacks: taken, as plain Metal makes it
  (it was refused).
- A mesh pipeline's object or mesh stage linking binary functions ends plain
  Metal's process ("Binary linked functions are not supported for object and
  mesh shaders"): `Invalid(BinaryFunctions(ObjectOrMeshStage))`, a new problem,
  where the runtime made the state.

The module docs of `pipeline/additions.rs` record the measurements, the error
and README docs follow, REFUSALS.md and the API signatures are regenerated.
RUNTIME_VERSION 1713: creation answers change class.

Verified on this Mac (MoltenVK, --cfg m2v_gpu, under maclock and memcap):
runtime_lane::tests::a_kernel_runs_the_functions_its_descriptor_links and
runtime_lane::function_tables::{binary_functions_link_as_plain_metal_links_them,
binary_functions_and_required_threads_answer_as_metal_s_do,
functions_added_to_a_stage_a_drawing_state_lacks_are_left_out} pass; each
asserts an answer the previous runtime gave otherwise. The runtime unit test of
`duplicate_linked_name` passes.

(Carried to development from steelbrain/reims-graphics-kext 580daa4338.)
2026-11-01 21:26:21 -08:00
Anees Iqbal 3c1f56b63b Resolve no visible-function reference against binary functions
Metal resolves a visible-function reference against MTLLinkedFunctions'
`functions` and `privateFunctions`, never `binaryFunctions`, whose functions
only a visible-function table reaches: on this M3 Max under macOS 27.0.1
(binary_function_linking.m) a direct call to a function only binaryFunctions
holds fails the creation, plain and under validation ("unresolved visible
function reference"), from the stage's function and from a linked function
alike, while a table calls it. Two different functions of one name, one in
each list, are made: the call calls the one of `functions`, and a table holds
both, each handle calling its own definition.

The compile layer resolved references against every list, so it linked what
Metal refuses and saw two such functions as ambiguous. Now
`LinkedList::resolves_references` is `functions` and `private_functions`;
`linked_modules` reaches a table's functions by key rather than by name, and
each `LinkedName` says whether a reference resolves to it
(`resolves_references`, a new field of metal2vulkan-air's public struct), which
canonicalization's stub resolution reads. A reference only a binary function
names is `NeedsInput(LinkedFunction)`, the answer for any unresolved one.

The owned fixture `linked_other_functions` (compiled by
scripts/regen-air-fixtures) defines `linked_scale` and `table_add` with other
bodies, for the two-of-one-name shapes. SEMANTICS_VERSION 1937: the same key
now compiles otherwise (a binary-only reference refuses).

Verified: the AIR link tests, `engine_linking::a_reference_resolves_to_no_
binary_function` (interpreter: the call calls the `functions` one from either
module; a binary-only call and a binary-only nested call refuse) and
`engine_tables::a_table_holds_a_binary_function_of_another_s_name`
(interpreter: alternating own and other `table_add` through one table) pass;
with the stub filter removed, the link test and the engine_linking test fail.
API signatures blessed (one new field).

(Carried to development from steelbrain/reims-graphics-kext 64bd644d0b.)
2026-11-01 21:26:21 -08:00
Anees Iqbal 6264c2d3f9 Probe what Metal answers for linked binary functions
A probe written from scratch, binary_function_linking.m, of compute, render
(vertex, fragment), tile and mesh pipelines whose linked binaryFunctions hold a
function alone (called directly, through a visible-function table, or not at
all), one name beside a function of `functions` or twice, a function not
compiled to a binary, and the same for functions added to a made state. Each
case is one process; the probe reads its libraries compiled from source or
from metallibs built ahead of time.

Measured on this M3 Max under macOS 27.0.1, plain and with MTL_DEBUG_LAYER=1,
both library kinds alike: no direct call resolves to a function only
binaryFunctions holds (code 3 "unresolved visible function reference"), a
table calls it; one name in both lists, or twice in binaryFunctions, is made
plain (validation stops it) and a direct call calls the one of `functions`; a
function not compiled to a binary fails the creation with code 2 ("Internal
error during compute pipeline creation", the tile form, or an empty
description for render stages) and an addition with code 1 ("Failed to
allocate a new pipeline"); a mesh or object stage's binary functions end the
process. While a compile-to-binary function lives, newFunctionWithName: of the
same library function answers that one object (options 1), which explains the
consumer's repro reading its "unbinary" cases as binary ones.

The results are in the probe's header; the runtime docs and tests follow in
the next commits.

(Carried to development from steelbrain/reims-graphics-kext 7d83e83da2.)
2026-11-01 21:26:21 -08:00
Anees Iqbal 51817ce0ef Test each committed device's wide-line route under both policies
The device's-own-lines route (WideLinePolicy::Device, and the exact
device route) runs on no lane venue here: MoltenVK has no wideLines, so
runtime_lane::line_widths cannot tell the two settings apart. The route
decision is now a function of the device profile, the policy, Metal's
width, what the draw draws and whether it is amplified or rate-mapped
(render/line_width.rs route, drawn), which ShapeInputs::line_route calls
and announces from; no behaviour changes.

render/line_width/tests.rs asserts the route of every draw at widths 0,
0.5, 1, 1.5, on and off each device's granularity, the top of its range
and a sixteenth above it, and 16, read from the committed profiles
amd-780m-radv, amd-780m-hawkpoint-radv, amd-rdna3-radv, intel-arl-anv,
lavapipe, nvidia-rtx5080-laptop, moltenvk-m3, swiftshader, vk12-floor,
roadmap-2022 and lunarg-desktop-baseline-2023, under Device and Exact,
for a list of lines, a triangle's edges in fill mode Lines, an emulated
mesh's lines and an amplified list: device lines exact or announced,
the band (its half width checked), Unsupported needing
tessellationShader, or NotImplemented(WideLines); a rate-mapped pass
refuses every width but 1.

The runtime-sources pin is rewritten (the previous commit's profile
reader and this one's runtime files; no behaviour change, so no
RUNTIME_VERSION bump).

Correction to b16d03150c's message: the lane's two refused cases are
the triangles in fill mode Lines at widths 4 and 0, not both at 4.

Verified: nextest render::line_width (2 pass); negative controls, each
reverted: dropping `w > 1.0` from the exact test fails it at
amd-780m-radv lines/Device 0.5 (Exact for Announced), and dropping
`|| !band` fails it at amd-780m-radv edges/Exact (Gap for Announced);
the runtime crate's suite (1179 pass); runtime_lane::line_widths on the
M3 Max under MoltenVK through maclock (4 pass, unchanged counts);
cargo clippy --workspace --all-targets --all-features -D warnings.

(Carried to development from steelbrain/reims-graphics-kext 7cf79c50ed.)
2026-11-01 21:26:21 -08:00
Anees Iqbal bbc7866fa0 Read nonStrictWideLinesUseParallelogram from the maintenance5 properties
The profile reader took VkPhysicalDeviceMaintenance5Properties' members
only through VkPhysicalDeviceVulkan14Properties, so a capture of a
Vulkan 1.3 device exposing VK_KHR_maintenance5, which carries only the
extension's structure, read nonStrictWideLinesUseParallelogram as false,
and the runtime would announce or band wide lines its device draws as
Metal's parallelogram. PROPERTY_STRUCTS now lists
VkPhysicalDeviceMaintenance5Properties and its KHR name; the member is
still read only where maintenance5 is exposed (the extension or 1.4).
The profile generator's EXTENSION_PROPERTIES states the member at the
value the reader takes when a requirements document lists the extension
and omits it (false).

Nothing moves: every committed capture that carries the extension
structure also carries the Vulkan 1.4 one, with the same value
(golden_hashes passes unblessed). The runtime-sources pin, which hashes
this file, is rewritten in the next commit.

Verified: nextest device::tests::description (23 pass), among them the
new wide_line_parallelograms_read_the_maintenance5_structure (a 1.3
document with the extension and either structure name reads true,
without the extension false, a 1.4 document's Vulkan 1.4 block true);
negative control: with the two names left out of PROPERTY_STRUCTS the
test fails; golden_hashes and fast_paths pass; scripts/regen-device-
profiles test_device_profiles.py and check_device_profiles.py clean.

(Carried to development from steelbrain/reims-graphics-kext 5651992284.)
2026-11-01 21:26:21 -08:00
Anees Iqbal eb41a55e82 Draw every width Apple's setLineWidth: takes, as Metal draws it
RenderCommandEncoder::set_line_width refused every width but 1
(AppleOnly::LineWidth). Measured on the Apple M3 Max under macOS 27.0.1
(probes/line_widths.m): each encoder starts at 1 and the width holds
across draws and pipeline states; Metal draws w' = floor(16 w) / 16
clamped to [0, 16] (NaN and negatives as 0, infinity as 16); at w' = 1
its ordinary diamond-exit lines; at every other w' Vulkan's non-strict
parallelogram (major axis the larger extent, x on a tie; minor-axis
edges through the endpoints, w' long and centred; ends not extended;
centres inside, top-left ties; the width not rounded); at 0 exactly the
pixel centres on the segment; one parallelogram per strip segment with
no joins; triangles in fill mode Lines draw their edges so; at 4
samples every width is the parallelogram at the sample positions.

The runtime (render/line_width.rs) keeps the quantized width in the
encoder state and routes each draw at w' != 1:
- the device's own lines (lineWidth w', no Bresenham mode) where it
  enables wideLines and w' lies in lineWidthRange above 0: exact where
  strictLines is unset, nonStrictWideLinesUseParallelogram set, w' > 1
  and on lineWidthGranularity; elsewhere announced device-wide-lines
  under the default DevicePolicy::wide_lines = WideLinePolicy::Device,
  and the band under WideLinePolicy::Exact (exact_answers() selects it);
- the pipeline's band variant otherwise (no wideLines, MoltenVK among
  them; w' outside the range; w' = 0 at half a width of
  2^-subPixelPrecisionBits): cull none, the band's front face, fill
  mode, a PATCH_LIST of two points, viewport 0's half extent pushed
  with the half width; strips and loops listed as their segments
  (ListGap::WideLines), flat inputs under the last provoking vertex
  read from the list led by the last vertex, which covers the same
  pixels.
Refused: Unsupported(WideLines) needing tessellationShader where neither
route draws a line; NotImplemented(RuntimeGap::WideLines) for a
triangle's edges or a mesh draw's lines the device's lines do not draw,
an amplified band, a rate-mapped pass and an execution's commands.
Counted: WorkCounts::device_wide_line_draws, line_band_draws.

The lane test runtime_lane::line_widths draws the probe's cases through
owned fixtures and compares every pixel with Metal's answers
(line_widths_m3_max.txt, the probe's output), checks each wide draw took
a route, and that every fragment is front-facing; its site WIDE_LINES
holds the new kind in the lane's degrade-notice closure.

Docs: FAST-PATHS.md's row for wide_lines and a known-gap bullet (edges
and mesh lines on devices without wideLines, near-plane cuts, band
fragments' inputs uncompared, width 1 on multisampled targets off
MoltenVK); API.md's policy bullet and degrade catalogue; the runtime
README's Line widths; RUNTIME-PORTING's row; REFUSALS.md regenerated
(reach rows for feature and gap WideLines, apple LineWidth gone).
Validation: the line limits the device description gained describe
execution and are not compared in a profile's subset check; the
generator's CORE_PROPERTIES and roadmap-2022's m2v_layer_presentation
state them at the reader's absent values; opened_chains reblessed (one
member more, wide_lines, on every device with it); golden_hashes'
profile fingerprints reblessed (no output cell moved); api_signatures
and api_surface name WideLinePolicy and LineBandState.

RUNTIME_VERSION 1712; the runtime-sources pin rewritten.

Verified on the M3 Max under MoltenVK 1.4.2 through maclock with the
validation layer: runtime_lane::line_widths, 4 tests pass. Default and
exact policies each: 102 cases, 100 matched pixel for pixel, 2 refused
(the two fill-mode Lines cases at width 4, NotImplemented(WideLines)),
0 announced; 46 draws took the band, 0 the device's lines (MoltenVK has
no wideLines). a_band_needs_tessellation (tessellationShader withheld:
width 0 refused needing it, width 2 refused, width 1 matches) and
the_lane_s_maps_tell_the_widths_apart pass. Negative control: the band
widened by 1/16 of a pixel fails both runs at LANE lines 0.5. Also
cargo clippy --workspace --all-targets --all-features -D warnings, plain
and with --cfg m2v_gpu; nextest of metal2vulkan, -air, -runtime and
-devtools (4954 run, the one failure the missing lane site, now
declared), of metal2vulkan-validation (the failures the profile rules,
chains and pin fixed here, rerun green) and of metal2vulkan-conformance
(1007 pass). Not run: lavapipe, RADV, ANV and NVIDIA lanes, which take
the device route.

(Carried to development from steelbrain/reims-graphics-kext b16d03150c.)
2026-11-01 21:26:20 -08:00
Anees Iqbal fe22294b09 Carry every vertex output through a line band's control stage
On MoltenVK the band drew every line from its first endpoint to the
target's right edge: the second control point's position read the bytes
after the first vertex's. MoltenVK runs a vertex stage followed by
tessellation as a compute kernel that writes its outputs into one record
per vertex, the location outputs, Position and PointSize (which the
translator's MoltenVK vertex stages always write), and lays the control
stage's input record out from what that stage declares. A control stage
that declared only Position read records of 32 bytes from records of 48.

The band's stages now carry the vertex stage's outputs entire: every
varying, read or not by the fragment stage, and PointSize where the
vertex function writes one and the device enables
shaderTessellationAndGeometryPointSize (TessellationPointSize, now a
requirement rule for tessellation entries beside GeometryPointSize). A
corner takes the first control point's point size, as it does a flat
varying. The input arrays are gl_MaxPatchVertices long again.

The binder also plans a band variant: its synthesized control and
evaluation stages run no Metal function and bind nothing, as link's
geometry stages (bind::graphics::metal_stages, with a plan test).
Two match expressions become matches! (clippy).

SEMANTICS_VERSION 1936: the band variant's control and evaluation
modules change under the same key.

Verified: nextest tests::engine_line_band, 4 tests pass, among them the
new the_control_stage_takes_every_value_the_vertex_stage_writes (the
control stage's per-vertex inputs and outputs and the evaluation
stage's inputs equal the vertex stage's outputs on every committed
profile with tessellationShader, PointSize included where the device
takes it). Negative control: with the point size left out it fails
(left [BuiltIn(0), Location(0), Location(1)], right adds BuiltIn(1)),
and the MoltenVK lane runtime_lane::line_widths draws LANE lines 0.5
otherwise than Metal. With the fix the lane matches Metal's maps on the
M3 Max under MoltenVK (the runtime commit that follows).

(Carried to development from steelbrain/reims-graphics-kext 8b865a057d.)
2026-11-01 21:26:20 -08:00
Anees Iqbal 14dc4c5f2e Draw a line wider than the device's lines as a band of two triangles
Metal draws a line under Apple's setLineWidth: at a width other than 1 as
the parallelogram Vulkan's non-strict wide lines may be (major axis the
larger framebuffer extent, minor-axis edges through the endpoints, centred,
w long). Devices without wideLines (MoltenVK among them) or whose wide
lines are strict or not parallelograms cannot draw it with their own lines.

A render pipeline's band variant (VariantKey::line_band) adds two
synthesized stages after the vertex stage (pipeline::link::band): a
tessellation control stage that copies each of a line's two vertices and
writes every level 1 in the quad domain, and an evaluation stage that
places each corner at its endpoint moved across the segment by half the
width in framebuffer pixels along the minor axis, taken to clip space
through Vulkan viewport 0's half extent, which the draw pushes
(PushField::LineBand, BindState::line_band, its own 16-byte aligned push
range). Ends behind w = 2^-20 are clipped first; smooth varyings and clip
distances follow their endpoint, flat and integer ones take the first
control point's. GraphicsState::line_band (LineBandState) states the
consumer's contract: PATCH_LIST of two control points, no culling, its
front face, the push offset.

The device description gains what chooses the route: VkFeature::WideLines,
and the limits lineWidthRange, lineWidthGranularity, strictLines,
nonStrictWideLinesUseParallelogram (VK_KHR_maintenance5) and
subPixelPrecisionBits, read from Khronos profile JSON and from ash. The
verifier and requirement rules take the per-vertex arrays of tessellation
control inputs and outputs and evaluation inputs, and TessLevelOuter and
TessLevelInner as arrays. ARTIFACT_FORMAT_VERSION 480 for the new encoded
fields (VariantKey, GraphicsState, LineBandState, PushField, VkFeature).

Verified: cargo build --workspace --all-features --all-targets; nextest
tests::engine_line_band (the band variant on every committed profile with
tessellationShader validates in spirv-val and requirements, draws
PATCH_LIST with its own push range; flat varyings take the first control
point; without tessellationShader it is refused needing it; barycentric
reads are not implemented) and the tessellation push_offset tests pass.

(Carried to development from steelbrain/reims-graphics-kext 19814d7bb3.)
2026-11-01 21:26:20 -08:00
Anees Iqbal 8ef82fffa5 SEMANTICS_VERSION 1935; bless the stitched caller's rows
Translation output changes: a pipeline that links a function from a
module carrying a stitching signature (or a linked-constants signature
on a module that declares no constant) now compiles instead of refusing,
so SEMANTICS_VERSION moves from 1933 to 1935 (1934 is reserved).

The golden tables gain the new fixture's rows and nothing else moved:
golden_hashes.tsv and public_fixture_expectations_engine.tsv each add
stitched_caller's two kernels in its two forms (.ll and .air.ll), every
profile NeedsInput(LinkedFunction) for `fused` and `fused4`, which no
module defines there; tests/air_input/stitched_caller.txt is the new
fixture's decode golden. Blessed with bless_golden_hashes,
bless_engine_inventory and bless_engine_goldens (llvm-as 21); git diff
shows only these additions.

(Carried to development from steelbrain/reims-graphics-kext 4ba981e668.)
2026-11-01 21:26:20 -08:00
Anees Iqbal 1146929b09 Lane test: a stitched function computes its graph on the device
The consumer's path end to end through the runtime: the stitched
library made from its bytes (Device::new_library_with_data, the form it
takes when a guest hands it over), its functions linked into the
caller's kernels in privateFunctions and in functions, one thread on
2, 3, 4 and 5. runtime_lane::stitched_functions checks Metal's measured
words, 20 for `fused` and 25 for `fused4`, read back from the device.
The runtime README says that a stitched function links as any linked
function does and that the runtime makes no stitched library itself.
The runtime's sources are unchanged.

Verified on the M3 Max through MoltenVK under the validation layer
(RUSTFLAGS='--cfg m2v_gpu', through the Mac GPU lock):
runtime_lane::stitched_functions::a_stitched_function_computes_its_graph
passes, beside runtime_lane::linked_functions' two tests; with the
translator's old signature gate restored it fails, the pipeline state
refused with the consumer's error.

(Carried to development from steelbrain/reims-graphics-kext 199df8d7b3.)
2026-11-01 21:26:19 -08:00
Anees Iqbal 43ba8cf525 Test stitched functions linked into their caller
Metal's stitcher writes its library only at run time, so the tests get
its structure from a writer of our own: metal2vulkan_devtools::stitched
writes, as LLVM text, the module the probe stitched_function_linked.m
read back from Metal for a graph of float stitchable functions (the
stitched function with its nodes inlined, its air.visible entry and
air.stitching_info naming internal helpers kept by llvm.compiler.used,
and an !air.signature of kind air.stitching_modules_signature listing
the graph in post-order and a digest per stitchable function), and the
executable metallib holding one visible (TYPE 4) module per function.
PROBE_GRAPHS are the probe's `fused` and `fused4`. No Apple-produced
bytes are committed.

The owned fixture engine/stitched_caller (regen-air-fixtures, macOS
27.0 target, as the probe compiled) holds the stitchable sum2 and
product2 and the kernels stitch_caller and stitch_caller4 that call
`fused` and `fused4`.

tests::engine_stitched checks Metal's answers: through the public API
the stitched library's functions are visible and each kernel's compute
pipeline links its function in privateFunctions and in functions; on the
SPIR-V interpreter the kernels store the probe's 20 and 25 (and the
graph's value on two other input sets); and each link passes L3 on
every committed profile.

Verified: the three tests pass; with the previous commit's gate
restored all three fail, the link refused with exactly the consumer's
error (Linking, NotImplemented, stitch_caller block 0 instruction 5,
symbol "fused"). regen-air-fixtures --check: up to date.

(Carried to development from steelbrain/reims-graphics-kext 88a6b651a7.)
2026-11-01 21:26:19 -08:00
Anees Iqbal 59209afdf7 Link stitched functions: read a linked module's signature as the entry's
A pipeline linking a function Metal's stitcher made was refused,
`Unsupported { feature: Linking, needs: NotImplemented }` at the call
(stitch_caller, block 0, instruction 5, symbol "fused"), because
link::plan refused every linked module that carries an !air.signature.
Each module of a stitched library carries one, of kind
air.stitching_modules_signature: it records the graph the function was
made from and the stitchable modules' digests, while the module's own
code (the graph's nodes inlined into the stitched function) is what
runs. The entry side already read a signature that way and refused only
a linked-constants module that still declares function constants, which
has no reading.

The rule is now one function, canon::unread_signature, which both the
entry's specialization and the linked module's plan use: a stitched
module and a linked-constants module that declares no constant link like
any other module; a linked-constants module that still declares one is
refused at the surviving call as before. The dynamic-library export
check, which blocks any signature, is unchanged: a stitched library is
an executable library and cannot be a dynamic one.

Verified: link_tests::a_linked_module_s_signature_is_read_as_the_entry_s
(replacing the test that held the old refusal) passes, and fails with
the old gate restored. Against the stitched library the probe dumped on
the M3 (not committed), the old gate reproduces the consumer's refusal
exactly, and with this change both stitched functions link, privately
or not, and compute 20 and 25 on the SPIR-V interpreter.

(Carried to development from steelbrain/reims-graphics-kext 3ebc1a708a.)
2026-11-01 21:26:19 -08:00
Anees Iqbal 1083e38ecf Probe a stitched function linked into a compute pipeline
A consumer's guest makes a stitched library with Metal's own stitcher
(newLibraryWithStitchedDescriptor:) and links its function `fused` into
a kernel as a private linked function; the translator refused that
pipeline. This probe measures Metal's answer from our own stitchable
source: `fused(a, b, c) = product2(sum2(a, b), c)` linked into
`stitch_caller` in privateFunctions or in functions, and the three-node
`fused4`, each run on 2, 3, 4 and 5, and it writes the stitched
library's bytes (its libraryDataContents) for inspection.

Measured on the M3 Max under macOS 27.0.1, each case in its own process
through the Mac GPU lock, MTL_DEBUG_LAYER unset: private 20, functions
20, deep 25, every command buffer status 4. The dumped library (11484
bytes, byte-identical across runs) is an executable metallib with one
visible (TYPE 4) function per module, each module carrying an
!air.signature of kind air.stitching_modules_signature.

(Carried to development from steelbrain/reims-graphics-kext 453a4a2b23.)
2026-11-01 21:26:19 -08:00
Anees Iqbal 4180cb2edb RUNTIME_VERSION 1710 for linking under specialized names
The branch changes what a runtime run does: linked functions resolve
under their specialized names, function-table handle keys carry the
link name and specialization, linked modules with function constants
link instead of refusing, and a pipeline of an unspecialized function
that declares constants is refused. The runtime-sources guard asks for
a RUNTIME_VERSION bump with such a change; 1710 is unused on every
branch. The pin (4fc5e9992a...) does not move with it.

(Carried to development from steelbrain/reims-graphics-kext 37280bc223.)
2026-11-01 21:26:18 -08:00
Anees Iqbal 45380bd58f Re-pin the runtime sources at the branch tip
The branch changes runtime-sources inputs: metal2vulkan-runtime's
error.rs, library.rs, pipeline/{additions,mod,render,tile,
unspecialized}.rs and warm/codec.rs, and metal2vulkan's
pipeline/table.rs. Recomputed over the same inputs, as
the_runtime_sources_are_the_committed_ones computes it.

These edits can change what a run does: a linked function links under
its specialized name, a visible-function handle's key holds the
specialized name and flag, a linked module with function constants is
specialized instead of refused, and a stage function made by name whose
function declares constants is refused. The guard's rule asks for a
RUNTIME_VERSION bump with such edits; RUNTIME_VERSION stays 1709 here
because its number is the orchestrator's to give, and the bump is left
for that number.

Verified: the guard passes (1/1).

(Carried to development from steelbrain/reims-graphics-kext ce415fe9f6.)
2026-11-01 21:26:18 -08:00
Anees Iqbal 468a91feab Size a copied constant's children with size_of_val
clippy's manual_slice_size_calculation (rust 1.98) stopped the
workspace's clippy at copy_bytes, the linked-module copy's ledger
estimate: size_of::<ConstId>() * children().len() over the slice
children() returns. The same bytes, as size_of_val of that slice.

Verified: cargo clippy --workspace --all-targets --all-features
-D warnings, plain and under --cfg m2v_gpu (own target), clean; rustdoc
-D warnings for the workspace, clean.

(Carried to development from steelbrain/reims-graphics-kext d232492977.)
2026-11-01 21:26:18 -08:00
Anees Iqbal e54a2c12aa Refuse a pipeline of an unspecialized function that declares constants
Since functions whose constants are left undefined compile (a2e34a9d2f),
the runtime made a pipeline state of a function made by
newFunctionWithName: whose function declares function constants. Plain
Metal ends its process there, at every creator's descriptor validation
(probes/undefined_function_constant_values.m, new cases <how>:<shape>,
on the M3 Max under macOS 27.0.1, MTL_DEBUG_LAYER unset, exit 134):
"Compute Pipeline Descriptor Validation / function ko cannot be used to
build a pipeline state. Use newFunctionWithName:constantValues:... to get
the specialized function"; the render and mesh creators name
vertexFunction, fragmentFunction, objectFunction and meshFunction, and
the tile creator says "without setting constant values first". It does
so for an optional constant read only where is_function_constant_defined
says (ko) and for a constant that only gates arguments (kg). Made: a
function made by name that declares none (kn, plain, tile-plain,
mesh-plain), and every shape made with constant values that hold none or
by newFunctionWithDescriptor: without them (each then answers an empty
functionConstantsDictionary; ko stored 7, kn 9).

- metal2vulkan: FunctionDescriptor gains `specialized` (false by default,
  a function made by name; a descriptor with constant values is
  specialized whatever it says) and with_specialized, and
  needs_specialization(budget, entries) answers whether Metal makes no
  state of the stage: not specialized and a non-empty
  functionConstantsDictionary. A module function's constants are read
  through the StageEntries' module decodes (constants_dictionary_with),
  which the stage's compile copies, so the check decodes nothing the
  compile does not. The compile itself is unchanged.
- metal2vulkan-runtime: Function::function_descriptor marks the stage
  specialized where the function was made with constant values or by
  descriptor. pipeline/unspecialized.rs refuses before anything is
  compiled, Invalid with the new Problem::UnspecializedFunction { stage,
  name }: compute and tile states (of_kernel), render states (vertex,
  fragment) and mesh states (object, mesh, fragment). A linked function
  keeps its own rule (LinkProblem::UnresolvedConstant).
- Pipeline records carry the stage's specialized flag, RECORD_FORMAT 3:
  without it every specialized stage's record read back unspecialized
  and went unrecorded.
- The owned fixture engine/unspecialized_stage_functions (the probe's
  shapes at every stage); its golden rows, inventory and printout are
  new rows only (11 functions by 2 forms in each table).
- docs/API.md ("Function constants"), the FunctionConstantValues and
  creators' docs, the runtime README, docs/REFUSALS.md regenerated, the
  signatures blessed (FunctionDescriptor.specialized, with_specialized,
  needs_specialization, Problem::UnspecializedFunction).

Verified:
- metal2vulkan tests::engine_unspecialized 2/2 (every declaring function
  of the fixture needs specialization made by name, no free one does,
  and the eleven answers read one module decode, (1, 10); specialized or
  valued, none does, decoding nothing).
- On MoltenVK (M3 Max) through maclock, --cfg m2v_gpu:
  runtime_lane::unspecialized_functions 3/3 (by name: guarded and gate
  kernels, vertex, fragment, tile, mesh and object refused; free kernel
  stores 9; plain render state made; empty-valued and descriptor-made
  guarded kernels store 7, gate kernels made, render states made; tile
  and mesh states of them not refused as unspecialized) and
  runtime_lane::linked_functions 2/2.
- metal2vulkan-runtime suite 1177/1177; tests::warm_record 4/4.
- metal2vulkan and metal2vulkan-air: 3748 of 3753 before blessing, the 5
  failures the new fixture's table rows; after blessing they and the
  signature and surface tests pass.
- Negative controls: needs_specialization answering false fails
  engine_unspecialized's by-name test; function_descriptor without the
  specialized flag fails all three lane tests (the empty-valued and
  descriptor-made functions refused); the stage flag removed from the
  record's writes and reads fails the four warm_record tests.

(Carried to development from steelbrain/reims-graphics-kext 116efd0dfe.)
2026-11-01 21:26:18 -08:00