D3D12.X: the presenter's copy of the title's image moves it to COPY_SOURCE and back #1535

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

@⁠dhanush2412 on GitHub · 2026-11-24 17:22 UTC · original
dhanush2412:d3d12x-present-source-barrier → main · +15 −0 · 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,934 x INVALID_SUBRESOURCE_STATE on CopyResource (the source is in RENDER_TARGET, needs COPY_SOURCE), about one per presented frame, and 2,925 x on the title's next ClearRenderTargetView of the same image (the layer then tracks it as COPY_SOURCE). The presenter's copy (present.rs, present_now) put a barrier on the back buffer only. This moves the title's image to COPY_SOURCE for the copy (and the frame-dump readback) and back to RENDER_TARGET after it. Off by default (XCL_PRESENT_SRC_BARRIER=1): the state RENDER_TARGET is what the debug layer showed in all 2,934 cases, not something XCL tracks, so a title that presents a resource in another state gets a wrong barrier.

What is in it

  • crates/xcl/src/hle/d3d12x/present.rs: present_src_barrier() (the switch) and the two transitions around CopyResource in present_now.

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; two runs, none and the switch): CopyResource errors 2,934 -> 7, ClearRenderTargetView errors 2,925 -> 26, all INVALID_SUBRESOURCE_STATE 8,808 -> 2,203. 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), so it shows the default path is unchanged.

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: ca44a681264c7b71132eee9e96e99f896c735661
gpu: NVIDIA GeForce RTX 3060
title: 404998dc
seconds: 60
exit: 0x0
frames shown: 1404 (PresentX 1404)
presents per 2 s (last 3): 42 22 8
device removals: 0
crashes: 0
peak commit: 22396 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 title that presents a resource in a state other than RENDER_TARGET
  • the picture with the switch on was only checked by the frame dump (XCL_FRAME_DUMP), not compared pixel by pixel

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/1535) `dhanush2412:d3d12x-present-source-barrier` → `main` · +15 −0 · 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,934 x `INVALID_SUBRESOURCE_STATE` on `CopyResource` (the source is in `RENDER_TARGET`, needs `COPY_SOURCE`), about one per presented frame, and 2,925 x on the title's next `ClearRenderTargetView` of the same image (the layer then tracks it as `COPY_SOURCE`). The presenter's copy (`present.rs`, `present_now`) put a barrier on the back buffer only. This moves the title's image to `COPY_SOURCE` for the copy (and the frame-dump readback) and back to `RENDER_TARGET` after it. Off by default (`XCL_PRESENT_SRC_BARRIER=1`): the state `RENDER_TARGET` is what the debug layer showed in all 2,934 cases, not something XCL tracks, so a title that presents a resource in another state gets a wrong barrier. **What is in it** - `crates/xcl/src/hle/d3d12x/present.rs`: `present_src_barrier()` (the switch) and the two transitions around `CopyResource` in `present_now`. **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; two runs, none and the switch): `CopyResource` errors 2,934 -> 7, `ClearRenderTargetView` errors 2,925 -> 26, all `INVALID_SUBRESOURCE_STATE` 8,808 -> 2,203. 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), so it shows the default path is unchanged. **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: ca44a681264c7b71132eee9e96e99f896c735661 gpu: NVIDIA GeForce RTX 3060 title: 404998dc seconds: 60 exit: 0x0 frames shown: 1404 (PresentX 1404) presents per 2 s (last 3): 42 22 8 device removals: 0 crashes: 0 peak commit: 22396 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 title that presents a resource in a state other than `RENDER_TARGET` - the picture with the switch on was only checked by the frame dump (`XCL_FRAME_DUMP`), not compared pixel by pixel **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.
The title's image is a render target when it is presented. CopyResource read it in that state
(debug layer: 2,934 x INVALID_SUBRESOURCE_STATE, and the title's next clear of the image read as
invalid too, 2,925 x). With the switch both drop to 7 and 26.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 04:56:49 +00:00
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/1535#issuecomment-7140364659) **#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

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

RTX 5060 Laptop GPU test on Bazzite 44 (NVIDIA 615.78.08, Proton Experimental 11.0-20261112, vkd3d-proton 4522cc1a8b1347f1ab1b0f7b14a23ed9444d95d1+). I tested exact #1535 head ca44a681264c7b71132eee9e96e99f896c735661 on main 9e3831e1f570d3646e53ab753b19ec07eb8f1485 with the dedicated presenter queue and local storage/residency changes.

Two focused Windows MSVC GPU tests ran under Proton and passed with zero skips. The added test started with a known render target, cleared it green, copied it on the dedicated presenter queue using the source barriers and checked the green readback. It then cleared the source red on the title queue and checked that readback as well.

Matched Series X title runs used the same executable and initial data/cache seeds. With the flag unset, the trace recorded 2,539 presents and 76,286 storage requests with zero failures. With XCL_PRESENT_SRC_BARRIER=1, it recorded 2,595 presents and 78,692 requests with zero failures. Both reached loading artwork and stopped at the same title watchdog. Neither logged a pipeline-bind timeout, D3D12 device removal or NVIDIA Xid. The Windows D3D12 debug layer was unavailable under Proton, and the title source state at PresentX was unverified.

AI assistance from OpenAI Codex (GPT-6.2-Sol high) for the focused test, paired runs and report.

**@⁠Filip722** on GitHub · 2026-11-24 18:14 UTC · [original](https://github.com/xcl-dev/xcl/pull/1535#issuecomment-7140369963) RTX 5060 Laptop GPU test on Bazzite 44 (NVIDIA 615.78.08, Proton Experimental 11.0-20261112, vkd3d-proton `4522cc1a8b1347f1ab1b0f7b14a23ed9444d95d1+`). I tested exact #1535 head `ca44a681264c7b71132eee9e96e99f896c735661` on main `9e3831e1f570d3646e53ab753b19ec07eb8f1485` with the dedicated presenter queue and local storage/residency changes. Two focused Windows MSVC GPU tests ran under Proton and passed with zero skips. The added test started with a known render target, cleared it green, copied it on the dedicated presenter queue using the source barriers and checked the green readback. It then cleared the source red on the title queue and checked that readback as well. Matched Series X title runs used the same executable and initial data/cache seeds. With the flag unset, the trace recorded 2,539 presents and 76,286 storage requests with zero failures. With `XCL_PRESENT_SRC_BARRIER=1`, it recorded 2,595 presents and 78,692 requests with zero failures. Both reached loading artwork and stopped at the same title watchdog. Neither logged a pipeline-bind timeout, D3D12 device removal or NVIDIA Xid. The Windows D3D12 debug layer was unavailable under Proton, and the title source state at PresentX was unverified. AI assistance from OpenAI Codex (GPT-6.2-Sol high) for the focused test, paired runs and report.
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/1535#issuecomment-7141594818) 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 has changes conflicting with the target branch.
  • crates/xcl/src/hle/d3d12x/present.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/1535/head:github-bot/gh-1535'
git switch 'github-bot/gh-1535'

Merge

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