shader: lower s_round_mode 0x0 and 0xc as MODE[3:2] writes in pixel_aot #2110

Merged
legacy-code-archaeologist merged 1 commit from upstream-pr/2118 into main 2026-11-25 01:38:51 +00:00
legacy-code-archaeologist commented 2026-11-25 00:47:45 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by legacy-code-archaeologist on 2026-11-25T00:47:45Z.


s_round_mode writes MODE[3:0]: bits 1:0 are the binary32 rounding and bits 3:2 the binary16/binary64 rounding. pixel_aot already tracks bits 3:2 for s_setreg_imm32_b32 hwreg(HW_REG_MODE, 2, 2) and the SOPK register forms. Every binary32 lowering assumes nearest even, so this accepts exactly the two immediates that leave bits 1:0 at 0:

  • s_round_mode 0x0 acts as hwreg(HW_REG_MODE, 2, 2), 0, and s_round_mode 0xc as hwreg(HW_REG_MODE, 2, 2), 3. They share the tracked state and the round-toward-zero gate for binary16, packed and binary64 forms, and the last write wins across all three write forms. A later s_getreg_b32 of the field returns 0 or 3.
  • Every other value is refused as Unsupported rounding mode: binary32 directed or truncating modes 0x1 to 0x3, binary16 directed modes 0x4 and 0x8, combinations of those, bits above bit 3, and the unprinted 0x00 and 0x0c. Decimal, upper-case, register or missing operands are refused as Malformed s_round_mode operand. LLVM 15 prints the SIMM16 in hex.
  • As with the setreg forms, the write is not accepted after the colour export, in a masked region or in a uniform skip block.

The five controls that pinned s_round_mode 3 as Unsupported instruction now pin the printed spelling s_round_mode 0x3 as Unsupported rounding mode. The value is still refused, but the refusal now comes from the new value check. tools/scan_unsupported_shaders.py lists the two accepted immediates as supported, next to the MODE[3:2] setreg entry, and rdna2_tools_check covers both the accepted and the refused cases.

s_denorm_mode stays refused.

Tests

Base 246a875d, Windows 11 build 26100, debug layer unavailable.

Check Result
python -B tests/pixel_aot_check.py (new check_sopp_round_mode_controls) pass
Six mutations of the lowering: unshifted field, binary16 state not updated, 0x3 accepted, decimal accepted, 0xc written as nearest even, write not counted for the read 6/6 fail the controls
ctest --preset dev --no-tests=error -R '^pixel_aot_sopp_round_mode_' -V on WARP 10.0.26100.8972 pass. Batch statuses: 10× mismatch for the five wrong references on both rows, 2× pass
same, hardware, NVIDIA Quadro M1000M 32.0.15.7371 pass, same statuses
same, hardware, Intel HD Graphics 530 31.0.101.2111 pass, same statuses
pixel_aot_check.py binary with LLVM 15.0.7 (round trip of the draw body, encodings 0000a4bf, 0c00a4bf, 0300a4bf, s_round_mode 12 printed as 0xc) pass
ctest -R '^pixel_aot_' -E '_hardware$' -j 3, before the rebase 90/90
tests/form_coverage_check.py, tests/rdna2_tools_check.py (with LLVM, 154 tests, 1 skip), docs_links_check, shader_census_check, shader_probe_check, startup_gfx2hlsl_refusals_check pass
Removing the new scanner regex rdna2_tools_check fails

The draw checks the translator's tracked value through s_getreg_b32, not the console's MODE register. The gfx1030 spelling matches gfx1013 by LLVM-C disassembly (bfa4000c → s_round_mode 0xc), but the repository pins only gfx1013. The archive rescan in docs/experiments.md was not repeated for s_round_mode.

AI-assisted.

🤖 Generated with Claude Code

<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:6594524094 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2118). Originally posted by [legacy-code-archaeologist](https://github.com/legacy-code-archaeologist) on 2026-11-25T00:47:45Z. --- `s_round_mode` writes MODE[3:0]: bits 1:0 are the binary32 rounding and bits 3:2 the binary16/binary64 rounding. pixel_aot already tracks bits 3:2 for `s_setreg_imm32_b32 hwreg(HW_REG_MODE, 2, 2)` and the SOPK register forms. Every binary32 lowering assumes nearest even, so this accepts exactly the two immediates that leave bits 1:0 at 0: - `s_round_mode 0x0` acts as `hwreg(HW_REG_MODE, 2, 2), 0`, and `s_round_mode 0xc` as `hwreg(HW_REG_MODE, 2, 2), 3`. They share the tracked state and the round-toward-zero gate for binary16, packed and binary64 forms, and the last write wins across all three write forms. A later `s_getreg_b32` of the field returns 0 or 3. - Every other value is refused as `Unsupported rounding mode`: binary32 directed or truncating modes `0x1` to `0x3`, binary16 directed modes `0x4` and `0x8`, combinations of those, bits above bit 3, and the unprinted `0x00` and `0x0c`. Decimal, upper-case, register or missing operands are refused as `Malformed s_round_mode operand`. LLVM 15 prints the SIMM16 in hex. - As with the setreg forms, the write is not accepted after the colour export, in a masked region or in a uniform skip block. The five controls that pinned `s_round_mode 3` as `Unsupported instruction` now pin the printed spelling `s_round_mode 0x3` as `Unsupported rounding mode`. The value is still refused, but the refusal now comes from the new value check. `tools/scan_unsupported_shaders.py` lists the two accepted immediates as supported, next to the MODE[3:2] setreg entry, and `rdna2_tools_check` covers both the accepted and the refused cases. `s_denorm_mode` stays refused. ## Tests Base `246a875d`, Windows 11 build 26100, debug layer unavailable. | Check | Result | |---|---| | `python -B tests/pixel_aot_check.py` (new `check_sopp_round_mode_controls`) | pass | | Six mutations of the lowering: unshifted field, binary16 state not updated, `0x3` accepted, decimal accepted, `0xc` written as nearest even, write not counted for the read | 6/6 fail the controls | | `ctest --preset dev --no-tests=error -R '^pixel_aot_sopp_round_mode_' -V` on WARP 10.0.26100.8972 | pass. Batch statuses: 10× mismatch for the five wrong references on both rows, 2× pass | | same, hardware, NVIDIA Quadro M1000M 32.0.15.7371 | pass, same statuses | | same, hardware, Intel HD Graphics 530 31.0.101.2111 | pass, same statuses | | `pixel_aot_check.py binary` with LLVM 15.0.7 (round trip of the draw body, encodings `0000a4bf`, `0c00a4bf`, `0300a4bf`, `s_round_mode 12` printed as `0xc`) | pass | | `ctest -R '^pixel_aot_' -E '_hardware$' -j 3`, before the rebase | 90/90 | | `tests/form_coverage_check.py`, `tests/rdna2_tools_check.py` (with LLVM, 154 tests, 1 skip), `docs_links_check`, `shader_census_check`, `shader_probe_check`, `startup_gfx2hlsl_refusals_check` | pass | | Removing the new scanner regex | `rdna2_tools_check` fails | The draw checks the translator's tracked value through `s_getreg_b32`, not the console's MODE register. The gfx1030 spelling matches gfx1013 by LLVM-C disassembly (`bfa4000c` → `s_round_mode 0xc`), but the repository pins only gfx1013. The archive rescan in `docs/experiments.md` was not repeated for `s_round_mode`. _AI-assisted._ 🤖 Generated with [Claude Code](https://claude.com/claude-code)
upstream-sync closed this pull request 2026-11-25 02:01:47 +00:00
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
R0Y00/Xbox2Windows!2110
No description provided.