[PR #1293] [CLOSED] runtime: opt-in presentation-path diagnostics (RT-PRESENT-PROBE) #1324

Closed
opened 2026-11-26 20:20:51 +01:00 by 4ld0 · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/ubiquitarianism/leonida/pull/1293
Author: @Moriz82
Created: 11/24/2026
Status: ❌ Closed

Base: main ← Head: split/rt-present-probe


📝 Commits (1)

  • 6e8b29c runtime: opt-in presentation-path diagnostics (RT-PRESENT-PROBE)

📊 Changes

7 files changed (+539 additions, -10 deletions)

View changed files

📝 docs/d3d12_vulkan.md (+20 -0)
📝 runtime/CMakeLists.txt (+11 -0)
📝 runtime/shims/d3d12_com.cpp (+8 -3)
📝 runtime/shims/xbox_present.cpp (+3 -2)
➕ runtime/src/present_probe.h (+31 -0)
📝 runtime/src/vulkan_present.h (+8 -5)
➕ runtime/test/present_probe_test.cpp (+458 -0)

📄 Description

Claimed in the coordination issue as: RT-PRESENT-PROBE (claim).

Part of the split of #984 into small pull requests.

Depends on: none
Overlaps: #984 (integration source; there these lines were unconditional local diagnostics, here they are behind a switch). #498 summarizes the existing capture and shader-lookup lines in boot_trace.py and reads none of the new ones. #576 dumps thread stacks of a hung boot. Neither logs the presentation path.

What and why

A boot that reaches its frame loop can present frames that show nothing. The log then says only that PresentX returned, not where the picture was lost. Two switches, both off by default, answer that.

LEONIDA_PRESENT_PROBE=1 writes [rt] present-probe: lines to stderr:

  • ClearRenderTargetView: the target's resource id, mip and layers, the colour and the rectangle count.
  • each draw: whether it was recorded or dropped because no viewport was set, with the pipeline id, target count, first target, viewport, scissor and vertex or index count.
  • each PresentX call: plane count, whether parameters were given, the suspended and registered states, and per plane the token, resource count, first resource id and flags. A refused call names the check and the HRESULT.
  • each present the presenter submits: the path (blit, compose or blank), the source id, whether it still resolves, its format, extent, mips, layers and samples, and running counts per path. A present queued behind held work is counted.

Each kind of line is written for the first few events and then for every 600th (draws: every 1200th; refusals: the first 40). The lines hold ids, sizes, formats, counts and result codes. No line holds buffer or texture contents.

LEONIDA_CAPTURE_SOURCE=1, together with the existing LEONIDA_CAPTURE=<dir>, also copies mip 0 of the texture the title presented, for the same frames the capture writes. It writes <dir>/source_NNNNN.ppm and one line of <dir>/source_index.txt with the path, format, extent, tracked layout, mean RGB and the number of non-zero texels. The frame capture says what was shown. The source capture says what was handed over, so a black frame can be told from a failed blit or composition. A texture that no tracked operation wrote is listed as never written and not read.

With both unset, no line is written, no counter is kept and no extra Vulkan work is submitted. The switches are read once: the capture switch when the presenter is created, the probe switch at the first probed call.

The refusal lines wrap the values present_x already returned, so the results of PresentX are unchanged.

Tested

Cross-built on CachyOS Linux 7.3 with clang-cl 23.1.5 and the xwin SDK. Ran the Windows tests one at a time under Wine 11.22 (distribution build, fresh prefix) on a Ryzen 5 5600X, 16 GB RAM, NVIDIA GeForce RTX 4070 12 GB, driver 620.73.04.

cmake --build runtime/build/boot --target present_probe_test xbox_present_test d3d12_present_test d3d12_draw_test d3d12_com_test vk_presenter_sync_test gta6rt -j6
wine present_probe_test.exe
wine present_probe_test.exe --on
wine xbox_present_test.exe
wine d3d12_present_test.exe
wine d3d12_draw_test.exe
wine d3d12_com_test.exe
wine vk_presenter_sync_test.exe
python3 -I scripts/check_no_game_data.py
python3 -I tests/test_docs_env_vars.py
git diff --check

present_probe_test clears a target, issues one draw without a viewport and one full-screen draw, then calls PresentX with one plane, no plane, an overlay plane, three planes and a token that was never handed out. It captures stderr and has LEONIDA_CAPTURE on in both forms.

Form Base implementation with this test This change
present_probe_test (both unset) Passed: 3 frames presented, 2 calls refused, 0 probe lines, 0 source files. Passed with the same result in 3 runs.
present_probe_test --on Failed at the first probe expectation (line 414): no ClearRenderTargetView line. Passed in 3 runs: 20 probe lines (2 clears, 2 draws of which 1 not recorded, 5 PresentX of which 2 refused, 3 submits: blit, blank, compose), 2 source images and their index lines match the yellow scene.

Both forms present the same 3 frames (yellow, black, yellow), each checked pixel by pixel, and return the same HRESULTs.

Two further runs of each form stopped before any probed call, at CreateWindowExW (line 373), while an unrelated job on the same desktop had some thousand crashing Wine processes open. The runs before and after it passed.

Other test Result
d3d12_draw_test, d3d12_com_test, vk_presenter_sync_test Passed.
xbox_present_test Exit 1 at line 1192 on the base and on this change: the frame extent after the test resizes its window. The desktop here is a tiling compositor that sizes the window itself. Every case before it passed on both.
d3d12_present_test Exit 1 at line 478 on the base and on this change: the same window-extent expectation.
python3 -I scripts/check_no_game_data.py, tests/test_docs_env_vars.py, git diff --check Passed.
Python CI loop over the non-semantic test files, and python3 -I scripts/run_semantic_tests.py tests/semantic -j 2 One failing file, tests/test_imhex_patterns.py, as on the base. None added. Semantic suite: 470 files, 6,168 tests, 0 failing files.

Rebased before opening. The cut was made on 6293c1c4f, and main then changed record_draw (it now tests every bound viewport), which conflicted with the probe's draw line. This head is the same change on main 6261ca916; the probe's "not recorded" test now uses main's any_nonempty_viewport(). On the rebased head these were run again and pass: the build of gta6rt, present_probe_test in both forms (2 runs each, same lines and files as above), d3d12_draw_test without the probe (0 probe lines) and with LEONIDA_PRESENT_PROBE=1 (14 probe lines), and d3d12_com_test. The base-implementation column, xbox_present_test, d3d12_present_test, vk_presenter_sync_test and the Python loops are from the head before the rebase.

Not run: native Windows, Proton, AMD and Intel GPUs, the Vulkan validation layer (not installed), CTest itself (the executables were started directly), and a boot of the title.

GPUs tested: NVIDIA GeForce RTX 4070, driver 620.73.04, Linux under Wine 11.22.
AI-assisted: yes (Claude Code).

Checklist

  • One commit based on upstream main 6261ca916. Merges cleanly.
  • One topic: two opt-in diagnostic switches, their documentation and their test.
  • Off by default. The unset form of the test shows no line, no file and the same frames.
  • Synthetic test, no game data. Content guard and whitespace check passed.
  • No translator rule changed.

🤖 Generated with Claude Code


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/ubiquitarianism/leonida/pull/1293 **Author:** [@Moriz82](https://github.com/Moriz82) **Created:** 11/24/2026 **Status:** ❌ Closed **Base:** `main` ← **Head:** `split/rt-present-probe` --- ### 📝 Commits (1) - [`6e8b29c`](https://github.com/ubiquitarianism/leonida/commit/6e8b29ce0e9ab69834dfe199bbd0d14593241a74) runtime: opt-in presentation-path diagnostics (RT-PRESENT-PROBE) ### 📊 Changes **7 files changed** (+539 additions, -10 deletions) <details> <summary>View changed files</summary> 📝 `docs/d3d12_vulkan.md` (+20 -0) 📝 `runtime/CMakeLists.txt` (+11 -0) 📝 `runtime/shims/d3d12_com.cpp` (+8 -3) 📝 `runtime/shims/xbox_present.cpp` (+3 -2) ➕ `runtime/src/present_probe.h` (+31 -0) 📝 `runtime/src/vulkan_present.h` (+8 -5) ➕ `runtime/test/present_probe_test.cpp` (+458 -0) </details> ### 📄 Description Claimed in the coordination issue as: RT-PRESENT-PROBE ([claim](https://github.com/ubiquitarianism/leonida/issues/14#issuecomment-7144859037)). Part of the split of #984 into small pull requests. Depends on: none Overlaps: #984 (integration source; there these lines were unconditional local diagnostics, here they are behind a switch). #498 summarizes the existing capture and shader-lookup lines in `boot_trace.py` and reads none of the new ones. #576 dumps thread stacks of a hung boot. Neither logs the presentation path. ### What and why A boot that reaches its frame loop can present frames that show nothing. The log then says only that `PresentX` returned, not where the picture was lost. Two switches, both off by default, answer that. `LEONIDA_PRESENT_PROBE=1` writes `[rt] present-probe:` lines to stderr: - `ClearRenderTargetView`: the target's resource id, mip and layers, the colour and the rectangle count. - each draw: whether it was recorded or dropped because no viewport was set, with the pipeline id, target count, first target, viewport, scissor and vertex or index count. - each `PresentX` call: plane count, whether parameters were given, the suspended and registered states, and per plane the token, resource count, first resource id and flags. A refused call names the check and the `HRESULT`. - each present the presenter submits: the path (`blit`, `compose` or `blank`), the source id, whether it still resolves, its format, extent, mips, layers and samples, and running counts per path. A present queued behind held work is counted. Each kind of line is written for the first few events and then for every 600th (draws: every 1200th; refusals: the first 40). The lines hold ids, sizes, formats, counts and result codes. No line holds buffer or texture contents. `LEONIDA_CAPTURE_SOURCE=1`, together with the existing `LEONIDA_CAPTURE=<dir>`, also copies mip 0 of the texture the title presented, for the same frames the capture writes. It writes `<dir>/source_NNNNN.ppm` and one line of `<dir>/source_index.txt` with the path, format, extent, tracked layout, mean RGB and the number of non-zero texels. The frame capture says what was shown. The source capture says what was handed over, so a black frame can be told from a failed blit or composition. A texture that no tracked operation wrote is listed as `never written` and not read. With both unset, no line is written, no counter is kept and no extra Vulkan work is submitted. The switches are read once: the capture switch when the presenter is created, the probe switch at the first probed call. The refusal lines wrap the values `present_x` already returned, so the results of `PresentX` are unchanged. ### Tested Cross-built on CachyOS Linux 7.3 with clang-cl 23.1.5 and the xwin SDK. Ran the Windows tests one at a time under Wine 11.22 (distribution build, fresh prefix) on a Ryzen 5 5600X, 16 GB RAM, NVIDIA GeForce RTX 4070 12 GB, driver 620.73.04. ```sh cmake --build runtime/build/boot --target present_probe_test xbox_present_test d3d12_present_test d3d12_draw_test d3d12_com_test vk_presenter_sync_test gta6rt -j6 wine present_probe_test.exe wine present_probe_test.exe --on wine xbox_present_test.exe wine d3d12_present_test.exe wine d3d12_draw_test.exe wine d3d12_com_test.exe wine vk_presenter_sync_test.exe python3 -I scripts/check_no_game_data.py python3 -I tests/test_docs_env_vars.py git diff --check ``` `present_probe_test` clears a target, issues one draw without a viewport and one full-screen draw, then calls `PresentX` with one plane, no plane, an overlay plane, three planes and a token that was never handed out. It captures stderr and has `LEONIDA_CAPTURE` on in both forms. | Form | Base implementation with this test | This change | |---|---|---| | `present_probe_test` (both unset) | Passed: 3 frames presented, 2 calls refused, 0 probe lines, 0 source files. | Passed with the same result in 3 runs. | | `present_probe_test --on` | Failed at the first probe expectation (line 414): no `ClearRenderTargetView` line. | Passed in 3 runs: 20 probe lines (2 clears, 2 draws of which 1 not recorded, 5 `PresentX` of which 2 refused, 3 submits: blit, blank, compose), 2 source images and their index lines match the yellow scene. | Both forms present the same 3 frames (yellow, black, yellow), each checked pixel by pixel, and return the same `HRESULT`s. Two further runs of each form stopped before any probed call, at `CreateWindowExW` (line 373), while an unrelated job on the same desktop had some thousand crashing Wine processes open. The runs before and after it passed. | Other test | Result | |---|---| | `d3d12_draw_test`, `d3d12_com_test`, `vk_presenter_sync_test` | Passed. | | `xbox_present_test` | Exit 1 at line 1192 on the base and on this change: the frame extent after the test resizes its window. The desktop here is a tiling compositor that sizes the window itself. Every case before it passed on both. | | `d3d12_present_test` | Exit 1 at line 478 on the base and on this change: the same window-extent expectation. | | `python3 -I scripts/check_no_game_data.py`, `tests/test_docs_env_vars.py`, `git diff --check` | Passed. | | Python CI loop over the non-semantic test files, and `python3 -I scripts/run_semantic_tests.py tests/semantic -j 2` | One failing file, `tests/test_imhex_patterns.py`, as on the base. None added. Semantic suite: 470 files, 6,168 tests, 0 failing files. | **Rebased before opening.** The cut was made on `6293c1c4f`, and `main` then changed `record_draw` (it now tests every bound viewport), which conflicted with the probe's draw line. This head is the same change on `main` `6261ca916`; the probe's "not recorded" test now uses `main`'s `any_nonempty_viewport()`. On the rebased head these were run again and pass: the build of `gta6rt`, `present_probe_test` in both forms (2 runs each, same lines and files as above), `d3d12_draw_test` without the probe (0 probe lines) and with `LEONIDA_PRESENT_PROBE=1` (14 probe lines), and `d3d12_com_test`. The base-implementation column, `xbox_present_test`, `d3d12_present_test`, `vk_presenter_sync_test` and the Python loops are from the head before the rebase. Not run: native Windows, Proton, AMD and Intel GPUs, the Vulkan validation layer (not installed), CTest itself (the executables were started directly), and a boot of the title. GPUs tested: NVIDIA GeForce RTX 4070, driver 620.73.04, Linux under Wine 11.22. AI-assisted: yes (Claude Code). ### Checklist - [x] One commit based on upstream main `6261ca916`. Merges cleanly. - [x] One topic: two opt-in diagnostic switches, their documentation and their test. - [x] Off by default. The unset form of the test shows no line, no file and the same frames. - [x] Synthetic test, no game data. Content guard and whitespace check passed. - [x] No translator rule changed. 🤖 Generated with [Claude Code](https://claude.com/claude-code) --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
4ld0 2026-11-26 20:20:51 +01:00
Sign in to join this conversation.
No labels
bug
pull-request
No milestone
No project
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.

Dependencies

No dependencies set

Reference
starred/leonida#1324
No description provided.