Repository navigation
D3D12.X: compile the indirect guard with DXC, and guard split chains - #3536
Conversation
Zippp69
left a comment
There was a problem hiding this comment.
Skip DXC-dependent tests when the compiler is unavailable
The guard shader compilation test and the indirect dispatch GPU test both unwrap dxc::compile, so both fail when DXC is missing. Check dxc::location() and use skip_test("no DXC") if the compiler is unavailable. Keep the compilation assertions so shader errors still fail the tests when DXC is installed.
I verified that the proposed patch applies to 8300b4e. I did not run the XCL tests. Codex assisted with the review and patch.
|
Thanks, good catch. Fixed in 6060772: Under Wine, with DXC all 5 |
XCL smoke results for PR #3536Windows 11 build 26300, NVIDIA GeForce RTX 2070 SUPER (driver 621.40), Intel Core i7-9700K. Separate release binaries built with From each source tree, the command was mainPR headThe PR rendered 100.99% of baseline frames and used 96.45% of baseline peak committed memory. Both runs exited normally with zero crashes and zero device removals. Coverage is limited to the 180-second Windows/NVIDIA smoke runs. Linux/Wine on AMD, the original world-load hang, and the full GPU test suite were outside the scope of this run. AI assist — Codex (GPT-6, exact model variant unavailable) |
|
Thanks. Fixed in d4212d1:
On #3528: agreed. Once it lands, the split-chain part of this guards little, but the DXC compile is still what turns the guard on under Wine. Under Wine with DXC, indirect_guard (5/5) and the dispatch_chain tests (15/15) pass. |
|
merge-check |
The guard that zeroes out-of-range ExecuteIndirect counts on the GPU never ran under Wine: its program went through D3DCompile, and Wine's d3dcompiler (vkd3d-shader) has no Load3 on a RWByteAddressBuffer, so every run logged "the counts are not checked (its program does not compile)". Three RADV hang reports of the world-load ring timeout all end in a DISPATCH_INDIRECT of a small translated program whose arguments are read straight from the title's buffer, with a different program each time: the counts, not a shader. The guard now compiles with DXC (cs_6_0), once per process and before GUARD is taken, so a first ExecuteIndirect waiting on DXC's pool does not hold the lock counts() and the watchdog take. If the device refuses the DXIL (dxcompiler.dll without dxil.dll, so unsigned), it falls back to D3DCompile's cs_5_0 as before. A split compute program's ExecuteIndirect ran its chain from the title's raw counts, before the guard; its slicer clamps each count to 65535 but dispatches a partial split's whole count at once, up to 65535^3 groups. The guard now runs first and the chain reads the checked counts (bind::execute_indirect_chain). The guard's out buffer goes UNORDERED_ACCESS -> NON_PIXEL_SHADER_RESOURCE and back only around the slicer, the one pass that reads it, and only when a chain records one. Tests: a split indirect dispatch with garbage counts in the title's buffer now runs no piece (it ran 65535 groups from the raw counts); dispatch_chain checks the slicer bracket. The guard's own GPU test compiled its counter shader with D3DCompile too and read the out-of-range counter of the previous test's device; the guard's DXC tests now report SKIPPED (no DXC) when DXC is missing.
d4212d1 to
9181dd3
Compare
The slicer moved its commands to INDIRECT_ARGUMENT | VERTEX_AND_CONSTANT_BUFFER. vkd3d-proton only counts a transition to exactly INDIRECT_ARGUMENT as a write to indirect arguments; without one it hoists an ExecuteIndirect's preprocessing to the start of its command buffer, or of the whole submit. So the pieces' ExecuteIndirects read the commands before the slicer wrote them: zeros, or the groups and slab origins of an earlier split dispatch recorded with the same storage, run with this program's pieces. On RADV that is a TCP page fault and a gfx ring timeout where the world finishes loading, the removal seen at about 170 s on main and on the guard branch alike. The commands now go to INDIRECT_ARGUMENT alone (the root-constant chain ABI needs no constant buffer state). The split-chain test now also counts the groups the pieces run: 0 before this, 6, 0 and 2 now.
|
merge-check |
|
Source review on head Please preserve valid split-chain counts through the slicer and its whole-form fallback while rejecting corrupt out-of-range axes before they are clamped. If a legal large grid still needs a runtime bound, it needs an offset-correct way to execute the full workload; zeroing it changes the result. A focused regression could read back the slicer's commands for a just-over-threshold valid grid and an invalid-axis grid, without executing millions of groups. Make the whole form ready, or choose a scratch budget that lets the complete valid grid fit, so the assertion checks the output the chain would actually run. I traced this on the current source; I have not run that regression or observed this case in a title. AI use: Codex (GPT-6.2 Sol) and Codex (GPT-6.2 Astra) reviewed the guard and slicer paths. |
|
New commit 373e22e on top, and the description is updated for this head (suite counts and @Foniass: the description check should be green now. One new finding from the game runs since your merge-check: @thehollowedone, on the |
|
merge-check AI-written and posted by Foniass without a human check of each point. |
|
merge-check claim |
|
#3018 (draft) fixes the guard's compile failure under Wine another way: AI review: Claude Code (Claude Opus 5.5), diffs read only, not built or run; not checked by a human. |
|
Thanks for the merge-check (7306798546). The head is unchanged (373e22e); the description now answers the points:
|
|
merge-check |
|
Review of head 373e22e (not a full merge-check: no test suite or title run on this machine)
Verdict: ready to merge from my side. Hardware: Linux x86_64 cloud machine, no GPU. The crate was type-checked only, not built for or run on Windows. |
The ExecuteIndirect guard, which zeroes out-of-range counts on the GPU, never ran under Wine: its program was compiled with
D3DCompile, and Wine's d3dcompiler (vkd3d-shader) rejects it (noLoad3on aRWByteAddressBuffer, E5005). Every run loggedExecuteIndirect: the counts are not checked (its program does not compile), and garbage counts went straight to the GPU; on Linux/RADV a retail title then hung at the end of the world load. This PR compiles the guard with DXC, puts split compute programs behind it, and fixes the split chain's pieces reading their commands before the slicer wrote them.Related: #3018 (draft) finds the same cause and makes
real::compilefall back to DXC for all of XCL's own programs whenD3DCompilerefuses one. That overlaps with this PR's first point only; the split-chain guard and theINDIRECT_ARGUMENTtransition fix (373e22e) are in no other PR. Whichever lands first, the other drops its DXC part: on top of #3018 the guard keeps only its compile beforeGUARDis taken (so a first ExecuteIndirect waiting on DXC holds no lock the watchdog needs).Why one PR: the three parts fix one crash path. Wiring the guard into the split chain changes nothing under Wine unless the guard compiles (the DXC part), and with the guard wired in, the chain's pieces read their commands before the slicer wrote them unless the slicer's transition is exactly
INDIRECT_ARGUMENT(373e22e): this head without that commit lost the device in 3 of 3 runs. 373e22e also fixes a hoistingmainhas (it lost the device at ~170 s in 1 of 3 runs), but the test that shows it (the groups the pieces actually ran) goes through the guarded chain.What is in it
indirect_guard.rs: the guard compiles with DXC (cs_6_0) once per process, beforeGUARDis taken, so a first ExecuteIndirect waiting on DXC holds no lock the watchdog needs. IfCreateComputePipelineStaterefuses the DXIL (e.g. unsigned), it falls back toD3DCompile'scs_5_0. Its GPU tests' counter shader and device-lifetime problems are fixed.bind.rs/dispatch_chain.rs: a split compute program's single-dispatch ExecuteIndirect ran its chain from the title's raw counts, before the guard. The guard now runs first and the slicer reads the checked counts (gpu_address()of the guard's output). The output buffer goes UAV →NON_PIXEL_SHADER_RESOURCE→ UAV only around the slicer, through a hookdispatch_chain::execute_indirectcalls just there, so theWholepath (no chain, bundle, no scratch) has no barriers. With a check, the chain reads the guard's output, so it also runs whereindirect_addressfinds no console address for the record (past the end of its console buffer), wheremainwentWhole: the counts are the ones the guard read and checked, the same theWholeform's ExecuteIndirect gets.pso.rs(373e22e):record_indirect_slicermoved the commands it writes toINDIRECT_ARGUMENT | VERTEX_AND_CONSTANT_BUFFER. vkd3d-proton (3.1,ResourceBarrier/ExecuteIndirect) treats only a transition to exactlyINDIRECT_ARGUMENTas an indirect-argument write; otherwise it hoists an ExecuteIndirect's preprocessing to the start of the command buffer or submit. So the pieces read their commands before the slicer wrote them: zeros or an earlier dispatch's groups and slab origins, which showed up as TCP page faults ~170 s into a retail title. NowINDIRECT_ARGUMENTalone (the constant-buffer state was for a CBV chain ABI that is no longer used), andrestore_indirect_commandsmatches.a_split_indirect_dispatch_slices_the_counts_the_guard_let_throughputs garbage counts[1, 1, 0x10000]in a title buffer, runs the real guard and the split-chain path, and checks both the commands the slicer wrote and the groups the pieces actually ran (6, 0 and 2 for[3,2,1], the garbage and[2,1,1]). Without the guard wiring it slices 65535 groups from the garbage; without the transition fix the pieces run 0 groups. The chain test checks the barrier hook is called only around the slicer.Tested
cargo test --workspace: 3115 passed, 27 failed, 51 ignored (SKIPPED GPU tests:two_pass_binds_set_the_shared_view_heap(no heap windows), twolist_xsplit tests (Close does not refuse an open pipeline-statistics query),a_stale_blob_the_driver_takes_is_made_with_one_create_and_replacedandpso_measurement_compiles_an_exact_synthetic_record(driver cache),rla_pixel_shader_compiles_without_local_arrays(no dxc.exe))uma_drivergroup (8 tests, each reserves the whole address space, which Wine backs with a byte per page) was left out, andhle::d3d12x::tests::serialize_root_signature_strips_console_flags_and_preserves_pc_flagsremoves the device and ends its process, onmaintoo.main86e86fc the same way: 3126 passed, 24 failed, 51 ignored. This PR fixes the 2indirect_guardfailures ofmain(an_execute_indirect_with_garbage_counts_draws_nothing/_runs_no_groups: the guard never compiled under Wine). The others are the same tests, exceptgpu::dxil::msaa_tests::gpu_direct_image_get_resinfo_d16, which fails on this PR's base d52ff48 and was fixed onmainby 466b75c, and the 4title_texturestests that fail with a poisoned lock afterplaced_title_textures_share_vram_and_preserve_pixelspanics (flaky onmaintoo, see D3D12.X: hand the title reserved textures with live page tables #3553).dxc::compilequeues it as wanted by a waiting thread (pso_async::wanted_here), ahead of the build-ahead work, so at worst it waits for one compile already running on a worker; that run: 2471 frames, no device removal.indirect_guard5/5 (no SKIPPED, with DXC) anddispatch_chain27/27 under Wine with the GPU, also each alone with 1 thread.main86e86fc in 1 of 3; with 373e22e, 2 of 3 runs were clean and one hit the separate reserved-texture fault (D3D12.X: hand the title reserved textures with live page tables #3553); 373e22e together with D3D12.X: hand the title reserved textures with live page tables #3553: 3 of 3 clean (2155, 2132, 2429 frames). The head 373e22e alone again for the block below: no page fault in the kernel log, 2243 frames (87 % ofmain's 2569; othermainruns 1995-2286), and no count out of range in any of these runs.Regression run
main:
PR:
Not tested
D3DCompilealready compiled the guard, so the DXC-first part changes which form runs there (DXIL instead of DXBC); the split-chain wiring and the transition fix apply everywhere.mainthere (itsD3DCompileworks), and thepso.rstransition matters only under vkd3d-proton, where the chain test shows it (0 groups run without it).uma_driverunit tests (see above).AI use
🤖 Generated with Claude Code