Extended-range fetch and blend refused: what needs Metal's tile half is NotImplemented(Format)

Metal's tile memory holds an attachment of Apple's extended-range formats (BGR10_XR, BGRA10_XR,
RGB10A8_2P_XR10 and their _sRGB twins) as half through a render pass and rounds it to the codes
only at the store. A fetch of such an attachment, or a blend onto it after an earlier draw of the
pass wrote it, sees that draw's half. The attachment holds the codes. With the half shadow gone
(the commit before), such a read or blend would take the stored codes, which is wrong but valid
output. Both are now a typed refusal, NotImplemented(Format) at Attachment::Color(n), on every
device and in either fetch form. This is the same boundary as the runtime's own refusal of every
extended-range texture: Gap::TextureFormat (crates/metal2vulkan-runtime/src/error.rs:1011),
raised in texture.rs's form() (texture.rs:2416, `if !viewed(mapping.emulation)`), so rt never
makes such an attachment.

Where (lower::fragment::fetch::codes_round_the_tile names the forms: an extended-range form that
is neither padded nor bfloat):
- A fetch: color::select_param, beside the bfloat fetch's refusal. It runs for the storage form
  and the input attachment alike. An integer read stays Metal's pipeline error
  (InvalidDescriptor(ColorAttachment)).
- A blend into one the function writes, under any write mask:
  - fetch::blended_extended_range, which both ordered devices' plans call (the interlocked storage
    form, and input_blend over rasterization-order input attachments);
  - stage_io::extended_color::plan, on a device that orders fetch in neither form. It is checked
    before the orderings' refusal, since no device would make the blend.
- The public door metal::format::extended_range_blend answers NotImplemented(Format) for those
  forms on every device.

Unchanged: an unblended write and a masked merge (a kept code is the encode of the half the tile
keeps there). Padded forms (R10Unorm_X6, RG10Unorm_X12, their _sRGB twins, RGB10A2Unorm_sRGB):
their fetches and blends are built as before. Bfloat: its fetch is refused as before, and its
blend is Metal's error.

Dead with it: the source-range clamp only those blends took. Every caller of
extended_range::blend::native now passes a padded form's None. Removed: blend::extended_ranges,
clamped_lanes and native's ranges parameter, extended_range::source_range, and blend_color.rs
(SOURCE_RANGE, SRGB_SOURCE_RANGE). The validation build script's runtime inputs list
blend_color.rs no more, and the runtime pin moves. In the CPU-model tests: the XR forms' blend
cases and EVERY_FORM; the padded blends keep their model.

Docs: fetch's module docs (the extended-range paragraph, plus one on Apple's forms in place of the
"across draws" one), color's and stage_io::extended_color's, input_blend's, ExtendedRangeColor's,
PrecisionNote::ExtendedRangeBlendSource and ExtendedRangeFloatBlendSource (now padded only), the
door's, and docs/API.md (section 4's framebuffer fetch, and the two notes' catalogue entries).
docs/REFUSALS.md regenerated, api_signatures blessed.

Conformance (crates/metal2vulkan-conformance/known-gaps-rt.tsv), by expectation: the next round's
conformance replay on every card confirms them. 260 rows change their answer from "unsupported:
FramebufferFetch; needs AnyOf([[Feature(FragmentShaderPixelInterlock)],
[Feature(RasterizationOrderColorAttachmentAccess)]])" to "unsupported: Format; needs
NotImplemented", at the same metadata and color attachment. Their explanation now names the
refusal:
- xr-blend-* (108);
- xr-gamut-* (108);
- xr-gradient-*-blended (24);
- xr-masked-*-over (20).
The unblended masked rows (xr-masked-bgr10xr-red, -blue-green and their sRGB twins) keep the
orderings' refusal. The runtime's floor orders fetch in neither form, so its stage_io refusal is
what these rows record. docs/CONFORMANCE-COVERAGE.md is regenerated.

Tests:
- fetch::tests: the door's case splits Apple's forms (NotImplemented) from the padded blended
  ones; on runtime-floor, R10Unorm_X6 keeps the orderings' refusal and BGRA10_XR is
  NotImplemented; the moltenvk-m3 FragmentStoresAndAtomics case takes R10Unorm_X6.
- engine_extended_range::blended_pipelines: a `refused` helper (Format, NotImplemented,
  Color(0)); the wide-gamut client pipelines are refused on every venue and runtime-floor; the
  unwritten and masked test expects the refusal for every written blended shape.
- engine_extended_range::targets: a blended attachment, and lavapipe's fetch, expect the refusal.
- engine_fragment: a_fetched_extended_range_attachment_is_refused (every Apple form on every
  committed profile, exf_fetch_three, and the whole pipeline on moltenvk-m3) replaces the made
  fetch; the fast source-alpha-over sRGB XR blend and the input-attachment XR blend go, as they
  covered refused forms only; the premultiplied blend test and the blend note's test move to
  padded forms (RG10Unorm_X12 and its sRGB twin). con_fetch_coverage, the second-source blend and
  tsw_fetch_discard keep their storage-form and coverage mechanics on RGB10A2Unorm_sRGB, the
  four-channel padded form, where the guests' pipelines had RGB10A8_2P_XR10; their docs say so.
- lower::arith::extended_range::tests: the padded forms' blend model alone.

SEMANTICS_VERSION 2225 (after guestgaps' 2224, on development 81bd82fdaa): the refused inputs'
cached artifacts must not be served. Every made pipeline lowers to the same words: native's clamp
ran for XR forms alone. The old render key test is re-pinned by the commit after this one, from
the check job's printed key. ARTIFACT (569, the shadows' deletion) and RUNTIME stay; the runtime
pin moves with the sources.

Consumer check (consumer-uses.sh, consumer development b955213d27, 64 refs): extended_ranges,
SOURCE_RANGE, SRGB_SOURCE_RANGE, blend_color, clamped_lanes and codes_round_the_tile have 0 hits.
source_range's hits are the consumer's own field (CopyIndirectCommandBuffer::source_range,
unrelated); ours was a private fn.

Verified, at the earlier base 453eec0373 with this change: check 60853 (4406 tests, 10 failed:
the render key, the tests above and the coverage doc, all changed here since; 60899 then showed a
closure type in the new engine_fragment test, fixed here). A states-only play of that tree over
the recordings (60871, 60872, 60873, 60893, 60900) refused 0 render and 0 compute states. The
check and the play at this tree are named in the next commit and the report.
This commit is contained in:
Anees Iqbal committed 2026-11-20 17:26:22 -08:00
1 parent 2028eb6356
commit 81ced9a1cb
23 files changed
+609 -1150

No files matched your search

+14 -9
View File
@@ -833,7 +833,12 @@ Where Metal's rules differ from Vulkan's, the pipeline gives Metal's answer:
fetching draw after the earlier draws of its pass. Linking refuses an attachment the read
cannot take: none attached, or one of another numeric class than the read's
(`InvalidDescriptor` at the color attachment), or one of a rotated, Y'CbCr or extended-range
format (`Unsupported{Format}`). A
format (`Unsupported{Format}`). A read of one of Apple's extended-range formats (`BGR10_XR`,
`BGRA10_XR`, `RGB10A8_2P_XR10` and their `_sRGB` twins), and a blend into one, are refused on
every device in either form (`Unsupported{Format}` at the color attachment): Metal's tile holds
such an attachment as `half` through the render pass and rounds it to the codes only at the
store, so a read or a blend after an earlier draw's write sees that draw's `half`, which the
stored codes do not keep. An unblended write, under any write mask, is built. A
raster order group on such a color input, or on a color output of an attachment the function
reads, orders that read alone there and takes no interlock; a group on anything else still
needs the pixel interlock (`Unsupported{RasterOrderGroups}`).
@@ -2350,12 +2355,12 @@ bound.
`PrecisionNote::HalfOutputFastMathBlend` instead).
- `metal2vulkan-degrade-extended-range-blend-source` (precision).
`PrecisionNote::ExtendedRangeBlendSource`: A fragment function's `half` color output (a scalar or
vector of AIR's `half`) is blended into an extended-range attachment (`BGR10_XR`, `BGRA10_XR`,
`RGB10A8_2P_XR10`, or an `_sRGB` twin) or a padded 10-bit one (`R10Unorm_X6`, `RG10Unorm_X12`,
their `_sRGB` twins, `RGB10A2Unorm_sRGB`), whose raw codes no device's blend unit reads, so the
function blends in the shader in the device's arithmetic: `S·Fs op D·Fd` in `float`, in the blend
equation's order, the source, second source and blend color clamped to the format's range first
(a padded format's not clamped, as Metal clamps none there). The device's compiler may contract a
vector of AIR's `half`) is blended into a padded 10-bit attachment (`R10Unorm_X6`,
`RG10Unorm_X12`, their `_sRGB` twins, `RGB10A2Unorm_sRGB`), whose raw codes no device's blend
unit reads, so the function blends in the shader in the device's arithmetic: `S·Fs op D·Fd` in
`float`, in the blend equation's order, the source, second source and blend color unclamped, as
Metal takes them there (a blend into one of Apple's extended-range formats is refused, section
4). The device's compiler may contract a
product into its sum and may regroup the blend: MoltenVK on the M3 Max and NVIDIA's driver on an
RTX 5080 compute a second source's blend `S·F + D·(1 - F)` as `D + F·(S - D)`. Metal's compiler
rounds each step to `half`, so a blended channel may store another code than Metal's: within two
@@ -2365,8 +2370,8 @@ bound.
its sign picks where Metal's sum is NaN, stored as code 0.
- `metal2vulkan-degrade-extended-range-float-blend-source` (precision).
`PrecisionNote::ExtendedRangeFloatBlendSource`: `PrecisionNote::ExtendedRangeBlendSource` for a
`float` color output (a scalar or vector of AIR's `float`): blended into an extended-range or
padded 10-bit attachment in the shader in the device's arithmetic, which the device's compiler
`float` color output (a scalar or vector of AIR's `float`): blended into a padded 10-bit
attachment in the shader in the device's arithmetic, which the device's compiler
may contract and regroup, where Metal's compiler rounds the output and each step of the blend to
`half`; a blended channel within `ExtendedRangeBlendSource`'s bound of Metal's.
- `metal2vulkan-degrade-anisotropic-filter` (precision). `PrecisionNote::AnisotropicFilter`: The