Repository navigation
Conversation
|
Ran on RDNA2 hardware through vkd3d-proton on a Steam Deck (not native Windows): AMD Van Gogh, RADV 26.1.99, SteamOS 3.8.28, Proton 11.0-3 (wine-11.0) with its vkd3d-proton 212991fc. Windows MSVC test binary (rustc 1.100.0) built from head
Not tested: native Windows AMD drivers; WARP (this setup has none, so the WARP leg ran on RADV too); whether the new test fails without the fix on this host. AI-assisted (Claude Code, Claude Opus 5.5); no game data. |
…fied together Merges Marvisak#156 Marvisak#162 Marvisak#168 Marvisak#169 Marvisak#368 Marvisak#379 Marvisak#456 Marvisak#587 Marvisak#990 Marvisak#1021 Marvisak#1048 Marvisak#1052 Marvisak#1053 Marvisak#1095 Marvisak#1142 Marvisak#1190 Marvisak#1211 Marvisak#1223 Marvisak#1259 Marvisak#1293 on top of the bundle of Marvisak#1402 (which is on Marvisak#1319, on main ffe310e), each head unchanged. Hunks that conflicted in emit/lower.rs, emit/valu_tests.rs and emit/diff_tests.rs were merged by keeping both sides (additions next to each other); a PR was kept only if cargo clippy -p victory-shader --all-targets -- -D warnings still passed with it. No instruction name is handled in two places. Marvisak#98 is not in this version: an offline measurement on a retail dump showed it loses 31 programs that validate on Marvisak#1402. cargo clippy --workspace --all-targets --locked -- -D warnings, with and without --all-features, is clean and cargo test --workspace --locked passes (381 passed, 6 ignored; main has 342 passed, 6 ignored). Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
|
Automated triage for the maintainers. Merge candidate (recommending a look, not approving). Thanks for the rebase: the branch now merges cleanly onto Generated by Claude Code |
|
Rebased onto \main\ (\940d32f) at $sha. Verified on RTX 3060 Ti + WARP: \�_pk_int16_clamp_saturates_as_rdna2\ passed, strict Clippy (--all-targets\ and --all-features) clean, \cargo xtask policy\ ok. |
bf873ff to
f76cf2b
Compare
…{add,sub,mad}_{u16,i16})
AI-generated & verified with Gemini 4 Neon (High Mode) — not written by a human engineer.
`packed16` in `lower.rs` previously rejected `v.clamp` on all packed 16-bit
integer instructions with `Err("modifiers on a packed integer operation")`.
Under the AMD RDNA2 ISA (VOP3P), `clamp` on `v_pk_add_u16`, `v_pk_sub_u16`,
`v_pk_mad_u16`, `v_pk_add_i16`, `v_pk_sub_i16`, and `v_pk_mad_i16` saturates
each 16-bit lane to `[0, 65535]` (unsigned) or `[-32768, 32767]` (signed).
Because `packed16` computes each lane in 32 bits (`u16*u16+u16 <= u32::MAX`,
`i16*i16+i16` fits in `i32`), saturation is exact in 32-bit integer compares
before masking to 16 bits. Non-saturating packed integer ops keep rejecting
`clamp`.
Verified with synthetic GPU + WARP + dxil.dll tests in `valu_tests.rs` on
NVIDIA GeForce RTX 3060 Ti (Windows 11, Rust 1.98.1). No game data used.
Co-Authored-By: Gemini 4 Neon (High Mode) <noreply@google.com>
f76cf2b to
de11155
Compare
fuzeofficlal
left a comment
There was a problem hiding this comment.
The saturation ranges and signedness checks look right for all six packed integer ops (v_pk_{add,sub,mad}_{u16,i16}): mad_u16 peaks at 0xffff_0000 (fitting in u32 so IUGT catches overflow without wrap), sub_u16 spans [-65535, 65535] (so SLT against 0 catches underflow), and all three signed ops stay strictly within i32 before clamping to [i16::MIN, i16::MAX]. Source OPSEL/OPSEL_HI selection and wrapping when clamp is clear remain intact, and mul_lo_u16/min/max/shifts still reject clamp.
As optional follow-up coverage, a non-default OPSEL/OPSEL_HI test and a CLAMP=0 wrap-around case would pin those paths as well.
Local verification at de111550 (and merged cleanly onto origin/main 63bcca43, emit/lower.rs = 522,255 B, 2,033 B under the 512 KiB cap): xtask policy (191 files ok), cargo clippy -p victory-shader --all-targets (default and --all-features), emit::valu_tests on both RTX 5090 and WARP (36/36), and v_pk_int16_clamp_saturates_as_rdna2 on RTX 5090 and WARP all passed.
Dukestar69
left a comment
There was a problem hiding this comment.
LGTM — verified on RTX 5090 and VICTORY_WARP=1 (Windows / D3D12) against origin/main (63bcca4).
- Supporting saturating
CLAMPon packed 16-bit integer ops (v_pk_{add,sub,mad}_{u16,i16}) matches RDNA2 semantics cleanly on both discrete NVIDIA hardware and WARP. cargo test -p victory-shader --lib emit::valu_tests::v_pk_int16_clamp_saturates_as_rdna2 -- --test-threads=1: passed on RTX 5090 andVICTORY_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).
What's wrong
In
crates/victory-shader/src/emit/lower.rs(packed16, line 4788), any packed 16-bit integer instruction withv.clamp == truefails lowering withUnsupported { what: "modifiers on a packed integer operation" }.Under the AMD RDNA2 ISA (VOP3P),
clamp = 1is the saturating integer modifier forv_pk_add_u16,v_pk_sub_u16,v_pk_mad_u16,v_pk_add_i16,v_pk_sub_i16, andv_pk_mad_i16, clamping each 16-bit lane to[0, 65535](unsigned) or[-32768, 32767](signed).Fix
v.clampinLower::packed16specifically for the 6 saturating packed integer ops (add_u16,sub_u16,mad_u16,add_i16,sub_i16,mad_i16); non-saturating packed integer ops (mul_lo_u16, shifts,min/max) continue to rejectv.clamp.& 0xFFFFmask:add_u16/mad_u16:u16::MAX * u16::MAX + u16::MAX = 4,294,901,760 <= u32::MAX(never wrapsu32), sor >u 0xFFFF ? 0xFFFF : ris exact.sub_u16: operands are in[0, 65535], soris in[-65535, 65535]andr <s 0 ? 0 : rcatches underflow exactly.add_i16/sub_i16/mad_i16: operands are sign-extended toi32(|r| <= 32768 * 32768 + 32768 < 2^31, never wrapsi32), so signed clamp to[-32768, 32767]is exact.emit::valu_tests::v_pk_int16_clamp_saturates_as_rdna2incrates/victory-shader/src/emit/valu_tests.rstesting all 6 instructions withclamp = 1across overflow, underflow, max-product, and in-range lanes.Verification (Real GPU + WARP + CI Gates)
Tested on Windows 11, NVIDIA GeForce RTX 3060 Ti (driver
32.0.16.1656), Rust1.98.1:cargo test -p victory-shader --lib v_pk_int16_clamp_saturates_as_rdna2: ok (dxil.dllvalidator + RTX 3060 Ti hardware + Microsoft WARP)cargo test -p victory-shader --locked: 121 passed, 0 failed, 1 ignoredcargo clippy --workspace --all-targets --locked -- -D warnings: pass (0 warnings)cargo clippy --workspace --all-targets --all-features --locked -- -D warnings: pass (0 warnings)cargo xtask policy:asset policy: 154 files okScope & Non-Overlap
v_pk_{add,sub,mad}_{u16,i16}saturatingclamp.