GPU, Shaders: honor thread dimensions in direct DispatchX (#2750) #2839
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/2841"
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?
Imported from Marvisak/VIctory. Originally posted by brainbudt on 2026-11-25T21:50:13Z.
Upstream
DispatchXforwards its arguments as D3D12 group counts for every flag value. A synthetic 64×1×1 kernel asked for 65 threads with flag0x20writes past slot 64. Issue #2750 reports the same flag on BVH builder requests.What changed
0x20, AMDUSE_THREAD_DIMENSIONS) as thread dimensions and compute host group counts with ceiling division per axis.EXECballot).Dispatch, flag-clearDispatchX, and complete groups continue using the existing pipeline with byte-identical DXIL.fxceless/victory-fork@36a2257.Verification
DispatchX(65, 1, 1, 0x20)wrote exactly slots0..64(upstream failed at slot 65); following ordinary 2-groupDispatchand flag-clear 2-groupDispatchXeach wrote 128; flag-clear 65 groups wrote 4,160.1.9.2609.5): accepted both ordinary (byte-identical to upstream) and bounded shaders.cargo check --workspace --target x86_64-pc-windows-msvc --tests, andcargo clippy --workspace --target x86_64-pc-windows-msvc --tests -- -D warningspassed.Reviewed with mistral-loop: 2 rounds with Mistral Large 4 and DeepSeek V4.1 Flash (Mistral Hosted) on high. Verdict: approved.
Created with gpt-6.2-astra in Codex (orchestrated with Gemini 4 Neon in T3 Code).
Imported from Marvisak/VIctory. Originally posted by kotekompotek on 2026-11-25T21:59:04Z.
Review: COMMENTED
Correct: thread-groups conversion uses the bound pipeline's own group size with div_ceil per axis, rejects zero/overflow (>65535 groups or u32::MAX threads) into a dropped dispatch rather than an invalid call, and binds the ORIGINAL thread dims into the shader's user data — which is what DispatchX's console callers pass and read. Partial-group handling via the bounded plan is covered by the hardware test that asserts only requested threads write. The const-generic THREADS split keeps the group-dispatch path unchanged. LGTM.
Imported from Marvisak/VIctory. Originally posted by Venom2054 on 2026-11-25T22:08:30Z.
Tested
274cdadbon a physical RTX 5070 Ti, driver 621.01, through the Windows D3D12 command-list entry points.0x8020. I replayed the X dimension of 82,606 seen in the #2750 prologue trace with a synthetic guest shader that stores its entrypopcount(EXEC_LO). D3D12 counted 82,624 invocations (2,582 groups). Exactly 82,606 slots were written. The last 14 active lanes each stored 14, and the remaining 18 slots in that group kept their sentinel. An ordinary two-group dispatch after a partial dispatch on the same list and UAV wrote all 64 slots with a population of 32.8 × 8 × 4groups and a guest shader with no bounds check, requests of16 × 13 × 8,16 × 16 × 5,10 × 16 × 5and10 × 13 × 5wrote exactly 1,664, 1,280, 800 and 650 cells respectively. I checked the coordinate value in every cell of the16 × 16 × 8volume and all 17 guard words for each case. The exactly divisible0x20control and ordinary dispatches before and after wrote all 2,048 cells.The PR's four original readbacks also reproduced on hardware (65 / 128 / 128 / 4,160). As a negative control on
bc677ec1, sending ordinary groups for the partial-Y case made the test fail at exactly(0, 13, 0), the first cell outside the requested volume.The attached patch adds the synthetic 3D regression test. To repeat it on Windows, apply it to the PR branch and run
cargo test --profile diag -p victory-gpu --lib dispatch_x_3d_writes_only_requested_voxels -- --ignored --nocapture. I haven't measured in-game lighting or frame time with this PR. Test and patch prepared with Codex.native-dispatchx-3d-tests.patch.txt
Imported from Marvisak/VIctory. Originally posted by oni-swr on 2026-11-25T22:28:55Z.
Independent Windows WARP verification of
274cdadbagainst currentmain(f3578e38). I confirmed Microsoft Basic Render Driver (vendor0x1414, device0x008c, software flag0x2) withVICTORY_D3D12_WARP=1and diagnostics enabled.DispatchXwith bit 5 set wrote exactly 65 slots. Ordinary two-group Dispatch and the two bit-5-clear DispatchX controls wrote 128, 128, and 4,160 slots, respectively.mainfailed at zero-based slot 65, which held 1 instead of 0.1.8.2502.11) accepted both ordinary and bounded DXIL, and the partial-dispatch group-barrier rejection test passed.AI-assisted with Codex (gpt-6.2-sol). Claude Code (claude-opus-5-5) prepared the initial WARP guard and main comparison harness. Synthetic data only.
Imported from Marvisak/VIctory. Originally posted by Machad3x on 2026-11-25T22:30:10Z.
Hardware result at head
274cdadb, cherry-picked onto a stack that also carries the console flow for wave64 programs (#439 / #2214), RTX 3080 Ti, driver 621.24.With the two together,
translate_partial_dispatchpanics at world load (bitcode.rs, "forward reference outside a phi") for a program that numbers its threads as the console does:dispatch_guardcallsthread_id, which returns theconsole_flatvalue cached by the body, in a block that does not dominate the guard. Resetting that cache besideself.user_data = Noneindispatch_guardfixes it; a synthetic wave64 program withv_readlane_b32translated as a partial dispatch for a 32-lane target reproduces it.mainhas no such cache today, so this matters when the two meet.With that fix (and #1273): one 7-minute run in play, no device removal; in the scene at a window, GPU step median 299 ms against 307 ms before (one run each).
Ran with AI assistance (Claude Code).
Imported from Marvisak/VIctory. Originally posted by fuzeofficlal on 2026-11-25T22:40:32Z.
Verified
274cdadbon Windows 11 (RTX 5090 + WARP + SDK10.0.26100.0dxil.dll) againstmain(f3578e3):cargo test --locked -p victory-shader --test dispatch_threads: 2/2 passed on RTX 5090 and WARP (includingdxil.dllvalidation of the guardedentry->body/abortsplit).victory-gpu:thread_dimensions_cover_partial_groups_on_each_axispassed (1/1);--ignoreddispatch_x_writes_only_requested_threadspassed on RTX 5090 (0.46s) and WARP (0.31s).cargo clippy --locked(victory-shaderdefault &--features host,diagnostics;victory-gpudefault &--features diagnostics,--all-targets -- -D warnings): 0 warnings;cargo xtask policy:193 files ok.Shader::partialcompilation leaves normalDispatch, non-0x20DispatchX, and exact-multiple dispatches untouched, andState::bind_dispatchswitches root/PSO cleanly between full and partial variants.crates/victory-shader/src/emit/lower.rsreaches523,090bytes here —1,198bytes shy of the 512 KiB (524,288-byte)xtask policylimit (#2836frees 821 bytes if landed alongside).Looks solid and ready to merge.
Imported from Marvisak/VIctory. Originally posted by Dukestar69 on 2026-11-26T03:27:59Z.
Review: COMMENTED
Tested merged onto
origin/main(63bcca4) on Windows 11 x64:cargo test -p victory-shader --test dispatch_threads: 2 passed, 0 failed.cargo test -p victory-gpu --lib/cargo clippy -p victory-gpu --all-targets -- -D warnings: fails to compile against currentorigin/main(63bcca4) becausedepth_bounds_test.rs(landed onmain) initializespipeline::Translatedwithout the newthreadsfield:cargo xtask policy: 194 files ok.Rebasing onto current
mainand addingthreads: Noneincrates/victory-gpu/src/pipeline/depth_bounds_test.rs:58should make the test target build cleanly.Synthetic tests only (no game files used). AI-assisted (Gemini 4 Neon).
Imported from Marvisak/VIctory. Originally posted by Marvisak on 2026-11-26T03:19:41Z.
Automated triage for the maintainers.
Verdict: merge candidate.
dispatch_xincrates/victory-gpu/src/list.rsnow reads bit 5 of the flags (USE_THREAD_DIMENSIONS, from AMD's public register reference) as thread counts instead of group counts.thread_groupsuses ceiling division and refuses more than 65,535 groups per axis. Incomplete groups use a lazily made pipeline whose entry guard (Lower::dispatch_guardinemit/lower.rs) compares global thread IDs with the requested counts, which are passed throughDISPATCH_THREADSuser data. Ordinary dispatches keep the existing DXIL, and partial dispatches withs_barrierare refused. Hardware runs on an RTX 5070 Ti and RTX 5090, plus a WARP run, confirm exact writes, withmainfailing the same fixture at slot 65. There is no other open PR for this.Two notes for the maintainer:
lower.rsis about 1.2 KB under the 512 KiB policy cap with this PR.console_flatthread id needs resetting indispatch_guard. Whichever PR lands second should include that.CI: passing. Recommending a look, not approving.
Generated by Claude Code
Imported from Marvisak/VIctory. Originally posted by fuzeofficlal on 2026-11-26T10:52:55Z.
Review: APPROVED
Tested
c2ed5d14locally on Windows 11 (RTX 5090 + WARP,VICTORY_D3D12_DEBUG=1, and Windows SDK10.0.26100.0\x64\dxil.dll).Verification:
cargo xtask policyandcargo clippy -p victory-shader -p victory-gpu --tests -- -D warnings(default and--all-features): clean.cargo test -p victory-shader --test dispatch_threadswith SDKdxil.dll: 2/2 passed (both full and partial-dispatch DXIL containers validate cleanly withIDxcValidator, including bothUserDataCBV handle annotations fixed up byreplace_const).list::dispatch_tests::thread_dimensions_cover_partial_groups_on_each_axis: passed.list::dispatch_tests::dispatch_x_writes_only_requested_threads -- --ignored: passed on RTX 5090, RTX 5090 +VICTORY_D3D12_DEBUG=1(--features diagnostics), and WARP +VICTORY_D3D12_DEBUG=1(--features diagnostics).placed_uav_tests,pipeline::make::tests(2/2), anddraw::tests(20/20 on RTX 5090): all passed.The entry-guard structure is sound:
ir::build_boundedalready rejects branches to block 0 so moving guest inputs/body to block 1 has no entry-PHI hazard,library::namekeys PSOs by serialized root signature and DXIL bytes so full and partial pipelines do not collide,State::bind_dispatchrebinds by raw COM pointer when toggling between full and partial variants on one guest pipeline, exact multiples stay on the unguarded pipeline (preserving shaders withs_barrier), and divergent barriers in partial dispatches are cleanly refused. Looks ready to merge.Imported from Marvisak/VIctory. Originally posted by brainbudt on 2026-11-26T10:22:03Z.
Thanks @Dukestar69 — rebased onto
origin/main(63bcca4) and addedthreads: Noneincrates/victory-gpu/src/pipeline/depth_bounds_test.rs(headc2ed5d1).Imported from Marvisak/VIctory. Originally posted by Jackster on 2026-11-26T16:06:31Z.
AMD verification of
c2ed5d1on a Radeon RX 7900 XTX (gfx1100, 32.0.32029.2010), Windows 11, hardware adapter:dispatch_x_writes_only_requested_threadspasses on the hardware adapter: 65 threads with flag0x20write exactly slots 0..64, and the ordinary and flag-clear controls keep their old counts.--test dispatch_threads: 2/2.cargo test -p victory-gpu --lib: 232 passed / 0 failed / 2 ignored.63bcca4, the same fixture withthread_groupsremoved: fails at slot 65 (slot 65, expected 65 writes), so the upstream forwarding reproduces on this card.Synthetic only, no game files. AI-assisted.
Imported from Marvisak/VIctory. Originally posted by kilolimaVI on 2026-11-26T20:52:09Z.
NEW-284 verification on current head, Windows 11, toolchain 1.98.1,
--test-threads=1. Hardware: AMD Radeon 780M (RDNA3 iGPU). WARP:VICTORY_WARP=1for victory-shader,VICTORY_D3D12_WARP=1with--features diagnosticsfor victory-gpu.cargo test -p victory-shader -p victory-gpu --locked --no-fail-fast: no failures on the 780M; on WARP only the four synthetic_tests failures main63bcca4also has (WARP-only harness issue, fixed by #2225). victory-gpu on WARP: 247 passed, 0 failed (main: 246).thread_dimensions_cover_partial_groups_on_each_axis,partial_and_group_dispatch_translate_to_distinct_programs,partial_dispatch_refuses_a_divergent_group_barrier.dispatch_x_writes_only_requested_threads(--ignored) passes on the 780M and on WARP. CI never runs it, so this is its first SM 6.6 hardware result.AI-assisted (Claude).
Imported from Marvisak/VIctory. Originally posted by kotekompotek on 2026-11-27T03:20:28Z.
WARP verification of head
c2ed5d14(NEW-284 claim: #1633)Environment: Windows 10 22H2, WARP software adapter (
VICTORY_WARP=1 VICTORY_D3D12_WARP=1), rust 1.98.1 msvc. Important local caveat: both adapters on this machine cap at SM 6.2, so SM-6.6 pipeline execution is impossible here for upstream code equally (proven: upstream's own SM-6.6 pipeline tests fail at creation on unmodified main63bcca43). victory-gpu runs use--features diagnostics— WARP selection is feature-gated there — and--test-threads=1serial.victory-gpu: 244 passed / 3 failed / 2 ignored vs baseline 243/3/1 — zero regressions; failure set bit-identical to main (all 3 are WARP-environmental failures that exist on main).
list::dispatch_tests::thread_dimensions_cover_partial_groups_on_each_axis: PASStests/dispatch_threads.rs: both PASS — including DXIL validation of ordinary and bounded variants with system dxil.dll 10.0.26100;partial_dispatch_refuses_a_divergent_group_barrierPASSdispatch_x_writes_only_requested_threadsis upstream-#[ignore]d (needs SM 6.6): force-run fails withcompute PSO unavailableon WARP and hardware alike — the environmental SM-6.6 wall above, not a PR defect--libresults bit-identical to baselineframe::tests::waits_end_on_ticks_and_count_framesfailed in two full-suite runs under heavy parallel build load; interleaved isolated reruns passed 10/10 on main and 10/10 on this head, and clean full-suite runs are regression-free — a load-sensitive timing assertion, not a regressionVerdict: verification supports.
Imported from Marvisak/VIctory. Originally posted by upipibi on 2026-11-28T02:10:49Z.
The visible effect of this, for priority. I read the forks' notes and ran nothing.
docs/findings.md) list among its faults: "Every ray missed: the dispatch flag that says counts are threads, not groups."So the BVH builder dispatches #2750 points at are what the title's ray tracing depends on: without this flag honoured, rays miss.
AI-assisted (Claude Code, Claude Opus 5.5 read the forks' notes).
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.Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.