Shaders/resource: do not treat RootType::Constants dword 0 as an address base in Tracer::sum #806

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

@⁠AscilCH on GitHub · 2026-11-25 08:19 UTC · original
AscilCH:fix/shader-resource-sum-constants-dword0 → main · +71 −7 · 1 files · 1 commits · open

Summary

Fix Tracer::sum() in crates/victory-shader/src/resource.rs misclassifying dword 0 of RootType::Constants (and RootType::Other) as an address base:

  • Tracer::sum() matched self.param_of(reg) against Some((_, 0)) without checking self.layout[param].root.
  • As a result, whenever a shader used dword 0 of a root-constants parameter as an offset:
    1. Adding root constant dword 0 to a root descriptor or table base (s_add_u32 s4, s0, s2) hit x.base.is_some() && y.base.is_some() and discarded the base. On compute shaders, by_address() silently rewrote the root-descriptor load to raw MEMORY instead of the bound root buffer; on graphics/mesh stages it failed compilation.
    2. Passing unshifted root constant dword 0 directly as SMEM soffset or flat vaddr failed with "an offset from a root parameter", breaking root_indexed_view's shift = 0 path.
  • Restrict base classification in Tracer::sum() to address-bearing root parameters (Table | ResourceHeap | SamplerHeap | Descriptor), and preserve "an address from a root parameter that is no address" in why_no_base() when a non-address root parameter is used directly as an address base.
  • Add resource::tests::root_constant_dword0_is_dynamic_offset_not_address_base covering both compute-shader root descriptor indexing and unshifted SMEM soffset root-indexed views.

Verification

  • cargo test -p victory-shader --locked -- resource::: 34 passed; 0 failed; 0 ignored.
  • cargo clippy -p victory-shader --all-targets --all-features --locked -- -D warnings: 0 warnings.
  • cargo xtask policy: 171 files ok.

(AI-assisted; synthetic unit tests only, no game data.)

**@⁠AscilCH** on GitHub · 2026-11-25 08:19 UTC · [original](https://github.com/fxceless/victory-fork/pull/806) `AscilCH:fix/shader-resource-sum-constants-dword0` → `main` · +71 −7 · 1 files · 1 commits · open ## Summary Fix `Tracer::sum()` in `crates/victory-shader/src/resource.rs` misclassifying dword 0 of `RootType::Constants` (and `RootType::Other`) as an address `base`: - `Tracer::sum()` matched `self.param_of(reg)` against `Some((_, 0))` without checking `self.layout[param].root`. - As a result, whenever a shader used dword 0 of a root-constants parameter as an offset: 1. Adding root constant dword 0 to a root descriptor or table base (`s_add_u32 s4, s0, s2`) hit `x.base.is_some() && y.base.is_some()` and discarded the base. On compute shaders, `by_address()` silently rewrote the root-descriptor load to raw `MEMORY` instead of the bound root buffer; on graphics/mesh stages it failed compilation. 2. Passing unshifted root constant dword 0 directly as SMEM `soffset` or flat `vaddr` failed with `"an offset from a root parameter"`, breaking `root_indexed_view`'s `shift = 0` path. - Restrict `base` classification in `Tracer::sum()` to address-bearing root parameters (`Table | ResourceHeap | SamplerHeap | Descriptor`), and preserve `"an address from a root parameter that is no address"` in `why_no_base()` when a non-address root parameter is used directly as an address base. - Add `resource::tests::root_constant_dword0_is_dynamic_offset_not_address_base` covering both compute-shader root descriptor indexing and unshifted SMEM `soffset` root-indexed views. ## Verification - `cargo test -p victory-shader --locked -- resource::`: `34 passed; 0 failed; 0 ignored`. - `cargo clippy -p victory-shader --all-targets --all-features --locked -- -D warnings`: 0 warnings. - `cargo xtask policy`: `171 files ok`. *(AI-assisted; synthetic unit tests only, no game data.)*
In `Tracer::sum()` (`crates/victory-shader/src/resource.rs`), matching
`self.param_of(reg)` for `Some((_, 0))` classified dword 0 of EVERY root
parameter—including `RootType::Constants` and `RootType::Other`—as an address
`base` rather than a `dynamic` offset term.

This caused two failures whenever a shader used dword 0 of a root-constants
parameter as an offset:

1. Adding root constant dword 0 to a root descriptor/table base
   (`s_add_u32 s4, s0, s2`) hit `x.base.is_some() && y.base.is_some()` and
   discarded the base; on Compute Shaders `by_address()` silently rewrote the
   root-descriptor load to raw `MEMORY` instead of the bound root buffer (and
   failed compilation on graphics/mesh stages).
2. Passing unshifted root constant dword 0 directly as SMEM `soffset` or flat
   `vaddr` failed with `"an offset from a root parameter"`, breaking
   `root_indexed_view`'s `shift = 0` path.

Restrict `base` classification in `Tracer::sum()` to address-bearing root
parameters (`Table | ResourceHeap | SamplerHeap | Descriptor`), preserve the
`"an address from a root parameter that is no address"` diagnostic in
`why_no_base()` when a non-address root parameter is used directly as a base,
and add `resource::tests::root_constant_dword0_is_dynamic_offset_not_address_base`.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 03:51:33 +00:00
Author
Owner

@⁠MamaLeVrai on GitHub · 2026-11-25 09:54 UTC · original

Test report on real hardware: AMD RX 6950 XT (RDNA2), Windows 11, Rust 1.98.1, with a GPU present. I merged this PR's head 8e1b61e into main 9376fd6 in a throwaway tree (no conflict). cargo clippy --workspace --all-targets --locked -- -D warnings fails, with the same two errors as main itself on this machine (function placed_filler_twins is never used, field depth_written is never read, victory-gpu): this PR adds none and removes none. cargo test --workspace --locked: 541 passed, 0 failed, 10 ignored, two runs (main alone: 540 passed). The title was not run, so this says nothing about in-game effect. No game data.

AI-assisted (Claude Code); no game data.

**@⁠MamaLeVrai** on GitHub · 2026-11-25 09:54 UTC · [original](https://github.com/fxceless/victory-fork/pull/806#issuecomment-7158952917) Test report on real hardware: AMD RX 6950 XT (RDNA2), Windows 11, Rust 1.98.1, with a GPU present. I merged this PR's head `8e1b61e` into `main` `9376fd6` in a throwaway tree (no conflict). `cargo clippy --workspace --all-targets --locked -- -D warnings` fails, with the same two errors as `main` itself on this machine (`function placed_filler_twins is never used`, `field depth_written is never read`, `victory-gpu`): this PR adds none and removes none. `cargo test --workspace --locked`: 541 passed, 0 failed, 10 ignored, two runs (`main` alone: 540 passed). The title was not run, so this says nothing about in-game effect. No game data. AI-assisted (Claude Code); no game data.
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/806/head:github-bot/gh-806'
git switch 'github-bot/gh-806'

Merge

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