fix: honor clamp on unsigned VOP3 add and subtract #327

Open
github-bot wants to merge 1 commit from github-bot/gh-327 into main AGit
Owner

@⁠mauroalvare on GitHub · 2026-11-26 03:26 UTC · original
mauroalvare:codex/victory-u32-clamp → main · +170 −32 · 4 files · 1 commits · open

Change

Neptune rejected unsigned VOP3 and VOP3B add/subtract with clamp as integer output modifiers before it emitted DXIL. The resource tracer also treated a clamped sum relative to s_getpc_b64 as an ordinary code-table address.

tools/lancer_victory.ps1 builds and launches the runtime that uses victory-gpu and victory_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 38ddebf954267e2ae46dce6f3f3dbfdb622219ee and adds Neptune-specific tests. The commit and THIRD_PARTY.md credit the source.

Verification

Commit 7e79fcee0443a2fff09f5b296dcb021f93553a76 is based on c4c93bdc413191a9dc909998d2d53080a3f0c880.

Run this from third_party/victory with the Windows SDK validator and cached dependencies.

$env:VICTORY_DXIL = 'C:\Program Files (x86)\Windows Kits\10\bin\10.0.26100.0\x64\dxil.dll'
Remove-Item Env:VICTORY_WARP -ErrorAction SilentlyContinue
cargo test --locked --offline -j 2 -p victory-shader --lib clamped_u32_ -- --nocapture --test-threads=1
  • On base c4c93bdc413191a9dc909998d2d53080a3f0c880 with the regression tests, all four fail. The three arithmetic tests stop in lowering at byte 36. The fourth shows the tracer returning CODE + 4 with a dynamic term for the saturated sum.
  • With the fix, all four pass. Locally logging the D3D12 adapter LUID confirmed dispatches on the NVIDIA GeForce RTX 5070 Ti (driver 621.40) and Microsoft WARP. SDK DXIL validator 1.8.2502.11 accepted 16 containers. All 16 compute pipelines produced the expected readbacks on both backends, including carry-in and borrow-in cases. The address regression exercises the reject path independently.

Additional checks on the committed tree:

Command Result
cargo test --locked --offline -j 2 -p victory-shader -- --nocapture --test-threads=1 246 passed, 0 failed, 2 ignored
cargo test --locked --offline -j 2 -p victory-loader --test load_probe 2 passed, 0 failed
cargo check --locked --offline -j 2 -p victory Finished successfully
cargo xtask policy 200 files OK
cargo build --release --locked --offline -j 2 --manifest-path rust/Cargo.toml Finished successfully
cargo test --release --locked --offline -j 2 --manifest-path rust/Cargo.toml 12 passed, 0 failed
python -m pytest -rs 1665 passed in 220.46s
python -m ruff check --select W605,F,E9 PrototypeScarlett tests tools All checks passed

The 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

  • Focused regression fails on the base and passes on the patched tree.
  • Commands, adapters, results, and skips are recorded above.
  • The unsupported saturated PC-relative address is reported explicitly.
  • Repository fixtures supply all input shaders and executables.
  • Pytest verifies the README language copies.
  • The GPL-compatible port is credited in THIRD_PARTY.md and the commit.

AI assistance by Codex for porting, regression tests, and Windows validation.

**@⁠mauroalvare** on GitHub · 2026-11-26 03:26 UTC · [original](https://github.com/LooperSalty/AnyXboxX/pull/327) `mauroalvare:codex/victory-u32-clamp` → `main` · +170 −32 · 4 files · 1 commits · open ## Change Neptune rejected unsigned VOP3 and VOP3B add/subtract with `clamp` as `integer output modifiers` before it emitted DXIL. The resource tracer also treated a clamped sum relative to `s_getpc_b64` as an ordinary code-table address. `tools/lancer_victory.ps1` builds and launches the runtime that uses `victory-gpu` and `victory_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](https://github.com/Marvisak/VIctory/pull/1398) by EatCodeSleep2 from commit `38ddebf954267e2ae46dce6f3f3dbfdb622219ee` and adds Neptune-specific tests. The commit and `THIRD_PARTY.md` credit the source. ## Verification Commit `7e79fcee0443a2fff09f5b296dcb021f93553a76` is based on `c4c93bdc413191a9dc909998d2d53080a3f0c880`. Run this from `third_party/victory` with the Windows SDK validator and cached dependencies. ```powershell $env:VICTORY_DXIL = 'C:\Program Files (x86)\Windows Kits\10\bin\10.0.26100.0\x64\dxil.dll' Remove-Item Env:VICTORY_WARP -ErrorAction SilentlyContinue cargo test --locked --offline -j 2 -p victory-shader --lib clamped_u32_ -- --nocapture --test-threads=1 ``` - On base `c4c93bdc413191a9dc909998d2d53080a3f0c880` with the regression tests, all four fail. The three arithmetic tests stop in lowering at byte 36. The fourth shows the tracer returning `CODE + 4` with a dynamic term for the saturated sum. - With the fix, all four pass. Locally logging the D3D12 adapter LUID confirmed dispatches on the NVIDIA GeForce RTX 5070 Ti (driver 621.40) and Microsoft WARP. SDK DXIL validator 1.8.2502.11 accepted 16 containers. All 16 compute pipelines produced the expected readbacks on both backends, including carry-in and borrow-in cases. The address regression exercises the reject path independently. Additional checks on the committed tree: | Command | Result | | --- | --- | | `cargo test --locked --offline -j 2 -p victory-shader -- --nocapture --test-threads=1` | 246 passed, 0 failed, 2 ignored | | `cargo test --locked --offline -j 2 -p victory-loader --test load_probe` | 2 passed, 0 failed | | `cargo check --locked --offline -j 2 -p victory` | Finished successfully | | `cargo xtask policy` | 200 files OK | | `cargo build --release --locked --offline -j 2 --manifest-path rust/Cargo.toml` | Finished successfully | | `cargo test --release --locked --offline -j 2 --manifest-path rust/Cargo.toml` | 12 passed, 0 failed | | `python -m pytest -rs` | 1665 passed in 220.46s | | `python -m ruff check --select W605,F,E9 PrototypeScarlett tests tools` | All checks passed | The 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](https://docs.amd.com/api/khub/documents/Et~wpu9g~Ffl7d9q0QZ~Og/content). 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](https://git.gtahub.st/github/LooperSalty--AnyXboxX/pulls/235). ## Checklist - [x] Focused regression fails on the base and passes on the patched tree. - [x] Commands, adapters, results, and skips are recorded above. - [x] The unsupported saturated PC-relative address is reported explicitly. - [x] Repository fixtures supply all input shaders and executables. - [x] Pytest verifies the README language copies. - [x] The GPL-compatible port is credited in `THIRD_PARTY.md` and the commit. AI assistance by Codex for porting, regression tests, and Windows validation.
Use the carry or borrow to saturate unsigned VOP3 add and subtract
results, including three-input addition. Preserve the carry or borrow
written to SDST. Keep clamped additions out of plain address tracing
and diagnose clamped PC-relative addresses before lowering.

Source: Marvisak/VIctory #1398 (38ddebf954267e2ae46dce6f3f3dbfdb622219ee)
Co-authored-by: EatCodeSleep2 <[email protected]>
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 05:43:13 +00:00
This pull request can be merged automatically.
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin '+refs/pull/327/head:github-bot/gh-327'
git switch 'github-bot/gh-327'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-327'
git switch 'github-bot/gh-327'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-327'
git switch 'github-bot/gh-327'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-327'
git switch 'main'
git merge --squash 'github-bot/gh-327'
git switch 'main'
git merge --ff-only 'github-bot/gh-327'
git switch 'main'
git merge 'github-bot/gh-327'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No description provided.