Shaders: reuse lane guards for unchanged EXEC within a block #617
No reviewers
Labels
No labels
accessibility
area: build
area: formats
area: gpu
area: loader
area: runtime
area: shader
bug
documentation
duplicate
enhancement
good first issue
gpu: amd
gpu: intel
gpu: nvidia
help wanted
host: wine
invalid
out of scope
question
request
run report
triage: confirmed
triage: has patch
triage: merge candidate
triage: needs info
triage: needs rebase
triage: needs work
triage: proposed close
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/Marvisak--VIctory!617
Loading…
Reference in a new issue
No description provided.
Delete branch "gh-pr/617/head"
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?
@yyc160 on GitHub · 2026-11-24 05:42 UTC · original
yyc160:perf/reuse-shader-guards→main· +96 −2 · 3 files · 1 commits · merged 2026-11-25 00:11 UTCChange
Lanes::finishused to ask whether the block implies EXEC and, if not, simplifyEXEC under the block condition for every guarded vector instruction. Within a
block that condition is fixed. Reuse the previous result (including
None)when the instruction has the same EXEC. Scalar instructions still bypass this
logic, and the cache starts empty at each block. This avoids repeated calls;
it does not change how any individual BDD query is evaluated.
The regression test covers a branch where the same EXEC goes from requiring a
guard to requiring none, a second comparison that changes EXEC within the
fallthrough, and a scalar instruction between guarded vector instructions.
Measurements
cargo bench --locked -p victory-shader --bench guard_runs, Windows x64,Rust 1.98.1, comparing
d2a4bae(with the benchmark only) to81b81df.Microseconds per synthetic program, timing only
structureon prebuilt IR.Each binary reports the median of 9 batches of 64 calls; the table gives the
median of five process runs per binary, alternating which binary ran first.
The last case spends 83% less time in this pass. It is not an end-to-end
compilation, frame-rate, or visual-correctness measurement. No title files or
GPU are required to run the benchmark. To reproduce the baseline, apply just
the benchmark file and its Cargo manifest entry to a separate checkout of
d2a4bae, then run the same command.Verification
cargo test --workspace --locked -- --test-threads=1: 265 passed, 4 ignored.Both WARP switches were enabled;
VICTORY_DXILpointed to the installedWindows SDK's x64 validator. A parallel baseline run had exited in
d3d10warp.dllbefore the optimisation; this PR does not address that failure.cargo build --locked --release -p victory: passed.cargo clippy --locked -p victory-shader --all-targets: passed.cargo xtask policyandcargo xtask policy --staged: passed.@geiyiliyabumo on GitHub · 2026-11-24 10:48 UTC · original
Independent verification & code review on Windows 11 Pro (build 26100) + AMD Radeon RX 9060 XT (RDNA4, driver
32.0.32029.2010, Rust1.98.1), cleanly merged ontomain(ffe310e):cargo xtask policy: PASS (155 files ok)cargo clippy -p victory-shader --all-targets --locked -- -D warnings: PASS (includes newbenches/guard_runs.rs)cargo clippy -p victory-shader --all-targets --features diagnostics --locked -- -D warnings: PASScargo test -p victory-shader --locked: 121 passed, 0 failed, 1 ignored (including newstructure::tests::guards_follow_exec_and_block_reachability)VICTORY_D3D12_DEBUG=1 cargo test -p victory-shader --locked -- diff_tests: 4/4 PASS on RX 9060 XT and 4/4 PASS on WARP (VICTORY_WARP=1)Diff review (
structure.rs,benches/guard_runs.rs,Cargo.toml): clean and exact —cond[n]is invariant within a block,BoolIDs are append-only interned handles, and intervening scalar ops do not clobberlast_guardwhenestays identical.AI-assisted; synthetic tests only, no game files.