'Runtime: add present-path diagnostic logging' #3368

Manually merged
github merged 7 commits from github-bot/gh-3366 into main 2026-11-29 17:21:38 +00:00 AGit
Owner

@⁠KelboLive on GitHub · 2026-11-28 14:22 UTC · original
KelboLive:runtime/present-path-diagnostic-logging → main · +147 −6 · 4 files · 7 commits · merged 2026-11-29 17:18 UTC

Runtime: add present-path diagnostic logging

When X2W_D3D12_RENDER=1 is set but no image appears on screen (black screen with audio), it is hard to tell whether the failure is in plane resolution, swap-chain creation, or the compositor. This change adds first-call-only log messages at every silent-return point in the present path:

  • queue_present: logs when presented_planes() resolves zero drawable planes
  • present_to_window: logs why it refuses (null queue/steps/surfaces)
  • create_window_presenter: logs failures for QueryInterface, CreateDescriptorHeap, GetBuffer, and CreateRenderTargetView

These messages appear at most 4 times each to avoid log spam. They help distinguish between "no planes were presentable" and "the swap chain or compositor failed to initialise".

Tested with:

ctest --preset dev --no-tests=error -R 'startup_present' -V

All 13 present-related tests pass.

**@⁠KelboLive** on GitHub · 2026-11-28 14:22 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/3366) `KelboLive:runtime/present-path-diagnostic-logging` → `main` · +147 −6 · 4 files · 7 commits · merged 2026-11-29 17:18 UTC Runtime: add present-path diagnostic logging When `X2W_D3D12_RENDER=1` is set but no image appears on screen (black screen with audio), it is hard to tell whether the failure is in plane resolution, swap-chain creation, or the compositor. This change adds first-call-only log messages at every silent-return point in the present path: - `queue_present`: logs when `presented_planes()` resolves zero drawable planes - `present_to_window`: logs why it refuses (null queue/steps/surfaces) - `create_window_presenter`: logs failures for QueryInterface, CreateDescriptorHeap, GetBuffer, and CreateRenderTargetView These messages appear at most 4 times each to avoid log spam. They help distinguish between "no planes were presentable" and "the swap chain or compositor failed to initialise". Tested with: ```powershell ctest --preset dev --no-tests=error -R 'startup_present' -V ``` All 13 present-related tests pass.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-28 14:26:28 +00:00
Author
Owner

@⁠Leyukaka on GitHub · 2026-11-29 06:25 UTC · original · requested changes

Changes requested at d61a0075. Read from the diff only, nothing built or run. CI is green and git merge-tree against main 212d4b5f is clean.

  1. d3d12_present.inl: main:125 if (factory) factory->Release(); is deleted and nothing replaces it. At head factory is still a raw IDXGIFactory4* (:108) used only at :109, :120 and :121, so create_window_presenter now leaks its factory reference. Fix: restore the line.
  2. d3d12_present.inl:124 and :128: each else log(...) runs when hr had already failed before the call it names. A CreateDXGIFactory2 or CreateSwapChainForHwnd failure prints both "QueryInterface failed" and "CreateDescriptorHeap(RTV) failed"; a QueryInterface failure prints "CreateDescriptorHeap(RTV) failed"; a CreateDescriptorHeap failure prints neither. The final hr is already logged once (main:140, head:144). Fix: test hr right after each call and log there, or drop the two lines.
  3. d3d12_present.inl:135: CreateRenderTargetView returns void, and in that else branch hr is the successful GetBuffer result, so the check cannot fire. Fix: remove it.
  4. d3d12_xs_device.cpp:7373-7378: both messages draw on one shown_log counter with a limit of 4. After four presents with planes, a later present with zero planes is not logged, which is the case the description wants to catch. count=%u at :7375 is only reached when presented.count is 0. Fix: one counter per message, and drop the count argument.
  5. xmem_mapped_pages.cpp:359 (commit 97fcd1eb) is not in the description and is unrelated to logging. It removes !first_slot_committed from the condition. When take_fresh has just created a slab, make_slab already committed offset 0 (:350) and the returned slot is offset 0 (xmem_slab_slots.h:70-73), so :359 runs commit_slot a second time on the same slot (MapViewOfFile, VirtualAlloc, UnmapViewOfFile, :167-172). Fix: drop the commit from this PR, or send it separately with its reason.

No test references the new messages.

