Skip to content

D3D12.X: compile the indirect guard with DXC, and guard split chains - #3536

Merged
capy-ai[bot] merged 2 commits into
xcl-dev:mainfrom
lucsoft:pr/indirect-guard-dxc
Dec 1, 2026
Merged

capy-ai[bot] merged 2 commits into
xcl-dev:mainfrom
lucsoft:pr/indirect-guard-dxc

Conversation

@lucsoft

@lucsoft lucsoft commented Nov 30, 2026 •

Copy link
Copy Markdown
Contributor

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 (no Load3 on a RWByteAddressBuffer, E5005). Every run logged ExecuteIndirect: 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::compile fall back to DXC for all of XCL's own programs when D3DCompile refuses one. That overlaps with this PR's first point only; the split-chain guard and the INDIRECT_ARGUMENT transition 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 before GUARD is 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 hoisting main has (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, before GUARD is taken, so a first ExecuteIndirect waiting on DXC holds no lock the watchdog needs. If CreateComputePipelineState refuses the DXIL (e.g. unsigned), it falls back to D3DCompile's cs_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 hook dispatch_chain::execute_indirect calls just there, so the Whole path (no chain, bundle, no scratch) has no barriers. With a check, the chain reads the guard's output, so it also runs where indirect_address finds no console address for the record (past the end of its console buffer), where main went Whole: the counts are the ones the guard read and checked, the same the Whole form's ExecuteIndirect gets.
  • pso.rs (373e22e): record_indirect_slicer moved the commands it writes to INDIRECT_ARGUMENT | VERTEX_AND_CONSTANT_BUFFER. vkd3d-proton (3.1, ResourceBarrier / ExecuteIndirect) treats only a transition to exactly INDIRECT_ARGUMENT as 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. Now INDIRECT_ARGUMENT alone (the constant-buffer state was for a CBV chain ABI that is no longer used), and restore_indirect_commands matches.
  • Tests: a_split_indirect_dispatch_slices_the_counts_the_guard_let_through puts 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

  • hardware (GPU + driver, CPU), Rust version, debug / release: AMD Radeon RX 7800 XT, Mesa 26.3.1 RADV, Linux 7.3, Wine 11.21 (staging), vkd3d-proton 3.1; AMD Ryzen 7 7800X3D; rustc 1.95.0; release, cross-built for x86_64-pc-windows-gnu, the test binaries run under Wine with vkd3d-proton.
  • cargo test --workspace: 3115 passed, 27 failed, 51 ignored (SKIPPED GPU tests: two_pass_binds_set_the_shared_view_heap (no heap windows), two list_x split tests (Close does not refuse an open pipeline-statistics query), a_stale_blob_the_driver_takes_is_made_with_one_create_and_replaced and pso_measurement_compiles_an_exact_synthetic_record (driver cache), rla_pixel_shader_compiles_without_local_arrays (no dxc.exe))
    • Run under Wine on this machine with each test binary on its own and the lib tests one module per process, 2 threads (a module that failed was rerun with 1, and that result counted), the same way as in D3D12.X: hand the title reserved textures with live page tables #3553: the uma_driver group (8 tests, each reserves the whole address space, which Wine backs with a byte per page) was left out, and hle::d3d12x::tests::serialize_root_signature_strips_console_flags_and_preserves_pc_flags removes the device and ends its process, on main too.
    • main 86e86fc the same way: 3126 passed, 24 failed, 51 ignored. This PR fixes the 2 indirect_guard failures of main (an_execute_indirect_with_garbage_counts_draws_nothing / _runs_no_groups: the guard never compiled under Wine). The others are the same tests, except gpu::dxil::msaa_tests::gpu_direct_image_get_resinfo_d16, which fails on this PR's base d52ff48 and was fixed on main by 466b75c, and the 4 title_textures tests that fail with a poisoned lock after placed_title_textures_share_vram_and_preserve_pixels panics (flaky on main too, see D3D12.X: hand the title reserved textures with live page tables #3553).
  • The first ExecuteIndirect's DXC compile of the guard, measured in a retail run (a local build of this head with one log line): 6 ms on the title's thread at 146 s, while the build-ahead queue held about 75,000 programs. dxc::compile queues 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_guard 5/5 (no SKIPPED, with DXC) and dispatch_chain 27/27 under Wine with the GPU, also each alone with 1 thread.
  • 180 s runs of a retail title (kernel log for page faults): this PR's head without 373e22e lost the device at ~170 s in 3 of 3 runs, and so did main 86e86fc 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 % of main's 2569; other main runs 1995-2286), and no count out of range in any of these runs.

Regression run

main:

xcl-smoke v1
commit: 86e86fcb33f94fa5d0c809d9b50af7b84bf49cce
gpu: AMD Radeon RX 7800 XT (RADV NAVI32)
title: retail-gta6
seconds: 180
exit: 0x0
frames shown: 2569 (PresentX 2569)
presents per 2 s (last 3): 1 0 0
device removals: 0
crashes: 0
peak commit: 0 MB

PR:

xcl-smoke v1
commit: 373e22e122523403027f05ccba7ad27506d3dec5
gpu: AMD Radeon RX 7800 XT (RADV NAVI32)
title: retail-gta6
seconds: 180
exit: 0x0
frames shown: 2243 (PresentX 2243)
presents per 2 s (last 3): 2 2 1
device removals: 0
crashes: 0
peak commit: 0 MB

Not tested

  • Windows and NVIDIA. On Windows the native D3DCompile already 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.
  • On Windows only the split-chain test fails without this PR (it catches the chain wiring); the DXC test passes on main there (its D3DCompile works), and the pso.rs transition matters only under vkd3d-proton, where the chain test shows it (0 groups run without it).
  • A cold start with empty shader caches: the DXC wait above was measured with warm caches (the queue was still full of build-ahead work).
  • The uma_driver unit tests (see above).

AI use

  • Claude Code, Claude Opus 5.5: analysis, the code, tests and this description; reviewed by me.

🤖 Generated with Claude Code

@github-actions github-actions Bot added area:d3d12 D3D12.X runtime, command lists, resources, sparse memory gpu:both Code affects both AMD and NVIDIA GPUs (scope tag; see needs:*-test for remaining checks) labels Nov 30, 2026

@Zippp69 Zippp69 left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@lucsoft

lucsoft commented Nov 30, 2026

Copy link
Copy Markdown
Contributor Author

Thanks, good catch. Fixed in 6060772: the_guards_program_compiles_with_dxc and an_execute_indirect_with_garbage_counts_runs_no_groups now check dxc::location() and call skip_test("no DXC"). an_execute_indirect_with_garbage_counts_draws_nothing needed the same: under Wine the guard itself has no compiler for its program without DXC, so check returned none. It now skips when DXC is missing and still panics otherwise.

Under Wine, with DXC all 5 indirect_guard tests pass. With XCL_DXC_DIR pointing nowhere, the three report SKIPPED and the suite passes.

@Zippp69

Zippp69 commented Nov 30, 2026

Copy link
Copy Markdown

XCL smoke results for PR #3536

Windows 11 build 26300, NVIDIA GeForce RTX 2070 SUPER (driver 621.40), Intel Core i7-9700K. Separate release binaries built with cargo build --locked --release -p xcl from clean source trees. Both runs used the same retail title and separate XCL data directories and DXIL caches.

From each source tree, the command was ./scripts/smoke.ps1 -Game <local-title-folder> -Seconds 180 -StartupTimeoutSeconds 180 -OutDir <run-output-dir>. Local paths are omitted.

main

xcl-smoke v1
commit: 9dfbe3ea6653a9c76ef3ea0d66187a4b5407483b
gpu: NVIDIA GeForce RTX 2070 SUPER
title: 6724f81f
seconds: 180
exit: 0x0
frames shown: 5147 (PresentX 5147)
presents per 2 s (last 3): 60 60 57
device removals: 0
crashes: 0
peak commit: 16242 MB

PR head

xcl-smoke v1
commit: 6060772137151bb3ec5994f90ef8d02f2bb24f2b
gpu: NVIDIA GeForce RTX 2070 SUPER
title: 6724f81f
seconds: 180
exit: 0x0
frames shown: 5198 (PresentX 5198)
presents per 2 s (last 3): 59 60 60
device removals: 0
crashes: 0
peak commit: 15666 MB

The 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)

@andresd-cerebras andresd-cerebras left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Withdrawn.

@lucsoft

lucsoft commented Nov 30, 2026

Copy link
Copy Markdown
Contributor Author

Thanks. Fixed in d4212d1:

  1. dispatch_chain::execute_indirect now takes a hook that runs only around the slicer, so the UAV/SRV transitions happen only when a chain actually records one. No barriers on the Whole path. The chain test checks both cases.
  2. If CreateComputePipelineState refuses the DXIL, make now retries with the cs_5_0 bytecode.
  3. The DXIL is compiled once per process before GUARD is taken, so counts() and the watchdog no longer wait behind DXC's pool.
  4. Partly: the transitions are covered through that hook. The bind.rs path itself (checked address, read() on Ran/Err) still has no unit test, because it needs the full title-list binding. The GPU guard tests and the game run cover it for now.

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.

@Foniass

Foniass commented Dec 1, 2026

Copy link
Copy Markdown
Contributor

merge-check
base: d0832e6
head: d4212d1
merge: clean
build: cargo build --workspace -> ok
tests: cargo test --workspace --no-fail-fast -- --test-threads=4 -> 2891 passed, 0 failed, 51 ignored; SKIPPED: 28 (22 no wave64, 2 no heap windows, 2 no d3d12SDKLayers.dll, 1 no D3D12 debug layer, 1 cannot disable the driver cache); failing: none. The guard's tests (incl. the_guards_program_compiles_with_dxc and both garbage-count GPU tests) and an_indirect_dispatch_runs_its_chain_without_any_whole_form ran and passed, not skipped.
review: whole diff read. The guard compiles with DXC (cs_6_0) and falls back to D3DCompile; it now runs before the split chain, which reads the checked counts through gpu_address(); the out buffer goes UAV -> NON_PIXEL_SHADER_RESOURCE -> UAV around the slicer only, and every Ran/Err path ends with read() (-> COMMON). No correctness problem found. (1) PR description check fails: the PR's xcl-smoke block is for 6060772, not head d4212d1, whose commit changes those runtime transitions. (2) 6060772 and d4212d1 are review fixups of 8300b4e and should be squashed. (3) The split-chain part has no test that fails without it: the new dispatch_chain assertion checks only the around_slicer bracket, not that the chain reads the checked counts. (4) Minor: the first ExecuteIndirect now waits on the title's thread for the shared DXC pool (a "wanted" job, so it overtakes background compiles); before, D3DCompile ran inline. (5) On Windows the guard is now DXIL instead of DXBC; tested here on NVIDIA only. The author's retail runs are on an older base and report peak commit 0 MB under Wine. No retail title on this machine: no smoke run here.
performance: reasoned: one 1-group guard dispatch and two transitions are added to each split-chain indirect dispatch, plus a one-time DXC compile on the first ExecuteIndirect; not measured (no retail title)
verdict: not yet: no xcl-smoke block for head d4212d1 (PR description check red); fixup commits to squash; no test that fails without the split-chain change
hardware / tool and model: NVIDIA GeForce RTX 5070 Ti (driver 32.0.16.2114 / 621.14), AMD Ryzen 7 7800X3D, Windows 11 Pro 10.0.26300, rustc 1.100.0 MSVC / Claude Code, Claude Opus 5.5

@github-actions github-actions Bot added the needs-pr-check Failing the PR description check (CONTRIBUTING.md) label Dec 1, 2026
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.
@lucsoft
lucsoft force-pushed the pr/indirect-guard-dxc branch from d4212d1 to 9181dd3 Compare December 1, 2026 00:47
@github-actions github-actions Bot removed the needs-pr-check Failing the PR description check (CONTRIBUTING.md) label Dec 1, 2026
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.
@Foniass

Foniass commented Dec 1, 2026

Copy link
Copy Markdown
Contributor

