The on-screen colour check ran whenever the test's window was the foreground window, but the foreground window
can still be covered at its centre (an always-on-top window, or one another process showed without taking the
foreground). GetPixel on the screen DC then returned that window's pixel and the test failed, although the
presented images had already been checked: 3 of 20 runs on the Radeon iGPU and 5 of 30 on the RTX 3070 with
another application in use.
A read now counts only when WindowFromPoint at the centre, taken to its root window, is the test's window before
and after the read; otherwise the check is skipped with a line saying the centre is covered, like the existing
"not in front", HDR and CLR_INVALID skips. A pixel that is not the clear colour is read again every 50 ms for up
to a second before the EXPECT, since how long the compositor takes to show the last frame is not known; nothing is
presented meanwhile, so a wrong colour that stays still fails. A click-through layered overlay is not seen by
WindowFromPoint and still fails the check; the comment says so.
docs/d3d12_vulkan.md: the sentence on the check names the new condition.
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
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.
On a Windows HDR desktop, DWM scales SDR content by the user's configured
SDR white level, causing GDI GetPixel reads to reflect the boosted and
potentially clipped values (e.g. 66,205,255 for a 51,153,230 clear).
Use IDXGIOutput6::GetDesc1 to check if the monitor displaying the test window
is running in HDR mode (DXGI_COLOR_SPACE_RGB_FULL_G2084_NONE_P2020), and skip
the on-screen colour check with an informative message if so, avoiding false
test failures.
Tested on AMD Radeon RX 9070 (driver 26.10.1, Windows 11).
AI-assisted.
tests/test_ctest_registration.py requires every built *_test to be run by
ctest. d3d12_present_test now exits 77 when vktest::Device can't be created
with presentation, like xbox_present_test, and is registered with
SKIP_RETURN_CODE 77.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
From VictorJulianiR's review of the presenter, with Vonsek's measurements:
- A failed blit submission left the frame's fence reset with nothing to signal it, so the next present waited
forever (Vonsek: the retry reached vkWaitForFences with UINT64_MAX). An empty batch now takes the acquire
semaphore and signals the fence, and the swapchain is recreated next time to give back the image that was
never presented. If that batch fails too, or a fence wait or reset fails, the presenter stops (ok() is
false). A back buffer the device does not know is refused before an image is acquired for it.
- A swapchain recreation published the new swapchain before its per-image semaphores existed, so a failed
semaphore left a presenter that could submit with a null one. The images and semaphores are now built in
local storage and published only when all exist; on a failure the partial objects are released and the next
present tries again.
- An out-of-date present was counted as presented (Vonsek: 69 VK_SUCCESS and one VK_ERROR_OUT_OF_DATE_KHR
reached 70). presented() now counts VK_SUCCESS and VK_SUBOPTIMAL_KHR only; the caller still gets VK_SUCCESS.
d3d12_present_test gives the device and presenter their functions through a driver double that forwards to the
real driver. It counts real out-of-date presents (the frame counts allow for them) and live binary semaphores.
It reports one present as out of date and one as suboptimal, fails the second semaphore of a recreation, and
fails one blit submission. Against the old presenter the test fails at the frame count after the resize, where
this RTX 5060 Ti reported a real out-of-date present.
Docs: the presenter is named as leonida::VulkanPresenter, made by rt::d3d12::create_window_presenter, and the
test is described as 60 frames then 10 after a resize (AlxcBTW).
- vulkan_present.h: VulkanPresenter blits a back buffer (an ordinary texture
in D3D12's PRESENT state, layout tracked like any other) to an acquired
swapchain image and presents it on the same VkQueue, after the
application's work. Two frames in flight, a present semaphore per image,
FIFO for vsync else MAILBOX/IMMEDIATE, swapchain recreated on resize or
out-of-date/suboptimal, minimised windows skip presents.
- rt::d3d12::create_window_presenter / WindowPresenter: Win32 surface for a
Vulkan device created with presentation; holds the device. This is the back
end a DXGI shim or PresentX would call; the game's own front end is still
open (docs question 6), so neither is invented here.
- Standalone device enables VK_KHR_surface/win32_surface and VK_KHR_swapchain
when present; the test helper can too.
Test: d3d12_present_test opens a window and presents 60 frames through the
Xbox-ABI proxy (reset, PRESENT->RENDER_TARGET, clear, ->PRESENT, execute,
present, fence), resizes the window (swapchain recreated, scaled blit),
switches to unsynchronised presents, and reads the screen with GDI:
51,153,229 for a 51,153,230 clear. Clean under the Khronos validation layer,
as are the other GPU tests; 6/6 ctest.