fix(victory-shader): exclude partial_active tail lanes in cross-lane ops #485
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/485"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from LooperSalty/AnyXboxX. Originally posted by mauroalvare on 2026-11-27T07:34:39Z.
What failed
In
third_party/victory/crates/victory-shader/src/emit/lower.rs, spilled 64-thread wave64 compute shaders dispatched with a partial final group (USER_DISPATCH_THREADS_X, such as the ray-tracing BVH structure builder kernels) run on 32-lane hosts (NVIDIA) withself.partial_active = Some(runs)so unlaunched tail lanes stay alive in the host wave to reach group barriers.While memory operations (
memory_guard), lane-mask ballots (launched),scc_some,wave_wide, and whole-wave reductions already masked out unlaunched tail lanes viapartial_active, three cross-lane paths did not:v_permlane16_b32andv_permlanex16_b32(fi:0): ballotedguard.unwrap_or(true)withoutpartial_active, so active launched lanes reading an unlaunched tail lane received stale VGPR data instead of keepingvdst(bound_ctrl:0) or reading0(bound_ctrl:1).ds_bpermute_b32: zeroed source values usingguardalone (skippingpartial_active), so launched lanes reading an unlaunched tail lane received stale VGPR data instead of0.v_readfirstlane_b32(first_live_lane): ballotedguardwithoutpartial_active, so a guarded first-lane read matching only unlaunched tail lanes returned an unlaunched lane's value instead of falling back to lane 0 as whenEXEC == 0.On base
b62053f, the synthetic 64-thread partial-dispatch compute test fails on an RTX 5070 Ti (host_wave = 32,count = 10, lane 0) on all four checks:How to reproduce
From
third_party/victory:The synthetic spilled wave64 compute shader runs on a 32-lane host (
TEST_HOST_WAVE = 32) withUSER_DISPATCH_THREADS_Xset to10,45, and0(full 64-lane group), validating the emitted DXIL withdxil.dlland checkingv_permlane16_b32(bound_ctrl:0),v_permlanex16_b32(bound_ctrl:1),ds_bpermute_b32, and guardedv_readfirstlane_b32across all 64 lanes.What changed
third_party/victory/crates/victory-shader/src/emit/lower.rs:Lower::active_guard(&mut self, guard: Option<V>) -> Option<V>combining a lane guard withself.partial_active, and delegatememory_guardto it.self.active_guard(guard)infirst_live_lane(v_readfirstlane_b32),ds_bpermute_b32, andv_permlane16_b32/v_permlanex16_b32(fi:0).third_party/victory/crates/victory-shader/src/emit/wave64_tests.rs:partial_dispatch_cross_lane_ops_exclude_unlaunched_lanes.Verification
Tested on Windows x64, Ryzen 7 9700X, NVIDIA GeForce RTX 5070 Ti (driver
621.40), WARP, anddxil.dll(10.0.26100.0), base SHAb62053f:b62053f:partial_dispatch_cross_lane_ops_exclude_unlaunched_lanesfailed (count 10, lane 0: [115, 116, 115, 120]vs expected[43690, 0, 0, 100]).cargo test --locked -p victory-shader partial_dispatch_cross_lane_ops_exclude_unlaunched_lanes -- --test-threads=1 --nocapture: 1 passed; 0 failed (RTX 5070 Ti +dxil.dll).cargo test --locked -p victory-shader -- --test-threads=1: 318 passed; 0 failed; 4 ignored (benchmarks / explicit sweeps).cargo xtask policy: asset policy: 289 files ok.All measurements are from synthetic unit tests only (no game files or game runs).
AI assistance
Assisted by AI (Antigravity) for root-cause analysis, synthetic shader construction, implementation, and local hardware verification.
Imported from LooperSalty/AnyXboxX. Originally posted by LooperSalty on 2026-11-27T16:59:20Z.
Two things before merge:
TRANSLATOR_VERSION(victory-shader/src/lib.rs:29) stays at 2, and cached DXIL is keyed on it (shader_cache.rs). Existing caches would keep serving the unmasked shaders. Please bump it (note that #456, also open, moves it to 3; take the next free value when you rebase).v_readfirstlane, the prefix/ballot path and the shuffle ballot, butquad_pick/quad_read(DPP quad reads), the permlaneread_lane(x, src)paths andv_readlane_b32inlower.rscan still read a lane past the launched tail. On RDNA 2 those lanes are EXEC-off and must not contribute. Please mask them withactive_guardtoo, or explain why a tail lane can never be their source, and extendpartial_dispatch_cross_lane_ops_exclude_unlaunched_lanesto one of them.Imported from LooperSalty/AnyXboxX. Originally posted by mauroalvare on 2026-11-27T17:27:01Z.
Rebased onto \origin/main\ (\445308) and updated in ${sha485}:
ead_lane\ path (clamping \safe_src\ first), so reading an unlaunched tail lane yields \