Translator and runtime: BGR10_XR and BGRA10_XR textures are held as the UNORM codes of their bits and read as Metal's values

An arm64 guest walk met MTLPixelFormatBGR10_XR (554) and MTLPixelFormatBGRA10_XR (552), which the
runtime refused (Gap::TextureFormat): the translator held them raw in an integer format whose
values the identity domains do not convert.

A texture of either is now held in the UNORM format of its bits (FormatEmulation::ExtendedRangeUnorm):
BGR10_XR in A2R10G10B10_UNORM_PACK32, bit-identical, its alpha read as one; BGRA10_XR in
R16G16B16A16_UNORM, viewed with red and blue exchanged. Copies, blits, getBytes and replaceRegion
move Metal's bytes unchanged. The emulation is admitted for sampling, linear filtering and min/max
reductions; a device whose format query lacks the usage is refused the texture. The runtime's form
admits it.

Every float or half sample, gather and read of a sampled colour image (lower::texture::extended_unorm)
tests the texture's word: a slot's pushed resource ID word, format (word >> 16) in 552..554; an
argument buffer member's handle, which now carries the word's low bits and bit 30 where the word
names one of those formats (AccessPlan::heap_extended). Where it does, each lane holding a channel's
code (the word's border-texel bits: code lanes, and alpha lanes) is mapped from the field's value u to
Metal's (c - 384) / 510: w = u * m (m = 1023, or 65535 / 64), a read's and a gather's code taken
whole (a 16-bit field's floor(w + 1/128), whatever its low 6 bits hold; a 10-bit field's nearest
code, floor(w + 1/2), as NVIDIA's gather on the RTX 3090 widens a 10-bit code by replicating its
bits, (c << 6 | c >> 4) / 65535, up to 0.015 of a code low, m3-max-85756), alpha clamped to [384, 894], and the quotient formed as n * KH + n * KL
(KH + KL the f32 split of 1/510), which rounds once to Metal's correctly rounded value at every code,
fused or not (unit tests over all 1024 codes of both formats, and of a replicated 10-bit code). The difference, both products and the sum are
decorated NoContraction: lavapipe otherwise factored the sum into n * fl(1/510), which misrounds 572
of the codes (the first try replay's reads one f32 step off at exactly the codes that misround). A read the device's robustness bounds
tests its operands inside the branch and reads a code lane outside as 0, Metal's out-of-bounds texel.
A sample is the device's filter of the codes, which the affine map keeps. On a real card a
nearest sample is Metal's value exactly: the RX 7900 XTX's every nearest sample of both formats,
m3-max-85664. Lavapipe converts a field by its reciprocal, c * fl(1 / (2^b - 1)), as
PrecisionNote::DeviceTexelConversion records, and the map keeps that: its nearest sample of
BGRA10_XR's code 602 is four f32 ulps from Metal's (m3-max-85482, LLVM 23.1.1; m3-max-85612, LLVM
23.1.4). The runtime test compares nearest samples exactly, on lavapipe (cfg m2v_cpu_icd) against
lavapipe's conversion so mapped.

A render pipeline with a 552 or 554 colour attachment is made as before, through the formats'
second, raw candidate (R32_UINT, R16G16B16A16_UINT; emulation ExtendedRange): their render targets
are not built, and a texture of either with RenderTarget usage takes that candidate, which the
runtime refuses (Gap::TextureFormat), so no pass draws into one. A storage element is not built
(the storage choice refuses the emulation).

Not built (the runtime's known gaps, docs/API.md): a sample past the edge through a border address
mode reads the device's border in code space (opaque white 1.2529, BGRA10_XR's 1.2549; black
-0.7529); a linear sample of a BGRA10_XR texel whose fields' low 6 bits are set filters them in
(within 63/64 of a code step); every float sample, gather and read of a sampled colour image pays
the word's test and branch.

SEMANTICS_VERSION 2373 (module words: the arm, the handle's bits). RUNTIME_VERSION 2572 (a run views an
extended-range format held as its UNORM codes); runtime-sources.sha256 re-pinned. api_signatures
blessed: FormatEmulation::ExtendedRangeUnorm added
(a consumer matching FormatEmulation exhaustively meets a new variant; the enum is non_exhaustive).
REFUSALS.md unchanged.

The ledger's llvmpipe rows for extended-swizzles-bgr10xr gain the four border sites (0ag1/g2,
0ag1/sl, 0ag1/sn, ar10/g1) the replay on lavapipe at the CI pin (Mesa 26.2.4, LLVM 23.1.1) shows,
m3-max-85482, and its BGRA10_XR rows of nearest and linear samples name the low-bits gap beside
the border's: most of the case's random fields hold low bits, which a sample filters in. Lavapipe's
conversion shows at none of the case's elements (each texel's fields checked against lavapipe's
reciprocal conversion). Coverage regenerated.
This commit is contained in:
Anees Iqbal committed 2026-12-03 16:14:41 -08:00
1 parent 5d628eeee8
commit 58988c6b83
22 files changed
+940 -46

No files matched your search

@@ -501,6 +501,50 @@ extended-swizzles-b5g6r5unorm Iris(R) Xe divergent case/rgba/sl 354 elements dif
extended-swizzles-b5g6r5unorm NVIDIA divergent case/rgba/sl 354 elements differ (U32), the largest difference 356555 The device's own answer (rule 1): a linear sample of a packed 16-bit unorm texture through a swizzled view: the device filters its own decode of the codes (a 5- or 6-bit code widened to 8 bits and read over 255), where Metal's texture unit answers the code over its own maximum and filters that. Notes `device-texel-conversion` and `device-sampling`. Open: nothing.
extended-swizzles-b5g6r5unorm Iris(R) Xe divergent case/rgba/sn 258 elements differ (U32), the largest difference 356555 The device's own answer (rule 1): a read, nearest sample or gather of a packed 16-bit unorm texel through a swizzled view: the device widens a 5- or 6-bit code to 8 bits by repeating its top bits and reads that byte over 255 (a 6-bit 15 reads 60/255), where Metal answers the code over its own maximum. Note `device-texel-conversion`, whose recorded bound puts a 5- or 6-bit channel within 0.18 of a code of Metal's. Open: nothing.
extended-swizzles-b5g6r5unorm NVIDIA divergent case/rgba/sn 258 elements differ (U32), the largest difference 356555 The device's own answer (rule 1): a read, nearest sample or gather of a packed 16-bit unorm texel through a swizzled view: the device widens a 5- or 6-bit code to 8 bits by repeating its top bits and reads that byte over 255 (a 6-bit 15 reads 60/255), where Metal answers the code over its own maximum. Note `device-texel-conversion`, whose recorded bound puts a 5- or 6-bit channel within 0.18 of a code of Metal's. Open: nothing.
extended-swizzles-bgr10xr llvmpipe divergent case/0ag1/g2 336 elements differ (U32), the largest difference 2121824 A known gap of the runtime (its README, Known gaps of textures): the texture is held as the UNORM codes of its bits, and a nearest or linear sample or a gather past its edge through a runtime sampler's clamp to border reads the device's border colour as a code (opaque white as `1.2529`, black as `-0.7529`) where Metal reads 1 or 0; a linear sample across the edge blends toward it. Every other texel answers Metal's value.
extended-swizzles-bgr10xr llvmpipe divergent case/0ag1/sl 131 elements differ (U32), the largest difference 8018522 A known gap of the runtime (its README, Known gaps of textures): the texture is held as the UNORM codes of its bits, and a nearest or linear sample or a gather past its edge through a runtime sampler's clamp to border reads the device's border colour as a code (opaque white as `1.2529`, black as `-0.7529`) where Metal reads 1 or 0; a linear sample across the edge blends toward it. Every other texel answers Metal's value.
extended-swizzles-bgr10xr llvmpipe divergent case/0ag1/sn 84 elements differ (U32), the largest difference 2121824 A known gap of the runtime (its README, Known gaps of textures): the texture is held as the UNORM codes of its bits, and a nearest or linear sample or a gather past its edge through a runtime sampler's clamp to border reads the device's border colour as a code (opaque white as `1.2529`, black as `-0.7529`) where Metal reads 1 or 0; a linear sample across the edge blends toward it. Every other texel answers Metal's value.
extended-swizzles-bgr10xr llvmpipe divergent case/ar10/g1 336 elements differ (U32), the largest difference 2121824 A known gap of the runtime (its README, Known gaps of textures): the texture is held as the UNORM codes of its bits, and a nearest or linear sample or a gather past its edge through a runtime sampler's clamp to border reads the device's border colour as a code (opaque white as `1.2529`, black as `-0.7529`) where Metal reads 1 or 0; a linear sample across the edge blends toward it. Every other texel answers Metal's value.
extended-swizzles-bgr10xr llvmpipe divergent case/ar10/sl 130 elements differ (U32), the largest difference 8756638 A known gap of the runtime (its README, Known gaps of textures): the texture is held as the UNORM codes of its bits, and a nearest or linear sample or a gather past its edge through a runtime sampler's clamp to border reads the device's border colour as a code (opaque white as `1.2529`, black as `-0.7529`) where Metal reads 1 or 0; a linear sample across the edge blends toward it. Every other texel answers Metal's value.
extended-swizzles-bgr10xr llvmpipe divergent case/ar10/sn 84 elements differ (U32), the largest difference 2121824 A known gap of the runtime (its README, Known gaps of textures): the texture is held as the UNORM codes of its bits, and a nearest or linear sample or a gather past its edge through a runtime sampler's clamp to border reads the device's border colour as a code (opaque white as `1.2529`, black as `-0.7529`) where Metal reads 1 or 0; a linear sample across the edge blends toward it. Every other texel answers Metal's value.
extended-swizzles-bgr10xr llvmpipe divergent case/bgra/g0 336 elements differ (U32), the largest difference 2121824 A known gap of the runtime (its README, Known gaps of textures): the texture is held as the UNORM codes of its bits, and a nearest or linear sample or a gather past its edge through a runtime sampler's clamp to border reads the device's border colour as a code (opaque white as `1.2529`, black as `-0.7529`) where Metal reads 1 or 0; a linear sample across the edge blends toward it. Every other texel answers Metal's value.
extended-swizzles-bgr10xr llvmpipe divergent case/bgra/g1 336 elements differ (U32), the largest difference 2121824 A known gap of the runtime (its README, Known gaps of textures): the texture is held as the UNORM codes of its bits, and a nearest or linear sample or a gather past its edge through a runtime sampler's clamp to border reads the device's border colour as a code (opaque white as `1.2529`, black as `-0.7529`) where Metal reads 1 or 0; a linear sample across the edge blends toward it. Every other texel answers Metal's value.
extended-swizzles-bgr10xr llvmpipe divergent case/bgra/g2 336 elements differ (U32), the largest difference 2121824 A known gap of the runtime (its README, Known gaps of textures): the texture is held as the UNORM codes of its bits, and a nearest or linear sample or a gather past its edge through a runtime sampler's clamp to border reads the device's border colour as a code (opaque white as `1.2529`, black as `-0.7529`) where Metal reads 1 or 0; a linear sample across the edge blends toward it. Every other texel answers Metal's value.
extended-swizzles-bgr10xr llvmpipe divergent case/bgra/sl 392 elements differ (U32), the largest difference 8783366 A known gap of the runtime (its README, Known gaps of textures): the texture is held as the UNORM codes of its bits, and a nearest or linear sample or a gather past its edge through a runtime sampler's clamp to border reads the device's border colour as a code (opaque white as `1.2529`, black as `-0.7529`) where Metal reads 1 or 0; a linear sample across the edge blends toward it. Every other texel answers Metal's value.
extended-swizzles-bgr10xr llvmpipe divergent case/bgra/sn 252 elements differ (U32), the largest difference 2121824 A known gap of the runtime (its README, Known gaps of textures): the texture is held as the UNORM codes of its bits, and a nearest or linear sample or a gather past its edge through a runtime sampler's clamp to border reads the device's border colour as a code (opaque white as `1.2529`, black as `-0.7529`) where Metal reads 1 or 0; a linear sample across the edge blends toward it. Every other texel answers Metal's value.
extended-swizzles-bgr10xr llvmpipe divergent case/gggg/g0 336 elements differ (U32), the largest difference 2121824 A known gap of the runtime (its README, Known gaps of textures): the texture is held as the UNORM codes of its bits, and a nearest or linear sample or a gather past its edge through a runtime sampler's clamp to border reads the device's border colour as a code (opaque white as `1.2529`, black as `-0.7529`) where Metal reads 1 or 0; a linear sample across the edge blends toward it. Every other texel answers Metal's value.
extended-swizzles-bgr10xr llvmpipe divergent case/gggg/g1 336 elements differ (U32), the largest difference 2121824 A known gap of the runtime (its README, Known gaps of textures): the texture is held as the UNORM codes of its bits, and a nearest or linear sample or a gather past its edge through a runtime sampler's clamp to border reads the device's border colour as a code (opaque white as `1.2529`, black as `-0.7529`) where Metal reads 1 or 0; a linear sample across the edge blends toward it. Every other texel answers Metal's value.
extended-swizzles-bgr10xr llvmpipe divergent case/gggg/g2 336 elements differ (U32), the largest difference 2121824 A known gap of the runtime (its README, Known gaps of textures): the texture is held as the UNORM codes of its bits, and a nearest or linear sample or a gather past its edge through a runtime sampler's clamp to border reads the device's border colour as a code (opaque white as `1.2529`, black as `-0.7529`) where Metal reads 1 or 0; a linear sample across the edge blends toward it. Every other texel answers Metal's value.
extended-swizzles-bgr10xr llvmpipe divergent case/gggg/g3 336 elements differ (U32), the largest difference 2121824 A known gap of the runtime (its README, Known gaps of textures): the texture is held as the UNORM codes of its bits, and a nearest or linear sample or a gather past its edge through a runtime sampler's clamp to border reads the device's border colour as a code (opaque white as `1.2529`, black as `-0.7529`) where Metal reads 1 or 0; a linear sample across the edge blends toward it. Every other texel answers Metal's value.
extended-swizzles-bgr10xr llvmpipe divergent case/gggg/sl 524 elements differ (U32), the largest difference 8018522 A known gap of the runtime (its README, Known gaps of textures): the texture is held as the UNORM codes of its bits, and a nearest or linear sample or a gather past its edge through a runtime sampler's clamp to border reads the device's border colour as a code (opaque white as `1.2529`, black as `-0.7529`) where Metal reads 1 or 0; a linear sample across the edge blends toward it. Every other texel answers Metal's value.
extended-swizzles-bgr10xr llvmpipe divergent case/gggg/sn 336 elements differ (U32), the largest difference 2121824 A known gap of the runtime (its README, Known gaps of textures): the texture is held as the UNORM codes of its bits, and a nearest or linear sample or a gather past its edge through a runtime sampler's clamp to border reads the device's border colour as a code (opaque white as `1.2529`, black as `-0.7529`) where Metal reads 1 or 0; a linear sample across the edge blends toward it. Every other texel answers Metal's value.
extended-swizzles-bgr10xr llvmpipe divergent case/rgba/g0 336 elements differ (U32), the largest difference 2121824 A known gap of the runtime (its README, Known gaps of textures): the texture is held as the UNORM codes of its bits, and a nearest or linear sample or a gather past its edge through a runtime sampler's clamp to border reads the device's border colour as a code (opaque white as `1.2529`, black as `-0.7529`) where Metal reads 1 or 0; a linear sample across the edge blends toward it. Every other texel answers Metal's value.
extended-swizzles-bgr10xr llvmpipe divergent case/rgba/g1 336 elements differ (U32), the largest difference 2121824 A known gap of the runtime (its README, Known gaps of textures): the texture is held as the UNORM codes of its bits, and a nearest or linear sample or a gather past its edge through a runtime sampler's clamp to border reads the device's border colour as a code (opaque white as `1.2529`, black as `-0.7529`) where Metal reads 1 or 0; a linear sample across the edge blends toward it. Every other texel answers Metal's value.
extended-swizzles-bgr10xr llvmpipe divergent case/rgba/g2 336 elements differ (U32), the largest difference 2121824 A known gap of the runtime (its README, Known gaps of textures): the texture is held as the UNORM codes of its bits, and a nearest or linear sample or a gather past its edge through a runtime sampler's clamp to border reads the device's border colour as a code (opaque white as `1.2529`, black as `-0.7529`) where Metal reads 1 or 0; a linear sample across the edge blends toward it. Every other texel answers Metal's value.
extended-swizzles-bgr10xr llvmpipe divergent case/rgba/sl 392 elements differ (U32), the largest difference 8783366 A known gap of the runtime (its README, Known gaps of textures): the texture is held as the UNORM codes of its bits, and a nearest or linear sample or a gather past its edge through a runtime sampler's clamp to border reads the device's border colour as a code (opaque white as `1.2529`, black as `-0.7529`) where Metal reads 1 or 0; a linear sample across the edge blends toward it. Every other texel answers Metal's value.
extended-swizzles-bgr10xr llvmpipe divergent case/rgba/sn 252 elements differ (U32), the largest difference 2121824 A known gap of the runtime (its README, Known gaps of textures): the texture is held as the UNORM codes of its bits, and a nearest or linear sample or a gather past its edge through a runtime sampler's clamp to border reads the device's border colour as a code (opaque white as `1.2529`, black as `-0.7529`) where Metal reads 1 or 0; a linear sample across the edge blends toward it. Every other texel answers Metal's value.
extended-swizzles-bgra10xr llvmpipe divergent case/0ag1/g2 336 elements differ (U32), the largest difference 2121824 A known gap of the runtime (its README, Known gaps of textures): the texture is held as the UNORM codes of its bits, and a nearest or linear sample or a gather past its edge through a runtime sampler's clamp to border reads the device's border colour as a code (opaque white as `1.2549`, black as `-0.7529`) where Metal reads 1 or 0; a linear sample across the edge blends toward it. Every other texel answers Metal's value.
extended-swizzles-bgra10xr llvmpipe divergent case/0ag1/sl 276 elements differ (U32), the largest difference 2159286264 A known gap of the runtime (its README, Known gaps of textures): the texture is held as the UNORM codes of its bits, and a nearest or linear sample or a gather past its edge through a runtime sampler's clamp to border reads the device's border colour as a code (opaque white as `1.2549`, black as `-0.7529`) where Metal reads 1 or 0; a linear sample across the edge blends toward it. Every other texel answers Metal's value but one whose fields' low 6 bits are not zero, as most of this case's random texels' are: a sample filters those bits in, within `63/64` of a code step, where Metal reads the code alone (the same known gaps).
extended-swizzles-bgra10xr llvmpipe divergent case/0ag1/sn 222 elements differ (U32), the largest difference 2138016 A known gap of the runtime (its README, Known gaps of textures): the texture is held as the UNORM codes of its bits, and a nearest or linear sample or a gather past its edge through a runtime sampler's clamp to border reads the device's border colour as a code (opaque white as `1.2549`, black as `-0.7529`) where Metal reads 1 or 0; a linear sample across the edge blends toward it. Every other texel answers Metal's value but one whose fields' low 6 bits are not zero, as most of this case's random texels' are: a sample filters those bits in, within `63/64` of a code step, where Metal reads the code alone (the same known gaps).
extended-swizzles-bgra10xr llvmpipe divergent case/ar10/g1 336 elements differ (U32), the largest difference 2121824 A known gap of the runtime (its README, Known gaps of textures): the texture is held as the UNORM codes of its bits, and a nearest or linear sample or a gather past its edge through a runtime sampler's clamp to border reads the device's border colour as a code (opaque white as `1.2549`, black as `-0.7529`) where Metal reads 1 or 0; a linear sample across the edge blends toward it. Every other texel answers Metal's value.
extended-swizzles-bgra10xr llvmpipe divergent case/ar10/sl 276 elements differ (U32), the largest difference 1048576000 A known gap of the runtime (its README, Known gaps of textures): the texture is held as the UNORM codes of its bits, and a nearest or linear sample or a gather past its edge through a runtime sampler's clamp to border reads the device's border colour as a code (opaque white as `1.2549`, black as `-0.7529`) where Metal reads 1 or 0; a linear sample across the edge blends toward it. Every other texel answers Metal's value but one whose fields' low 6 bits are not zero, as most of this case's random texels' are: a sample filters those bits in, within `63/64` of a code step, where Metal reads the code alone (the same known gaps).
extended-swizzles-bgra10xr llvmpipe divergent case/ar10/sn 222 elements differ (U32), the largest difference 2138016 A known gap of the runtime (its README, Known gaps of textures): the texture is held as the UNORM codes of its bits, and a nearest or linear sample or a gather past its edge through a runtime sampler's clamp to border reads the device's border colour as a code (opaque white as `1.2549`, black as `-0.7529`) where Metal reads 1 or 0; a linear sample across the edge blends toward it. Every other texel answers Metal's value but one whose fields' low 6 bits are not zero, as most of this case's random texels' are: a sample filters those bits in, within `63/64` of a code step, where Metal reads the code alone (the same known gaps).
extended-swizzles-bgra10xr llvmpipe divergent case/bgra/g0 336 elements differ (U32), the largest difference 2121824 A known gap of the runtime (its README, Known gaps of textures): the texture is held as the UNORM codes of its bits, and a nearest or linear sample or a gather past its edge through a runtime sampler's clamp to border reads the device's border colour as a code (opaque white as `1.2549`, black as `-0.7529`) where Metal reads 1 or 0; a linear sample across the edge blends toward it. Every other texel answers Metal's value.
extended-swizzles-bgra10xr llvmpipe divergent case/bgra/g1 336 elements differ (U32), the largest difference 2121824 A known gap of the runtime (its README, Known gaps of textures): the texture is held as the UNORM codes of its bits, and a nearest or linear sample or a gather past its edge through a runtime sampler's clamp to border reads the device's border colour as a code (opaque white as `1.2549`, black as `-0.7529`) where Metal reads 1 or 0; a linear sample across the edge blends toward it. Every other texel answers Metal's value.
extended-swizzles-bgra10xr llvmpipe divergent case/bgra/g2 336 elements differ (U32), the largest difference 2121824 A known gap of the runtime (its README, Known gaps of textures): the texture is held as the UNORM codes of its bits, and a nearest or linear sample or a gather past its edge through a runtime sampler's clamp to border reads the device's border colour as a code (opaque white as `1.2549`, black as `-0.7529`) where Metal reads 1 or 0; a linear sample across the edge blends toward it. Every other texel answers Metal's value.
extended-swizzles-bgra10xr llvmpipe divergent case/bgra/sl 636 elements differ (U32), the largest difference 2159286264 A known gap of the runtime (its README, Known gaps of textures): the texture is held as the UNORM codes of its bits, and a nearest or linear sample or a gather past its edge through a runtime sampler's clamp to border reads the device's border colour as a code (opaque white as `1.2549`, black as `-0.7529`) where Metal reads 1 or 0; a linear sample across the edge blends toward it. Every other texel answers Metal's value but one whose fields' low 6 bits are not zero, as most of this case's random texels' are: a sample filters those bits in, within `63/64` of a code step, where Metal reads the code alone (the same known gaps).
extended-swizzles-bgra10xr llvmpipe divergent case/bgra/sn 582 elements differ (U32), the largest difference 2138016 A known gap of the runtime (its README, Known gaps of textures): the texture is held as the UNORM codes of its bits, and a nearest or linear sample or a gather past its edge through a runtime sampler's clamp to border reads the device's border colour as a code (opaque white as `1.2549`, black as `-0.7529`) where Metal reads 1 or 0; a linear sample across the edge blends toward it. Every other texel answers Metal's value but one whose fields' low 6 bits are not zero, as most of this case's random texels' are: a sample filters those bits in, within `63/64` of a code step, where Metal reads the code alone (the same known gaps).
extended-swizzles-bgra10xr llvmpipe divergent case/gggg/g0 336 elements differ (U32), the largest difference 2121824 A known gap of the runtime (its README, Known gaps of textures): the texture is held as the UNORM codes of its bits, and a nearest or linear sample or a gather past its edge through a runtime sampler's clamp to border reads the device's border colour as a code (opaque white as `1.2549`, black as `-0.7529`) where Metal reads 1 or 0; a linear sample across the edge blends toward it. Every other texel answers Metal's value.
extended-swizzles-bgra10xr llvmpipe divergent case/gggg/g1 336 elements differ (U32), the largest difference 2121824 A known gap of the runtime (its README, Known gaps of textures): the texture is held as the UNORM codes of its bits, and a nearest or linear sample or a gather past its edge through a runtime sampler's clamp to border reads the device's border colour as a code (opaque white as `1.2549`, black as `-0.7529`) where Metal reads 1 or 0; a linear sample across the edge blends toward it. Every other texel answers Metal's value.
extended-swizzles-bgra10xr llvmpipe divergent case/gggg/g2 336 elements differ (U32), the largest difference 2121824 A known gap of the runtime (its README, Known gaps of textures): the texture is held as the UNORM codes of its bits, and a nearest or linear sample or a gather past its edge through a runtime sampler's clamp to border reads the device's border colour as a code (opaque white as `1.2549`, black as `-0.7529`) where Metal reads 1 or 0; a linear sample across the edge blends toward it. Every other texel answers Metal's value.
extended-swizzles-bgra10xr llvmpipe divergent case/gggg/g3 336 elements differ (U32), the largest difference 2121824 A known gap of the runtime (its README, Known gaps of textures): the texture is held as the UNORM codes of its bits, and a nearest or linear sample or a gather past its edge through a runtime sampler's clamp to border reads the device's border colour as a code (opaque white as `1.2549`, black as `-0.7529`) where Metal reads 1 or 0; a linear sample across the edge blends toward it. Every other texel answers Metal's value.
extended-swizzles-bgra10xr llvmpipe divergent case/gggg/sl 720 elements differ (U32), the largest difference 2159286264 A known gap of the runtime (its README, Known gaps of textures): the texture is held as the UNORM codes of its bits, and a nearest or linear sample or a gather past its edge through a runtime sampler's clamp to border reads the device's border colour as a code (opaque white as `1.2549`, black as `-0.7529`) where Metal reads 1 or 0; a linear sample across the edge blends toward it. Every other texel answers Metal's value but one whose fields' low 6 bits are not zero, as most of this case's random texels' are: a sample filters those bits in, within `63/64` of a code step, where Metal reads the code alone (the same known gaps).
extended-swizzles-bgra10xr llvmpipe divergent case/gggg/sn 720 elements differ (U32), the largest difference 2138016 A known gap of the runtime (its README, Known gaps of textures): the texture is held as the UNORM codes of its bits, and a nearest or linear sample or a gather past its edge through a runtime sampler's clamp to border reads the device's border colour as a code (opaque white as `1.2549`, black as `-0.7529`) where Metal reads 1 or 0; a linear sample across the edge blends toward it. Every other texel answers Metal's value but one whose fields' low 6 bits are not zero, as most of this case's random texels' are: a sample filters those bits in, within `63/64` of a code step, where Metal reads the code alone (the same known gaps).
extended-swizzles-bgra10xr llvmpipe divergent case/rgba/g0 336 elements differ (U32), the largest difference 2121824 A known gap of the runtime (its README, Known gaps of textures): the texture is held as the UNORM codes of its bits, and a nearest or linear sample or a gather past its edge through a runtime sampler's clamp to border reads the device's border colour as a code (opaque white as `1.2549`, black as `-0.7529`) where Metal reads 1 or 0; a linear sample across the edge blends toward it. Every other texel answers Metal's value.
extended-swizzles-bgra10xr llvmpipe divergent case/rgba/g1 336 elements differ (U32), the largest difference 2121824 A known gap of the runtime (its README, Known gaps of textures): the texture is held as the UNORM codes of its bits, and a nearest or linear sample or a gather past its edge through a runtime sampler's clamp to border reads the device's border colour as a code (opaque white as `1.2549`, black as `-0.7529`) where Metal reads 1 or 0; a linear sample across the edge blends toward it. Every other texel answers Metal's value.
extended-swizzles-bgra10xr llvmpipe divergent case/rgba/g2 336 elements differ (U32), the largest difference 2121824 A known gap of the runtime (its README, Known gaps of textures): the texture is held as the UNORM codes of its bits, and a nearest or linear sample or a gather past its edge through a runtime sampler's clamp to border reads the device's border colour as a code (opaque white as `1.2549`, black as `-0.7529`) where Metal reads 1 or 0; a linear sample across the edge blends toward it. Every other texel answers Metal's value.
extended-swizzles-bgra10xr llvmpipe divergent case/rgba/sl 636 elements differ (U32), the largest difference 2159286264 A known gap of the runtime (its README, Known gaps of textures): the texture is held as the UNORM codes of its bits, and a nearest or linear sample or a gather past its edge through a runtime sampler's clamp to border reads the device's border colour as a code (opaque white as `1.2549`, black as `-0.7529`) where Metal reads 1 or 0; a linear sample across the edge blends toward it. Every other texel answers Metal's value but one whose fields' low 6 bits are not zero, as most of this case's random texels' are: a sample filters those bits in, within `63/64` of a code step, where Metal reads the code alone (the same known gaps).
extended-swizzles-bgra10xr llvmpipe divergent case/rgba/sn 582 elements differ (U32), the largest difference 2138016 A known gap of the runtime (its README, Known gaps of textures): the texture is held as the UNORM codes of its bits, and a nearest or linear sample or a gather past its edge through a runtime sampler's clamp to border reads the device's border colour as a code (opaque white as `1.2549`, black as `-0.7529`) where Metal reads 1 or 0; a linear sample across the edge blends toward it. Every other texel answers Metal's value but one whose fields' low 6 bits are not zero, as most of this case's random texels' are: a sample filters those bits in, within `63/64` of a code step, where Metal reads the code alone (the same known gaps).
extended-swizzles-bgr5a1unorm Iris(R) Xe divergent case/0ag1/g2 360 elements differ (U32), the largest difference 356555 The device's own answer (rule 1): a read, nearest sample or gather of a packed 16-bit unorm texel through a swizzled view: the device widens a 5- or 6-bit code to 8 bits by repeating its top bits and reads that byte over 255 (a 6-bit 15 reads 60/255), where Metal answers the code over its own maximum. Note `device-texel-conversion`, whose recorded bound puts a 5- or 6-bit channel within 0.18 of a code of Metal's. Open: nothing.
extended-swizzles-bgr5a1unorm NVIDIA divergent case/0ag1/g2 360 elements differ (U32), the largest difference 356555 The device's own answer (rule 1): a read, nearest sample or gather of a packed 16-bit unorm texel through a swizzled view: the device widens a 5- or 6-bit code to 8 bits by repeating its top bits and reads that byte over 255 (a 6-bit 15 reads 60/255), where Metal answers the code over its own maximum. Note `device-texel-conversion`, whose recorded bound puts a 5- or 6-bit channel within 0.18 of a code of Metal's. Open: nothing.
extended-swizzles-bgr5a1unorm Iris(R) Xe divergent case/0ag1/rf 30 elements differ (U32), the largest difference 356555 The device's own answer (rule 1): a read, nearest sample or gather of a packed 16-bit unorm texel through a swizzled view: the device widens a 5- or 6-bit code to 8 bits by repeating its top bits and reads that byte over 255 (a 6-bit 15 reads 60/255), where Metal answers the code over its own maximum. Note `device-texel-conversion`, whose recorded bound puts a 5- or 6-bit channel within 0.18 of a code of Metal's. Open: nothing.
@@ -5663,8 +5707,8 @@ astc-8x8-srgb AMD Radeon 780M refused case/zero-blocks/texture Err(Error::Unsupp
astc-8x8-srgb RX 7900 XTX refused case/zero-blocks/texture Err(Error::Unsupported("no texture of ASTC8x8SRGB is made on this device for the usage")) The device's own answer (rule 2): this device's format queries offer no image of MTLPixelFormatASTC_8x8_sRGB with the usage the case asks, so rt makes no such texture (Gap::TextureFormat, or the creator's NotMade).
astc-8x8-srgb NVIDIA refused case/zero-blocks/texture Err(Error::Unsupported("no texture of ASTC8x8SRGB is made on this device for the usage")) The device's own answer (rule 2): this device's format queries offer no image of MTLPixelFormatASTC_8x8_sRGB with the usage the case asks, so rt makes no such texture (Gap::TextureFormat, or the creator's NotMade).
blit-copy-indirect-command-buffer * refused case/pipeline Err(Error::Unsupported("indirect command buffers of ComputeCommands are not built")) refused: no stream uses it yet (full selector census 11-19, m3-max-53207-53208, 53213, 53217-53221: 26 streams, every pipeline descriptor's supportIndirectCommandBuffers NO). Gap::IndirectCommandBuffers, IndirectCommandsKind::ComputeCommands: a compute pipeline state for indirect command buffers is refused on every device; compute commands are not built (the runtime README, Known gaps of indirect command buffers).
blit-generated-mipmaps-bgr10xr * refused case/work Err({refused: Error::Unsupported("no texture of BGR10XR is made on this device for the usage"), resource: 0 (0x0)}) refused: no stream uses it yet (full selector census 11-19, m3-max-53207-53208, 53213, 53217-53221: 26 streams, no texture or view of MTLPixelFormatBGR10_XR). rt makes no texture of MTLPixelFormatBGR10_XR for the usage the case asks on any venue (Gap::TextureFormat, or the creator's NotMade).
blit-generated-mipmaps-bgra10xr * refused case/work Err({refused: Error::Unsupported("no texture of BGRA10XR is made on this device for the usage"), resource: 0 (0x0)}) refused: no stream uses it yet (full selector census 11-19, m3-max-53207-53208, 53213, 53217-53221: 26 streams, no texture or view of MTLPixelFormatBGRA10_XR). rt makes no texture of MTLPixelFormatBGRA10_XR for the usage the case asks on any venue (Gap::TextureFormat, or the creator's NotMade).
blit-generated-mipmaps-bgr10xr * refused case/work Err({refused: Error::Unsupported("mipmaps of a BGR10XR texture, whose image this device's blits do not filter"), step: 8 (0x8)}) refused: no stream uses it yet (full selector census 11-19, m3-max-53207-53208, 53213, 53217-53221: 26 streams, no texture or view of MTLPixelFormatBGR10_XR). rt holds a BGR10_XR texture as the UNORM codes of its bits (FormatEmulation::ExtendedRangeUnorm), whose levels the device's blit chain would filter as codes, not Metal's mipmaps: Gap::MipmapFilter on every venue.
blit-generated-mipmaps-bgra10xr * refused case/work Err({refused: Error::Unsupported("mipmaps of a BGRA10XR texture, whose image this device's blits do not filter"), step: 8 (0x8)}) refused: no stream uses it yet (full selector census 11-19, m3-max-53207-53208, 53213, 53217-53221: 26 streams, no texture or view of MTLPixelFormatBGRA10_XR). rt holds a BGRA10_XR texture as the UNORM codes of its bits (FormatEmulation::ExtendedRangeUnorm), whose levels the device's blit chain would filter as codes, not Metal's mipmaps: Gap::MipmapFilter on every venue.
blit-optimize-indirect-command-buffer * refused case/pipeline Err(Error::Unsupported("indirect command buffers of ComputeCommands are not built")) refused: no stream uses it yet (full selector census 11-19, m3-max-53207-53208, 53213, 53217-53221: 26 streams, every pipeline descriptor's supportIndirectCommandBuffers NO). Gap::IndirectCommandBuffers, IndirectCommandsKind::ComputeCommands: a compute pipeline state for indirect command buffers is refused on every device; compute commands are not built (the runtime README, Known gaps of indirect command buffers).
blit-optimized-contents * refused case/work Err({refused: Unavailable({call: "optimizeContentsForCPUAccess:"}), step: 6 (0x6)}) refused: no stream uses it yet (full selector census 11-19, m3-max-53207-53208, 53213, 53217-53221: 26 streams, no optimizeContents call). The rt side of the suite answers `optimizeContentsForCPUAccess:` Unavailable: rt has no counterpart of the call, and no replay stream makes it.
blit-reset-commands-in-buffer * refused case/pipeline Err(Error::Unsupported("indirect command buffers of ComputeCommands are not built")) refused: no stream uses it yet (full selector census 11-19, m3-max-53207-53208, 53213, 53217-53221: 26 streams, every pipeline descriptor's supportIndirectCommandBuffers NO). Gap::IndirectCommandBuffers, IndirectCommandsKind::ComputeCommands: a compute pipeline state for indirect command buffers is refused on every device; compute commands are not built (the runtime README, Known gaps of indirect command buffers).
@@ -5768,7 +5812,7 @@ chroma-pair-texel-reads-bgrg422 * refused case/texture Err(Error::Unsupported("n
chroma-pair-texel-reads-gbgr422 * refused case/texture Err(Error::Unsupported("no texture of GBGR422 is made on this device for the usage")) refused: no stream uses it yet (full selector census 11-19, m3-max-53207-53208, 53213, 53217-53221: 26 streams, no texture or view of MTLPixelFormatGBGR422). rt makes no texture of MTLPixelFormatGBGR422 for the usage the case asks on any venue (Gap::TextureFormat, or the creator's NotMade).
chroma-pair-texel-samples-bgrg422 * refused case/texture Err(Error::Unsupported("no texture of BGRG422 is made on this device for the usage")) refused: no stream uses it yet (full selector census 11-19, m3-max-53207-53208, 53213, 53217-53221: 26 streams, no texture or view of MTLPixelFormatBGRG422). rt makes no texture of MTLPixelFormatBGRG422 for the usage the case asks on any venue (Gap::TextureFormat, or the creator's NotMade).
chroma-pair-texel-samples-gbgr422 * refused case/texture Err(Error::Unsupported("no texture of GBGR422 is made on this device for the usage")) refused: no stream uses it yet (full selector census 11-19, m3-max-53207-53208, 53213, 53217-53221: 26 streams, no texture or view of MTLPixelFormatGBGR422). rt makes no texture of MTLPixelFormatGBGR422 for the usage the case asks on any venue (Gap::TextureFormat, or the creator's NotMade).
compressed-blits-bgra10xr * refused case/work Err({refused: Error::Unsupported("no texture of BGRA10XR is made on this device for the usage"), resource: 1 (0x1)}) refused: no stream uses it yet (full selector census 11-19, m3-max-53207-53208, 53213, 53217-53221: 26 streams, no texture or view of MTLPixelFormatBGRA10_XR). rt makes no texture of MTLPixelFormatBGRA10_XR for the usage the case asks on any venue (Gap::TextureFormat, or the creator's NotMade).
compressed-blits-bgra10xr * refused case/work Err({refused: Error::Refused("a region at 4 with rows 76 and images 0 bytes apart is no layout Metal takes in a buffer of 612 bytes"), step: 13 (0xd)}) refused: no stream uses it yet (full selector census 11-19, m3-max-53207-53208, 53213, 53217-53221: 26 streams, no texture or view of MTLPixelFormatBGRA10_XR). The case blits level 3 out at a buffer offset of 4, half of a BGRA10_XR texel; Metal without its validation layer copies it, and rt refuses an offset of no whole number of texels as Metal's validation layer stops it (Refusal::BufferCopyLayout), on every venue and for every 8-byte format.
compressed-blits-bgra10xr-srgb * refused case/work Err({refused: Error::Unsupported("no texture of BGRA10XRSRGB is made on this device for the usage"), resource: 1 (0x1)}) refused: no stream uses it yet (full selector census 11-19, m3-max-53207-53208, 53213, 53217-53221: 26 streams, no texture or view of MTLPixelFormatBGRA10_XR_sRGB). rt makes no texture of MTLPixelFormatBGRA10_XR_sRGB for the usage the case asks on any venue (Gap::TextureFormat, or the creator's NotMade).
detach-in-a-completed-handler * refused case/detach Err(Unavailable({call: "detachBacking"})) refused: no stream uses it yet (full selector census 11-19, m3-max-53207-53208, 53213, 53217-53221: 26 streams, no detachBacking). The rt side of the suite answers `detachBacking` Unavailable: rt has no counterpart of the call, and no replay stream makes it.
device-rate-map-layer-counts * refused case/layers-1 Err(Unavailable({call: "supports_rasterization_rate_map_layers"})) refused: no stream uses it yet (full selector census 11-19, m3-max-53207-53208, 53213, 53217-53221: 26 streams, no rasterization rate map call). The rt side of the suite answers `supports_rasterization_rate_map_layers` Unavailable: rt has no counterpart of the call, and no replay stream makes it.
@@ -7503,8 +7547,8 @@ xr-gradient-bgra10xr-srgb-unblended-x1 * refused case/target Err(Error::Unsuppor
xr-gradient-bgra10xr-srgb-unblended-x4 * refused case/target Err(Error::Unsupported("no texture of BGRA10XRSRGB is made on this device for the usage")) refused: no stream uses it yet (full selector census 11-19, m3-max-53207-53208, 53213, 53217-53221: 26 streams, no texture or view of MTLPixelFormatBGRA10_XR_sRGB). rt makes no texture of MTLPixelFormatBGRA10_XR_sRGB for the usage the case asks on any venue (Gap::TextureFormat, or the creator's NotMade).
xr-gradient-bgra10xr-unblended-x1 * refused case/target Err(Error::Unsupported("no texture of BGRA10XR is made on this device for the usage")) refused: no stream uses it yet (full selector census 11-19, m3-max-53207-53208, 53213, 53217-53221: 26 streams, no texture or view of MTLPixelFormatBGRA10_XR). rt makes no texture of MTLPixelFormatBGRA10_XR for the usage the case asks on any venue (Gap::TextureFormat, or the creator's NotMade).
xr-gradient-bgra10xr-unblended-x4 * refused case/target Err(Error::Unsupported("no texture of BGRA10XR is made on this device for the usage")) refused: no stream uses it yet (full selector census 11-19, m3-max-53207-53208, 53213, 53217-53221: 26 streams, no texture or view of MTLPixelFormatBGRA10_XR). rt makes no texture of MTLPixelFormatBGRA10_XR for the usage the case asks on any venue (Gap::TextureFormat, or the creator's NotMade).
xr-planes-bgr10xr-bgra10xr * refused case/texture/plane0 Err(Error::Unsupported("no texture of BGR10XR is made on this device for the usage")) refused: no stream uses it yet (full selector census 11-19, m3-max-53207-53208, 53213, 53217-53221: 26 streams, no texture or view of MTLPixelFormatBGR10_XR). rt makes no texture of MTLPixelFormatBGR10_XR for the usage the case asks on any venue (Gap::TextureFormat, or the creator's NotMade).
xr-planes-bgr10xr-bgra10xr-srgb * refused case/texture/plane0 Err(Error::Unsupported("no texture of BGR10XR is made on this device for the usage")) refused: no stream uses it yet (full selector census 11-19, m3-max-53207-53208, 53213, 53217-53221: 26 streams, no texture or view of MTLPixelFormatBGR10_XR). rt makes no texture of MTLPixelFormatBGR10_XR for the usage the case asks on any venue (Gap::TextureFormat, or the creator's NotMade).
xr-planes-bgr10xr-bgra10xr * refused case/join/dispatch Err(Error::Unsupported("texture slot 2, which a function writes or reads as storage, bound to a BGRA10XR texture with no storage element on this device, or one it cannot read without a format, is not built")) refused: no stream uses it yet (full selector census 11-19, m3-max-53207-53208, 53213, 53217-53221: 26 streams, no texture or view of MTLPixelFormatBGRA10_XR). rt holds a BGRA10_XR texture as the UNORM codes of its bits, read through the identity domains' arm; a kernel's write of one is not built (the storage choice refuses FormatEmulation::ExtendedRangeUnorm), so the joining kernel's dispatch is refused on every venue.
xr-planes-bgr10xr-bgra10xr-srgb * refused case/texture/joined-out Err(Error::Unsupported("no texture of BGRA10XRSRGB is made on this device for the usage")) refused: no stream uses it yet (full selector census 11-19, m3-max-53207-53208, 53213, 53217-53221: 26 streams, no texture or view of MTLPixelFormatBGRA10_XR_sRGB). rt makes no texture of MTLPixelFormatBGRA10_XR_sRGB for the usage the case asks on any venue (Gap::TextureFormat): the extended-range sRGB twins are held raw, which the identity domains do not convert.
xr-planes-bgr10xr-srgb-bgra10xr * refused case/texture/plane0 Err(Error::Unsupported("no texture of BGR10XRSRGB is made on this device for the usage")) refused: no stream uses it yet (full selector census 11-19, m3-max-53207-53208, 53213, 53217-53221: 26 streams, no texture or view of MTLPixelFormatBGR10_XR_sRGB). rt makes no texture of MTLPixelFormatBGR10_XR_sRGB for the usage the case asks on any venue (Gap::TextureFormat, or the creator's NotMade).
xr-planes-bgr10xr-srgb-bgra10xr-srgb * refused case/texture/plane0 Err(Error::Unsupported("no texture of BGR10XRSRGB is made on this device for the usage")) refused: no stream uses it yet (full selector census 11-19, m3-max-53207-53208, 53213, 53217-53221: 26 streams, no texture or view of MTLPixelFormatBGR10_XR_sRGB). rt makes no texture of MTLPixelFormatBGR10_XR_sRGB for the usage the case asks on any venue (Gap::TextureFormat, or the creator's NotMade).
xr-two-plane-samples-p2-lc-f * refused case/texture Err(Error::Unsupported("no texture of RGB10A82PXR10 is made on this device for the usage")) refused: no stream uses it yet (full selector census 11-19, m3-max-53207-53208, 53213, 53217-53221: 26 streams, no texture or view of MTLPixelFormatRGB10A8_2P_XR10). rt makes no texture of MTLPixelFormatRGB10A8_2P_XR10 for the usage the case asks on any venue (Gap::TextureFormat, or the creator's NotMade).
Can't render this file because it is too large.
+20 -3
View File
@@ -1926,9 +1926,17 @@ made, with no lock, and never rewritten for layouts.
- A format is made where the translator's format table maps it for the usage on the device
(`vk_format`) to the format itself or to one whose view gives Metal's values (a swizzled or
rotated view, alpha held in red, an RGBX format, a depth or stencil aspect of a combined
format), and the device's image format query takes the image. Elsewhere it is
`Gap::TextureFormat`: the shaders of the identity domains read a texture through its view alone,
so a format whose texels the shader converts (extended range, bfloat, YCbCr, decoded,
format), and the device's image format query takes the image. `BGR10_XR` and `BGRA10_XR` are
made in the UNORM format of their bits (`A2R10G10B10_UNORM_PACK32`, `R16G16B16A16_UNORM`) for
shader reads, whose codes every identity function's `float` sample, gather and read maps to
Metal's values where the texture's word names them (docs/API.md). Their render targets are not
built yet: a texture of either with `RenderTarget` usage, or on a device whose format query
lacks that format for the usage, is `Gap::TextureFormat` (a render pipeline with an attachment
of either is made, writing their raw texels, so no draw reaches it), and one made for shader
writes has no storage element (below). Elsewhere it is `Gap::TextureFormat`: the shaders of the
identity domains read a texture through its view alone, so another format whose texels the
shader converts (the
extended-range `_sRGB` and two-plane formats, the padded 10-bit ones, bfloat, YCbCr, decoded,
copies-only, 24-bit depth held as 32-bit float) is not made. Past the query's extent, layers or
sample counts it is `Limit::TextureSize` or `Limit::TextureSamples`.
- Refused as Metal refuses each descriptor (`Refusal::TextureZeroExtent`,
@@ -2362,6 +2370,15 @@ made, with no lock, and never rewritten for layouts.
### Known gaps of textures
- Every `float` or `half` sample, gather and read of a sampled colour image tests its texture's
word for `BGR10_XR` and `BGRA10_XR` and maps their codes in a branch (docs/API.md): on a texture
of any other format the read pays the word's test and the branch.
- A sample of a `BGR10_XR` or `BGRA10_XR` texture past its edge through a sampler's
`ClampToBorderColor` or `ClampToZero` reads the device's border colour as a code (opaque white
as `1.2529`, `BGRA10_XR`'s `1.2549`; black as `-0.7529`) where Metal reads 0 or 1, and a linear
sample across the edge blends toward it. A sample of a `BGRA10_XR` texel whose fields'
low 6 bits, which Metal neither reads nor writes, hold ones (bytes a CPU copy or a blit wrote)
filters them in, within `63/64` of a code step (`1 / 510`) of Metal's.
- A texture buffer with a swizzle other than each channel's own is `Gap::TextureBufferSwizzle`:
Metal applies it to the reads, and neither a buffer view nor a `gpuResourceID` carries one.
- A view of a texture buffer (`newTextureViewWithPixelFormat:` and its kin) is `Gap::TextureView`
@@ -4,9 +4,12 @@
//! swizzle:
//!
//! - the texture is made, and its bytes come back from `getBytes` as `replaceRegion` wrote them;
//! - a read of each texel, and a nearest sample at its centre, answer Metal's value of each code,
//! `(c - 384) / 510` correctly rounded, alpha's clamped to `[0, 1]` and `BGR10_XR`'s alpha 1,
//! whatever bits Metal does not read hold (`BGR10_XR`'s top two, a `BGRA10_XR` field's low six);
//! - a read of each texel answers Metal's value of each code, `(c - 384) / 510` correctly rounded,
//! alpha's clamped to `[0, 1]` and `BGR10_XR`'s alpha 1, whatever bits Metal does not read hold
//! (`BGR10_XR`'s top two, a `BGRA10_XR` field's low six); a nearest sample at its centre answers
//! it too, on lavapipe the map of lavapipe's own conversion of the field ([`lavapipe_sample`]),
//! and a sample of a `BGRA10_XR` texel whose low bits hold ones within `63/64` of a code step
//! (the runtime's known gaps);
//! - a gather of each component answers its four texels' values, and through the swizzled view
//! the component the swizzle names, a `Zero` or `One` lane its constant;
//! - a linear sample between four texels answers the value of their codes' mean, within the
@@ -42,6 +45,38 @@ mod on_device {
[900, 901, 902, 500],
];
/// The most a `BGRA10_XR` sample reads past Metal's value where its fields' low 6 bits hold
/// ones: `63/64` of a code step, and an `f32` step.
const LOW_BITS: f32 = 63.0 / 64.0 / 510.0 + 1e-6;
/// Lavapipe's nearest sample of a texel of `codes` (red first): lavapipe converts a field to
/// its fraction by the reciprocal, `c · fl(1 / (2^b - 1))`, as
/// `PrecisionNote::DeviceTexelConversion` records, one `f32` step low at some codes, which the
/// arm (`lower::texture::extended_unorm`) maps as it maps any device's fraction: `BGRA10_XR`'s
/// code 602 four steps of its value from Metal's. That is lavapipe's answer, not the arm's: on
/// the RX 7900 XTX every nearest sample of both formats is Metal's value exactly
/// (m3-max-85664), which the test holds on every real card.
fn lavapipe_sample(format: PixelFormat, codes: [u32; 4]) -> [f32; 4] {
let (shift, max, m) = match format {
PixelFormat::BGRA10XR => (6, 65535.0f32, 65535.0f32 / 64.0),
_ => (0, 1023.0, 1023.0),
};
// The arm's split of `1 / 510`.
let (kh, kl) = (f32::from_bits(0x3b00_8000), f32::from_bits(0x3300_8081));
std::array::from_fn(|j| {
if j == 3 && format == PixelFormat::BGR10XR {
return 1.0;
}
let u = (codes[j] << shift) as f32 * (1.0 / max);
let w = match j {
3 => (u * m).clamp(384.0, 894.0),
_ => u * m,
};
let d = w - 384.0;
d * kh + d * kl
})
}
/// Metal's value of code `c`, `(c - 384) / 510` correctly rounded: the `f64` quotient of two
/// small integers is within half an `f64` step of it and never an `f32` tie.
fn value(c: u32) -> f32 {
@@ -203,6 +238,8 @@ mod on_device {
(device.new_sampler_state(&d, 2)).unwrap_or_else(|error| panic!("{name}: {error}"));
let read = state(&device, &library, "fpv_swz_read");
let sample = state(&device, &library, "fpv_swz_sample");
// Lavapipe's conversion of a field (`lavapipe_sample`), the copy_cause tests' cfg.
let lavapipe = cfg!(m2v_cpu_icd);
let gathers = ["x", "y", "z", "w"]
.map(|c| state(&device, &library, &format!("fpv_swz_gather_{c}")));
use TextureSwizzle::{Alpha, Blue, Red, Zero};
@@ -249,7 +286,21 @@ mod on_device {
for (i, w) in want.iter().enumerate() {
assert_eq!(bits(got[i]), bits(*w), "{name}: {format:?}: read {i}");
let n = got_nearest[i];
assert_eq!(bits(n), bits(*w), "{name}: {format:?}: sample {i}");
// A `BGRA10_XR` texel whose fields' low 6 bits hold ones samples them in,
// within `63/64` of a code step (the runtime's known gaps).
match format == PixelFormat::BGRA10XR && i % 2 == 1 {
false => {
let w = match lavapipe {
true => lavapipe_sample(format, CODES[i]),
false => *w,
};
assert_eq!(bits(n), bits(w), "{name}: {format:?}: sample {i}");
}
true => assert!(
(0..4).all(|j| (n[j] - w[j]).abs() <= LOW_BITS),
"{name}: {format:?}: sample {i}: {n:?} for {w:?}"
),
}
}
// Between texels (1, 0), (2, 0), (1, 1) and (2, 1): a gather's texels in Metal's
@@ -272,8 +323,9 @@ mod on_device {
/ 4.0;
let w = (mean - 384.0) / 510.0;
let diff = (f64::from(got[c]) - w).abs();
// The device's filter, and the low bits of two `BGRA10_XR` texels.
assert!(
diff < 1e-3,
diff < 1e-3 + f64::from(LOW_BITS) / 2.0,
"{name}: {format:?}: linear {c}: {got:?} for {w}"
);
}
+4 -1
View File
@@ -3417,12 +3417,15 @@ fn planned(
}
/// Whether a format held so gives Metal's values through its view, with no conversion in the
/// shader.
/// shader but the one every identity function makes where a texture's word names it: an
/// extended-range format held as the UNORM codes of its bits (`ExtendedRangeUnorm`), whose
/// `float` sample, gather and read map the codes to Metal's values.
fn viewed(emulation: FormatEmulation) -> bool {
matches!(
emulation,
FormatEmulation::Direct
| FormatEmulation::SwizzledView
| FormatEmulation::ExtendedRangeUnorm
| FormatEmulation::AlphaInRed
| FormatEmulation::RotatedView
| FormatEmulation::XChannel
@@ -1 +1 @@
dfe0edba01ac382597f8b3b77f0c4ce960400597e5746cc52176f2a534850dbc
600429185080d6865900ba91d186f4da95335d02dc6170a9ad4821f2bf1da35e
+2 -2
View File
@@ -60,7 +60,7 @@ mod tests;
/// unchanged version, and its bless records the version. Independent of the crate's version and of
/// [`ARTIFACT_FORMAT_VERSION`]. The commit that bumps it says what changed; this comment keeps no
/// history.
pub const SEMANTICS_VERSION: u32 = 2372;
pub const SEMANTICS_VERSION: u32 = 2373;
/// The byte-layout version of encoded artifacts (`CompiledFunction::to_bytes` and the
/// [`PipelineArtifact`] encodings). Every encoded artifact carries it, and a decode under another
@@ -93,7 +93,7 @@ pub const ARTIFACT_FORMAT_VERSION: u32 = 609;
/// changes no behaviour, and then updates that hash alone with the commit saying why, or changes
/// behaviour and also bumps this version. The commit that bumps it says what changed; this comment
/// keeps no history.
pub const RUNTIME_VERSION: u32 = 2571;
pub const RUNTIME_VERSION: u32 = 2572;
/// Writes a digest as lowercase hex.
pub(crate) fn write_hex(f: &mut fmt::Formatter<'_>, name: &str, hash: &Hash256) -> fmt::Result {
+29 -5
View File
@@ -1233,7 +1233,10 @@ pub fn emit(
/// (`TextureWord::OUT_OF_BOUNDS_ALPHA_ONE`) moved to `HANDLE_ALPHA_ONE` where the function's
/// handles carry it (`memory::handles::Lookup::Flagged`'s `alpha`), and the word's low bits
/// above the index where the function reads an argument buffer's texture through a sampler, whose
/// border texels they hold (`AccessPlan::heap_border`), or reaches an argument buffer's texture
/// border texels they hold (`AccessPlan::heap_border`), or samples, gathers or reads an argument
/// buffer's texture as a `float` sampled image, with `lower::texture::extended_unorm`'s
/// `HANDLE_EXTENDED` where the word names a format held as UNORM codes
/// (`AccessPlan::heap_extended`), or reaches an argument buffer's texture
/// buffer held as words and its stage's `SpecKey::TexelBufferWords` holds
/// (`lower::texture::HANDLE_WORD`). The program writes the ID, so
/// the mask keeps any value it holds inside the arrays: a bad ID reads the element at its masked
@@ -1264,10 +1267,11 @@ fn emit_identity_handle(
return Err(cx.fail(format!("an identity handle of the {other:?} form")));
}
};
// Where the function reads an argument buffer's texture through a sampler, or reaches an
// argument buffer's texture buffer held as words, the word's low bits, which the heap accesses
// mask off.
let border = cx.plan.families.access.heap_border;
// Where the function reads an argument buffer's texture through a sampler, samples, gathers or
// reads one as a `float` sampled image, or reaches an argument buffer's texture buffer held as
// words, the word's low bits, which the heap accesses mask off.
let extended = cx.plan.families.access.heap_extended;
let border = cx.plan.families.access.heap_border || extended;
let h = match border || cx.plan.families.texture.words.heap {
true => {
use crate::lower::texture::{HANDLE_WORD, HANDLE_WORD_SHIFT};
@@ -1289,6 +1293,26 @@ fn emit_identity_handle(
}
false => h,
};
// Where the function maps an argument buffer's extended-range texture's codes, whether the
// word names such a format (`lower::texture::extended_unorm`).
let h = match extended {
true => {
use crate::lower::texture::extended_unorm::{FIRST, HANDLE_EXTENDED, SPAN};
use crate::metal::resource_word::TextureWord;
let word = fb.composite_extract(id, &[1])?;
let shift = k32(fb, TextureWord::PIXEL_FORMAT_SHIFT)?;
let format = fb.binary(BinOp::ShiftRightLogical, word, shift)?;
let first = k32(fb, FIRST)?;
let past = fb.binary(BinOp::ISub, format, first)?;
let span = k32(fb, SPAN)?;
let named = fb.binary(BinOp::ULessThanEqual, past, span)?;
let bit = k32(fb, HANDLE_EXTENDED)?;
let none = k32(fb, 0)?;
let bit = fb.select(named, bit, none)?;
fb.binary(BinOp::BitwiseOr, h, bit)?
}
false => h,
};
cx.define(vid, h);
Ok(())
}
@@ -837,6 +837,12 @@ pub struct AccessPlan {
/// (`docs/RESOURCE-ID.md`), as they do a slot's: each heap handle carries its word's low bits
/// (`lower::texture::HANDLE_WORD`), which the read takes them from.
pub heap_border: bool,
/// A heap texture's `float` sample, gather or read of a sampled image maps an extended-range
/// texture's UNORM codes to Metal's values (`lower::texture::extended_unorm`), which the
/// texture's word decides: each heap handle carries its word's low bits
/// (`lower::texture::HANDLE_WORD`) and, where the word names such a format,
/// `extended_unorm::HANDLE_EXTENDED`.
pub heap_extended: bool,
/// The relaxed atomic loads an exit of a loop holding them depends on ([`atomic::spin`]): each
/// acquires its memory. Planned before any instruction is selected.
pub spins: BTreeSet<InstId>,
@@ -1922,9 +1922,46 @@ pub(super) fn held_value(
let Some(form) = s.texel else {
return Err(cx.fail("a sample without a texel form"));
};
let texel = extended_value(cx, fb, s, image, texel)?;
held_texel(fb, image.texel, form, texel)
}
/// The device's value `texel` of sampling `s` of a `float` colour texture, as Metal reads it where
/// the texture's word names an extended-range format held as UNORM codes
/// (`lower::texture::extended_unorm`): a sample's filter, and a fetch's texel and a gather's
/// texels by their codes. A depth texture's, a comparison's and another class's are `texel`.
fn extended_value(
cx: &mut EmitCx<'_>,
fb: &mut FunctionBuilder<'_>,
s: &Sampling,
image: super::CombinedImage,
texel: SValue,
) -> BResult<SValue> {
use crate::lower::texture::extended_unorm::{self as xr, Lanes, Word};
if image.texel != TexelClass::Float || s.depth {
return Ok(texel);
}
let (lanes, source) = match &s.op {
SampleOp::Sample { dref: None, .. } => (Lanes::Texel, xr::Source::Filtered),
SampleOp::PixelFetch { .. } => (Lanes::Texel, xr::Source::Texel),
SampleOp::Gather {
component,
dref: None,
..
} => (Lanes::Gather(*component), xr::Source::Texel),
_ => return Ok(texel),
};
let word = match s.source {
Source::Combined(key) => {
Word::Slot(crate::lower::texture::identity_id(cx, fb, key.texture)?.1)
}
Source::Heap { handle, .. }
| Source::HeapSampler { handle, .. }
| Source::HeapArray { handle, .. } => Word::Heap(cx.operand(fb, handle)?),
};
xr::decoded(cx, fb, word, texel, (lanes, source), None)
}
#[cfg(test)]
mod axis_tests;
+17 -1
View File
@@ -153,7 +153,7 @@ use crate::error::{
use crate::lower::emit::EmitCx;
use crate::lower::select::{FamilyPlans, Plan, SelectCx};
use crate::lower::strategy::FamilyStrategy;
use crate::lower::texture::{ImageDecl, TexelClass, TexelForm};
use crate::lower::texture::{ImageDecl, TexelClass, TexelConv, TexelForm};
use crate::memory::handles::ENTRY_FIELD_WORDS;
use crate::metal::sampler::SamplerUse;
use crate::pipeline::interface::SamplerSlot;
@@ -894,6 +894,21 @@ impl Sampling {
}
_ => 0,
};
// A `float` colour texture's arm for an extended-range texture's codes.
let float = matches!(
self.texel.map(|f| f.conv),
Some(TexelConv::F16 | TexelConv::F32)
);
let coded = match &self.op {
SampleOp::Sample { dref: None, .. }
| SampleOp::PixelFetch { .. }
| SampleOp::Gather { dref: None, .. }
if float && !self.depth =>
{
crate::lower::texture::extended_unorm::ARM_WORDS
}
_ => 0,
};
// The slot's parent tests in Metal's offset rule, on each plane axis of the bicubic
// footprint that places the offset.
let parent = match self.offset_base {
@@ -902,6 +917,7 @@ impl Sampling {
};
base + wrap
+ heap
+ coded
+ half
+ centre
+ word
@@ -1388,6 +1388,14 @@ fn select_extended(
/// decoded as `t`. `arm` is set for an arm of a switch-at-use: with `Some(true)`, a fragment
/// implicit-LOD sample reads the gradients its switch hoisted, so that the arms share one emulation
/// (SEMANTICS 1012, `Sampling::shared_shape`).
/// A heap element's `float` sample or gather of a colour texture without a comparison maps an
/// extended-range texture's codes where its word names one (`AccessPlan::heap_extended`).
fn heap_extended(cx: &mut SelectCx<'_>, integer: bool, compare: bool, depth: bool) {
if !integer && !compare && !depth {
cx.families.access.heap_extended = true;
}
}
fn select_one(
cx: &mut SelectCx<'_>,
call: Call<'_>,
@@ -1858,6 +1866,7 @@ fn select_one(
Source::Combined(key)
}
(ImageRef::Heap { group, handle }, SamplerArg::Static(sampler, _)) => {
heap_extended(cx, integer, compare, shape.depth);
let key = HeapKey {
group,
sampler,
@@ -1868,6 +1877,7 @@ fn select_one(
}
// An argument buffer's sampler is read from the sampler array of its use.
(ImageRef::Heap { group, handle }, SamplerArg::Heap(sampler)) => {
heap_extended(cx, integer, compare, shape.depth);
let key = HeapSamplerKey { group, compare };
cx.families.sampler.heap_samplers.insert(key);
Source::HeapSampler {
+85 -4
View File
@@ -545,8 +545,9 @@ pub(crate) struct HeapElement {
fn heap_element_index(cx: &EmitCx<'_>, fb: &mut FunctionBuilder<'_>, h: SValue) -> BResult<SValue> {
let access = &cx.plan.families.access;
// Every handle carries its word's low bits where the function reads a heap texture's border
// texels (`AccessPlan::heap_border`).
if access.heap_border {
// texels (`AccessPlan::heap_border`) or maps an extended-range texture's codes
// (`AccessPlan::heap_extended`, beside `extended_unorm::HANDLE_EXTENDED`).
if access.heap_border || access.heap_extended {
let element = u32s(fb, 1, crate::pipeline::link::IDENTITY_TEXTURES - 1)?;
return fb.binary(BinOp::BitwiseAnd, h, element);
}
@@ -1738,6 +1739,73 @@ fn cube_face_texel(
Ok((texel, inb))
}
/// The device's texel `texel` (a `vec4` of `f32`) of a `float` sampled colour image read at
/// `image`, as Metal reads it where the texture's word names an extended-range format held as
/// UNORM codes (`extended_unorm`): each channel by its code. A storage image's, a depth
/// texture's, a texture buffer's, another class's and a slot's held raw
/// (`ImageDecl::extended`) are `texel`.
fn extended_texel(
cx: &mut EmitCx<'_>,
fb: &mut FunctionBuilder<'_>,
(image, decl): (ImageRef, &ImageDecl),
texel: SValue,
in_range: Option<super::extended_unorm::InRange<'_>>,
) -> BResult<SValue> {
use super::extended_unorm::{self as xr, Lanes, Word};
let held = decl.usage == ImageUsage::Sampled
&& decl.texel == TexelClass::Float
&& !decl.depth
&& decl.dim != Dim::Buffer
&& decl.extended.is_none();
if !held {
return Ok(texel);
}
let word = match image {
ImageRef::Slot(index) => Word::Slot(identity_id(cx, fb, index)?.1),
ImageRef::Heap { handle, .. } => Word::Heap(cx.operand(fb, handle)?),
};
xr::decoded(
cx,
fb,
word,
texel,
(Lanes::Texel, xr::Source::Texel),
in_range,
)
}
/// Whether a sampled read the device's robustness bounds is inside image `img`: its level below
/// the level count (where it has one), its coordinate `coord` (`n` lanes) below the size at that
/// level, and its sample below the sample count.
fn unchecked_in_range(
fb: &mut FunctionBuilder<'_>,
img: SValue,
(coord, n): (SValue, u8),
level: Option<SValue>,
sample: Option<SValue>,
) -> BResult<SValue> {
let mut ok = None;
let size = match level {
Some(l) => {
let levels = fb.query(ImageQuery::Levels, img)?;
ok = Some(fb.binary(BinOp::ULessThan, l, levels)?);
// A size query's level must be the image's.
let clamped = clamp_below(fb, l, levels, 1)?;
fb.query(ImageQuery::SizeLod(clamped), img)?
}
None => fb.query(ImageQuery::Size, img)?,
};
let lt = fb.binary(BinOp::ULessThan, coord, size)?;
let inside = if n == 1 { lt } else { fb.unary(UnOp::All, lt)? };
let mut ok = and(fb, ok, inside)?;
if let Some(s) = sample {
let samples = fb.query(ImageQuery::Samples, img)?;
let within = fb.binary(BinOp::ULessThan, s, samples)?;
ok = fb.binary(BinOp::LogicalAnd, ok, within)?;
}
Ok(ok)
}
fn read_texel(cx: &mut EmitCx<'_>, fb: &mut FunctionBuilder<'_>, r: &Read) -> BResult<ReadTexel> {
// A two-plane 3D texture's read takes its first texel ([`planes_volume`]).
let volume = decl_of(cx, &r.image).is_some_and(|d| planes_volume(&d));
@@ -1770,6 +1838,7 @@ fn read_texel(cx: &mut EmitCx<'_>, fb: &mut FunctionBuilder<'_>, r: &Read) -> BR
return Err(cx.fail("a cube element's read of another form"));
}
let (texel, inb) = cube_face_texel(cx, fb, r, &decl, img)?;
let texel = extended_texel(cx, fb, (r.image, &decl), texel, None)?;
let oob = out_of_bounds_texel(cx, fb, &decl, &r.image, r.alpha, flagged)?;
let texel = fb.select(inb, texel, oob)?;
let texel = from_image(fb, &decl, r.texel, texel)?;
@@ -1869,8 +1938,20 @@ fn read_texel(cx: &mut EmitCx<'_>, fb: &mut FunctionBuilder<'_>, r: &Read) -> BR
true => fb.fetch(img, coord, &ops)?,
false => fb.read(img, coord, &ops, mem)?,
};
// An extended-range texel's value, decoded from its raw code before Metal's out-of-bounds
// texel is selected.
// An extended-range texel's value: a texture held as UNORM codes mapped where its word names
// one, a slot's raw code decoded, before Metal's out-of-bounds texel is selected. A read the
// device's robustness bounds tests its operands in the arm, whose zero texel is not Metal's.
let bounds: Option<super::extended_unorm::InRange<'_>> =
match (r.checked(), &through, sampled, volume) {
(false, None, true, false) => {
let n = coord_len(&decl);
Some(Box::new(move |fb: &mut FunctionBuilder<'_>| {
unchecked_in_range(fb, img, (coord, n), level, sample)
}))
}
_ => None,
};
let texel = extended_texel(cx, fb, (r.image, &decl), texel, bounds)?;
let texel = match r.extended {
Some(form) => {
let half = r.texel.conv == TexelConv::F16;
@@ -0,0 +1,471 @@
//! Metal's values of an extended-range texture held as the UNORM codes of its bits
//! (`metal::format::FormatEmulation::ExtendedRangeUnorm`): `BGR10_XR` in
//! `A2R10G10B10_UNORM_PACK32` and `BGRA10_XR` in `R16G16B16A16_UNORM`, each channel's field read
//! by the device as its normalized value `u`, the field over its maximum.
//!
//! Under the identity domains a function learns its texture's format only at run time, from the
//! texture's word (`TextureWord`): a slot's from its resource ID, a heap element's from the bits
//! its handle carries ([`HANDLE_EXTENDED`] and `HANDLE_WORD`). So each `float` or `half` sample,
//! gather and read of a sampled image keeps the device's value, then tests the word, and where
//! it names one of these formats maps each lane that holds a channel's code to Metal's value
//! (the arm, [`decoded`]):
//!
//! - **The code space.** `w = u · m`, where `m` is the field's maximum over the code's step:
//! `1023` for `BGR10_XR`'s 10-bit field, `65535 / 64` for `BGRA10_XR`'s 16-bit field, whose
//! code is its top 10 bits. At a texel's own value `w` is the code exactly (every code, both
//! formats, with the device's conversion `c / (2^b - 1)` correctly rounded); a filter's value is
//! the same weighted sum of codes, the map being affine.
//! - **One texel's code.** A read and a gather, which hand back texels unfiltered, take the code
//! whole: a `BGRA10_XR` field's as `floor(w + 1/128)`, whatever its low 6 bits hold (Metal does
//! not read them), and a `BGR10_XR` field's as the nearest code, `floor(w + 1/2)`, which a device
//! that widens a 10-bit code by replicating its bits to 16, `(c << 6 | c >> 4) / 65535` (NVIDIA's
//! gather on the RTX 3090), leaves up to 0.015 of a code low.
//! - **Alpha.** `BGRA10_XR`'s alpha code is clamped to `[384, 894]`, values `[0, 1]`, as Metal
//! reads it.
//! - **The value.** `(w - 384) / 510` as `n · kh + n · kl` for `n = w - 384`, where `kh` is the
//! `f32` nearest `1 / 510` cut to its top 12 significant bits and `kl` the `f32` nearest the
//! rest: `n · kh` is exact for every code, so the sum rounds once, and it is Metal's correctly
//! rounded quotient for each of the 1024 codes, fused or not (`decode_is_metals_quotient`). The
//! difference, both products and the sum are decorated `NoContraction`: a device free to
//! rewrite them would take `n · (kh + kl)`, the product with the `f32` nearest `1 / 510`, which
//! misrounds 572 of the codes (lavapipe did, one `f32` step from Metal's).
//!
//! The lanes the arm maps are the word's own: its border texels (`TextureWord::BORDER_TEXELS`)
//! state, for each lane after the texture's swizzle, whether it reads 0 under transparent black
//! and 1 under opaque white (a channel the format has), and 1 under opaque black (its alpha); a
//! lane the swizzle makes 0 or 1, and `BGR10_XR`'s alpha, which the view reads as 1, are neither
//! and stay. A gather maps its four texels by the gathered component's lane.
use crate::lower::emit::EmitCx;
use crate::spirv::builder::constructs::{ArmEnd, ArmFn, Merged};
use crate::spirv::builder::FunctionBuilder;
use crate::spirv::error::BResult;
use crate::spirv::ids::{TypeId, Value as SValue};
use crate::spirv::ir::{BinOp, ConstBits, Constant, GlslOp, Type as SType, UnOp};
use crate::metal::resource_word::TextureWord;
/// The bit of an identity heap handle set where its texture's word names a format of this
/// module's: above the word's low bits (`HANDLE_WORD` from `HANDLE_WORD_SHIFT`) and below
/// `memory::handles::HANDLE_ALPHA_ONE`; every heap access masks its handle to the element.
pub(crate) const HANDLE_EXTENDED: u32 = 1 << 30;
const _: () = assert!(
HANDLE_EXTENDED & (super::HANDLE_WORD << super::HANDLE_WORD_SHIFT) == 0
&& HANDLE_EXTENDED & crate::memory::handles::HANDLE_ALPHA_ONE == 0
&& HANDLE_EXTENDED & (crate::pipeline::link::IDENTITY_TEXTURES - 1) == 0
);
/// `MTLPixelFormatBGRA10_XR`, the lowest raw value of the formats held so; `BGR10_XR` is 554.
/// The value between, `BGRA10_XR_sRGB` (553), is never held so: the runtime makes no texture of
/// it, so no word names it.
pub(crate) const FIRST: u32 = 552;
/// The raw values from [`FIRST`] a word's format may be past it and be held so.
pub(crate) const SPAN: u32 = 2;
/// The estimated words the arm adds at a site: the word's test and branch, the scale's choice,
/// the lanes' flags, the code space, a texel's nudge's choice and floor, alpha's clamp, the
/// value's two products and sum, the lanes' selection, and the merge.
pub(crate) const ARM_WORDS: u32 = 240;
/// The `f32` nearest `1 / 510` with its 12 low mantissa bits cleared (module docs).
const KH: u32 = 0x3b00_8000;
/// The `f32` nearest `1 / 510 - KH` (module docs).
const KL: u32 = 0x3300_8081;
/// What a texel's code space `w` gains before its floor, so the floor is the texel's code
/// (module docs): a 10-bit field's (`ten`) half a code, its nearest; a 16-bit field's `1/128`,
/// its top 10 bits whatever its low 6 hold.
const fn texel_nudge(ten: bool) -> f32 {
match ten {
true => 0.5,
false => 1.0 / 128.0,
}
}
/// The lanes a site's value holds.
#[derive(Clone, Copy, Debug)]
pub(crate) enum Lanes {
/// A texel's lanes, lane `c` channel `c` after the swizzle.
Texel,
/// A gather's four texels of component `c` after the swizzle.
Gather(u32),
}
/// Whether the value is one texel's (a read or a gather), whose code the arm takes, or a filter's
/// (a sample).
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub(crate) enum Source {
Texel,
Filtered,
}
/// Whether a read's operands are inside its image, computed in the arm alone: a read the device's
/// robustness answers out of bounds hands back its zero texel, whose code lanes Metal reads as 0
/// rather than as code 0's value.
pub(crate) type InRange<'a> = Box<dyn FnOnce(&mut FunctionBuilder<'_>) -> BResult<SValue> + 'a>;
/// What a site knows of its texture's word.
#[derive(Clone, Copy, Debug)]
pub(crate) enum Word {
/// A slot's: its resource ID's word.
Slot(SValue),
/// A heap element's handle, which carries [`HANDLE_EXTENDED`] and the word's low bits.
Heap(SValue),
}
fn u32_ty(fb: &mut FunctionBuilder<'_>) -> BResult<TypeId> {
fb.module().ty(SType::Int {
width: 32,
signed: false,
})
}
fn f32_ty(fb: &mut FunctionBuilder<'_>) -> BResult<TypeId> {
fb.module().ty(SType::Float { width: 32 })
}
fn vec(fb: &mut FunctionBuilder<'_>, elem: TypeId, n: u8) -> BResult<TypeId> {
match n {
1 => Ok(elem),
_ => fb.module().ty(SType::Vector { elem, len: n }),
}
}
/// The scalar constant `bits` of `elem`.
fn scalar(fb: &mut FunctionBuilder<'_>, elem: TypeId, bits: u64) -> BResult<SValue> {
let c = fb.module().constant(Constant::Scalar {
ty: elem,
bits: ConstBits(bits),
})?;
fb.module().const_value(c)
}
/// `lanes` scalar constants of `elem`, as a vector of `lanes.len()` (a scalar for one).
fn lanes_of(fb: &mut FunctionBuilder<'_>, elem: TypeId, lanes: &[u64]) -> BResult<SValue> {
let mut parts = Vec::with_capacity(lanes.len());
for &bits in lanes {
parts.push(fb.module().constant(Constant::Scalar {
ty: elem,
bits: ConstBits(bits),
})?);
}
let n = u8::try_from(lanes.len()).unwrap_or(4);
if let [only] = parts[..] {
return fb.module().const_value(only);
}
let ty = vec(fb, elem, n)?;
let c = fb.module().constant(Constant::Composite {
ty,
parts: parts.into(),
})?;
fb.module().const_value(c)
}
fn splat_u32(fb: &mut FunctionBuilder<'_>, n: u8, v: u32) -> BResult<SValue> {
let u = u32_ty(fb)?;
lanes_of(fb, u, &vec![u64::from(v); usize::from(n)])
}
fn splat_f32(fb: &mut FunctionBuilder<'_>, n: u8, v: f32) -> BResult<SValue> {
let f = f32_ty(fb)?;
lanes_of(fb, f, &vec![u64::from(v.to_bits()); usize::from(n)])
}
/// `x` (a `u32`) as `n` lanes.
fn spread(fb: &mut FunctionBuilder<'_>, x: SValue, n: u8) -> BResult<SValue> {
if n == 1 {
return Ok(x);
}
let u = u32_ty(fb)?;
let ty = vec(fb, u, n)?;
fb.composite_construct(ty, &vec![x; usize::from(n)])
}
/// `x` (an `f32`) as `n` lanes.
fn spread_f32(fb: &mut FunctionBuilder<'_>, x: SValue, n: u8) -> BResult<SValue> {
if n == 1 {
return Ok(x);
}
let f = f32_ty(fb)?;
let ty = vec(fb, f, n)?;
fb.composite_construct(ty, &vec![x; usize::from(n)])
}
/// The lane count of `x`, an `f32` scalar or vector.
fn width(fb: &mut FunctionBuilder<'_>, x: SValue) -> BResult<u8> {
let ty = fb.value_ty(x)?;
Ok(match fb.module().types().get(ty)? {
SType::Vector { len, .. } => *len,
_ => 1,
})
}
/// The test the arm takes and the word bits it reads (bits 0-12 of the word): a slot's word
/// names a format from [`FIRST`]; a heap handle carries [`HANDLE_EXTENDED`].
fn test(fb: &mut FunctionBuilder<'_>, word: Word) -> BResult<(SValue, SValue)> {
let u = u32_ty(fb)?;
match word {
Word::Slot(w) => {
let shift = scalar(fb, u, u64::from(TextureWord::PIXEL_FORMAT_SHIFT))?;
let format = fb.binary(BinOp::ShiftRightLogical, w, shift)?;
let first = scalar(fb, u, u64::from(FIRST))?;
let past = fb.binary(BinOp::ISub, format, first)?;
let span = scalar(fb, u, u64::from(SPAN))?;
Ok((fb.binary(BinOp::ULessThanEqual, past, span)?, w))
}
Word::Heap(h) => {
let bit = scalar(fb, u, u64::from(HANDLE_EXTENDED))?;
let set = fb.binary(BinOp::BitwiseAnd, h, bit)?;
let zero = scalar(fb, u, 0)?;
let test = fb.binary(BinOp::INotEqual, set, zero)?;
let shift = scalar(fb, u, u64::from(super::HANDLE_WORD_SHIFT))?;
Ok((test, fb.binary(BinOp::ShiftRightLogical, h, shift)?))
}
}
}
/// The value of `x`, the device's `f32` value (a scalar or vector) of a `float` sampled image's
/// texel or filter at a site whose texture's word is `word`: Metal's value where the word names
/// a format held as UNORM codes (module docs), else `x`. Where `in_range` is given (a read the
/// device's robustness bounds), each code lane is 0 where it says the read is outside, Metal's
/// out-of-bounds texel.
pub(crate) fn decoded(
cx: &mut EmitCx<'_>,
fb: &mut FunctionBuilder<'_>,
word: Word,
x: SValue,
(lanes, source): (Lanes, Source),
in_range: Option<InRange<'_>>,
) -> BResult<SValue> {
let (test, bits) = test(fb, word)?;
let mapped: ArmFn<'_, EmitCx<'_>> = Box::new(move |fb, _| {
let v = mapped(fb, bits, x, lanes, source)?;
let v = match in_range {
Some(f) => {
let ok = f(fb)?;
outside_zero(fb, bits, (x, v), lanes, ok)?
}
None => v,
};
Ok(ArmEnd::FallThrough(vec![v]))
});
let kept: ArmFn<'_, EmitCx<'_>> = Box::new(move |_, _| Ok(ArmEnd::FallThrough(vec![x])));
let Merged(merged) = fb.if_(cx, test, mapped, Some(kept))?;
match merged[..] {
[v] => Ok(v),
_ => Err(cx.fail("an extended-range arm without its merged value")),
}
}
/// Each lane of a code (word bits `bits`, [`flags`]) of `v`, the arm's value of `x`, as 0 where
/// `ok` (a `bool`) is false; the others as they are.
fn outside_zero(
fb: &mut FunctionBuilder<'_>,
bits: SValue,
(x, v): (SValue, SValue),
lanes: Lanes,
ok: SValue,
) -> BResult<SValue> {
let n = width(fb, x)?;
let (code, _) = flags(fb, bits, lanes, n)?;
let ok = match n {
1 => ok,
_ => {
let b = fb.module().ty(SType::Bool)?;
let ty = vec(fb, b, n)?;
fb.composite_construct(ty, &vec![ok; usize::from(n)])?
}
};
let out = fb.unary(UnOp::LogicalNot, ok)?;
let gone = fb.binary(BinOp::LogicalAnd, code, out)?;
let zero = splat_f32(fb, n, 0.0)?;
fb.select(gone, zero, v)
}
/// The lanes of `n` that hold a channel's code, and those that hold alpha's, by word bits `bits`
/// (module docs), as `bool`s of `n` lanes.
fn flags(
fb: &mut FunctionBuilder<'_>,
bits: SValue,
lanes: Lanes,
n: u8,
) -> BResult<(SValue, SValue)> {
let u = u32_ty(fb)?;
// Each lane's three border bits: transparent black, opaque black, opaque white.
let t = match lanes {
Lanes::Texel => {
let shifts: Vec<u64> = (0..u64::from(n)).map(|c| 3 * c).collect();
let shifts = lanes_of(fb, u, &shifts)?;
let spread = spread(fb, bits, n)?;
fb.binary(BinOp::ShiftRightLogical, spread, shifts)?
}
Lanes::Gather(c) => {
let shift = scalar(fb, u, u64::from(3 * c))?;
let t = fb.binary(BinOp::ShiftRightLogical, bits, shift)?;
spread(fb, t, n)?
}
};
// A channel's code: 0 under transparent black, 1 under opaque white; alpha's also 1 under
// opaque black.
let five = splat_u32(fb, n, 0b101)?;
let four = splat_u32(fb, n, 0b100)?;
let seven = splat_u32(fb, n, 0b111)?;
let six = splat_u32(fb, n, 0b110)?;
let low = fb.binary(BinOp::BitwiseAnd, t, five)?;
let code = fb.binary(BinOp::IEqual, low, four)?;
let all = fb.binary(BinOp::BitwiseAnd, t, seven)?;
let alpha = fb.binary(BinOp::IEqual, all, six)?;
Ok((code, alpha))
}
/// The arm's value of `x` (module docs) for word bits `bits` (bits 0-12 of the word valid).
fn mapped(
fb: &mut FunctionBuilder<'_>,
bits: SValue,
x: SValue,
lanes: Lanes,
source: Source,
) -> BResult<SValue> {
let n = width(fb, x)?;
let u = u32_ty(fb)?;
let f = f32_ty(fb)?;
// The field's maximum over the code's step: `BGR10_XR` has no alpha.
let alpha_one = scalar(fb, u, u64::from(TextureWord::OUT_OF_BOUNDS_ALPHA_ONE))?;
let alpha_one = fb.binary(BinOp::BitwiseAnd, bits, alpha_one)?;
let zero = scalar(fb, u, 0)?;
let ten = fb.binary(BinOp::INotEqual, alpha_one, zero)?;
let m10 = scalar(fb, f, u64::from(1023.0f32.to_bits()))?;
let m16 = scalar(fb, f, u64::from((65535.0f32 / 64.0).to_bits()))?;
let m = fb.select(ten, m10, m16)?;
let m = spread_f32(fb, m, n)?;
let (code, alpha) = flags(fb, bits, lanes, n)?;
let w = fb.binary(BinOp::FMul, x, m)?;
let w = match source {
Source::Filtered => w,
Source::Texel => {
// The nearest code of a 10-bit field; a 16-bit field's top 10 bits.
let half = scalar(fb, f, u64::from(texel_nudge(true).to_bits()))?;
let past = scalar(fb, f, u64::from(texel_nudge(false).to_bits()))?;
let nudge = fb.select(ten, half, past)?;
let nudge = spread_f32(fb, nudge, n)?;
let w = fb.binary(BinOp::FAdd, w, nudge)?;
fb.glsl(GlslOp::Floor, &[w])?
}
};
let lo = splat_f32(fb, n, 384.0)?;
let hi = splat_f32(fb, n, 894.0)?;
let clamped = fb.glsl(GlslOp::FClamp, &[w, lo, hi])?;
let w = fb.select(alpha, clamped, w)?;
let centre = splat_f32(fb, n, 384.0)?;
// Rounded as written (module docs): no device factors `d` out of the sum.
let d = fb.binary_no_contraction(BinOp::FSub, w, centre)?;
let kh = splat_f32(fb, n, f32::from_bits(KH))?;
let kl = splat_f32(fb, n, f32::from_bits(KL))?;
let high = fb.binary_no_contraction(BinOp::FMul, d, kh)?;
let low = fb.binary_no_contraction(BinOp::FMul, d, kl)?;
let v = fb.binary_no_contraction(BinOp::FAdd, high, low)?;
fb.select(code, v, x)
}
#[cfg(test)]
mod tests {
use super::{texel_nudge, KH, KL};
/// `f32` rounding of an `f64` (round to nearest even, as the cast does).
fn f32_of(x: f64) -> f32 {
x as f32
}
/// Metal's value of code `c`: `(c - 384) / 510` correctly rounded to `f32`. The quotient of two
/// small integers is never a tie at `f32`'s precision, and its `f64` is within half an `f64`
/// step of it, far below half an `f32` step, so the `f64`'s rounding is the quotient's.
fn metal(c: u32) -> f32 {
f32_of((f64::from(c) - 384.0) / 510.0)
}
/// `KH` is `1 / 510` cut to its top 12 significant bits, `KL` the rest's nearest `f32`.
#[test]
fn the_constants_split_the_reciprocal() {
let k = 1.0f32 / 510.0;
assert_eq!(KH, k.to_bits() & !0xfff);
let rest = 1.0f64 / 510.0 - f64::from(f32::from_bits(KH));
assert_eq!(KL, f32_of(rest).to_bits());
}
/// For every code of both formats, the arm's code space from the device's normalized value is
/// the code (a filter's value and a texel's whole code alike: a 10-bit field's nearest, a
/// 16-bit field's floor past `1/128`), and its value is Metal's quotient, with the second
/// product rounded before the sum or fused into it.
#[test]
fn decode_is_metals_quotient() {
let (kh, kl) = (f32::from_bits(KH), f32::from_bits(KL));
for c in 0u32..1024 {
for (m, u, nudge) in [
(1023.0f32, f32_of(f64::from(c) / 1023.0), texel_nudge(true)),
(
65535.0 / 64.0,
f32_of(f64::from(c << 6) / 65535.0),
texel_nudge(false),
),
] {
let w = u * m;
assert_eq!(w, c as f32, "code {c}, scale {m}");
assert_eq!((w + nudge).floor(), c as f32, "code {c}, scale {m}");
let n = w - 384.0;
let unfused = n * kh + n * kl;
// `kh + kl` spans 40 bits and `n` 10, so the `f64` product is the exact sum of
// the two exact products, rounded once to `f32` as a fused multiply-add does.
let fused = f32_of(f64::from(n) * (f64::from(kh) + f64::from(kl)));
assert_eq!(unfused, metal(c), "code {c}");
assert_eq!(fused, metal(c), "code {c}");
}
}
}
/// The product a device would take were it free to factor the sum (`n · (kh + kl)`, the `f32`
/// sum rounded first) misrounds 572 of the 1024 codes, so the arm's arithmetic is
/// `NoContraction`.
#[test]
fn the_rounded_reciprocal_misrounds_codes() {
let k = f32::from_bits(KH) + f32::from_bits(KL);
assert_eq!(k, 1.0f32 / 510.0);
let misrounded = (0u32..1024)
.filter(|&c| (c as f32 - 384.0) * k != metal(c))
.count();
assert_eq!(misrounded, 572);
}
/// A `BGR10_XR` code a device widens by replicating its bits to 16 before converting,
/// `(c << 6 | c >> 4) / 65535` (NVIDIA's gather), is up to 0.015 of a code from `c`, and the
/// nearest code is `c` for every code.
#[test]
fn a_replicated_ten_bit_code_is_its_nearest() {
let mut worst = 0.0f32;
for c in 0u32..1024 {
let u = f32_of(f64::from(c << 6 | c >> 4) / 65535.0);
let w = u * 1023.0;
worst = worst.max((w - c as f32).abs());
assert_eq!((w + texel_nudge(true)).floor(), c as f32, "code {c}");
}
assert!(worst > 1.0 / 128.0 && worst < 0.016, "{worst}");
}
/// A `BGRA10_XR` field's low 6 bits, which Metal does not read, leave a texel's code as it is.
#[test]
fn a_fields_low_bits_leave_its_code() {
for c in 0u32..1024 {
for low in [1u32, 31, 63] {
let u = f32_of(f64::from(c << 6 | low) / 65535.0);
let w = u * (65535.0 / 64.0);
assert_eq!(
(w + texel_nudge(false)).floor(),
c as f32,
"code {c}, low {low}"
);
}
}
}
}
+14 -2
View File
@@ -165,6 +165,7 @@ mod alpha;
mod atomic;
mod cooperative;
mod emit;
pub(crate) mod extended_unorm;
mod slice;
mod slot;
mod status;
@@ -174,8 +175,8 @@ pub(crate) use absent::absent_arm;
pub use absent::ABSENT_ARM;
pub use atomic::TexAtomic;
pub(crate) use emit::{
dispatch, heap_element, live_or_zero, rgb9e5_word, slot_image, swizzled_float, swizzled_gather,
swizzled_held, with_word, NullLeaf, SRGB_DECODE_WORDS,
dispatch, heap_element, identity_id, live_or_zero, rgb9e5_word, slot_image, swizzled_float,
swizzled_gather, swizzled_held, with_word, NullLeaf, SRGB_DECODE_WORDS,
};
pub use emit::{emit, held_texel, to_image};
pub(crate) use slot::depth_comparison;
@@ -359,6 +360,11 @@ fn read_words(r: &Read) -> u32 {
Some(t) if r.image.heap() && t.sampler.bordered() => 32,
_ => 0,
}
+ match r.texel.conv {
// A `float` sampled image's arm for an extended-range texture's codes.
TexelConv::F16 | TexelConv::F32 => extended_unorm::ARM_WORDS,
_ => 0,
}
+ if r.srgb_codes {
SRGB_DECODE_WORDS
} else if r.extended.is_some() {
@@ -1990,6 +1996,12 @@ fn select_read(
if write_only {
return Err(refuse());
}
// A heap element's `float` read of a sampled colour image maps an extended-range texture's
// codes where its word names one (`AccessPlan::heap_extended`).
let float = matches!(texel.conv, TexelConv::F16 | TexelConv::F32);
if image.heap() && !storage && float && !shape.depth && shape.dim != ImageDim::Buffer {
cx.families.access.heap_extended = true;
}
let level = if shape.ms || shape.dim == ImageDim::Buffer {
level_zero(cx, ops)?;
None
+51 -8
View File
@@ -136,6 +136,17 @@ pub enum FormatEmulation {
/// (`LoweringInputs::extended_range_colors`); admitted for those usages only (no filter, blend,
/// or texel buffer).
ExtendedRange,
/// `BGR10_XR` or `BGRA10_XR` ([`ExtendedRange`]'s bytes), held in the UNORM format of the
/// same bits: `A2R10G10B10_UNORM_PACK32`, its alpha read as one (Metal reads `BGR10_XR`'s
/// alpha as 1), and `R16G16B16A16_UNORM`, viewed with red and blue exchanged (its fields are
/// blue, green, red and alpha from the lowest). The sampled view reads each channel's field
/// over its maximum; under the identity domains a function's `float` sample, gather and read
/// of a sampled image maps that to Metal's value where the texture's word names one of these
/// formats (`lower::texture::extended_unorm`): exact for a texel read and gathered, the
/// device's filter of the codes for a sample. Copies and blits move the bytes unchanged.
/// Admitted for sampling, whose filters and reductions the map keeps (it is increasing and
/// affine); a device whose format query lacks the usage is refused the texture.
ExtendedRangeUnorm,
/// Apple's two-plane YCbCr formats this crate holds ([`ycbcr`]), which Metal makes only over
/// an IOSurface's two planes and reads as RGB: held as texels of exactly Metal's values,
/// which the consumer computes from the planes' bytes (Metal's conversion,
@@ -255,6 +266,10 @@ impl FormatEmulation {
U::SampledImage | U::StorageImage | U::ColorAttachment
)
}
FormatEmulation::ExtendedRangeUnorm => matches!(
usage,
U::SampledImage | U::SampledImageFilterLinear | U::SampledImageFilterMinmax
),
FormatEmulation::YCbCr => {
matches!(usage, U::SampledImage | U::SampledImageFilterLinear)
}
@@ -1342,12 +1357,39 @@ fn make_repr(pf: PixelFormat) -> Repr {
red_blue_twin(F::A2B10G10R10_UNORM_PACK32),
]),
// Apple's extended-range formats: 10-bit codes `c` of the value `(c - 384) / 510`
// (sRGB-encoded in the `_sRGB` twins), which no Vulkan format has, held raw in the
// integer format of their bytes.
P::BGR10XR | P::BGR10XRSRGB => color(vec![combined(F::R32_UINT, E::ExtendedRange)]),
P::BGRA10XR | P::BGRA10XRSRGB => {
color(vec![combined(F::R16G16B16A16_UINT, E::ExtendedRange)])
}
// (sRGB-encoded in the `_sRGB` twins), which no Vulkan format has. The `_sRGB` twins are
// held raw in the integer format of their bytes.
// `BGR10_XR` and `BGRA10_XR` in the UNORM format of their bits, whose fields a function
// maps to Metal's values ([`FormatEmulation::ExtendedRangeUnorm`]); a color attachment of
// either in its bytes' integer format, raw, as before (their render targets are not built).
P::BGR10XR => color(vec![
Candidate {
format: F::A2R10G10B10_UNORM_PACK32,
components: vk::ComponentMapping {
r: S::IDENTITY,
g: S::IDENTITY,
b: S::IDENTITY,
a: S::ONE,
},
emulation: E::ExtendedRangeUnorm,
},
combined(F::R32_UINT, E::ExtendedRange),
]),
P::BGRA10XR => color(vec![
Candidate {
format: F::R16G16B16A16_UNORM,
components: vk::ComponentMapping {
r: S::B,
g: S::G,
b: S::R,
a: S::A,
},
emulation: E::ExtendedRangeUnorm,
},
combined(F::R16G16B16A16_UINT, E::ExtendedRange),
]),
P::BGR10XRSRGB => color(vec![combined(F::R32_UINT, E::ExtendedRange)]),
P::BGRA10XRSRGB => color(vec![combined(F::R16G16B16A16_UINT, E::ExtendedRange)]),
// Two planes, the extended-range color word and an alpha byte, held side by side in one
// image.
P::RGB10A82PXR10 | P::RGB10A82PXR10SRGB => {
@@ -2690,10 +2732,11 @@ fn held_storage_choice(
// into: Metal drops a write-only slot's writes to a 4:2:0 or 4:2:2 format
// ([`writes_dropped`]); the 4:4:4 formats' writes, which Metal stores into both planes, and a
// slot that reads and writes any of them, are not modelled.
// Nor does a function write a texture held for copies alone ([`copies_only`]).
// Nor does a function write a texture held for copies alone ([`copies_only`]), nor one held as
// the UNORM codes of an extended-range format's bits, whose writes are not built.
if matches!(
candidates[0].emulation,
FormatEmulation::YCbCr | FormatEmulation::CopiesOnly
FormatEmulation::YCbCr | FormatEmulation::CopiesOnly | FormatEmulation::ExtendedRangeUnorm
) {
return Err(Unsupported::not_implemented(Feature::Format).into());
}
@@ -145,6 +145,14 @@ fn direct_formats_round_trip() {
match candidates[0].emulation {
FormatEmulation::Direct => back.entry(candidates[0].format).or_default().push(pf),
FormatEmulation::ExtendedRange => {}
// `BGR10_XR`'s and `BGRA10_XR`'s bits in the UNORM format of the same bits, which
// `BGR10A2Unorm` and `RGBA16Unorm` hold directly.
FormatEmulation::ExtendedRangeUnorm => {
assert!(
matches!(pf, PixelFormat::BGR10XR | PixelFormat::BGRA10XR),
"{pf:?}"
)
}
FormatEmulation::RotatedView => assert_eq!(pf, PixelFormat::ARGB8Unorm),
FormatEmulation::YCbCr => assert!(ycbcr_format(pf).is_some(), "{pf:?}"),
// An RGBX format's bytes are its RGBA twin's, which converts in the shader.
@@ -395,8 +395,10 @@ fn hoisted_derivatives_take_the_whole_bias() {
s.reads_metals_bias(1, stem);
}
/// Outside a fragment function the bias is the explicit level unclamped: no `FClamp` at all in
/// Outside a fragment function the bias is the explicit level unclamped: no `FClamp` of a bias in
/// `sample_bias_kernel` (two biases and two minimum-LOD clamps, formerly two `FClamp(bias, ±max)`).
/// Its one `FClamp` a sample is the extended-range arm's clamp of an alpha code
/// (`lower::texture::extended_unorm`).
#[test]
fn a_base_level_takes_the_whole_bias() {
let Some(bc) = assemble_file("sampling_completion.ll") else {
@@ -405,7 +407,7 @@ fn a_base_level_takes_the_whole_bias() {
for stem in ["moltenvk-m3", "runtime-floor"] {
let a = ok(&bc, "sample_bias_kernel", &p(stem));
let s = shape(&a);
assert_eq!(s.glsl_count(GLSL_FCLAMP), 0, "{stem}");
assert_eq!(s.glsl_count(GLSL_FCLAMP), 3, "{stem}");
assert_eq!(s.count(OP_IMAGE_SAMPLE_EXPLICIT_LOD), 3, "{stem}");
}
}
@@ -282,8 +282,10 @@ fn bias_and_clamp_outside_a_fragment_are_explicit_levels() {
assert_eq!(uses(&a, "sampler.sample_base_level"), 3);
assert_eq!(count(&a, OP_IMAGE_SAMPLE_EXPLICIT_LOD), 3);
assert_eq!(count(&a, OP_IMAGE_SAMPLE_IMPLICIT_LOD), 0);
// Two biases (one dynamic, one constant), unclamped, and two minimum-LOD clamps.
assert_eq!(glsl(&a, GLSL_FCLAMP), 0);
// Two biases (one dynamic, one constant), unclamped, and two minimum-LOD clamps. Each of the
// three samples' one `FClamp` is the extended-range arm's clamp of an alpha code
// (`lower::texture::extended_unorm`).
assert_eq!(glsl(&a, GLSL_FCLAMP), 3);
assert_eq!(glsl(&a, GLSL_FMAX), 2);
let v = ok(&bc, "vertex_bias", &m3());
assert_eq!(uses(&v, "sampler.sample_base_level"), 1);
@@ -9888,6 +9888,7 @@ variant metal2vulkan::metal::format::FormatEmulation::DepthInCombined DepthInCom
variant metal2vulkan::metal::format::FormatEmulation::DepthWidened DepthWidened
variant metal2vulkan::metal::format::FormatEmulation::Direct Direct
variant metal2vulkan::metal::format::FormatEmulation::ExtendedRange ExtendedRange
variant metal2vulkan::metal::format::FormatEmulation::ExtendedRangeUnorm ExtendedRangeUnorm
variant metal2vulkan::metal::format::FormatEmulation::RotatedView RotatedView
variant metal2vulkan::metal::format::FormatEmulation::StencilInCombined StencilInCombined
variant metal2vulkan::metal::format::FormatEmulation::SwizzledView SwizzledView
Can't render this file because it is too large.
+18 -1
View File
@@ -205,7 +205,24 @@ the runtime's, the command line's, the compile worker's and every validation too
class index one array. No variant is chosen there: a
texture reads through the plain form whatever texture its ID names, its `float` or `half` reads
take the device's sRGB decode with `PrecisionNote::SrgbTexelDecode`, and no texture is sparse
(the runtime makes none). A texture slot sampled through a runtime sampler slot
(the runtime makes none). A `BGR10_XR` or `BGRA10_XR` texture is held in the
UNORM format of its bits (`FormatEmulation::ExtendedRangeUnorm`: `A2R10G10B10_UNORM_PACK32`,
alpha read as one, and `R16G16B16A16_UNORM` viewed with red and blue exchanged), so every
`float` or `half` sample, gather and read of a sampled colour image, at a slot or through an
argument buffer, keeps the device's value and tests the texture's word (a slot's pushed ID's; a
member's carried in its handle, bit 30 and the word's low bits): where it names one of those
formats, each lane that holds a channel's code (by the word's border texels) is mapped from the
field's normalized value `u` to Metal's value, `(u · m - 384) / 510` (`m` 1023, or `65535 / 64`
for a 16-bit field), a read's and a gather's code first taken whole, alpha's clamped to
`[384, 894]`, and the quotient formed as two products whose sum rounds once, each operation
decorated `NoContraction` so no device factors it into one product: Metal's correctly
rounded value at every code. A read the device's robustness bounds tests its operands in that
branch and reads a code lane outside as 0, Metal's out-of-bounds texel. A sample is the
device's filter of the codes, which the map keeps. Not built yet: a sample past the edge
through a border address mode reads the device's border in code space (opaque white `1.2529`,
`BGRA10_XR`'s `1.2549`; black `-0.7529`) where Metal's is 0 or 1, and a sample of a `BGRA10_XR`
texel whose fields' low 6 bits are not zero filters them in (within `63/64` of a code step);
both are the runtime's known gaps. A texture slot sampled through a runtime sampler slot
samples set 1's element of the sampler arrays at the index of the sampler's pushed
`gpuResourceID`, joined to the texture's element by `OpSampledImage`, and reads the sampler's
word from that ID. One sampled through a constexpr sampler samples the element at the index the
+47 -3
View File
@@ -43,7 +43,7 @@ Its limits, measured rather than asserted:
| committed recordings | 1356 |
| distinct SDK items the Metal leg reaches, of any status | 812 |
| of those, reached only where this cannot name the family | 5 |
| ledger rows (a case whose gap is recorded) | 8276 |
| ledger rows (a case whose gap is recorded) | 8320 |
| declared crossings of the option space (pairs put to Metal at once) | 26 |
| declared crossings that are no pair of it (a boolean or numeric field, or one type in two slots) | 30 |
@@ -2601,6 +2601,50 @@ A case whose difference from Metal is recorded rather than compared away. The le
| `extended-swizzles-b5g6r5unorm` | The device's own answer (rule 1): a linear sample of a packed 16-bit unorm texture through a swizzled view: the device filters its own decode of the codes (a 5-… |
| `extended-swizzles-b5g6r5unorm` | The device's own answer (rule 1): a read, nearest sample or gather of a packed 16-bit unorm texel through a swizzled view: the device widens a 5- or 6-bit code … |
| `extended-swizzles-b5g6r5unorm` | The device's own answer (rule 1): a read, nearest sample or gather of a packed 16-bit unorm texel through a swizzled view: the device widens a 5- or 6-bit code … |
| `extended-swizzles-bgr10xr` | A known gap of the runtime (its README, Known gaps of textures): the texture is held as the UNORM codes of its bits, and a nearest or linear sample or a gather … |
| `extended-swizzles-bgr10xr` | A known gap of the runtime (its README, Known gaps of textures): the texture is held as the UNORM codes of its bits, and a nearest or linear sample or a gather … |
| `extended-swizzles-bgr10xr` | A known gap of the runtime (its README, Known gaps of textures): the texture is held as the UNORM codes of its bits, and a nearest or linear sample or a gather … |
| `extended-swizzles-bgr10xr` | A known gap of the runtime (its README, Known gaps of textures): the texture is held as the UNORM codes of its bits, and a nearest or linear sample or a gather … |
| `extended-swizzles-bgr10xr` | A known gap of the runtime (its README, Known gaps of textures): the texture is held as the UNORM codes of its bits, and a nearest or linear sample or a gather … |
| `extended-swizzles-bgr10xr` | A known gap of the runtime (its README, Known gaps of textures): the texture is held as the UNORM codes of its bits, and a nearest or linear sample or a gather … |
| `extended-swizzles-bgr10xr` | A known gap of the runtime (its README, Known gaps of textures): the texture is held as the UNORM codes of its bits, and a nearest or linear sample or a gather … |
| `extended-swizzles-bgr10xr` | A known gap of the runtime (its README, Known gaps of textures): the texture is held as the UNORM codes of its bits, and a nearest or linear sample or a gather … |
| `extended-swizzles-bgr10xr` | A known gap of the runtime (its README, Known gaps of textures): the texture is held as the UNORM codes of its bits, and a nearest or linear sample or a gather … |
| `extended-swizzles-bgr10xr` | A known gap of the runtime (its README, Known gaps of textures): the texture is held as the UNORM codes of its bits, and a nearest or linear sample or a gather … |
| `extended-swizzles-bgr10xr` | A known gap of the runtime (its README, Known gaps of textures): the texture is held as the UNORM codes of its bits, and a nearest or linear sample or a gather … |
| `extended-swizzles-bgr10xr` | A known gap of the runtime (its README, Known gaps of textures): the texture is held as the UNORM codes of its bits, and a nearest or linear sample or a gather … |
| `extended-swizzles-bgr10xr` | A known gap of the runtime (its README, Known gaps of textures): the texture is held as the UNORM codes of its bits, and a nearest or linear sample or a gather … |
| `extended-swizzles-bgr10xr` | A known gap of the runtime (its README, Known gaps of textures): the texture is held as the UNORM codes of its bits, and a nearest or linear sample or a gather … |
| `extended-swizzles-bgr10xr` | A known gap of the runtime (its README, Known gaps of textures): the texture is held as the UNORM codes of its bits, and a nearest or linear sample or a gather … |
| `extended-swizzles-bgr10xr` | A known gap of the runtime (its README, Known gaps of textures): the texture is held as the UNORM codes of its bits, and a nearest or linear sample or a gather … |
| `extended-swizzles-bgr10xr` | A known gap of the runtime (its README, Known gaps of textures): the texture is held as the UNORM codes of its bits, and a nearest or linear sample or a gather … |
| `extended-swizzles-bgr10xr` | A known gap of the runtime (its README, Known gaps of textures): the texture is held as the UNORM codes of its bits, and a nearest or linear sample or a gather … |
| `extended-swizzles-bgr10xr` | A known gap of the runtime (its README, Known gaps of textures): the texture is held as the UNORM codes of its bits, and a nearest or linear sample or a gather … |
| `extended-swizzles-bgr10xr` | A known gap of the runtime (its README, Known gaps of textures): the texture is held as the UNORM codes of its bits, and a nearest or linear sample or a gather … |
| `extended-swizzles-bgr10xr` | A known gap of the runtime (its README, Known gaps of textures): the texture is held as the UNORM codes of its bits, and a nearest or linear sample or a gather … |
| `extended-swizzles-bgr10xr` | A known gap of the runtime (its README, Known gaps of textures): the texture is held as the UNORM codes of its bits, and a nearest or linear sample or a gather … |
| `extended-swizzles-bgra10xr` | A known gap of the runtime (its README, Known gaps of textures): the texture is held as the UNORM codes of its bits, and a nearest or linear sample or a gather … |
| `extended-swizzles-bgra10xr` | A known gap of the runtime (its README, Known gaps of textures): the texture is held as the UNORM codes of its bits, and a nearest or linear sample or a gather … |
| `extended-swizzles-bgra10xr` | A known gap of the runtime (its README, Known gaps of textures): the texture is held as the UNORM codes of its bits, and a nearest or linear sample or a gather … |
| `extended-swizzles-bgra10xr` | A known gap of the runtime (its README, Known gaps of textures): the texture is held as the UNORM codes of its bits, and a nearest or linear sample or a gather … |
| `extended-swizzles-bgra10xr` | A known gap of the runtime (its README, Known gaps of textures): the texture is held as the UNORM codes of its bits, and a nearest or linear sample or a gather … |
| `extended-swizzles-bgra10xr` | A known gap of the runtime (its README, Known gaps of textures): the texture is held as the UNORM codes of its bits, and a nearest or linear sample or a gather … |
| `extended-swizzles-bgra10xr` | A known gap of the runtime (its README, Known gaps of textures): the texture is held as the UNORM codes of its bits, and a nearest or linear sample or a gather … |
| `extended-swizzles-bgra10xr` | A known gap of the runtime (its README, Known gaps of textures): the texture is held as the UNORM codes of its bits, and a nearest or linear sample or a gather … |
| `extended-swizzles-bgra10xr` | A known gap of the runtime (its README, Known gaps of textures): the texture is held as the UNORM codes of its bits, and a nearest or linear sample or a gather … |
| `extended-swizzles-bgra10xr` | A known gap of the runtime (its README, Known gaps of textures): the texture is held as the UNORM codes of its bits, and a nearest or linear sample or a gather … |
| `extended-swizzles-bgra10xr` | A known gap of the runtime (its README, Known gaps of textures): the texture is held as the UNORM codes of its bits, and a nearest or linear sample or a gather … |
| `extended-swizzles-bgra10xr` | A known gap of the runtime (its README, Known gaps of textures): the texture is held as the UNORM codes of its bits, and a nearest or linear sample or a gather … |
| `extended-swizzles-bgra10xr` | A known gap of the runtime (its README, Known gaps of textures): the texture is held as the UNORM codes of its bits, and a nearest or linear sample or a gather … |
| `extended-swizzles-bgra10xr` | A known gap of the runtime (its README, Known gaps of textures): the texture is held as the UNORM codes of its bits, and a nearest or linear sample or a gather … |
| `extended-swizzles-bgra10xr` | A known gap of the runtime (its README, Known gaps of textures): the texture is held as the UNORM codes of its bits, and a nearest or linear sample or a gather … |
| `extended-swizzles-bgra10xr` | A known gap of the runtime (its README, Known gaps of textures): the texture is held as the UNORM codes of its bits, and a nearest or linear sample or a gather … |
| `extended-swizzles-bgra10xr` | A known gap of the runtime (its README, Known gaps of textures): the texture is held as the UNORM codes of its bits, and a nearest or linear sample or a gather … |
| `extended-swizzles-bgra10xr` | A known gap of the runtime (its README, Known gaps of textures): the texture is held as the UNORM codes of its bits, and a nearest or linear sample or a gather … |
| `extended-swizzles-bgra10xr` | A known gap of the runtime (its README, Known gaps of textures): the texture is held as the UNORM codes of its bits, and a nearest or linear sample or a gather … |
| `extended-swizzles-bgra10xr` | A known gap of the runtime (its README, Known gaps of textures): the texture is held as the UNORM codes of its bits, and a nearest or linear sample or a gather … |
| `extended-swizzles-bgra10xr` | A known gap of the runtime (its README, Known gaps of textures): the texture is held as the UNORM codes of its bits, and a nearest or linear sample or a gather … |
| `extended-swizzles-bgra10xr` | A known gap of the runtime (its README, Known gaps of textures): the texture is held as the UNORM codes of its bits, and a nearest or linear sample or a gather … |
| `extended-swizzles-bgr5a1unorm` | The device's own answer (rule 1): a read, nearest sample or gather of a packed 16-bit unorm texel through a swizzled view: the device widens a 5- or 6-bit code … |
| `extended-swizzles-bgr5a1unorm` | The device's own answer (rule 1): a read, nearest sample or gather of a packed 16-bit unorm texel through a swizzled view: the device widens a 5- or 6-bit code … |
| `extended-swizzles-bgr5a1unorm` | The device's own answer (rule 1): a read, nearest sample or gather of a packed 16-bit unorm texel through a swizzled view: the device widens a 5- or 6-bit code … |
@@ -9551,8 +9595,8 @@ A case whose difference from Metal is recorded rather than compared away. The le
| `xr-gradient-bgra10xr-srgb-unblended-x4` | refused: no stream uses it yet (full selector census 11-19, m3-max-53207-53208, 53213, 53217-53221: 26 streams, no texture or view of MTLPixelFormatBGRA10_XR_sR… |
| `xr-gradient-bgra10xr-unblended-x1` | refused: no stream uses it yet (full selector census 11-19, m3-max-53207-53208, 53213, 53217-53221: 26 streams, no texture or view of MTLPixelFormatBGRA10_XR). … |
| `xr-gradient-bgra10xr-unblended-x4` | refused: no stream uses it yet (full selector census 11-19, m3-max-53207-53208, 53213, 53217-53221: 26 streams, no texture or view of MTLPixelFormatBGRA10_XR). … |
| `xr-planes-bgr10xr-bgra10xr` | refused: no stream uses it yet (full selector census 11-19, m3-max-53207-53208, 53213, 53217-53221: 26 streams, no texture or view of MTLPixelFormatBGR10_XR). r… |
| `xr-planes-bgr10xr-bgra10xr-srgb` | refused: no stream uses it yet (full selector census 11-19, m3-max-53207-53208, 53213, 53217-53221: 26 streams, no texture or view of MTLPixelFormatBGR10_XR). r… |
| `xr-planes-bgr10xr-bgra10xr` | refused: no stream uses it yet (full selector census 11-19, m3-max-53207-53208, 53213, 53217-53221: 26 streams, no texture or view of MTLPixelFormatBGRA10_XR). … |
| `xr-planes-bgr10xr-bgra10xr-srgb` | refused: no stream uses it yet (full selector census 11-19, m3-max-53207-53208, 53213, 53217-53221: 26 streams, no texture or view of MTLPixelFormatBGRA10_XR_sR… |
| `xr-planes-bgr10xr-srgb-bgra10xr` | refused: no stream uses it yet (full selector census 11-19, m3-max-53207-53208, 53213, 53217-53221: 26 streams, no texture or view of MTLPixelFormatBGR10_XR_sRG… |
| `xr-planes-bgr10xr-srgb-bgra10xr-srgb` | refused: no stream uses it yet (full selector census 11-19, m3-max-53207-53208, 53213, 53217-53221: 26 streams, no texture or view of MTLPixelFormatBGR10_XR_sRG… |
| `xr-two-plane-samples-p2-lc-f` | refused: no stream uses it yet (full selector census 11-19, m3-max-53207-53208, 53213, 53217-53221: 26 streams, no texture or view of MTLPixelFormatRGB10A8_2P_X… |
+5 -1
View File
@@ -98,7 +98,11 @@ where the device's answer for its format differs with the usage, bit 11. A slot'
buffer's texture's, takes the border texel an index outside the level reads on a border axis from
bits 0-11 of the word, for the sampler's border color; a texture buffer's whose word has bit 13
set, from the border texels of the format its code names, as an argument buffer's texture buffer
held as words does from the code its handle carries. The runtime writes a slot's ID, so its index is an element;
held as words does from the code its handle carries. A `float` or `half` sample, gather or read of a
sampled colour image tests the word's format for `BGR10_XR` (554) and `BGRA10_XR` (552), whose
images hold their codes as UNORM, and maps each lane that bits 0-11 mark as a channel's
(docs/API.md); a function that makes such a read of an argument buffer's texture carries the
test in bit 30 of the texture's handle, beside the word's bits 0-13. The runtime writes a slot's ID, so its index is an element;
the program writes an argument buffer's, so the shader masks its index to its low 16 bits: a bad
ID reads the element at `index & 0xFFFF`, never one outside the arrays.