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

Open
github-bot wants to merge 1 commit from github-bot/gh-2469 into main AGit
Owner

@⁠razormontana on GitHub · 2026-11-25 19:39 UTC · original
razormontana:d3d12x/reuse-split-scratch-on-growth-failure → main · +42 −10 · 2 files · 1 commits · open

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, Intel Core i7-10700K, GeForce RTX 3070 8 GB (driver 617.42). Rust 1.100.0, stable MSVC x64, debug. The focused tests run on the CPU.
  • cargo +stable-x86_64-pc-windows-msvc test --offline --locked -p xcl --lib hle::d3d12x::real::dispatch_chain::tests:: -- --nocapture --test-threads=1. With the original selection behavior on base 2898511, 1 passed and 1 failed. An injected failure growing from 2 MiB to 8 MiB returned no buffer for a 64 KiB group. On the fixed source, 2 passed, 0 failed, 0 ignored and 0 skipped. The local focused run preceded the README update. Head 44a66e6 has the identical runtime and test source.
  • cargo build --offline --locked --workspace succeeded in debug and release. On the exact PR head, cargo test --offline --locked --workspace --no-fail-fast -- --test-threads=4 --show-output reported 1,364 passed, 0 failed and 46 ignored. There were 26 runtime SKIPPED notices for cases Cargo counted as passed.

Regression run

Both 60-second release runs used the same retail title on the RTX 3070, the Series S profile, identical starting DXIL cache contents, and XCL_DIRECT_DXIL=1 plus XCL_TEXTURE_LEVEL_PAGES=1. The starting cache was copied from the first main run. The head showed 778 frames at 14,668 MB peak commit. Main showed 773 frames at 14,620 MB. Each completed with zero crashes and device removals.

Main

xcl-smoke v1
commit: 2898511af1c038a2ef809719e9b6f89e5675c422
gpu: NVIDIA GeForce RTX 3070
title: 3c290c16
seconds: 60
exit: 0x0
frames shown: 773 (PresentX 773)
presents per 2 s (last 3): 10 19 21
device removals: 0
crashes: 0
peak commit: 14620 MB

PR head

xcl-smoke v1
commit: 44a66e63d7173ddfea4f989355c8038fd43942dd
gpu: NVIDIA GeForce RTX 3070
title: 3c290c16
seconds: 60
exit: 0x0
frames shown: 778 (PresentX 778)
presents per 2 s (last 3): 0 24 23
device removals: 0
crashes: 0
peak commit: 14668 MB

The first 60-second pair used the original cache seed. The head showed 590 frames at 15,071 MB peak commit. Main showed 795 frames at 14,457 MB. Both completed cleanly, and the head missed the 80% frame gate. Each log recorded zero chained dispatches and peak scratch of 0 MiB.

Not tested

Both retail smoke pairs recorded zero chained dispatches. The CPU test simulates the scratch allocation failure. The effect on shader-code usage during retail world loading remains unmeasured.

The retail smoke covers launcher stability and present counts. World entry was outside the verified coverage.

AI use

Codex (GPT-6.2 Astra) investigated the path, wrote the change and regression test, ran the focused tests and drafted this description.

OpenAI Codex (GPT-6.2) reviewed the change and ran the exact-head workspace suite and paired retail smoke checks.

**@⁠razormontana** on GitHub · 2026-11-25 19:39 UTC · [original](https://github.com/xcl-dev/xcl/pull/2469) `razormontana:d3d12x/reuse-split-scratch-on-growth-failure` → `main` · +42 −10 · 2 files · 1 commits · open 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, Intel Core i7-10700K, GeForce RTX 3070 8 GB (driver 617.42). Rust 1.100.0, stable MSVC x64, debug. The focused tests run on the CPU. - `cargo +stable-x86_64-pc-windows-msvc test --offline --locked -p xcl --lib hle::d3d12x::real::dispatch_chain::tests:: -- --nocapture --test-threads=1`. With the original selection behavior on base `2898511`, 1 passed and 1 failed. An injected failure growing from 2 MiB to 8 MiB returned no buffer for a 64 KiB group. On the fixed source, 2 passed, 0 failed, 0 ignored and 0 skipped. The local focused run preceded the README update. Head `44a66e6` has the identical runtime and test source. - `cargo build --offline --locked --workspace` succeeded in debug and release. On the exact PR head, `cargo test --offline --locked --workspace --no-fail-fast -- --test-threads=4 --show-output` reported 1,364 passed, 0 failed and 46 ignored. There were 26 runtime `SKIPPED` notices for cases Cargo counted as passed. **Regression run** Both 60-second release runs used the same retail title on the RTX 3070, the Series S profile, identical starting DXIL cache contents, and `XCL_DIRECT_DXIL=1` plus `XCL_TEXTURE_LEVEL_PAGES=1`. The starting cache was copied from the first main run. The head showed 778 frames at 14,668 MB peak commit. Main showed 773 frames at 14,620 MB. Each completed with zero crashes and device removals. Main ``` xcl-smoke v1 commit: 2898511af1c038a2ef809719e9b6f89e5675c422 gpu: NVIDIA GeForce RTX 3070 title: 3c290c16 seconds: 60 exit: 0x0 frames shown: 773 (PresentX 773) presents per 2 s (last 3): 10 19 21 device removals: 0 crashes: 0 peak commit: 14620 MB ``` PR head ``` xcl-smoke v1 commit: 44a66e63d7173ddfea4f989355c8038fd43942dd gpu: NVIDIA GeForce RTX 3070 title: 3c290c16 seconds: 60 exit: 0x0 frames shown: 778 (PresentX 778) presents per 2 s (last 3): 0 24 23 device removals: 0 crashes: 0 peak commit: 14668 MB ``` The first 60-second pair used the original cache seed. The head showed 590 frames at 15,071 MB peak commit. Main showed 795 frames at 14,457 MB. Both completed cleanly, and the head missed the 80% frame gate. Each log recorded zero chained dispatches and peak scratch of 0 MiB. **Not tested** Both retail smoke pairs recorded zero chained dispatches. The CPU test simulates the scratch allocation failure. The effect on shader-code usage during retail world loading remains unmeasured. The retail smoke covers launcher stability and present counts. World entry was outside the verified coverage. **AI use** Codex (GPT-6.2 Astra) investigated the path, wrote the change and regression test, ran the focused tests and drafted this description. OpenAI Codex (GPT-6.2) reviewed the change and ran the exact-head workspace suite and paired retail smoke checks.
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)
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 05:31:28 +00:00
Author
Owner

@⁠DavidM1911 on GitHub · 2026-11-25 20:22 UTC · original

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

  • cargo test -p xcl --lib: all passed, 0 failed, ~26 ignored. (Intermittent single-test flake / 0xc0000005 abort under parallel scheduling — tracked in #1978; clean on single-threaded rerun.)

Thanks!

**@⁠DavidM1911** on GitHub · 2026-11-25 20:22 UTC · [original](https://github.com/xcl-dev/xcl/pull/2469#issuecomment-7173562931) Verification on RTX 3060 Ti (Windows 11), branch merged with current `main`: - `cargo test -p xcl --lib`: all passed, 0 failed, ~26 ignored. (Intermittent single-test flake / 0xc0000005 abort under parallel scheduling — tracked in #1978; clean on single-threaded rerun.) Thanks!
This pull request has changes conflicting with the target branch.
  • crates/xcl/src/hle/d3d12x/real/dispatch_chain.rs
View command line instructions

Manual merge helper

Use this merge commit message when completing the merge manually.

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin '+refs/pull/2469/head:github-bot/gh-2469'
git switch 'github-bot/gh-2469'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-2469'
git switch 'github-bot/gh-2469'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-2469'
git switch 'github-bot/gh-2469'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-2469'
git switch 'main'
git merge --squash 'github-bot/gh-2469'
git switch 'main'
git merge --ff-only 'github-bot/gh-2469'
git switch 'main'
git merge 'github-bot/gh-2469'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No description provided.