State the padded sRGB twins' code and decode bounds as measured

DevicePackConversion's documented bound for the extended-range and
padded conversions said "a code within one" of Metal's. For
R10Unorm_X6_sRGB and RGB10A2Unorm_sRGB that is wrong. Metal's write of
these formats rounds the value clamped to [0, 1] to 2^-13 (nearest even)
and then looks it up in its encode table (R10X6_SRGB_ENCODE_FIRST). The
device writes the MSL transfer by its own maths, times 1023, RoundEven.
In the transfer's linear segment, one 2^-13 step spans 1.6 codes, so the
two can land two codes apart.

Measured: for each 2^-13 step over [0, 1], the f32s at and next to both
edges, where Metal's code is constant within a step and the device's
code rises with the value. The device's code (exact transfer) lies at
most two from Metal's table. It reaches two only below 0.0031308: at
1.5/8192, just above 6.5/8192, and at 24.5/8192. Everywhere else it is
within one, beyond the Pow's bound. Metal's recorded writes and stores
of RGB10A2Unorm_sRGB on the M3 Max under macOS 27.0.1
(rgb10a2-srgb-writes, -stores-f, -stores-h) show exactly that: three
words each, at k/16384 for k = 3 and 49, and at the 1.5/8192 special.

Metal's decode of RGB10A2Unorm_sRGB's colour (the rgb10a2-srgb-reads
recording, every code) lies up to 1.637 steps of 2^-13 from the exact
transfer (code 952: Metal 0.84912109, exact 0.84932096). That is the
1.64 the docs gave for R10Unorm_X6_sRGB only.

So artifact.rs's DevicePackConversion, the FAST-PATHS air.pack row and
API.md's catalogue entry now give, for those two formats only: a colour
code within two below 0.0031308, and a decoded colour within 1.64
steps. Doc text only: the device's conversion is unchanged (rule 1),
and so is behaviour. No version bump.

(cherry picked from commit 8bfaab43bd6c6368c41d58caa7e9c91fe64820d5)
(cherry picked from commit e728f0fa394c46c528d2f99df89a33751f5691d7)
This commit is contained in:
Anees Iqbal committed 2026-11-03 04:10:31 -08:00
1 parent 24d2ada6af
commit aa9b38e6fd
3 files changed
+12 -8

No files matched your search

+5 -3
View File
@@ -3611,9 +3611,11 @@ bound.
its quiet bit). Metal divides correctly rounded, rounds the exact product, rounds a `half` with
ties away from zero, converts the sRGB twins through its own tables, makes a bfloat NaN
`0x7fc00000` or `0x7fc0`, and rounds a bfloat sample's `half` toward zero: a linear value within
one `f32` ulp, a code within one, an sRGB twin's decoded value within half a `2^-13` step of
Metal's table (`R10Unorm_X6_sRGB`'s 1.64 steps) beyond the `Pow`'s bound, a `half` result within
one `half` ulp.
one `f32` ulp, a code within one (`R10Unorm_X6_sRGB`'s and `RGB10A2Unorm_sRGB`'s colour within
two below `0.0031308`, where Metal rounds the value to `2^-13` before its table, a step there
spanning 1.6 codes), an sRGB twin's decoded value within half a `2^-13` step of Metal's table
(`R10Unorm_X6_sRGB`'s and `RGB10A2Unorm_sRGB`'s colour 1.64 steps) beyond the `Pow`'s bound, a
`half` result within one `half` ulp.
- `metal2vulkan-degrade-color-attachment-groups` (precision).
`PrecisionNote::ColorAttachmentGroups`: A render pipeline whose color attachments the device
draws in more than one group (more than the lesser of its `maxColorAttachments` and