Shaders: lower v_swap_b32 and v_xnor_b32 #127
No reviewers
Labels
No labels
accessibility
area: build
area: formats
area: gpu
area: loader
area: runtime
area: shader
bug
documentation
duplicate
enhancement
good first issue
gpu: amd
gpu: intel
gpu: nvidia
help wanted
host: wine
invalid
out of scope
question
request
run report
triage: confirmed
triage: has patch
triage: merge candidate
triage: needs info
triage: needs rebase
triage: needs work
triage: proposed close
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/Marvisak--VIctory!127
Loading…
Reference in a new issue
No description provided.
Delete branch "gh-pr/127/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?
@7ROBE on GitHub · 2026-11-24 00:43 UTC · original
7ROBE:fix/shader-xnor-swap→main· +86 −0 · 1 files · 1 commits · closed without mergingWhat is in it
v_swap_b32(swapping two VGPRs under the activeEXECguard;ir.rsalready marks both operands as read and written) incrates/victory-shader/src/emit/lower.rs.v_xnor_b32(~(src0 ^ src1)) incrates/victory-shader/src/emit/lower.rs.v_xnor_b32_and_v_swap_b32_translatecoveringv_xnor_b32andv_swap_b32(distinct VGPRs and self-swap).Refs #97.
Tested
cargo xtask policy:asset policy: 150 files okcargo test --workspace: 240 passed, 0 failed, 3 ignored (includingemit::lower::tests::v_xnor_b32_and_v_swap_b32_translate)cargo clippy --workspace --all-targets: passed (0 warnings)rustfmt --check --edition 2024 crates/victory-shader/src/emit/lower.rs: passedHardware / OS
AI-assisted
@raffclar on GitHub · 2026-11-24 00:50 UTC · original
This isn't needed anymore. #58 added them
@tanishq-dubey on GitHub · 2026-11-24 00:53 UTC · original
Related self-swap edge case on
mainat9aef3d9: a synthetic compute shader that readsv1afterv_swap_b32 v1, v1and stores it to a UAV fails translation witha value defined after its use(offset 36). The existing self-swap here is immediately followed bys_endpgm, so it may not exercise a later use.In
ir.rs, the same VGPR is recorded twice as a write; skipping the second write whenv.dst.as_ref() == v.src.first()fixed the regression. An end-to-end synthetic test then returned both0x12345678and0xffffffffunchanged on an RTX 5090 using Wine 11.22 and vkd3d-proton. No game assets used. AI-assisted.@DaviTostes on GitHub · 2026-11-24 01:10 UTC · original
Tested
60e8adfon Arch Linux x86_64, rustc 1.98.1: pass.cargo test -p victory-shader: 52 passed, 0 failed (2 test binaries), including the 1 test this PR adds.victory-gpuE0425.@Lyrnc on GitHub · 2026-11-24 06:22 UTC · original
RDNA2 hardware check: both match.
Setup. AMD Radeon iGPU of a Ryzen 7 9800X3D, gfx1036 (RDNA2), AMD driver 32.0.21042.62, Windows 11 Pro 26200. Hand-written instructions in a HIP kernel (assembled by the AMD driver's amd_comgr). RDNA2 desktop silicon, not the console's. No game data. 400 operand pairs (edge values and 300 random).
v_xnor_b32:~(src0 ^ src1), 400/400.v_swap_b32 v16, v17with distinct registers swaps them, 400/400.v_swap_b32 v18, v18leaves the register unchanged, 400/400 (your self-swap case).AI use: Claude Code (Claude Opus 5.5) wrote the probes, ran them on the GPU above and drafted this comment; the numbers come from the hardware run.
@Dathinel on GitHub · 2026-11-24 06:23 UTC · original
I checked what remains to integrate after #58. On
main@d2a4bae1, applying #127's test function without either lowering change gives 1 passed forv_xnor_b32_and_v_swap_b32_translate. Clippy also passes in that configuration.With the full #127 change applied to the same main,
cargo clippy --frozen -p victory-shader --features host --all-targets -- -D warningsreports two unreachable match arms inlower.rs, one for each opcode. The integrated file matches GitHub's test merge.I'd drop the duplicate lowering changes. The added
dst != srccheck is inside the unreachable swap arm. If you want to keep a distinct regression test here, the case reported on9aef3d9reads the register after swapping it with itself. The current test ends immediately after that instruction and checks translation. The RDNA2 measurement above supplies the expected register value for a readback test. AI tools assisted with the comparison.Pull request closed