Exposing VkSwapchainCreateInfoKHR::flags for VK_KHR_present_id2 / present_wait2
#1716
Unanswered
FrancoisBerard
asked this question in
Q&A
Replies: 1 comment 1 reply
-
|
Your suggests sound sensible. Could you implement what you think will work and then submit a PR so I can review and test it, and provide feedback/make revisions if required. |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Hi, and thanks for VSG.
Disclaimer: this text was drafted by Claude Code, not by me.
What I'm doing. I'm building a low-latency stereo HCI application. To synchronise LCD shutter
glasses with a 240 Hz display I need to know exactly when each frame reaches scan-out: right after
vkQueuePresentKHRI block the render thread on present-wait for that frame's id and, when itreturns, fire a hardware ping (a Teensy over serial).
What works today. Using the v1 extensions
VK_KHR_present_id+VK_KHR_present_waitthis worksnicely on stock VSG. I add the two device-extension names and the
presentId/presentWaitfeatures through
WindowTraits(deviceExtensionNames+ avsg::DeviceFeatureswithVkPhysicalDevicePresentIdFeaturesKHR/VkPhysicalDevicePresentWaitFeaturesKHR), subclassvsg::Viewer, and in my own present path chain aVkPresentIdKHRontoVkPresentInfoKHRand thencall
vkWaitForPresentKHR. No VSG change needed, because the v1 extensions don't require anyswapchain creation flag.
What I can't do. I'd like to move to the successor extensions
VK_KHR_present_id2/VK_KHR_present_wait2. The main reason is robust support detection: v2 adds the surface-capabilitystructures (
VkSurfaceCapabilitiesPresentId2KHR/VkSurfaceCapabilitiesPresentWait2KHR) so I canquery whether the surface in use actually supports present-wait, rather than enabling the v1
device extension blindly — on some WSI/driver paths that distinction matters and getting it wrong is
undefined behaviour.
The blocker is that v2 requires the swapchain to be created with
VK_SWAPCHAIN_CREATE_PRESENT_ID_2_BIT_KHR/VK_SWAPCHAIN_CREATE_PRESENT_WAIT_2_BIT_KHR. Withoutthose flags, chaining
VkPresentId2KHRand callingvkWaitForPresent2KHRare invalid uses of theswapchain. VSG can already enable the device extensions and features via
WindowTraits, but as faras I can tell there's no way to set
VkSwapchainCreateInfoKHR::flags:Swapchainbuilds thecreate-info internally and leaves
flagsat 0, andSwapchainPreferenceshas no field for it.Proposed change. Add a
flagsfield toSwapchainPreferencesand forward it to the createinfo — a minimal, backward-compatible addition (defaults to 0, current behaviour unchanged):
// src/vsg/vk/Swapchain.cpp, in Swapchain::Swapchain(...) createInfo.flags = preferences.flags;An app could then write
traits->swapchainPreferences.flags |= VK_SWAPCHAIN_CREATE_PRESENT_ID_2_BIT_KHR | VK_SWAPCHAIN_CREATE_PRESENT_WAIT_2_BIT_KHR;and the rest (extension names,
DeviceFeatures) goes through the existingWindowTraitsAPI.Did I miss an existing way to set swapchain create flags?
Thanks!
Beta Was this translation helpful? Give feedback.
All reactions