D3D12.X: read back the swap chain buffer for the frame dump and guard readback_copy #2713

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

@⁠itsSio on GitHub · 2026-11-26 08:05 UTC · original
itsSio:d3d12x/frame-dump-swapchain-readback → main · +178 −12 · 1 files · 1 commits · open

With XCL_FRAME_DUMP set and no composited present, the frame dump read back the title's own src with a texture copy recorded at present time. XCL does not know which state the title keeps src in, and readback_copy recorded the copy for any resource, buffers included. The dump now reads back the swap chain buffer XCL has just copied into (COPY_DEST -> COPY_SOURCE -> PRESENT), as the composited path already does from RENDER_TARGET, and readback_copy refuses what it cannot copy to a buffer: anything other than a single-sample 2D texture with a size and a footprint format, or a failed GetCopyableFootprints. Part of #499 (observation 2).

What is in it

  • D3D12.X: read back the swap chain buffer for the frame dump and guard readback_copy: crates/xcl/src/hle/d3d12x/present.rs (dump_backbuffer used by both present paths; readback_possible checked in readback_copy; a unit test of the checks and a GPU test on WARP that dumps a filled swap chain buffer and refuses a buffer)

Tested
Commit b25ae0cf3816b2538742645b755ea8cf967976fd, clean checkouts on each PC, debug builds for workspace tests and release builds for retail smoke runs.

  • PC 1: NVIDIA GeForce RTX 5080 (driver 32.0.16.1088), AMD Ryzen 7 9800X3D, 32 GB RAM, Windows 11 Pro build 26200, Rust 1.97.0 (stable-x86_64-pc-windows-msvc), DXC 1.9.2609.5.
    • cargo build --workspace: exit 0.
    • cargo test --workspace -- --test-threads=4: 1431 passed, 0 failed, 47 ignored.
    • 26 SKIPPED GPU tests: wave64 tests (no wave64 on this adapter), f16 / f16-conversion wave32 refusals (#1426), heap_window_out_of_memory_falls_back_to_the_switch_form (no heap windows), pso_measurement_compiles_an_exact_synthetic_record (driver cache, Developer Mode).
    • cargo test -p xcl --lib frame_dump_tests: 5 passed, 0 failed, 0 ignored. With the readback_copy check removed, the new test fails on the buffer assertion.
    • Retail 120 s XCL_FRAME_DUMP=1 + XCL_PRESS_A_AT=15,25,35,45,55 check (release, RTX 5080): both main 08db8020 (3258 frames, non-black from frame_2780 at ~105 s) and b25ae0cf (3306 frames, non-black from frame_2300 at ~89 s) capture genuine non-black BMPs (max=249, mean=36.6, 99.8% non-dark) with 0 crashes, 0 device removals, and 0 nvwgf2umx.dll faults.
  • PC 2: NVIDIA GeForce RTX 2080 SUPER (driver 32.0.16.1088), AMD Ryzen 5 5600X, 16 GB RAM, Windows 11 Pro build 26200, Rust 1.99.1 (stable-x86_64-pc-windows-msvc), Windows SDK 10.0.26100 DXC 1.8.2502.11.
    • cargo build --workspace: exit 0.
    • cargo test --workspace -- --test-threads=4: first run had 1 unrelated failure (vfs_hooks::tests::move_with_locked_overlay_source_preserves_destination). Rerun with --no-fail-fast: 1431 passed, 0 failed, 47 ignored; that test passed 10/10 standalone.
    • 27 SKIPPED: the same 26, plus uploads_start_from_each_subresources_state (no D3D12 debug layer).
    • cargo test -p xcl --lib frame_dump_tests: 5 passed, 0 failed, 0 ignored.
  • The present.rs GPU tests run on WARP.

Regression run

main (08db8020, RTX 5080, release, XCL_FRAME_DUMP=1):

xcl-smoke v1
commit: 08db8020d323bf478964fcc586152cce54959cfc
gpu: NVIDIA GeForce RTX 5080
title: retail-title
seconds: 60
exit: 0x0
frames shown: 1573 (PresentX 1573)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 9877 MB

PR (b25ae0cf, RTX 5080, release, XCL_FRAME_DUMP=1):

xcl-smoke v1
commit: b25ae0cf3816b2538742645b755ea8cf967976fd
gpu: NVIDIA GeForce RTX 5080
title: retail-title
seconds: 60
exit: 0x0
frames shown: 1588 (PresentX 1588)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 9890 MB

Not tested

  • Reproducing the original RTX 3080 Ti nvwgf2umx.dll crash on main (did not reproduce on RTX 5080 on main 08db8020).
  • AMD discrete GPUs (RDNA3/RDNA4), Intel Arc, Linux / Wine / vkd3d-proton.
  • Retail scripts/smoke.ps1 on the RTX 2080 SUPER.

AI use
Ran via Samaritan:

  • OpenCode (Claude Opus 5.5): wrote the submitted patch and its tests, ran the initial workspace checks, and drafted the description. OpenCode helpers on the same model ran independent workspace checks and recorded the paired retail smoke results.
  • Google Antigravity CLI (Gemini 4 Neon (High)): coordinated and reviewed verification, ran the local PR description check, and finalized the fork draft.
  • Google Antigravity CLI (Gemini 4 Hydrogen (High)): contributed frame-dump verification and wrote and reviewed an earlier, superseded implementation; that earlier commit is not included in this PR.
  • OpenCode (GPT-6.2 Sol): checked the attribution against the original execution records and prepared this corrected description
**@⁠itsSio** on GitHub · 2026-11-26 08:05 UTC · [original](https://github.com/xcl-dev/xcl/pull/2713) `itsSio:d3d12x/frame-dump-swapchain-readback` → `main` · +178 −12 · 1 files · 1 commits · open With `XCL_FRAME_DUMP` set and no composited present, the frame dump read back the title's own `src` with a texture copy recorded at present time. XCL does not know which state the title keeps `src` in, and `readback_copy` recorded the copy for any resource, buffers included. The dump now reads back the swap chain buffer XCL has just copied into (COPY_DEST -> COPY_SOURCE -> PRESENT), as the composited path already does from RENDER_TARGET, and `readback_copy` refuses what it cannot copy to a buffer: anything other than a single-sample 2D texture with a size and a footprint format, or a failed `GetCopyableFootprints`. Part of #499 (observation 2). **What is in it** - `D3D12.X: read back the swap chain buffer for the frame dump and guard readback_copy`: `crates/xcl/src/hle/d3d12x/present.rs` (`dump_backbuffer` used by both present paths; `readback_possible` checked in `readback_copy`; a unit test of the checks and a GPU test on WARP that dumps a filled swap chain buffer and refuses a buffer) **Tested** Commit `b25ae0cf3816b2538742645b755ea8cf967976fd`, clean checkouts on each PC, debug builds for workspace tests and release builds for retail smoke runs. - PC 1: NVIDIA GeForce RTX 5080 (driver `32.0.16.1088`), AMD Ryzen 7 9800X3D, 32 GB RAM, Windows 11 Pro build 26200, Rust 1.97.0 (`stable-x86_64-pc-windows-msvc`), DXC 1.9.2609.5. - `cargo build --workspace`: exit 0. - `cargo test --workspace -- --test-threads=4`: **1431 passed, 0 failed, 47 ignored**. - 26 `SKIPPED` GPU tests: wave64 tests (no wave64 on this adapter), f16 / f16-conversion wave32 refusals (`#1426`), `heap_window_out_of_memory_falls_back_to_the_switch_form` (no heap windows), `pso_measurement_compiles_an_exact_synthetic_record` (driver cache, Developer Mode). - `cargo test -p xcl --lib frame_dump_tests`: **5 passed, 0 failed, 0 ignored**. With the `readback_copy` check removed, the new test fails on the buffer assertion. - Retail 120 s `XCL_FRAME_DUMP=1` + `XCL_PRESS_A_AT=15,25,35,45,55` check (release, RTX 5080): both `main` `08db8020` (`3258` frames, non-black from `frame_2780` at ~105 s) and `b25ae0cf` (`3306` frames, non-black from `frame_2300` at ~89 s) capture genuine non-black BMPs (`max=249`, `mean=36.6`, `99.8%` non-dark) with `0` crashes, `0` device removals, and `0` `nvwgf2umx.dll` faults. - PC 2: NVIDIA GeForce RTX 2080 SUPER (driver `32.0.16.1088`), AMD Ryzen 5 5600X, 16 GB RAM, Windows 11 Pro build 26200, Rust 1.99.1 (`stable-x86_64-pc-windows-msvc`), Windows SDK 10.0.26100 DXC 1.8.2502.11. - `cargo build --workspace`: exit 0. - `cargo test --workspace -- --test-threads=4`: first run had 1 unrelated failure (`vfs_hooks::tests::move_with_locked_overlay_source_preserves_destination`). Rerun with `--no-fail-fast`: **1431 passed, 0 failed, 47 ignored**; that test passed 10/10 standalone. - 27 `SKIPPED`: the same 26, plus `uploads_start_from_each_subresources_state` (no D3D12 debug layer). - `cargo test -p xcl --lib frame_dump_tests`: **5 passed, 0 failed, 0 ignored**. - The `present.rs` GPU tests run on WARP. **Regression run** `main` (`08db8020`, RTX 5080, release, `XCL_FRAME_DUMP=1`): ``` xcl-smoke v1 commit: 08db8020d323bf478964fcc586152cce54959cfc gpu: NVIDIA GeForce RTX 5080 title: retail-title seconds: 60 exit: 0x0 frames shown: 1573 (PresentX 1573) presents per 2 s (last 3): 60 60 60 device removals: 0 crashes: 0 peak commit: 9877 MB ``` PR (`b25ae0cf`, RTX 5080, release, `XCL_FRAME_DUMP=1`): ``` xcl-smoke v1 commit: b25ae0cf3816b2538742645b755ea8cf967976fd gpu: NVIDIA GeForce RTX 5080 title: retail-title seconds: 60 exit: 0x0 frames shown: 1588 (PresentX 1588) presents per 2 s (last 3): 60 60 60 device removals: 0 crashes: 0 peak commit: 9890 MB ``` **Not tested** - Reproducing the original RTX 3080 Ti `nvwgf2umx.dll` crash on `main` (did not reproduce on RTX 5080 on `main` `08db8020`). - AMD discrete GPUs (RDNA3/RDNA4), Intel Arc, Linux / Wine / vkd3d-proton. - Retail `scripts/smoke.ps1` on the RTX 2080 SUPER. **AI use** Ran via Samaritan: - OpenCode (Claude Opus 5.5): wrote the submitted patch and its tests, ran the initial workspace checks, and drafted the description. OpenCode helpers on the same model ran independent workspace checks and recorded the paired retail smoke results. - Google Antigravity CLI (Gemini 4 Neon (High)): coordinated and reviewed verification, ran the local PR description check, and finalized the fork draft. - Google Antigravity CLI (Gemini 4 Hydrogen (High)): contributed frame-dump verification and wrote and reviewed an earlier, superseded implementation; that earlier commit is not included in this PR. - OpenCode (GPT-6.2 Sol): checked the attribution against the original execution records and prepared this corrected description
With XCL_FRAME_DUMP set and no composited present, the frame dump recorded
a texture copy from the title's own resource at present time. XCL does not
know which state the title keeps that resource in, and readback_copy recorded
the copy for any resource, a buffer included (#499, observation 2: an access
violation in the NVIDIA user-mode driver at ~250 presents, only with the dump
on).

The dump now reads back the swap chain buffer XCL has just copied into, as the
composited path already does, through dump_backbuffer, which moves the buffer
to COPY_SOURCE and leaves it in PRESENT. readback_copy refuses anything other
than a single-sample 2D texture with a size and a footprint format, and a
failed GetCopyableFootprints (readback_possible).

Tests: readback_possible's cases, and a WARP test that dumps a filled swap
chain buffer from COPY_DEST, reads the pixels back and refuses a buffer (it
fails without the guard: the old readback_copy returned a copy for it).

Assisted-by: OpenCode (Claude Opus 5.5)
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 08:09:07 +00:00
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/2713/head:github-bot/gh-2713'
git switch 'github-bot/gh-2713'

Merge

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