Recompiler: translate s_quadmask_b32/b64 and s_bitreplicate_b64_b32 #808
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/814"
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?
Imported from ivall/xcl. Originally posted by mastrr9 on 2026-11-24T05:48:49Z.
s_quadmask_b32,s_quadmask_b64, ands_bitreplicate_b64_b32were previously reported unsupported (SALU/SALU64), causing shaders using them to fail translation.What is in it
crates/xcl/src/gpu/recomp/emit.rs:quadmask(uint m)andbitrep16(uint x)alongsidewqm.s_quadmask_b32ands_quadmask_b64(one bit per non-zero nibble, updatingSCCwhen non-zero).s_bitreplicate_b64_b32handled before the wide/narrow split (32-bit source, 64-bit destination, leavingSCCunchanged).crates/xcl/src/gpu/recomp/tests.rs: HLSL + DXC compile check (scalar_quadmask_and_bitreplicate) and GPU execution check (gpu_scalar_quadmask_and_bitreplicate).Tested
617.42/32.0.16.1742), Windows 11 Pro 25H2 (26200.9974), D3D12 debug layer installed (d3d12SDKLayers.dll),rustc 1.100.0 (0ef1bc386 2026-11-09)MSVC, DXC from Windows SDK10.0.26100.0, debug build.38f5173df16e9fea1707e851c7c47a79af79aa10):cargo build --workspace && cargo test --workspace -- --test-threads=4gpu::recomp::tests::scalar_quadmask_and_bitreplicate—okgpu::recomp::tests::gpu_scalar_quadmask_and_bitreplicate—ok(executed on RTX 5080, not skipped)gpu::recomp::tests::gpu_geometry_wave32_prefix_count_over_a_mask(no wave64),gpu::recomp::tests::gpu_wave32_program_in_wave64_hardware(no wave64).Regression run
Smoke run by @Toons29 in comment below: https://github.com/xcl-dev/xcl/pull/814#issuecomment-7151516153
Contributed by a community tester; the PR author did not run it. Both blocks are pasted as posted.
main:
PR:
Tester's setup and limits: AMD Radeon RX 9070 (RDNA4, driver 32.0.32029.2010), Ryzen 7 7800X3D, 32 GB, Windows 11 build 26300, Rust 1.100.0,
cargo build --release -p xcl, 60 s,XCL_NETWORK=0. This is a regression check only: it does not show whether the run reaches the code this PR changes.Tester's AI use: Claude Code (Claude Opus 5.5) built both trees and ran
scripts/smoke.ps1; the tester checked the blocks before posting.Not tested
AI use
Imported from ivall/xcl. Originally posted by SlopTart on 2026-11-24T06:41:27Z.
2|
3|AMD/wave64 + release-build datapoint - the two axes your row lists as not tested.
4|
5|Machine: RX 7900 XT (RADV NAVI31), Mesa 26.2.5, kernel 7.2 (Arch), Wine = Proton Experimental (wine-11.0), patched vkd3d-proton v3.1, Rust 1.100.0 cross
x86_64-pc-windows-gnu, release profile,XCL_NETWORK=0, native wave64. Same rig as my Linux rows in #42 / #718.6|
7|Merged state: head
38f5173onto mainbeaa245, clean merge.8|
9|Full suite,
cargo test --workspace --release --no-fail-fast -- --test-threads=4: 705 passed, 10 failed, 41 ignored (17 suites). The 10 = this rig's 7 stable Wine-lane failures (my #42 row) + the #718 flaky trio firing that run (~2/5 rate, PR-independent). Nothing new fails. Your tests pass on RDNA3:gpu_scalar_quadmask_and_bitreplicateok,scalar_quadmask_and_bitreplicateok.10|
11|Not tested: retail titles (none here), Windows, RDNA4.
12|Counts only, no game data.
13|AI use: Hermes agent (local Qwen-class) ran the suite and drafted this; I checked it before posting.
Imported from ivall/xcl. Originally posted by 4usphs on 2026-11-24T09:41:45Z.
Measured on RDNA2 hardware:
s_quadmask_b32,s_quadmask_b64ands_bitreplicate_b64_b32match this translation, results and SCC.Method. The Radeon iGPU of a Ryzen 7 9800X3D (
gfx1036, RDNA2), Windows 11 Pro 26200, display driver 32.0.21045.29003, AMD OpenCL3652.0 (PAL,LC). Each case is one inline-assembly block in an OpenCL C kernel (the #518 / #772 method):s_cmp_eq_u32sets SCC, the instruction runs on SGPR operands with the destination preset to0xCAFEBABE…, ands_cselect_b32 1, 0reads SCC back. The model is a Python port of this PR'squadmask/bitrep16helpers, which also agree with the ISA's bit-by-bit description on every input.Inputs. 157 64-bit values: 0, all ones, this PR's test values (
0x80F00301,0x00001000,0x80010005),0x1111…,0x8888…,0x8000000000000001, and 150 random ones (half of them sparse). Each value goes throughs_quadmask_b32(low half),s_quadmask_b64, ands_bitreplicate_b64_b32with SCC 1 and 0 before. All of it runs 3 times (wave32, wave64, wave32) with identical output.Result: all 628 cases match:
s_quadmask_b32/_b64: the result, and SCC = (result != 0).s_bitreplicate_b64_b32: the 64-bit result. SCC is left as it was (1 stays 1, 0 stays 0), as the translation does by not writing it.For comparison, an RX 9070 XT (
gfx1201, RDNA4, OpenCL3686.0) gives the same results.Not tested: the console itself (
gfx1036is a desktop RDNA2 APU of the same generation), RDNA1, this PR's D3D12 tests on this GPU, smoke or a title.AI use: Claude Code (Claude Opus 5.5) wrote the OpenCL probes and the port of the helpers, ran them on my PC and wrote this comment. I have not reviewed the code.
Imported from ivall/xcl. Originally posted by Toons29 on 2026-11-25T03:01:36Z.
Regression run of
343bd2f3on the retail title, for this PR's Regression run section. Both blocks are fromscripts/smoke.ps1as printed, not edited:mainon4178e888, this PR on its head commit with no uncommitted changes, same title and time.Against the limits in CONTRIBUTING.md: 100 % of
main's frames, 100 % of its peak commit, no crash, no device removal.AMD Radeon RX 9070 (RDNA4, driver 32.0.32029.2010), Ryzen 7 7800X3D, 32 GB, Windows 11 build 26300, Rust 1.100.0,
cargo build --release -p xcl, 60 s,XCL_NETWORK=0. This is a regression check only: it does not show whether the run reaches the code this PR changes.AI use: Claude Code (Claude Opus 5.5) built both trees and ran
scripts/smoke.ps1; I checked the blocks before posting.Imported from ivall/xcl. Originally posted by JJAutoCompare on 2026-11-25T04:03:01Z.
Intel Arc A770 verification for xcl-dev/xcl PR #814
https://github.com/xcl-dev/xcl/pull/814
Tested
The PR was open at
343bd2f37cbefore and after the run. The assigned checkout was clean and detached at that SHA both times. The live PR description and discussion contained no equivalent Arc A770 report. Read current upstream AGENTS.md and CONTRIBUTING.md.STOR-WINLAB ran Windows 11 Enterprise Evaluation x64 build 26200.9974 on an AMD Ryzen 7 3800X and Intel Arc A770 (driver 32.0.101.9175). Rust 1.100.0 (0ef1bc386, x86_64-pc-windows-msvc), Cargo 1.100.0, unoptimized test profile. Both fixtures logged DXC and DXIL 1.9.2609.5 from %LOCALAPPDATA%/XclTooling/dxc-1.9.2609/bin/x64.
Prebuild outside the Arc mutex
cargo test --locked -p xcl --lib --no-run
Exit 0 in 31.52 s.
Settings
CARGO_TARGET_DIR=L:/XclTooling/pr1778-2e2ee55-20261125-020159/target
CARGO_BUILD_JOBS=2
CARGO_INCREMENTAL=0
CARGO_PROFILE_DEV_DEBUG=0
CARGO_PROFILE_TEST_DEBUG=0
TEMP=TMP=L:/XclTooling/pr814/20261125-045803-885/temp
XCL_ADAPTER=A770
XCL_DXC_DIR=%LOCALAPPDATA%/XclTooling/dxc-1.9.2609/bin/x64
Exact fixture commands
$binary = 'L:\XclTooling\pr1778-2e2ee55-20261125-020159\target\debug\build\xcl\77aca8ccb20e299f\out\xcl-77aca8ccb20e299f.exe'
CPU, outside the Arc mutex
& $binary 'gpu::recomp::tests::scalar_quadmask_and_bitreplicate' --exact --nocapture --test-threads=1
GPU, under the Arc mutex
& 'L:/XclTooling/Invoke-ArcTest.ps1' -Test {
& $binary 'gpu::recomp::tests::gpu_scalar_quadmask_and_bitreplicate' --exact --nocapture --test-threads=1
}
The GPU wrapper ran in its own PowerShell process with -NoProfile -NonInteractive -ExecutionPolicy RemoteSigned -OutputFormat Text -EncodedCommand, and logged mutex acquisition and release. Separate stdout, stderr, exact command, and exit code files are in L:/XclTooling/pr814/20261125-045803-885. The GPU child and wrapper both returned exit 0.
CPU: 1 passed, 0 failed, 0 ignored, 0 explicit SKIPPED, 685 filtered out, exit 0, 0.04 s test time.
GPU: 1 passed, 0 failed, 0 ignored, 0 explicit SKIPPED, 685 filtered out, exit 0, 0.21 s test time.
The CPU fixture checked HLSL emission and compiled it as cs_6_6. The GPU fixture used HLSL/DXC and D3D12, checking B32 quadmask 0xA5, B64 quadmask (0x08A5, 0), and bitreplication (0x33, 0xC0000003). It also checked that a zero B32 quadmask produces zero and clears SCC. The runner selects split wave64 on this Arc A770. An earlier same-host capability probe reported WaveLaneCountMax=32 in L:/XclTooling/pr1577/wave-capability-20261125-033726.log.
Not tested
Native wave64, direct DXIL, other adapters, release builds, the full suite, and retail-title smoke.
AI use
T3 Code / Codex (gpt-6.2-sol) verified the revision, ran the stock fixtures, and wrote the report from the captured output.
Imported from ivall/xcl. Originally posted by DavidM1911 on 2026-11-25T10:48:20Z.
Verification on RTX 3060 Ti (Windows 11), branch merged with current
main:cargo test -p xcl --lib: all passed, 0 failed, ~26 ignored. (Intermittent single-test flake / 0xc0000005 abort under parallel scheduling — tracked in #1978; clean on single-threaded rerun.)Thanks!
Imported from ivall/xcl. Originally posted by github-actions[bot] on 2026-11-29T20:41:15Z.
Nothing has happened on this PR for 3 days, so it is marked
staleand will be closed in 4 days. A push or a comment takes the mark off: rebase it ontomainif it conflicts, and say in one line what it still fixes. If it only waits for a maintainer, a comment saying so is enough.Imported from ivall/xcl. Originally posted by Foniass on 2026-12-01T04:11:25Z.
Triage (#1607) – head
343bd2f#1473 adds the same
quadmask()helper and the sames_quadmask_b32/s_quadmask_b64lowering in recomp/emit.rs. This PR was opened first and also translatess_bitreplicate_b64_b32. Neither is on main yet.The GPU test values (0xA5, 0x08A5, 0x33 / 0xC0000003) are correct for the ISA semantics, and SCC is left alone for bitreplicate as it should be.
Recommendation: keep open.
AI review: Claude Code (Claude Opus 5.5), diffs read only, not built or run; not checked by a human.
Imported from ivall/xcl. Originally posted by BBareth on 2026-12-01T07:30:36Z.
merge-check claim
head:
343bd2f37cImported from ivall/xcl. Originally posted by BBareth on 2026-12-01T07:47:14Z.
merge-check
base:
493dbd3dd0head:
343bd2f37cmerge: clean
build: cargo build --workspace -> ok
tests: cargo test --workspace --no-fail-fast -- --test-threads=4 -> 2901 passed, 1 failed, 51 ignored; 28 SKIPPED lines, as on the base; failing:
gpu::recomp::tests::gpu_scalar_quadmask_and_bitreplicate, a test this PR adds (tests.rs:339,runner::run_codereturnedErr("s_quadmask_b32 s0, s4: SALU")); it does not exist on the base. The base alone, same machine, same commit: 2900 passed, 0 failed, 51 ignored, 28 SKIPPED lines (22 no wave64, 2 no heap windows, 2 no d3d12SDKLayers.dll, 1 no D3D12 debug layer, 1 cannot disable the driver cache). The other new test,scalar_quadmask_and_bitreplicate(HLSL text and a DXC compile), passed.review: one blocking finding; two files (+51/-0), every line read. (1) The PR's own GPU test fails on a GPU:
runner::run_codetranslates through the direct DXIL lowering, which has nos_quadmask_b32(the error above), so the HLSL added inemit.rsis never run by it. CI has no GPU, wheregpu_ready()returns early and the test passes without running. Either the DXIL lowering gets the three instructions too, or the GPU test has to run the HLSL path. (2) Not blocking: the HLSL itself reads right to me (quadmaskfolds one bit per nibble into 8 bits,bitrep16doubles each bit, the expected values in the test match by hand), and SCC is set for the two quadmask forms only. (3) #1473 is open forS_QUADMASK_B32/B64as well; the two overlap.performance: none: three more cases in the translator.
verdict: not yet: the GPU test added by this PR fails on an NVIDIA GPU (
s_quadmask_b32 ...: SALUfrom the direct DXIL path)hardware / tool and model: RTX 5070 Ti 16 GB, driver 621.24 (32.0.16.2124); i7-12700K; Windows 11 26200. Claude Code, Claude Fable 5.2 read the diff, ran the build and the suite and wrote this check.
Imported from ivall/xcl. Originally posted by sandivd on 2026-12-02T00:25:06Z.
merge-check claim
head:
343bd2f37cImported from ivall/xcl. Originally posted by Pipodi on 2026-12-02T10:27:57Z.
merge-check
base:
1c8b551475head:
343bd2f37cmerge: clean
build: cargo build --workspace -> ok (and cargo build --release -p xcl -> ok)
tests: cargo test --workspace --no-fail-fast -- --test-threads=4 -> 2910 passed, 1 failed, 51 ignored; 25 SKIPPED lines (22 no wave64, 2 no heap windows, 1 cannot disable the driver cache); failing:
gpu::recomp::tests::gpu_scalar_quadmask_and_bitreplicate, added by this PR, so it does not exist on the base: tests.rs:339runner::run_codereturnsErr("s_quadmask_b32 s0, s4: SALU"). This reproduces the failure in the check above on a second NVIDIA GPU. The same two tests rerun withXCL_DIRECT_DXIL=0(HLSL path): 2 passed, 0 failed, the GPU test ran on the GPU (DXC compile, no skip).review: two files (+51/-0), every line read. (1) Blocking: with
XCL_DIRECT_DXILunset, the default,runner::run_codeand compute kernels go through the direct DXIL lowering (gpu/dxil/lower.rs), which has no case fors_quadmask_b32/_b64/s_bitreplicate_b64_b32(it falls toerr(d, "SALU")). So the PR's own GPU test fails on any GPU that runs it, and the HLSL added inemit.rsonly takes effect where a shader falls back to the HLSL path. The DXIL lowering needs the three instructions too, or the test has to target the HLSL path explicitly. (2) The HLSL is correct against the RDNA2 ISA:quadmasksets result bit i when nibble i of the source has any bit set (8 bits from 32, 16 from 64, upper bits 0),bitrep16puts every source bit into two adjacent result bits; SCC = result != 0 for both quadmask forms, and bitreplicate leaves SCC alone, matchingrdna2_spec.rs(implicit SCC output on S_QUADMASK_B32/B64, none on S_BITREPLICATE_B64_B32). The expected values in the test (0xA5; 0x08A5, 0; 0x33, 0xC0000003; 0 with SCC 0) check out by hand. (3) Test placement is fine: the GPU test returns throughgpu_ready()(which callsskip_test), no#[ignore], no weakened asserts, no change outside the scope. (4) Overlap: #1473 adds the same quadmask lowering.performance: none by default: three more match arms in the HLSL translator; nothing runs unless a shader uses these instructions. Smoke pair not run, because the suite fails because of the PR.
verdict: not yet: the GPU test added by this PR fails on NVIDIA through the default direct DXIL path (
s_quadmask_b32 ...: SALU); the direct DXIL lowering needs the three instructions as wellhardware / tool and model: NVIDIA GeForce RTX 4090, driver 621.40 (32.0.16.2140); i9-13900K; Windows 11 build 26300; rustc 1.100.0 (0ef1bc386 2026-11-09), debug test profile. Claude Code, Claude Opus 5.5 read the diff, ran the build and the suite and wrote this check.
View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.