Skip to content

D3D12.X: reuse split dispatch scratch when growth fails - #2469

Open
razormontana wants to merge 1 commit into
xcl-dev:mainfrom
razormontana:d3d12x/reuse-split-scratch-on-growth-failure
Open

razormontana wants to merge 1 commit into
xcl-dev:mainfrom
razormontana:d3d12x/reuse-split-scratch-on-growth-failure

Conversation

@razormontana

@razormontana razormontana commented Nov 25, 2026 •

Copy link
Copy Markdown
Contributor

A split compute dispatch can use smaller slabs when a command list’s scratch buffer holds at least one thread group. If allocating a larger buffer failed, XCL discarded that option and built or bound the whole compute pipeline. Reusing the buffer avoids bringing an additional whole pipeline into use on this path. Part of #2403.

What is in it

  • In real/dispatch_chain.rs, reuse the same recording’s scratch after a failed growth request if one group fits. Report reuse to the command recorder so it issues its UAV barrier. Only a successful allocation updates scratch usage and replaces the shared buffer.
  • The CPU regression test injects an allocation failure and checks the returned buffer and reuse flag. It covers an exact-fit group, a buffer one byte too small, a missing buffer, successful growth and an already adequate buffer.
  • README.md describes when split dispatches can continue with the recording’s existing scratch buffer.

Tested

  • Windows 11 Pro build 22631, Core i7-10700K, RTX 3070 8 GB (driver 617.42), Rust 1.100.0 MSVC.
  • Two focused CPU tests passed on the rebased head. The original allocation-failure fixture failed without the reuse change. The rebase preserves the upstream GPU scratch-sharing test and the existing UAV barrier on reuse.
  • Debug workspace build passed. On f2062cda, cargo test --offline --locked --workspace --no-fail-fast -- --test-threads=4 --show-output reported 1,443 passed, 0 failed and 47 ignored. The pass count includes 26 explicit GPU skip notices.
  • cargo build --offline --locked --release -p xcl succeeded.

Regression run

Both release builds ran the same retail title offline for 60 seconds on the RTX 3070. Both used the Series S profile, direct DXIL and copies of the same starting cache. This pair uses e120925, the preceding main commit. At 8b957be, smoke reached its startup deadline during #2555 shader preparation. The PR merges cleanly into 8b957be; the combined retail run remains unverified. The initial pair showed 703 frames on main and 378 on the PR. For this repeat, both started from copies of the cache left by the first main run, after builds completed.

Main

xcl-smoke v1
commit: e120925e3abc9956a8b9bae631969d32e8ccd43c
gpu: NVIDIA GeForce RTX 3070
title: 80ea98f7
seconds: 60
exit: 0x0
frames shown: 445 (PresentX 446)
presents per 2 s (last 3): 18 18 18
device removals: 0
crashes: 0
peak commit: 17596 MB

PR head

xcl-smoke v1
commit: f2062cdaeb31bbf83e442cce27066409b8162cb4
gpu: NVIDIA GeForce RTX 3070
title: 80ea98f7
seconds: 60
exit: 0x0
frames shown: 450 (PresentX 450)
presents per 2 s (last 3): 18 18 18
device removals: 0
crashes: 0
peak commit: 17630 MB

Not tested

The CPU test injects scratch allocation failure. The retail smoke checks startup and presents. It does not establish a reduction in shader-code usage during world loading.

AI use

Codex GPT-6.2 wrote and reviewed the code and tests, rebased the branch, ran the checks, and updated this description.

@DavidM1911

Copy link
Copy Markdown
Contributor

Verification on RTX 3060 Ti (Windows 11), branch merged with current main:

Thanks!

@throny throny added the goal:world-load Bears on the retail title getting past world loading label Nov 25, 2026

@bmjask bmjask 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.

No concrete defect found. Fallback reuse is capacity-safe, slabbed within its existing allocation, and inserts the required UAV barrier; current Windows CI is green. Nonblocking coverage gap: the test injects select_scratch failure rather than exercising the real D3D12 allocation-failure -> command-recording/slab path. A seam/integration test would strengthen it, but I found no blocker.