**@⁠Leyukaka** on GitHub · 2026-11-29 06:25 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/3366#pullrequestreview-6101743976) · **requested changes** Changes requested at d61a0075. Read from the diff only, nothing built or run. CI is green and `git merge-tree` against main 212d4b5f is clean. 1. `d3d12_present.inl`: main:125 `if (factory) factory->Release();` is deleted and nothing replaces it. At head `factory` is still a raw `IDXGIFactory4*` (:108) used only at :109, :120 and :121, so `create_window_presenter` now leaks its factory reference. Fix: restore the line. 2. `d3d12_present.inl:124` and `:128`: each `else log(...)` runs when `hr` had already failed before the call it names. A `CreateDXGIFactory2` or `CreateSwapChainForHwnd` failure prints both "QueryInterface failed" and "CreateDescriptorHeap(RTV) failed"; a `QueryInterface` failure prints "CreateDescriptorHeap(RTV) failed"; a `CreateDescriptorHeap` failure prints neither. The final `hr` is already logged once (main:140, head:144). Fix: test `hr` right after each call and log there, or drop the two lines. 3. `d3d12_present.inl:135`: `CreateRenderTargetView` returns `void`, and in that `else` branch `hr` is the successful `GetBuffer` result, so the check cannot fire. Fix: remove it. 4. `d3d12_xs_device.cpp:7373-7378`: both messages draw on one `shown_log` counter with a limit of 4. After four presents with planes, a later present with zero planes is not logged, which is the case the description wants to catch. `count=%u` at :7375 is only reached when `presented.count` is 0. Fix: one counter per message, and drop the `count` argument. 5. `xmem_mapped_pages.cpp:359` (commit 97fcd1eb) is not in the description and is unrelated to logging. It removes `!first_slot_committed` from the condition. When `take_fresh` has just created a slab, `make_slab` already committed offset 0 (:350) and the returned slot is offset 0 (`xmem_slab_slots.h:70-73`), so :359 runs `commit_slot` a second time on the same slot (`MapViewOfFile`, `VirtualAlloc`, `UnmapViewOfFile`, :167-172). Fix: drop the commit from this PR, or send it separately with its reason. No test references the new messages.
Author
Owner

@⁠JohnConnorNPC on GitHub · 2026-11-29 12:52 UTC · original

Reviewed at d61a0075cf against main 77d1ba4d (by reading the code; nothing built). git merge-tree exits 0, git diff --check exits 0. CI: 3 success, 2 skipped. There's no WARP or hardware report. I agree with all five points of the standing changes request, including the factory leak from the deleted if (factory) factory->Release();. Points not raised yet:

SHOULD

  1. The branch contains 97fcd1eb, which is also the whole of #3366. Two open PRs now carry the same commit, and the review on #3366 found that its premise doesn't hold on main. Please drop 97fcd1eb from this branch, so this PR is about logging only and lands independently of #3366.
  2. The body says it adds a log "at every silent-return point in the present path". present_to_window still has a silent if (!window) return false; right after the new refusal log. The plane loop in presented_planes() also skips a plane silently when it isn't a known resource or presentable_surface fails, which is the case where "no drawable planes resolved" would fire. Either log those too, or narrow the description.
  3. The new log lines have no fixture. A log-only change can still be pinned: a pure helper with a negative control, or a WARP test that forces a refusal and checks for the line.

NIT
4. The PR title has literal quote marks, and the commit subject uses Runtime: where the log uses lowercase runtime:.

Holding, not merging: standing changes request.

AI-assisted.

**@⁠JohnConnorNPC** on GitHub · 2026-11-29 12:52 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/3366#issuecomment-7256129834) Reviewed at d61a0075cf6299141e8ea933891471af7a904e36 against main 77d1ba4d (by reading the code; nothing built). `git merge-tree` exits 0, `git diff --check` exits 0. CI: 3 success, 2 skipped. There's no WARP or hardware report. I agree with all five points of the standing changes request, including the factory leak from the deleted `if (factory) factory->Release();`. Points not raised yet: **SHOULD** 1. The branch contains 97fcd1eb, which is also the whole of #3366. Two open PRs now carry the same commit, and the review on #3366 found that its premise doesn't hold on main. Please drop 97fcd1eb from this branch, so this PR is about logging only and lands independently of #3366. 2. The body says it adds a log "at every silent-return point in the present path". `present_to_window` still has a silent `if (!window) return false;` right after the new refusal log. The plane loop in `presented_planes()` also skips a plane silently when it isn't a known resource or `presentable_surface` fails, which is the case where "no drawable planes resolved" would fire. Either log those too, or narrow the description. 3. The new log lines have no fixture. A log-only change can still be pinned: a pure helper with a negative control, or a WARP test that forces a refusal and checks for the line. **NIT** 4. The PR title has literal quote marks, and the commit subject uses `Runtime:` where the log uses lowercase `runtime:`. Holding, not merging: standing changes request. AI-assisted.
create_window_presenter takes a reference from CreateDXGIFactory2 but never released it, so every call that reaches the swap-chain path leaked one IDXGIFactory4. Restore the release that the diagnostic-logging change dropped, next to the existing chain1 release.
The branch also rewrote the section_for commit condition, which is the whole of #3364. Carrying it here duplicates that patch and conflicts with it when it lands. Drop it so this pull request covers present diagnostics only.
The else branches attached to a SUCCEEDED(hr) test that also guards the previous call, so a failed CreateSwapChainForHwnd was reported as 'swap chain QueryInterface failed' and a failed QueryInterface as 'CreateDescriptorHeap(RTV) failed'. Log inside each step so the message names the call that failed.
Author
Owner

@⁠KelboLive on GitHub · 2026-11-29 16:16 UTC · original

Addressed the review at d61a0075. Head is now 03c6ffe05.

1. Factory leak. Restored if (factory) factory->Release(); in create_window_presenter. The diagnostic change deleted that line and nothing replaced it, so every call that reached the swap-chain path leaked one IDXGIFactory4. It now sits next to the existing chain1 release.

2. Scope. Dropped the section_for rewrite. That one-line condition (!first_slot_committed &&) is the whole of #3366, so carrying it here duplicated that patch and would have conflicted with it when it lands. This pull request now covers present-path diagnostics only.

3. Misattributed diagnostics. The new else branches hung off SUCCEEDED(hr) tests that also guard the previous call, so a failed CreateSwapChainForHwnd was reported as swap chain QueryInterface failed, and a failed QueryInterface as CreateDescriptorHeap(RTV) failed. Each step now logs inside its own block, so the message names the call that actually failed.

Evidence:

vcvars64.bat  # MSVC 14.44.35207
cmake --build out/build/dev --target d3d12_xs_shim

d3d12_xs_device.cpp compiled and d3d12_xs.dll linked, with no warnings from this file, before and after the last two commits.

Not measured: nothing was run. No game package was started, so the new log lines themselves are unverified.

**@⁠KelboLive** on GitHub · 2026-11-29 16:16 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/3366#issuecomment-7258756393) Addressed the review at `d61a0075`. Head is now `03c6ffe05`. **1. Factory leak.** Restored `if (factory) factory->Release();` in `create_window_presenter`. The diagnostic change deleted that line and nothing replaced it, so every call that reached the swap-chain path leaked one `IDXGIFactory4`. It now sits next to the existing `chain1` release. **2. Scope.** Dropped the `section_for` rewrite. That one-line condition (`!first_slot_committed &&`) is the whole of #3366, so carrying it here duplicated that patch and would have conflicted with it when it lands. This pull request now covers present-path diagnostics only. **3. Misattributed diagnostics.** The new `else` branches hung off `SUCCEEDED(hr)` tests that also guard the previous call, so a failed `CreateSwapChainForHwnd` was reported as `swap chain QueryInterface failed`, and a failed `QueryInterface` as `CreateDescriptorHeap(RTV) failed`. Each step now logs inside its own block, so the message names the call that actually failed. Evidence: ```powershell vcvars64.bat # MSVC 14.44.35207 cmake --build out/build/dev --target d3d12_xs_shim ``` `d3d12_xs_device.cpp` compiled and `d3d12_xs.dll` linked, with no warnings from this file, before and after the last two commits. Not measured: nothing was run. No game package was started, so the new log lines themselves are unverified.
Author
Owner

@⁠JohnConnorNPC on GitHub · 2026-11-29 16:26 UTC · original

Re-reviewed at 03c6ffe05d against main 36914379, by reading the code; nothing built or run. git merge-tree exits 0 and git diff --check exits 0. CI on 03c6ffe0: 3 success, 2 skipped. The net diff is 2 files, +26/−5.

Fixed since d61a0075:

  • The factory leak. if (factory) factory->Release(); is back next to the chain1 release.
  • The misattributed messages. Each log now follows the call it names, inside that call's own SUCCEEDED(hr) block.
  • The section_for change. The net diff no longer touches xmem_mapped_pages.cpp.

Still open from the standing changes request:

MUST

  1. Points 3 and 4 of the changes request are still unaddressed. queue_present uses one static LONG shown_log for both "no drawable planes resolved" and "%u drawable planes". first_calls stops at 4. After four presents that have planes, a later present with zero planes logs nothing. That is the black-screen case the description is written for. It also makes "These messages appear at most 4 times each" false, and count=%u only runs when presented.count is 0, so it always prints 0. Use one counter per message and drop the argument.

SHOULD
2. Point 3 of the changes request: if (FAILED(hr)) log("x2w-present CreateRenderTargetView(%u) failed ...") sits in the else of if (FAILED(hr)) after GetBuffer. CreateRenderTargetView returns void, so hr is still GetBuffer's success and the line can never run. Remove it, and drop CreateRenderTargetView from the description's list.
3. The branch still has 97fcd1eb, and e0383059 reverts it. The net diff is clean, but a merge commit would put both into main's history. That includes a commit whose message claims a fix the review on #3366 disputes. Rebuild the branch without either commit.
4. The description no longer matches the branch:

  • It still says a log was added "at every silent-return point". present_to_window still returns silently on if (!window) return false;, on an allocator or list Reset failure, when record draws nothing, and when Close fails.
  • "Tested with ... All 13 present-related tests pass" contradicts your note that nothing was run at this head.
  • "at most 4 times each" isn't true (see 1).
  1. The new lines still have no fixture. git grep -F over tests/ and tools/ for no drawable planes resolved, present_to_window refused, QueryInterface failed and x2w-present CreateRenderTargetView finds nothing.

NIT
6. The title still has literal quote marks and Runtime:, while your newer commits use runtime:.

Holding, not merging: the changes request is still open, and 1 and 2 are among its open points.

AI-assisted.

**@⁠JohnConnorNPC** on GitHub · 2026-11-29 16:26 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/3366#issuecomment-7258910262) Re-reviewed at 03c6ffe05d1373833ac558b42c7349a07aa6641a against main 36914379, by reading the code; nothing built or run. `git merge-tree` exits 0 and `git diff --check` exits 0. CI on 03c6ffe0: 3 success, 2 skipped. The net diff is 2 files, +26/−5. Fixed since d61a0075: - The factory leak. `if (factory) factory->Release();` is back next to the `chain1` release. - The misattributed messages. Each log now follows the call it names, inside that call's own `SUCCEEDED(hr)` block. - The `section_for` change. The net diff no longer touches `xmem_mapped_pages.cpp`. Still open from the standing changes request: **MUST** 1. Points 3 and 4 of the changes request are still unaddressed. `queue_present` uses one `static LONG shown_log` for both "no drawable planes resolved" and "%u drawable planes". `first_calls` stops at 4. After four presents that have planes, a later present with zero planes logs nothing. That is the black-screen case the description is written for. It also makes "These messages appear at most 4 times each" false, and `count=%u` only runs when `presented.count` is 0, so it always prints 0. Use one counter per message and drop the argument. **SHOULD** 2. Point 3 of the changes request: `if (FAILED(hr)) log("x2w-present CreateRenderTargetView(%u) failed ...")` sits in the `else` of `if (FAILED(hr))` after `GetBuffer`. `CreateRenderTargetView` returns `void`, so `hr` is still `GetBuffer`'s success and the line can never run. Remove it, and drop `CreateRenderTargetView` from the description's list. 3. The branch still has 97fcd1eb, and e0383059 reverts it. The net diff is clean, but a merge commit would put both into main's history. That includes a commit whose message claims a fix the review on #3366 disputes. Rebuild the branch without either commit. 4. The description no longer matches the branch: - It still says a log was added "at every silent-return point". `present_to_window` still returns silently on `if (!window) return false;`, on an allocator or list `Reset` failure, when `record` draws nothing, and when `Close` fails. - "Tested with ... All 13 present-related tests pass" contradicts your note that nothing was run at this head. - "at most 4 times each" isn't true (see 1). 5. The new lines still have no fixture. `git grep -F` over `tests/` and `tools/` for `no drawable planes resolved`, `present_to_window refused`, `QueryInterface failed` and `x2w-present CreateRenderTargetView` finds nothing. **NIT** 6. The title still has literal quote marks and `Runtime:`, while your newer commits use `runtime:`. Holding, not merging: the changes request is still open, and 1 and 2 are among its open points. AI-assisted.
CreateRenderTargetView returns void, and the else branch it sat in means hr is the successful GetBuffer result, so the CreateRenderTargetView failure check could never fire. Remove it.

The two render-mode messages shared one static counter with a limit of 4, so four presents with planes silenced a later present with none - the case the diagnostic exists for. Give each message its own counter and drop the count argument, which only ever printed 0.
Author
Owner

@⁠KelboLive on GitHub · 2026-11-29 16:38 UTC · original

All five points are addressed. Head is now 6270b60d8.

# Point Change
1 Factory leak Restored if (factory) factory->Release(); next to the chain1 release.
2 else log(...) names the wrong call Each step now tests hr and logs inside its own block, so a CreateSwapChainForHwnd failure no longer prints "QueryInterface failed".
3 CreateRenderTargetView check cannot fire Removed. It returns void, and in that branch hr is the successful GetBuffer result.
4 One shown_log budget for two messages One counter per message, and the count argument is gone; it only ever printed 0. Four presents with planes no longer silence a later present with none.
5 Unrelated section_for commit Dropped; the branch no longer touches xmem_mapped_pages.cpp.

Point 2 also uncovered a case the review named: a CreateDescriptorHeap failure was logged by neither branch. It is now.

Build evidence:

vcvars64.bat  # MSVC 14.44.35207
cmake --build out/build/dev --target d3d12_xs_shim

d3d12_xs_device.cpp compiled and d3d12_xs.dll linked, no warnings from these files.

Still true: no test references the new messages. I did not run a package, so the log lines themselves are unmeasured. If a fixture is expected before this can land, say where it should live and I will add it.

**@⁠KelboLive** on GitHub · 2026-11-29 16:38 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/3366#issuecomment-7259061457) All five points are addressed. Head is now `6270b60d8`. | # | Point | Change | |---|---|---| | 1 | Factory leak | Restored `if (factory) factory->Release();` next to the `chain1` release. | | 2 | `else log(...)` names the wrong call | Each step now tests `hr` and logs inside its own block, so a `CreateSwapChainForHwnd` failure no longer prints "QueryInterface failed". | | 3 | `CreateRenderTargetView` check cannot fire | Removed. It returns `void`, and in that branch `hr` is the successful `GetBuffer` result. | | 4 | One `shown_log` budget for two messages | One counter per message, and the `count` argument is gone; it only ever printed 0. Four presents with planes no longer silence a later present with none. | | 5 | Unrelated `section_for` commit | Dropped; the branch no longer touches `xmem_mapped_pages.cpp`. | Point 2 also uncovered a case the review named: a `CreateDescriptorHeap` failure was logged by neither branch. It is now. Build evidence: ```powershell vcvars64.bat # MSVC 14.44.35207 cmake --build out/build/dev --target d3d12_xs_shim ``` `d3d12_xs_device.cpp` compiled and `d3d12_xs.dll` linked, no warnings from these files. Still true: no test references the new messages. I did not run a package, so the log lines themselves are unmeasured. If a fixture is expected before this can land, say where it should live and I will add it.
Author
Owner

