Shaders: lower V_SAT_PK_U8_I16 #3146

Closed
github-bot wants to merge 1 commit from gh-pr/3146/head into gh-pr/3146/base
Owner

@⁠andrewpozdnakov7-jpg on GitHub · 2026-11-26 10:15 UTC · original
andrewpozdnakov7-jpg:fix/sat-pack-u8-i16 → main · +48 −0 · 2 files · 1 commits · closed without merging

V_SAT_PK_U8_I16 decodes in both VOP1 and VOP3 forms, but shader translation on main returns Unsupported. Interpret both input halves as signed i16, clamp each to [0, 255], and pack the bytes into the low half of the result. AMD RDNA 2 ISA, section 12.8

The synthetic shader checks all 81 pairs of nine boundary values for each encoding, including the cleared upper 16 bits. The same test reproduced Unsupported on main and passed on WARP after the change. All 36 VALU tests passed on WARP. Strict Clippy for victory-shader and cargo xtask policy passed.

AI-assisted with Codex. Please retain the Git author when cherry-picking or rebasing. If folded into another commit, please add Co-authored-by: andrewpozdnakov7-jpg <[email protected]>.

**@⁠andrewpozdnakov7-jpg** on GitHub · 2026-11-26 10:15 UTC · [original](https://github.com/Marvisak/VIctory/pull/3146) `andrewpozdnakov7-jpg:fix/sat-pack-u8-i16` → `main` · +48 −0 · 2 files · 1 commits · closed without merging `V_SAT_PK_U8_I16` decodes in both VOP1 and VOP3 forms, but shader translation on main returns `Unsupported`. Interpret both input halves as signed i16, clamp each to [0, 255], and pack the bytes into the low half of the result. [AMD RDNA 2 ISA, section 12.8](https://docs.amd.com/api/khub/documents/Et~wpu9g~Ffl7d9q0QZ~Og/content) The synthetic shader checks all 81 pairs of nine boundary values for each encoding, including the cleared upper 16 bits. The same test reproduced `Unsupported` on main and passed on WARP after the change. All 36 VALU tests passed on WARP. Strict Clippy for victory-shader and `cargo xtask policy` passed. AI-assisted with Codex. Please retain the Git author when cherry-picking or rebasing. If folded into another commit, please add `Co-authored-by: andrewpozdnakov7-jpg <[email protected]>`.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 11:08:33 +00:00
github-bot closed this pull request 2026-11-26 11:08:33 +00:00
Author
Owner

@⁠andrewpozdnakov7-jpg on GitHub · 2026-11-26 10:28 UTC · original

The original PR is #499. The full-dword result is confirmed by the RDNA2 hardware report. I sent the tested, author-preserving replay there and am closing this duplicate.

**@⁠andrewpozdnakov7-jpg** on GitHub · 2026-11-26 10:28 UTC · [original](https://github.com/Marvisak/VIctory/pull/3146#issuecomment-7189406402) The original PR is #499. The full-dword result is confirmed by the [RDNA2 hardware report](https://git.gtahub.st/github/Marvisak--VIctory/pulls/499). I sent the [tested, author-preserving replay](https://git.gtahub.st/github/Marvisak--VIctory/pulls/499) there and am closing this duplicate.
Author
Owner

@⁠oni-swr on GitHub · 2026-11-26 10:28 UTC · original

WARP test report: head 078c53a6 (parent / main 63bcca43)

Coordinated under #1633 (claim: #1633).

Environment (software adapter only, no physical GPU used): Windows 11 Pro 10.0.26200 (UBR 9974); d3d10warp.dll 10.0.26100.9818; SDK dxil.dll 1.8.2502.11 (Windows SDK 10.0.26100.0, VICTORY_DXIL); dxc.exe/dxcompiler.dll 1.8.2502.11; rustc/cargo 1.98.1. VICTORY_D3D12_WARP=1 VICTORY_WARP=1 (the second forces the victory-shader test host onto WARP, which otherwise also opens the default hardware adapter). A temporary local probe confirmed DXGI reports the adapter as Microsoft Basic Render Driver (flags 0x2 software, vendor 0x1414, 0 dedicated VRAM). Every hardware label in the output below therefore also ran on WARP. Shared env for all commands: CARGO_TARGET_DIR=D:\victory-3146-3142-warp-target, -j 4.

Parent control (63bcca4 + this PR's valu_tests.rs only):
cargo test -p victory-shader --lib -j 4 -- sat_pk_u8_i16 --nocapture -> the PR's test fails with build: Unsupported { offset: 36, what: "v_sat_pk_u8_i16" } (0 passed, 2 failed incl. my local sweep below). Matches the PR description.

Head 078c53a6:

  • Same command: sat_pk_u8_i16_clamps_signed_halves_into_low_bytes ... ok (81 pairs x VOP1 and VOP3).
  • Temporary local sweep, not pushed (independent oracle from the ISA text: each half signed i16, clamp to [0,255], low byte | high byte << 8, upper 16 bits zero): 3000 xorshift-random words plus a step-257 sweep of all 16-bit patterns in the low half, high half and both halves, 3768 words per encoding, VOP1 and VOP3: 7536 checks per encoding (two host labels, both WARP), 0 mismatches. On the parent the same sweep fails with the same Unsupported.
  • cargo test -p victory-shader --lib -j 4 -- emit::valu_tests: 37 passed, 0 failed (includes the local sweep).
  • Full cargo test -p victory-shader --lib -j 4: 301 passed, 4 failed, 3 ignored. The 4 failures (synthetic_tests::{gathers_at_a_level_match_the_hardware, permutes_mask_high_address_bits_and_divergent_branches, permutes_read_the_lane_named_and_zero_from_lanes_left_out, a_mask_joined_with_data_at_a_uniform_loop_is_its_number}) are the same four that fail on the parent (299 passed, 6 failed there: those 4 plus the two new tests). They are hardware-only checks, which I forced onto WARP, so they are not attributable to this PR.
  • cargo test -p victory-gpu --lib --features diagnostics -j 4: 246 passed, 0 failed, 1 ignored, 3 of 3 runs. One earlier run on the parent showed 1 failure (descriptor::host::tests::a_slot_rewritten_while_its_view_is_prepared_views_the_new_record) that did not recur in 3 further parent runs, so I treat it as a flake unrelated to this PR.

Not run: Clippy, cargo xtask policy, any real-GPU run, and anything using game files.

Result: the lowering matches the ISA semantics on WARP for both encodings; no defect found.

AI use: tested by Claude Code (Claude Sonnet 5.5), coordinated by Claude Code (Claude Opus 5.5). No game files, dumps, shader names or hashes were used.

**@⁠oni-swr** on GitHub · 2026-11-26 10:28 UTC · [original](https://github.com/Marvisak/VIctory/pull/3146#issuecomment-7189415339) ## WARP test report: head `078c53a6` (parent / main `63bcca43`) Coordinated under #1633 (claim: https://git.gtahub.st/github/Marvisak--VIctory/issues/1633). **Environment (software adapter only, no physical GPU used):** Windows 11 Pro 10.0.26200 (UBR 9974); `d3d10warp.dll` 10.0.26100.9818; SDK `dxil.dll` 1.8.2502.11 (Windows SDK 10.0.26100.0, `VICTORY_DXIL`); `dxc.exe`/`dxcompiler.dll` 1.8.2502.11; rustc/cargo 1.98.1. `VICTORY_D3D12_WARP=1 VICTORY_WARP=1` (the second forces the victory-shader test host onto WARP, which otherwise also opens the default hardware adapter). A temporary local probe confirmed DXGI reports the adapter as `Microsoft Basic Render Driver` (flags 0x2 software, vendor 0x1414, 0 dedicated VRAM). Every `hardware` label in the output below therefore also ran on WARP. Shared env for all commands: `CARGO_TARGET_DIR=D:\victory-3146-3142-warp-target`, `-j 4`. **Parent control (`63bcca4` + this PR's `valu_tests.rs` only):** `cargo test -p victory-shader --lib -j 4 -- sat_pk_u8_i16 --nocapture` -> the PR's test fails with `build: Unsupported { offset: 36, what: "v_sat_pk_u8_i16" }` (0 passed, 2 failed incl. my local sweep below). Matches the PR description. **Head `078c53a6`:** - Same command: `sat_pk_u8_i16_clamps_signed_halves_into_low_bytes ... ok` (81 pairs x VOP1 and VOP3). - Temporary local sweep, not pushed (independent oracle from the ISA text: each half signed i16, clamp to [0,255], low byte | high byte << 8, upper 16 bits zero): 3000 xorshift-random words plus a step-257 sweep of all 16-bit patterns in the low half, high half and both halves, 3768 words per encoding, VOP1 and VOP3: 7536 checks per encoding (two host labels, both WARP), 0 mismatches. On the parent the same sweep fails with the same `Unsupported`. - `cargo test -p victory-shader --lib -j 4 -- emit::valu_tests`: 37 passed, 0 failed (includes the local sweep). - Full `cargo test -p victory-shader --lib -j 4`: 301 passed, 4 failed, 3 ignored. The 4 failures (`synthetic_tests::{gathers_at_a_level_match_the_hardware, permutes_mask_high_address_bits_and_divergent_branches, permutes_read_the_lane_named_and_zero_from_lanes_left_out, a_mask_joined_with_data_at_a_uniform_loop_is_its_number}`) are the same four that fail on the parent (299 passed, 6 failed there: those 4 plus the two new tests). They are hardware-only checks, which I forced onto WARP, so they are not attributable to this PR. - `cargo test -p victory-gpu --lib --features diagnostics -j 4`: 246 passed, 0 failed, 1 ignored, 3 of 3 runs. One earlier run on the parent showed 1 failure (`descriptor::host::tests::a_slot_rewritten_while_its_view_is_prepared_views_the_new_record`) that did not recur in 3 further parent runs, so I treat it as a flake unrelated to this PR. **Not run:** Clippy, `cargo xtask policy`, any real-GPU run, and anything using game files. **Result:** the lowering matches the ISA semantics on WARP for both encodings; no defect found. AI use: tested by Claude Code (Claude Sonnet 5.5), coordinated by Claude Code (Claude Opus 5.5). No game files, dumps, shader names or hashes were used.

Pull request closed

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!3146
No description provided.