Shaders: cover s_bfe_u32/s_bfe_i32 SCC, literal src1, dirty bits, and width>=32 in valu_tests #2058

Merged
fuzeofficlal merged 1 commit from upstream-pr/2060 into main 2026-11-25 21:54:06 +00:00
fuzeofficlal commented 2026-11-25 04:17:11 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by fuzeofficlal on 2026-11-25T04:17:11Z.


Addresses #803.

Summary

Audited Lower::bfe and Lower::sop against RDNA2 S_BFE_U32 (0x27) / S_BFE_I32 (0x28) semantics and expanded valu_tests::bfe_signed_and_unsigned_match_rdna2 to cover the remaining gaps beyond 328eec1:

  • s_bfe_u32 & v_bfe_u32 width wrapping: adds s_bfe_u32 GPU/WARP cases in valu_tests and verifies 5-bit width = 32 -> 0 masking for v_bfe_u32 alongside v_bfe_i32.
  • SCC condition-code output (D != 0): verifies SCC for both s_bfe_i32 (not previously checked via sop2_probe) and s_bfe_u32 through s_cselect_b32.
  • 32-bit literal src1 (0xFF): exercises literal offset | (width << 16) operands for both 0x27 and 0x28 (value and SCC).
  • Ignored bits & width = 64 boundary: verifies hardware masking of unused src1[15:5] and src1[31:23] bits (0xFF80_FFE0) and width = 64 (where width >= 32 while width & 31 == 0).

Testing

  • cargo test -p victory-shader --locked bfe_signed_and_unsigned_match_rdna2 across hardware D3D12 adapters (RTX 5090, RDNA2), WARP, and dxil.dll validation.
  • cargo clippy --workspace --all-targets --all-features -- -D warnings and cargo xtask policy.
<!-- greyfinch-sync:Marvisak/VIctory:issue:6597094351 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2060). Originally posted by [fuzeofficlal](https://github.com/fuzeofficlal) on 2026-11-25T04:17:11Z. --- Addresses #803. ### Summary Audited `Lower::bfe` and `Lower::sop` against RDNA2 `S_BFE_U32` (`0x27`) / `S_BFE_I32` (`0x28`) semantics and expanded `valu_tests::bfe_signed_and_unsigned_match_rdna2` to cover the remaining gaps beyond `328eec1`: - **`s_bfe_u32` & `v_bfe_u32` width wrapping**: adds `s_bfe_u32` GPU/WARP cases in `valu_tests` and verifies 5-bit `width = 32 -> 0` masking for `v_bfe_u32` alongside `v_bfe_i32`. - **`SCC` condition-code output (`D != 0`)**: verifies `SCC` for both `s_bfe_i32` (not previously checked via `sop2_probe`) and `s_bfe_u32` through `s_cselect_b32`. - **32-bit literal `src1` (`0xFF`)**: exercises literal `offset | (width << 16)` operands for both `0x27` and `0x28` (value and `SCC`). - **Ignored bits & `width = 64` boundary**: verifies hardware masking of unused `src1[15:5]` and `src1[31:23]` bits (`0xFF80_FFE0`) and `width = 64` (where `width >= 32` while `width & 31 == 0`). ### Testing - `cargo test -p victory-shader --locked bfe_signed_and_unsigned_match_rdna2` across hardware D3D12 adapters (RTX 5090, RDNA2), WARP, and `dxil.dll` validation. - `cargo clippy --workspace --all-targets --all-features -- -D warnings` and `cargo xtask policy`.
catminou4 commented 2026-11-25 05:05:52 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by catminou4 on 2026-11-25T04:33:49Z.

Review: APPROVED


Tested locally: macOS arm64, rustc 1.98.1, PR head merged into main 940d32f69b, cargo test -p victory-shader --locked.

144 passed / 0 failed / 2 ignored. s_bfe_u32/s_bfe_i32 SCC coverage, literal src1, dirty-bit handling — BFE opcode completeness.

<!-- greyfinch-sync:Marvisak/VIctory:review:6051901128 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2060#pullrequestreview-6051901128). Originally posted by [catminou4](https://github.com/catminou4) on 2026-11-25T04:33:49Z. **Review:** APPROVED --- Tested locally: macOS arm64, rustc 1.98.1, PR head merged into main 940d32f69b, `cargo test -p victory-shader --locked`. 144 passed / 0 failed / 2 ignored. s_bfe_u32/s_bfe_i32 SCC coverage, literal src1, dirty-bit handling — BFE opcode completeness.
DenRakEiw commented 2026-11-25 05:05:52 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by DenRakEiw on 2026-11-25T04:36:27Z.

Review: APPROVED


Verified locally merged onto origin/main (940d32f, Windows 11 x64, NVIDIA GeForce RTX 5090 + WARP, Rust 1.98.1 MSVC, with dxil.dll validator):

  • cargo test -p victory-shader --lib bfe — passed on both RTX 5090 hardware and VICTORY_D3D12_WARP=1
  • cargo clippy -p victory-shader --all-targets — 0 warnings
  • cargo xtask policy — ok (183 files ok)

Thorough end-to-end GPU+WARP test coverage for s_bfe_u32/s_bfe_i32 SCC, literal src1, dirty upper bits, and width >= 32. Looks good.

AI-assisted (Gemini 4 Neon).

<!-- greyfinch-sync:Marvisak/VIctory:review:6051919536 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2060#pullrequestreview-6051919536). Originally posted by [DenRakEiw](https://github.com/DenRakEiw) on 2026-11-25T04:36:27Z. **Review:** APPROVED --- Verified locally merged onto `origin/main` (`940d32f`, Windows 11 x64, NVIDIA GeForce RTX 5090 + WARP, Rust 1.98.1 MSVC, with `dxil.dll` validator): - `cargo test -p victory-shader --lib bfe` — passed on both RTX 5090 hardware and `VICTORY_D3D12_WARP=1` - `cargo clippy -p victory-shader --all-targets` — 0 warnings - `cargo xtask policy` — ok (`183 files ok`) Thorough end-to-end GPU+WARP test coverage for `s_bfe_u32`/`s_bfe_i32` SCC, literal `src1`, dirty upper bits, and `width >= 32`. Looks good. AI-assisted (Gemini 4 Neon).
jeremygold02 commented 2026-11-25 05:06:16 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by jeremygold02 on 2026-11-25T04:20:23Z.


Triage verdict — Keep the expanded coverage as a standalone test change (a3479b2)

Evidence

  • main already covers the unsigned scalar value and SCC cases described in #803. @fuzeofficlal’s additional cases cover signed SCC, literal operands, ignored packed bits, and the width-64 wrapping boundary. Those assertions add coverage beyond the original issue. Existing scalar coverage · Expanded fixture

Checks and limits

  • The exact-head focused test passed independently. Hardware D3D12 and WARP both ran the synthetic shader cases. I did not separately require the optional DXIL validator in this run.

Next step

  • Keep the incremental cases together as a test-only change. The maintainer can resolve #803 based on the existing scalar coverage and review these additional assertions on their own merits.

This verification was AI-assisted.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7152752706 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2060#issuecomment-7152752706). Originally posted by [jeremygold02](https://github.com/jeremygold02) on 2026-11-25T04:20:23Z. --- **Triage verdict — Keep the expanded coverage as a standalone test change** (`a3479b2`) **Evidence** - `main` already covers the unsigned scalar value and SCC cases described in #803. @fuzeofficlal’s additional cases cover signed SCC, literal operands, ignored packed bits, and the width-64 wrapping boundary. Those assertions add coverage beyond the original issue. [Existing scalar coverage](https://github.com/Marvisak/VIctory/commit/328eec1ce3af6de07dedc381a075e6a567a0afc1) · [Expanded fixture](https://github.com/Marvisak/VIctory/blob/a3479b252b005ddeae50b1fcba727506282036da/crates/victory-shader/src/emit/valu_tests.rs#L1099-L1280) **Checks and limits** - The exact-head focused test passed independently. Hardware D3D12 and WARP both ran the synthetic shader cases. I did not separately require the optional DXIL validator in this run. **Next step** - Keep the incremental cases together as a test-only change. The maintainer can resolve #803 based on the existing scalar coverage and review these additional assertions on their own merits. This verification was AI-assisted.
Marvisak commented 2026-11-25 10:07:42 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Marvisak on 2026-11-25T09:25:09Z.


Automated triage for the maintainers.
Merge candidate.

This only adds tests. It extends bfe_signed_and_unsigned_match_rdna2 in crates/victory-shader/src/emit/valu_tests.rs (#803) with:

  • s_bfe_u32 values
  • SCC for both scalar BFEs, read through s_cselect_b32
  • literal src1, with the unused bits [15:5] and [31:23] set
  • widths 32/64/127 for the scalar ops (7-bit width field)
  • the 5-bit width wrap of v_bfe_u32

I checked the expected values by hand against the documented RDNA2 BFE formula, (S0 >> S1[4:0]) & ((1 << S1[22:16]) - 1) with SCC = result != 0. The values follow that formula rather than just matching Lower::bfe in lower.rs. The width ≥ 32 → full-mask reading matches the width-32 case main already asserts. No other open PR adds these cases.

CI: passing (check).

Recommending a look, not approving.


Generated by Claude Code

<!-- greyfinch-sync:Marvisak/VIctory:comment:7158303207 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2060#issuecomment-7158303207). Originally posted by [Marvisak](https://github.com/Marvisak) on 2026-11-25T09:25:09Z. --- <!-- victory-triage v1 head=a3479b252b005ddeae50b1fcba727506282036da verdict=merge-candidate at=2026-11-25T09:25:02Z --> Automated triage for the maintainers. **Merge candidate.** This only adds tests. It extends `bfe_signed_and_unsigned_match_rdna2` in `crates/victory-shader/src/emit/valu_tests.rs` (#803) with: - `s_bfe_u32` values - SCC for both scalar BFEs, read through `s_cselect_b32` - literal `src1`, with the unused bits `[15:5]` and `[31:23]` set - widths 32/64/127 for the scalar ops (7-bit width field) - the 5-bit width wrap of `v_bfe_u32` I checked the expected values by hand against the documented RDNA2 BFE formula, `(S0 >> S1[4:0]) & ((1 << S1[22:16]) - 1)` with SCC = result != 0. The values follow that formula rather than just matching `Lower::bfe` in `lower.rs`. The width ≥ 32 → full-mask reading matches the width-32 case `main` already asserts. No other open PR adds these cases. CI: passing (`check`). Recommending a look, not approving. --- _Generated by [Claude Code](https://claude.ai/code)_
sinan-cmyk commented 2026-11-25 10:07:43 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by sinan-cmyk on 2026-11-25T09:26:50Z.


Offline measurement on a retail dump

Result: no count change against main.

I merged head a3479b25 onto main 940d32f (clean merge) and ran victory translate --validate --list on shaders.rpf (1.0.2.1), with dxil.dll 1.8.2502.11. I compared the result with main program by program (25,889 programs). Validated: 23,918 on main, 23,918 with this PR.

No program changes its failure reason. The count shows that the change rejects nothing on this data. It does not show whether the output is right.

No shader names or data are included, per the asset policy. AI-assisted (Claude Code).

<!-- greyfinch-sync:Marvisak/VIctory:comment:7158341381 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2060#issuecomment-7158341381). Originally posted by [sinan-cmyk](https://github.com/sinan-cmyk) on 2026-11-25T09:26:50Z. --- ### Offline measurement on a retail dump **Result: no count change against `main`.** I merged head a3479b25 onto `main` 940d32f (clean merge) and ran `victory translate --validate --list` on `shaders.rpf` (1.0.2.1), with dxil.dll 1.8.2502.11. I compared the result with `main` program by program (25,889 programs). Validated: 23,918 on `main`, 23,918 with this PR. No program changes its failure reason. The count shows that the change rejects nothing on this data. It does not show whether the output is right. No shader names or data are included, per the asset policy. AI-assisted (Claude Code).
upstream-sync closed this pull request 2026-11-25 22:03:24 +00:00
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!2058
No description provided.