runtime: trace writes to presentation textures by color #2231

Merged
R0Y00 merged 2 commits from upstream-pr/2239 into main 2026-11-25 07:43:29 +00:00
R0Y00 commented 2026-11-25 07:04:25 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-11-25T07:04:25Z.


Refs #874.

Add an opt-in trace that compares an RGBA8 texel before and after graphics writes to the title-selected presentation resources. Records include the queue, ordered operation, pipeline key, and current color and depth attachments. A submission fence protects readback. A manual frame window and an automatic exact-RGB trigger both use the same bounded capture.

For an automatic capture, set X2W_RED_PRODUCER_AUTO=3700,12, X2W_RED_PRODUCER_RGB=255,0,255, and X2W_PRESENT_SIGNATURE_EVERY=1. The automatic trigger waits until the first eligible color transition. Logs retain up to 64 earlier recording identities to help correlate the delayed sample.

Verification

Release on Windows build 26200, MSVC 19.51.36244.0. Ran the source-built control on WARP (Microsoft Basic Render Driver) and NVIDIA GeForce RTX 4060 Laptop GPU, driver 616.56. The fixture enabled the D3D12 debug layer. All five selected CTests passed.

cmake --build <release-build> --target startup_present_producer startup_present_signature startup_list_resubmit
ctest --test-dir <release-build> --no-tests=error -R '^(startup_present_producer_(warp|hardware)|startup_present_signature_warp|startup_list_resubmit_(warp|hardware))$' --output-on-failure

