fix: honor clamp on unsigned VOP3 add and subtract #327
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/327"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from LooperSalty/AnyXboxX. Originally posted by mauroalvare on 2026-11-26T03:26:33Z.
Change
Neptune rejected unsigned VOP3 and VOP3B add/subtract with
clampasinteger output modifiersbefore it emitted DXIL. The resource tracer also treated a clamped sum relative tos_getpc_b64as an ordinary code-table address.tools/lancer_victory.ps1builds and launches the runtime that usesvictory-gpuandvictory_shader::emit::translate. These regressions exercise that translator's lowering and resource tracing.Use carry or borrow to saturate the VGPR result and preserve the lane bit written to SDST. For
v_add3_u32, overflow in either addition saturates the result. Resource tracing refuses a saturated PC-relative address with an explicit diagnostic because the lowered PC is an offset into the shader.This adapts VIctory #1398 by EatCodeSleep2 from commit
38ddebf954267e2ae46dce6f3f3dbfdb622219eeand adds Neptune-specific tests. The commit andTHIRD_PARTY.mdcredit the source.Verification
Commit
7e79fcee0443a2fff09f5b296dcb021f93553a76is based onc4c93bdc413191a9dc909998d2d53080a3f0c880.Run this from
third_party/victorywith the Windows SDK validator and cached dependencies.c4c93bdc413191a9dc909998d2d53080a3f0c880with the regression tests, all four fail. The three arithmetic tests stop in lowering at byte 36. The fourth shows the tracer returningCODE + 4with a dynamic term for the saturated sum.Additional checks on the committed tree:
cargo test --locked --offline -j 2 -p victory-shader -- --nocapture --test-threads=1cargo test --locked --offline -j 2 -p victory-loader --test load_probecargo check --locked --offline -j 2 -p victorycargo xtask policycargo build --release --locked --offline -j 2 --manifest-path rust/Cargo.tomlcargo test --release --locked --offline -j 2 --manifest-path rust/Cargo.tomlpython -m pytest -rspython -m ruff check --select W605,F,E9 PrototypeScarlett tests toolsThe full shader run also reported four optional console-compiler skips, one WARP pipeline skip, and one hardware wave test whose pipeline the device did not accept. The focused regression ran all 16 containers on both backends. Pytest used Python 3.13.15,
ANYXBOXX_REQUIRE_RUNTIME=1, and the existing native runtime and TomBox builds.Oracle and test data
The regression assembles one-thread synthetic compute shaders using the repository's GFX10 encoders. It compares every readback to exact integer arithmetic, using the representable range from section 6.5 of the AMD RDNA 2 ISA guide. The expected carry and borrow are based on the exact unsaturated result, as in the independently implemented interpreter and HLSL tests for the nine two-input variants in AnyXboxX #235.
Checklist
THIRD_PARTY.mdand the commit.AI assistance by Codex for porting, regression tests, and Windows validation.
Rebase verification
Rebased on
58d2f53and merged the upstream credit into the currentTHIRD_PARTY.mdtable.cargo test --locked --offline -j 5 -p victory-shader clamped_u32 -- --nocapture --test-threads=1passed all 4 tests on the rebased code.The size check in CI found that
lower.rsexceeded the 512 KiB limit. The existing add/subtract carry helper now lives ininteger_carry.rs. After the move,cargo xtask policypassed for all 215 files and all 4 targeted tests passed again.Imported from LooperSalty/AnyXboxX. Originally posted by LooperSalty on 2026-11-26T14:01:29Z.
This PR now conflicts with main in
THIRD_PARTY.md(the sources table moved after the recent merges, including #351). Please rebase on main (git fetch origin && git rebase origin/main), keep both sides of the table rows, and force-push your branch; CI must then pass again before review.🤖 Generated with Claude Code
Imported from LooperSalty/AnyXboxX. Originally posted by mauroalvare on 2026-11-26T18:25:32Z.
Rebased and pushed over #387, with the VOP3 clamp attribution in the current
THIRD_PARTY.mdtable. I moved the carry helper into its own module to keeplower.rsbelow the 512 KiB limit.All four clamp tests passed, and the asset-policy check passed for the updated branch.
The latest CI run passed.
Imported from LooperSalty/AnyXboxX. Originally posted by LooperSalty on 2026-11-27T12:24:02Z.
Review: this removes the v_permlane16_b32 / v_permlanex16_b32 lowering arm in lower.rs (about 79 lines) with no replacement, which the title does not mention. Please restore it (rebase on main) so the permlane tests exercise it again. CI is green only because the GPU tests skip.
Imported from LooperSalty/AnyXboxX. Originally posted by mauroalvare on 2026-11-27T17:02:12Z.
The previous Vice-Tay port accidentally removed the
v_permlane16_b32andv_permlanex16_b32lowering arm. I restored it frommainand kept the unsigned saturation changes. The saturation tests passed, and the row selection and EXEC cases ran on the RTX 5070 Ti and passed.Imported from LooperSalty/AnyXboxX. Originally posted by LooperSalty on 2026-11-27T17:31:05Z.
Thanks for restoring the permlane arm. This changes the DXIL of
v_add_u32/v_sub_u32(VOP3 with clamp) for shaders that translated before, so pervictory-shader/src/lib.rs("bump it with any change that changes the translation of a shader")TRANSLATOR_VERSIONneeds a bump; otherwise caches from earlier builds keep the unclamped translation. Please take the next free value (#456 uses 3, #485 4, #306 asks for 5) and re-bump if another one lands first.Imported from LooperSalty/AnyXboxX. Originally posted by mauroalvare on 2026-11-27T17:57:32Z.
Bumped
TRANSLATOR_VERSIONto7inc41526a(leaving3for #456,4for #485,5for #306,6for #321; will re-bump if another translation bump lands first). Re-verified all 4clamped_u32_*tests andcargo xtask policy(286 files ok).