Shaders: reuse source-lane activity ballots #2924

Open
github-bot wants to merge 1 commit from github-bot/gh-2924 into main AGit
Owner

@⁠Ingenioeren on GitHub · 2026-11-26 00:13 UTC · original
Ingenioeren:perf/reuse-cross-lane-ballots → main · +75 −18 · 2 files · 1 commits · open

What

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.waveActiveBallot calls 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, and v3 = 0x00010000 + lane. With EXEC narrowed to lanes where (lane & 3) != 3, it runs DPP8 v_mov_b32 v2, v1 followed by DPP8 v_add_nc_u32 v2, v2, v3. Both use selectors [1, 0, 3, 2, 5, 4, 7, 6] and fi:0. It restores EXEC and stores v2 at byte offset 4 * lane. The exact GFX10 instruction words are below.

be810380 f4080100 fa000000 4a0200ff 10000001 4a0400ff
dead0000 4a0600ff 00010000 36080083 be8c037e 7daa0883
7e0402e9 de54c101 4a0406e9 de54c102 befe030c 340a0082
e0701000 80010205 bf810000

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 local dxil.dll Pipeline State Validation failures:
    • emit::rect::tests::rectangles_get_their_fourth_corner
    • emit::tests::elements_sharing_a_row_keep_their_order
  • cargo 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.

**@⁠Ingenioeren** on GitHub · 2026-11-26 00:13 UTC · [original](https://github.com/Marvisak/VIctory/pull/2924) `Ingenioeren:perf/reuse-cross-lane-ballots` → `main` · +75 −18 · 2 files · 1 commits · open ## What 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.waveActiveBallot` calls 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`, and `v3 = 0x00010000 + lane`. With EXEC narrowed to lanes where `(lane & 3) != 3`, it runs DPP8 `v_mov_b32 v2, v1` followed by DPP8 `v_add_nc_u32 v2, v2, v3`. Both use selectors `[1, 0, 3, 2, 5, 4, 7, 6]` and `fi:0`. It restores EXEC and stores `v2` at byte offset `4 * lane`. The exact GFX10 instruction words are below. ```text be810380 f4080100 fa000000 4a0200ff 10000001 4a0400ff dead0000 4a0600ff 00010000 36080083 be8c037e 7daa0883 7e0402e9 de54c101 4a0406e9 de54c102 befe030c 340a0082 e0701000 80010205 bf810000 ``` ## 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 local `dxil.dll` Pipeline State Validation failures: - `emit::rect::tests::rectangles_get_their_fourth_corner` - `emit::tests::elements_sharing_a_row_keep_their_order` - `cargo 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.
Share the ballot for the same EXEC predicate within a DXIL block. Two dependent DPP8 instructions emit one ballot instead of two.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 05:17:37 +00:00
Author
Owner

@⁠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 one waveActiveBallot. The reuse is sound: live host lanes in a block change only at a discard, and every discard now goes through emit_discard, which clears the cache. dpp8_in_one_block_shares_the_source_activity_ballot checks the lane results against the CPU reference and the ballot count.

CI: passing.


Generated by Claude Code

**@⁠Marvisak** on GitHub · 2026-11-26 04:23 UTC · [original](https://github.com/Marvisak/VIctory/pull/2924#issuecomment-7182549862) <!-- victory-triage v1 head=061e7a6cbbb989649c4c140d1eaa919e65112db3 verdict=merge-candidate at=2026-11-26T04:23:09Z --> 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 one `waveActiveBallot`. The reuse is sound: live host lanes in a block change only at a discard, and every discard now goes through `emit_discard`, which clears the cache. `dpp8_in_one_block_shares_the_source_activity_ballot` checks the lane results against the CPU reference and the ballot count. CI: passing. --- _Generated by [Claude Code](https://claude.ai/code)_
This pull request can be merged automatically.
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin '+refs/pull/2924/head:github-bot/gh-2924'
git switch 'github-bot/gh-2924'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-2924'
git switch 'github-bot/gh-2924'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-2924'
git switch 'github-bot/gh-2924'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-2924'
git switch 'main'
git merge --squash 'github-bot/gh-2924'
git switch 'main'
git merge --ff-only 'github-bot/gh-2924'
git switch 'main'
git merge 'github-bot/gh-2924'
git push origin 'main'
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/Marvisak--VIctory!2924
No description provided.