rootw0rm pushed a commit to rootw0rm/xcl that referenced this pull request Nov 26, 2026
…ry (port upstream xcl-dev#2469 + xcl-dev#2532 + xcl-dev#2543 + xcl-dev#2629)

(cherry picked from commit bc14f1d8b191b3935c9829a539454b6226c542d0)
@Prime1997 Prime1997 mentioned this pull request Nov 26, 2026
A recording can dispatch a split program in smaller slabs if its current scratch holds at least one group. Keep that buffer and request the reuse barrier when creating a larger resource fails, so dispatch does not build a whole pipeline for this case.

Assisted-by: Codex (GPT-6.2 Astra)
Assisted-by: Codex GPT-6.2
@razormontana
razormontana force-pushed the d3d12x/reuse-split-scratch-on-growth-failure branch from 44a66e6 to f2062cd Compare November 26, 2026 17:41
@Ritolino

Copy link
Copy Markdown
Contributor

Independent Windows 11 x64 + NVIDIA GeForce RTX 4080 (wave32) verification of #2469 head f2062cda merged cleanly onto current main (8b957bec):

Tested

  • Windows 11 x64, AMD Ryzen 9 7950X, NVIDIA GeForce RTX 4080 (wave32), rustc 1.100.0 (stable-x86_64-pc-windows-msvc), debug
  • cargo build --workspace: succeeded
  • hle::d3d12x::real::dispatch_chain::tests::failed_scratch_growth_reuses_a_buffer_that_fits_a_group: ok
  • cargo test --workspace --no-fail-fast -- --test-threads=4 --skip blob_enumeration_sees_one_submitted_update:
    • xcl --lib: 1318 passed, 0 failed, 27 ignored, 1 filtered out
    • All 37 other workspace test targets: 128 passed, 0 failed, 20 ignored
    • Total: 1446 passed, 0 failed, 47 ignored, 1 filtered out (blob_enumeration_sees_one_submitted_update skipped due to pre-existing #2421 / #2373).

AI use: Antigravity with Gemini 4 Hydrogen (Medium) ran the merge/build/test pass and drafted this report; reviewed by human.

@a-DuckGod

Copy link
Copy Markdown

Independent Windows 11 / NVIDIA test report on exact PR head f2062cdaeb31bbf83e442cce27066409b8162cb4 (clean detached checkout; merge-base e120925e).

Tested

  • Hardware / OS / toolchain: NVIDIA GeForce RTX 3080 Ti (12 GB, wave32, mesh shaders), driver 32.0.16.2114; Intel Core i7-8700K, 32 GB RAM; Windows 11 Pro (Version Dev 29708.1003); rustc 1.100.0 (0ef1bc386 2026-11-09) (x86_64-pc-windows-msvc), Windows SDK DXC 1.8.2502.11, D3D12 debug layer installed, debug build.
  • cargo build --workspace: succeeded.
  • cargo test -p xcl --lib failed_scratch_growth_reuses_a_buffer_that_fits_a_group -- --nocapture: 1 passed, 0 failed, 0 ignored, 0 skipped.
  • cargo test --workspace --no-fail-fast -- --test-threads=4: 1442 passed, 1 failed, 47 ignored (including all e2e tests under the D3D12 debug layer and DRED).
    • The 1 failure was hle::d3d12x::vram::tests::d32s8_targets_take_their_own_size_of_video_memory (vram.rs:2040:26, HRESULT(0x80004005) under parallel GPU load).
    • Standalone rerun cargo test -p xcl --lib d32s8_targets_take_their_own_size_of_video_memory -- --nocapture: 1 passed, 0 failed, 0 ignored (2.83 s).
  • SKIPPED GPU tests (26): 21 no wave64 (RTX 3080 Ti is 32-lane waves only), 3 per-lane gpu: direct RDNA2 -> DXIL backend (no HLSL / DXC), behind XCL_DIRECT_DXIL #1426 refused forms (V_MUL_F16, V_PK_MUL_F16, V_CVT_F16_F32), 1 shaders::tests::pso_measurement_compiles_an_exact_synthetic_record (cannot disable driver cache; Windows Developer Mode required), 1 heap_window_out_of_memory_falls_back_to_the_switch_form (no heap windows).

Not tested

  • Release build, retail title / scripts/smoke.ps1 run, XCL_SAMPLE_* tests, live OOM scratch-growth fallback during a game dispatch, AMD / Intel / native wave64 GPUs.

AI use

  • Antigravity (Gemini 4 Neon) checked out the PR, read commit f2062cda (dispatch_chain.rs and README.md), ran the build and tests, and drafted this report. I checked it before posting.

@Decodere

Copy link
Copy Markdown
Contributor

Independent RTX 4060 (8 GB) / Windows 11 release verification of PR #2469 rebased head f2062cdaeb31bbf83e442cce27066409b8162cb4 (exact parent & merge-base e120925e3abc9956a8b9bae631969d32e8ccd43c). Measurements and targeted test results only; not a full source review.

Setup

  • GPU: NVIDIA GeForce RTX 4060 (8 GB / 7956 MiB reported by D3D12), driver 32.0.16.2114 (NVIDIA 621.14, WDDM 3.2)
  • CPU / RAM / OS: Intel Core i5-11400F (6 cores / 12 threads), 32 GB RAM (31.9 GiB usable), Windows 11 Home 26200
  • Toolchain / caches: rustc 1.100.0 (0ef1bc386 2026-11-09), DXC 1.9.2609.5, release builds, warm DXIL/pipeline caches, quiet machine (zero concurrent builds/tests during timed runs)
  • Workload: Retail workload title: 29640639 via scripts/smoke.ps1 -Seconds 60 (XCL_NETWORK=0, default flags, no input)

Targeted RTX 4060 release unit & GPU tests (f2062cda)

  • cargo test --release -p xcl --lib failed_scratch_growth_reuses_a_buffer_that_fits_a_group -- --nocapture: 1 passed, 0 failed, 0 ignored (0.00 s, 0 SKIPPED).
  • cargo test --release -p xcl --lib hle::d3d12x::real::dispatch_chain:: (3 consecutive parallel passes): 3 passed, 0 failed, 0 ignored on all 3 passes (0.25 s / 0.17 s / 0.17 s, 0 SKIPPED).
  • cargo test --release -p xcl --lib hle::d3d12x::real::: 64 passed, 0 failed, 0 ignored (0.36 s, 0 SKIPPED).

Paired 60 s RTX 4060 smoke (exact parent e120925e vs f2062cda)

Both runs completed cleanly at steady 60/2 s pacing with 0 device removals and 0 crashes (f2062cda vs e120925e xcl.log: 6,176 / 6,115 MB vs 6,114 / 6,114 MB peak/end local VRAM, 4,651 MB end non-local VRAM on both, 19,450 vs 19,588 translated draws / 1,024 dispatches with 0 skipped).

Exact parent (e120925e):

xcl-smoke v1
commit: e120925e3abc9956a8b9bae631969d32e8ccd43c
gpu: NVIDIA GeForce RTX 4060
title: 29640639
seconds: 60
exit: 0x0
frames shown: 1602 (PresentX 1602)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 13979 MB

PR #2469 head (f2062cda):

xcl-smoke v1
commit: f2062cdaeb31bbf83e442cce27066409b8162cb4
gpu: NVIDIA GeForce RTX 4060
title: 29640639
seconds: 60
exit: 0x0
frames shown: 1591 (PresentX 1591)
presents per 2 s (last 3): 60 60 61
device removals: 0
crashes: 0
peak commit: 13997 MB

Limits of coverage

  • Full workspace test suite was not run on f2062cda (only failed_scratch_growth_reuses_a_buffer_that_fits_a_group, 3 parallel passes of dispatch_chain::, hle::d3d12x::real::, release build, and exact-parent paired 60 s smokes).
  • The 60 s no-input menu/intro smoke hit 0 split-compute programs (compute split: 0 programs split, 0 pieces built, 0 chained dispatches issued in 0 slabs; scratch 0 MiB), so scratch-growth failure fallback and buffer reuse were exercised by the targeted release unit test above rather than live split-compute OOM pressure.
  • Single discrete NVIDIA 8 GB GPU (RTX 4060) on native Windows 11; no AMD, Intel, or Wine/Linux run on this host.

AI use

Ran the targeted release unit/GPU tests, release build, and exact-parent paired quiet 60 s smoke runs with assistance from Google Antigravity (Gemini 4 Neon); all test counts, timings, memory figures, and smoke blocks were extracted directly from cargo test, xcl.log, and scripts/smoke.ps1 outputs.

@thiagocalile

Copy link
Copy Markdown

Independent test and smoke report for head f2062cdaeb31bbf83e442cce27066409b8162cb4 on an AMD Radeon RX 6600 (8 GB VRAM, RDNA2, native wave64).

Tested

  • Hardware: AMD Radeon RX 6600 (8146 MiB VRAM, RDNA2, native wave64 + mesh shaders, driver 32.0.21045.29003, XCL_ADAPTER=radeon), AMD Ryzen 7 5700X3D, 47.9 GB RAM, Windows 11 (10.0.26200.0), Rust 1.100.0 (stable-x86_64-pc-windows-msvc), DXC 1.8.2502.11.
  • XCL_ADAPTER=radeon cargo test --no-fail-fast -p xcl --lib -- dispatch_chain --test-threads=4: 11 passed, 0 failed, 0 ignored (0 skipped).

Not tested: full workspace suite, 60 s smoke run on this head, NVIDIA/Intel GPUs, or Linux/Wine.

AI use: Antigravity (Gemini 4 Neon) ran the builds, tests, and smoke runs and drafted this report; the account owner reviewed and approved posting.

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

Labels

goal:world-load Bears on the retail title getting past world loading

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants