xshader: check the guest mode on its real encoding before lowering extrema #543

Merged
csj0oe merged 2 commits from upstream-pr/543 into main 2026-11-29 21:27:38 +00:00
csj0oe commented 2026-11-29 21:08:34 +00:00 (Migrated from github.com)

Imported from brcly/TuxBox. Originally posted by csj0oe on 2026-11-29T21:08:34Z.


What

A divergent f32 extrema reduction was lowered to WaveActiveMin/Max even when the guest had changed the floating-point mode. The check only matched s_round_mode/s_denorm_mode (Sopp 0x24/0x25), but this decoder represents s_setreg_b32/s_setreg_imm32_b32 as Sopk 19/21 — which is how a program actually sets MODE. One shared predicate now covers both encodings and the HW_REG_MODE field, and both Emitter::new and the extrema lowering call it.

Also from review: the unreachable second proof is gone rather than left as a claim; 64-lane reductions cover high == sum, high != sum and a later read; the scratch reuse carries a note naming its 32-lane ceiling; the select is matched exactly at first - 1 with its mnemonic, and the restore is verified by mnemonic, destination and saved register.

GPU verification pending

AMD and NVIDIA. No GPU or present gate was run; the extrema lowering's identity and flush behaviour is checked statically and at DXIL level only.

<!-- greyfinch-sync:brcly/TuxBox:issue:5555139851 --> Imported from [brcly/TuxBox](https://github.com/brcly/TuxBox/pull/543). Originally posted by [csj0oe](https://github.com/csj0oe) on 2026-11-29T21:08:34Z. --- ## What A divergent f32 extrema reduction was lowered to `WaveActiveMin`/`Max` even when the guest had changed the floating-point mode. The check only matched `s_round_mode`/`s_denorm_mode` (Sopp 0x24/0x25), but this decoder represents `s_setreg_b32`/`s_setreg_imm32_b32` as Sopk 19/21 — which is how a program actually sets `MODE`. One shared predicate now covers both encodings and the `HW_REG_MODE` field, and both `Emitter::new` and the extrema lowering call it. Also from review: the unreachable second proof is gone rather than left as a claim; 64-lane reductions cover `high == sum`, `high != sum` and a later read; the scratch reuse carries a note naming its 32-lane ceiling; the select is matched exactly at `first - 1` with its mnemonic, and the restore is verified by mnemonic, destination and saved register. ## GPU verification pending AMD and NVIDIA. No GPU or present gate was run; the extrema lowering's identity and flush behaviour is checked statically and at DXIL level only.
brcly commented 2026-11-29 21:11:52 +00:00 (Migrated from github.com)

Imported from brcly/TuxBox. Originally posted by brcly on 2026-11-29T21:11:52Z.


Thanks. This is in our current focus. You noted no GPU checks were run, so we're running the full check on an NVIDIA and an AMD card here, and measuring how many recorded programs' translations change. We'll merge it if that passes.

<!-- greyfinch-sync:brcly/TuxBox:comment:7262682391 --> Imported from [brcly/TuxBox](https://github.com/brcly/TuxBox/pull/543#issuecomment-7262682391). Originally posted by [brcly](https://github.com/brcly) on 2026-11-29T21:11:52Z. --- Thanks. This is in our current focus. You noted no GPU checks were run, so we're running the full check on an NVIDIA and an AMD card here, and measuring how many recorded programs' translations change. We'll merge it if that passes.
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
brcly/TuxBox!543
No description provided.