Skip to content

Recompiler: honour 32-bit SSRC0 in salu64 (s_bfm_b64) - #1159

Open
b3IKK wants to merge 1 commit into
xcl-dev:mainfrom
b3IKK:recomp/salu-bfm-b64-32bit-src0
Open

b3IKK wants to merge 1 commit into
xcl-dev:mainfrom
b3IKK:recomp/salu-bfm-b64-32bit-src0

Conversation

@b3IKK

@b3IKK b3IKK commented Nov 24, 2026 •

Copy link
Copy Markdown
Contributor

salu64 checked o.size == 32 for ins[1] (shift amounts and s_bfe controls) but unconditionally called read64 on ins[0]. In s_bfm_b64, SSRC0 is a 32-bit operand (rdna2_spec.rs), so passing m0 (124), exec_hi (127), or s105 failed translation with Err("op") because code64 rejects them as 64-bit register pairs.

This uses the same o.size == 32 check for both salu64 source operands.

What is in it

  • crates/xcl/src/gpu/recomp/emit.rs: read 32-bit ins[0] operands with read() instead of read64() in salu64.
  • crates/xcl/src/gpu/recomp/tests.rs: add GPU test gpu_s_bfm_b64_accepts_32bit_ssrc0 testing S_BFM_B64 with m0 and s105 across wave32 and split wave64 (verified failing translation before the fix).

Tested

  • hardware (GPU + driver, CPU), Windows build, Rust version, debug / release: NVIDIA GeForce RTX 5080 (driver 32.0.16.1088), AMD Ryzen 9 9950X3D, Windows 11 10.0.26300, Rust 1.100.0 (stable-x86_64-pc-windows-msvc), DXC 1.9.2609.5, debug (scripts/test.ps1) and release (scripts/smoke.ps1)
  • .\scripts\test.ps1 (cargo build --workspace + cargo test --workspace -- --test-threads=4): 742 passed, 0 failed, 41 ignored (SKIPPED GPU tests: 2 no wave64 — gpu::recomp::tests::gpu_geometry_wave32_prefix_count_over_a_mask, gpu::recomp::tests::gpu_wave32_program_in_wave64_hardware)
  • cargo test -p xcl --lib gpu_s_bfm_b64_accepts_32bit_ssrc0: 1 passed, 0 failed across wave32 and split wave64 (failed with s_bfm_b64: op before the fix)

Regression run

main:

xcl-smoke v1
commit: 47efa2ecea0a12934719ae69b81930cf02a4b1c3
gpu: NVIDIA GeForce RTX 5080
title: 9cc6a39e
seconds: 60
exit: 0x0
frames shown: 1226 (PresentX 1226)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 15341 MB

PR:

xcl-smoke v1
commit: 04ca7f808558acf8f595580bf0d941ac740479e1
gpu: NVIDIA GeForce RTX 5080
title: 9cc6a39e
seconds: 60
exit: 0x0
frames shown: 1648 (PresentX 1648)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 14462 MB

Not tested

  • AMD GPUs and native wave64 hardware
  • other titles (Minecraft Preview, Unicorn Overlord, Fortnite, XDefiant) and Linux / Wine

AI use

  • OpenCode, Gemini 4 Neon: audited emit.rs, wrote the fix and GPU test, ran the test suite and scripts/smoke.ps1 regression runs, and drafted this PR description.

salu64 checked o.size == 32 for ins[1] (shift amounts / bfe controls)
but unconditionally called read64 on ins[0]. In s_bfm_b64, SSRC0 is a
32-bit operand (rdna2_spec.rs), so passing m0 (124), exec_hi (127), or
s105 failed translation with Err(op) because code64 rejects them as
64-bit register pairs.

Use the same o.size == 32 check for both salu64 source operands, with a
GPU test for s_bfm_b64 using m0 and s105 across wave32 and split wave64.

Assisted-by: OpenCode (Gemini 4 Neon)
@DavidM1911

Copy link
Copy Markdown
Contributor

