GPU, Shaders: direct dispatches past 65,535 groups in x run in parts #3086
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!3086
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-3086"
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?
@0xkn0wh3r3 on GitHub · 2026-11-26 07:03 UTC · original
0xkn0wh3r3:gpu/dispatch-x-past-65535-in-parts→main· +169 −4 · 4 files · 3 commits · openWhat
The console runs more than 65,535 thread groups in x in one dispatch. D3D12 refuses more than
D3D12_CS_DISPATCH_MAX_THREAD_GROUPS_PER_DIMENSION, andState::dispatchpassed the title's counts straight through.A direct
Dispatchwith more than 65,535 groups in x now runs in parts of at most 65,535, with y and z as asked.RootType::Other(GROUP_BASE), placed past the console's user data. It holds the first group of the part being run, and is 0 as bound.State::dispatchsets that dword to each part's first group (dispatch_parts), then back to 0 afterwards.victory_shader::SOURCE_HASH), so old entries aren't found and the cache magic staysVSH1.Relation to #2312 and #2841
Where it came from
From DexNom's fork, DexNom/VIctory@570a941:
USER_GROUP_BASEadded to the group id, and the direct dispatch run in parts. Here it's on this tree's user-data model. DexNom applied it only to programs that read neither group y nor group z. Adding the base to group x is right whatever else the program reads, so this PR applies it to every compute program that reads group x. Credited withCo-authored-by: DexNom.Tested
emit::semantics_tests::group_x_starts_at_the_dispatch_part: a translated program run with base 1, on the hardware adapter and on WARP, reads its input and writes its output as group 1. Group 0's output stays untouched. It fails without the change (no base dword).draw::tests::large_dispatches_run_in_parts: 0, 100, 65,535, 65,536, 115,200 andu32::MAXgroups each split into parts of at most 65,535 that cover every group once.cargo test -p victory-gpu --lib: 231 passed. The 2 failures are the ones #2121 fixes; they fail the same on main.cargo test -p victory-shader --lib(skippingheap_direct_texture_reads_mark_their_heap_index, which crashes on main): 297 passed and 5 failed. All 5 fail the same on main: the 2stride_tests,gathers_at_a_level_match_the_hardware,rectangles_get_their_fourth_cornerandelements_sharing_a_row_keep_their_order.cargo clippy -p victory-shader -p victory-gpu --all-targets -- -D warnings, andvictory-gpuwith--features diagnostics: clean.Not tested
@Dukestar69 on GitHub · 2026-11-26 07:07 UTC · original · approved these changes
Tested locally merged onto
origin/main(63bcca4) on Windows 11 x64 (NVIDIA GeForce RTX 5090 + WARP +dxil.dll):cargo test -p victory-shader group_x_starts_at_the_dispatch_part -- --test-threads=1(RTX 5090 & WARP): 1 passed, 0 failed on both.cargo test -p victory-gpu draw::tests -- --test-threads=1(RTX 5090): 21 passed, 0 failed (includinglarge_dispatches_run_in_parts).cargo test -p victory-gpu shader_cache::tests: 4 passed, 0 failed.cargo clippy -p victory-shader -p victory-gpu --all-targets -- -D warnings: clean.cargo xtask policy: 191 files ok.Synthetic tests only (no game files used). AI-assisted (Gemini 4 Neon).
@oni-swr on GitHub · 2026-11-26 07:27 UTC · original
Independent WARP verification of this PR at exact head
44375c12(parent63bcca4,main). Claim: #1633Setup. Windows 11, WARP only; the physical GPU was never used.
VICTORY_WARP=1(this is what makes the shader test host'sHost::new(false)pick WARP too) andVICTORY_D3D12_WARP=1(read by victory-gpu only with--features diagnostics, which I built with). The test device was confirmed from its LUID:Microsoft Basic Render Driver,DXGI_ADAPTER_FLAG_SOFTWAREset, vendor 0x1414, 0 dedicated VRAM. Shaders were validated with the Windows SDKdxil.dll(10.0.26100.0).cargo -j 4.Boundary / group-ID check (local harness, not part of the PR: it lowers the same synthetic program as
group_x_starts_at_the_dispatch_part, with unique input dwords, and runs it the wayState::dispatchdoes:dispatch_partssplit,GROUP_BASE= each part's first group). Per part it checks that the groups of that part hold exactly their own input, and that every other group is untouched.GROUP_BASEdword)PR head: 0 mismatches in all 12 cases (parts of at most 65,535 covering every x group once). The parent is the control: the same split without a base word gives the wrong group ids for every part after the first, so the check does tell the two apart. Dispatches of 65,535 in y or z and x=65,536 with y=2, z=3 ran and matched (the shader keys on group x only, so the y/z groups write the same values; this covers that y/z are passed through with the parts, not that y/z are numbered).
Focused suites on the PR head (all WARP):
cargo test -p victory-gpu --lib --features diagnostics -- draw::tests::large_dispatches_run_in_parts shader_cache: 5 passed (includes theVSH2cache entries).cargo test -p victory-shader --lib -- emit::semantics_tests --test-threads=1: 35 passed, 1 ignored (existingdefect_ignore), includesgroup_x_starts_at_the_dispatch_part. Both of its adapter iterations ran on WARP here.emit::flow_tests,memory_tests,crosslane_tests,waterfall_tests,valu_tests: 51 passed.Limitations. Synthetic inputs only; no game files, shader names, hashes, dumps or retail artifacts. WARP only, so nothing here speaks for GPU drivers. Not tested: y or z over 65,535 (D3D12 refuses it, and I did not send it to the device), indirect dispatches, the real
State::dispatchcommand-list path (I replicated its split and base writes in the harness;dispatch_partsitself is covered by the PR's unit test), and theSetComputeRoot32BitConstantreset back to 0 for a following dispatch. The fullvictory-gpuandvictory-shadersuites were not run, so the PR's stated pre-existing failures were neither confirmed nor refuted.The harness stayed local and the PR was not touched.
AI use: Claude Code (Claude Sonnet 5.5), coordinated by Codex (gpt-6.2-sol).
@fuzeofficlal on GitHub · 2026-11-26 08:00 UTC · original · reviewed
Tested locally on Windows 11 x64 (
rustc 1.98.1, NVIDIA GeForce RTX 5090 + WARP + SDKdxil.dll):cargo clippy -p victory-shader -p victory-gpu --all-targets --locked -- -D warnings(default and--all-features): clean.cargo test -p victory-shader --lib --locked -- emit::semantics_tests --test-threads=1: 35 passed, 0 failed, 1 ignored (group_x_starts_at_the_dispatch_partverified on both RTX 5090 and WARP).cargo test -p victory-gpu --lib --locked -- draw::tests --test-threads=1: 21 passed, 0 failed on both RTX 5090 and WARP (--features diagnostics,VICTORY_D3D12_WARP=1).cargo test -p victory-gpu --lib --locked -- shader_cache::tests --test-threads=1: 4 passed, 0 failed on both RTX 5090 and WARP.cargo xtask policy: 191 files ok.The lowering and split logic look solid:
lower.rsdoes not emitSV_DispatchThreadID(threadId.i32), so offsettingInput::GroupId(0)shifts derived global IDs consistently;index = max(p.user_data + p.sgprs)avoids collisions withROOT_SRV_VIEW/ROOT_UAV_VIEW/ROOT_VIEW_OFFSET; anddispatch_partshandles0..=u32::MAXwithout overflow.One small diagnostics bug to fix in
crates/victory-gpu/src/draw.rs(op_text, under#[cfg(feature = "diagnostics")]):State::bindspecial-casesRootType::Other(victory_shader::emit::GROUP_BASE) => 0, butop_textiteratest.host.user_data.iter().filter(|u| !is_root_view(u))and callsself.user_value(compute, u.slot, u.root, u.dword). For any compute shader readingGroupId(0), that hitsuser_value's fallback_ =>arm, logging a spurious"a shader reads a root argument the title did not set"warning (slot = 0, root = Other(260)) and printing a bogus[heap 0: ...]lookup inop_text. Filtering outu.root == RootType::Other(victory_shader::emit::GROUP_BASE)alongside!is_root_view(u)avoids this.Minor non-blocking note:
MAGICfromVSH1toVSH2incrates/victory-gpu/src/shader_cache.rsis not strictly needed: the binary encoding didn't change (root_code/root_typealready round-tripRootType::Other(0x104)), andshader_cache::build()already hashesvictory_shader::SOURCE_HASHinto both the cache subdirectory and key. KeepingVSH1would avoid an unnecessary merge conflict with other PRs touchingshader_cache.rs(such as #2948).@0xkn0wh3r3 on GitHub · 2026-11-26 08:03 UTC · original
Thanks, both taken in
e4fa1a1b.op_textnow skips theGROUP_BASEroot alongside root views, so a compute program that reads its group x no longer logs a spurious unset root argument or a heap lookup for it. The cache magic is back toVSH1:build()already hashesvictory_shader::SOURCE_HASH(and the encoding file's own text) into the key, so old entries aren't found anyway. That also removes theVSH2overlap with #2948.draw::testsandshader_cachepass with and without--features diagnostics, and clippy is clean both ways.@Marvisak on GitHub · 2026-11-26 08:21 UTC · original
Automated triage for the maintainers.
Needs work (small). The approach looks right.
State::dispatchsplits a direct dispatch with more than 65,535 groups in x into parts (dispatch_parts). Each part's first group goes into a host-filled root constant (RootType::Other(GROUP_BASE)), which is bound as 0 in the user-data loop and reset to 0 after the parts. Inemit/lower.rs,group_xadds that constant to group x for CS programs only. The unit test and the semantics test cover the split and the base.Needed before merge:
emit/lower.rs,group_xwas inserted betweencompute_idand its doc comment.group_x's doc now begins with "A component of a compute thread or group id, read in the entry block." andcompute_idhas no doc. Please move that line back abovefn compute_id.CI: passing (check).
Generated by Claude Code
@0xkn0wh3r3 on GitHub · 2026-11-26 08:23 UTC · original
Fixed in
2fd63f00: the doc line is back abovefn compute_id, andgroup_xkeeps only its own doc. On #2312: agreed, that's your call. Both claim the first user-data dword past the console's, so whichever lands second moves its word by one, and I'll rebase this onto #2312 if you take that one. The difference is that this PR covers direct dispatches with any y and z (including z > 1, which #2312 leaves out), while #2312 also covers indirect dispatches.@fuzeofficlal on GitHub · 2026-11-26 08:29 UTC · original · approved these changes
Both points from the earlier review are cleanly addressed in
e4fa1a1b(and the doc comment placement cleanup in2fd63f00looks good):op_textincrates/victory-gpu/src/draw.rsnow filters outRootType::Other(victory_shader::emit::GROUP_BASE), avoiding spurious missing-root-argument warnings and bogus heap lookups in diagnostics logs.crates/victory-gpu/src/shader_cache.rsis left untouched onVSH1, relying onvictory_shader::SOURCE_HASHfor cache invalidation without colliding with other cache format work.Verified locally on Windows 11 (RTX 5090 + WARP):
cargo clippy -p victory-shader -p victory-gpu --all-targets -- -D warnings(default and--all-features): cleanvictory-shaderemit::semantics_tests::group_x_starts_at_the_dispatch_part: passed (both hardware and WARP paths)victory-gpudraw::tests(21/21 on RTX 5090, 21/21 on WARP with--features diagnostics) andshader_cache::tests(4/4): all passedcargo xtask policy: 191 files okLGTM.
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.