Skip to content

D3D12.X: a split program's failed whole build is not tried again - #2629

Open
Royalflamejlh wants to merge 2 commits into
xcl-dev:mainfrom
Royalflamejlh:arch/split-whole-failure
Open

Royalflamejlh wants to merge 2 commits into
xcl-dev:mainfrom
Royalflamejlh:arch/split-whole-failure

Conversation

@Royalflamejlh

@Royalflamejlh Royalflamejlh commented Nov 26, 2026 •

Copy link
Copy Markdown
Contributor

A split compute program whose whole form fails to build is no longer built again at every call that needs it. Chain::whole kept the whole pipeline once built, and returned a failure without keeping it. So every later call that needs that form ran the whole compile again, on the title's thread and under the chain's lock. On main that is every ExecuteIndirect of a split program (bind.rs, dispatch_chain::whole) and every dispatch that gets no scratch: a list with no tracked allocator, a bundle, a scratch allocation that failed. The program is large by construction, since splitting is for large programs, so each try can take the driver seconds and fail again.

Part of #2088. A failure is now final for that program, as a failed build is in pso_async (complete, 0 = failed): its later calls skip their dispatch instead of trying again. The exception is E_OUTOFMEMORY, which can pass: such a build is tried once more, 10 s later, and a second failure stays final (a driver can also refuse a program with out of memory every time).

