Repository navigation
fix(shader): guard runtime MODE changes - #1854
Conversation
0805875 to
18ed85f
Compare
klosixgaming-arch
left a comment
There was a problem hiding this comment.
This is the bar for shader-semantics PRs in this repo: RDNA2 ISA §5.8/§6.4 Table 24 plus a LLVM 20.1.8 cross-reference with exact source links, a 5,120-comparison regression (all 256 FLOAT_MODE bytes, wave32/wave64), independent LLVM-assembler encoding verification, and the remaining gaps explicitly recorded in TechnicalDebt rather than silently stubbed. Runtime MODE transitions correctly throw with instruction + PC, and the ARCHITECTURE.md addition is clear about what is and isn't modeled. No console/GPU measurements are claimed where they don't exist — exactly right.
Written with AI assistance.
|
Measured on RDNA2 (gfx1036, Radeon 610M) with
Writes, starting from 0xc5: |
18ed85f to
3df8f69
Compare
Read MODE rounding fields from the declared initial mode. Accept only constant writes that preserve it; diagnose unsupported runtime changes. Document the supported contract and add decoder-to-recompiler regressions. Refs boykopovar#1668, boykopovar#981
Co-Authored-By: Claude <noreply@anthropic.com>
|
Checked on the HW oracle (gfx1035, wave32) across 32 initial modes (all 16 rounding combinations × two denorm/IEEE/DX10 settings): the ten MODE[3:0] subfield reads, Added on your branch:
Merging once CI is green. |
3df8f69 to
4120b2b
Compare
…e-registers fix(shader): guard runtime MODE changes
What
Part of #1668's shader-mode workstream and #981. MODE rounding reads currently return zero even when the shader declares a nonzero initial mode, and MODE writes can silently leave that declared state inconsistent with the shader's instructions.
For example, with
FLOAT_MODE=0xc5, reading MODE bits 0..3 now returns5. An immediate write of5preserves the state and is accepted; writing0reports the instruction and program counter as an unsupported runtime transition.GuestContext::floatMode.s_setreg_imm32_b32only when its selected rounding bits remain unchanged, masking source bits above the selected width. Apply the same rule to the low four bits ofs_round_mode; its upper immediate bits are ignored.Semantics follow AMD's RDNA2 ISA sections 5.8 and 6.4, Table 24, cross-checked against LLVM 20.1.8's
AMDGPUBaseInfo.h,SIModeRegister.cppand GFX10 assembler tests. Exact source links are in Architecture. No console or GPU execution measurements are claimed. Missing metadata retains the existing nearest-even assumption; other MODE fields remain unsupported, and non-MODEs_setreg_b32writes retain their existing no-op behavior, recorded in TechnicalDebt.This is partial progress on #1668; it does not complete the category issue or add arithmetic support for every initial mode. Initial-mode propagation (#1816), output-modifier mode handling (#1851) and f32 denormal flushing (#1850) are already on main. No open PR prerequisite.
Coordination with #1811: both PRs initially edited the same CMake test-list line. The MODE test is now registered separately, with its normal-build inclusion, Windows runtime path and timeout preserved. Combining the two changes merges cleanly in either order; neither PR depends on the other. The MODE documentation also sits within the existing Graphics section so it can merge independently of #1802's appended kernel documentation.
Tested
Release builds on Windows 11 Pro (build 26300, WinLibs GCC 15.2.0 r7) and Ubuntu 24.04 under WSL2 (GCC 13.3.0). Four focused CTest cases passed on each host, with no skips:
agc_shader_mode_register,agc_shader_control_flow,agc_shader_disk_cache, andagc_validate_program.The new regression uses production decoding, control-flow construction and translation, with requirements active in Release:
s_round_modecombinations, including ignored upper bits and preservation of untouched rounding bits.Recompile.LLVM 18.1.3's assembler independently verified 23 instruction encodings for both gfx1013 and gfx1030. Replacing the production fix with upstream code makes the final regression fail; restoring it returns all four Linux cases to passing.
Local builds used an untracked CMake parent importing the production libc/recompiler source lists and the four production test target definitions, with SPIRV-Tools disabled. After rebasing onto main
ce64d8eb, all four cases passed again on each host; the parent also evaluates the production MODE test registration and checks its inclusion in normal builds. This covers compiler regressions, not the full application build, GPU execution, a title or console behavior. Full repository CI passed on Linux and Windows at the earlier head4344bbfd. After the rebase onto main8b393b6e9a8ade9188d4f74a0293e0efd9828597, the four cases pass again on Ubuntu 24.04/WSL2 (GCC 13.3.0, Release, 4/4, normal repository build); the rebased head3df8f69e7bdebaa8903f834d604fcc9d75f2f831needs a fresh CI run.Checklist
main; no other open PR implements the same functions.mdfiles or images added to the repository