Shaders: reuse source-lane activity ballots #2924
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!2924
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-2924"
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?
@Ingenioeren on GitHub · 2026-11-26 00:13 UTC · original
Ingenioeren:perf/reuse-cross-lane-ballots→main· +75 −18 · 2 files · 1 commits · openWhat
Reuse the source-lane activity ballot for DPP and LDS swizzle instructions that share a DXIL block and an EXEC predicate. Each instruction still checks the bit for its own source lane. Every emitted discard clears the cache because discarded lanes become helpers and stop contributing to wave ballots.
Why
The ballot depends on which host lanes are active at the call and which of those lanes satisfy the EXEC predicate. Between discards, the DXIL block and EXEC predicate determine when a ballot can be reused.
Numbers
dx.op.waveActiveBallotcalls written 2 → 1 (50% fewer). The second DPP8 instruction reuses the first instruction's ballot. The count measures emitted DXIL calls, and whether a driver compiler would already merge the two ballots was not measured.The test builds a wave32 compute shader with one 32-thread group and a raw output UAV in table slot 0. It initializes
v1 = 0x10000001 + lane,v2 = 0xdead0000 + lane, andv3 = 0x00010000 + lane. With EXEC narrowed to lanes where(lane & 3) != 3, it runs DPP8v_mov_b32 v2, v1followed by DPP8v_add_nc_u32 v2, v2, v3. Both use selectors[1, 0, 3, 2, 5, 4, 7, 6]andfi:0. It restores EXEC and storesv2at byte offset4 * lane. The exact GFX10 instruction words are below.How tested
cargo test --locked --offline -p victory-shader dpp8_in_one_block_shares_the_source_activity_ballot -- --nocapture— all 32 output dwords matched the CPU reference before and after on an AMD Radeon RX 6750 XT. The baseline failed the structural assertion with two calls. The updated test passed with one call.cargo test --locked --offline -p victory-shader— baseline 300 passed, 2 failed, 3 ignored. After the discard fix, 301 passed, 2 failed, 3 ignored. Both runs reported the same localdxil.dllPipeline State Validation failures:emit::rect::tests::rectangles_get_their_fourth_corneremit::tests::elements_sharing_a_row_keep_their_ordercargo test --locked --offline -p victory-shader --test resource_tracking— 3 passed, 0 failed, 1 ignored.cargo clippy --locked --offline -p victory-shader --all-targets— passed.cargo run -p xtask -- policy --staged— passed for the two staged files in the original change and again for the staged discard fix.No game launch or hardware run of the title. The hardware check used only the synthetic shader.
AI assistance: prepared with OpenAI Codex under Claude Code's direction, reviewed by Ingenioeren.
@Marvisak on GitHub · 2026-11-26 04:23 UTC · original
Automated triage for the maintainers.
Merge candidate.
Lower::source_active(emit/lower.rs) caches the source-lane activity ballot per (DXIL block, EXEC predicate), so DPP and swizzle ops in one block share onewaveActiveBallot. The reuse is sound: live host lanes in a block change only at a discard, and every discard now goes throughemit_discard, which clears the cache.dpp8_in_one_block_shares_the_source_activity_ballotchecks the lane results against the CPU reference and the ballot count.CI: passing.
Generated by Claude Code
View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.