shader: lower s_setreg_b32 and s_getreg_b32 for the MODE rounding field in pixel_aot #1777
No reviewers
Labels
No labels
accessibility
awaiting author
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
priority: P0
question
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/R0Y00--Xbox2Windows!1777
Loading…
Reference in a new issue
No description provided.
Delete branch "gh-pr/1777/head"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
@JB2WIN on GitHub · 2026-11-24 18:25 UTC · original
JB2WIN:shader/sopk-setreg→main· +335 −18 · 5 files · 1 commits · merged 2026-11-24 18:38 UTCChange
tools/pixel_aot.pynow lowers two of the five SOPK forms that the gfx1013 coverage still lists as uncovered:s_setreg_b32ands_getreg_b32. Each is accepted only where its effect is known.s_setreg_b32 hwreg(...), sNtakes the same targets ass_setreg_imm32_b32:SIISelLowering.cpp(4354–4417) buildsSetMask = WidthMask << Offset, so the hardware takes the lowsizebits. Even so, a value with higher bits set (for example0x103or0xffffffff) is refused instead of truncated. Values 1 and 2 are refused as before.vcc_lo/m0/nullsources, immediates and pairs.s_getreg_b32 sD, hwreg(HW_REG_MODE, 2, 2)is accepted only after the program has written that field itself, with either setreg form. The MODE value at shader entry is only assumed, so a read before any write is refused (MODE rounding is read before the program writes it).SIISelLowering.cpp(3553–3572).Unsupported hardware register read).Masked regions: neither form runs inside one (they are not in
REGION_SALU), so the rounding state is tracked in straight-line code. A control shows that a write before a skip, followed by a read after the join, works.Spelling and encoding (LLVM 15.0.7, gfx1013):
s_setreg_b32 hwreg(HW_REG_MODE, 2, 2), s0is810880b9ands_getreg_b32 s0, hwreg(HW_REG_MODE, 2, 2)is810800b9. A whole FLAT_SCR register prints ashwreg(HW_REG_FLAT_SCR_LO). The field encoding followsSIDefines.h; the operand order followsSOPInstructions.td(878–899).Not covered here:
s_call_b64ands_subvector_loop_begin/endwould need call and subvector-loop models, which pixel_aot does not have.form_coverage_check.pynow asserts that they stay refused.Changed controls: these controls already expected a refusal. They still refuse the same input; only the expected message is more specific now:
form_coverage_check.pymovess_getreg_b32out of the refused-neighbour list and counts both forms as covered.Test
New mode
draw-sopk-hwreg, registered aspixel_aot_sopk_hwreg_hardwareand_warp(60 s timeout, skip code 77, its ownFORM_COVERAGE_RECORD). The program is part of the LLVM 15 round trip, and a binary check pins the encodings above.pixel_mismatch.0x103, other registers and fields, getreg before setreg, malformed operands.main: withmain'stools/pixel_aot.pythe mode fails withUnsupported instruction 21: s_setreg_b32 hwreg(HW_REG_MODE, 2, 2), s48.The semantics come from LLVM 15. They are not checked against the ISA document and not measured on a console.
tools/scan_unsupported_shaders.pyis unchanged. A static scan cannot know the SGPR value, so it keeps reporting the register forms as unsupported.On commit
a1011264(rebased onf58d2425), with an NVIDIA GeForce RTX 3080 (driver 32.0.16.2124), WARP 10.0.26100.9818, Windows 11 build 26200 and the debug layer unavailable:The pure checks and the LLVM 15.0.7 binary round trip pass.
AI-assisted (Claude Code).
🤖 Generated with Claude Code
@tedin7 on GitHub · 2026-11-24 18:38 UTC · original · reviewed
Dual-platform peer review at
head_sha:a101126422224c66d38084037d5a20f475bbb515Findings
No blocking issues (0 P1, 0 P2).
tools/pixel_aot.py: lowerss_setreg_b32forhwreg(HW_REG_MODE, 2, 2)(requiring a bound, non-pending, non-conditional SGPR holding exact integer0or3, refusing1,2, upper bits, non-integer/unknown SGPRs, and special registers) and wholeHW_REG_FLAT_SCR_LO/HI(any bound SGPR), and lowerss_getreg_b32forhwreg(HW_REG_MODE, 2, 2)only after a prior write in the program (returning right-aligned0or3intoscalar[dst]andscalar_mask[dst], withTrackedScalar.__setitem__clearingconditional). Both are excluded from masked regions, uniform skip blocks, and post-export code, and added to_check_two_exits.tests/pixel_aot_check.py,tests/form_coverage_check.py,CMakeLists.txt,docs/experiments.md: cover static lowering/refusal controls, LLVM assemble/disassemble encoding and round-trip checks, WARP draw with 5 negative-reference mismatch controls, +2gfx1013form coverage accounting, test-only CMake registration (pixel_aot_sopk_hwreg_${adapter}), and clean-room neutral docs.Verification
git diff --check origin/main...HEAD: clean.python3 -B tests/docs_links_check.py: passed (17 Markdown files, 366 links).python3 -B tests/bidi_controls_check.py: passed (1302 tracked files).python3 -B tests/pixel_aot_check.py: passed.check_sopk_hwreg_binary+SOPK_HWREG_BODYassemble/disassemble round-trip withllvm-mc-19,llvm-objcopy-19,/usr/lib/llvm-19/lib/libLLVM-19.so: passed (40 instructions).python3 -B tests/form_coverage_check.py: passed.python3 -B tests/rdna2_tools_check.py: passed (148 tests, 18 skipped).git checkout -- .):s_getreg_b32assignment frommode_roundingtomode_rounding << 2->tests/pixel_aot_check.pyfailed incheck_sopk_hwreg_controls(exit 1).if mode_rounding is None:guard withif False:->tests/pixel_aot_check.pyfailed incheck_mode_register_controls(exit 1).tests/form_coverage_check.pyok (17.18s).--preset dev):ctest --preset dev -R '^(pixel_aot_sopk_hwreg_warp|pixel_aot_warp|rdna2_tools_check)$' --parallel 6 --no-tests=error --output-on-failure: 3/3 passed (13.89s:pixel_aot_sopk_hwreg_warp4.64s,rdna2_tools_check9.82s,pixel_aot_warp13.82s)./O2(--preset release):ctest --preset release -R '^(pixel_aot_sopk_hwreg_warp|pixel_aot_warp|rdna2_tools_check)$' --parallel 6 --no-tests=error --output-on-failure: 3/3 passed (14.09s:pixel_aot_sopk_hwreg_warp3.86s,rdna2_tools_check10.88s,pixel_aot_warp14.00s).AI-assisted; commands listed were executed locally.