What is in it

  • crates/xcl/src/hle/d3d12x/real/dispatch_chain.rs: the outcome of the whole build, a failure too, is kept in the chain's OnceLock; a first out-of-memory failure is not kept, and retry_at holds the time of its one more try. PipelineBuilder::pipeline returns the HRESULT. retry_at's lock lets one caller build while the others wait, in place of build_whole.
  • crates/xcl/src/hle/d3d12x/bind.rs: the ExecuteIndirect warning for a failed whole form is capped at 4, as the Dispatch one is: a kept failure now comes at the call rate, not once a compile.
  • Two tests: a_whole_form_that_fails_to_build_is_not_built_again (the chain's pipeline creation always fails and counts its calls; two calls of whole make it build once) and a_whole_form_that_ran_out_of_memory_is_tried_once_more_after_a_pause (it always runs out of memory: one build, none within the pause, one more after it, then none).

Other branches

Tested

  • Native Windows: NVIDIA GeForce RTX 2070 SUPER 8 GB (driver 621.01), Ryzen 7 5700X3D, Windows 11 Pro 26200, rustc 1.100.0; tests in debug, the smoke runs from release builds. Head 8bfaa12 on main b49be18.
  • The new test on main with only the test added: failed, the pipeline was built twice (left: 2, right: 1). On this branch: cargo test --workspace --no-fail-fast -- --test-threads=4: 1,437 passed, 0 failed, 47 ignored, both new tests among them. 29 SKIPPED lines: 21 no wave64, 3 wave32 per-lane forms refused, 3 no D3D12 debug layer, 1 no heap windows, 1 pso_measurement_compiles_an_exact_synthetic_record (the driver cache cannot be turned off without Windows Developer Mode).

Regression run

main:

xcl-smoke v1
commit: b49be1836844fe0b0cdb3211dce3cb7fb4e21ac7
gpu: NVIDIA GeForce RTX 2070 SUPER
title: 5330474d
seconds: 60
exit: 0x0
frames shown: 691 (PresentX 691)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 14716 MB

PR:

xcl-smoke v1
commit: 8bfaa12f1fdfcb7d4ca319ae5f365cedb7201a1c
gpu: NVIDIA GeForce RTX 2070 SUPER
title: 5330474d
seconds: 60
exit: 0x0
frames shown: 1490 (PresentX 1490)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 13884 MB

Not tested

  • A failed whole build on a live device. One title run of ours with XCL_DIRECT_DXIL=1 (300 s, RTX 5070 Ti, a tree without this change) met failed whole builds, but only in the second after the device was removed: every pipeline creation then failed with 0x887a0005 in about 1 ms, so building again cost little. The case this is for, a driver that refuses or runs out of memory on a large split program's whole form while the device is alive, no run has shown.
  • The two 60 s smoke runs had no XCL_DIRECT_DXIL=1, the only path that splits programs, so they do not reach the changed code; they are a regression check only.
  • AMD GPUs.

AI use

  • Claude Code (Claude Opus 5.5) found the case by reading the code, wrote the change, the test and this text, and ran the tests and the smoke runs on the Windows machines through a script.

`Chain::whole` kept the whole pipeline of a split compute program once
it was built, and returned a failure without keeping it. So every later
call that needs that form built it again: each `ExecuteIndirect` of the
pipeline and each dispatch that gets no scratch, on the title's thread
and under the chain's lock. The program is large by construction
(splitting is for large programs), so each try can take the driver
seconds or more and fail again.

The outcome is kept in the `OnceLock`, a failure too. Its `get_or_init`
lets one caller build and the others wait, so the separate lock goes.
A failure is now final for the program, as a failed build is in
`pso_async`. The `ExecuteIndirect` warning for it is capped as the
`Dispatch` one is: it now comes at the call rate, not once a compile.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@futurepro62

futurepro62 commented Nov 26, 2026 •

Copy link
Copy Markdown

Full-suite run, since this PR has no test report yet. Tested exact head bf200e16 (on its base b49be18).

Tested

  • NVIDIA GeForce RTX 5070 Ti 16 GB (Blackwell, 32-lane waves only, mesh shaders), driver 621.40, Ryzen 7 9800X3D, Windows 11 Home 26300, Rust 1.100.0 MSVC, DXC + dxil.dll 1.9.2602.17 (Windows SDK 10.0.26100), debug, D3D12 debug layer installed.
  • cargo build --workspace, then XCL_REQUIRE_GPU=mesh cargo test --workspace -- --test-threads=4 --skip heap_window_out_of_memory_falls_back_to_the_switch_form --skip gpu::recomp::lower_dxil::tests::f16_programs_on_the_gpu --skip gpu::recomp::lower_dxil::tests::f32_programs_on_the_gpu --skip gpu::recomp::lower_dxil::tests::integer_programs_on_the_gpu --skip gpu::recomp::lower_dxil::tests::f64_programs_on_the_gpu --skip gpu::recomp::lower_dxil::tests::const_and_null_mask_operands_agree_with_hlsl_on_the_gpu --skip gpu::recomp::lower_dxil::tests::mask_ff0_and_flbit_agree_with_hlsl_on_the_gpu --skip gpu::dxil::fuzz_tests: 1424 passed, 0 failed, 45 ignored. SKIPPED (no wave64): a_2d_or_3d_group_agrees_with_the_hlsl_path_on_the_gpu, a_per_lane_2d_or_3d_group_runs_on_the_gpu, coalesced_guarded_runs_agree_with_the_hlsl_path_on_the_gpu, cross_lane_reads_agree_with_the_hlsl_path_on_the_gpu, dispatch_chain_native_wave64_builds_whole, gpu_geometry_wave32_prefix_count_over_a_mask, gpu_wave32_program_in_wave64_hardware, the_wave64_lowering_agrees_with_the_hlsl_path_on_the_gpu.
  • The new tests ran and passed: a_whole_form_that_fails_to_build_is_not_built_again.
  • Same head on the AMD Radeon integrated GPU (iGPU) of the Ryzen 7 9800X3D (RDNA2, XCL_ADAPTER=radeon), cargo test --workspace -- --test-threads=4 --skip gpu::dxil::fuzz_tests::fuzz_validate_and_gpu_1: 1435 passed, 0 failed, 47 ignored. SKIPPED: f16_programs_on_the_gpu (f16 arithmetic, wave32, per-lane form: refused (unsupported V_MUL_F16 (its gpu: direct RDNA2 -> DXIL backend (no HLSL / DXC), behind XCL_DIRECT_DXIL #1426 semantics differ from the console's))), f16_programs_on_the_gpu (f16 arithmetic, wave64, per-lane form: refused (unsupported V_MUL_F16 (its gpu: direct RDNA2 -> DXIL backend (no HLSL / DXC), behind XCL_DIRECT_DXIL #1426 semantics differ from the console's))), f16_programs_on_the_gpu (f16 packed, wave32, per-lane form: refused (unsupported V_PK_MUL_F16: VOP3 modifiers (its gpu: direct RDNA2 -> DXIL backend (no HLSL / DXC), behind XCL_DIRECT_DXIL #1426 semantics differ from the console's))), f16_programs_on_the_gpu (f16 packed, wave64, per-lane form: refused (unsupported V_PK_MUL_F16: VOP3 modifiers (its gpu: direct RDNA2 -> DXIL backend (no HLSL / DXC), behind XCL_DIRECT_DXIL #1426 semantics differ from the console's))), f32_programs_on_the_gpu (f32 conversions, wave32, per-lane form: refused (unsupported V_CVT_F16_F32 (its gpu: direct RDNA2 -> DXIL backend (no HLSL / DXC), behind XCL_DIRECT_DXIL #1426 semantics differ from the console's))), f32_programs_on_the_gpu (f32 conversions, wave64, per-lane form: refused (unsupported V_CVT_F16_F32 (its gpu: direct RDNA2 -> DXIL backend (no HLSL / DXC), behind XCL_DIRECT_DXIL #1426 semantics differ from the console's))), heap_window_out_of_memory_falls_back_to_the_switch_form (no heap windows).
  • --skip leaves out tests that fail on main b49be183 too, not because of this PR. On NVIDIA: heap_window_out_of_memory_falls_back_to_the_switch_form (Tests: heap_window_out_of_memory_falls_back_to_the_switch_form fails under XCL_REQUIRE_GPU=mesh (opt-in skip counted as missing coverage) #1651), the four gpu::recomp::lower_dxil::tests::*_programs_on_the_gpu tests, const_and_null_mask_operands_agree_with_hlsl_on_the_gpu and mask_ff0_and_flbit_agree_with_hlsl_on_the_gpu (follow-up on #1651) fail because runner::skip_test turns their skips into failures under XCL_REQUIRE_GPU=mesh, and gpu::dxil::fuzz_tests seeds 70, 545, 1019 and 1507 fail CreateComputePipelineState with E_OUTOFMEMORY on this card (drivers 616.64 and 621.40). On AMD: fuzz_validate_and_gpu_1 fails on seed 540 (res[833] 0x7 vs CPU 0x6). The AMD run does not set XCL_REQUIRE_GPU.

Not tested

  • a release build, a game (test run only).

AI use

  • Claude Code (Claude Opus 5.5) ran the tests and wrote this report. I checked it before posting.

@luckyteagirl luckyteagirl left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Could this avoid caching recoverable pipeline-creation failures as a permanent None? The new OnceLock<Option<_>> stores the result of the first whole build forever, while PipelineBuilder::pipeline drops the HRESULT. D3D12 can return E_OUTOFMEMORY when memory is insufficient. If the first whole build hits temporary pressure and memory later becomes available, subsequent chain dispatches still cannot retry; main would retry. Keeping the HRESULT and retrying or backing off for recoverable failures would retain the intended one-time cache for permanent refusals. A builder that fails once with OOM and then succeeds would cover this path. Source review only at head bf200e16; I did not reproduce live-device OOM. AI-assisted with Codex (GPT-6.2 Sol).

… once more

A failed whole build is kept so it is not compiled again at every call
that needs it. Out of memory can pass, though, and then a program that
failed once under memory pressure never got its whole form for the rest
of the run (luckyteagirl's review). Such a failure now waits 10 s and
is tried once more; a second failure, and any other, stays final. Once,
because a driver can also refuse a program with out of memory every
time (`translated_compute_pso_once` records an AMD one, 15 to 23 s a
try), and then each try would be seconds on the title's thread again.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@Royalflamejlh
Royalflamejlh force-pushed the arch/split-whole-failure branch from 73798ca to 8bfaa12 Compare November 26, 2026 06:07
@Royalflamejlh

Copy link
Copy Markdown
Contributor Author

@luckyteagirl yes: an E_OUTOFMEMORY can pass, and with bf200e16 such a program's ExecuteIndirects and its dispatches without scratch skipped their work for the rest of the run, where main builds again. 8bfaa12 keeps every other failure final and tries an out-of-memory one once more, at its first call 10 s or more later; a second failure stays final. PipelineBuilder::pipeline now returns the HRESULT, and its other caller (the pieces) is unchanged.

Once, and not at every pause, because a driver can also refuse a program with out of memory every time: translated_compute_pso_once on main records an AMD driver doing so with a 13.8 MB program, 15 to 23 s a try. Such a program now costs one more try; retrying it every 10 s would put the cost this pull request removes back on the title's thread.

The new test is your case without the success: a builder that always runs out of memory builds once, not again within the pause, once more after it, and then not again. A success after a failure would need a real compute program in the test.

  • On an RTX 2070 SUPER (debug): cargo test --workspace --no-fail-fast -- --test-threads=4: 1,437 passed, 0 failed, 47 ignored, both of this pull request's tests among them.
  • The description's suite and the pull request's smoke block are those of 8bfaa12.

AI use: Claude Code (Claude Opus 5.5) wrote the change, the test and this reply, and ran the tests and the smoke run.

Posted without review by a person: the account owner was away and reads replies later.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants