Shaders: hardware test for the 16-bit integer ops #1875

Open
LouisRiverstone wants to merge 2 commits from upstream-pr/1877 into main
LouisRiverstone commented 2026-11-24 23:58:53 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by LouisRiverstone on 2026-11-24T23:58:53Z.


v_add_nc_u16, v_sub_nc_u16, v_mul_lo_u16, v_lshrrev_b16, v_ashrrev_i16, v_lshlrev_b16, v_max_u16, v_max_i16, v_min_u16 and v_min_i16 (VOP3 0x303..0x30c, 0x314) are lowered in lower.rs through one arm that works on the low halves, sign-extending for the i16 forms and masking the shift amount to four bits. No hardware test ran them.

New test v_16_bit_integer_ops_match_rdna2 runs all 64 ordered pairs of eight 16-bit values (the sign boundary, shift amounts 16 and 17, all-ones) through each op, with garbage in the high halves of the sources. The result's low half is compared with u16 operations in Rust.

Test only, no production change.

Verify: cargo test -p victory-shader v_16_bit_integer (Windows, hardware GPU or WARP). I type-checked it with clippy for x86_64-pc-windows-msvc, but could not run it locally: the shader test module is Windows-only.

🤖 Generated with Claude Code

<!-- greyfinch-sync:Marvisak/VIctory:issue:5482437013 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1877). Originally posted by [LouisRiverstone](https://github.com/LouisRiverstone) on 2026-11-24T23:58:53Z. --- `v_add_nc_u16`, `v_sub_nc_u16`, `v_mul_lo_u16`, `v_lshrrev_b16`, `v_ashrrev_i16`, `v_lshlrev_b16`, `v_max_u16`, `v_max_i16`, `v_min_u16` and `v_min_i16` (VOP3 0x303..0x30c, 0x314) are lowered in `lower.rs` through one arm that works on the low halves, sign-extending for the `i16` forms and masking the shift amount to four bits. No hardware test ran them. New test `v_16_bit_integer_ops_match_rdna2` runs all 64 ordered pairs of eight 16-bit values (the sign boundary, shift amounts 16 and 17, all-ones) through each op, with garbage in the high halves of the sources. The result's low half is compared with `u16` operations in Rust. Test only, no production change. **Verify:** `cargo test -p victory-shader v_16_bit_integer` (Windows, hardware GPU or WARP). I type-checked it with clippy for `x86_64-pc-windows-msvc`, but could not run it locally: the shader test module is Windows-only. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
catminou4 commented 2026-11-25 02:09:55 +00:00 (Migrated from github.com)

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

Review: APPROVED


Tested locally on macOS arm64 (rustc 1.98.1): PR head merged cleanly into current main (940d32f), cargo test → 144 passed, 0 failed. GPU execution tests are #[cfg(all(test, windows))] and run only on Windows.

victory-shader. Hardware test for the 16-bit integer ops: RDNA2-matched (Windows-gated).

<!-- greyfinch-sync:Marvisak/VIctory:review:6050606005 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1877#pullrequestreview-6050606005). Originally posted by [catminou4](https://github.com/catminou4) on 2026-11-25T02:09:55Z. **Review:** APPROVED --- Tested locally on macOS arm64 (rustc 1.98.1): PR head merged cleanly into current main (940d32f), cargo test → 144 passed, 0 failed. GPU execution tests are #[cfg(all(test, windows))] and run only on Windows. victory-shader. Hardware test for the 16-bit integer ops: RDNA2-matched (Windows-gated).
Marvisak commented 2026-11-25 09:06:11 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Marvisak on 2026-11-25T08:18:53Z.


Automated triage for the maintainers.

Merge candidate (recommending a look, not an approval). Reviewed at 9520cf3, which merges cleanly into main. Test only: v_16_bit_integer_ops_match_rdna2 in crates/victory-shader/src/emit/valu_tests.rs.

The ten opcodes match gfx10/opcodes.rs, and the expected values follow the RDNA2 definitions: low halves only, i16 forms signed, and the shifts take a 4-bit amount from the first operand with the value in the second. That is what the _ => 16-bit arm of emit/lower.rs implements. The high halves of the sources are filled with garbage, and only the low half of the result is compared. CI: check passing.

Nit, not blocking: vop3(...) is built twice per op to take [0] and [1]. Binding it once would read better.


Generated by Claude Code

<!-- greyfinch-sync:Marvisak/VIctory:comment:7156872433 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1877#issuecomment-7156872433). Originally posted by [Marvisak](https://github.com/Marvisak) on 2026-11-25T08:18:53Z. --- <!-- victory-triage v1 head=9520cf3a4e3043d3199b31248fbe7d5aa084c17d verdict=merge-candidate at=2026-11-26T02:18:00Z --> Automated triage for the maintainers. **Merge candidate** (recommending a look, not an approval). Reviewed at `9520cf3`, which merges cleanly into `main`. Test only: `v_16_bit_integer_ops_match_rdna2` in `crates/victory-shader/src/emit/valu_tests.rs`. The ten opcodes match `gfx10/opcodes.rs`, and the expected values follow the RDNA2 definitions: low halves only, `i16` forms signed, and the shifts take a 4-bit amount from the first operand with the value in the second. That is what the `_ =>` 16-bit arm of `emit/lower.rs` implements. The high halves of the sources are filled with garbage, and only the low half of the result is compared. CI: `check` passing. Nit, not blocking: `vop3(...)` is built twice per op to take `[0]` and `[1]`. Binding it once would read better. --- _Generated by [Claude Code](https://claude.ai/code)_
sinan-cmyk commented 2026-11-25 12:03:56 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by sinan-cmyk on 2026-11-25T11:55:45Z.


Offline measurement on a retail dump

Result: no count change against main.

I merged head 85af2ca2 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:7161692026 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1877#issuecomment-7161692026). Originally posted by [sinan-cmyk](https://github.com/sinan-cmyk) on 2026-11-25T11:55:45Z. --- ### Offline measurement on a retail dump **Result: no count change against `main`.** I merged head 85af2ca2 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).
fuzeofficlal commented 2026-11-26 19:35:50 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by fuzeofficlal on 2026-11-26T19:35:50Z.

Review: APPROVED


Looks good to me — solid test coverage for the 10 lowered VOP3 16-bit integer ops, with the first Windows hardware + WARP run confirming they pass.

Verified locally on Windows 11 with head 9520cf3a cleanly merged onto main (63bcca43):

  • Audited v_16_bit_integer_ops_match_rdna2 (crates/victory-shader/src/emit/valu_tests.rs:1313-1356) against gfx10/opcodes.rs and RDNA2 ISA: all 10 opcodes (0x303..=0x305, 0x307..=0x30C, 0x314), operand ordering (src0 = v1 shift count / left operand, src1 = v2 shifted value / right operand), sign-extension for i16 forms, 4-bit shift masking (& 15), and high-half source garbage (0xABCD_0000 | a, 0x1234_0000 | b) match expected semantics.
  • Formatting check (rustfmt --edition 2024 --config skip_children=true) shows no diffs on the added lines.
  • cargo run -p xtask -- policy (191 files ok) and cargo clippy --locked -p victory-shader --all-targets -- -D warnings (both default and --all-features) pass.
  • cargo test --locked -p victory-shader --lib v_16_bit_integer_ops_match_rdna2 passes on both VICTORY_WARP=0 (RTX 5090, 32.57s) and VICTORY_WARP=1 (WARP, 0.56s): 1 passed; 0 failed (305 filtered out).

Two minor non-blocking notes:

  • v0 is zero-initialized (vop1(0x001, 0, 128)) and the assertion masks got & 0xFFFF, so upper-half preservation in v0[31:16] is left untested here.
  • The comment at valu_tests.rs:1314 writes 0x303..0x30c, which spans 0x306 (not present in gfx10/opcodes.rs or tested).
<!-- greyfinch-sync:Marvisak/VIctory:review:6079607127 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1877#pullrequestreview-6079607127). Originally posted by [fuzeofficlal](https://github.com/fuzeofficlal) on 2026-11-26T19:35:50Z. **Review:** APPROVED --- Looks good to me — solid test coverage for the 10 lowered VOP3 16-bit integer ops, with the first Windows hardware + WARP run confirming they pass. Verified locally on Windows 11 with head `9520cf3a` cleanly merged onto `main` (`63bcca43`): - Audited `v_16_bit_integer_ops_match_rdna2` (`crates/victory-shader/src/emit/valu_tests.rs:1313-1356`) against `gfx10/opcodes.rs` and RDNA2 ISA: all 10 opcodes (`0x303..=0x305`, `0x307..=0x30C`, `0x314`), operand ordering (`src0 = v1` shift count / left operand, `src1 = v2` shifted value / right operand), sign-extension for `i16` forms, 4-bit shift masking (`& 15`), and high-half source garbage (`0xABCD_0000 | a`, `0x1234_0000 | b`) match expected semantics. - Formatting check (`rustfmt --edition 2024 --config skip_children=true`) shows no diffs on the added lines. - `cargo run -p xtask -- policy` (`191 files ok`) and `cargo clippy --locked -p victory-shader --all-targets -- -D warnings` (both default and `--all-features`) pass. - `cargo test --locked -p victory-shader --lib v_16_bit_integer_ops_match_rdna2` passes on both `VICTORY_WARP=0` (RTX 5090, `32.57s`) and `VICTORY_WARP=1` (WARP, `0.56s`): `1 passed; 0 failed` (`305 filtered out`). Two minor non-blocking notes: - `v0` is zero-initialized (`vop1(0x001, 0, 128)`) and the assertion masks `got & 0xFFFF`, so upper-half preservation in `v0[31:16]` is left untested here. - The comment at `valu_tests.rs:1314` writes `0x303..0x30c`, which spans `0x306` (not present in `gfx10/opcodes.rs` or tested).
Dukestar69 commented 2026-11-26 23:48:52 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Dukestar69 on 2026-11-26T23:48:52Z.

Review: APPROVED


LGTM — verified on RTX 5090 and VICTORY_WARP=1 (Windows / D3D12) against origin/main (63bcca4).

  • Hardware test v_16_bit_integer_ops_match_rdna2 passes cleanly on both discrete NVIDIA hardware and WARP.
  • cargo test -p victory-shader --lib v_16_bit_integer_ops_match_rdna2 -- --test-threads=1: passed on RTX 5090 and VICTORY_WARP=1.
  • cargo clippy -p victory-shader --all-targets -- -D warnings: clean.
  • cargo xtask policy: 191 files ok.

Synthetic tests only (no game files used). AI-assisted (Gemini 4 Neon).

<!-- greyfinch-sync:Marvisak/VIctory:review:6081666888 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1877#pullrequestreview-6081666888). Originally posted by [Dukestar69](https://github.com/Dukestar69) on 2026-11-26T23:48:52Z. **Review:** APPROVED --- LGTM — verified on RTX 5090 and `VICTORY_WARP=1` (Windows / D3D12) against `origin/main` (`63bcca4`). - Hardware test `v_16_bit_integer_ops_match_rdna2` passes cleanly on both discrete NVIDIA hardware and WARP. - `cargo test -p victory-shader --lib v_16_bit_integer_ops_match_rdna2 -- --test-threads=1`: passed on RTX 5090 and `VICTORY_WARP=1`. - `cargo clippy -p victory-shader --all-targets -- -D warnings`: clean. - `cargo xtask policy`: 191 files ok. Synthetic tests only (no game files used). AI-assisted (Gemini 4 Neon).
andrewpozdnakov7-jpg commented 2026-11-27 01:00:40 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by andrewpozdnakov7-jpg on 2026-11-27T01:00:40Z.


I ran the exact 9520cf3 test on Windows with app-local WARP 1.0.22 and DXIL validation. All ten instructions and 64 ordered input pairs passed in three fresh processes.

The test-only follow-up exercises all eight selections of source and destination halves. It initializes the destination with two different sentinels and compares the full 32-bit result, so a write to the wrong half or a clobbered neighboring half fails. All 5,120 comparisons passed per run in three WARP processes. The 37 VALU tests, strict clippy in both configurations, and asset policy also passed. AMD lists these operations under VOP3 OPSEL support.

@LouisRiverstone the test is ready to pick up. A native RDNA2 run would provide an independent check of the same words. Please retain the Git author or add Co-authored-by: andrewpozdnakov7-jpg if folding the change.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7206935076 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1877#issuecomment-7206935076). Originally posted by [andrewpozdnakov7-jpg](https://github.com/andrewpozdnakov7-jpg) on 2026-11-27T01:00:40Z. --- I ran the exact `9520cf3` test on Windows with app-local WARP 1.0.22 and DXIL validation. All ten instructions and 64 ordered input pairs passed in three fresh processes. The [test-only follow-up](https://github.com/andrewpozdnakov7-jpg/VIctory/commit/065b31d02062bee303aa1e5b8d3d86a81171720b) exercises all eight selections of source and destination halves. It initializes the destination with two different sentinels and compares the full 32-bit result, so a write to the wrong half or a clobbered neighboring half fails. All 5,120 comparisons passed per run in three WARP processes. The 37 VALU tests, strict clippy in both configurations, and asset policy also passed. AMD lists these operations under [VOP3 OPSEL support](https://www.amd.com/content/dam/amd/en/documents/radeon-tech-docs/instruction-set-architectures/rdna2-shader-instruction-set-architecture.pdf#page=45). @LouisRiverstone the test is ready to pick up. A native RDNA2 run would provide an independent check of the same words. Please retain the Git author or add `Co-authored-by: andrewpozdnakov7-jpg` if folding the change.
This pull request cannot be merged automatically due to conflicts.
Merge manually to resolve the conflicts.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin 'upstream-pr/1877:upstream-pr/1877'
git switch 'upstream-pr/1877'

Merge

Merge the changes and update on Forgejo.

Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.

git switch 'main'
git merge --no-ff 'upstream-pr/1877'
git switch 'upstream-pr/1877'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/1877'
git switch 'upstream-pr/1877'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/1877'
git switch 'main'
git merge --squash 'upstream-pr/1877'
git switch 'main'
git merge --ff-only 'upstream-pr/1877'
git switch 'main'
git merge 'upstream-pr/1877'
git push origin 'main'
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!1875
No description provided.