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

Open
AscilCH wants to merge 1 commit from upstream-pr/806 into main
AscilCH commented 2026-11-25 08:19:22 +00:00 (Migrated from github.com)

Imported from fxceless/victory-fork. Originally posted by AscilCH on 2026-11-25T08:19:22Z.


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.)

<!-- greyfinch-sync:fxceless/victory-fork:issue:6600223293 --> Imported from [fxceless/victory-fork](https://github.com/fxceless/victory-fork/pull/806). Originally posted by [AscilCH](https://github.com/AscilCH) on 2026-11-25T08:19:22Z. --- ## 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.)*
MamaLeVrai commented 2026-11-25 10:11:15 +00:00 (Migrated from github.com)

Imported from fxceless/victory-fork. Originally posted by MamaLeVrai on 2026-11-25T09:54:06Z.


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.

<!-- greyfinch-sync:fxceless/victory-fork:comment:7158952917 --> Imported from [fxceless/victory-fork](https://github.com/fxceless/victory-fork/pull/806#issuecomment-7158952917). Originally posted by [MamaLeVrai](https://github.com/MamaLeVrai) on 2026-11-25T09:54:06Z. --- 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 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/806:upstream-pr/806'
git switch 'upstream-pr/806'

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/806'
git switch 'upstream-pr/806'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/806'
git switch 'upstream-pr/806'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/806'
git switch 'main'
git merge --squash 'upstream-pr/806'
git switch 'main'
git merge --ff-only 'upstream-pr/806'
git switch 'main'
git merge 'upstream-pr/806'
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
fxceless/victory-fork!805
No description provided.