Repository navigation
GPU: add VICTORY_INDIRECT_CLAMP=0 opt-out to bypass per-draw argument clamping - #169
HailLucifer666 wants to merge 1 commit into
Conversation
… clamping THE BUG. Every ExecuteIndirect call (even when batched via VICTORY_INDIRECT_WINDOW=1) runs a clamp compute shader between two global UAV barriers and state transitions and invalidates cached host compute pipeline/root-signature state. WHY NOT HYPOTHETICAL. In gameplay, thousands of indirect mesh draws per frame pay compute/graphics mode switches, scratch-buffer copies, barrier stalls, and state rebinds even when the title argument buffers are already valid. THE FIX. Add VICTORY_INDIRECT_CLAMP (enabled by default; 0/false/no/off disables clamping). When disabled, draw::State::indirect validates record alignment/stride via indirect::validate_layout, refreshes the argument/count shadow ranges, emits a single UAV barrier (indirect::wait_direct), and executes ExecuteIndirect directly from the title argument buffer without running the clamp shader, scratch copy, state transitions, or pipeline invalidation. SCOPE. Only the indirect argument clamping path in indirect.rs and draw.rs. Default behavior (clamping enabled) is unchanged.
…DIRECT_CLAMP=0 opt-out to bypass per-draw argument clamping Part of #16
|
Tested this on GTA VI (Series X build), RTX 5080, Windows 11, with With The title's own crash reporter then starts (blocked upload to backtrace.io). That is a deliberate null write: the game's own fatal path, not a fault in VIctory. Both runs died about 90 s after launch, during the load into the world, before any gameplay frame. The same binary with the clamp left on (the default) loads and plays normally. So on GTA VI at least, some indirect arguments the title produces need the clamp, presumably group counts the clamp zeroes or bounds. Running One caveat for honesty: the same crash site showed up once before, on a first launch of a build with the BVH builder (#36), which then loaded fine on relaunch. Here it reproduced on the relaunch too, with a warm shader cache, which is why I attribute it to the switch. Context, in case it helps anyone working on GPU time: on this card the frame is front-end bound (Nsight Systems GPU metrics during gameplay: GR active ~75%, SMs active ~28%, SM issue ~4%), with ~5,000 one-record indirect mesh draws per frame, each with its clamp pass. So the cost of the clamp + (Tested and written with the help of an AI assistant, Claude Code; numbers above are from our own runs.) |
Problem
ExecuteIndirectcall (even when batched viaVICTORY_INDIRECT_WINDOW=1) runs a clamp compute shader between two global UAV barriers and state transitions, and invalidates cached host compute pipeline and root-signature state.Fix
VICTORY_INDIRECT_CLAMP(enabled by default;0/false/no/offdisables clamping).draw::State::indirectvalidates record alignment/stride viaindirect::validate_layout, refreshes the argument/count shadow ranges, emits a single UAV barrier (indirect::wait_direct), and executesExecuteIndirectdirectly from the title's argument buffer without running the clamp compute pass, scratch copy, state transitions, or pipeline invalidation.Verification
parse_clamp_enabled_defaults_on_and_respects_explicit_disableandvalidate_layout_rejects_misaligned_or_overflowing_direct_arguments.cargo clippy --workspace --all-targets --locked -- -D warningscargo clippy --workspace --all-targets --all-features --locked -- -D warningscargo test -p victory-gpu indirect:: --locked -- --test-threads=1(9/9 passed)cargo test -p xtask --locked(4/4 passed)