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.