Recompiler: translate s_getreg_b32 for MODE's round modes #938
No reviewers
Labels
No labels
accessibility
bug
documentation
duplicate
enhancement
goal:world-load
good first issue
help wanted
invalid
keep-open
off-goal
question
stale
test-only
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/xcl-dev--xcl!938
Loading…
Reference in a new issue
No description provided.
Delete branch "gh-pr/938/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?
@maximecmb on GitHub · 2026-11-24 08:52 UTC · original
recomp-s-getreg→main· +98 −1 · 2 files · 1 commits · closed without mergings_getreg_b32was untranslated (theisa_coveragecensus lists it as missing; no open PR or issue covers it). It reads a field of a hardware register into an SGPR. The common use in compiled shaders is reading the current round mode (hwreg(HW_REG_MODE, 0, 4), what LLVM'sllvm.get.roundingbecomes), often to restore it later.XCL already models MODE's round modes:
[1:0](f32) is always 0, since any other value is refused, and[3:2](f16 / f64) isxcl_fp16_rmwhere a program changes it. So a read of a field insideMODE[3:0]is exact. The rest is refused, with a reason that names the register (which then shows inreport.json), not answered with 0: the other MODE bits (denormals, clamps, IEEE) come from the console's program set-up, and registers such asHW_ID1/HW_ID2(wave, SIMD, CU ids),STATUSorSHADER_CYCLESfrom its hardware. A made-up value would be wrong for some programs, e.g. two waves with the same wave id indexing per-wave slots.What is in it
crates/xcl/src/gpu/recomp/emit.rs:getregfors_getreg_b32(MODE fields within[3:0]; refusals for the rest, named).configure_round_modesalso followsMODE[3:2]at run time when the program reads it back, not only when an f16 op rounds by it: before, a change of it in a program without f16 ops was dropped, and a read would have given 0.crates/xcl/src/gpu/recomp/tests.rs:s_getreg_b32_reads_the_round_modes_and_refuses_the_rest(the HLSL for a constant and a followed MODE, and the refusals with their reasons) andgpu_s_getreg_b32_round_modes(MODE read before and afters_round_modeands_setreg_imm32_b32, in a program with no f16 op:0,0xC, single bits, a field straddling[1:0]/[3:2]). Without theconfigure_round_modeschange the GPU test fails (every read gives 0).Tested
stable-x86_64-pc-windows-msvc, debug, DXC 1.9.2602.17cargo build --workspace && cargo test --workspace --no-fail-fast -- --test-threads=4: 715 passed, 3 failed, 41 ignored. The 3 aremain's memory-pressure failures of #913 (placed_title_textures_share_vram_and_preserve_pixels, thentransitions_apply_when_their_list_is_submittedandd32s8_targets_take_their_own_size_of_video_memoryon its poisoned lock), which #923 addressescargo test -p xcl --lib -- --test-threads=4 --skip a_freed_block_is_decommitted_before_its_address_is_reused: 676 passed, 0 failed, 21 ignoredgpu_geometry_wave32_prefix_count_over_a_mask,gpu_wave32_program_in_wave64_hardware; noXCL_SAMPLE_*setisa_coveragestill listss_getreg_b32: it encodes each instruction with zero operands, which for this one is hardware register 0, refused on purposeRegression run
main:This PR:
Not tested
s_setreg_b32 hwreg(MODE, 0, 4), sNfrom an SGPR is still refused (dynamic f32 round mode), as before this changeAI use
🤖 Generated with Claude Code
@dcastell1 on GitHub · 2026-11-24 09:11 UTC · original
Verified on Windows 11 10.0.26300, NVIDIA GeForce RTX 5090 (driver 621.24), Rust 1.100.0 MSVC 14.44.35207, debug build, on clean
main@beaa245(713 passed, 0 failed, 41 ignored on this box):Two more passing tests than main:
s_getreg_b32for MODE's round modes translates and its fixtures are green here.Tree restored afterwards (md5 and a full diff against a clean checkout), hardware adapter, no Wine, no game data. AI-assisted (opencode): applied the patch to a built tree, ran the suite, reverted it.
@eizispark on GitHub · 2026-11-24 09:17 UTC · original
Hardware check of
50939319dcddbca8bf58e2d7b60a5e4211ff6a36(verified clean merge withmain077ce40): pass.Tested
rustc 1.100.0 (0ef1bc386 2026-11-09), release + test profilecargo test --workspace -- --test-threads=4:715 passed, 3 failed, 41 ignored(GPU tests skipped on this adapter:none; the 3 failures are the pre-existing concurrent VRAM test race inplaced_title_textures_share_vram_and_preserve_pixelsplus 2 downstreamPoisonErrors —cargo test -p xcl --lib hle::d3d12x -- --test-threads=1:115 passed, 0 failed, 1 ignored)gpu::recomp::tests::gpu_s_getreg_b32_round_modes(native wave64),gpu::recomp::tests::s_getreg_b32_reads_the_round_modes_and_refuses_the_rest,gpu::recomp::tests::gpu_wave32_program_in_wave64_hardware, andgpu::recomp::tests::gpu_geometry_wave32_prefix_count_over_a_maskallokRegression run
main(beaa245):PR (
5093931):Not tested
AI use
scripts/smoke.ps1harness on this machine and formatted this report.@DarkPanda69 on GitHub · 2026-11-24 09:43 UTC · original · edited 2026-11-24 10:26 UTC
Test report for head
50939319d.Setup
main077ce40(all applied cleanly), debug build, Rust 1.100.0, Windows 11 Pro 26200, Ryzen 7 5800X, DXC 1.9.2602.17.cargo test -p xcl --lib -- gpu::recomp --test-threads=4, once withXCL_ADAPTER=radeonand once withXCL_ADAPTER=3060.Tested: pass on both GPUs, including an AMD GPU and the native wave64 form you listed as not tested.
gpu_s_getreg_b32_round_modesok.gpu_s_getreg_b32_round_modesok.Not tested: the save / restore pattern end to end; a title that uses the instruction.
AI use: Claude Code (Claude Opus 5.5) ran the tests on this machine and wrote this report.
Note: these runs check that the translated HLSL matches the test's reference model, in 64-lane and in 32-lane waves. They cannot show that the model matches the hardware (on #925 both had the same mistake, and the test still passed).
@SlopTart on GitHub · 2026-11-24 10:37 UTC · original
Linux / AMD RDNA3 datapoint.
Merged state: head
5093931onto main9aec53d, clean merge.Full suite,
cargo test --workspace --release --no-fail-fast --target x86_64-pc-windows-gnu -- --test-threads=4: 718 passed, 8 failed, 41 ignored; failures are the known Wine-lane set from my #42 rows plus this rig's title-textures flake family (see #718). s_getreg_b32 MODE round-modes green; see flake footnote.Footnote:
gpu::recomp::tests::gpu_geometry_wave32_prefix_count_over_a_maskfailed once in-lane but passes 2/2 in isolation on the same merge, and current main passes the same isolated runs - ordering flake on this rig, not attributed to this PR.Not tested: retail titles (none here), Windows, RDNA4.
Counts only, no game data.
Machine: RX 7900 XT (RADV NAVI31), Mesa 26.2.5, kernel 7.2 (Arch), Proton Experimental (wine-11.0), patched vkd3d-proton v3.1, Rust cross
x86_64-pc-windows-gnu,XCL_NETWORK=0, release profile,--test-threads=4. My Linux rows: #42 / #718.AI use: Hermes agent (local Qwen-class) ran the suite and drafted this; I checked it before posting.
@DavidM1911 on GitHub · 2026-11-24 12:37 UTC · original
Independent verification, merged onto current
main384f7f7locally (clean merge).Machine: Windows 11, Ryzen 9 7900X + RTX 3060 Ti; Rust stable MSVC, debug; DXC 1.8.2502.11.
cargo test -p xcl --lib s_getreg: 2 passed, 0 failed —s_getreg_b32_reads_the_round_modes_and_refuses_the_rest(emission) andgpu_s_getreg_b32_round_modes(GPU) both pass.AI use: test runs by Devin (Cognition, SWE-2); no code changes.
@DavidM1911 on GitHub · 2026-11-26 03:11 UTC · original
Re-verification on RTX 3060 Ti (Windows 11), new head merged with current
main:cargo test -p xcl --lib: all passed, 0 failed, 27 ignored. The earlier merge conflict is resolved.Thanks!
— Devin
Pull request closed