Lane dont_care_unstored: a 0.5 channel's UNORM8 midpoint takes the device's rounding

dcs_mark writes a green of 0.5 and its second color's y of 0.5, which dcs_read writes; in a
BGRA8Unorm target that is the midpoint 127.5 of a step. The classifier took only 128, Metal's and
RADV's answer, so the pin 38 round's 3090 lane (m3-max-16904) found every marked pixel '?' under
both policies. The device's own float-to-UNORM conversion is its answer (AGENTS.md rule 1); the
classifier now takes 127 or 128 for those channels.
This commit is contained in:
Anees Iqbal committed 2026-11-11 12:56:17 -08:00
1 parent 3bfeeb38fd
commit 51b0ccf5fa
1 file changed
+6 -3
@@ -456,14 +456,17 @@ fn encode_separate_run(
/// What a pixel's first color says (`BGRA8Unorm` bytes in memory order): `P` the poison (no draw
/// wrote it), `M` `dcs_mark`'s, `Z` a read of a zero second color, `S` a read of the poison's
/// second color, `K` a read of `dcs_mark`'s, `F` `dcs_flag`'s, `?` anything else.
/// second color, `K` a read of `dcs_mark`'s, `F` `dcs_flag`'s, `?` anything else. A `0.5` channel
/// (`dcs_mark`'s green, and its second color's `y` that `dcs_read` writes) is the midpoint 127.5 of
/// a `UNORM8` step, which the device's own conversion rounds (AGENTS.md rule 1): Metal and RADV
/// store 128, NVIDIA's may store 127.
fn class(bgra: &[u8]) -> char {
match bgra {
[17, 34, 51, 68] => 'P',
[0, 128, 0, 255] => 'M',
[0, 127 | 128, 0, 255] => 'M',
[255, 0, 0, 255] => 'Z',
[255, 223, 191, 255] => 'S',
[255, 128, 64, 255] => 'K',
[255, 127 | 128, 64, 255] => 'K',
[255, 0, 255, 255] => 'F',
_ => '?',
}