Shaders: every barrier-free 1D compute program takes the DispatchX thread-count guard #3561

Open
github-bot wants to merge 2 commits from github-bot/gh-3561 into main AGit
Owner

@⁠CocoBeans64 on GitHub · 2026-11-27 17:52 UTC · original
CocoBeans64:find38-guard-1d → main · +762 −37 · 13 files · 2 commits · open

Stacked on #3426. It needs #3426's thread-count guard and its host-side conversion, and should merge after it or together with it. The commit that is new here is the top one, b900021; the rest of the diff is #3426. FIND-38 (#1633).

What

DispatchX with flag 0x20 passes thread counts, not group counts.

  • What #3426 does: it converts such a dispatch to group counts only for programs translated with the thread-count guard, and it gives the guard only to two programs it names by digest.
  • What it misses: the BVH builder has two more programs dispatched this way (flags 0x8020, 32-thread groups). They are not named, so they are not converted, and they still run 32 times the threads they ask for.
  • The change: this PR replaces the list of names with a rule. Any compute program whose groups are one-dimensional (n×1×1, n > 1) and that has no s_barrier takes the guard.
    • The host side is #3426's, unchanged. It sets the limit only for a DispatchX with flag 0x20, and leaves it at 0 (no limit) for every other dispatch, so other dispatches run exactly as before.
    • A program with s_barrier is left out: a lane that left at entry would not reach the barrier.
    • Groups in more than one dimension are left out, because the guard tests X only.
    • #3426's two named programs keep the guard either way.

Measured

In the title, on an RX 6800 XT (RDNA 2, 32..64 lanes), Windows 10 22H2, Agility SDK 1.614.

  • Trees: main 63bcca4 + #2118, then with #3426, then with #3426 + this PR.
  • Builds and runs: diag, VICTORY_GPU_TIMING=1, DRED. Menus by hand, then a few minutes in the opening world area.
  • Counter: a local one in dispatch_x, not part of this PR. It counts the lanes each DispatchX launches against the threads the counts ask for, over 300 frames while the builder runs.
builder program (group size, flags) main + #2118 + #3426 + #3426 + this PR
A (64, 0x20) ×64 guarded guarded
B (64, 0x20) ×64 guarded guarded
C (32, 0x8020) ×32 not guarded, ×32 guarded: 31.85 M lanes launched for 31.80 M threads asked
D (32, 0x8020) ×32 not guarded, ×32 guarded: one thread a call, so one 32-lane group whose other 31 lanes stop at the guard

The full numbers are in the measurement comment on #3426.

  • Image and stability: the image looks the same as with #3426 alone, and neither run had a device removal or a crash.
  • Pipelines: 1,506 compute pipelines change, the ones that now take the guard, and none is refused.
  • GPU time: 166.6 against 160.1 ms of commands per frame with #3426 alone. That is one run each in a scene that varies, so I can't tell this from noise. The guard costs a compare and a branch at entry in each such program.
  • Not shown: #2118 holds the builder back after its first frames on all three trees, for another reason (a root view's offset: no root view, or outside title buffers). So these runs don't show the builder's own cost with and without the guard.

Tests

  • New, in emit::thread_limit_tests:
    • one_dimensional_groups_without_a_barrier_take_the_thread_limit: 32×1×1 and 64×1×1;
    • programs_the_guard_would_break_or_not_cover_keep_their_groups: with s_barrier, 8×8×1, 32×1×2 and 1×1×1.
  • Run here: those two tests, plus #3426's partial_dispatch_guards_threads_past_the_tail and dispatch_x_counts_are_groups_without_a_partial_dispatch_guard. All pass.
  • Clean: cargo clippy --locked -p victory-shader --all-targets -- -D warnings, with and without --all-features.
  • cargo xtask policy passes.
  • Not run here: the full cargo test --workspace. Windows 10's runtime gives the GPU tests no SM 6.6 device without local changes, so CI will be the first to run it.

No title data in this pull request: the tests are hand-written programs (s_barrier, s_endpgm). AI-assisted (Claude).

🤖 Generated with Claude Code

