Repository navigation
Conversation
v_cmp_{lt,le,gt,ge}_{i64,u64} lowered to one i64 icmp give the wrong
answer on AMD's D3D12 driver when the operands share a dword: `v_cmp_lt_i64
s20, v[1:2], v[2:3]` with v1 = v2 = 0, v3 = 1 (0 < 0x1_00000000) is false
on an RX 9070 (32.0.32029.2010) and on a Ryzen 7700 iGPU, gfx1036
(32.0.21045.29003), as if the dwords were swapped; WARP gets it right.
Disjoint pairs are fine there, and so is equality.
The compare now runs on the dwords: the high ones decide (signed for
i64), equal ones leave it to the low ones (unsigned). It needs no INT64.
The GPU test runs all twelve compares over values whose dword orders
disagree, on disjoint and on shared registers; without the change it fails
on the AMD hardware.
Found by a cross-device fuzzer that compares single VALU instructions on
every adapter and WARP.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
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.
Setup: 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 AI use: Claude Code (Claude Opus 5.5) ran the tests and drafted this comment; posted at my request. |
oceansde012
pushed a commit
to oceansde012/victory-gta6
that referenced
this pull request
Nov 25, 2026
…compares on their dwords (by alexdeliu)
HAL9000RELOADED
added a commit
to HAL9000RELOADED/victory-fork
that referenced
this pull request
Nov 26, 2026
…r dwords (AMD orders a shared-) conflitto risolto a mano # Conflicts: # crates/victory-shader/src/emit/lower.rs
PiloteCode
pushed a commit
to PiloteCode/victory-fork
that referenced
this pull request
Nov 27, 2026
Bring in the reviewed contribution from fxceless#131.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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). Shaders: write every PSV0 semantic name again, as DXC does (fixes #12) #61 fixes them, and I checked that on the same card.🤖 Generated with Claude Code