'Runtime: add present-path diagnostic logging' #3368
No reviewers
Labels
No labels
accessibility
awaiting author
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
priority: P0
question
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/R0Y00--Xbox2Windows!3368
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-3366"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
@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 UTCRuntime: add present-path diagnostic logging
When
X2W_D3D12_RENDER=1is 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 whenpresented_planes()resolves zero drawable planespresent_to_window: logs why it refuses (null queue/steps/surfaces)create_window_presenter: logs failures for QueryInterface, CreateDescriptorHeap, GetBuffer, and CreateRenderTargetViewThese 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:
All 13 present-related tests pass.
@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 andgit merge-treeagainst main212d4b5fis clean.d3d12_present.inl: main:125if (factory) factory->Release();is deleted and nothing replaces it. At headfactoryis still a rawIDXGIFactory4*(:108) used only at :109, :120 and :121, socreate_window_presenternow leaks its factory reference. Fix: restore the line.d3d12_present.inl:124and:128: eachelse log(...)runs whenhrhad already failed before the call it names. ACreateDXGIFactory2orCreateSwapChainForHwndfailure prints both "QueryInterface failed" and "CreateDescriptorHeap(RTV) failed"; aQueryInterfacefailure prints "CreateDescriptorHeap(RTV) failed"; aCreateDescriptorHeapfailure prints neither. The finalhris already logged once (main:140, head:144). Fix: testhrright after each call and log there, or drop the two lines.d3d12_present.inl:135:CreateRenderTargetViewreturnsvoid, and in thatelsebranchhris the successfulGetBufferresult, so the check cannot fire. Fix: remove it.d3d12_xs_device.cpp:7373-7378: both messages draw on oneshown_logcounter 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=%uat :7375 is only reached whenpresented.countis 0. Fix: one counter per message, and drop thecountargument.xmem_mapped_pages.cpp:359(commit97fcd1eb) is not in the description and is unrelated to logging. It removes!first_slot_committedfrom the condition. Whentake_freshhas just created a slab,make_slabalready committed offset 0 (:350) and the returned slot is offset 0 (xmem_slab_slots.h:70-73), so :359 runscommit_slota 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.
@JohnConnorNPC on GitHub · 2026-11-29 12:52 UTC · original
Reviewed at
d61a0075cfagainst main77d1ba4d(by reading the code; nothing built).git merge-treeexits 0,git diff --checkexits 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 deletedif (factory) factory->Release();. Points not raised yet:SHOULD
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 drop97fcd1ebfrom this branch, so this PR is about logging only and lands independently of #3366.present_to_windowstill has a silentif (!window) return false;right after the new refusal log. The plane loop inpresented_planes()also skips a plane silently when it isn't a known resource orpresentable_surfacefails, which is the case where "no drawable planes resolved" would fire. Either log those too, or narrow the description.NIT
4. The PR title has literal quote marks, and the commit subject uses
Runtime:where the log uses lowercaseruntime:.Holding, not merging: standing changes request.
AI-assisted.
@KelboLive on GitHub · 2026-11-29 16:16 UTC · original
Addressed the review at
d61a0075. Head is now03c6ffe05.1. Factory leak. Restored
if (factory) factory->Release();increate_window_presenter. The diagnostic change deleted that line and nothing replaced it, so every call that reached the swap-chain path leaked oneIDXGIFactory4. It now sits next to the existingchain1release.2. Scope. Dropped the
section_forrewrite. 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
elsebranches hung offSUCCEEDED(hr)tests that also guard the previous call, so a failedCreateSwapChainForHwndwas reported asswap chain QueryInterface failed, and a failedQueryInterfaceasCreateDescriptorHeap(RTV) failed. Each step now logs inside its own block, so the message names the call that actually failed.Evidence:
d3d12_xs_device.cppcompiled andd3d12_xs.dlllinked, 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.
@JohnConnorNPC on GitHub · 2026-11-29 16:26 UTC · original
Re-reviewed at
03c6ffe05dagainst main36914379, by reading the code; nothing built or run.git merge-treeexits 0 andgit diff --checkexits 0. CI on03c6ffe0: 3 success, 2 skipped. The net diff is 2 files, +26/−5.Fixed since
d61a0075:if (factory) factory->Release();is back next to thechain1release.SUCCEEDED(hr)block.section_forchange. The net diff no longer touchesxmem_mapped_pages.cpp.Still open from the standing changes request:
MUST
queue_presentuses onestatic LONG shown_logfor both "no drawable planes resolved" and "%u drawable planes".first_callsstops 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, andcount=%uonly runs whenpresented.countis 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 theelseofif (FAILED(hr))afterGetBuffer.CreateRenderTargetViewreturnsvoid, sohris stillGetBuffer's success and the line can never run. Remove it, and dropCreateRenderTargetViewfrom the description's list.3. The branch still has
97fcd1eb, ande0383059reverts 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:
present_to_windowstill returns silently onif (!window) return false;, on an allocator or listResetfailure, whenrecorddraws nothing, and whenClosefails.git grep -Fovertests/andtools/forno drawable planes resolved,present_to_window refused,QueryInterface failedandx2w-present CreateRenderTargetViewfinds nothing.NIT
6. The title still has literal quote marks and
Runtime:, while your newer commits useruntime:.Holding, not merging: the changes request is still open, and 1 and 2 are among its open points.
AI-assisted.
@KelboLive on GitHub · 2026-11-29 16:38 UTC · original
All five points are addressed. Head is now
6270b60d8.if (factory) factory->Release();next to thechain1release.else log(...)names the wrong callhrand logs inside its own block, so aCreateSwapChainForHwndfailure no longer prints "QueryInterface failed".CreateRenderTargetViewcheck cannot firevoid, and in that branchhris the successfulGetBufferresult.shown_logbudget for two messagescountargument is gone; it only ever printed 0. Four presents with planes no longer silence a later present with none.section_forcommitxmem_mapped_pages.cpp.Point 2 also uncovered a case the review named: a
CreateDescriptorHeapfailure was logged by neither branch. It is now.Build evidence:
d3d12_xs_device.cppcompiled andd3d12_xs.dlllinked, 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.
@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 (atd61a0075) is still the recorded state, so this waits on that re-review.Fixed since my last comment (by reading
git diff 03c6ffe0 6270b60d):shown_logcounter).queue_presentnow hasno_plane_logandplane_log, one budget per message, and the always-0count=%uargument is gone. Four presents with planes no longer silence a later zero-plane present.FAILED(hr)afterCreateRenderTargetView). Removed. The loop is nowif (FAILED(hr)) log(... GetBuffer ...) else device->CreateRenderTargetView(...).dcb65bb9(factory->Release()restored) and03c6ffe0(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 noxmem_mapped_pages.cpp.git merge-tree --write-tree origin/main 6270b60dexits 0 (mainc4b8a41b), andgit diff --checkexits 0. CI is green: Windows, gfx1013 and Linux Python pass;/O2and coverage are skipped.SHOULD
CreateRenderTargetViewamong the logged failures, says "every silent-return point" (present_to_windowstill has a silentif (!window) return false;), and says "All 13 present-related tests pass", while your comments say onlyd3d12_xs_shimwas built and nothing was run. Please make it match the current diff and what was actually measured.97fcd1eb("always commit fresh slot in section_for()", which is #3366) plus its reverte0383059. The net effect is zero, but a merge commit would bring both intomain's history. Dropping both commits (interactive rebase and a force-push) keeps this PR to present-path logging only.present_to_windowrefusing with a nullstepsorcount, 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.
@KelboLive on GitHub · 2026-11-29 17:03 UTC · original
Added the missing fixture. Head is now
c000fa711.tests/startup_present_log_check.cppcalls the presenter's refusal path six times with an empty present and reads back whatlog()appends toX2W_TRAP_LOG.Why a seam.
present_to_windowis internal tod3d12_xs_device.cpp(the whole translation unit is one anonymous namespace), so the fixture cannot call it from another TU, andqueue_presentonly 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.hlog_opens(),gameinput.cpp), so this adds one:It sits after the anonymous namespace closes, is not in the
.def, and nothing but the fixture calls it.What it asserts
--controlreads a five-line budget and must printFAIL:— registered withPASS_REGULAR_EXPRESSION "FAIL: ".Sensitivity. Replacing the
log(...)in the refusal branch with(void)0;and rebuilding makes the plain run fail:Results (
ctest --preset dev --no-tests=error -R "^startup_present", MSVC 14.44.35207):Not measured: the other four messages.
queue_present's two andcreate_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.@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:if (factory) factory->Release();is back atsrc/startup_stubs/d3d12_present.inl:128.else log: each log is inside its ownSUCCEEDED(hr)step, QueryInterface:125, CreateDescriptorHeap:132, GetBuffer:137.:137-138logs a GetBuffer failure, otherwise creates the view.count=%u: separateno_plane_log/plane_logatsrc/startup_stubs/d3d12_xs_device.cpp:7373-7381, and the argument is gone.section_forchange: not in the net diff (4 files, +147/-6).SHOULD:
startup_present_logandstartup_present_log_controlboth delete and then append to the same fixed%TEMP%\x2w_present_log_check.log(tests/startup_present_log_check.cpp:69-74), so underctest -jone 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:
--controlpasses whenever the count is not 5, including when nothing is logged, so it only shows thatcheckcan fail. The test-onlyx2w_present_to_window_refusal_for_test()(d3d12_xs_device.cpp:7747) is compiled into the productiond3d12_xsDLL. Theprpreset 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.@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 atc000fa71replaces the earlier CHANGES_REQUESTED, so nothing is blocking the merge.What the delta adds (
git diff 6270b60d c000fa71: 3 files, +121): a test seamx2w_present_to_window_refusal_for_test()after the anonymous namespace closes ind3d12_xs_device.cpp, the fixturetests/startup_present_log_check.cpp, andtests/cmake/startup_present_log.cmake. The glob picks the fragment up (file(GLOB X2W_TEST_FRAGMENTS ... tests/cmake/*.cmake)), and it linksd3d12_xs_device_obj, the same object targetoffscreen_checkuses. The seam's callpresent_to_window(nullptr, nullptr, 0, nullptr, 1)goes into the!queue || !steps || !count || !plane_surfacesbranch, which is the one guarded byfirst_calls(fail_log, 4).append_logreadsX2W_TRAP_LOGon every call, so setting it inmainbefore the first call works. Net PR diff vs main: 4 files, +147/-6.git merge-tree --write-tree origin/main c000fa71rc 0,git diff --checkrc 0.SHOULD (follow-up, not blocking):
ctest -j. I agree with Leyukaka's point. Both tests delete and append to the same%TEMP%\x2w_present_log_check.log. Theprpreset does not run them (the Windows job's log shows100% tests passed out of 82, and the new test is not mentioned). After the merge, though, the push-to-main job runsctest --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_logon both tests, or put the mode or PID in the file name.every silent-return/13 tests/CreateRenderTargetViewlines (2 matching lines). The squash or merge message should describe the four-file diff and the one covered message.NIT:
3.
--controlpasses whenever the count is not 5, including 0. It only shows thatcheckcan fail. The author's(void)0mutation 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_xsobject. It is not in the.def, so it is never exported. It is dead code there.Merged at
c000fa71(merge commit26df1826) under the review rule (0 MUST, mergeable, no standing CHANGES_REQUESTED, CI green).AI-assisted review.
@KelboLive on GitHub · 2026-11-29 17:19 UTC · original
Re-checked at
b195a55aa, against currentmainrather than the branch's base.The branch is based on
f5a6f6bae, about 300 commits back, so I merged it intoupstream/mainlocally to see whether it still applies:d3d12_xs_device.cppneeded a 3-way merge, and it resolved.cmake --build out/build/dev --target startup_present_log d3d12_xs_shim— both link.ctest --preset dev --no-tests=error -R "^startup_present"→ 15/15 passed, includingstartup_present_logandstartup_present_log_control.Other checks:
dumpbin /exports d3d12_xs.dllhas nopresent_to_windowand nox2w_present_to_window_refusal_for_test.failed=%dint,queue/steps/surfaces=%pvoid*,count=%uwithPresentedPlanes::count(unsigned),0x%08lxwithunsigned long.d3d12_present.inl,d3d12_xs_device.cpp,tests/cmake/startup_present_log.cmakeandtests/startup_present_log_check.cpp.xmem_mapped_pages.cppis untouched.d61a0075are all present in this head: factory release restored, each step logs inside its own block, the deadCreateRenderTargetViewcheck gone, one counter per message, and thesection_forcommit dropped.I also found and fixed two things in my own fixture:
d3d12.handpresent_planes.hwere 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.