**@⁠CocoBeans64** on GitHub · 2026-11-27 17:52 UTC · [original](https://github.com/Marvisak/VIctory/pull/3561) `CocoBeans64:find38-guard-1d` → `main` · +762 −37 · 13 files · 2 commits · open **Stacked on #3426.** It needs #3426's thread-count guard and its host-side conversion, and should merge after it or together with it. The commit that is new here is the top one, `b900021`; the rest of the diff is #3426. FIND-38 (#1633). ## What `DispatchX` with flag `0x20` passes thread counts, not group counts. - **What #3426 does:** it converts such a dispatch to group counts only for programs translated with the thread-count guard, and it gives the guard only to two programs it names by digest. - **What it misses:** the BVH builder has two more programs dispatched this way (flags `0x8020`, 32-thread groups). They are not named, so they are not converted, and they still run 32 times the threads they ask for. - **The change:** this PR replaces the list of names with a rule. Any compute program whose groups are one-dimensional (n×1×1, n > 1) and that has no `s_barrier` takes the guard. - The host side is #3426's, unchanged. It sets the limit only for a `DispatchX` with flag `0x20`, and leaves it at 0 (no limit) for every other dispatch, so other dispatches run exactly as before. - A program with `s_barrier` is left out: a lane that left at entry would not reach the barrier. - Groups in more than one dimension are left out, because the guard tests X only. - #3426's two named programs keep the guard either way. ## Measured In the title, on an RX 6800 XT (RDNA 2, 32..64 lanes), Windows 10 22H2, Agility SDK 1.614. - **Trees:** `main` `63bcca4` + #2118, then with #3426, then with #3426 + this PR. - **Builds and runs:** diag, `VICTORY_GPU_TIMING=1`, DRED. Menus by hand, then a few minutes in the opening world area. - **Counter:** a local one in `dispatch_x`, not part of this PR. It counts the lanes each `DispatchX` launches against the threads the counts ask for, over 300 frames while the builder runs. | builder program (group size, flags) | `main` + #2118 | + #3426 | + #3426 + this PR | |---|---|---|---| | A (64, `0x20`) | ×64 | guarded | guarded | | B (64, `0x20`) | ×64 | guarded | guarded | | C (32, `0x8020`) | ×32 | **not guarded, ×32** | guarded: 31.85 M lanes launched for 31.80 M threads asked | | D (32, `0x8020`) | ×32 | **not guarded, ×32** | guarded: one thread a call, so one 32-lane group whose other 31 lanes stop at the guard | The full numbers are in [the measurement comment on #3426](https://git.gtahub.st/github/Marvisak--VIctory/pulls/3426). - **Image and stability:** the image looks the same as with #3426 alone, and neither run had a device removal or a crash. - **Pipelines:** 1,506 compute pipelines change, the ones that now take the guard, and none is refused. - **GPU time:** 166.6 against 160.1 ms of commands per frame with #3426 alone. That is one run each in a scene that varies, so I can't tell this from noise. The guard costs a compare and a branch at entry in each such program. - **Not shown:** #2118 holds the builder back after its first frames on all three trees, for another reason (`a root view's offset: no root view, or outside title buffers`). So these runs don't show the builder's own cost with and without the guard. ## Tests - New, in `emit::thread_limit_tests`: - `one_dimensional_groups_without_a_barrier_take_the_thread_limit`: 32×1×1 and 64×1×1; - `programs_the_guard_would_break_or_not_cover_keep_their_groups`: with `s_barrier`, 8×8×1, 32×1×2 and 1×1×1. - Run here: those two tests, plus #3426's `partial_dispatch_guards_threads_past_the_tail` and `dispatch_x_counts_are_groups_without_a_partial_dispatch_guard`. All pass. - Clean: `cargo clippy --locked -p victory-shader --all-targets -- -D warnings`, with and without `--all-features`. - `cargo xtask policy` passes. - Not run here: the full `cargo test --workspace`. Windows 10's runtime gives the GPU tests no SM 6.6 device without local changes, so CI will be the first to run it. No title data in this pull request: the tests are hand-written programs (`s_barrier`, `s_endpgm`). AI-assisted (Claude). 🤖 Generated with [Claude Code](https://claude.com/claude-code)
`DispatchX` with flag 0x20 passes thread counts, not group counts
(FIND-38). #3426 converts such a dispatch to groups only for programs
translated with the thread-count guard, and gives the guard to two
programs it names by digest. The title's BVH builder has two more
programs dispatched this way (flags 0x8020, 32-thread groups) that it
does not name, and those still ran 32 times their threads.

Any compute program of one-dimensional groups (n x 1 x 1, n > 1) without
`s_barrier` now takes the guard. The host sets the limit only for a
DispatchX with flag 0x20 and leaves it at 0 (no limit) for every other
dispatch, so other dispatches are unchanged. A program with `s_barrier`
is left out, since a lane that left at entry would not reach the
barrier, and so are groups in more than one dimension, since the guard
tests X only.

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

@⁠pickles976 on GitHub · 2026-11-27 18:23 UTC · original

Verified production head b9000218cc on Linux 6.17 / Wine 11 / physical RTX 4060 Laptop 8 GiB (NVIDIA 590.48.1), 16 GiB system RAM. This is the disclosed diagnostic-relaxed-vtable vkd3d-proton 2576c0b4adfae4a+ stack, not stock certification. Production unchanged; local test-only strengthening/addition retained in VIctory-pr3561.

Five focused checks passed:

  • Shader eligibility/structural tail checks plus a new required-NVIDIA, mandatory-DXIL-validator GPU readback: 4/4, 0 ignored, 0.94 s; fresh intended-tree shader compile 6.08 s.
  • dispatch_x_counts_are_groups_without_a_partial_dispatch_guard: 1/1 CPU, 0 ignored; fresh intended-tree GPU/dependency compile 8.22 s.

The new hardware fixture emits two synthetic wave32-logical programs with 32x1x1 and 64x1x1 groups. Each stores globalThreadId.x+1 at its own UAV word. Two groups execute for each limit 0, 1, width-1, width, width+1, 2width-1, 2width, and 2*width+7. Limit zero exercises ordinary unlimited dispatch. All 1,792 output words across 16 actual NVIDIA dispatches matched, including untouched partial tails and the extra 16-word guard band. Both emitted modules passed the mandatory SDK validator. No WARP request or adapter skip.

Scope: the GPU fixture binds the thread-limit metadata through the test host; it is not an end-to-end production State::DispatchX invocation or original XboxBvhBuilder shader execution. These synthetic programs do not exercise split-Wave64/translator-inserted barriers, the unresolved scalar/lane-loop semantics, or gameplay. No matched-parent, frame-time or memory-saving claim. Preserve the barrier exclusion when evolving paired-wave lowering: early per-thread returns must not strand group-wide synchronization.

Local evidence:
.compat-runtime/logs/verify-pr3561-dispatch-tail-20261127T181754Z/
.compat-runtime/logs/verify-pr3561-dispatch-counts-20261127T181802Z/

Resource guards unchanged (9 GiB scope/512 MiB swap; global GPU 6000 MiB, available RAM 2048 MiB, disk 10 GiB). The hardware leg sampled GPU peak 234 MiB and available RAM minimum 11333 MiB. No title launched.

**@⁠pickles976** on GitHub · 2026-11-27 18:23 UTC · [original](https://github.com/Marvisak/VIctory/pull/3561#issuecomment-7225440672) Verified production head b9000218cc129b88af1be4bd536b2c215517aaf4 on Linux 6.17 / Wine 11 / physical RTX 4060 Laptop 8 GiB (NVIDIA 590.48.1), 16 GiB system RAM. This is the disclosed diagnostic-relaxed-vtable vkd3d-proton 2576c0b4adfae4a+ stack, not stock certification. Production unchanged; local test-only strengthening/addition retained in VIctory-pr3561. Five focused checks passed: - Shader eligibility/structural tail checks plus a new required-NVIDIA, mandatory-DXIL-validator GPU readback: 4/4, 0 ignored, 0.94 s; fresh intended-tree shader compile 6.08 s. - dispatch_x_counts_are_groups_without_a_partial_dispatch_guard: 1/1 CPU, 0 ignored; fresh intended-tree GPU/dependency compile 8.22 s. The new hardware fixture emits two synthetic wave32-logical programs with 32x1x1 and 64x1x1 groups. Each stores globalThreadId.x+1 at its own UAV word. Two groups execute for each limit 0, 1, width-1, width, width+1, 2*width-1, 2*width, and 2*width+7. Limit zero exercises ordinary unlimited dispatch. All 1,792 output words across 16 actual NVIDIA dispatches matched, including untouched partial tails and the extra 16-word guard band. Both emitted modules passed the mandatory SDK validator. No WARP request or adapter skip. Scope: the GPU fixture binds the thread-limit metadata through the test host; it is not an end-to-end production State::DispatchX invocation or original XboxBvhBuilder shader execution. These synthetic programs do not exercise split-Wave64/translator-inserted barriers, the unresolved scalar/lane-loop semantics, or gameplay. No matched-parent, frame-time or memory-saving claim. Preserve the barrier exclusion when evolving paired-wave lowering: early per-thread returns must not strand group-wide synchronization. Local evidence: .compat-runtime/logs/verify-pr3561-dispatch-tail-20261127T181754Z/ .compat-runtime/logs/verify-pr3561-dispatch-counts-20261127T181802Z/ Resource guards unchanged (9 GiB scope/512 MiB swap; global GPU 6000 MiB, available RAM 2048 MiB, disk 10 GiB). The hardware leg sampled GPU peak 234 MiB and available RAM minimum 11333 MiB. No title launched.
Author
Owner

@⁠kilolimaVI on GitHub · 2026-11-27 18:42 UTC · original

Hardware run, head b900021: Windows 11, Radeon 780M (RDNA3 iGPU), toolchain 1.98.1.

  • cargo test -p victory-shader on the 780M: 309 passed, 0 failed, including partial_dispatch_guards_threads_past_the_tail and thread_limit_tests::programs_the_guard_would_break_or_not_cover_keep_their_groups.
  • cargo test -p victory-gpu --features diagnostics: 249 passed, 0 failed on the 780M and on WARP, including dispatch_x_counts_are_groups_without_a_partial_dispatch_guard.

AI-assisted (Claude).

**@⁠kilolimaVI** on GitHub · 2026-11-27 18:42 UTC · [original](https://github.com/Marvisak/VIctory/pull/3561#issuecomment-7225779284) Hardware run, head b900021: Windows 11, Radeon 780M (RDNA3 iGPU), toolchain 1.98.1. - `cargo test -p victory-shader` on the 780M: 309 passed, 0 failed, including `partial_dispatch_guards_threads_past_the_tail` and `thread_limit_tests::programs_the_guard_would_break_or_not_cover_keep_their_groups`. - `cargo test -p victory-gpu --features diagnostics`: 249 passed, 0 failed on the 780M and on WARP, including `dispatch_x_counts_are_groups_without_a_partial_dispatch_guard`. AI-assisted (Claude).
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/3561/head:github-bot/gh-3561'
git switch 'github-bot/gh-3561'

Merge

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