merge-check
base: d0832e6
head: 9181dd3
merge: clean
build: cargo build --workspace -> ok
tests: cargo test --workspace --no-fail-fast -- --test-threads=4 -> 2892 passed, 0 failed, 51 ignored; SKIPPED: 28 (22 no wave64, 2 no heap windows, 2 no d3d12SDKLayers.dll, 1 no D3D12 debug layer, 1 cannot disable the driver cache); failing: none. a_split_indirect_dispatch_slices_the_counts_the_guard_let_through, the_guards_program_compiles_with_dxc and both garbage-count GPU tests ran and passed, not skipped.
review: whole diff read; the change since d4212d1 moves the chain path into bind::execute_indirect_chain with the same behaviour (read() on Ran/Err, transitions only around the slicer) and adds a test that fails without the fix (garbage 1x1x0x10000 in the title's buffer: 0 groups sliced, where the raw counts would give 65535). The earlier fixup and missing-test points are resolved. Remaining: the PR description is stale (test counts and xcl-smoke block are for 6060772, not 9181dd3), so the PR description check is red. Minor, unchanged: the first ExecuteIndirect waits on the title's thread for the shared DXC pool once.
performance: smoke 240 s on the merged tree 424d472e vs main d0832e6 (same title, same input script; main run before and after): every run, main included, loses the device to a GPU page fault (DRED state 7) during the world load: main at 100.4 s / 100.4 s with 2195 / 2219 presents, this PR at 105.1 s with 2149; peak commit 35438 MB vs 34766 / 32760 MB. No out-of-range counts logged on NVIDIA. Not a regression; the world itself could not be tested here.
verdict: not yet: the PR description check is red (no xcl-smoke block and suite counts for head 9181dd3); the code has no open finding
hardware / tool and model: NVIDIA GeForce RTX 5070 Ti (driver 32.0.16.2114 / 621.14), AMD Ryzen 7 7800X3D, Windows 11 Pro 10.0.26300, rustc 1.100.0 MSVC / Claude Code, Claude Opus 5.5

@github-actions github-actions Bot added the needs-pr-check Failing the PR description check (CONTRIBUTING.md) label Dec 1, 2026
@thehollowedone

Copy link
Copy Markdown
Contributor

Source review on head 9181dd37: the new split-chain path calls the indirect guard before the slicer. The guard zeros a dispatch when the group-count product exceeds its default 2^22 limit, even if every dimension is within D3D12's 65,535-per-axis limit. For example, 2049 × 2048 × 1 = 4,196,352 is only 2,048 groups over that threshold. Before this PR, the split chain's slicer received the original counts and could emit complete split commands or a whole-form command when ready. The existing fold_counts_within test also preserves 4096 × 4096 × 1 because its axes are valid. This new path can silently drop legitimate work.

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.

@lucsoft

lucsoft commented Dec 1, 2026

Copy link
Copy Markdown
Contributor Author

New commit 373e22e on top, and the description is updated for this head (suite counts and xcl-smoke blocks):

@Foniass: the description check should be green now. One new finding from the game runs since your merge-check: record_indirect_slicer moved the commands it writes to INDIRECT_ARGUMENT | VERTEX_AND_CONSTANT_BUFFER, and vkd3d-proton 3.1 counts only a transition to exactly INDIRECT_ARGUMENT as an indirect-argument write. Otherwise it hoists the ExecuteIndirect's preprocessing to the start of the command buffer, so the split chain's pieces read their commands before the slicer wrote them. Under Wine on AMD that was the TCP page fault ~170 s into a retail title (the head without it lost the device in 3 of 3 runs). 373e22e transitions to INDIRECT_ARGUMENT alone, and the chain test now also checks the groups the pieces actually ran. It is a separate commit because it is a separate bug that is also on main. The first-call DXC wait is unchanged: one compile per process, before GUARD is taken.

@thehollowedone, on the 2^22 bound for split chains (7299645415): that is deliberate, and the same bound every other indirect dispatch already gets on main, including a split program's own whole form (Indirect::Whole) and the guard's whole output. Valid axes are no protection: counts the title did not mean (a float's bits, a stale buffer) are often within 65535 per axis, and on Linux a dispatch of a few hundred million groups is a hang with no TDR to end it. That is the case the guard is for, and before this PR the chain path was the one way around it. A zeroed dispatch is not silent either: the log names the first ones out of range with their counts, and XCL_INDIRECT_MAX_GROUPS raises the bound (4 Mi is 32 times a 4K target in 8x8 groups). In the retail runs on this head no dispatch reached it (no out-of-range line in 6 runs of 180 s). If a title turns out to need bigger grids, raising the default is a one-line change for both paths, so I would rather not give the chain path its own rule.

@github-actions github-actions Bot added area:recompiler RDNA2 decoder, HLSL/direct-DXIL recompiler, wave64/wave32 and removed needs-pr-check Failing the PR description check (CONTRIBUTING.md) labels Dec 1, 2026
@Foniass

Foniass commented Dec 1, 2026 •

Copy link
Copy Markdown
Contributor

merge-check
base: 7d86c5d
head: 373e22e
merge: clean
build: cargo build --workspace -> ok
tests: cargo test --workspace --no-fail-fast -- --test-threads=4 -> 2898 passed, 0 failed, 51 ignored; SKIPPED: 28 (20 no wave64, 2 no d3d12SDKLayers.dll, 1 no D3D12 debug layer, 1 no heap windows, 1 cannot disable the driver cache, 3 others; the same set as on main); failing: none
review: read the whole diff (+233/-28). Findings: (1) Scope. Three changes in one PR: the guard compiled with DXC, the guard wired into split dispatch chains (dispatch_chain.rs), and the vkd3d-proton state workaround in pso.rs. They could be split, or the description could say why not. (2) Possible stall on the first ExecuteIndirect (default path, reasoned). guard_of now calls dxil() on the title's thread (indirect_guard.rs ~203). That queues the guard on the DXC pool and blocks on rx.recv() (dxc.rs ~898) until a worker is free, and on a cold start the workers can be in the middle of large console programs. Main ran D3DCompile inline. Compiling the guard at device creation, or off the title's thread, avoids the wait. (3) On Windows, the tests don't fail without the change. the_guards_program_compiles_with_dxc passes on main, and the pso.rs state change only matters under vkd3d-proton. The garbage-count test in dispatch_chain.rs does catch the chain wiring. The counter test now needs DXC and skips without it, where it used to run through D3DCompile. (4) Undescribed change. When a check exists, the chain now runs where indirect_address returns None (a record past the console buffer, bind.rs ~3970); main went Whole there. (5) Likely conflicts: #3528 (same execute_indirect signature), #3401 (guard skip order in bind.rs), and #3009, which keeps the guard buffer in INDIRECT_ARGUMENT and so conflicts with this PR's UAV -> NON_PIXEL_SHADER_RESOURCE transitions. This PR supersedes the guard part of #3018. Fine: a DXC failure or a refused DXIL pipeline falls back to D3DCompile (make ~245), and with both failing the guard turns off with a log line. The guard output's transitions are balanced on Ran, Err and Whole. Dropping VERTEX_AND_CONSTANT_BUFFER is safe, because the runtime chain feeds constants through its command signature. The Whole path adds no barriers. Update (same head, after the author's reply and the updated description): (1) the description now says why it's one PR (one crash path: without 373e22e the wired chain lost the device in 3 of 3 runs), which answers the scope point. (2) The first ExecuteIndirect's compile is queued as wanted, because a title thread counts as wanted in pso_async::wanted_here (~347-352), so it overtakes the build-ahead work (dxc.rs ~694-696). It waits at most for one compile already running on a worker; the author measured 6 ms in a warm retail run, and a cold start is listed under Not tested. (3) and (4) are now in the description. (5) The author will rebase whichever of #3528 / #3401 / #3009 lands first. throny's merge-check on 493dbd3 (2902 passed, clean) agrees.
performance: 60 s smoke of a retail title, main 7d86c5d vs this merge (b1ed6d34): 1663 -> 1686 frames shown (101 %; last presents per 2 s: 60 60 60), peak commit 17153 -> 17431 MB, 0 device removals, 0 crashes. This run's log has no line showing an ExecuteIndirect or guard compile, so it doesn't show whether the first-ExecuteIndirect wait happens here.
verdict: safe to merge (updated: the earlier blockers are answered in the description; the remaining risk is a cold-start wait for one running DXC compile on the first ExecuteIndirect, untested)
hardware / tool and model: RTX 5070 Ti (driver 621.14), Ryzen 7 7800X3D, Windows 11 26300 / Claude Code with Claude Opus 5.5

AI-written and posted by Foniass without a human check of each point.

@throny

throny commented Dec 1, 2026

Copy link
Copy Markdown
Collaborator

merge-check claim
head: 373e22e

@Foniass

Foniass commented Dec 1, 2026

Copy link
Copy Markdown
Contributor

Triage (#1607) – head 373e22e

#3018 (draft) fixes the guard's compile failure under Wine another way: real::compile falls back to DXC for all of XCL's own programs. This PR compiles the guard with DXC and falls back to D3DCompile. Its other two parts are in no other PR: split chains read the guard's checked counts, and the slicer's commands go to INDIRECT_ARGUMENT alone. #3528 also edits dispatch_chain::execute_indirect, for a different change.
No problems found in the diff: in bind.rs::execute_indirect_chain, Checked::read runs on the Ran and Err paths only, and the Whole path keeps checked for the normal ExecuteIndirect.
Recommendation: keep open.

AI review: Claude Code (Claude Opus 5.5), diffs read only, not built or run; not checked by a human.

@lucsoft

lucsoft commented Dec 1, 2026

Copy link
Copy Markdown
Contributor Author

Thanks for the merge-check (7306798546). The head is unchanged (373e22e); the description now answers the points:

  1. Scope. It stays one PR, and the description now says why: the three parts fix one crash path. The chain wiring does nothing under Wine unless the guard compiles, and with it wired in, the pieces read their commands before the slicer wrote them unless the transition is exactly INDIRECT_ARGUMENT (this head without 373e22e lost the device in 3 of 3 runs). Your triage on PR triage: duplicate PRs and batch-tested PRs, each checked by two contributors #1607 came to the same split of who does what (D3D12.X: DXC compiles XCL's own HLSL when D3DCompile refuses it #3018 overlaps only the compile).
  2. The first ExecuteIndirect's DXC wait. Measured in a retail run with a local build of this head plus one log line: 6 ms on the title's thread at 146 s, while the build-ahead queue held about 75,000 programs. dxc::compile sends it as wanted by a waiting thread (pso_async::wanted_here), so it goes ahead of the build-ahead work; at worst it waits for one compile already running on a worker. The run had warm shader caches; a cold start with empty caches is listed under Not tested. I'd rather keep it on first use than add a compile to every device creation for titles that never call ExecuteIndirect, but I can move it if you see a case that waits longer.
  3. Tests on Windows. Right: there only the split-chain test fails without this PR (it catches the wiring). The DXC test passes on main there, and the pso.rs transition matters only under vkd3d-proton, where the chain test shows it (0 groups run without it). Now in the description.
  4. indirect_address returning None. Now described: with a check, the chain reads the guard's output, which holds the counts the guard read and checked, the same the Whole form's ExecuteIndirect gets. So it runs where main went Whole, with the same counts.
  5. Conflicts with D3D12.X: use whole form once ready for split ExecuteIndirect #3528, D3D12.X: clean up indirect_guard state on ExecuteIndirect skip paths #3401 and D3D12.X: the count check's buffer stays INDIRECT_ARGUMENT between checks #3009: whichever lands first, I'll rebase this one.

@throny

throny commented Dec 1, 2026

Copy link
Copy Markdown
Collaborator

merge-check
base: 493dbd3
head: 373e22e (unchanged since the claim)
merge: clean
build: cargo build --workspace -> ok
tests: cargo test --workspace --no-fail-fast -- --test-threads=4 -> 2902 passed, 0 failed, 51 ignored; failing: none (25 SKIPPED lines in the log, none of them from this PR's tests: both new tests, the_guards_program_compiles_with_dxc and a_split_indirect_dispatch_slices_the_counts_the_guard_let_through, ran and passed); no test binary ended abnormally; no base comparison needed
review: Read the whole diff (pso.rs, bind.rs, indirect_guard.rs, dispatch_chain.rs; 4 files). Three changes: (1) the slicer's commands buffer is transitioned to INDIRECT_ARGUMENT alone (not | VERTEX_AND_CONSTANT_BUFFER) before and after, so vkd3d-proton does not hoist the ExecuteIndirect preprocessing above the slicer pass; (2) the guard's program is compiled once with DXC (cs_6_0) and falls back to D3DCompile cs_5_0 when DXC or the device refuses it, with a combined error message; (3) a split chain's dispatch reads the counts as the guard let them through (execute_indirect_chain, around_slicer brackets the slicer pass with UAV/SRV transitions only when a chain records it), and checked.read runs after. The new GPU test checks the groups sliced and the groups the pieces actually ran for three count cases including an out-of-range one, so it does test change (3) on this Windows D3D12 driver; (1) and the Wine/vkd3d/RADV motivation for (1) and (2) are not reproducible here, so those fixes are untested on Wine, AMD and vkd3d-proton (the tests call skip_test without DXC/GPU and would pass without running their bodies there). Minor: the diff touches the existing test that skips when GUARD is absent, and tests became pub(super) for a shared lock, which is only test-visible.
performance: can cost a little on the default path: the guard now compiles its program with DXC once per process (one small cs_6_0 compile, before GUARD is taken) where it used D3DCompile, and a split indirect dispatch records two extra transitions around the slicer; both only where the guard or a split chain already runs. Reasoned, not measured in-world.
verdict: safe to merge
hardware / tool and model: RTX 4080 16 GB (621.40), i9-12900K, Windows 11 26300; Claude Code, Claude Sonnet 5.5 ran the build and the suite and read the diff; Claude Opus 5.5 checked this report

@github-actions github-actions Bot added checks-disagree Merge-checks disagree (safe vs not yet); needs maintainer/3rd look needs:amd-test Needs a test report or merge-check on an AMD GPU ready-to-merge Has 2 independent safe merge-checks on current head (#3041) and removed checks-disagree Merge-checks disagree (safe vs not yet); needs maintainer/3rd look needs:amd-test Needs a test report or merge-check on an AMD GPU labels Dec 1, 2026
@capy-ai

capy-ai Bot commented Dec 1, 2026

Copy link
Copy Markdown
Contributor

Review of head 373e22e (not a full merge-check: no test suite or title run on this machine)

  • Merged onto main b2b1f10: clean, git diff --check clean. Also clean together with D3D12.X: hand the title reserved textures with live page tables #3553; the two PRs touch no common file.
  • cargo check --workspace --all-targets --target x86_64-pc-windows-gnu on the merge: ok, with the same warning count as main (39 lib, 19 lib test).
  • I read the whole diff (pso.rs, bind.rs, indirect_guard.rs, dispatch_chain.rs) and found nothing blocking:
    • The guard's output buffer is balanced on every path of execute_indirect_chain. It goes UAV → NON_PIXEL_SHADER_RESOURCE → UAV only around the slicer, also when record_indirect_slicer fails. read() returns it to COMMON on Ran and Err, and Whole keeps checked for the normal ExecuteIndirect.
    • Dropping VERTEX_AND_CONSTANT_BUFFER is safe. chain_command_signature has only a root-constant argument and a Dispatch argument, so nothing reads the commands buffer as a CBV.
    • dxil() compiles once per process, before GUARD is taken. A DXC failure, or a DXIL pipeline the device refuses, falls back to D3DCompile cs_5_0.
  • Not covered by anyone yet: Windows on AMD (the guard now runs as DXIL instead of DXBC there), and the first ExecuteIndirect's DXC wait on a cold start. The runtime evidence for this head is the two Windows/NVIDIA merge-checks above (0 failed) and the author's Wine/RADV runs.

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.
AI use: Capy (Claude Opus 5.5) did the merge, the type-check and the diff review, and wrote this comment.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:d3d12 D3D12.X runtime, command lists, resources, sparse memory area:recompiler RDNA2 decoder, HLSL/direct-DXIL recompiler, wave64/wave32 gpu:both Code affects both AMD and NVIDIA GPUs (scope tag; see needs:*-test for remaining checks) ready-to-merge Has 2 independent safe merge-checks on current head (#3041)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants