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

Open
fuzeofficlal wants to merge 1 commit from upstream-pr/2385 into main
fuzeofficlal commented 2026-11-25 12:26:03 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by fuzeofficlal on 2026-11-25T12:26:03Z.


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

<!-- greyfinch-sync:Marvisak/VIctory:issue:6604438385 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2385). Originally posted by [fuzeofficlal](https://github.com/fuzeofficlal) on 2026-11-25T12:26:03Z. --- ### 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
DenRakEiw commented 2026-11-25 13:02:31 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by DenRakEiw on 2026-11-25T12:31:08Z.

Review: APPROVED


Verified against origin/main (940d32f) on Windows 11 + NVIDIA GeForce RTX 5090 and WARP:

  • Tracking s_add_u32 with src_scc carry into address high halves (#815) passes all resource tracking and live GPU VALU tests.
  • cargo test -p victory-shader resource::tests: 34/34 passed (including add_scc_carries_into_address_high_halves).
  • cargo test -p victory-shader src_scc: 1/1 passed on RTX 5090, 1/1 passed on WARP.
  • cargo clippy -p victory-shader --all-targets -- -D warnings: 0 warnings.
  • cargo xtask policy: 183 files ok.

AI-assisted (Gemini 4 Neon).

<!-- greyfinch-sync:Marvisak/VIctory:review:6057631078 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2385#pullrequestreview-6057631078). Originally posted by [DenRakEiw](https://github.com/DenRakEiw) on 2026-11-25T12:31:08Z. **Review:** APPROVED --- Verified against `origin/main` (`940d32f`) on Windows 11 + NVIDIA GeForce RTX 5090 and WARP: - Tracking `s_add_u32` with `src_scc` carry into address high halves (`#815`) passes all resource tracking and live GPU VALU tests. - `cargo test -p victory-shader resource::tests`: 34/34 passed (including `add_scc_carries_into_address_high_halves`). - `cargo test -p victory-shader src_scc`: 1/1 passed on RTX 5090, 1/1 passed on WARP. - `cargo clippy -p victory-shader --all-targets -- -D warnings`: 0 warnings. - `cargo xtask policy`: 183 files ok. AI-assisted (Gemini 4 Neon).
catminou4 commented 2026-11-25 13:02:31 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by catminou4 on 2026-11-25T12:41:44Z.

Review: APPROVED


Tested locally: merged into main 940d32f69b, cargo test -p victory-shader --locked on macOS arm64 — 145 passed, 0 failed, 2 ignored (Windows-gated hardware execution tests not run here). Approving — s_add_u32 with src_scc tracked in address high halves.

<!-- greyfinch-sync:Marvisak/VIctory:review:6057785084 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2385#pullrequestreview-6057785084). Originally posted by [catminou4](https://github.com/catminou4) on 2026-11-25T12:41:44Z. **Review:** APPROVED --- Tested locally: merged into main 940d32f69b, `cargo test -p victory-shader --locked` on macOS arm64 — 145 passed, 0 failed, 2 ignored (Windows-gated hardware execution tests not run here). Approving — s_add_u32 with src_scc tracked in address high halves.
Marvisak commented 2026-11-25 15:04:33 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Marvisak on 2026-11-25T14:58:19Z.


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

<!-- greyfinch-sync:Marvisak/VIctory:comment:7166100633 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2385#issuecomment-7166100633). Originally posted by [Marvisak](https://github.com/Marvisak) on 2026-11-25T14:58:19Z. --- <!-- 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)_
cloph-dsp commented 2026-11-25 16:09:17 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by cloph-dsp on 2026-11-25T15:41:49Z.


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.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7167240709 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2385#issuecomment-7167240709). Originally posted by [cloph-dsp](https://github.com/cloph-dsp) on 2026-11-25T15:41:49Z. --- 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 cannot be merged automatically due to conflicts.
Merge manually to resolve the conflicts.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin 'upstream-pr/2385:upstream-pr/2385'
git switch 'upstream-pr/2385'

Merge

Merge the changes and update on Forgejo.

Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.

git switch 'main'
git merge --no-ff 'upstream-pr/2385'
git switch 'upstream-pr/2385'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/2385'
git switch 'upstream-pr/2385'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/2385'
git switch 'main'
git merge --squash 'upstream-pr/2385'
git switch 'main'
git merge --ff-only 'upstream-pr/2385'
git switch 'main'
git merge 'upstream-pr/2385'
git push origin 'main'
Sign in to join this conversation.
No reviewers
No labels
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.

Reference
Marvisak/VIctory!2383
No description provided.