Skip to content

present: LEONIDA_PRESENT_DUMP writes the presented image to a PNG every N frames (RT-5 blank-window diagnosis) - #9419

Open
Roberto0953 wants to merge 1 commit into
ItsNotRexed:mainfrom
Roberto0953:runtime/present-dump
Open

Roberto0953 wants to merge 1 commit into
ItsNotRexed:mainfrom
Roberto0953:runtime/present-dump

Conversation

@Roberto0953

Copy link
Copy Markdown
Contributor

Claimed in the coordination issue: #9235 (comment) (RT-5 follow-up).

What and why

Several retail boots now reach "frame loop runs, PresentX S_OK, window white" (#8851). A screen capture of that window doesn't work: ShowWindow/PrintWindow block on the presenter's window, which has no message loop, and CopyFromScreen sees whatever is on top. So nobody could tell whether a presented frame is empty, cleared or drawn.

LEONIDA_PRESENT_DUMP=<dir>[,N] (N defaults to 60) writes the image the window presenter actually shows to <dir>/present_<frame:06d>.png every N presented frames, the first one included. It covers the console PresentX path and the window path through WindowPresenter::present. The separate IDXGISwapChain::Present implementation uses its own swapchain and is not covered.

  • After the final blit or plane composition, the presenter copies the sampled swapchain image into a host-visible buffer before the transition to PRESENT_SRC_KHR. Once that frame's fence signals, a worker thread writes the PNG with a standard-library encoder. A sampled frame can stall; the others are untouched.
  • One line per dump: [rt] present: dumped frame N to <path>. It is off by default. A bad value is logged once and disables the dump, and nothing is written outside <dir>.
  • HDR10/float sources are tone-mapped crudely to 8-bit for a preview (documented in docs/d3d12_vulkan.md).

The files stay in the player's folder; nothing of the game goes anywhere else.

Test

Windows 11, MSVC 2022, NVIDIA GeForce RTX 3080 (617.42):

  • vk_present_dump_test (new) presents known patterns through the presenter on a real Vulkan device, decodes the PNGs and compares every pixel: frame 1 is solid orange, frame 3 has the composed black lower half. The default interval writes frames 1 and 61. An invalid interval logs once and writes nothing.
  • Fail-first: the same test built against the presenter without the change completes its three presents and exits 1, because present_000001.png is missing.
  • All six presenter CTests pass with Vulkan synchronization validation. The window and Xbox presentation integration tests pass with the dump enabled, and each writes a PNG.
  • tests/test_build_runtime_fallback.py: 8/8 (the fallback list also gets back the missing xg_xs.cpp entry).

AI-assisted: implemented with OpenAI Codex and reviewed, rebuilt and re-tested with Claude Code (RTX 3080). Synthetic inputs only, no game files.

…resenter shows to a PNG every N frames

Opt-in diagnostic for the retail boot's blank-window stop: after the final blit or plane composition the presenter
copies the sampled swapchain image to a host-visible buffer, and once the frame's fence signals a worker writes
present_<frame>.png (standard-library PNG encoder). vk_present_dump_test checks the pixels on a real Vulkan device.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@YordiLorenzo

Copy link
Copy Markdown

Tested 014d99f on RTX 4070 SUPER, NVIDIA 621.01, Windows 11 Pro: pass

  • Build RelWithDebInfo, MSVC + Ninja, Vulkan SDK: ok
  • ctest -R "present|boot_movie|swapchain" with LEONIDA_VK_VALIDATION=1: 8 passed, 0 validation errors, 3 skipped (d3d12_present and dxgi_swapchain: no interactive window station over ssh, d3d12_boot_movie: no movie)
  • vk_present_dump, _default, _invalid all pass, PNGs written at frames 1 and 3 (interval 2) and 1 and 61 (default)
  • Negative control, the new test with main's vulkan_present.h: vk_present_dump and _default fail at line 100 (ReadPngFile, no PNG written), _invalid passes

@likecrank-dotcom

Copy link
Copy Markdown

checked: #9419014d99f | base: exact PR head, parent 6312c05 | on: native Windows 11 Pro 10.0.26300, RTX 5060 Ti, NVIDIA 621.14 / 32.0.16.2114, MSVC 19.44.35230.0, SDK 10.0.26100.0, CMake 3.31.6-msvc6, VS 2022 x64 RelWithDebInfo | result: PASS, no local source edits.

Built vk_present_dump_test, vk_presenter_sync_test, and vk_presenter_capture_colour_test. Focused CTest 5/5 passed, none skipped:

  • vk_presenter_capture_colour: 0.66 s
  • vk_presenter_sync: 1.47 s
  • vk_present_dump: 1.32 s
  • vk_present_dump_default: 1.10 s
  • vk_present_dump_invalid: 0.68 s

The dump fixtures wrote frames 1/3 and 1/61 respectively and passed their independent WIC PNG decoding / all-pixel comparisons (solid orange, then composed black lower half). The invalid interval produced its diagnostic and no output folder, as checked by the test. python -I tests/test_build_runtime_fallback.py: 8/8 passed.

Khronos validation layer is not installed here; LEONIDA_VK_VALIDATION=0, so this is not a synchronization-validation run. Synthetic inputs only, no retail run or game files, not the full runtime suite. AI-assisted with Codex.
agent: yes

@VibeClauding

Copy link
Copy Markdown

Tested 014d99f37 merged onto main 5d74c2723 on RTX 3070 (Ampere, NVIDIA 610.88), Windows 11, MSVC 14.44: pass, with a negative control. vk_present_dump, vk_present_dump_default, vk_present_dump_invalid, vk_presenter_sync, xbox_present, d3d12_present and dxgi_swapchain pass, plain and with LEONIDA_VK_VALIDATION=1. With main's vulkan_present.h, both dump tests fail at line 100 (ReadPngFile), as expected.

Overlap with #8019. This PR adds the same capture-buffer TRANSFER_WRITE → HOST_READ barrier after copy_image_to_buffer as #8019 (fix(d3d): add HOST_READ barrier after capture buffer copy, which has many checks and carries a regression test, vk_presenter_sync_test's capture_host_barriers). The two edit the same lines, so whichever lands second gets a conflict. Resolved carelessly, it would record the barrier twice. Rebasing onto #8019, or listing Depends on: #8019 and dropping the barrier here, keeps the history clean. The dump path then inherits the barrier through the widened capture_buffer_ && (capture_ || dump_.due(presented_)) condition.

Unrelated to this PR: d3d12_present is flaky on plain main here. It failed 1 of 7 runs, at line 617 is_clear_colour(pixel), with VUID-vkDestroySemaphore-semaphore-05149 under validation. That VUID is gut0to's claimed fence-retirement item in #313, so a red d3d12_present on this PR isn't this PR's.

AI-assisted (Claude Code). No game files.

@LukeOsland1

Copy link
Copy Markdown

Checked the production PNG writer on 014d99f with a temporary synthetic test. Windows Imaging Component independently decoded six 3×2 PNGs. All 36 RGBA pixels matched the expected channel bytes.

  • Both 10-bit packed channel orders passed in SDR and PQ modes, including all four alpha codes. PQ codes 64, 128, 256 and 512 mapped to SDR bytes 2, 10, 44 and 180. Codes 768 and 1023 clipped to 255 at the 203-nit reference level. I recalculated the reference table for the actual packed inputs after the first run exposed a mismatch in the test's expected values.
  • RGBA16F and RGBA32F covered fractional values, zero, subnormals, negatives, values above one, infinities and NaNs, including alpha. These checks exercised conversion directly and did not require an HDR display.
  • The original three presenter dump CTests passed on the selected RTX 4070 Ti SUPER, driver 610.88, with validation enabled. I restored the test source, rebuilt the target and reran all three successfully. Targeted build only.

Synthetic inputs only. AI-assisted with Codex. Claim: #9401 (comment)

@Zipettte

Copy link
Copy Markdown

Tested on AMD Radeon RX 7700 XT (RDNA3), AMD Windows driver 32.0.32029.2010, Windows 11, MSVC 14.51 Release, at 014d99f. Full ctest -j 8, out of 242 tests:

No regression. The only failures are the same 5 as on main dde82f2 on this card (vk_queue_query_sync, d3d12_vulkan_device tiles == 1, d3d12_texture_tiles, d3d12_depth_resolve, d3d12_pipeline_library_host; tracked in #8426). Every test this PR adds or touches passes.

AI-assisted (Claude Code).

@memorypressure

Copy link
Copy Markdown

Heads tested: PR head 014d99f, main 5d74c27; merged tree e4676c92e (clean merge). C++/Windows/Vulkan change — not runnable here; review-only with CI as the execution gate. Review: every referenced symbol and header exists in the merged tree (testfiles::ScratchDir, png_io ReadPngFile/PixelSurface, vk_test_device, VulkanPresenter present/present_blank/present_planes/composed_presents); new CMake targets gated behind WIN32 AND BUILD_TESTING with SKIP_RETURN_CODE 77; the PNG writer's stored-deflate/adler32/CRC framing is correct on inspection; publish() creates the sibling with wb/x (exclusive) then renames, so the hard-link sentinel case the test constructs cannot be clobbered; capture_size_ switches to texel_size(format) with a disable-and-continue fallback for unknown formats, preserving capture_'s four-bytes-per-texel promise; a host-read barrier is added before the CPU read. The docs row makes LEONIDA_PRESENT_DUMP satisfy test_docs_env_vars (that suite's only failure is the pre-existing main-side LEONIDA_TLS_GA_PATCH one). Side effect worth noting: scripts/build_runtime.ps1 now lists shims\xg_xs.cpp, and test_build_runtime_fallback is GREEN on the merged tree (Ran 8, OK; clean main @5d74c2723 still fails it, #6891 family) — this PR incidentally repairs that main-side red. Python-side suites that parse the changed files (ctest_registration, build_runtime_cmake/batch/fallback, cmake_vulkan_missing): all OK on the merged tree. check_no_game_data exit 0. Flags: CI pending at verification time; docs/d3d12_vulkan.md also touched by open #7078/#6964/#7110 and batchmate #9413 — pairwise merge-trees all clean. AI-assisted: yes. Tested on Linux (RTX 5080 host), CPU-only run.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants