D3D12.X: replace busy copy scratch within budget #1421

Open
github-bot wants to merge 2 commits from github-bot/gh-1421 into main AGit
Owner

@⁠hajduzsolt on GitHub · 2026-11-24 15:47 UTC · original
hajduzsolt:fix/copy-scratch-busy-buffer → main · +61 −8 · 1 files · 2 commits · open

Runtime fix verified with unit tests and RX 9070 XT smoke run.

What is in it

  • crates/xcl/src/hle/d3d12x/list_x.rs: retain busy scratch until GPU completion and test replacement and accounting with synthetic D3D12 resources.

Tested

  • Windows 11 Pro x64 build 26300, AMD Ryzen 7 9800X3D, AMD Radeon RX 9070 XT 16 GB, driver 32.0.32029.2010; Rust 1.98.1 MSVC, debug.
  • cargo test -p xcl --lib copy_scratch -- --test-threads=4: 3 passed, 0 failed.
  • cargo test --workspace -- --test-threads=4 --nocapture: 752 passed, 0 failed, 41 ignored. The reported passes include tests that return early.
  • SKIPPED: test_title_draws_with_a_root_signature_under_the_debug_layer and uploads_start_from_each_subresources_state (D3D12 debug layer unavailable).

Regression run

main:

xcl-smoke v1
commit: c160d86ef2efe3a07e4dfb473e4fa72eafb413c0
gpu: AMD Radeon RX 9070 XT
title: A newer retail game
seconds: 60
exit: 0x0
frames shown: 1594 (PresentX 1594)
presents per 2 s (last 3): 49 48 14
device removals: 0
crashes: 0
peak commit: 20195 MB

PR:

xcl-smoke v1
commit: 7124a95392e1a6b99db7b3fc5763d1269606c5f3
gpu: AMD Radeon RX 9070 XT
title: A newer retail game
seconds: 60
exit: 0x0
frames shown: 1680 (PresentX 1680)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 14843 MB

Not tested

  • Retail title, debug-layer validation, and the end-to-end kickoff/copy path. The budget-exhausted fallback and its logging are unchanged.

AI use

  • Codex (GPT-6): wrote implementation and unit tests, ran validation, and drafted this description.
**@⁠hajduzsolt** on GitHub · 2026-11-24 15:47 UTC · [original](https://github.com/xcl-dev/xcl/pull/1421) `hajduzsolt:fix/copy-scratch-busy-buffer` → `main` · +61 −8 · 1 files · 2 commits · open Runtime fix verified with unit tests and RX 9070 XT smoke run. **What is in it** - `crates/xcl/src/hle/d3d12x/list_x.rs`: retain busy scratch until GPU completion and test replacement and accounting with synthetic D3D12 resources. **Tested** - Windows 11 Pro x64 build 26300, AMD Ryzen 7 9800X3D, AMD Radeon RX 9070 XT 16 GB, driver 32.0.32029.2010; Rust 1.98.1 MSVC, debug. - `cargo test -p xcl --lib copy_scratch -- --test-threads=4`: 3 passed, 0 failed. - `cargo test --workspace -- --test-threads=4 --nocapture`: 752 passed, 0 failed, 41 ignored. The reported passes include tests that return early. - SKIPPED: `test_title_draws_with_a_root_signature_under_the_debug_layer` and `uploads_start_from_each_subresources_state` (D3D12 debug layer unavailable). **Regression run** main: ``` xcl-smoke v1 commit: c160d86ef2efe3a07e4dfb473e4fa72eafb413c0 gpu: AMD Radeon RX 9070 XT title: A newer retail game seconds: 60 exit: 0x0 frames shown: 1594 (PresentX 1594) presents per 2 s (last 3): 49 48 14 device removals: 0 crashes: 0 peak commit: 20195 MB ``` PR: ``` xcl-smoke v1 commit: 7124a95392e1a6b99db7b3fc5763d1269606c5f3 gpu: AMD Radeon RX 9070 XT title: A newer retail game seconds: 60 exit: 0x0 frames shown: 1680 (PresentX 1680) presents per 2 s (last 3): 60 60 60 device removals: 0 crashes: 0 peak commit: 14843 MB ``` **Not tested** - Retail title, debug-layer validation, and the end-to-end kickoff/copy path. The budget-exhausted fallback and its logging are unchanged. **AI use** - Codex (GPT-6): wrote implementation and unit tests, ran validation, and drafted this description.
Retire a busy scratch buffer until its fence completes and allocate a replacement when the budget has room.

Co-Authored-By: Codex GPT-6 <[email protected]>
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 04:53:20 +00:00
Author
Owner

@⁠srcamarda on GitHub · 2026-11-24 16:54 UTC · original

Test report for 4c65020 merged onto main 2008399: AMD RDNA3, with the debug layer installed; the retail title does not reach the #1408 path in its first 150 s

Tested

  • AMD Radeon RX 7800 XT 16 GB (RDNA3), driver 32.0.32029.2010; Ryzen 5 5600G, 32 GB; Windows 11 Pro 26300 with Graphics Tools (D3D12 debug layer); rustc 1.100.0; debug for the tests, release for the title.
  • This PR merged onto main 2008399 locally (clean merge, not pushed).
  • cargo test --workspace --no-fail-fast -- --test-threads=4: 752 passed, 0 failed, 41 ignored. No SKIPPED lines. The two debug-layer tests your description lists as skipped ran and passed here: test_title_draws_with_a_root_signature_under_the_debug_layer (which asserts no "invalid for use as a source buffer" since #993) and uploads_start_from_each_subresources_state. The three copy-scratch tests pass, including busy_copy_scratch_is_retired_when_budget_allows_a_replacement.

Retail title under the debug layer

  • Retail title 1.0.2.1, XCL_D3D12_DEBUG=1 XCL_NETWORK=0 XCL_ACTIVITY=1 XCL_RUN_SECONDS=150, Enter (= A) at 30 / 40 / 50 s (title screens into the start of loading). Interleaved main, this PR, main, this PR.
  • XCL logs only the first 8 messages of each id, and id 538 fills that from 2.9 s with other state errors. So for these runs both builds carried the same local diagnostic, not part of this PR: messages that mention CopyBufferRegion are logged with no cap.
  • CopyBufferRegion state errors: 0 in all four runs, main and this PR alike. No device removal or crash; frames shown: main 2157 / 2008, this PR 1698 / 2009.
  • So in these 150 s the title does not reach a copy within one window after a resubmitted list, and this run does not show the effect of the change either way. It also shows no regression.

The id 538 errors the title does hit (same in both builds, and on main 47efa2e before #993; for whoever looks at them, not this PR's):

  • ClearRenderTargetView on a resource in UNORDERED_ACCESS (also once in COPY_SOURCE);
  • CopyResource with its source in RENDER_TARGET;
  • Draw with a render target in NON_PIXEL_SHADER_RESOURCE | PIXEL_SHADER_RESOURCE.

Not tested

  • The world load and later (the title's crash at +0x23cf683, #534, comes after these 150 s on this machine).
  • This PR on its own base; the budget-exhausted fallback.

Claude Code (Claude Opus 5.5), from runs on the hardware above.

**@⁠srcamarda** on GitHub · 2026-11-24 16:54 UTC · [original](https://github.com/xcl-dev/xcl/pull/1421#issuecomment-7138379461) **Test report for `4c65020` merged onto `main` `2008399`: AMD RDNA3, with the debug layer installed; the retail title does not reach the #1408 path in its first 150 s** **Tested** - AMD Radeon RX 7800 XT 16 GB (RDNA3), driver 32.0.32029.2010; Ryzen 5 5600G, 32 GB; Windows 11 Pro 26300 with Graphics Tools (D3D12 debug layer); rustc 1.100.0; debug for the tests, release for the title. - This PR merged onto `main` `2008399` locally (clean merge, not pushed). - `cargo test --workspace --no-fail-fast -- --test-threads=4`: 752 passed, 0 failed, 41 ignored. No `SKIPPED` lines. The two debug-layer tests your description lists as skipped **ran and passed** here: `test_title_draws_with_a_root_signature_under_the_debug_layer` (which asserts no "invalid for use as a source buffer" since #993) and `uploads_start_from_each_subresources_state`. The three copy-scratch tests pass, including `busy_copy_scratch_is_retired_when_budget_allows_a_replacement`. **Retail title under the debug layer** - Retail title 1.0.2.1, `XCL_D3D12_DEBUG=1 XCL_NETWORK=0 XCL_ACTIVITY=1 XCL_RUN_SECONDS=150`, Enter (= A) at 30 / 40 / 50 s (title screens into the start of loading). Interleaved `main`, this PR, `main`, this PR. - XCL logs only the first 8 messages of each id, and id 538 fills that from 2.9 s with other state errors. So for these runs both builds carried the same local diagnostic, not part of this PR: messages that mention `CopyBufferRegion` are logged with no cap. - **`CopyBufferRegion` state errors: 0 in all four runs**, `main` and this PR alike. No device removal or crash; frames shown: `main` 2157 / 2008, this PR 1698 / 2009. - So in these 150 s the title does not reach a copy within one window after a resubmitted list, and this run does not show the effect of the change either way. It also shows no regression. **The id 538 errors the title does hit** (same in both builds, and on `main` `47efa2e` before #993; for whoever looks at them, not this PR's): - `ClearRenderTargetView` on a resource in `UNORDERED_ACCESS` (also once in `COPY_SOURCE`); - `CopyResource` with its source in `RENDER_TARGET`; - `Draw` with a render target in `NON_PIXEL_SHADER_RESOURCE | PIXEL_SHADER_RESOURCE`. **Not tested** - The world load and later (the title's crash at `+0x23cf683`, #534, comes after these 150 s on this machine). - This PR on its own base; the budget-exhausted fallback. _Claude Code (Claude Opus 5.5), from runs on the hardware above._
Author
Owner

@⁠DavidM1911 on GitHub · 2026-11-24 17:21 UTC · original

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

  • cargo test -p xcl --lib: all passed, 0 failed, ~21 ignored.

Thanks!

**@⁠DavidM1911** on GitHub · 2026-11-24 17:21 UTC · [original](https://github.com/xcl-dev/xcl/pull/1421#issuecomment-7139070008) Verification on RTX 3060 Ti (Windows 11), branch merged with current `main`: - `cargo test -p xcl --lib`: all passed, 0 failed, ~21 ignored. Thanks!
Author
Owner

@⁠enderrr9 on GitHub · 2026-11-24 18:00 UTC · original

Test report: NVIDIA, 32-lane waves, head 4c65020

Tested

  • NVIDIA GeForce RTX 3050 Laptop GPU (4 GB, driver 621.24), AMD Ryzen 5 4600H, Windows 11 build 26300, rustc 1.100.0 (MSVC), DXC 1.8.2502.11, debug build
  • cargo test -p xcl --lib copy_scratch -- --test-threads=4 --nocapture: 3 passed, 0 failed (a_new_list_takes_no_copy_scratch_of_an_earlier_one, busy_copy_scratch_is_retired_when_budget_allows_a_replacement, copy_scratch_budget_counts_resources_until_gpu_completion), none SKIPPED
  • cargo test --workspace -- --test-threads=4: 752 passed, 0 failed, 41 ignored. SKIPPED: gpu_geometry_wave32_prefix_count_over_a_mask (no wave64), gpu_wave32_program_in_wave64_hardware (no wave64)

Not tested

  • a retail title (I have none), the D3D12 debug layer, whether the new test fails without the change

Report written and the tests run with Claude Code (Claude Opus 5.5).

**@⁠enderrr9** on GitHub · 2026-11-24 18:00 UTC · [original](https://github.com/xcl-dev/xcl/pull/1421#issuecomment-7140022836) **Test report: NVIDIA, 32-lane waves**, head `4c65020` **Tested** - NVIDIA GeForce RTX 3050 Laptop GPU (4 GB, driver 621.24), AMD Ryzen 5 4600H, Windows 11 build 26300, rustc 1.100.0 (MSVC), DXC 1.8.2502.11, debug build - `cargo test -p xcl --lib copy_scratch -- --test-threads=4 --nocapture`: 3 passed, 0 failed (`a_new_list_takes_no_copy_scratch_of_an_earlier_one`, `busy_copy_scratch_is_retired_when_budget_allows_a_replacement`, `copy_scratch_budget_counts_resources_until_gpu_completion`), none SKIPPED - `cargo test --workspace -- --test-threads=4`: 752 passed, 0 failed, 41 ignored. SKIPPED: `gpu_geometry_wave32_prefix_count_over_a_mask` (no wave64), `gpu_wave32_program_in_wave64_hardware` (no wave64) **Not tested** - a retail title (I have none), the D3D12 debug layer, whether the new test fails without the change Report written and the tests run with Claude Code (Claude Opus 5.5).
Author
Owner

@⁠hajduzsolt on GitHub · 2026-11-24 19:23 UTC · original

Thanks for noting the missing diagnostic. Budget-driven scratch refusals now emit a one-time warning before using the in-place fallback, including requests larger than the budget. The existing budget-exhaustion test and cargo test --workspace -- --test-threads=2 passed (708 library tests passed, 21 ignored).

**@⁠hajduzsolt** on GitHub · 2026-11-24 19:23 UTC · [original](https://github.com/xcl-dev/xcl/pull/1421#issuecomment-7142030915) Thanks for noting the missing diagnostic. Budget-driven scratch refusals now emit a one-time warning before using the in-place fallback, including requests larger than the budget. The existing budget-exhaustion test and `cargo test --workspace -- --test-threads=2` passed (708 library tests passed, 21 ignored).
Author
Owner

@⁠pvfreis on GitHub · 2026-11-24 16:34 UTC · original · edited 2026-11-24 22:33 UTC

Test report for 7124a95392 (this PR's head) merged onto main 1d027e5c76 (git auto-merged list_x.rs, no conflict). (Edited after a rerun. The first version covered 4c65020 onto b7aa9f3: 770 passed, 1 failed, 41 ignored; main 769/1/41, and noted the log line was missing; 7124a95 added it.) The new test passes on NVIDIA; no other test result changed. I opened #1408. Of its "Expected": a busy scratch moves to released, still charged to the budget, and a new one is made within it; the log line when the budget forces the fallback is now there.

Tested

  • RTX 3060 12 GB (driver 617.14), Ryzen 9 5900XT, Windows 11 26H2 (10.0.26300), Rust 1.100.0 stable MSVC, debug
  • cargo build --workspace --locked --offline, then cargo test --workspace --locked --offline --no-fail-fast -- --test-threads=4:
    • main 1d027e5: 958 passed, 1 failed, 43 ignored
    • this PR merged onto 1d027e5: 959 passed, 1 failed, 43 ignored. The difference is busy_copy_scratch_is_retired_when_budget_allows_a_replacement, which passes; the other two copy-scratch tests pass too, and the log has the new warning (emitted once per process) for a request of 67108864 bytes
  • SKIPPED, the same 22 lines on both: 18 no wave64 (16 in gpu::recomp::lower / lower_dxil, gpu_geometry_wave32_prefix_count_over_a_mask, gpu_wave32_program_in_wave64_hardware), 3 refused wave32 per-lane cases in f16_programs_on_the_gpu / f32_programs_on_the_gpu, and heap_window_out_of_memory_falls_back_to_the_switch_form (no heap windows)
  • The 1 failure is the same on both and not from this PR: test_title_runs_and_game_folder_is_untouched (e2e, presents 0), because these runs are in an isolated non-interactive session where CreateSwapChainForHwnd returns 0x887A0022.

Not tested

  • main after 1d027e5 (689f2db now; the commits since touch only gpu/dxil and gpu/recomp)
  • the warning has no test asserting it
  • kickoff_x / copy_memory_x end to end, the debug layer on this path
  • AMD, Intel; a retail title (no smoke run here)

Run and written with Claude Code (Claude Opus 5.5); counts recomputed from the logs by a second agent (Claude Opus 5.5); text reviewed with Claude Fable 5.2. The runs are real, on the hardware above.

**@⁠pvfreis** on GitHub · 2026-11-24 16:34 UTC · [original](https://github.com/xcl-dev/xcl/pull/1421#issuecomment-7137880197) · edited 2026-11-24 22:33 UTC Test report for 7124a95392e1a6b99db7b3fc5763d1269606c5f3 (this PR's head) merged onto main 1d027e5c76 (git auto-merged `list_x.rs`, no conflict). (Edited after a rerun. The first version covered 4c65020 onto b7aa9f3: 770 passed, 1 failed, 41 ignored; main 769/1/41, and noted the log line was missing; 7124a95 added it.) The new test passes on NVIDIA; no other test result changed. I opened #1408. Of its "Expected": a busy scratch moves to `released`, still charged to the budget, and a new one is made within it; the log line when the budget forces the fallback is now there. **Tested** - RTX 3060 12 GB (driver 617.14), Ryzen 9 5900XT, Windows 11 26H2 (10.0.26300), Rust 1.100.0 stable MSVC, debug - `cargo build --workspace --locked --offline`, then `cargo test --workspace --locked --offline --no-fail-fast -- --test-threads=4`: - main 1d027e5: 958 passed, 1 failed, 43 ignored - this PR merged onto 1d027e5: 959 passed, 1 failed, 43 ignored. The difference is `busy_copy_scratch_is_retired_when_budget_allows_a_replacement`, which passes; the other two copy-scratch tests pass too, and the log has the new warning (emitted once per process) for a request of 67108864 bytes - SKIPPED, the same 22 lines on both: 18 `no wave64` (16 in `gpu::recomp::lower` / `lower_dxil`, `gpu_geometry_wave32_prefix_count_over_a_mask`, `gpu_wave32_program_in_wave64_hardware`), 3 refused wave32 per-lane cases in `f16_programs_on_the_gpu` / `f32_programs_on_the_gpu`, and `heap_window_out_of_memory_falls_back_to_the_switch_form` (no heap windows) - The 1 failure is the same on both and not from this PR: `test_title_runs_and_game_folder_is_untouched` (e2e, `presents` 0), because these runs are in an isolated non-interactive session where `CreateSwapChainForHwnd` returns 0x887A0022. **Not tested** - main after 1d027e5 (689f2db now; the commits since touch only `gpu/dxil` and `gpu/recomp`) - the warning has no test asserting it - `kickoff_x` / `copy_memory_x` end to end, the debug layer on this path - AMD, Intel; a retail title (no smoke run here) Run and written with Claude Code (Claude Opus 5.5); counts recomputed from the logs by a second agent (Claude Opus 5.5); text reviewed with Claude Fable 5.2. The runs are real, on the hardware above.
Author
Owner

@⁠DavidM1911 on GitHub · 2026-11-26 05:13 UTC · original

Re-verification on RTX 3060 Ti (Windows 11), new head merged with current main:

  • cargo test -p xcl --lib: all passed, 0 failed, 27 ignored. The earlier merge conflict is resolved.

Thanks!

— Devin

**@⁠DavidM1911** on GitHub · 2026-11-26 05:13 UTC · [original](https://github.com/xcl-dev/xcl/pull/1421#issuecomment-7183286912) Re-verification on RTX 3060 Ti (Windows 11), new head merged with current `main`: - `cargo test -p xcl --lib`: all passed, 0 failed, 27 ignored. The earlier merge conflict is resolved. Thanks! — Devin
This pull request can be merged automatically.
This branch is out-of-date with the base branch
You are not authorized to merge this pull request.
View command line instructions

Checkout

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

Merge

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