Shaders: track s_add_u32 with src_scc in address high halves (#815) #2385

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

@⁠fuzeofficlal on GitHub · 2026-11-25 12:26 UTC · original
fuzeofficlal:fix/shader-add-scc-carry-high-half-815 → main · +280 −8 · 3 files · 1 commits · open

Summary

Tracks s_add_u32 (and zero-high-base s_mov_b32) reading src_scc (Operand::Const(253)) in 64-bit address high halves (Tracer::high_half and Tracer::carried in crates/victory-shader/src/resource.rs), and removes scc from Lower::operand's unsupported special-operand message (crates/victory-shader/src/emit/lower.rs, which already lowers Operand::Const(253) via scc_in).

In the native compute pipeline measurements on main reported in #815 (#issuecomment-7160878577 world-run breakdown), 31 distinct compute programs fail translation with "an address into a descriptor heap with an untracked high half" when adding the s_add_u32 low-half carry into the high dword via s_add_u32 hi, 0, src_scc rather than s_addc_u32 hi, 0, 0.

Details

  • ir::add_regs (crates/victory-shader/src/ir.rs:1068) already records Reg::Scc in inst.reads for Operand::Const(253).
  • Tracer::add_scc verifies inst.writes.first()?.1 == v and inst.read(Reg::Scc).is_some(), returning the non-carry term x for s_add_u32 v, x, src_scc / s_add_u32 v, src_scc, x and Term::Const(0) for s_mov_b32 v, src_scc.
  • Tracer::high_half accepts self.add_scc(v) == Some(want) alongside s_addc_u32 (supporting descriptor tables/heaps where want = Term::Const(0) as well as 64-bit root descriptors and s_getpc_b64 code tables where want = Term::Value(base_hi)), while rejecting s_mov_b32 hi, src_scc when base_hi is non-zero.
  • Tracer::carried recurses through add_scc alongside s_addc_u32.

Verification

  • resource::tests::add_scc_carries_into_address_high_halves: covers table/heap (s_add_u32 in both operand orders and s_mov_b32), root descriptors, s_getpc_b64 code tables, and negative cases (adding an arbitrary SGPR to a heap high half stays refused; s_mov_b32 hi, src_scc on a root descriptor drops base_hi and falls back to title memory).
  • emit::valu_tests::add_scc_carry_in_table_and_code_addresses_runs_on_host: validates DXIL with dxil.dll and executes on both hardware GPU and WARP.
  • cargo clippy -p victory-shader --lib --tests --all-features --locked -- -D warnings & cargo xtask policy pass.

Refs #815

**@⁠fuzeofficlal** on GitHub · 2026-11-25 12:26 UTC · [original](https://github.com/Marvisak/VIctory/pull/2385) `fuzeofficlal:fix/shader-add-scc-carry-high-half-815` → `main` · +280 −8 · 3 files · 1 commits · open ### Summary Tracks `s_add_u32` (and zero-high-base `s_mov_b32`) reading `src_scc` (`Operand::Const(253)`) in 64-bit address high halves (`Tracer::high_half` and `Tracer::carried` in `crates/victory-shader/src/resource.rs`), and removes `scc` from `Lower::operand`'s unsupported special-operand message (`crates/victory-shader/src/emit/lower.rs`, which already lowers `Operand::Const(253)` via `scc_in`). In the native compute pipeline measurements on `main` reported in #815 (`#issuecomment-7160878577` world-run breakdown), **31 distinct compute programs** fail translation with `"an address into a descriptor heap with an untracked high half"` when adding the `s_add_u32` low-half carry into the high dword via `s_add_u32 hi, 0, src_scc` rather than `s_addc_u32 hi, 0, 0`. ### Details - `ir::add_regs` (`crates/victory-shader/src/ir.rs:1068`) already records `Reg::Scc` in `inst.reads` for `Operand::Const(253)`. - `Tracer::add_scc` verifies `inst.writes.first()?.1 == v` and `inst.read(Reg::Scc).is_some()`, returning the non-carry term `x` for `s_add_u32 v, x, src_scc` / `s_add_u32 v, src_scc, x` and `Term::Const(0)` for `s_mov_b32 v, src_scc`. - `Tracer::high_half` accepts `self.add_scc(v) == Some(want)` alongside `s_addc_u32` (supporting descriptor tables/heaps where `want = Term::Const(0)` as well as 64-bit root descriptors and `s_getpc_b64` code tables where `want = Term::Value(base_hi)`), while rejecting `s_mov_b32 hi, src_scc` when `base_hi` is non-zero. - `Tracer::carried` recurses through `add_scc` alongside `s_addc_u32`. ### Verification - `resource::tests::add_scc_carries_into_address_high_halves`: covers table/heap (`s_add_u32` in both operand orders and `s_mov_b32`), root descriptors, `s_getpc_b64` code tables, and negative cases (adding an arbitrary SGPR to a heap high half stays refused; `s_mov_b32 hi, src_scc` on a root descriptor drops `base_hi` and falls back to title memory). - `emit::valu_tests::add_scc_carry_in_table_and_code_addresses_runs_on_host`: validates DXIL with `dxil.dll` and executes on both hardware GPU and `WARP`. - `cargo clippy -p victory-shader --lib --tests --all-features --locked -- -D warnings` & `cargo xtask policy` pass. Refs #815
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 05:04:17 +00:00
Author
Owner

@⁠Marvisak on GitHub · 2026-11-25 14:58 UTC · original · edited 2026-11-26 02:19 UTC

Automated triage for the maintainers.

Merge candidate. d996f08 is the same change as the earlier reviewed head, now as one commit on current main, and it merges cleanly. The resource tracer (Tracer::high_half/carried in crates/victory-shader/src/resource.rs, via a new add_scc) accepts an address high half built as s_add_u32 hi, x, src_scc (either operand order) or s_mov_b32 hi, src_scc, the carry form the title's compute programs use instead of s_addc_u32. main already reads SCC for operand 253 (ir.rs) and lowers it as 0/1 (Lower::operand, scc_in), so only the tracer was missing and the error message's "scc" was stale. The check is as lenient as the existing s_addc_u32 one, which also does not tie the carry to the low add. I re-checked the test words (0x8007FD80 is s_add_u32 s7, 0, src_scc, 0xBE8703FD is s_mov_b32 s7, src_scc). The tests cover tables, root descriptors, s_getpc_b64 code tables and two refusals, plus a GPU readback on hardware and WARP.

CI: check passing.


Generated by Claude Code

**@⁠Marvisak** on GitHub · 2026-11-25 14:58 UTC · [original](https://github.com/Marvisak/VIctory/pull/2385#issuecomment-7166100633) · edited 2026-11-26 02:19 UTC <!-- victory-triage v1 head=d996f08cd78aabedfd0488cf43a43b6d2ae927b5 verdict=merge-candidate at=2026-11-26T02:20:00Z --> Automated triage for the maintainers. **Merge candidate.** `d996f08` is the same change as the earlier reviewed head, now as one commit on current `main`, and it merges cleanly. The resource tracer (`Tracer::high_half`/`carried` in `crates/victory-shader/src/resource.rs`, via a new `add_scc`) accepts an address high half built as `s_add_u32 hi, x, src_scc` (either operand order) or `s_mov_b32 hi, src_scc`, the carry form the title's compute programs use instead of `s_addc_u32`. `main` already reads SCC for operand 253 (`ir.rs`) and lowers it as 0/1 (`Lower::operand`, `scc_in`), so only the tracer was missing and the error message's "scc" was stale. The check is as lenient as the existing `s_addc_u32` one, which also does not tie the carry to the low add. I re-checked the test words (`0x8007FD80` is `s_add_u32 s7, 0, src_scc`, `0xBE8703FD` is `s_mov_b32 s7, src_scc`). The tests cover tables, root descriptors, `s_getpc_b64` code tables and two refusals, plus a GPU readback on hardware and WARP. CI: `check` passing. --- _Generated by [Claude Code](https://claude.ai/code)_
Author
Owner

@⁠cloph-dsp on GitHub · 2026-11-25 15:41 UTC · original

Independent local validation for Victory PR #2385 (Windows, Rust 1.100.0/MSVC, head 2b68ca3, no game data): cargo test --locked -p victory-shader --lib -> 249 passed, 0 failed, 3 ignored, exit 0 (138.91s, shared target); git diff --check clean. CPU-only regression run; synthetic s_add_u32/src_scc address-high-half scenario not replayed. AI-assisted (Hy4 flash). GPU/driver N/A for CPU tests.

**@⁠cloph-dsp** on GitHub · 2026-11-25 15:41 UTC · [original](https://github.com/Marvisak/VIctory/pull/2385#issuecomment-7167240709) Independent local validation for Victory PR #2385 (Windows, Rust 1.100.0/MSVC, head 2b68ca3, no game data): `cargo test --locked -p victory-shader --lib` -> 249 passed, 0 failed, 3 ignored, exit 0 (138.91s, shared target); `git diff --check` clean. CPU-only regression run; synthetic s_add_u32/src_scc address-high-half scenario not replayed. AI-assisted (Hy4 flash). GPU/driver N/A for CPU tests.
This pull request can be merged automatically.
This branch is out-of-date with the base branch
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/2385/head:github-bot/gh-2385'
git switch 'github-bot/gh-2385'

Merge

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