Shaders: hardware probe for s_bitset0_b32 and s_bitset1_b32 #1365

Closed
LouisRiverstone wants to merge 1 commit from upstream-pr/1365 into main
LouisRiverstone commented 2026-11-24 17:36:51 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by LouisRiverstone on 2026-11-24T17:36:51Z.


Adds probes for s_bitset0_b32 / s_bitset1_b32 (SOP1 0x1b / 0x1d) in scalar_probes: the destination is seeded with the first operand, then bit src[4:0] is cleared or set. Reduced after triage: s_bfm_b32 is already covered on main.

<!-- greyfinch-sync:Marvisak/VIctory:issue:6587762223 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1365). Originally posted by [LouisRiverstone](https://github.com/LouisRiverstone) on 2026-11-24T17:36:51Z. --- Adds probes for `s_bitset0_b32` / `s_bitset1_b32` (SOP1 0x1b / 0x1d) in `scalar_probes`: the destination is seeded with the first operand, then bit `src[4:0]` is cleared or set. Reduced after triage: `s_bfm_b32` is already covered on main.
catminou4 commented 2026-11-24 18:05:00 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by catminou4 on 2026-11-24T17:42:41Z.

Review: APPROVED


Hardware test only: s_bfm_b32 (SOP2 0x24) and s_bitset{0,1}_b32 (SOP1 0x1b/0x1d) using the low 5 bits of both operands, with width/offset edge cases (32, 33). The bfm reference (1 << (w & 31)) - 1 << (o & 31) asserts the 5-bit truncation — that's the behavior the title claims hardware shows; please confirm on the Windows run since width=32 wrapping to 0 is surprising. 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.

<!-- greyfinch-sync:Marvisak/VIctory:review:6044388388 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1365#pullrequestreview-6044388388). Originally posted by [catminou4](https://github.com/catminou4) on 2026-11-24T17:42:41Z. **Review:** APPROVED --- Hardware test only: s_bfm_b32 (SOP2 0x24) and s_bitset{0,1}_b32 (SOP1 0x1b/0x1d) using the low 5 bits of both operands, with width/offset edge cases (32, 33). The bfm reference `(1 << (w & 31)) - 1 << (o & 31)` asserts the 5-bit truncation — that's the behavior the title claims hardware shows; please confirm on the Windows run since width=32 wrapping to 0 is surprising. 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.
matheusfermiano-source commented 2026-11-24 19:04:01 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by matheusfermiano-source on 2026-11-24T18:08:16Z.


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

  • Head a4c994b. 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.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7140211035 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1365#issuecomment-7140211035). Originally posted by [matheusfermiano-source](https://github.com/matheusfermiano-source) on 2026-11-24T18:08:16Z. --- First GPU run of this PR's test that I could find, on an AMD GPU under Proton on Linux: **`s_bfm_and_s_bitset_use_the_low_five_bits`: pass** on a Radeon 660M (RDNA2). - Head `a4c994b`. 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.
wwwwwwww3333333 commented 2026-11-24 20:03:03 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by wwwwwwww3333333 on 2026-11-24T19:13:08Z.


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 a4c994b 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_bfm_and_s_bitset_use_the_low_five_bits 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).

<!-- greyfinch-sync:Marvisak/VIctory:comment:7141772815 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1365#issuecomment-7141772815). Originally posted by [wwwwwwww3333333](https://github.com/wwwwwwww3333333) on 2026-11-24T19:13:08Z. --- 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 a4c994b 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_bfm_and_s_bitset_use_the_low_five_bits` 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).
catminou4 commented 2026-11-24 21:02:15 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by catminou4 on 2026-11-24T20:50:16Z.

Review: APPROVED


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 s_bfm_b32 and s_bitset0/1_b32: s_bfm_and_s_bitset_use_the_low_five_bits pins the 5-bit field behavior.

<!-- greyfinch-sync:Marvisak/VIctory:review:6047176743 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1365#pullrequestreview-6047176743). Originally posted by [catminou4](https://github.com/catminou4) on 2026-11-24T20:50:16Z. **Review:** APPROVED --- 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 s_bfm_b32 and s_bitset0/1_b32: s_bfm_and_s_bitset_use_the_low_five_bits pins the 5-bit field behavior.
Marvisak commented 2026-11-25 03:03:35 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Marvisak on 2026-11-25T02:37:10Z.


Automated triage for the maintainers.

Merge candidate.

The PR is now what the last triage asked for. The s_bfm_b32 cases that duplicated main are gone, and the s_bitset0_b32/s_bitset1_b32 probes (SOP1 0x1B/0x1D) moved into scalar_probes in crates/victory-shader/src/emit/semantics_tests.rs, using main's existing sop1, vop1, scalar and pairs helpers. Each probe first sets the destination with s_mov_b32 s20, s16, so the test checks that only one bit of the old value changes. The bit index is the low five bits of the source (inputs include 32, 33 and 0xFFFFFFE1). That matches the RDNA2 ISA and the s_bitset0_b32 | s_bitset1_b32 arm in lower.rs. No SCC is expected, which is correct.

CI: passing (check).


Generated by Claude Code

<!-- greyfinch-sync:Marvisak/VIctory:comment:7150957934 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1365#issuecomment-7150957934). Originally posted by [Marvisak](https://github.com/Marvisak) on 2026-11-25T02:37:10Z. --- <!-- victory-triage v1 head=34a344022af0b41d2604d4ddc54bb79757500d48 verdict=merge-candidate at=2026-11-25T16:44:32Z --> Automated triage for the maintainers. **Merge candidate.** The PR is now what the last triage asked for. The `s_bfm_b32` cases that duplicated main are gone, and the `s_bitset0_b32`/`s_bitset1_b32` probes (SOP1 0x1B/0x1D) moved into `scalar_probes` in `crates/victory-shader/src/emit/semantics_tests.rs`, using main's existing `sop1`, `vop1`, `scalar` and `pairs` helpers. Each probe first sets the destination with `s_mov_b32 s20, s16`, so the test checks that only one bit of the old value changes. The bit index is the low five bits of the source (inputs include 32, 33 and 0xFFFFFFE1). That matches the RDNA2 ISA and the `s_bitset0_b32 | s_bitset1_b32` arm in `lower.rs`. No SCC is expected, which is correct. CI: passing (`check`). --- _Generated by [Claude Code](https://claude.ai/code)_
upstream-sync changed title from [PR #1365] Shaders: hardware test for s_bfm_b32 and s_bitset0/1_b32 to [PR #1365] Shaders: hardware probe for s_bitset0_b32 and s_bitset1_b32 2026-11-25 16:06:00 +00:00
upstream-sync closed this pull request 2026-11-25 22:02:56 +00:00
Marvisak commented 2026-11-25 22:04:40 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Marvisak on 2026-11-25T22:00:29Z.


Automated triage for the maintainers, second look (a review against current main, with builds and tests where they could change the verdict).

Closing as covered by #2015, which adds the same two probes (destination seeded from another register, bit indices including 32 and above). The probes here are right and pass on an RX 6700 XT and on WARP.

If this is mistaken, reply here with what was missed and it will be looked at again. Thank you for the contribution.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7175817976 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1365#issuecomment-7175817976). Originally posted by [Marvisak](https://github.com/Marvisak) on 2026-11-25T22:00:29Z. --- Automated triage for the maintainers, second look (a review against current `main`, with builds and tests where they could change the verdict). Closing as covered by #2015, which adds the same two probes (destination seeded from another register, bit indices including 32 and above). The probes here are right and pass on an RX 6700 XT and on WARP. If this is mistaken, reply here with what was missed and it will be looked at again. Thank you for the contribution.

Pull request closed

Sign in to join this conversation.
No reviewers
No labels
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.

Reference
Marvisak/VIctory!1365
No description provided.