Fix compute shader signed overflow and paired LDS writes #1088

Open
github-bot wants to merge 2 commits from github-bot/gh-1088 into main AGit
Owner

@⁠THE-PRO-GAME on GitHub · 2026-11-24 15:38 UTC · original
THE-PRO-GAME:compute-shader-improvements → main · +205 −19 · 2 files · 2 commits · open

Changes

  • Signed scalar overflow. The translator rejected branches that consumed SCC from S_ADD_I32, S_SUB_I32, or S_ADDK_I32. The lowering now derives signed overflow from the operand and result sign bits while preserving the wrapping 32-bit result. This enables shaders whose translation depended on these SCC values. Lowering · AMD RDNA 2 ISA §12.1 · AMD RDNA 2 ISA §12.2
  • Paired LDS writes. The four 32-bit and 64-bit DS_WRITE2 and DS_WRITE2ST64 forms wrote DATA1 over DATA0 when their offsets matched. Equal offsets now emit one write with DATA0. Distinct offsets still write both operands. This prevents affected shaders from reading the wrong shared-memory value after an equal-offset write. Lowering · AMD RDNA 2 ISA §10.4.3

Verification

  • All seven new regressions reproduced the defects before the fixes and passed afterward. On D3D12 WARP, 32 scalar dispatches checked the arithmetic result and branch decision. Eight LDS dispatches checked equal and distinct offsets across 64 lanes. Scalar regressions · LDS regressions
  • cargo test --workspace --locked reported 349 passes and zero failures. With --all-features, it reported 353 passes and zero failures. Three ignored synthetic benchmarks also passed when run separately. Three reference-data tests and the Xbox SDK differential tests were unavailable.
  • cargo clippy --workspace --all-targets --locked -- -D warnings passed with default and all features. The optional workspace formatting check flagged pre-existing differences outside the changed hunks.
  • Microsoft DXC v1.9.2609 accepted all 12 emitted DXIL containers. As a separate compatibility check, an external conversion of those containers passed spirv-val --target-env vulkan1.3 for all 12 modules. VIctory emits DXIL for D3D12. Numerical verification ran on WARP. Microsoft DXC · dxil-spirv revision · Khronos SPIRV-Tools revision

Scope and disclosure

OpenAI Codex was used to investigate, implement, and test these changes using public documentation and synthetic shaders. In-game impact has not been verified. RTX 3060 execution was unavailable on the test host, and game performance was not measured.

Existing work on other SCC instructions, atomics, LDS bounds and barriers, and wave64 remains separate. SCC #168 · Atomics #164 · LDS and barriers #292 · RTX 3060 #1001

**@⁠THE-PRO-GAME** on GitHub · 2026-11-24 15:38 UTC · [original](https://github.com/Marvisak/VIctory/pull/1088) `THE-PRO-GAME:compute-shader-improvements` → `main` · +205 −19 · 2 files · 2 commits · open ## Changes - **Signed scalar overflow.** The translator rejected branches that consumed SCC from `S_ADD_I32`, `S_SUB_I32`, or `S_ADDK_I32`. The lowering now derives signed overflow from the operand and result sign bits while preserving the wrapping 32-bit result. This enables shaders whose translation depended on these SCC values. [Lowering](https://github.com/THE-PRO-GAME/VIctory/blob/59ab6b736af3037780f46b706ddce67362c26448/crates/victory-shader/src/emit/lower.rs#L2598) · [AMD RDNA 2 ISA §12.1](https://docs.amd.com/api/khub/documents/Et~wpu9g~Ffl7d9q0QZ~Og/content#page=110) · [AMD RDNA 2 ISA §12.2](https://docs.amd.com/api/khub/documents/Et~wpu9g~Ffl7d9q0QZ~Og/content#page=116) - **Paired LDS writes.** The four 32-bit and 64-bit `DS_WRITE2` and `DS_WRITE2ST64` forms wrote `DATA1` over `DATA0` when their offsets matched. Equal offsets now emit one write with `DATA0`. Distinct offsets still write both operands. This prevents affected shaders from reading the wrong shared-memory value after an equal-offset write. [Lowering](https://github.com/THE-PRO-GAME/VIctory/blob/59ab6b736af3037780f46b706ddce67362c26448/crates/victory-shader/src/emit/lower.rs#L2182) · [AMD RDNA 2 ISA §10.4.3](https://docs.amd.com/api/khub/documents/Et~wpu9g~Ffl7d9q0QZ~Og/content#page=104) ## Verification - All seven new regressions reproduced the defects before the fixes and passed afterward. On D3D12 WARP, 32 scalar dispatches checked the arithmetic result and branch decision. Eight LDS dispatches checked equal and distinct offsets across 64 lanes. [Scalar regressions](https://github.com/THE-PRO-GAME/VIctory/blob/59ab6b736af3037780f46b706ddce67362c26448/crates/victory-shader/src/emit/valu_tests.rs#L234) · [LDS regressions](https://github.com/THE-PRO-GAME/VIctory/blob/59ab6b736af3037780f46b706ddce67362c26448/crates/victory-shader/src/emit/valu_tests.rs#L1024) - `cargo test --workspace --locked` reported 349 passes and zero failures. With `--all-features`, it reported 353 passes and zero failures. Three ignored synthetic benchmarks also passed when run separately. Three reference-data tests and the Xbox SDK differential tests were unavailable. - `cargo clippy --workspace --all-targets --locked -- -D warnings` passed with default and all features. The optional workspace formatting check flagged pre-existing differences outside the changed hunks. - Microsoft DXC v1.9.2609 accepted all 12 emitted DXIL containers. As a separate compatibility check, an external conversion of those containers passed `spirv-val --target-env vulkan1.3` for all 12 modules. VIctory emits DXIL for D3D12. Numerical verification ran on WARP. [Microsoft DXC](https://github.com/microsoft/DirectXShaderCompiler/releases/tag/v1.9.2609) · [dxil-spirv revision](https://github.com/HansKristian-Work/dxil-spirv/commit/7c048638ab59bcdbb1c43c19af2c4a057038435f) · [Khronos SPIRV-Tools revision](https://github.com/KhronosGroup/SPIRV-Tools/commit/199cb207b911501ddd76dcddf100a6e21c15ef23) ## Scope and disclosure OpenAI Codex was used to investigate, implement, and test these changes using public documentation and synthetic shaders. In-game impact has not been verified. RTX 3060 execution was unavailable on the test host, and game performance was not measured. Existing work on other SCC instructions, atomics, LDS bounds and barriers, and wave64 remains separate. [SCC #168](https://git.gtahub.st/github/Marvisak--VIctory/pulls/168) · [Atomics #164](https://git.gtahub.st/github/Marvisak--VIctory/pulls/164) · [LDS and barriers #292](https://git.gtahub.st/github/Marvisak--VIctory/pulls/292) · [RTX 3060 #1001](https://git.gtahub.st/github/Marvisak--VIctory/issues/1001)
Set SCC for S_ADD_I32, S_SUB_I32, and S_ADDK_I32 from the signs of their inputs and wrapping result. Exercise branches that consume SCC and compare GPU readback against signed arithmetic.
Emit one store element for equal-offset DS_WRITE2 and DS_WRITE2ST64. Exercise 32-bit and 64-bit stores with equal and distinct offsets through compute dispatch and readback.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 04:19:26 +00:00
Author
Owner

@⁠ghost on GitHub · 2026-11-24 16:14 UTC · original

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 59ab6b7 on main ffe310e. Your numerical checks ran on WARP, so this adds RDNA2 hardware.

  • scalar_add_i32_scc_controls_branch, scalar_sub_i32_scc_controls_branch, scalar_addk_i32_scc_controls_branch and the four paired_lds_write2* tests (b32/b64, st64, 64 lanes) pass.
  • victory-shader lib tests: 126 passed, 1 failed, 1 ignored. The one failure, stub_pipeline_is_created, fails on main on this host too (likely vkd3d-proton accepting the zero DXIL digest the test expects refused; environment, not this PR).
  • No hangs. The SCC part overlaps #1095.

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.

**@⁠ghost** on GitHub · 2026-11-24 16:14 UTC · [original](https://github.com/Marvisak/VIctory/pull/1088#issuecomment-7137333841) 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 `59ab6b7` on main `ffe310e`. Your numerical checks ran on WARP, so this adds RDNA2 hardware. - `scalar_add_i32_scc_controls_branch`, `scalar_sub_i32_scc_controls_branch`, `scalar_addk_i32_scc_controls_branch` and the four `paired_lds_write2*` tests (b32/b64, st64, 64 lanes) pass. - victory-shader lib tests: 126 passed, 1 failed, 1 ignored. The one failure, `stub_pipeline_is_created`, fails on main on this host too (likely vkd3d-proton accepting the zero DXIL digest the test expects refused; environment, not this PR). - No hangs. The SCC part overlaps #1095. 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.
Author
Owner

@⁠Zipettte on GitHub · 2026-11-24 16:29 UTC · original

Tested on AMD Radeon RX 7700 XT (RDNA3, gfx1101), driver 32.0.32029.2010, Windows 11, Rust 1.98.1 MSVC at 59ab6b7: cargo test -p victory-shader passes, 127 passed / 0 failed. Workspace baseline on main (ffe310e) is green on the same machine (342 passed).

Tested with AI assistance (Claude).

**@⁠Zipettte** on GitHub · 2026-11-24 16:29 UTC · [original](https://github.com/Marvisak/VIctory/pull/1088#issuecomment-7137754507) Tested on AMD Radeon RX 7700 XT (RDNA3, gfx1101), driver 32.0.32029.2010, Windows 11, Rust 1.98.1 MSVC at 59ab6b7: `cargo test -p victory-shader` passes, 127 passed / 0 failed. Workspace baseline on main (ffe310e) is green on the same machine (342 passed). _Tested with AI assistance (Claude)._
Author
Owner

@⁠Marvisak on GitHub · 2026-11-25 00:34 UTC · original

Automated triage for the maintainers.

Needs rebase. This PR does not merge cleanly into current main (ac2525d). Conflicting files: crates/victory-shader/src/emit/valu_tests.rs.

The content has not been reviewed yet; it will be once the branch is rebased onto main.


Generated by Claude Code

**@⁠Marvisak** on GitHub · 2026-11-25 00:34 UTC · [original](https://github.com/Marvisak/VIctory/pull/1088#issuecomment-7148654915) <!-- victory-triage v1 head=59ab6b736af3037780f46b706ddce67362c26448 verdict=needs-rebase at=2026-11-25T00:13:20Z --> Automated triage for the maintainers. **Needs rebase.** This PR does not merge cleanly into current `main` (ac2525d). Conflicting files: `crates/victory-shader/src/emit/valu_tests.rs`. The content has not been reviewed yet; it will be once the branch is rebased onto `main`. --- _Generated by [Claude Code](https://claude.ai/code)_
This pull request has changes conflicting with the target branch.
  • crates/victory-shader/src/emit/lower.rs
  • crates/victory-shader/src/emit/valu_tests.rs
View command line instructions

Manual merge helper

Use this merge commit message when completing the merge manually.

Checkout

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

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-1088'
git switch 'github-bot/gh-1088'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-1088'
git switch 'github-bot/gh-1088'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-1088'
git switch 'main'
git merge --squash 'github-bot/gh-1088'
git switch 'main'
git merge --ff-only 'github-bot/gh-1088'
git switch 'main'
git merge 'github-bot/gh-1088'
git push origin 'main'
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!1088
No description provided.