Skip to content

D3D12.X: reserve split compute scratch before allocating it - #2532

Open
razormontana wants to merge 1 commit into
xcl-dev:mainfrom
razormontana:d3d12x/reserve-split-scratch-before-allocation
Open

razormontana wants to merge 1 commit into
xcl-dev:mainfrom
razormontana:d3d12x/reserve-split-scratch-before-allocation

Conversation

@razormontana

Copy link
Copy Markdown
Contributor

Two command lists could both ask D3D12 for 256 MiB of split-compute scratch under a shared 384 MiB budget. Each recording checked the available space before either driver allocation had returned. XCL now reserves a recording’s allowance when it chooses the buffer size. Part of #1833.

What is in it

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 and Windows SDK DXC. Exact head bb33ceed26be32dba18b4799d0b6396649bed840. The focused admission 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 --skip a_list_recorded_after_another_goes_on_in_its_scratch. The original charge-after-allocation behavior with the test seam produced 1 pass and 2 failures. Concurrent recordings each requested 256 MiB and an in-progress 16 MiB allocation counted as zero. After the fix, 3 passed, 0 failed, 0 ignored and 0 runtime skips. The concurrent requests were 256 and 128 MiB.
  • cargo build --offline --locked --workspace and cargo build --offline --locked --release --workspace succeeded. The debug cargo test --offline --locked --workspace --no-fail-fast -- --test-threads=4 --show-output run with XCL_ADAPTER=3070 reported 1,425 passed, 0 failed and 46 ignored across 37 targets. The pass count includes 26 SKIPPED notices (21 native-wave64 checks, 3 unsupported per-lane forms, 1 reserved cube with mips and 1 heap-window check).

Regression run

Both clean release builds ran scripts/smoke.ps1 -Game <folder> -Seconds 60 on the same retail title in the Series S profile on the RTX 3070. They used XCL_DIRECT_DXIL=1, networking off and identical starting copies of XCL's warmed cache. NVIDIA's driver cache settings were left at their defaults.

Main

xcl-smoke v1
commit: 6d12f58a229bc73889878a448c64dc3af25eeba0
gpu: NVIDIA GeForce RTX 3070
title: 3c290c16
seconds: 60
exit: 0x0
frames shown: 651 (PresentX 651)
presents per 2 s (last 3): 8 0 15
device removals: 0
crashes: 0
peak commit: 14469 MB

Candidate

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

Not tested

Both retail smoke logs reported zero chained dispatches and 0 MiB peak split scratch. The concurrent-admission case is covered by the synthetic test. Retail prevalence, effect on NVIDIA device removals, and behavior on AMD and Intel GPUs remain unmeasured.

AI use

OpenAI Codex (GPT-6.2 Astra) inspected the recording path, wrote the code and tests, ran the focused tests and drafted this description. OpenAI Codex (GPT-6.2 Sol) independently reviewed the diff and evidence and edited this description. The lead agent ran the workspace suite and retail smoke using OpenAI Codex (GPT-6.2).

Two concurrent command lists could each request 256 MiB from the same 384 MiB budget before either driver call returned. Charge a request while deciding its size and return the charge when allocation fails or the recording releases the buffer. Keep live and peak measurements limited to successful allocations.
@razormontana
razormontana marked this pull request as ready for review November 25, 2026 22:00
@DavidM1911

Copy link
Copy Markdown
Contributor

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

Thanks!

@emirduran707

Copy link
Copy Markdown
Contributor

Independent AMD RDNA4 (native wave64) test report on exact head bb33ceed26be32dba18b4799d0b6396649bed840 (clean detached checkout, no local changes).

Tested

  • AMD Radeon RX 9060 XT 16 GB (RDNA4, native wave64, driver 32.0.31044.16), Ryzen 5 5600, 32 GB RAM, Windows 11 Pro 26300, Rust 1.100.0 (stable-x86_64-pc-windows-msvc), DXC 1.9.2602.17; tests debug, smoke release.
  • cargo build --workspace && cargo test --workspace --no-fail-fast -- --test-threads=4: 1423 passed, 2 failed, 46 ignored; 8 SKIPPED (6 in lower_dxil::tests::{f16,f32}_programs_on_the_gpu refused by per-lane form; heap_window_out_of_memory_falls_back_to_the_switch_form; pso_measurement_compiles_an_exact_synthetic_record). All native wave64 GPU tests ran and passed.
    • Both PR tests passed: hle::d3d12x::real::dispatch_chain::tests::pending_scratch_releases_its_charge_on_allocation_failure and simultaneous_scratch_allocations_share_the_total.
    • The 2 failures (gpu::dxil::fuzz_tests::fuzz_validate_and_gpu_1 seed 722 and fuzz_validate_and_gpu_3 seed 1599) are pre-existing on unmodified main on this GPU.

Regression run (60 s retail-title smoke, XCL_NETWORK=0, release)

xcl-smoke v1
commit: bb33ceed26be32dba18b4799d0b6396649bed840
gpu: AMD Radeon RX 9060 XT
title: 21222967
seconds: 60
exit: 0x0
frames shown: 1613 (PresentX 1613)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 13911 MB

(Matched main 68a284a baseline on the same machine today: 1573 frames, 14420 MB peak, 0 device removals, 0 crashes.)

Not tested

  • D3D12 debug layer; Intel GPUs.

AI use

  • Antigravity with Gemini 4 Neon ran the build, test suite, and smoke run and drafted this report.

@xpatfussy69x

xpatfussy69x commented Nov 25, 2026 •

Copy link
Copy Markdown

Test run on exact head bb33cee (bb33ceed26be32dba18b4799d0b6396649bed840, on its base 6d12f58), clean tree.

Tested

  • NVIDIA GeForce RTX 3060 12 GB (driver 32.0.16.2124, 32-lane waves only), AMD Ryzen 5 7500F, Windows 11, Rust 1.100.0; debug build for the tests, release for the smoke runs
  • cargo test --workspace -- --test-threads=4: 1425 passed, 0 failed, 46 ignored
  • SKIPPED (25): 21 × no wave64; 1 × no heap windows; 3 × per-lane form refused V_MUL_F16 / V_PK_MUL_F16 / V_CVT_F16_F32 (on main too)
  • cargo test -p xcl --lib scratch: 7 passed, 0 failed
  • This PR's new tests in the workspace run:
    • simultaneous_scratch_allocations_share_the_total: ok
    • pending_scratch_releases_its_charge_on_allocation_failure: ok
  • Conflicts with D3D12.X: clear dispatch_chain shared scratch on list lifecycle transitions #2543 in crates/xcl/src/hle/d3d12x/real/dispatch_chain.rs (git merge-tree of both heads); whichever lands second needs a rebase

Regression run (60 s, default settings, a retail title)

main:

xcl-smoke v1
commit: e1d84b7d9153f86a97d2ec5d209d196046fc0bea
gpu: NVIDIA GeForce RTX 3060
title: c3f791f3
seconds: 60
exit: 0x0
frames shown: 1091 (PresentX 1091)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 14814 MB

this PR:

xcl-smoke v1
commit: bb33ceed26be32dba18b4799d0b6396649bed840
gpu: NVIDIA GeForce RTX 3060
title: c3f791f3
seconds: 60
exit: 0x0
frames shown: 1143 (PresentX 1143)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 14787 MB

No crash or device removal; frames 105 % of main's, peak commit 100 %.

Not tested

  • Whether the title allocates split compute scratch in this run: a regression check only
  • The PR merged into current main (tested on its own base; it merges into e1d84b7 without conflicts)
  • AMD / native wave64

AI use

  • Claude Code (Claude Opus 5.5) ran the tests and both smoke runs on the machine above and wrote this report.

@SlopTart

Copy link
Copy Markdown

Tested: current PR head merged onto current origin/main (clean), Linux (Arch, kernel 7.2.15), Mesa 26.2.5 RADV, Radeon RX 7900 XT (NAVI31), cargo target x86_64-pc-windows-gnu run under wine-11.0 (Proton), rustc 1.94.0, vkd3d-proton 3.1 with the XCL patch, official MS DXC (binaries 2026-09-29).

gpu_ suite (cold cache): 164 passed / 3 failed, no crashes. The three are the known baseline on this lane (seed-1003 fuzz, mad/mac contraction, promoted-UAV-clear driver gap, PR #2490); none caused by this PR.
Targeted run of pending_scratch_releases_its_charge_on_allocation_failure and simultaneous_scratch_allocations_share_the_total: 2 passed.

Not tested: retail titles (no title data on this lane, counts only).

AI use: Hermes agent (local Qwen-class) ran both machines and drafted this; I checked it before posting.

@KOLESNiii KOLESNiii mentioned this pull request Nov 25, 2026
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.

5 participants