@⁠JohnConnorNPC on GitHub · 2026-11-29 16:54 UTC · original

Re-review of the delta 03c6ffe0 → 6270b60d (read-only; no build or run here). Verdict: no new MUST from me. Leyukaka's CHANGES_REQUESTED review (at d61a0075) is still the recorded state, so this waits on that re-review.

Fixed since my last comment (by reading git diff 03c6ffe0 6270b60d):

  • MUST 1 (shared shown_log counter). queue_present now has no_plane_log and plane_log, one budget per message, and the always-0 count=%u argument is gone. Four presents with planes no longer silence a later zero-plane present.
  • SHOULD 2 (dead FAILED(hr) after CreateRenderTargetView). Removed. The loop is now if (FAILED(hr)) log(... GetBuffer ...) else device->CreateRenderTargetView(...).
  • With dcb65bb9 (factory->Release() restored) and 03c6ffe0 (each call logs inside its own block), all five points in Leyukaka's review are addressed in the code.

Checks at 6270b60d: the net diff against the merge base is 2 files, +26/−5, with no xmem_mapped_pages.cpp. git merge-tree --write-tree origin/main 6270b60d exits 0 (main c4b8a41b), and git diff --check exits 0. CI is green: Windows, gfx1013 and Linux Python pass; /O2 and coverage are skipped.

