d3d12: a failed present is named, and a run of the same failure is logged at its 1st, 10th, 100th, ... #138

Closed
Andretuta wants to merge 1 commit from upstream-pr/138 into main
Andretuta commented 2026-11-24 02:26:14 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by Andretuta on 2026-11-24T02:26:14Z.


Carried over from old PR 9869 by Amitoxx in the original Leonida repository, which went private on 23 Nov 2026. The code is the branch old-pr/9869, exactly that PR's last commit. All carried-over PRs are listed in #17.
Opened as a draft, and the CI runs the opening started were cancelled so 250 PRs don't fill the queue. Re-run CI here when you review it.
Amitoxx: this is your work. Feel free to take it over, by pushing to the branch or opening your own PR and closing this one.


Original description (mentions and #N references are disabled; the numbers refer to the old repository):

Claim: https://github.com/ProjectLeonida/Leonida/issues/9677#issuecomment-7116754041

What and why

present_result printed [rt] d3d12: present failed (VkResult <number>) for every failed present. A presenter that fails every frame writes one line per frame for as long as the title runs. Measured on a retail run (AMD RX 6750 XT, Windows 11, driver 32.0.21045.16010, an integration stack): every present returned VK_ERROR_OUT_OF_DATE_KHR and the log got 180,031 identical lines in 15 minutes.

The result is now named, and a run of the same result in a row is logged at its 1st, 10th, 100th, ... failure, with a closing line giving the whole length when the run ends. A different result always starts a new run and gets its own line.

Changes

  • runtime/src/present_failure_log.h (new): names and the run counter; no Vulkan or Windows header.
  • runtime/shims/d3d12_vulkan_device.cpp: present_result uses it; a static_assert checks the numbers against the real VkResult values.
  • runtime/test/present_failure_log_test.cpp (new) and its CMake entry.
  • runtime/test/d3d12_present_test.cpp, docs/d3d12_vulkan.md: the wording of the announced lines.

Tested

Windows 11, VS 2022 17.9 (MSVC 14.39.33519), Ninja RelWithDebInfo, AMD RX 6750 XT (driver 32.0.21045.16010):

  • present_failure_log, d3d12_present, xbox_present, dxgi_swapchain: 4/4 pass, all four rebuilt with the change.
  • d3d12_present_test prints the three injected failures in the new form.
  • python -I scripts/check_no_game_data.py on the six files: clean.

Not covered: these ran on dde82f27e plus this commit (cherry-picked without conflict), because main at 2d53a8055 did not compile here: acphal.cpp static_asserts on the SHAPE context sizes, and create_console_descriptor_heap in d3d12_xs_device.cpp and d3d12_vulkan_device.cpp. The same lines are still in 73ddc61cd, which this branch is rebased on. The MSVC 14.39 fix of #7146 was applied locally to build and is not part of this PR. No Wine, no NVIDIA or Intel run.

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

🤖 Generated with Claude Code

<!-- greyfinch-sync:ubiquitarianism/leonida:issue:5464915451 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/138). Originally posted by [Andretuta](https://github.com/Andretuta) on 2026-11-24T02:26:14Z. --- > Carried over from **old PR 9869** by `Amitoxx` in the original Leonida repository, which went private on 23 Nov 2026. The code is the branch `old-pr/9869`, exactly that PR's last commit. All carried-over PRs are listed in #17. > Opened as a draft, and the CI runs the opening started were cancelled so 250 PRs don't fill the queue. Re-run CI here when you review it. > `Amitoxx`: this is your work. Feel free to take it over, by pushing to the branch or opening your own PR and closing this one. --- Original description (mentions and `#N` references are disabled; the numbers refer to the old repository): Claim: https://github.com/ProjectLeonida/Leonida/issues/9677#issuecomment-7116754041 ## What and why `present_result` printed `[rt] d3d12: present failed (VkResult <number>)` for every failed present. A presenter that fails every frame writes one line per frame for as long as the title runs. Measured on a retail run (AMD RX 6750 XT, Windows 11, driver 32.0.21045.16010, an integration stack): every present returned VK_ERROR_OUT_OF_DATE_KHR and the log got 180,031 identical lines in 15 minutes. The result is now named, and a run of the same result in a row is logged at its 1st, 10th, 100th, ... failure, with a closing line giving the whole length when the run ends. A different result always starts a new run and gets its own line. ## Changes - `runtime/src/present_failure_log.h` (new): names and the run counter; no Vulkan or Windows header. - `runtime/shims/d3d12_vulkan_device.cpp`: `present_result` uses it; a static_assert checks the numbers against the real VkResult values. - `runtime/test/present_failure_log_test.cpp` (new) and its CMake entry. - `runtime/test/d3d12_present_test.cpp`, `docs/d3d12_vulkan.md`: the wording of the announced lines. ## Tested Windows 11, VS 2022 17.9 (MSVC 14.39.33519), Ninja RelWithDebInfo, AMD RX 6750 XT (driver 32.0.21045.16010): - `present_failure_log`, `d3d12_present`, `xbox_present`, `dxgi_swapchain`: 4/4 pass, all four rebuilt with the change. - `d3d12_present_test` prints the three injected failures in the new form. - `python -I scripts/check_no_game_data.py` on the six files: clean. Not covered: these ran on `dde82f27e` plus this commit (cherry-picked without conflict), because `main` at `2d53a8055` did not compile here: `acphal.cpp` static_asserts on the SHAPE context sizes, and `create_console_descriptor_heap` in `d3d12_xs_device.cpp` and `d3d12_vulkan_device.cpp`. The same lines are still in `73ddc61cd`, which this branch is rebased on. The MSVC 14.39 fix of `#7146` was applied locally to build and is not part of this PR. No Wine, no NVIDIA or Intel run. No game files. AI-assisted (Claude Code). 🤖 Generated with [Claude Code](https://claude.com/claude-code)
Snooozs commented 2026-11-24 18:01:08 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by Snooozs on 2026-11-24T18:01:08Z.


Independent check: present_failure_log passes (target rebuilt). I did not run d3d12_present, which opens a window on a PC in use. From reading: the failure still decides the HRESULT exactly as before, the mutex covers only note(), and the counters restart on any different result. One gap: VK_ERROR_FULL_SCREEN_EXCLUSIVE_MODE_LOST_EXT (-1000255000) is in the name table but not in the static_assert that keeps the two in step.

Windows 10 Pro 22H2 (19045), VS 2022 RelWithDebInfo, merged onto main 3aa975421 without conflicts, targets rebuilt, CPU only, no game files. AI-assisted (Claude Code): I read the whole diff and ran this on that machine.

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7140037966 --> Imported from [ubiquitarianism/leonida](https://github.com/ubiquitarianism/leonida/pull/138#issuecomment-7140037966). Originally posted by [Snooozs](https://github.com/Snooozs) on 2026-11-24T18:01:08Z. --- Independent check: `present_failure_log` passes (target rebuilt). I did not run `d3d12_present`, which opens a window on a PC in use. From reading: the failure still decides the HRESULT exactly as before, the mutex covers only `note()`, and the counters restart on any different result. One gap: `VK_ERROR_FULL_SCREEN_EXCLUSIVE_MODE_LOST_EXT` (-1000255000) is in the name table but not in the `static_assert` that keeps the two in step. Windows 10 Pro 22H2 (19045), VS 2022 RelWithDebInfo, merged onto `main` 3aa975421 without conflicts, targets rebuilt, CPU only, no game files. AI-assisted (Claude Code): I read the whole diff and ran this on that machine.
fiestorra commented 2026-11-30 09:46:00 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by fiestorra on 2026-11-30T09:46:00Z.


Independent verification on this machine (Windows 11, RTX 4090, MSVC 19.44.35226): it applies, builds, its tests pass - and a negative control shows that one half of the change is not covered by any test.

1. It applies and builds. merge-tree clean; cherry-picks onto main 4014af7fe without a conflict. Six files.

2. With the branch, both tests pass:

ctest -R '^(present_failure_log|d3d12_present)$'
100% tests passed, 0 tests failed out of 2

3. The control - revert only the device, keep the header and the tests:

git checkout origin/main -- runtime/shims/d3d12_vulkan_device.cpp
cmake --build … --target present_failure_log_test d3d12_present_test
ctest -R '^(present_failure_log|d3d12_present)$'
100% tests passed, 0 tests failed out of 2      <- still green

So the test does not bite on d3d12_vulkan_device.cpp. The reason is visible in what each file does:

file what the PR does covered by
src/present_failure_log.h (new) the naming, the 1st/10th/100th line, the closing count present_failure_log_test - a pure unit test of the header, which is why it passes with or without the device
shims/d3d12_vulkan_device.cpp includes the header, adds a static_assert on the VkResult numbers, and uses it to decide which failed presents get a line nothing
test/d3d12_present_test.cpp only rewords an existing fprintf message ("the next three … are expected") - no new assertion -

What that means, stated as narrowly as I can: the new formatting logic is tested; the decision to use it in the presenter is not. If a future change stopped calling it from d3d12_vulkan_device.cpp, no test in this pull request would notice.

What I am not saying: that the change is wrong. The unit test is real and it passes; the integration may well be exercised by a test elsewhere in the suite that I did not run. What I ran was the pair of tests this pull request touches, plus the one control.

How it was found: this is the first negative control on the shortlist of 122 pull requests that replay onto current main and whose tests build and pass. A passing test proves the test passes; only the control says what it covers.

Written with an AI assistant.

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7274655560 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/138#issuecomment-7274655560). Originally posted by [fiestorra](https://github.com/fiestorra) on 2026-11-30T09:46:00Z. --- Independent verification on this machine (Windows 11, RTX 4090, MSVC 19.44.35226): **it applies, builds, its tests pass - and a negative control shows that one half of the change is not covered by any test.** **1. It applies and builds.** `merge-tree` clean; cherry-picks onto `main` `4014af7fe` without a conflict. Six files. **2. With the branch, both tests pass:** ``` ctest -R '^(present_failure_log|d3d12_present)$' 100% tests passed, 0 tests failed out of 2 ``` **3. The control - revert only the device, keep the header and the tests:** ``` git checkout origin/main -- runtime/shims/d3d12_vulkan_device.cpp cmake --build … --target present_failure_log_test d3d12_present_test ctest -R '^(present_failure_log|d3d12_present)$' 100% tests passed, 0 tests failed out of 2 <- still green ``` **So the test does not bite on `d3d12_vulkan_device.cpp`.** The reason is visible in what each file does: | file | what the PR does | covered by | |---|---|---| | `src/present_failure_log.h` (new) | the naming, the 1st/10th/100th line, the closing count | **`present_failure_log_test`** - a pure unit test of the header, which is why it passes with or without the device | | `shims/d3d12_vulkan_device.cpp` | includes the header, adds a `static_assert` on the `VkResult` numbers, and uses it to decide which failed presents get a line | **nothing** | | `test/d3d12_present_test.cpp` | **only rewords an existing `fprintf` message** ("the next three … are expected") - no new assertion | - | **What that means, stated as narrowly as I can:** the new **formatting logic is tested**; the **decision to use it in the presenter is not**. If a future change stopped calling it from `d3d12_vulkan_device.cpp`, no test in this pull request would notice. **What I am not saying:** that the change is wrong. The unit test is real and it passes; the integration may well be exercised by a test elsewhere in the suite that I did not run. **What I ran was the pair of tests this pull request touches, plus the one control.** **How it was found:** this is the first negative control on the shortlist of 122 pull requests that replay onto current `main` and whose tests build and pass. **A passing test proves the test passes; only the control says what it covers.** Written with an AI assistant.
merzleckeier commented 2026-11-30 10:05:18 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by merzleckeier on 2026-11-30T10:05:18Z.


Independent follow-up to the Windows negative control. I merged 360abb21f onto 4014af7fe and added a local mode to d3d12_present_test that checks stderr from WindowPresenter::present_blank().

The mode arms the existing driver::fail_surface_formats hook before each of 137 calls on a fresh presenter. It asserts that every call consumes the injection and returns E_FAIL, and that zero frames were presented. The next call runs without injection and must return S_OK and present one frame. Markers on stderr delimit the failed calls and the recovery call.

Build During the 137 failures On the first successful frame
PR Three named VK_ERROR_OUT_OF_DATE_KHR lines at 1, 10 and 100 One summary reporting 137
Only runtime/shims/d3d12_vulkan_device.cpp restored from 4014af7fe 137 numeric VkResult -1000001004 lines No summary

The existing d3d12_present and present_failure_log assertions passed with both builds. The extra stderr assertions distinguish the two, so the existing injection hook can cover the logger wiring too.

Both GPUs reproduced the table on Wine 11.22 (Wayland), clang-cl 23.1.5 Release, CachyOS: RTX 4070 SUPER (620.73.04) and Radeon 610M/Raphael (RADV 26.3.1). Synthetic window and frames, no game data. AI-assisted.

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7275102145 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/138#issuecomment-7275102145). Originally posted by [merzleckeier](https://github.com/merzleckeier) on 2026-11-30T10:05:18Z. --- Independent follow-up to the Windows negative control. I merged `360abb21f` onto `4014af7fe` and added a local mode to `d3d12_present_test` that checks stderr from `WindowPresenter::present_blank()`. The mode arms the existing `driver::fail_surface_formats` hook before each of 137 calls on a fresh presenter. It asserts that every call consumes the injection and returns `E_FAIL`, and that zero frames were presented. The next call runs without injection and must return `S_OK` and present one frame. Markers on stderr delimit the failed calls and the recovery call. | Build | During the 137 failures | On the first successful frame | | --- | --- | --- | | PR | Three named `VK_ERROR_OUT_OF_DATE_KHR` lines at 1, 10 and 100 | One summary reporting 137 | | Only `runtime/shims/d3d12_vulkan_device.cpp` restored from `4014af7fe` | 137 numeric `VkResult -1000001004` lines | No summary | The existing `d3d12_present` and `present_failure_log` assertions passed with both builds. The extra stderr assertions distinguish the two, so the existing injection hook can cover the logger wiring too. Both GPUs reproduced the table on Wine 11.22 (Wayland), clang-cl 23.1.5 Release, CachyOS: RTX 4070 SUPER (620.73.04) and Radeon 610M/Raphael (RADV 26.3.1). Synthetic window and frames, no game data. AI-assisted.
MoonEyes commented 2026-11-30 19:11:25 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by MoonEyes on 2026-11-30T19:11:25Z.


Two merge blockers remain in the current diff. First, the tests exercise PresentFailureLog but do not assert that WindowPresenter::present_blank() wires it into stderr; the negative control shows both PR tests pass after restoring d3d12_vulkan_device.cpp. The local integration mode described in the later review is not present in this patch. Please commit equivalent assertions for repeated failures and recovery. Second, present_result_name includes VK_ERROR_FULL_SCREEN_EXCLUSIVE_MODE_LOST_EXT (-1000255000), but the parity static_assert omits it. The PR is still a draft and all available checks are cancelled; please address both, rebase, and get current CI green before merge. Coordinate the shared header with #2486 as noted in #2570.

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7288984841 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/138#issuecomment-7288984841). Originally posted by [MoonEyes](https://github.com/MoonEyes) on 2026-11-30T19:11:25Z. --- Two merge blockers remain in the current diff. First, the tests exercise `PresentFailureLog` but do not assert that `WindowPresenter::present_blank()` wires it into stderr; the negative control shows both PR tests pass after restoring `d3d12_vulkan_device.cpp`. The local integration mode described in the later review is not present in this patch. Please commit equivalent assertions for repeated failures and recovery. Second, `present_result_name` includes `VK_ERROR_FULL_SCREEN_EXCLUSIVE_MODE_LOST_EXT` (`-1000255000`), but the parity `static_assert` omits it. The PR is still a draft and all available checks are cancelled; please address both, rebase, and get current CI green before merge. Coordinate the shared header with #2486 as noted in #2570.
aslan2142 commented 2026-12-01 12:10:11 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by aslan2142 on 2026-12-01T12:10:11Z.


Marking Ready for Review since no WIP/blocker reason for draft status is specified on this PR, so it can enter normal CI and review.

(AI-assisted triage.)

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7310750726 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/138#issuecomment-7310750726). Originally posted by [aslan2142](https://github.com/aslan2142) on 2026-12-01T12:10:11Z. --- Marking Ready for Review since no WIP/blocker reason for draft status is specified on this PR, so it can enter normal CI and review. *(AI-assisted triage.)*
aslan2142 commented 2026-12-01 16:22:37 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by aslan2142 on 2026-12-01T16:22:37Z.


Closing this PR because the legacy C++ Vulkan runtime (and legacy Python shader compiler) is now considered deprecated in favor of the new Rust Vulkan runtime (in progress) and the Rust DX12 runtime (d3d12/) available now. Thank you for the contribution! If you believe this PR was closed by mistake (for example, if it still applies to active tools, d3d12/, or general docs), please feel free to reopen it.

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7317502251 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/138#issuecomment-7317502251). Originally posted by [aslan2142](https://github.com/aslan2142) on 2026-12-01T16:22:37Z. --- Closing this PR because the legacy C++ Vulkan runtime (and legacy Python shader compiler) is now considered deprecated in favor of the new Rust Vulkan runtime (in progress) and the Rust DX12 runtime (`d3d12/`) available now. Thank you for the contribution! If you believe this PR was closed by mistake (for example, if it still applies to active tools, `d3d12/`, or general docs), please feel free to reopen it.

Pull request closed

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
ProjectLeonida/mandy!138
No description provided.