Shaders: a signed 64-bit operand sign-extends its 32-bit literal (port of VIctory#447) #188
No reviewers
Labels
No labels
accessibility
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
question
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/Belobug--VIctory-Belobug-AMD!188
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-188"
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?
@lcg007xd-c on GitHub · 2026-11-25 20:25 UTC · original
lcg007xd-c:port/vic-447→main· +43 −4 · 2 files · 1 commits · openPort of Marvisak/VIctory#447 by Duff. It is cherry-picked with
-x, so the commit keeps its author and its upstream hash. This fork'smain(000ffdd) does not have it, and it is not in #142.What it fixes
A 32-bit literal in a signed 64-bit operand is sign-extended on the hardware (LLVM's AMDGPU operand rules), but the fork zero-extended every literal except
s_bfe_i64's:v_cmp_lt_i64 v[1:2], -100compared against 4294967196, ands_ashr_i64of a negative literal shifted in zeros. Upstream's rule (every_i64instruction) covers the fork'ss_bfe_i64case, so that one now follows it.Tested (Linux, Rust 1.98.1)
valu_tests::signed_64_bit_operands_sign_extend_their_literal(Windows/GPU) is included. On Linux I checked the lowered IR with a temporary test (VOP3v_cmp_lt_i64with -100, ands_ashr_i64): passes with the port, fails without; not committed.cargo test -p victory-shader --libon this branch alone: no failures.mainwithout conflicts, and does not depend on the other open ports.Not run here: Windows/GPU tests, since I have no Windows machine.
🤖 Generated with Claude Code
@MamaLeVrai on GitHub · 2026-11-26 05:00 UTC · original
RDNA2 data point. This PR (
8394b7e) merged onmain4f62c2a,cargo test --release -p victory-shader --libon an RX 6950 XT (Windows 11 build 26300, Rust 1.98.1):main: 275 passed, 2 failed.The 2 failures are the same as on
main: the RDNA2 wave-size testsscalar_counted_in_a_divergent_loop_read_after_itandscalar_counted_in_nested_divergent_loops, fixed by #110 and #204. No regression here. One run ended without a result line, which this test binary does now and then on this machine, onmaintoo. Not run in the game.harness machine: rx6950xt-w11 | AMD Radeon RX 6950 XT (RDNA2), driver 32.0.21045.29003 | 32 GB RAM | Windows 11 build 26300
AI-assisted (Claude Code); no game data.
@adrianmjim on GitHub · 2026-11-26 19:43 UTC · original
Tested on Windows 11, RX 7900 XT (RDNA3, driver 32.0.32029.2010), Rust 1.98.1.
The branch is based on
000ffdd. I tested it merged onto main4f62c2a, which gives the same tree as refs/pull/188/merge.GPU test:
signed_64_bit_operands_sign_extend_their_literalpasses on both the hardware adapter and WARP.4f62c2a, it fails on the hardware adapter at the first case (v_cmp_eq_i64, -100: got 0, want 1).v_cmpcases taken out, thes_ashr_i64case also fails on4f62c2a(high dword: got 0, want 0xffffffff). So both the vector and the scalar change are covered.cargo test -p victory-shader --lib -- --test-threads=1: 278 passed, 0 failed, 6 ignored. On4f62c2a: 277 passed, 0 failed, 6 ignored.Full shaders.rpf of the title (
translate --validate --host-lanes 32-64):4f62c2a._i64instruction at all, and no instruction with an_i64,_u64or_b64mnemonic has a literal operand.So for this title the change is a correctness fix with no effect on this archive.
Not tested: other games, the branch head on its own, or a run in game.
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.