Skip to content

Shaders: lower v_cmp_{f,t}_{i64,u64} constant 64-bit compares - #1685

Open
Calvix2k wants to merge 1 commit into
Marvisak:mainfrom
Calvix2k:codex/shader-cmp64-ft-1531
Open

Calvix2k wants to merge 1 commit into
Marvisak:mainfrom
Calvix2k:codex/shader-cmp64-ft-1531

Conversation

@Calvix2k

Copy link
Copy Markdown
Contributor

Implements #1531.

Ports the fix from @davi713albano-coder's fork (commit 41715fc by Davi713), applied unchanged onto ffe310e; the commit keeps its original author.

Summary

The u64 | i64 arm of emit::lower::compare fell through to Err("a 64-bit compare") for the constant-true and constant-false compares, while the 32-bit arm handled them with self.lane(inst, Some(op == "t")).

  • v_cmp_{f,t}_{i64,u64} and v_cmpx_{f,t}_{i64,u64} now short-circuit before src64, so a constant compare does not set the Int64 flag (SFI0 bit 0x8000) it does not need.

Test

New synthetic compute test v_cmp_f_and_t_64bit_match_rdna2 covers v_cmp_f_i64, v_cmp_t_i64, v_cmp_f_u64 and v_cmp_t_u64: dxil.dll validation, absence of the Int64 flag, and execution on D3D12 hardware/WARP.

Validation

  • cargo test -p victory-shader --locked -- --test-threads=1 --skip emit::valu_tests --skip emit::waterfall_tests — passed (102 tests, 1 ignored).
  • cargo clippy -p victory-shader --all-targets --all-features --locked -- -D warnings — passed.
  • cargo xtask policy — passed (154 files).
  • Upstream fork CI ran the full workspace, including the new WARP/hardware VALU test: 343 passed, 0 failed.

Airamek added a commit to Airamek/VIctory that referenced this pull request Nov 24, 2026
@Calvix2k

Copy link
Copy Markdown
Contributor Author

Hardware run on the RX 7800 XT (RDNA3), Windows 10 x64, Agility SDK 1.616 for SM 6.6:

  • cargo test -p victory-shader --locked v_cmp_f_and_t_64bit_match_rdna2 -- --test-threads=1 --nocapture — 1 passed, 0 failed on the hardware backend.
  • WARP skipped (SM 6.2 here), so this confirms the constant-true/false 64-bit compares and the absent Int64 flag on AMD hardware.

@catminou4 catminou4 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested locally on macOS arm64 (rustc 1.98.1): PR head merged cleanly into current main (ffe310e), cargo test -p victory-shader --locked → 96 passed, 0 failed. Hardware/valu/waterfall execution tests are #[cfg(all(test, windows))] and run only on Windows; macOS covers lowering/structure unit tests.

v_cmp_f_i64/v_cmp_t_i64/v_cmp_f_u64/v_cmp_t_u64 constant 64-bit compares: 59-line diff with an RDNA2 reference test.

@Calvix2k

Copy link
Copy Markdown
Contributor Author

Rebased onto 70564ae; only the test module conflicted (upstream added more test helpers). Both sets are kept. cargo check -p victory-shader --tests --locked passes; the test itself was already verified on a Radeon RX 7800 XT before the rebase and is unchanged.

@Calvix2k
Calvix2k force-pushed the codex/shader-cmp64-ft-1531 branch from 04e65b6 to d7536bd Compare November 24, 2026 22:14
@upipibi

upipibi commented Nov 24, 2026

Copy link
Copy Markdown

NVIDIA run: RTX 3070 8 GB, driver 616.56, Windows 11, debug, d7536bd (on main 70564ae). v_cmp_f_and_t_64bit_match_rdna2 passes on the hardware adapter.

AI-assisted (Claude Code). Synthetic tests only.

zhaibingye added a commit to zhaibingye/VIctory that referenced this pull request Nov 24, 2026
Backport Marvisak#1685 unchanged, preserving Davi713's original commit. Verified 119 portable shader tests and Windows MSVC-target test compilation. The PR records earlier native AMD validation; native execution was not rerun here.
DesignWithTommy added a commit to DesignWithTommy/i95-GTA6-PC-Launcher that referenced this pull request Nov 24, 2026
…difiers

v_cmp_{f,t}_{i64,u64} return their constant before reading sources, so
they no longer refuse on modifiers or unpaired sources (VIctory-zhai
d7536bd / c012f2d, Davi713, Marvisak/VIctory#1685).

v_frexp_mant_f32 and v_ldexp_f32 apply abs/neg to the raw sign bit, and
tb_ldexp returns an infinity or NaN unchanged, so a NaN keeps its bits
(leonida 5f063e58, milk4sale). The binary64 roundings of leonida 26d010b4
were already integer ops that keep NaN bits and round subnormals.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@Calvix2k
Calvix2k force-pushed the codex/shader-cmp64-ft-1531 branch from d7536bd to d869333 Compare November 25, 2026 02:24

Marvisak commented Nov 25, 2026 •

Copy link
Copy Markdown
Owner

Automated triage for the maintainers.

Needs rebase. This PR no longer merges cleanly into main: main has moved since the last triage, and the branch now conflicts in crates/victory-shader/src/emit/lower.rs and crates/victory-shader/src/emit/valu_tests.rs. It will be reviewed again once it is rebased onto current main.

Previous verdict for this head: merge candidate.


Generated by Claude Code

@StExpeditus

Copy link
Copy Markdown

Test report: RTX 5060 Ti (Blackwell), Windows 11 Pro 26200, driver 621.24. Branch at d869333. cargo test --workspace --locked --no-fail-fast -> 697 passed, 5 failed, 10 ignored. The failures are the same 5 pre-existing NVIDIA 1M-view-heap-cap failures (also on main; see my reports on #2030 and #1940). Nothing introduced by this PR fails on this machine.

@Calvix2k

Copy link
Copy Markdown
Contributor Author

Hardware run on an RX 7800 XT (RDNA3), Windows 10 19045, SM 6.6 via the Agility runtime for the test binaries (#486): victory-shader lib suite 248 passed, 0 failed, 3 ignored, including the 64-bit constant-compare cases. The lowering is exercised on the card here as well as on CI's device.

@Calvix2k
Calvix2k force-pushed the codex/shader-cmp64-ft-1531 branch from d869333 to 803c7f3 Compare November 26, 2026 13:52
@Calvix2k

Copy link
Copy Markdown
Contributor Author

Rebased. The f/t early return now runs before upstream's dword-wise comparison, so both the AMD dword order and the float predicates are handled by one path.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants