Shaders: 64-bit integer compares on their dwords (AMD orders a shared-dword i64 compare wrong) #135
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/135"
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 fxceless/victory-fork. Originally posted by alexdeliu on 2026-11-24T21:45:19Z.
Port of Marvisak/VIctory#1599, which is still open upstream, to this fork. It fixes a translation bug that only AMD hosts hit.
v_cmp_{lt,le,gt,ge}_{i64,u64}are lowered to oneicmpon ani64built from two dwords. AMD's D3D12 driver answers wrong when the two operands share a dword, as if the dwords were swapped. For example,v_cmp_lt_i64 s20, v[1:2], v[2:3]with v1 = v2 = 0, v3 = 1 asks whether0 < 0x1_00000000. AMD says false, WARP and NVIDIA say true. It reproduced on:Change: the compare runs on the dwords. The high dwords decide (signed for
i64); when they are equal, the low dwords decide (unsigned). It no longer needsINT64. The only conflict with this fork was thatjoin64and the newsrc64_dwordswere added in the same place. Both are kept.Test:
v_cmp_u64_and_i64_order_by_the_high_dword, on the GPU (hardware and WARP):Results on this fork's
main(4e17478), RX 9070:hardware: v_cmp_lt_i64(0x0000000000000000, 0x0000000100000000). With it, it passes.cargo test --workspace --lockedpasses 495.emit::rect::tests::{the_rectangle_stage_is_a_geometry_shader, rectangles_are_drawn_whole}, already fail onmainwith the Windows SDK'sdxil.dll(1.7). #61 fixes them, and I checked that on the same card.🤖 Generated with Claude Code
Imported from fxceless/victory-fork. Originally posted by bawhen on 2026-11-24T22:17:38Z.
Reproduced and fixed on a desktop RDNA3 card (RX 7700, driver 32.0.32029.2010), which adds a third AMD generation to the RX 9070 and gfx1036 results.
cargo test -p victory-shader --locked --lib v_cmp_u64_and_i64_order_by_the_high_dword -- --nocapture9b8ab0bskippedline, so the card ran it)lower.rsfrommainhardware: v_cmp_lt_i64(0x0000000000000000, 0x0000000100000000), the same first failure as on the RX 9070Setup: AMD Radeon RX 7700 (RDNA3, 16 GB), driver 32.0.32029.2010, Ryzen 7 8700F, 16 GB RAM, Windows 11 (build 26300), Rust 1.98.1 from
rust-toolchain.toml. Baselinemainat4e17478:cargo test --workspace --lockedgives 496 passed, 0 failed, 7 ignored. The "without the fix" run checks outmain's version of the PR's non-test files and keeps the PR's new test. No game files used.AI use: Claude Code (Claude Opus 5.5) ran the tests and drafted this comment; posted at my request.
Imported from fxceless/victory-fork. Originally posted by murillojndem on 2026-11-28T05:53:54Z.
Since the tree moved to the VIctory-NVIDIA base on 27 November this conflicts, and
mainstill lowers the 64-bit compares as one i64icmp. #1506 carries the lines of upstream's cc7ec2a (your Marvisak/VIctory#1599) on currentmain, with you as co-author. It reproduces on an RX 7900 XT (RDNA 3, driver 32.0.32015.7029): the test fails on the card without the change and passes with it. If you would rather rebase this one, #1506 can be closed.AI use: Claude Code ran the tests and drafted this comment; posted at my request.
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.