Repository navigation
Conversation
D = MODE field (offset, size) right-justified, SCC kept. MODE[1:0] reads 0 (f32 always nearest even here), MODE[3:2] the f16/f64 rounding tracked from s_setreg (%mode_r16). Other MODE bits and other hardware registers stay Unsupported with a message naming them. Layout and reads measured on RDNA2 gfx1036. GPU fixture cs_w32_getreg_mode, semantic test GetregMode, design.md row. AI-assisted.
A MODE.FP_ROUND write ((2,2), (1,3) or (0,4)) now takes its value from an SGPR that holds a constant set earlier in the block, or that s_getreg_b32 of the same field filled earlier in the block (restored at run time); any other register source stays Unsupported. Field write semantics measured on RDNA2 gfx1036. GPU fixture cs_w32_setreg_sgpr, semantic test SetregFromSgpr, design.md row. AI-assisted.
|
Tested Independent Linux Vulkan check of Changing only the initial rounding mode from toward zero to nearest-even before the two saves gave Both modules assembled with LLVM 21.1.8 and passed Vulkan 1.2 SPIR-V validation. The three focused CPU tests and the fixture regeneration check also passed. Synthetic Vulkan coverage on Linux. AI-assisted. AI-assisted verification. |
|
Tested 38fdf50 on AMD Radeon RX 9060 XT (RDNA4), AMD driver 26.10.44 (LLPC, Vulkan driver 2.0.395), Windows 11 Pro 10.0.26300, subgroup 32..64: pass. The checks above have no AMD run from outside the author; this adds an AMD card with native 64-wide subgroups.
Test programs: an MSVC 14.44 build of main ec8ec4c; this PR's runtime C++ and CMake are identical to that commit, and the translator, runner and |
|
Tested 38fdf50 on NVIDIA GeForce RTX 3090 (Ampere, subgroup 32..32), driver 610.88 (Vulkan 1.4.341), Windows 11 Pro 26300: pass. The PR's diff applied cleanly to
|
|
Tested
Tools: llvm-mc 23.1.6 (conda-forge), SPIRV-Tools from the Vulkan SDK. No game files. AI-assisted (Claude Code). |
|
Tested
No game files. AI-assisted (Claude Code). |
docs/design.md tools/rdna2spirv.py AI-assisted.
docs/design.md tools/rdna2spirv.py AI-assisted.
tests/semantic/test_scalar_noop_waitcnt.py s4 now folds to a constant on main, so the not-modelled s_setreg_b32 case uses an unwritten user SGPR (s9). AI-assisted.
|
Re-tested |
docs/design.md runtime/test/shaders/check.py scripts/run_gpu_tests.py tools/rdna2spirv.py The per-block reset of the s_getreg save map goes next to each sgpr_imm reset in main's restructured dispatch loop. AI-assisted.
|
Tested Ran the PR’s synthetic fixtures through
AI-assisted verification with synthetic inputs. |
docs/design.md AI-assisted.
|
Apple M2 / MoltenVK validation of head
No code changes, no game data; synthetic fixtures and counts only. AI-assisted. |
|
Tested
New in this PR:
Every other test has the same result as on |
Requested by Lucas · project thread
Claimed in the coordination issue as: EGEN-SALU-SETREG-SGPR, #2891 (comment)
Depends on: #2980 (
s_getreg_b32of MODE.FP_ROUND). This branch is stacked on it, so the first commit here is #2980's and only the last commit is new.What and why
Every
s_setreg_b32from a register raisedUnsupported. That means the save/restore pair for the f16/f64 rounding mode could not be translated:Change (
tools/rdna2spirv.py,Gen.mode_write): an MODE.FP_ROUND write now accepts the fields that cover FP_ROUND[3:2] whole and stay inside FP_ROUND[3:0]: (2,2), (1,3) and (0,4). This also applies tos_setreg_imm32_b32, which accepted only (2,2) before. The value can come from:s_mov_b32set to a constant earlier in the block. The rules match the immediate case: the f32 bits must be 0, and FP_ROUND[3:2] must be 0 or 3;s_getreg_b32of the same field filled earlier in the block, with no write to it in between. It is restored at run time. The saved value can only hold what the translator tracks, so FP_ROUND[3:2] is set to its top two bits. The provenance is tracked inGen.sgpr_mode, whichstore_regand each block start clear, as forsgpr_imm.Any other register source stays
Unsupported, with a message saying why: a computed value, a load, a save of a different field, or a save from another block. Directed rounding and non-zero f32 rounding bits are refused as before.Measured on RDNA2 gfx1036 (Radeon iGPU of a Ryzen 9 9950X3D, driver 26.10.1,
tools/hw_oracleraw wave32 kernels, v0-v15 / s4-s15):s_setreg_b32of the same field reads back 3 / 0xc.s_setreg_b32 (2,2)of 7 gives MODE[3:0] = 0xc, so the bits abovesizeare dropped. 0xc into (1,3) gives 8.New contract row in
docs/design.md. #2980's row now points to it.Tested
Windows 11, LLVM
llvm-mc,VK_LOADER_LAYERS_DISABLE=~implicit~, one GPU at a time,python -I scripts/run_gpu_tests.py --filter cs_w32_setreg_sgpr:15361 15360 3 15360 12 15361 0 5runtime/test/shaders/cs_w32_setreg_sgpr.asm. It checks the f16 rounding ofv_cvt_f16_f32of 1 + 0.75 × 2^-10 (0x3c01 to nearest even, 0x3c00 toward zero) ands_getreg_b32across a (2,2) restore, a (0,4) restore and a constant SGPR. The words are derived in its header. It is registered incheck.py,run_gpu_tests.pyandregen_fixtures.py.SetregFromSgprintest_value_semantics.pychecks the words against a plain-Python reference. It also checks the refusals: a computed SGPR, a save that was modified, a save of a different field, directed rounding, and f32 rounding bits.SetregFromSgprfails withUnsupported: s_setreg_b32 with a register value on MODE.FP_ROUND.2 - offset).SetregFromSgprfails, and the Radeon run fails with15361 15360 3 15361 0 15361 0 5. Then I reverted it.test_scalar_noop_waitcntuseds_setreg_b32 ..., s2as an example of a refused write. In that programs2is the constant 0xffffffff, so the write is now applied. The case now usess4, which is a computed value.tests/test_mode_round.py(s0, a user SGPR) still refuses.python -m unittest discover -s tests/semantic,python tests/semantic/regen_fixtures.py --check(clean),python -I tests/test_shader_checks.py, andpytest tests/test_docs_design_rows.py tests/test_run_gpu_tests.py tests/test_mode_round.py.AI-assisted.
Checklist
docs/design.md, with how it was confirmed.