gpu: add fence-timed targeted readback fixture #3951

Manually merged
github merged 1 commit from github-bot/gh-3949 into gh-pr/3949/base 2026-12-03 17:24:41 +00:00 AGit
Owner

@⁠lambirou on GitHub · 2026-12-03 16:48 UTC · original
lambirou:codex/memory-targeted-readback → main · +269 −0 · 3 files · 1 commits · merged 2026-12-03 17:20 UTC

Problem

The runtime has no demonstrated path for making a GPU-written range visible through
the title's original CPU address when the backing cannot alias those pages. A
readback added before a CPU-dependent case is measured would copy work for every
GPU-written buffer and leave the synchronization point unproven.

Change

Add a source-built D3D12 fixture for one 4 KiB range in a 256 KiB buffer. The GPU
writes the range through a copy, the fixture copies only that range to a READBACK
resource, waits for the queue fence, and compares the mapped bytes. A second full
buffer readback checks the other 252 KiB against their sentinel pattern. The
wrong-offset case reads 512 bytes later and must fail the comparison.

This is a transfer primitive and fence-boundary prototype. It does not wire a
writeback into title memory. Runtime integration remains conditional on a measured
CPU read that depends on a GPU-written range whose backing cannot alias title pages.

Refs #1914, #3678 and #3765.

Validation

Windows 11, MSVC 19.44.35228, dev preset, debug layer off:

cmake --build --preset dev --target startup_targeted_readback
ctest --preset dev --no-tests=error -R '^startup_targeted_readback_' --output-on-failure -j1

WARP and the physical adapter: 4/4 passed, 0 skipped. The positive case transferred
4,096 bytes and preserved all neighbour bytes. Both wrong-offset controls rejected
the copied range.

Limits

  • Synthetic D3D12 buffers only.
  • No queue-wrapper integration, title-memory writeback, UAV write tracking or CPU-read detection.
  • No console result.
**@⁠lambirou** on GitHub · 2026-12-03 16:48 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/3949) `lambirou:codex/memory-targeted-readback` → `main` · +269 −0 · 3 files · 1 commits · merged 2026-12-03 17:20 UTC ## Problem The runtime has no demonstrated path for making a GPU-written range visible through the title's original CPU address when the backing cannot alias those pages. A readback added before a CPU-dependent case is measured would copy work for every GPU-written buffer and leave the synchronization point unproven. ## Change Add a source-built D3D12 fixture for one 4 KiB range in a 256 KiB buffer. The GPU writes the range through a copy, the fixture copies only that range to a READBACK resource, waits for the queue fence, and compares the mapped bytes. A second full buffer readback checks the other 252 KiB against their sentinel pattern. The `wrong-offset` case reads 512 bytes later and must fail the comparison. This is a transfer primitive and fence-boundary prototype. It does not wire a writeback into title memory. Runtime integration remains conditional on a measured CPU read that depends on a GPU-written range whose backing cannot alias title pages. Refs #1914, #3678 and #3765. ## Validation Windows 11, MSVC 19.44.35228, `dev` preset, debug layer off: ```text cmake --build --preset dev --target startup_targeted_readback ctest --preset dev --no-tests=error -R '^startup_targeted_readback_' --output-on-failure -j1 ``` WARP and the physical adapter: 4/4 passed, 0 skipped. The positive case transferred 4,096 bytes and preserved all neighbour bytes. Both wrong-offset controls rejected the copied range. ## Limits - Synthetic D3D12 buffers only. - No queue-wrapper integration, title-memory writeback, UAV write tracking or CPU-read detection. - No console result.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-12-03 16:57:59 +00:00
github-bot changed target branch from main to gh-pr/3949/base 2026-12-03 17:24:06 +00:00
github manually merged commit 39874a8233 into gh-pr/3949/base 2026-12-03 17:24:41 +00:00
Author
Owner

@⁠R0Y00 on GitHub · 2026-12-03 17:18 UTC · original · approved these changes

Independently built startup_targeted_readback with MSVC Debug and ran ctest --test-dir out/build/review --no-tests=error -j 1 -V -R '^startup_targeted_readback_' on Windows 11 build 26300. All four cases passed, no skips, on WARP and RTX 4060 Laptop. Both adapters matched the 4,096-byte destination after the fence and preserved the surrounding bytes. Both wrong-offset controls rejected the copy. The fixture uses ordinary D3D12 buffers and tests the submission boundary without depending on the runtime wrapper. Required Windows CI passed.

**@⁠R0Y00** on GitHub · 2026-12-03 17:18 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/3949#pullrequestreview-6174789700) · **approved these changes** Independently built startup_targeted_readback with MSVC Debug and ran ctest --test-dir out/build/review --no-tests=error -j 1 -V -R '^startup_targeted_readback_' on Windows 11 build 26300. All four cases passed, no skips, on WARP and RTX 4060 Laptop. Both adapters matched the 4,096-byte destination after the fence and preserved the surrounding bytes. Both wrong-offset controls rejected the copy. The fixture uses ordinary D3D12 buffers and tests the submission boundary without depending on the runtime wrapper. Required Windows CI passed.
This discussion has been locked. Commenting is limited to contributors.
No description provided.