D3D12.X: sparse upload lists move the windows they copied into back to COMMON #1536

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

@⁠dhanush2412 on GitHub · 2026-11-24 17:22 UTC · original
dhanush2412:d3d12x-upload-barrier → main · +37 −2 · 1 files · 1 commits · draft

Part of #1452. With XCL_D3D12_DEBUG=1 a 130-170 s run of the retail game (retail title 1.0.2.1, Series X) reports 2,569 x INVALID_SUBRESOURCE_STATE on IASetIndexBuffer (the buffer is in COPY_DEST, "promoted from COMMON", needs INDEX_BUFFER) and a few dozen on IASetVertexBuffers. The sparse upload lists (sparse.rs, upload_dirty and the zero fill) copy into the window buffers; the copy promotes a window from COMMON to COPY_DEST, and a write state does not decay at the end of ExecuteCommandLists, so the title's own lists find it there. This records which windows an upload list copied into and, before it is closed, moves them from COPY_DEST back to COMMON. Off by default (XCL_UPLOAD_BARRIER=1).

What is in it

  • crates/xcl/src/hle/d3d12x/sparse.rs: UploadSlot.touched (a bit per window), upload_barrier() (the switch), the barrier in submit_slot, and touched set at the two CopyBufferRegion sites.

Tested

  • RTX 3060 12 GB (driver 610.88), i5-13400F, 16 GB RAM, Windows 11 10.0.26300, rustc 1.100.0, release
  • cargo test --release --workspace -- --test-threads=4: 776 passed, 0 failed, 41 ignored (SKIPPED GPU tests on this adapter: gpu_geometry_wave32_prefix_count_over_a_mask and gpu_wave32_program_in_wave64_hardware (no wave64), heap_window_out_of_memory_falls_back_to_the_switch_form (no heap windows))
  • debug layer, same 130-170 s retail run (an earlier tree, the same code; with XCL_PRESENT_SRC_BARRIER=1 as well, see the sibling PR): IASetIndexBuffer errors 2,569 -> 892 (the rest come from a copy path this does not cover), all INVALID_SUBRESOURCE_STATE 8,808 -> 1,127. The device is still removed at the end of that run (#1452), so this does not fix that.
  • game checked: retail title 1.0.2.1 (Series X), 60 s, the switch is off in the regression run below (the default).

Regression run

main:

xcl-smoke v1
commit: 9e3831e1f570d3646e53ab753b19ec07eb8f1485
gpu: NVIDIA GeForce RTX 3060
title: 404998dc
seconds: 60
exit: 0x0
frames shown: 1408 (PresentX 1408)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 19067 MB

PR:

xcl-smoke v1
commit: a780e1d11665b8674dff79bc8b7cc732a95d6503
gpu: NVIDIA GeForce RTX 3060
title: 404998dc
seconds: 60
exit: 0x0
frames shown: 1582 (PresentX 1582)
presents per 2 s (last 3): 59 58 59
device removals: 0
crashes: 0
peak commit: 17599 MB

Not tested

  • another GPU or driver than the RTX 3060 / 610.88; AMD; any title but the retail title
  • the switch on in a regression run (only in the debug-layer runs above)
  • that a window is always in COPY_DEST when the barrier is recorded: it is after a copy into it in the same list, which is the only case recorded

AI use

  • Claude Code with Claude Sonnet 5.5: found the errors in a debug-layer capture, wrote the change and the commit message, ran the tests and the runs below on the author's machine. The runs and numbers are real runs; the code was written by the tool.
**@⁠dhanush2412** on GitHub · 2026-11-24 17:22 UTC · [original](https://github.com/xcl-dev/xcl/pull/1536) `dhanush2412:d3d12x-upload-barrier` → `main` · +37 −2 · 1 files · 1 commits · draft Part of #1452. With `XCL_D3D12_DEBUG=1` a 130-170 s run of the retail game (retail title 1.0.2.1, Series X) reports 2,569 x `INVALID_SUBRESOURCE_STATE` on `IASetIndexBuffer` (the buffer is in `COPY_DEST`, "promoted from COMMON", needs `INDEX_BUFFER`) and a few dozen on `IASetVertexBuffers`. The sparse upload lists (`sparse.rs`, `upload_dirty` and the zero fill) copy into the window buffers; the copy promotes a window from COMMON to COPY_DEST, and a write state does not decay at the end of `ExecuteCommandLists`, so the title's own lists find it there. This records which windows an upload list copied into and, before it is closed, moves them from COPY_DEST back to COMMON. Off by default (`XCL_UPLOAD_BARRIER=1`). **What is in it** - `crates/xcl/src/hle/d3d12x/sparse.rs`: `UploadSlot.touched` (a bit per window), `upload_barrier()` (the switch), the barrier in `submit_slot`, and `touched` set at the two `CopyBufferRegion` sites. **Tested** - RTX 3060 12 GB (driver 610.88), i5-13400F, 16 GB RAM, Windows 11 10.0.26300, rustc 1.100.0, release - `cargo test --release --workspace -- --test-threads=4`: 776 passed, 0 failed, 41 ignored (SKIPPED GPU tests on this adapter: `gpu_geometry_wave32_prefix_count_over_a_mask` and `gpu_wave32_program_in_wave64_hardware` (no wave64), `heap_window_out_of_memory_falls_back_to_the_switch_form` (no heap windows)) - debug layer, same 130-170 s retail run (an earlier tree, the same code; with `XCL_PRESENT_SRC_BARRIER=1` as well, see the sibling PR): `IASetIndexBuffer` errors 2,569 -> 892 (the rest come from a copy path this does not cover), all `INVALID_SUBRESOURCE_STATE` 8,808 -> 1,127. The device is still removed at the end of that run (#1452), so this does not fix that. - game checked: retail title 1.0.2.1 (Series X), 60 s, the switch is off in the regression run below (the default). **Regression run** main: ``` xcl-smoke v1 commit: 9e3831e1f570d3646e53ab753b19ec07eb8f1485 gpu: NVIDIA GeForce RTX 3060 title: 404998dc seconds: 60 exit: 0x0 frames shown: 1408 (PresentX 1408) presents per 2 s (last 3): 60 60 60 device removals: 0 crashes: 0 peak commit: 19067 MB ``` PR: ``` xcl-smoke v1 commit: a780e1d11665b8674dff79bc8b7cc732a95d6503 gpu: NVIDIA GeForce RTX 3060 title: 404998dc seconds: 60 exit: 0x0 frames shown: 1582 (PresentX 1582) presents per 2 s (last 3): 59 58 59 device removals: 0 crashes: 0 peak commit: 17599 MB ``` **Not tested** - another GPU or driver than the RTX 3060 / 610.88; AMD; any title but the retail title - the switch on in a regression run (only in the debug-layer runs above) - that a window is always in COPY_DEST when the barrier is recorded: it is after a copy into it in the same list, which is the only case recorded **AI use** - Claude Code with Claude Sonnet 5.5: found the errors in a debug-layer capture, wrote the change and the commit message, ran the tests and the runs below on the author's machine. The runs and numbers are real runs; the code was written by the tool.
A copy promotes a window buffer from COMMON to COPY_DEST and a write state does not decay at the
end of ExecuteCommandLists. The title's lists then used it as an index or vertex buffer in
COPY_DEST (debug layer: 2,569 x INVALID_SUBRESOURCE_STATE on IASetIndexBuffer). With the switch
the count drops to about 890.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 04:56:50 +00:00
Author
Owner

@⁠crosettiremi on GitHub · 2026-11-24 17:50 UTC · original

Windows RX 7900 XT, Series X retail profile. I applied a780e1d by itself to a downstream XCL build with the sparse-release, streaming and partial-readback fixes. Release build. XCL_UPLOAD_BARRIER=1, DRED on, 28 GiB whole-job limit. The present-source barrier was absent.

The game passed the Player1 picker after a second scripted A, displayed loading artwork and streamed assets. Last positive present interval 299.155 s. Device removal at 302.892 s (0x887a0006), DRED page fault at GPU VA 0xd79c28000 with no matching existing or recently freed allocation. Peak sampled process commit 28,433 MB. The final capture was dark. The previous build without this patch ended in a guest watchdog after 258 s. Input timing differed substantially, so elapsed times do not establish a performance improvement.

This tests the opt-in path on AMD. The D3D12 debug layer was off, so this run cannot compare your index/vertex resource-state error counts.

**@⁠crosettiremi** on GitHub · 2026-11-24 17:50 UTC · [original](https://github.com/xcl-dev/xcl/pull/1536#issuecomment-7139772520) Windows RX 7900 XT, Series X retail profile. I applied a780e1d by itself to a downstream XCL build with the sparse-release, streaming and partial-readback fixes. Release build. XCL_UPLOAD_BARRIER=1, DRED on, 28 GiB whole-job limit. The present-source barrier was absent. The game passed the Player1 picker after a second scripted A, displayed loading artwork and streamed assets. Last positive present interval 299.155 s. Device removal at 302.892 s (0x887a0006), DRED page fault at GPU VA 0xd79c28000 with no matching existing or recently freed allocation. Peak sampled process commit 28,433 MB. The final capture was dark. The previous build without this patch ended in a guest watchdog after 258 s. Input timing differed substantially, so elapsed times do not establish a performance improvement. This tests the opt-in path on AMD. The D3D12 debug layer was off, so this run cannot compare your index/vertex resource-state error counts.
Author
Owner

@⁠srcamarda on GitHub · 2026-11-24 18:14 UTC · original

#1535 and #1536 on AMD RDNA3 (RX 7800 XT) with the debug layer: #1535 removes the presenter's errors here too (~4 500 → 0); #1536's case does not come up on this card in 150 s; no fps drop in either setting

Both PRs were merged together onto main 9e3831e locally (clean merges, not pushed; local merge commit 944fc18). Each switch was then turned on alone and together.

Setup

  • AMD Radeon RX 7800 XT 16 GB (RDNA3, native wave64), driver 32.0.32029.2010; Ryzen 5 5600G, 32 GB; Windows 11 Pro 26300 with Graphics Tools; rustc 1.100.0; release for the title, debug for the tests.
  • Retail title 1.0.2.1, Series X, saved profile; XCL_NETWORK=0 XCL_ACTIVITY=1 XCL_RUN_SECONDS=150, Enter (= A) at 30 / 40 / 50 s (title screens into the start of loading).

Debug layer (XCL_D3D12_DEBUG=1). XCL logs only 8 messages per id, so for these five runs both builds carried the same local diagnostic, not part of either PR: every debug-layer message counted by id, call and actual state, printed at the end of the run. Totals over 150 s:

main merged, switches off XCL_PRESENT_SRC_BARRIER=1 XCL_UPLOAD_BARRIER=1 both
538 CopyResource, source in RENDER_TARGET 2 237 2 311 0 2 176 0
538 ClearRenderTargetView, in COPY_SOURCE 2 232 2 306 0 2 171 0
538 CopyTextureRegion, source in NON_PIXEL|PIXEL_SHADER_RESOURCE (0xC0) 276 321 240 195 213
538 IASetIndexBuffer / IASetVertexBuffers 0 0 0 0 0
other 538 (Draw / Clear* / CopyResource in other states) 25 25 22 23 22
all messages, all ids 11 285 11 712 7 007 11 166 7 158
frames shown 2 237 2 311 2 199 2 176 1 962

No device removal or crash in any of the five.

  • #1535: the presenter's CopyResource and the title's next ClearRenderTargetView both go to 0 on this card as on the RTX 3060.
  • #1536: this title does not hit the IASetIndexBuffer in COPY_DEST case on this card in these 150 s, not even on main, so these runs show neither the fix nor a regression. Your 130–170 s runs reach further into the world load than mine.
  • Left over, in neither PR: CopyTextureRegion with its source in a shader-resource state (0xC0), about 200–320 per run. The ids outside 538 are the same in every column: 745 (simultaneous-access / buffer still referenced on ExecuteCommandLists / UpdateTileMappings), 677, 679, 680, 1047, 1422.

Smoke runs, no debug layer (scripts/smoke.ps1 -Seconds 60, interleaved, two rounds):

frames shown presents per 2 s (last 3) peak commit
main 9e3831e 1 039 · 1 080 60 60 60 · 60 60 60 16 792 · 17 743 MB
merged, switches off 1 057 · 1 084 60 60 60 · 60 60 60 16 604 · 16 751 MB
merged, both switches on 1 090 · 1 107 60 60 60 · 60 60 60 16 778 · 16 714 MB

No device removal or crash. The drop in your PR smoke block (presents 42 22 8, peak commit +3.3 GB, with the switch off) does not reproduce here.

Tests: cargo test --workspace --no-fail-fast -- --test-threads=4 on the merged tree: 776 passed, 0 failed, 41 ignored, with the switches unset and with both set to 1. SKIPPED: heap_window_out_of_memory_falls_back_to_the_switch_form (no heap windows), in both.

Not tested

  • Each PR on its own base, or alone in its own build (one build carried both, each switch tested alone at run time).
  • The world load past 150 s, where #1536's case and the device removal of #1452 come.
  • One run per configuration under the debug layer.

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

**@⁠srcamarda** on GitHub · 2026-11-24 18:14 UTC · [original](https://github.com/xcl-dev/xcl/pull/1536#issuecomment-7140365302) **#1535 and #1536 on AMD RDNA3 (RX 7800 XT) with the debug layer: #1535 removes the presenter's errors here too (~4 500 → 0); #1536's case does not come up on this card in 150 s; no fps drop in either setting** Both PRs were merged together onto `main` `9e3831e` locally (clean merges, not pushed; local merge commit `944fc18`). Each switch was then turned on alone and together. **Setup** - AMD Radeon RX 7800 XT 16 GB (RDNA3, native wave64), driver 32.0.32029.2010; Ryzen 5 5600G, 32 GB; Windows 11 Pro 26300 with Graphics Tools; rustc 1.100.0; release for the title, debug for the tests. - Retail title 1.0.2.1, Series X, saved profile; `XCL_NETWORK=0 XCL_ACTIVITY=1 XCL_RUN_SECONDS=150`, Enter (= A) at 30 / 40 / 50 s (title screens into the start of loading). **Debug layer** (`XCL_D3D12_DEBUG=1`). XCL logs only 8 messages per id, so for these five runs both builds carried the same local diagnostic, not part of either PR: every debug-layer message counted by id, call and actual state, printed at the end of the run. Totals over 150 s: | | `main` | merged, switches off | `XCL_PRESENT_SRC_BARRIER=1` | `XCL_UPLOAD_BARRIER=1` | both | |---|---|---|---|---|---| | 538 `CopyResource`, source in `RENDER_TARGET` | 2 237 | 2 311 | **0** | 2 176 | **0** | | 538 `ClearRenderTargetView`, in `COPY_SOURCE` | 2 232 | 2 306 | **0** | 2 171 | **0** | | 538 `CopyTextureRegion`, source in `NON_PIXEL\|PIXEL_SHADER_RESOURCE` (0xC0) | 276 | 321 | 240 | 195 | 213 | | 538 `IASetIndexBuffer` / `IASetVertexBuffers` | 0 | 0 | 0 | 0 | 0 | | other 538 (Draw / Clear* / CopyResource in other states) | 25 | 25 | 22 | 23 | 22 | | all messages, all ids | 11 285 | 11 712 | 7 007 | 11 166 | 7 158 | | frames shown | 2 237 | 2 311 | 2 199 | 2 176 | 1 962 | No device removal or crash in any of the five. - **#1535:** the presenter's `CopyResource` and the title's next `ClearRenderTargetView` both go to 0 on this card as on the RTX 3060. - **#1536:** this title does not hit the `IASetIndexBuffer` in `COPY_DEST` case on this card in these 150 s, not even on `main`, so these runs show neither the fix nor a regression. Your 130–170 s runs reach further into the world load than mine. - **Left over, in neither PR:** `CopyTextureRegion` with its source in a shader-resource state (0xC0), about 200–320 per run. The ids outside 538 are the same in every column: 745 (simultaneous-access / buffer still referenced on `ExecuteCommandLists` / `UpdateTileMappings`), 677, 679, 680, 1047, 1422. **Smoke runs, no debug layer** (`scripts/smoke.ps1 -Seconds 60`, interleaved, two rounds): | | frames shown | presents per 2 s (last 3) | peak commit | |---|---|---|---| | `main` `9e3831e` | 1 039 · 1 080 | 60 60 60 · 60 60 60 | 16 792 · 17 743 MB | | merged, switches off | 1 057 · 1 084 | 60 60 60 · 60 60 60 | 16 604 · 16 751 MB | | merged, both switches on | 1 090 · 1 107 | 60 60 60 · 60 60 60 | 16 778 · 16 714 MB | No device removal or crash. The drop in your PR smoke block (presents 42 22 8, peak commit +3.3 GB, with the switch off) does not reproduce here. **Tests:** `cargo test --workspace --no-fail-fast -- --test-threads=4` on the merged tree: 776 passed, 0 failed, 41 ignored, with the switches unset and with both set to 1. `SKIPPED`: `heap_window_out_of_memory_falls_back_to_the_switch_form` (no heap windows), in both. **Not tested** - Each PR on its own base, or alone in its own build (one build carried both, each switch tested alone at run time). - The world load past 150 s, where #1536's case and the device removal of #1452 come. - One run per configuration under the debug layer. _Claude Code (Claude Opus 5.5), from runs on the hardware above._
Author
Owner

@⁠DavidM1911 on GitHub · 2026-11-24 19:05 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 19:05 UTC · [original](https://github.com/xcl-dev/xcl/pull/1536#issuecomment-7141595446) Verification on RTX 3060 Ti (Windows 11), branch merged with current `main`: - `cargo test -p xcl --lib`: all passed, 0 failed, ~21 ignored. Thanks!
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/1536/head:github-bot/gh-1536'
git switch 'github-bot/gh-1536'

Merge

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