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

Manually merged
github merged 1 commit from github-bot/gh-2497 into main 2026-11-30 14:17:22 +00:00 AGit
Owner

@⁠fuzeofficlal on GitHub · 2026-11-29 13:39 UTC · original
fuzeofficlal:fix/shader-resource-guarded-valu-address → main · +381 −51 · 2 files · 1 commits · merged 2026-11-30 14:12 UTC

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.

Changes

  • Added Tracer::site_known and Tracer::runs_value in crates/victory-shader/src/resource.rs, threading lane conditions (known: &[(Bool, bool)]) through vorigin, vterm, vadd, sum, code_join, code_base, carried, flat_address, address, smem_address, lane_term, fetched, and waterfall.
  • Added unit tests in crates/victory-shader/src/resource.rs (a_guarded_move_is_folded_only_for_lanes_that_run_it, guarded_add_folds_inside_guard_and_stays_dynamic_after_restore, a_guarded_high_half_carry_requires_exec_coverage) and an end-to-end GPU test in crates/victory-shader/src/emit/valu_tests.rs (global_loads_keep_each_lanes_offset_after_exec_is_restored).

Verification

  • cargo test --locked -p victory-shader --lib resource::tests — all pass.
  • cargo test --locked -p victory-shader --lib emit::valu_tests::global_loads_keep_each_lanes_offset_after_exec_is_restored -- --exact — pass on RTX 5090 (VICTORY_ADAPTER=NVIDIA), WARP, and dxil.dll.
  • cargo clippy --locked -p victory-shader --all-targets — 0 new warnings in touched files.
  • cargo run --quiet --locked -p xtask -- policy --staged — pass.
**@⁠fuzeofficlal** on GitHub · 2026-11-29 13:39 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/2497) `fuzeofficlal:fix/shader-resource-guarded-valu-address` → `main` · +381 −51 · 2 files · 1 commits · merged 2026-11-30 14:12 UTC ### 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. ### Changes - Added `Tracer::site_known` and `Tracer::runs_value` in `crates/victory-shader/src/resource.rs`, threading lane conditions (`known: &[(Bool, bool)]`) through `vorigin`, `vterm`, `vadd`, `sum`, `code_join`, `code_base`, `carried`, `flat_address`, `address`, `smem_address`, `lane_term`, `fetched`, and `waterfall`. - Added unit tests in `crates/victory-shader/src/resource.rs` (`a_guarded_move_is_folded_only_for_lanes_that_run_it`, `guarded_add_folds_inside_guard_and_stays_dynamic_after_restore`, `a_guarded_high_half_carry_requires_exec_coverage`) and an end-to-end GPU test in `crates/victory-shader/src/emit/valu_tests.rs` (`global_loads_keep_each_lanes_offset_after_exec_is_restored`). ### Verification - `cargo test --locked -p victory-shader --lib resource::tests` — all pass. - `cargo test --locked -p victory-shader --lib emit::valu_tests::global_loads_keep_each_lanes_offset_after_exec_is_restored -- --exact` — pass on RTX 5090 (`VICTORY_ADAPTER=NVIDIA`), WARP, and `dxil.dll`. - `cargo clippy --locked -p victory-shader --all-targets` — 0 new warnings in touched files. - `cargo run --quiet --locked -p xtask -- policy --staged` — pass.
In resource.rs, Tracer::lane_value checked Tracer::runs for guarded VALU writes, 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. Thread lane conditions into vorigin, vadd, carried, lane_term, and sum via Tracer::site_known and Tracer::runs_value so guarded writes are folded only for lanes guaranteed to run them.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-29 13:44:35 +00:00
github manually merged commit ac848749fd into main 2026-11-30 14:17:22 +00:00
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/trustno1-coder--VIctory-NVIDIA!2497
No description provided.