Independent verification on current main 384f7f7 (branch already contains it — clean).

Machine: Windows 11, Ryzen 9 7900X + RTX 3060 Ti; Rust stable MSVC, debug; DXC 1.8.2502.11.

  • cargo test -p xcl --lib bfm: 1 passed, 0 failed — gpu_s_bfm_b64_accepts_32bit_ssrc0 covers the 32-bit SSRC0 operand on real hardware.

AI use: test runs by Devin (Cognition, SWE-2); no code changes.

@bjarngard

Copy link
Copy Markdown

Test report for head 04ca7f8 (AMD, native wave64)

Tested

  • AMD Radeon(TM) Graphics (Ryzen 9 9950X iGPU, RDNA2, native wave64), driver 32.0.21043.5001; Windows 11 build 26300; Rust 1.99.1 MSVC; DXC 1.9.2602.17; debug
  • XCL_ADAPTER=radeon cargo test --workspace --no-fail-fast -- --test-threads=4: 742 passed, 0 failed, 41 ignored, no SKIPPED
  • With XCL_REQUIRE_GPU=wave64: gpu_s_bfm_b64_accepts_32bit_ssrc0 passed

Not tested: retail titles, RDNA3/RDNA4.

AI use: the tests were run and this report was written by an AI agent, Claude Code (Claude Opus 5.5), on the hardware above. The numbers are copied from the actual test output.

@JoaoPauluu

Copy link
Copy Markdown

A run on Linux with vkd3d-proton, where the shaders go through dxil-spirv to Vulkan instead of a Windows driver's DXIL compiler.

Tested

  • RTX 3060 12 GB (NVIDIA 620.70.06, 32-lane waves), i5-10400F, 16 GB, CachyOS (kernel 7.3.3), Proton Experimental 11.0-20261112 with the patched vkd3d-proton 3.1 from Linux: docs/linux.md, scripts/linux and Wine start-up checks for vkd3d-proton and DXVK (#154, #241) #257 (DXIL → SPIR-V through dxil-spirv), DXC 1.9.2609.5. Release, cross-built for x86_64-pc-windows-gnu. 04ca7f8 as it is (based on 47efa2e), no uncommitted changes. The lib test binary runs under Wine, one test per process (--exact).
  • gpu::recomp::tests::gpu_s_bfm_b64_accepts_32bit_ssrc0: ok, no SKIPPED.

Not tested

  • whether the new test fails without the fix on this stack; the rest of the suite on this head; native Windows; AMD / native wave64.

AI use

  • Claude Code (Claude Opus 5.5) built the head, ran the tests and wrote this report. The account owner asked for test reports to be posted and has not reviewed this one.

@milesah3ad

Copy link
Copy Markdown

The direct DXIL backend counterpart of this fix, from @regiumlepidi's parity sweep on #1269: gpu_s_bfm_b64_accepts_32bit_ssrc0 pass with XCL_DIRECT_DXIL=1 with the patch below. Without it they fail on the direct path.

salu64 in gpu/dxil/lower.rs read the first operand as a 64-bit pair whatever its size, so s_bfm_b64 with a 32-bit SSRC0 that is no valid pair (m0, s105) was refused at translation (op), not miscomputed. The patch reads a 32-bit operand as one dword with a zero high half, for the first operand as for the second, the same change your PR makes in emit.rs.

How to take it: this PR predates the direct backend on main, so rebase it onto main first (your commit rebases cleanly onto 7994cd1), then git am the patch below. Feel free to fold it into your PR with a Co-Authored-By: milesah3ad <360542007+milesah3ad@users.noreply.github.com> line. I didn't open a separate PR, so this doesn't add another review.

patch (1 commit, for git am)
From 17b4d43bf4f566ee57d1134f925c0dc64208321c Mon Sep 17 00:00:00 2001
From: milesah3ad <360542007+milesah3ad@users.noreply.github.com>
Date: Tue, 24 Nov 2026 18:53:33 -0600
Subject: [PATCH] Direct DXIL: salu64 reads a 32-bit first operand as one dword
 (s_bfm_b64)

salu64 read its first operand as a 64-bit pair whatever its size, so
s_bfm_b64 with a 32-bit SSRC0 that is no valid pair (m0, s105) failed
to translate ("op"). A 32-bit operand is now read as one dword with a
zero high half, for the first operand as for the second, as #1159 does
on the HLSL path.

gpu_s_bfm_b64_accepts_32bit_ssrc0 now passes with XCL_DIRECT_DXIL=1.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01YPhfiWsdJcDBLYSS8edLyS
---
 crates/xcl/src/gpu/dxil/lower.rs | 23 +++++++++++++----------
 1 file changed, 13 insertions(+), 10 deletions(-)

diff --git a/crates/xcl/src/gpu/dxil/lower.rs b/crates/xcl/src/gpu/dxil/lower.rs
index 27c4cdb..c3903ff 100644
--- a/crates/xcl/src/gpu/dxil/lower.rs
+++ b/crates/xcl/src/gpu/dxil/lower.rs
@@ -1560,20 +1560,23 @@ impl Lw {
 
     fn salu64(&mut self, d: &Decoded, name: &str, dst: &Dst, ins: &[&Operand]) -> LResult<()> {
         let e = || format!("{}: op", rdna2::format(d));
+        // 32-bit operands (controls, shift amounts, s_bfm_b64's width and offset) are read as one
+        // dword: m0 or s105 is no valid 64-bit pair (#1159)
+        let read_op = |this: &mut Self, o: &Operand| -> LResult<(Value, Value)> {
+            if o.size == 32 {
+                let v = this.read(d, o, false).ok_or_else(e)?;
+                let z = this.c(0);
+                Ok((v, z))
+            } else {
+                this.read64(d, o, false).ok_or_else(e)
+            }
+        };
         let a = match ins.first() {
-            Some(o) => Some(self.read64(d, o, false).ok_or_else(e)?),
+            Some(o) => Some(read_op(self, o)?),
             None => None,
         };
         let b = match ins.get(1) {
-            Some(o) => {
-                if o.size == 32 {
-                    let v = self.read(d, o, false).ok_or_else(e)?;
-                    let z = self.c(0);
-                    Some((v, z))
-                } else {
-                    Some(self.read64(d, o, false).ok_or_else(e)?)
-                }
-            }
+            Some(o) => Some(read_op(self, o)?),
             None => None,
         };
         let z = self.c(0);
-- 
2.48.1.windows.1

Tested

Not tested: wave64 hardware (the wave64 cases SKIP here), AMD, any title, the full workspace suite (lib only).

AI use: Claude Code (Claude Opus 5.5) wrote the fix and ran the tests on the machine above. I checked the results.

@luckyteagirl

Copy link
Copy Markdown

Independent RX 6800M GPU check on exact PR head 04ca7f808558acf8f595580bf0d941ac740479e1.

Tested

  • Windows 11 build 26200, Ryzen 9 5980HX, Radeon RX 6800M driver 30.0.13002.13003, Rust 1.99.0 MSVC, DXC/DXIL 1.9.2609.5.
  • XCL_ADAPTER=6800M XCL_REQUIRE_GPU=wave64 XCL_DIRECT_DXIL=0 cargo test --locked -p xcl --lib -j 2 gpu_s_bfm_b64_accepts_32bit_ssrc0 -- --test-threads=1 --show-output: 1 passed, 0 failed, 0 ignored in 0.30 s. There was no SKIPPED line. The regression tests the HLSL translator's 32-bit SSRC0 handling for S_BFM_B64 using m0 and s105 on wave32 and split wave64.

I did not run the full workspace suite, a pre-fix negative control on this machine, the direct DXIL counterpart proposed in the PR discussion, or a retail title smoke comparison. This is a focused GPU result on an older PR head, not current-main integration coverage. No game data was used or uploaded.

AI-assisted testing and report drafting with OpenAI Codex (GPT-6); I checked the exact revision and test log before posting.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants