Record a texture write's NaN encoding only where its stored NaN is not measured to be Metal's

reims-vgpu treats precision notes as fatal on Apple GPUs. A kernel's write of halves into a
32-bit float or RG11B10Float texture died with DeviceNanEncoding, and through NativeNanEncoding,
on the M3 Max where the stored bytes are Metal's; a write of a constant texel with no NaN died
the same way on every device.

What:
- A new DriverDeviation::MetalSmallFloatNans (VkProperty::MetalSmallFloatNans), taken by the
  APPLE9 MoltenVK row alone: the device stores a float's or a half's NaN written to a
  B10G11R11_UFLOAT_PACK32 storage image as Metal does.
- half_write_nans (a half texel's write) classifies the slot's storage choice: a 16-bit float
  format takes MetalHalfTexelWrites as before, a 32-bit float one MetalNanMoves (the widened
  half's bits are Metal's 0x7fc00000), the packed small float one MetalSmallFloatNans; a taken
  deviation drops the note and requires its property. A slot declared without a format (every
  float storage choice on MoltenVK and lavapipe) records the note under the bound format's class
  (a SpecializedNote of BoundTexelFormat), one clause per class the profile does not cover, so
  the runtime announces it only when such a texture is bound.
- half_storage_facts (a float texel's write) drops the small-float note the same way.
- A texture write of a constant texel none of whose lanes is a NaN records neither note.
- A new module side table, stored_texels, records each texture-family write's texel (kept
  through edit.rs's retain and the roll pass's check). narrow::moves_unfolded no longer counts a
  widened half's store as such a texel as an escape: the write's own DeviceNanEncoding accounts
  for its stored NaN under the format it stores.

Verified on this M3 Max, byte for byte against plain Metal (an MSL probe): a float4 write of
33,792 words (16,446 NaNs) and a half4 write of all 65,536 halves (2,046 NaNs) into RG11B10Float,
RGBA32Float, RG32Float and R32Float store Metal's bytes; into R16Float and RGBA16Float a half
NaN's payload differs (the device stores 0x7e00), so those keep the note.
- runtime_lane::half_write_nans on MoltenVK: half writes into rgba32f, r32f and rg11b10f announce
  nothing and 0 texels differ; rgba16f announces device-nan-encoding (2,045 NaNs differ). Without
  note_stored_texel the lane fails ("write r32f: ... native-nan-encoding true").
- New core tests: a_half_texel_write_s_nan_into_wide_and_small_float_images_is_metal_s_where_
  measured (declared and formatless choices on moltenvk-m3 with and without each deviation, and
  lavapipe; the bound-class clauses evaluated per format) and a_constant_texel_without_a_nan_
  records_no_nan_encoding (zero and 0x7e00 constants, every committed profile); the existing
  device-nan-encoding and half-storage-notes tests follow the deviations. Each fails with its
  change disabled (the NaN test forced true; the stored-texel exemption removed).
- Notes of every public fixture on moltenvk-m3, lavapipe and nvidia-rtx5080-laptop before and
  after: DeviceNanEncoding leaves 65 moltenvk-m3 rows and 6 rows on each other profile (constant
  texels), 17 formatless rows per profile go from unconditional to specialized by bound format,
  58 moltenvk-m3 rows lose their small-float clause, NativeNanEncoding leaves 11 moltenvk-m3 rows,
  and no row gains a note. Consumer AIR on moltenvk-m3: DeviceNanEncoding 33 entries to 21,
  NativeNanEncoding 9 to 5.

Docs: API.md (device-nan-encoding and native-nan-encoding exemptions), HOWTO.md, the
PrecisionNote, VkProperty and deviation rustdoc, the driver-facts measurement record.
api_signatures gains the two variants. The versions bumped in the previous commit cover this one.

(cherry picked from commit 05d96c61107989813c186961087ee70d573cf876)
This commit is contained in:
Anees Iqbal committed 2026-11-02 16:41:46 -08:00
1 parent 217cc233f5
commit 763965c854
22 files changed
+533 -70

No files matched your search

+15 -5
View File
@@ -3079,7 +3079,15 @@ bound.
Metal's fill keeps a half NaN's sign and payload and makes a small float's all ones. Also a blend
a fragment function computes into a 16-bit float attachment through the pixel interlock: a NaN
of the blend is the device's arithmetic's, which the storage image's store converts, where Metal
stores every NaN of the blend as `0x7e00`.
stores every NaN of the blend as `0x7e00`. A texture write records it where the stored NaN is the
device's: a constant texel none of whose lanes is a NaN records nothing. **Exempt:** a `half`
texel's write to a 32-bit float storage image on a profile that takes
`DriverDeviation::MetalNanMoves` (the image stores the widened `float`'s bits, Metal's
`0x7fc00000`; the module requires `VkProperty::MetalNanMoves`), and a `float` or `half` texel's
write to a packed small float one (`RG11B10Float`) on a profile that takes
`DriverDeviation::MetalSmallFloatNans`, MoltenVK on Apple's GPUs of the Apple M3 Max's macOS 27
identity, measured byte for byte against plain Metal over every `half` and 33,792 `float` words,
16,446 NaNs among them (the module requires `VkProperty::MetalSmallFloatNans`).
- `metal2vulkan-degrade-restricted-depth-range` (precision). `PrecisionNote::RestrictedDepthRange`:
The device compares a depth texture's texels on a device without `VK_EXT_depth_range_unrestricted`
enabled whose driver is not measured to keep depth values outside `[0, 1]` without it.
@@ -3493,10 +3501,12 @@ bound.
`fabs`, a `half`'s widening to `float`, a `half` `fabs`, and a module's reads and encodes of a
`half`'s bits record no note and require `VkProperty::MetalNanMoves`. The exemption stops where
the module carries a widened `half` out of the registers before narrowing it (a store to a stage
output or a variable other than a function's `float` one, a call, a return, a group, atomic or
image operation), reads its widened bits (a bitcast but to store them to memory, `frexp`,
`modf`, `ldexp`), or holds a `float` NaN constant other than `0x7fc00000`: such a module
records the note there too. A `half` `fneg` records it on every device.
output or a variable other than a function's `float` one, a call, a return, a group or atomic
operation, an image operation but a texture write of it, whose store the write's own
`PrecisionNote::DeviceNanEncoding` accounts for), reads its widened bits (a bitcast but to store
them to memory, `frexp`, `modf`, `ldexp`), or holds a `float` NaN constant other than
`0x7fc00000`: such a module records the note there too. A `half` `fneg` records it on every
device.
- `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