Repository navigation
d3d12_present_test: check the presented images through the capture, GDI screen read only where it works - #1908
Merged
ItsNotRexed merged 1 commit intoNov 22, 2026
Conversation
…DI screen read only where it works Under Wine's macOS driver the test failed at its last step, the GDI read of the screen: GetPixel on the screen DC returns CLR_INVALID there for every pixel, even one GDI painted itself (BitBlt from the screen DC fails too), and the window's own DC holds Wine's GDI surface (white), not the image presented through the Metal layer. The presenter itself was fine: all the injected-failure checks passed, MoltenVK made 320x240 and 400x300 swapchains at contents scale 1.0, and the driver reported no out-of-date presents. The "present failed" lines in that log (VkResult -1000001004 twice, then -1 = VK_ERROR_OUT_OF_HOST_MEMORY) are the test's own injections; markers around them showed each line inside its injection. The test now enables the presenter's capture and checks the whole presented image for the clear colour at the swapchain's size after the first 60 frames, after the resize and at the end, on every platform. The screen check stays where GDI can read the screen; a CLR_INVALID there is reported and skipped instead of failing. The test also says on stderr that the next three "present failed" lines are expected, since they were read as faults twice. Checked under CrossOver's Wine 11 with MoltenVK 1.4.3 on an Apple M3 Max: the test passes, and with the clear colour changed the capture check fails at the first 60 frames.
2 tasks done
Serrambi
approved these changes
Nov 22, 2026
Serrambi
left a comment
Contributor
There was a problem hiding this comment.
Reviewed 17a27f23 and tested on NVIDIA GeForce RTX 5070 Ti (driver 610.88, Windows 11 Pro, MSVC 19.50.35719.0, Vulkan SDK 1.4.363.0): approve.
Code review (runtime/test/d3d12_present_test.cpp, docs/d3d12_vulkan.md, runtime/README.md)
- Enabling
presenter->enable_capture()and checking the captured swapchain image after the initial 60 frames, after the 400×300 resize, and after the injected failure cases validates the actual presented pixels even whenGetPixel(screen, ...)cannot read the screen (CLR_INVALID/ non-foreground window). - Announcing the three expected injected
[rt] d3d12: present failedlines before running them makes stderr much clearer. - Minor non-blocking note:
presented_image_is_clear_colour()handles bothVK_FORMAT_B8G8R8A8_UNORMandVK_FORMAT_B8G8R8A8_SRGBswizzles while comparing raw bytes against linear51, 153, 230, which is exact on UNORM swapchains and would encode differently if a surface ever chose an_SRGBformat.
Checks on 17a27f23
d3d12_present_test.exe(default): passed (EXIT=0, capture colour confirmed;the window is not in front: on-screen colour check skipped)d3d12_present_test.exe(LEONIDA_VK_VALIDATION=1): passed (EXIT=0, 0 Vulkan validation errors, capture colour confirmed)ctest --test-dir runtime/build --output-on-failure -R "^d3d12_present$": passed 1/1
Contributor
|
Tested on native Windows + NVIDIA at head
|
Contributor
|
Tested 17a27f2, merged onto
AI-assisted (Claude Code). |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Claimed in the coordination issue as: item 3 of #1745 (comment) (
d3d12_presenton a Mac under Wine)What and why
d3d12_presentfailed on a Mac under Wine atline 311: pixel != CLR_INVALID.The swapchain recreation path is fine. The
present failed (VkResult -1000001004)lines (twice) and(-1)in the log are the test's own injections:fail_next_submit = VK_ERROR_OUT_OF_HOST_MEMORY.I bracketed each injection with temporary markers, and each line falls inside its own. The test already says "0 real out-of-date presents".
MVK_CONFIG_LOG_LEVEL=2shows MoltenVK creating the swapchains at exactly 320×240 and 400×300 (contents scale 1.0).What fails is the last step. It reads the colour back from the screen with GDI, and Wine's macOS driver can't do that. A standalone probe shows
GetPixelon the screen DC returnsCLR_INVALIDeven for a pixel GDI itself painted, andBitBltfrom the screen fails as well. The window DC returns Wine's white GDI surface, not the Metal layer's content.The change, test and docs only, no runtime change:
enable_capture(), the pathxbox_present_testalready requires in CI). It checks that the whole presented image holds the clear colour at the swapchain's size three times: after the first 60 frames, after the resize to 400×300, and at the end. So the presented image is checked on every platform.GetPixelreturnsCLR_INVALIDdoes the test print why and skip that one step; a wrong colour on screen still fails. Note this also applies on Windows, whereCLR_INVALIDused to fail the test; the capture check covers the colour there now.present failedlines are expected. They have been read as a fault at least twice, including the Intel UHD 770 finding in Coordinating who works on what (6) (moved to #1548) #1380. That finding failed at a different line (the on-screen colour,std::abs(r - 51) …), and this PR doesn't claim to fix it.Tested
Apple M3 Max, macOS 27.3, Wine 11.0 (CrossOver 26.3's loader) with MoltenVK 1.4.3 (main 5189f8de with SPIRV-Cross 57e4efcc). Windows build cross-compiled on the Mac with clang-cl 23.1.6, lld-link 22.1.8 and the xwin 10.0.26100 SDK (
runtime/cmake/clang-cl-xwin.cmake).d3d12_presentunder Wine: before, FAIL (pixel != CLR_INVALID); after, PASS ("colour confirmed in the presented images"). I re-ran it myself after the delegate's run.presented image 320x240: 51,153,204 at 0,0).xbox_present_testandvk_presenter_sync_testpass under Wine.ctest(runtime/build/mac, MoltenVK): 33/33.xbox_present_testalready exercises there in CI.No game files. AI-assisted.
Checklist
docs/design.md, with how it was confirmed. (No translator change.)🤖 Generated with Claude Code