The synthetic test reverses known color clears and resubmits the closed recording. Automatic controls check both red and magenta, reject an earlier exact match, a later near match, and an out-of-range RGB value, and compare the paired texels to the same surface at present.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:6599143991 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2239). Originally posted by [R0Y00](https://github.com/R0Y00) on 2026-11-25T07:04:25Z. --- Refs #874. Add an opt-in trace that compares an RGBA8 texel before and after graphics writes to the title-selected presentation resources. Records include the queue, ordered operation, pipeline key, and current color and depth attachments. A submission fence protects readback. A manual frame window and an automatic exact-RGB trigger both use the same bounded capture. For an automatic capture, set `X2W_RED_PRODUCER_AUTO=3700,12`, `X2W_RED_PRODUCER_RGB=255,0,255`, and `X2W_PRESENT_SIGNATURE_EVERY=1`. The automatic trigger waits until the first eligible color transition. Logs retain up to 64 earlier recording identities to help correlate the delayed sample. ### Verification Release on Windows build 26200, MSVC 19.51.36244.0. Ran the source-built control on WARP (Microsoft Basic Render Driver) and NVIDIA GeForce RTX 4060 Laptop GPU, driver 616.56. The fixture enabled the D3D12 debug layer. All five selected CTests passed. ```powershell cmake --build <release-build> --target startup_present_producer startup_present_signature startup_list_resubmit ctest --test-dir <release-build> --no-tests=error -R '^(startup_present_producer_(warp|hardware)|startup_present_signature_warp|startup_list_resubmit_(warp|hardware))$' --output-on-failure ``` The synthetic test reverses known color clears and resubmits the closed recording. Automatic controls check both red and magenta, reject an earlier exact match, a later near match, and an out-of-range RGB value, and compare the paired texels to the same surface at present.
tedin7 commented 2026-11-25 07:10:15 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-25T07:10:15Z.

Review: COMMENTED


Review of head 2e095a4e7da6c5a2cc2e1b20a457861c1cb0a63c.

Scope read: git diff --stat origin/main...HEAD (8 files, +616/-8), then targeted reads of d3d12_draw.inl, the d3d12_xs_device.cpp hooks (draw, indirect, clear, OMSetRenderTargets, queue execute, present) and present_signature_sampler.h.

Commands executed locally (Linux):

  • python3 tests/docs_links_check.py: self-test passed, 18 Markdown files, 418 links OK.
  • python3 tests/bidi_controls_check.py: 1522 files, no bidirectional controls.
  • git diff --check origin/main...HEAD: clean.
  • git merge-tree --write-tree origin/main HEAD: one conflict, docs/experiments.md.
  • gh pr checks: Linux Python checks, gfx1013 fixtures and Windows build/test pass; /O2 job skipped.

P2 - merge conflict. The PR reports CONFLICTING. The only conflict is docs/experiments.md (both sides appended sections). Rebase on origin/main and keep both sections; re-run the docs link check after.

P2 - the new C++ and the CTest are not exercised on Linux. startup_present_producer* is Windows/D3D12 only, so I could not run it or mutate the new logic here (for example flipping the exact-RGB compare in matches() or the fence guard before readback). The PR body already reports 5 CTests on WARP and a hardware GPU; please confirm they were re-run after the rebase, since the conflict may touch neighbouring code. The check script tests/startup_present_producer_check.py needs the backend and exe arguments, so it cannot run standalone.

Observations (no action required):

  • list_targets copies targets[8] (zero-initialised at declaration) into pass.trace_targets only when tracing is on, after the early return for no targets. A stale entry could only matter if target_count were stale; target_count is reset at entry, so draws read at most the current count. OK.
  • Hooks are no-ops unless the opt-in env vars are set (may_record() / enabled() gate), so default behaviour of draw, clear, indirect and execute paths is unchanged. queue_execute now routes through a lambda; both the readback and plain branches still call ExecuteCommandLists once.
  • discard_red_producer is called from reset and from the failed-close path, which matches how draw dumps are discarded.
  • Nit: Sampler now takes a third positional bool (capture_center); a named option would read clearer at the call site in present_signature.

No P1 found. Title is neutral and the body keeps the clean-room framing.

AI-assisted; commands listed were executed locally.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6053278701 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2239#pullrequestreview-6053278701). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-25T07:10:15Z. **Review:** COMMENTED --- Review of head `2e095a4e7da6c5a2cc2e1b20a457861c1cb0a63c`. **Scope read:** `git diff --stat origin/main...HEAD` (8 files, +616/-8), then targeted reads of `d3d12_draw.inl`, the `d3d12_xs_device.cpp` hooks (draw, indirect, clear, OMSetRenderTargets, queue execute, present) and `present_signature_sampler.h`. **Commands executed locally (Linux):** - `python3 tests/docs_links_check.py`: self-test passed, 18 Markdown files, 418 links OK. - `python3 tests/bidi_controls_check.py`: 1522 files, no bidirectional controls. - `git diff --check origin/main...HEAD`: clean. - `git merge-tree --write-tree origin/main HEAD`: one conflict, `docs/experiments.md`. - `gh pr checks`: Linux Python checks, gfx1013 fixtures and Windows build/test pass; /O2 job skipped. **P2 - merge conflict.** The PR reports CONFLICTING. The only conflict is `docs/experiments.md` (both sides appended sections). Rebase on `origin/main` and keep both sections; re-run the docs link check after. **P2 - the new C++ and the CTest are not exercised on Linux.** `startup_present_producer*` is Windows/D3D12 only, so I could not run it or mutate the new logic here (for example flipping the exact-RGB compare in `matches()` or the fence guard before readback). The PR body already reports 5 CTests on WARP and a hardware GPU; please confirm they were re-run after the rebase, since the conflict may touch neighbouring code. The check script `tests/startup_present_producer_check.py` needs the backend and exe arguments, so it cannot run standalone. **Observations (no action required):** - `list_targets` copies `targets[8]` (zero-initialised at declaration) into `pass.trace_targets` only when tracing is on, after the early return for no targets. A stale entry could only matter if `target_count` were stale; `target_count` is reset at entry, so draws read at most the current count. OK. - Hooks are no-ops unless the opt-in env vars are set (`may_record()` / `enabled()` gate), so default behaviour of draw, clear, indirect and execute paths is unchanged. `queue_execute` now routes through a lambda; both the readback and plain branches still call `ExecuteCommandLists` once. - `discard_red_producer` is called from reset and from the failed-close path, which matches how draw dumps are discarded. - Nit: `Sampler` now takes a third positional bool (`capture_center`); a named option would read clearer at the call site in `present_signature`. No P1 found. Title is neutral and the body keeps the clean-room framing. AI-assisted; commands listed were executed locally.
tedin7 commented 2026-11-25 07:38:44 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-25T07:38:44Z.

Review: COMMENTED


Re-review of head 91bc515d26398354e5d90bf4a6385ce4833c9bf2 (previous review was on 2e095a4e).

Previous P2 findings

  • Merge conflict in docs/experiments.md: RESOLVED. git merge-tree --write-tree origin/main HEAD now yields a clean tree, gh pr view reports MERGEABLE, no conflict markers remain in docs/experiments.md or src/startup_stubs, and the new section sits next to the sections from main.
  • C++/CTest not exercised on Linux: PARTLY RESOLVED. This is still Windows/D3D12 only, so I could not run it or mutate the new logic here. The merge brought the indirect-draw hook in d3d12_xs_device.cpp:2366-2369 next to the red-producer hooks (draw, clear, execute, present) without a visible clash, and the Windows build and test CI job passes on this head. The PR body's WARP and hardware results (5 CTests) were taken before the merge. Please confirm the five selected CTests were re-run on this merged head, or say CI covers them.

Commands executed locally (Linux)

  • git merge-tree --write-tree origin/main HEAD: clean tree.
  • python3 tests/docs_links_check.py: self-test passed, 18 Markdown files, 419 links OK.
  • python3 tests/bidi_controls_check.py: 1526 files, no bidirectional controls.
  • git diff --check origin/main...HEAD: clean.
  • gh pr checks 2239: Linux Python checks, gfx1013 fixtures and Windows build/test pass; /O2 job skipped.

Findings

  • P1: none.
  • P2: the post-merge Windows re-run evidence (see above) is still missing from the PR body.
  • Nit (unchanged): Sampler(every, always, capture_center) takes a third positional bool; a named option would read clearer at d3d12_xs_device.cpp:3879.

Title is neutral and the clean-room framing is kept.

AI-assisted; commands listed were executed locally.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6053573706 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2239#pullrequestreview-6053573706). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-25T07:38:44Z. **Review:** COMMENTED --- Re-review of head `91bc515d26398354e5d90bf4a6385ce4833c9bf2` (previous review was on `2e095a4e`). **Previous P2 findings** - Merge conflict in `docs/experiments.md`: RESOLVED. `git merge-tree --write-tree origin/main HEAD` now yields a clean tree, `gh pr view` reports MERGEABLE, no conflict markers remain in `docs/experiments.md` or `src/startup_stubs`, and the new section sits next to the sections from main. - C++/CTest not exercised on Linux: PARTLY RESOLVED. This is still Windows/D3D12 only, so I could not run it or mutate the new logic here. The merge brought the indirect-draw hook in `d3d12_xs_device.cpp:2366-2369` next to the red-producer hooks (draw, clear, execute, present) without a visible clash, and the `Windows build and test` CI job passes on this head. The PR body's WARP and hardware results (5 CTests) were taken before the merge. Please confirm the five selected CTests were re-run on this merged head, or say CI covers them. **Commands executed locally (Linux)** - `git merge-tree --write-tree origin/main HEAD`: clean tree. - `python3 tests/docs_links_check.py`: self-test passed, 18 Markdown files, 419 links OK. - `python3 tests/bidi_controls_check.py`: 1526 files, no bidirectional controls. - `git diff --check origin/main...HEAD`: clean. - `gh pr checks 2239`: Linux Python checks, gfx1013 fixtures and Windows build/test pass; /O2 job skipped. **Findings** - P1: none. - P2: the post-merge Windows re-run evidence (see above) is still missing from the PR body. - Nit (unchanged): `Sampler(every, always, capture_center)` takes a third positional bool; a named option would read clearer at `d3d12_xs_device.cpp:3879`. Title is neutral and the clean-room framing is kept. AI-assisted; commands listed were executed locally.
upstream-sync closed this pull request 2026-11-25 08:04:55 +00:00
SuperCraft3M commented 2026-11-25 22:02:16 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by SuperCraft3M on 2026-11-25T21:05:19Z.


Follow-up using the presentation color trace on Windows 11 26300.9711, RTX 4070, driver 32.0.16.2114, Release build.

On the baseline with a packed pixel-position experiment already enabled, the trace triggered on RGB (255, 0, 0). The captured full-surface mean was also (255, 0, 0), and the sampled presentation pixel was already red before the subsequent direct graphics writes. The descriptor diagnostics found a sampled texture slot backed by a zero-padded index word where the translated draw expected an SRV token.

I tried an opt-in resolver that follows a bounded chain of zero-padded indices within the graphics list's bound guest view heap. It accepts a terminal registered SRV and leaves the normal resource and view-dimension checks in place. Source-built C++ checks passed for direct and chained indices and for rejection of empty, out-of-range, cyclic, non-SRV, non-index and unreadable entries.

A later local run with this resolver and an unrelated XMem fix reached the stage where the solid-red output had been visible. The observer reported that the solid red was gone, and the automatic RGB trigger did not fire through that stage. The bounded resolver log confirms successful view resolution in this run. A descriptor-only A/B comparison, per-pass input readback, and a source-built D3D12 integration fixture remain open.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7174595215 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2239#issuecomment-7174595215). Originally posted by [SuperCraft3M](https://github.com/SuperCraft3M) on 2026-11-25T21:05:19Z. --- Follow-up using the presentation color trace on Windows 11 26300.9711, RTX 4070, driver 32.0.16.2114, Release build. On the baseline with a packed pixel-position experiment already enabled, the trace triggered on RGB (255, 0, 0). The captured full-surface mean was also (255, 0, 0), and the sampled presentation pixel was already red before the subsequent direct graphics writes. The descriptor diagnostics found a sampled texture slot backed by a zero-padded index word where the translated draw expected an SRV token. I tried an opt-in resolver that follows a bounded chain of zero-padded indices within the graphics list's bound guest view heap. It accepts a terminal registered SRV and leaves the normal resource and view-dimension checks in place. Source-built C++ checks passed for direct and chained indices and for rejection of empty, out-of-range, cyclic, non-SRV, non-index and unreadable entries. A later local run with this resolver and an unrelated XMem fix reached the stage where the solid-red output had been visible. The observer reported that the solid red was gone, and the automatic RGB trigger did not fire through that stage. The bounded resolver log confirms successful view resolution in this run. A descriptor-only A/B comparison, per-pass input readback, and a source-built D3D12 integration fixture remain open.
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
R0Y00/Xbox2Windows!2231
No description provided.