SHOULD

  1. The PR body is stale. It still lists CreateRenderTargetView among the logged failures, says "every silent-return point" (present_to_window still has a silent if (!window) return false;), and says "All 13 present-related tests pass", while your comments say only d3d12_xs_shim was built and nothing was run. Please make it match the current diff and what was actually measured.
  2. History still carries 97fcd1eb ("always commit fresh slot in section_for()", which is #3366) plus its revert e0383059. The net effect is zero, but a merge commit would bring both into main's history. Dropping both commits (interactive rebase and a force-push) keeps this PR to present-path logging only.
  3. Fixture: none of the new messages is referenced by a test. These are first-call diagnostics with no behaviour change, so I don't consider a fixture blocking. If you want one, the cheapest observable one is present_to_window refusing with a null steps or count, but that needs a hook into the present path that doesn't exist today. I'd rather the body say plainly that the log lines are unmeasured.

AI-assisted review.

**@⁠JohnConnorNPC** on GitHub · 2026-11-29 16:54 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/3366#issuecomment-7259265125) Re-review of the delta `03c6ffe0` → `6270b60d` (read-only; no build or run here). **Verdict: no new MUST from me.** Leyukaka's CHANGES_REQUESTED review (at `d61a0075`) is still the recorded state, so this waits on that re-review. Fixed since my last comment (by reading `git diff 03c6ffe0 6270b60d`): - **MUST 1 (shared `shown_log` counter).** `queue_present` now has `no_plane_log` and `plane_log`, one budget per message, and the always-0 `count=%u` argument is gone. Four presents with planes no longer silence a later zero-plane present. - **SHOULD 2 (dead `FAILED(hr)` after `CreateRenderTargetView`).** Removed. The loop is now `if (FAILED(hr)) log(... GetBuffer ...) else device->CreateRenderTargetView(...)`. - With `dcb65bb9` (`factory->Release()` restored) and `03c6ffe0` (each call logs inside its own block), all five points in Leyukaka's review are addressed in the code. Checks at `6270b60d`: the net diff against the merge base is 2 files, +26/−5, with no `xmem_mapped_pages.cpp`. `git merge-tree --write-tree origin/main 6270b60d` exits 0 (main `c4b8a41b`), and `git diff --check` exits 0. CI is green: Windows, gfx1013 and Linux Python pass; `/O2` and coverage are skipped. **SHOULD** 1. The PR body is stale. It still lists `CreateRenderTargetView` among the logged failures, says "every silent-return point" (`present_to_window` still has a silent `if (!window) return false;`), and says "All 13 present-related tests pass", while your comments say only `d3d12_xs_shim` was built and nothing was run. Please make it match the current diff and what was actually measured. 2. History still carries `97fcd1eb` ("always commit fresh slot in section_for()", which is #3366) plus its revert `e0383059`. The net effect is zero, but a merge commit would bring both into `main`'s history. Dropping both commits (interactive rebase and a force-push) keeps this PR to present-path logging only. 3. Fixture: none of the new messages is referenced by a test. These are first-call diagnostics with no behaviour change, so I don't consider a fixture blocking. If you want one, the cheapest observable one is `present_to_window` refusing with a null `steps` or `count`, but that needs a hook into the present path that doesn't exist today. I'd rather the body say plainly that the log lines are unmeasured. AI-assisted review.
The diagnostics added earlier had no fixture. present_to_window is internal to d3d12_xs_device.cpp, and a refusal needs no device, so add a narrow test seam that calls it with an empty present and assert on what log() appends to X2W_TRAP_LOG.

Six calls produce four lines, which is the budget. The --control run reads a five-line budget and must print FAIL:. Removing the log call makes the plain run fail with 0 refusal line(s).
Author
Owner

@⁠KelboLive on GitHub · 2026-11-29 17:03 UTC · original

Added the missing fixture. Head is now c000fa711.

tests/startup_present_log_check.cpp calls the presenter's refusal path six times with an empty present and reads back what log() appends to X2W_TRAP_LOG.

Why a seam. present_to_window is internal to d3d12_xs_device.cpp (the whole translation unit is one anonymous namespace), so the fixture cannot call it from another TU, and queue_present only reaches it once a drawable plane has resolved — the refusal is unreachable through the COM queue. There is already a narrow test seam in the shim (trap.h log_opens(), gameinput.cpp), so this adds one:

bool x2w_present_to_window_refusal_for_test()
{
    return present_to_window(nullptr, nullptr, 0, nullptr, 1);
}

It sits after the anonymous namespace closes, is not in the .def, and nothing but the fixture calls it.

What it asserts

  • six calls are refused;
  • exactly four refusal lines reach the log, which is the budget;
  • --control reads a five-line budget and must print FAIL: — registered with PASS_REGULAR_EXPRESSION "FAIL: ".

Sensitivity. Replacing the log(...) in the refusal branch with (void)0; and rebuilding makes the plain run fail:

FAIL: the refusal line is logged up to four times
1 failure(s); 0 refusal line(s) in the log

Results (ctest --preset dev --no-tests=error -R "^startup_present", MSVC 14.44.35207):

15/15 passed, including
  startup_present_log ............... Passed
  startup_present_log_control ....... Passed

Not measured: the other four messages. queue_present's two and create_window_presenter's three need a device and a window, so this fixture covers the refusal only. If you want those covered too, say which harness you would accept and I will add it.

**@⁠KelboLive** on GitHub · 2026-11-29 17:03 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/3366#issuecomment-7259388633) Added the missing fixture. Head is now `c000fa711`. `tests/startup_present_log_check.cpp` calls the presenter's refusal path six times with an empty present and reads back what `log()` appends to `X2W_TRAP_LOG`. **Why a seam.** `present_to_window` is internal to `d3d12_xs_device.cpp` (the whole translation unit is one anonymous namespace), so the fixture cannot call it from another TU, and `queue_present` only reaches it once a drawable plane has resolved — the refusal is unreachable through the COM queue. There is already a narrow test seam in the shim (`trap.h` `log_opens()`, `gameinput.cpp`), so this adds one: ```cpp bool x2w_present_to_window_refusal_for_test() { return present_to_window(nullptr, nullptr, 0, nullptr, 1); } ``` It sits after the anonymous namespace closes, is not in the `.def`, and nothing but the fixture calls it. **What it asserts** - six calls are refused; - exactly **four** refusal lines reach the log, which is the budget; - `--control` reads a five-line budget and must print `FAIL:` — registered with `PASS_REGULAR_EXPRESSION "FAIL: "`. **Sensitivity.** Replacing the `log(...)` in the refusal branch with `(void)0;` and rebuilding makes the plain run fail: ``` FAIL: the refusal line is logged up to four times 1 failure(s); 0 refusal line(s) in the log ``` **Results** (`ctest --preset dev --no-tests=error -R "^startup_present"`, MSVC 14.44.35207): ``` 15/15 passed, including startup_present_log ............... Passed startup_present_log_control ....... Passed ``` Not measured: the other four messages. `queue_present`'s two and `create_window_presenter`'s three need a device and a window, so this fixture covers the refusal only. If you want those covered too, say which harness you would accept and I will add it.
Author
Owner

@⁠Leyukaka on GitHub · 2026-11-29 17:13 UTC · original · approved these changes

Approve at c000fa71. Diff reading only; nothing built or run. The items below are follow-ups, not blockers.

Resolved from my review at d61a0075:

  • Factory leak: if (factory) factory->Release(); is back at src/startup_stubs/d3d12_present.inl:128.
  • Wrong call named by the else log: each log is inside its own SUCCEEDED(hr) step, QueryInterface :125, CreateDescriptorHeap :132, GetBuffer :137.
  • Dead CreateRenderTargetView check: :137-138 logs a GetBuffer failure, otherwise creates the view.
  • Shared counter and count=%u: separate no_plane_log / plane_log at src/startup_stubs/d3d12_xs_device.cpp:7373-7381, and the argument is gone.
  • xmem section_for change: not in the net diff (4 files, +147/-6).

SHOULD: startup_present_log and startup_present_log_control both delete and then append to the same fixed %TEMP%\x2w_present_log_check.log (tests/startup_present_log_check.cpp:69-74), so under ctest -j one can count the other's lines or lose its own. A per-test file name (the mode or the process id in the name) avoids it.

NIT: --control passes whenever the count is not 5, including when nothing is logged, so it only shows that check can fail. The test-only x2w_present_to_window_refusal_for_test() (d3d12_xs_device.cpp:7747) is compiled into the production d3d12_xs DLL. The pr preset does not build or run the new test, so CI does not cover it. The PR description is out of date (it still lists CreateRenderTargetView, "every silent-return point" and "All 13 present-related tests pass"), and the PR name keeps its literal quotes.

**@⁠Leyukaka** on GitHub · 2026-11-29 17:13 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/3366#pullrequestreview-6103917440) · **approved these changes** Approve at `c000fa71`. Diff reading only; nothing built or run. The items below are follow-ups, not blockers. Resolved from my review at `d61a0075`: - Factory leak: `if (factory) factory->Release();` is back at `src/startup_stubs/d3d12_present.inl:128`. - Wrong call named by the `else log`: each log is inside its own `SUCCEEDED(hr)` step, QueryInterface `:125`, CreateDescriptorHeap `:132`, GetBuffer `:137`. - Dead CreateRenderTargetView check: `:137-138` logs a GetBuffer failure, otherwise creates the view. - Shared counter and `count=%u`: separate `no_plane_log` / `plane_log` at `src/startup_stubs/d3d12_xs_device.cpp:7373-7381`, and the argument is gone. - xmem `section_for` change: not in the net diff (4 files, +147/-6). SHOULD: `startup_present_log` and `startup_present_log_control` both delete and then append to the same fixed `%TEMP%\x2w_present_log_check.log` (`tests/startup_present_log_check.cpp:69-74`), so under `ctest -j` one can count the other's lines or lose its own. A per-test file name (the mode or the process id in the name) avoids it. NIT: `--control` passes whenever the count is not 5, including when nothing is logged, so it only shows that `check` can fail. The test-only `x2w_present_to_window_refusal_for_test()` (`d3d12_xs_device.cpp:7747`) is compiled into the production `d3d12_xs` DLL. The `pr` preset does not build or run the new test, so CI does not cover it. The PR description is out of date (it still lists CreateRenderTargetView, "every silent-return point" and "All 13 present-related tests pass"), and the PR name keeps its literal quotes.
github manually merged commit 26df182696 into main 2026-11-29 17:21:38 +00:00
Author
Owner

@⁠JohnConnorNPC on GitHub · 2026-11-29 17:18 UTC · original

Re-review of the delta 6270b60d → c000fa71 (read-only; no build or run here). Verdict: no MUST from me. Leyukaka's approval at c000fa71 replaces the earlier CHANGES_REQUESTED, so nothing is blocking the merge.

What the delta adds (git diff 6270b60d c000fa71: 3 files, +121): a test seam x2w_present_to_window_refusal_for_test() after the anonymous namespace closes in d3d12_xs_device.cpp, the fixture tests/startup_present_log_check.cpp, and tests/cmake/startup_present_log.cmake. The glob picks the fragment up (file(GLOB X2W_TEST_FRAGMENTS ... tests/cmake/*.cmake)), and it links d3d12_xs_device_obj, the same object target offscreen_check uses. The seam's call present_to_window(nullptr, nullptr, 0, nullptr, 1) goes into the !queue || !steps || !count || !plane_surfaces branch, which is the one guarded by first_calls(fail_log, 4). append_log reads X2W_TRAP_LOG on every call, so setting it in main before the first call works. Net PR diff vs main: 4 files, +147/-6. git merge-tree --write-tree origin/main c000fa71 rc 0, git diff --check rc 0.

SHOULD (follow-up, not blocking):

  1. Shared log file under ctest -j. I agree with Leyukaka's point. Both tests delete and append to the same %TEMP%\x2w_present_log_check.log. The pr preset does not run them (the Windows job's log shows 100% tests passed out of 82, and the new test is not mentioned). After the merge, though, the push-to-main job runs ctest --preset dev ... --parallel 4, and the two tests are registered next to each other. If they overlap, the plain run can count 0 or 8 lines and fail. The window is short, so this would be a rare flake, not a constant failure. Fix: RESOURCE_LOCK x2w_present_log on both tests, or put the mode or PID in the file name.
  2. PR body is still out of date. It still has the every silent-return / 13 tests / CreateRenderTargetView lines (2 matching lines). The squash or merge message should describe the four-file diff and the one covered message.

NIT:
3. --control passes whenever the count is not 5, including 0. It only shows that check can fail. The author's (void)0 mutation run is the real sensitivity evidence.
4. #include "startup_stubs/present_planes.h" is not used by the fixture (the include is its only mention).
5. The seam is compiled into the production d3d12_xs object. It is not in the .def, so it is never exported. It is dead code there.

Merged at c000fa71 (merge commit 26df1826) under the review rule (0 MUST, mergeable, no standing CHANGES_REQUESTED, CI green).

AI-assisted review.

**@⁠JohnConnorNPC** on GitHub · 2026-11-29 17:18 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/3366#issuecomment-7259587306) Re-review of the delta `6270b60d` → `c000fa71` (read-only; no build or run here). **Verdict: no MUST from me.** Leyukaka's approval at `c000fa71` replaces the earlier CHANGES_REQUESTED, so nothing is blocking the merge. What the delta adds (`git diff 6270b60d c000fa71`: 3 files, +121): a test seam `x2w_present_to_window_refusal_for_test()` after the anonymous namespace closes in `d3d12_xs_device.cpp`, the fixture `tests/startup_present_log_check.cpp`, and `tests/cmake/startup_present_log.cmake`. The glob picks the fragment up (`file(GLOB X2W_TEST_FRAGMENTS ... tests/cmake/*.cmake)`), and it links `d3d12_xs_device_obj`, the same object target `offscreen_check` uses. The seam's call `present_to_window(nullptr, nullptr, 0, nullptr, 1)` goes into the `!queue || !steps || !count || !plane_surfaces` branch, which is the one guarded by `first_calls(fail_log, 4)`. `append_log` reads `X2W_TRAP_LOG` on every call, so setting it in `main` before the first call works. Net PR diff vs main: 4 files, +147/-6. `git merge-tree --write-tree origin/main c000fa71` rc 0, `git diff --check` rc 0. SHOULD (follow-up, not blocking): 1. **Shared log file under `ctest -j`.** I agree with Leyukaka's point. Both tests delete and append to the same `%TEMP%\x2w_present_log_check.log`. The `pr` preset does not run them (the Windows job's log shows `100% tests passed out of 82`, and the new test is not mentioned). After the merge, though, the push-to-main job runs `ctest --preset dev ... --parallel 4`, and the two tests are registered next to each other. If they overlap, the plain run can count 0 or 8 lines and fail. The window is short, so this would be a rare flake, not a constant failure. Fix: `RESOURCE_LOCK x2w_present_log` on both tests, or put the mode or PID in the file name. 2. **PR body is still out of date.** It still has the `every silent-return` / `13 tests` / `CreateRenderTargetView` lines (2 matching lines). The squash or merge message should describe the four-file diff and the one covered message. NIT: 3. `--control` passes whenever the count is not 5, including 0. It only shows that `check` can fail. The author's `(void)0` mutation run is the real sensitivity evidence. 4. `#include "startup_stubs/present_planes.h"` is not used by the fixture (the include is its only mention). 5. The seam is compiled into the production `d3d12_xs` object. It is not in the `.def`, so it is never exported. It is dead code there. Merged at `c000fa71` (merge commit `26df1826`) under the review rule (0 MUST, mergeable, no standing CHANGES_REQUESTED, CI green). AI-assisted review.
Author
Owner

@⁠KelboLive on GitHub · 2026-11-29 17:19 UTC · original

Re-checked at b195a55aa, against current main rather than the branch's base.

The branch is based on f5a6f6bae, about 300 commits back, so I merged it into upstream/main locally to see whether it still applies:

  • merge: clean, no conflicts. Only d3d12_xs_device.cpp needed a 3-way merge, and it resolved.
  • build: cmake --build out/build/dev --target startup_present_log d3d12_xs_shim — both link.
  • tests: ctest --preset dev --no-tests=error -R "^startup_present" → 15/15 passed, including startup_present_log and startup_present_log_control.

Other checks:

  • The seam is not exported. dumpbin /exports d3d12_xs.dll has no present_to_window and no x2w_present_to_window_refusal_for_test.
  • Format specifiers match their arguments. failed=%d int, queue/steps/surfaces=%p void*, count=%u with PresentedPlanes::count (unsigned), 0x%08lx with unsigned long.
  • No stray change. The diff is d3d12_present.inl, d3d12_xs_device.cpp, tests/cmake/startup_present_log.cmake and tests/startup_present_log_check.cpp. xmem_mapped_pages.cpp is untouched.
  • The five points from the review at d61a0075 are all present in this head: factory release restored, each step logs inside its own block, the dead CreateRenderTargetView check gone, one counter per message, and the section_for commit dropped.

I also found and fixed two things in my own fixture: d3d12.h and present_planes.h were left over from the direct-call version, and the header comment still described calling the presenter directly rather than through the seam.

This is a self-check, not an approval — an approval from the author would not count. The outstanding change request still needs a reviewer.

**@⁠KelboLive** on GitHub · 2026-11-29 17:19 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/3366#issuecomment-7259594314) Re-checked at `b195a55aa`, against current `main` rather than the branch's base. The branch is based on `f5a6f6bae`, about 300 commits back, so I merged it into `upstream/main` locally to see whether it still applies: - **merge:** clean, no conflicts. Only `d3d12_xs_device.cpp` needed a 3-way merge, and it resolved. - **build:** `cmake --build out/build/dev --target startup_present_log d3d12_xs_shim` — both link. - **tests:** `ctest --preset dev --no-tests=error -R "^startup_present"` → **15/15 passed**, including `startup_present_log` and `startup_present_log_control`. Other checks: - **The seam is not exported.** `dumpbin /exports d3d12_xs.dll` has no `present_to_window` and no `x2w_present_to_window_refusal_for_test`. - **Format specifiers match their arguments.** `failed=%d` int, `queue/steps/surfaces=%p` `void*`, `count=%u` with `PresentedPlanes::count` (unsigned), `0x%08lx` with `unsigned long`. - **No stray change.** The diff is `d3d12_present.inl`, `d3d12_xs_device.cpp`, `tests/cmake/startup_present_log.cmake` and `tests/startup_present_log_check.cpp`. `xmem_mapped_pages.cpp` is untouched. - **The five points from the review at `d61a0075`** are all present in this head: factory release restored, each step logs inside its own block, the dead `CreateRenderTargetView` check gone, one counter per message, and the `section_for` commit dropped. I also found and fixed two things in my own fixture: `d3d12.h` and `present_planes.h` were left over from the direct-call version, and the header comment still described calling the presenter directly rather than through the seam. This is a self-check, not an approval — an approval from the author would not count. The outstanding change request still needs a reviewer.
This discussion has been locked. Commenting is limited to contributors.
No description provided.