Shaders: require EXEC coverage when tracing VALU address operands #2923

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

@⁠fuzeofficlal on GitHub · 2026-11-26 00:13 UTC · original
fuzeofficlal:fix/shader-resource-guarded-valu-address → main · +367 −50 · 2 files · 1 commits · open

Problem

In crates/victory-shader/src/resource.rs, Tracer::lane_value already calls Tracer::runs(site, known) to verify that every lane reaching a consumer actually executed each guarded VALU write. However, vorigin, vadd, carried (v_add_co_ci_u32), lane_term, and sum followed guarded v_mov_b32 / v_add_co_u32 / v_add_nc_u32 / v_add_co_ci_u32 definitions without checking lanes.guards.

When a shader updates a VGPR offset (or high-half address carry) under narrowed EXEC (e.g. v_cmp_* + s_and_saveexec_b32), restores EXEC, and executes a global_load_* / global_store_* / global_atomic_*:

  • flat_address folded the guarded add/move into a static Address::offset for every lane, so lanes skipped while EXEC == 0 silently read or wrote at the wrong offset.
  • A guarded v_add_co_ci_u32 high-half carry after EXEC restore was still attributed to the root parameter instead of falling back to MEMORY.

Changes

  • Added Tracer::site_known and Tracer::runs_value in crates/victory-shader/src/resource.rs, threading lane conditions (known: &[(Bool, bool)]) and guard tracking (unguarded: &mut bool) through vorigin, vterm, vadd, sum / sum_tracked, carried, flat_address, address, traced_address, smem_address, lane_term, fetched, and waterfall.
  • Restricted Tracer::sums memoization to sums traced without encountering any EXEC guard (local == true), preventing guarded and unguarded uses of the same SSA Value (or its ancestors) from poisoning each other regardless of visit order while still allowing unguarded siblings to cache.
  • Left emit/lower.rs untouched.

Verification

All tests use synthetic GFX10 encodings (no external files):

  • Added 3 unit tests in crates/victory-shader/src/resource.rs:
    • a_guarded_move_is_folded_only_for_lanes_that_run_it (same guard folds, s_xor_b32 else-arm and post-restore copy stay dynamic)
    • sums_with_guarded_terms_are_not_cached_in_either_order (checks both visit orders and verifies Tracer::sums stays unpopulated for guarded ancestors)
    • a_guarded_high_half_carry_requires_exec_coverage (guarded v_add_co_ci_u32 folds inside guard and falls back to MEMORY after restore)
  • Added end-to-end DXIL + GPU test emit::synthetic_tests::global_stores_keep_each_lanes_offset_after_exec_is_restored: verified with Windows SDK 10.0.26100.0 dxil.dll, NVIDIA GeForce RTX 5090 (hardware), and D3D12 WARP (VICTORY_WARP=1).
  • cargo test --locked -p victory-shader --lib -- resource::tests emit::lower::tests emit::flow_tests emit::waterfall_tests global_stores_keep_each_lanes_offset_after_exec_is_restored: 78/78 passed on RTX 5090, and global_stores_keep_each_lanes_offset_after_exec_is_restored passed on WARP.
  • cargo clippy --locked -p victory-shader --all-targets -- -D warnings (default and --all-features) and cargo xtask policy (191 files ok): clean.
**@⁠fuzeofficlal** on GitHub · 2026-11-26 00:13 UTC · [original](https://github.com/Marvisak/VIctory/pull/2923) `fuzeofficlal:fix/shader-resource-guarded-valu-address` → `main` · +367 −50 · 2 files · 1 commits · open ### Problem In `crates/victory-shader/src/resource.rs`, `Tracer::lane_value` already calls `Tracer::runs(site, known)` to verify that every lane reaching a consumer actually executed each guarded VALU write. However, `vorigin`, `vadd`, `carried` (`v_add_co_ci_u32`), `lane_term`, and `sum` followed guarded `v_mov_b32` / `v_add_co_u32` / `v_add_nc_u32` / `v_add_co_ci_u32` definitions without checking `lanes.guards`. When a shader updates a VGPR offset (or high-half address carry) under narrowed `EXEC` (e.g. `v_cmp_*` + `s_and_saveexec_b32`), restores `EXEC`, and executes a `global_load_*` / `global_store_*` / `global_atomic_*`: - `flat_address` folded the guarded add/move into a static `Address::offset` for every lane, so lanes skipped while `EXEC == 0` silently read or wrote at the wrong offset. - A guarded `v_add_co_ci_u32` high-half carry after `EXEC` restore was still attributed to the root parameter instead of falling back to `MEMORY`. ### Changes - Added `Tracer::site_known` and `Tracer::runs_value` in `crates/victory-shader/src/resource.rs`, threading lane conditions (`known: &[(Bool, bool)]`) and guard tracking (`unguarded: &mut bool`) through `vorigin`, `vterm`, `vadd`, `sum` / `sum_tracked`, `carried`, `flat_address`, `address`, `traced_address`, `smem_address`, `lane_term`, `fetched`, and `waterfall`. - Restricted `Tracer::sums` memoization to sums traced without encountering any `EXEC` guard (`local == true`), preventing guarded and unguarded uses of the same SSA `Value` (or its ancestors) from poisoning each other regardless of visit order while still allowing unguarded siblings to cache. - Left `emit/lower.rs` untouched. ### Verification All tests use synthetic GFX10 encodings (no external files): - Added 3 unit tests in `crates/victory-shader/src/resource.rs`: - `a_guarded_move_is_folded_only_for_lanes_that_run_it` (same guard folds, `s_xor_b32` else-arm and post-restore copy stay dynamic) - `sums_with_guarded_terms_are_not_cached_in_either_order` (checks both visit orders and verifies `Tracer::sums` stays unpopulated for guarded ancestors) - `a_guarded_high_half_carry_requires_exec_coverage` (guarded `v_add_co_ci_u32` folds inside guard and falls back to `MEMORY` after restore) - Added end-to-end DXIL + GPU test `emit::synthetic_tests::global_stores_keep_each_lanes_offset_after_exec_is_restored`: verified with Windows SDK 10.0.26100.0 `dxil.dll`, NVIDIA GeForce RTX 5090 (`hardware`), and D3D12 WARP (`VICTORY_WARP=1`). - `cargo test --locked -p victory-shader --lib -- resource::tests emit::lower::tests emit::flow_tests emit::waterfall_tests global_stores_keep_each_lanes_offset_after_exec_is_restored`: **78/78 passed** on RTX 5090, and `global_stores_keep_each_lanes_offset_after_exec_is_restored` passed on WARP. - `cargo clippy --locked -p victory-shader --all-targets -- -D warnings` (default and `--all-features`) and `cargo xtask policy` (`191 files ok`): clean.
In resource.rs, Tracer::lane_value already checked Tracer::runs to ensure every active lane at a use site executed a guarded VALU write, but vorigin, vadd, carried (v_add_co_ci_u32), lane_term, and sum followed guarded v_mov_b32 / v_add_co_u32 / v_add_nc_u32 / v_add_co_ci_u32 definitions without checking EXEC guards.

When a shader modifies a VGPR offset or address pair under narrowed EXEC (for example via s_and_saveexec_b32), restores EXEC, and performs a global_load / global_store / global_atomic, flat_address folded the guarded offset statically or attributed the high half to a root parameter, causing lanes whose EXEC bit was clear during the guarded write to read or write the wrong offset.

Thread the use site's lane conditions into vorigin, vadd, carried, lane_term, and sum via Tracer::site_known and Tracer::runs_value, and cache entries in Tracer::sums only when tracing relied on no EXEC guards so guarded and unguarded consumers of the same SSA value do not poison each other.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 05:17:36 +00:00
Author
Owner

@⁠Jackster on GitHub · 2026-11-26 01:08 UTC · original

Independent verification on Windows 11 26100, AMD Radeon RX 7900 XTX (RDNA3, driver 32.0.32029.2010), Rust 1.100.0, Windows SDK 10.0.26100.0 (dxil.dll):

cargo test --locked -p victory-shader --lib -- resource::tests emit::lower::tests emit::flow_tests emit::waterfall_tests global_stores_keep_each_lanes_offset_after_exec_is_restored
→ 78 passed; 0 failed (1.23 s)

All three new resource::tests pass, and global_stores_keep_each_lanes_offset_after_exec_is_restored runs on both backends:

  • hardware: verified narrowed and restored EXEC stores
  • VICTORY_WARP=1: WARP: verified narrowed and restored EXEC stores

DXIL validation ran with the SDK's dxil.dll (Validator::default_path selects 10.0.26100.0\x64\dxil.dll).

cargo clippy --locked -p victory-shader --all-targets -- -D warnings: clean. cargo xtask policy: 191 files ok.

No game files. AI-assisted.

**@⁠Jackster** on GitHub · 2026-11-26 01:08 UTC · [original](https://github.com/Marvisak/VIctory/pull/2923#issuecomment-7179482018) Independent verification on Windows 11 26100, AMD Radeon RX 7900 XTX (RDNA3, driver 32.0.32029.2010), Rust 1.100.0, Windows SDK 10.0.26100.0 (`dxil.dll`): ``` cargo test --locked -p victory-shader --lib -- resource::tests emit::lower::tests emit::flow_tests emit::waterfall_tests global_stores_keep_each_lanes_offset_after_exec_is_restored → 78 passed; 0 failed (1.23 s) ``` All three new `resource::tests` pass, and `global_stores_keep_each_lanes_offset_after_exec_is_restored` runs on both backends: - `hardware: verified narrowed and restored EXEC stores` - `VICTORY_WARP=1`: `WARP: verified narrowed and restored EXEC stores` DXIL validation ran with the SDK's `dxil.dll` (`Validator::default_path` selects `10.0.26100.0\x64\dxil.dll`). `cargo clippy --locked -p victory-shader --all-targets -- -D warnings`: clean. `cargo xtask policy`: 191 files ok. No game files. AI-assisted.
Author
Owner

@⁠Marvisak on GitHub · 2026-11-26 04:22 UTC · original

Automated triage for the maintainers.

Merge candidate. This fixes a real hole in victory-shader/src/resource.rs: vorigin, vadd, carried and sum followed v_mov_b32 / v_add_* / v_add_co_ci_u32 definitions written under narrowed EXEC without the runs() coverage check lane_value already makes, so lanes that skipped the write got a wrong static offset. The new site_known / runs_value threading through flat_address, address, traced_address, smem_address, lane_term and waterfall reads correctly, and restricting the sums cache to unguarded traces is right. The end-to-end test's expected values follow from EXEC semantics. Note for the maintainer: the descriptor-from-memory path now passes an empty known, which is more conservative and can fall back to MEMORY where it used to resolve to a root parameter.

CI: passing.


Generated by Claude Code

**@⁠Marvisak** on GitHub · 2026-11-26 04:22 UTC · [original](https://github.com/Marvisak/VIctory/pull/2923#issuecomment-7182544250) <!-- victory-triage v1 head=208ada7b953843163f75f0f6a337e9f1b11b584e verdict=merge-candidate at=2026-11-26T04:22:42Z --> Automated triage for the maintainers. **Merge candidate.** This fixes a real hole in `victory-shader/src/resource.rs`: `vorigin`, `vadd`, `carried` and `sum` followed `v_mov_b32` / `v_add_*` / `v_add_co_ci_u32` definitions written under narrowed EXEC without the `runs()` coverage check `lane_value` already makes, so lanes that skipped the write got a wrong static offset. The new `site_known` / `runs_value` threading through `flat_address`, `address`, `traced_address`, `smem_address`, `lane_term` and `waterfall` reads correctly, and restricting the `sums` cache to unguarded traces is right. The end-to-end test's expected values follow from EXEC semantics. Note for the maintainer: the descriptor-from-memory path now passes an empty `known`, which is more conservative and can fall back to MEMORY where it used to resolve to a root parameter. CI: passing. --- _Generated by [Claude Code](https://claude.ai/code)_
This pull request can be merged automatically.
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/2923/head:github-bot/gh-2923'
git switch 'github-bot/gh-2923'

Merge

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