Recompiler: translate v_qsad_pk_u16_u8 and v_mqsad_{pk_u16,u32}_u8 #909
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!909
Loading…
Reference in a new issue
No description provided.
Delete branch "gh-pr/909/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?
@bigiello on GitHub · 2026-11-24 08:03 UTC · original
feat/recomp-qsad→main· +226 −1 · 2 files · 1 commits · closed without mergingDraft pending
scripts/smoke.ps1regression blocks on a retail title (no local game files available; see Not tested).Adds RDNA2 VOP3 translation for
v_qsad_pk_u16_u8,v_mqsad_pk_u16_u8, andv_mqsad_u32_u8. Previously the_pk_u16_u8instructions routed intovalu16due to_u16in their names, and 64/128-bit VALU operands were rejected.What is in it
crates/xcl/src/gpu/recomp/emit.rs:pk_sad_u16helper inPRELUDEreusingsad_u8,msad_u8, andsat_u32.Em::valu_qsadhandling 64-bitSRC0, 32-bitSRC1, and 64-bit (_pk_u16_u8) / 128-bit VGPR (v_mqsad_u32_u8) accumulators via temporaries, enforcing VGPR bounds and clamping per element whenCLAMPis set.crates/xcl/src/gpu/recomp/tests.rs:qsad_and_mqsad_operand_forms_and_validation(unit translation + DXC compile + bounds/non-VGPRSRC2rejection).gpu_qsad_and_mqsad(D3D12/DXIL hardware test across wave32 and wave64 covering sliding windows, zero-byte masking,CLAMPwrap vs saturation, SGPR/VCC/inline sources, overlapped registers, andEXECmasking).isa_coverage: pass non-zeroSRC2VGPR operand forV_MQSAD_U32_U8(OPR_SRC_VGPR).Tested
10.0.26100.0\x64)..\scripts\test.ps1(at commit8747cb1): exit 0 — 717 passed, 0 failed, 41 ignored across the workspace (xcl --lib: 676 passed, 0 failed, 21 ignored; 2 GPU tests skipped due tono wave64:gpu_geometry_wave32_prefix_count_over_a_mask,gpu_wave32_program_in_wave64_hardware; integration binaries:console_dlls_e2e13 passed,console_shaders3 passed / 4 ignored,disasm_e2e1 passed,e2e3 passed,gpu_compute_e2e2 passed,gpu_pso_e2e7 passed,heap_probe0 passed / 4 ignored,pls_quota1 passed,predication_e2e1 passed,rpf_e2e2 passed,sparse_reinit1 passed,texture_states1 passed,xg_oracle6 passed / 12 ignored).cargo test -p xcl --lib -- qsad --nocapture: 2 passed, 0 failed.cargo test -p xcl --lib -- isa_coverage --ignored --nocapture: 1 passed (RDNA2 instructions (spec + console): 1157, translated: 1045 (90.3%),VOP3 290 / 298).cargo clippy --workspace --all-targets: 0 errors, 0 new warnings in touched lines.rustfmt --check crates\xcl\src\gpu\recomp\emit.rs crates\xcl\src\gpu\recomp\tests.rs: 0 diffs in changed lines (cargo fmt --checkoverall exits 1 due to pre-existing formatting in untouched files).Not tested
v_qsad*ran in wave32 and split-wave64).scripts/smoke.ps1 -Game <folder>(XCL_SAMPLE_*unset; no retail game files available locally).AI use
Em::valu_qsad,pk_sad_u16, unit/GPU tests, running the suite, and drafting this PR description. All diffs and test outputs verified locally.@dcastell1 on GitHub · 2026-11-24 08:16 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, so
v_qsad_pk_u16_u8andv_mqsad_{pk_u16,u32}_u8translate and their fixtures run green here; nothing else changes verdict.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.
@SlopTart on GitHub · 2026-11-24 09:34 UTC · original
Linux / AMD RDNA3 datapoint.
Merged state: head
4ed088donto main09940bb, clean merge.Full suite,
cargo test --workspace --release --no-fail-fast --target x86_64-pc-windows-gnu -- --test-threads=4: 711 passed, 7 failed, 41 ignored; failures are the known Wine-lane set from my #42 rows. qsad pack recompile tests green on RDNA3 wave64.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.
@4usphs on GitHub · 2026-11-24 09:39 UTC · original
Measured on RDNA2 hardware: the three quad-SAD instructions behave as this translation models them, including the zero-byte mask on S1 and
CLAMP.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 instruction runs as inline RDNA2 assembly in an OpenCL C kernel (the #518 / #772 method), VOP3 with a 64-bit S0, a 32-bit S1 and a 64-bit S2 (128-bit forv_mqsad_u32_u8,uint4operands), with and withoutclamp. The comparison model is a Python port ofvalu_qsadwithsad_u8/msad_u8/pk_sad_u16/sat_u32: 4 windows of S0 at byte offsets 0..3, S1's zero bytes skipped formqsad, per-element wrap or saturation.Inputs. This PR's GPU-test operands (
S0 = 0xFF605000_40302010,S1 = 0x40002015, the three accumulators, and-1/0x00FF0001), plus 2 000 random cases: S1 bytes zero 30 % of the time, and accumulators near 2^16 / 2^32 for the wrap and clamp edges. Each set runs 3 times (wave32, wave64, wave32) with identical output.v_qsad_pk_u16_u8v_mqsad_pk_u16_u8v_mqsad_u32_u8On the hardware, the cases in
gpu_qsad_and_mqsadgive exactly the values the test asserts. These arev8:v9=0x009D0036, 0x00BF004E;v12:v13=0x009C0033, 0x01BB002B; the clamp forms0x009CFFFF, 0x01BBFFFFand0x005CFFFF, 0x016BFFFF;v16:v17=0x005D0006, 0x006F004E;v20:v21=0x010000FF, 0x01020101; andv_mqsad_u32_u8=1, 0xFFFFFFFB, 74, 112wrapped and0xFFFFFFFF, 0xFFFFFFFB, 0xFFFFFFFF, 112clamped. So the expected values are the console generation's, not only the ISA text's.For comparison, an RX 9070 XT (
gfx1201, RDNA4, OpenCL3686.0) gives the same results in every case.Not tested: the console itself (
gfx1036is a desktop RDNA2 APU of the same generation), RDNA1, overlapping VDST / source ranges and EXEC masking on the hardware (the compiler picks the registers in this method), 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 model, ran them on my PC and wrote this comment. I have not reviewed the code.
@NWProgramming00 on GitHub · 2026-11-25 14:58 UTC · original
Continued in #2334. It keeps this PR's commit unchanged, with its authorship, and adds the direct DXIL lowering, a check of both backends against RDNA2 hardware, and the regression run.
Pull request closed