Skip to content

Shaders: lower V_SAT_PK_U8_I16 - #3146

Closed
andrewpozdnakov7-jpg wants to merge 1 commit into
Marvisak:mainfrom
andrewpozdnakov7-jpg:fix/sat-pack-u8-i16
Closed

andrewpozdnakov7-jpg wants to merge 1 commit into
Marvisak:mainfrom
andrewpozdnakov7-jpg:fix/sat-pack-u8-i16

Conversation

@andrewpozdnakov7-jpg

Copy link
Copy Markdown
Contributor

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 <andrewpozdnakov7-jpg@users.noreply.github.com>.

@andrewpozdnakov7-jpg
andrewpozdnakov7-jpg marked this pull request as draft November 26, 2026 10:24
@andrewpozdnakov7-jpg

Copy link
Copy Markdown
Contributor Author

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.

@oni-swr

oni-swr commented Nov 26, 2026

Copy link
Copy Markdown

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

Coordinated under #1633 (claim: #1633 (comment)).

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants