Encode a half's bits by the device's narrowing, not an integer sequence
A half value whose bits are not known from a load (a store, a reinterpretation, a texel's or snapshot's bits) is encoded by the device: with shaderFloat16 one OpFConvert to 16 bits (NoContraction under the float controls), each lane read as a word beside a 16-bit zero; without it GLSL.std.450 PackHalf2x16. The exact integer sequence (rebias, NaN quieting, the 2^24 denormal scaling, the 0x7C00 cap under native rounding) is deleted. narrow::encodes_bits finds the narrowing; compile.rs records the widening's notes for it: NativeNanEncoding everywhere, NativeHalfConversion where neither the float controls nor MetalHalfArithmetic cover it. Bits known from a load, folded constants, an integer's half and bfloat stay exact. bits_words 136 -> 48 per lane. Tests pinning the old NaN bits accept the device's where the note is recorded; 40 known-gaps rows the Apple M3 Max no longer diverges at are dropped (29 attribute-format-fetches half-NaN sites, 3 each of half-texel-nans-r16f/ -rg16f/-rgba16f, 2 of math-frexp-ilogb-half: Metal's own NaN bits now). SEMANTICS_VERSION 1919. Verified: 347 translator tests (lower::arith::tests, the touched engine modules, every public fixture on every committed profile), clippy plain and --cfg m2v_gpu, rustdoc; a sabotaged encode form fails the new a_half_encode_is_the_devices_narrowing_in_every_form; on the M3 Max: conformance replay of 28 half cases exit 0 (every divergence a held ledger row), validation runtime_lane half tests 7/7, runtime nan_signs/vertex conversion notices/degradation sites 4/4. golden_hashes.tsv cells move, re-blessed on development. Not run: lavapipe, the full validation and conformance sets. One work packet, landed as 1 commit on archive/development-linear-2026-10-29: 0d7093d826.
This commit is contained in:
1 parent
ed114bcf43
commit
bc1a6ebf8b
13 files changed
+552
-265
No files matched your search
+9
-4
@@ -3232,9 +3232,11 @@ bound.
|
||||
conversion under them, exactly, with no note): NVIDIA, whose driver folds the conversion's round
|
||||
trip even under those controls (`DriverWorkaround::HalfConversionPairFolded`), MoltenVK,
|
||||
lavapipe, and any device without them. Also recorded where a `half` read from its bits is the
|
||||
device's widening and that widening is neither under those controls nor measured to be Metal's:
|
||||
the conversion on NVIDIA and lavapipe, and `GLSL.std.450 UnpackHalf2x16` on every device without
|
||||
`shaderFloat16`. A half denormal may read as the zero of its sign.
|
||||
device's widening, or a `half` encoded to its bits (where they are not the bits it was read from)
|
||||
is the device's narrowing, and that conversion is neither under those controls nor measured to be
|
||||
Metal's: the conversion on NVIDIA and lavapipe, and `GLSL.std.450 UnpackHalf2x16` and
|
||||
`PackHalf2x16` on every device without `shaderFloat16`. A half denormal may read or encode as the
|
||||
zero of its sign.
|
||||
- `metal2vulkan-degrade-native-half-quantize` (precision). `PrecisionNote::NativeHalfQuantize`:
|
||||
Native half rounding (a quantize): the module rounds a `half` result it computes in `float` (a
|
||||
`half` operation's, a function's, a conversion from `float`'s, a texel's) by the device's
|
||||
@@ -3250,7 +3252,10 @@ bound.
|
||||
recorded wherever a `half` is read from its bits, on every device, since the read is the
|
||||
device's widening (its conversion with `shaderFloat16`, `UnpackHalf2x16` without): a NaN's bits
|
||||
the device's, where Metal widens every `half` NaN to `0x7fc00000` and moves one it does not
|
||||
widen with its bits.
|
||||
widen with its bits. And wherever a `half` is encoded to its bits (a store, a reinterpretation, a
|
||||
texel's bits) where they are not the bits it was read from, on every device, since the encode is
|
||||
the device's narrowing (its conversion with `shaderFloat16`, `PackHalf2x16` without): a NaN's
|
||||
bits the device's, where Metal keeps a `half` NaN's sign and payload.
|
||||
- `metal2vulkan-degrade-native-min-max` (precision). `PrecisionNote::NativeMinMax`: Native device
|
||||
maths: Metal's `fmin`, `fmax`, `min3`, `max3`, `clamp` or `saturate` (its `clamp(x, +0, 1)`) on
|
||||
`float` or `half` is the device's `GLSL.std.450` `NMin`, `NMax` or `NClamp`, on a device not
|
||||
|
||||
Reference in new issue
Block a user