Shaders: hardware probe for s_flbit_i32 #1361

Open
github-bot wants to merge 2 commits from github-bot/gh-1361 into main AGit
Owner

@⁠LouisRiverstone on GitHub · 2026-11-24 17:36 UTC · original
LouisRiverstone:shaders/s-bit-scan-test → main · +5 −0 · 1 files · 2 commits · open

Adds sop1_probe(0x17, ...) for s_flbit_i32 (first bit that differs from the sign bit, -1 for 0 and -1) to scalar_probes. Reduced after triage: the other scalar bit-scan ops are already covered on main.

**@⁠LouisRiverstone** on GitHub · 2026-11-24 17:36 UTC · [original](https://github.com/Marvisak/VIctory/pull/1361) `LouisRiverstone:shaders/s-bit-scan-test` → `main` · +5 −0 · 1 files · 2 commits · open Adds `sop1_probe(0x17, ...)` for `s_flbit_i32` (first bit that differs from the sign bit, -1 for 0 and -1) to `scalar_probes`. Reduced after triage: the other scalar bit-scan ops are already covered on main.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 04:28:47 +00:00
Author
Owner

@⁠matheusfermiano-source on GitHub · 2026-11-24 18:08 UTC · original

First GPU run of this PR's test that I could find, on an AMD GPU under Proton on Linux: s_bit_scan_and_reverse_ops_match_rdna2: pass on a Radeon 660M (RDNA2).

  • Head 8d6d06c. Built on Linux with llvm-mingw for x86_64-pc-windows-gnullvm (Rust 1.98.1) and run under Proton Experimental (11.0-20261027b) with its vkd3d-proton 3.1.0, one GPU at a time; dxil.dll from DXC 1.9.2609 was loaded, so the test modules were validated.
  • Radeon 660M (RDNA2, RADV Mesa 26.3.1, waves 32..64): whole victory-shader suite 120 passed, 1 failed, 1 ignored. Nothing fails that passes on main (ffe310e). The one failure, emit::tests::stub_pipeline_is_created, fails on main here too: vkd3d-proton accepts the zeroed DXIL hash that the Windows runtime refuses (one of the Wine failures listed in #1218).

This is RADV, not AMD's Windows driver, so it adds to a Windows run rather than replacing it. Synthetic tests only, no game files. AI-assisted (Claude Code, Opus 5.5); every run was on this machine.

**@⁠matheusfermiano-source** on GitHub · 2026-11-24 18:08 UTC · [original](https://github.com/Marvisak/VIctory/pull/1361#issuecomment-7140216918) First GPU run of this PR's test that I could find, on an AMD GPU under Proton on Linux: **`s_bit_scan_and_reverse_ops_match_rdna2`: pass** on a Radeon 660M (RDNA2). - Head `8d6d06c`. Built on Linux with llvm-mingw for `x86_64-pc-windows-gnullvm` (Rust 1.98.1) and run under Proton Experimental (11.0-20261027b) with its vkd3d-proton 3.1.0, one GPU at a time; `dxil.dll` from DXC 1.9.2609 was loaded, so the test modules were validated. - **Radeon 660M** (RDNA2, RADV Mesa 26.3.1, waves 32..64): whole `victory-shader` suite 120 passed, 1 failed, 1 ignored. Nothing fails that passes on `main` (`ffe310e`). The one failure, `emit::tests::stub_pipeline_is_created`, fails on `main` here too: vkd3d-proton accepts the zeroed DXIL hash that the Windows runtime refuses (one of the Wine failures listed in #1218). This is RADV, not AMD's Windows driver, so it adds to a Windows run rather than replacing it. Synthetic tests only, no game files. AI-assisted (Claude Code, Opus 5.5); every run was on this machine.
Author
Owner

@⁠wwwwwwww3333333 on GitHub · 2026-11-24 19:12 UTC · original

Native Windows run on AMD RDNA2: RX 6750 XT (RDNA2, gfx1031), AMD driver 32.0.21045.29003, i5-13400F, Windows 11, Rust 1.98.1 MSVC. Head 8d6d06c on main ffe310e (clean merge).

cargo test -p victory-shader --lib -- --test-threads=1: 121 passed, 0 failed, 1 ignored (main alone: 120 passed). s_bit_scan_and_reverse_ops_match_rdna2 ran on the hardware adapter and then on WARP, and passed on both. The earlier RDNA2 runs on this PR went through vkd3d-proton on Linux; this one is AMD's own D3D12 driver.

Synthetic tests only, no game files. AI-assisted (Claude picked the PRs and wrote the batch script; I ran it on my machine).

**@⁠wwwwwwww3333333** on GitHub · 2026-11-24 19:12 UTC · [original](https://github.com/Marvisak/VIctory/pull/1361#issuecomment-7141749817) Native Windows run on AMD RDNA2: RX 6750 XT (RDNA2, gfx1031), AMD driver 32.0.21045.29003, i5-13400F, Windows 11, Rust 1.98.1 MSVC. Head 8d6d06c on main ffe310e (clean merge). `cargo test -p victory-shader --lib -- --test-threads=1`: **121 passed, 0 failed**, 1 ignored (main alone: 120 passed). `s_bit_scan_and_reverse_ops_match_rdna2` ran on the hardware adapter and then on WARP, and passed on both. The earlier RDNA2 runs on this PR went through vkd3d-proton on Linux; this one is AMD's own D3D12 driver. Synthetic tests only, no game files. AI-assisted (Claude picked the PRs and wrote the batch script; I ran it on my machine).
Author
Owner

@⁠Marvisak on GitHub · 2026-11-25 02:36 UTC · original · edited 2026-11-26 02:17 UTC

Automated triage for the maintainers.

Merge candidate (recommending a look, not an approval). Reviewed at d3b7805, which merges cleanly into main. The unrelated reformatting is gone: the PR is now only the five lines in scalar_probes (crates/victory-shader/src/emit/semantics_tests.rs).

It adds a probe for s_flbit_i32 (SOP1 0x17), which main lowers in the "s_flbit_i32_b32" | "s_flbit_i32" arm of emit/lower.rs but no probe covered. The expected value (leading zeros of the value, or of its complement when negative, and -1 for 0 and -1) matches the RDNA2 definition of the first bit that differs from the sign bit. CI: check passing.


Generated by Claude Code

**@⁠Marvisak** on GitHub · 2026-11-25 02:36 UTC · [original](https://github.com/Marvisak/VIctory/pull/1361#issuecomment-7150942405) · edited 2026-11-26 02:17 UTC <!-- victory-triage v1 head=d3b780517ab2834ebf3f403aded935e4c43d6ce5 verdict=merge-candidate at=2026-11-26T02:17:30Z --> Automated triage for the maintainers. **Merge candidate** (recommending a look, not an approval). Reviewed at `d3b7805`, which merges cleanly into `main`. The unrelated reformatting is gone: the PR is now only the five lines in `scalar_probes` (`crates/victory-shader/src/emit/semantics_tests.rs`). It adds a probe for `s_flbit_i32` (SOP1 0x17), which `main` lowers in the `"s_flbit_i32_b32" | "s_flbit_i32"` arm of `emit/lower.rs` but no probe covered. The expected value (leading zeros of the value, or of its complement when negative, and -1 for 0 and -1) matches the RDNA2 definition of the first bit that differs from the sign bit. CI: `check` passing. --- _Generated by [Claude Code](https://claude.ai/code)_
Author
Owner

@⁠catminou4 on GitHub · 2026-11-24 17:42 UTC · original · approved these changes

Hardware test only: s_brev/s_bcnt1/s_ff1/s_flbit (u32 and signed)/s_abs_i32 SOP1 opcodes with RDNA2 reference formulas (searches return -1/0xFFFFFFFF when no bit). The signed flbit formula (invert when sign set, then leading_zeros) matches the 'first bit differing from sign' definition. Windows-only execution — worth a hardware run since flbit signed corner cases (0, INT_MIN) are exactly where emulators diverge. Local verification: macOS arm64, rustc 1.98.1, PR head merged into main ffe310e, cargo test -p <crate> --locked. Shader execution tests (valu_tests/host/diff_tests) are #[cfg(all(test, windows))], so macOS covers lowering/decode/unit tests only. 96 passed, 0 failed.

**@⁠catminou4** on GitHub · 2026-11-24 17:42 UTC · [original](https://github.com/Marvisak/VIctory/pull/1361#pullrequestreview-6044387982) · **approved these changes** Hardware test only: s_brev/s_bcnt1/s_ff1/s_flbit (u32 and signed)/s_abs_i32 SOP1 opcodes with RDNA2 reference formulas (searches return -1/0xFFFFFFFF when no bit). The signed flbit formula (invert when sign set, then leading_zeros) matches the 'first bit differing from sign' definition. Windows-only execution — worth a hardware run since flbit signed corner cases (0, INT_MIN) are exactly where emulators diverge. Local verification: macOS arm64, rustc 1.98.1, PR head merged into main ffe310e, `cargo test -p <crate> --locked`. Shader execution tests (valu_tests/host/diff_tests) are `#[cfg(all(test, windows))]`, so macOS covers lowering/decode/unit tests only. 96 passed, 0 failed.
Author
Owner

@⁠catminou4 on GitHub · 2026-11-24 20:50 UTC · original · approved these changes

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 tests are #[cfg(all(test, windows))] and only run on Windows; macOS covers structure/lowering unit tests.

Hardware test for the scalar bit-scan/reverse/abs ops (s_bit_scan_and_reverse_ops_match_rdna2) against RDNA2 reference values.

**@⁠catminou4** on GitHub · 2026-11-24 20:50 UTC · [original](https://github.com/Marvisak/VIctory/pull/1361#pullrequestreview-6047176223) · **approved these changes** 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 tests are #[cfg(all(test, windows))] and only run on Windows; macOS covers structure/lowering unit tests. Hardware test for the scalar bit-scan/reverse/abs ops (s_bit_scan_and_reverse_ops_match_rdna2) against RDNA2 reference values.
Author
Owner

@⁠fuzeofficlal on GitHub · 2026-11-26 21:16 UTC · original · approved these changes

LGTM — verified against origin/main (63bcca43) on Windows x64 (RTX 5090 and WARP).

  • The new sop1_probe(0x17, unary(U32_EDGES), ...) in crates/victory-shader/src/emit/semantics_tests.rs:2759-2763 accurately models RDNA2 s_flbit_i32 (first bit from MSB differing from the sign bit, -1 for 0 and -1) and matches DXIL FirstbitSHi on both host GPU and WARP.
  • Checks:
    • cargo test --locked -p victory-shader --lib -- --test-threads=1 emit::semantics_tests:: with VICTORY_WARP=0: 34 passed, 0 failed, 1 ignored (including scalar_alu_matches_the_hardware).
    • cargo test --locked -p victory-shader --lib -- --test-threads=1 emit::semantics_tests:: with VICTORY_WARP=1: 34 passed, 0 failed, 1 ignored (including scalar_alu_matches_the_hardware).
    • cargo clippy -p victory-shader --all-targets --locked -- -D warnings (default and --all-features): clean.
    • cargo xtask policy: 191 files ok; rustfmt --edition 2024: clean on changed hunks.

Synthetic tests only; no game data used.

**@⁠fuzeofficlal** on GitHub · 2026-11-26 21:16 UTC · [original](https://github.com/Marvisak/VIctory/pull/1361#pullrequestreview-6080549517) · **approved these changes** LGTM — verified against `origin/main` (`63bcca43`) on Windows x64 (RTX 5090 and WARP). - The new `sop1_probe(0x17, unary(U32_EDGES), ...)` in `crates/victory-shader/src/emit/semantics_tests.rs:2759-2763` accurately models RDNA2 `s_flbit_i32` (first bit from MSB differing from the sign bit, `-1` for `0` and `-1`) and matches DXIL `FirstbitSHi` on both host GPU and WARP. - **Checks**: - `cargo test --locked -p victory-shader --lib -- --test-threads=1 emit::semantics_tests::` with `VICTORY_WARP=0`: 34 passed, 0 failed, 1 ignored (including `scalar_alu_matches_the_hardware`). - `cargo test --locked -p victory-shader --lib -- --test-threads=1 emit::semantics_tests::` with `VICTORY_WARP=1`: 34 passed, 0 failed, 1 ignored (including `scalar_alu_matches_the_hardware`). - `cargo clippy -p victory-shader --all-targets --locked -- -D warnings` (default and `--all-features`): clean. - `cargo xtask policy`: 191 files ok; `rustfmt --edition 2024`: clean on changed hunks. Synthetic tests only; no game data used.
This pull request can be merged automatically.
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin '+refs/pull/1361/head:github-bot/gh-1361'
git switch 'github-bot/gh-1361'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-1361'
git switch 'github-bot/gh-1361'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-1361'
git switch 'github-bot/gh-1361'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-1361'
git switch 'main'
git merge --squash 'github-bot/gh-1361'
git switch 'main'
git merge --ff-only 'github-bot/gh-1361'
git switch 'main'
git merge 'github-bot/gh-1361'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No reviewers
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
github/Marvisak--VIctory!1361
No description provided.