Issue in qvulkanwindow.cpp ?
-
I've encountered an issue with QVulkanWindow on Windows that produces validation layer errors. I initially developed a large portion of my Vulkan application on Linux, but when moving to Windows, I started getting validation errors.
When running my application with Vulkan validation layers enabled, I receive this error:vkDebug: vkAcquireNextImageKHR(): Semaphore must not have any pending operations.
The Vulkan spec states: If semaphore is not VK_NULL_HANDLE, it must not have any uncompleted signal or wait operations pending (https://vulkan.lunarg.com/doc/view/1.4.309.0/windows/antora/spec/latest/chapters/VK_KHR_surface/wsi.html#VUID-vkAcquireNextImageKHR-semaphore-01779)To confirm this wasn't an issue with my code, I ran the "hellovulkantriangle" example that ships with Qt, and it produces the same validation error. This suggests the problem is in the Qt Vulkan implementation itself or with how is the class supposed to be used. This is my code, that has same structure as in qt example:
void BaseGame::startNextFrame() { vt::Functions *functions = vt::Functions::instance(); GameEnvironment *gameEnv = GameEnvironment::instance(); VkCommandBuffer cb = p_instruments->window->currentCommandBuffer(); VkRenderPassBeginInfo p_rpBeginInfo = {}; p_rpBeginInfo.sType = VK_STRUCTURE_TYPE_RENDER_PASS_BEGIN_INFO; p_rpBeginInfo.renderPass = p_instruments->window->defaultRenderPass(); p_rpBeginInfo.framebuffer = p_instruments->window->currentFramebuffer(); p_rpBeginInfo.renderArea.extent.width = 800; p_rpBeginInfo.renderArea.extent.height = 600; p_rpBeginInfo.clearValueCount = p_instruments->window->sampleCountFlagBits() > VK_SAMPLE_COUNT_1_BIT ? 3 : 2; p_rpBeginInfo.pClearValues = m_clearValues; p_instruments->devFuncs->vkCmdBeginRenderPass(cb, &p_rpBeginInfo, VK_SUBPASS_CONTENTS_INLINE); functions->setViewport(cb, {0, 0}, {gameEnv->swapChainImageSize().width(), 800}); functions->setScissors(cb, {0, 0}, {gameEnv->swapChainImageSize().width(), 600}); p_instruments->devFuncs->vkCmdEndRenderPass(cb); p_instruments->window->frameReady(); p_instruments->window->requestUpdate(); }
Did anybody encounter the same issue as me? What could be a workaround? Thank you.
Qt version: 6.7.3
Vulkan version: 1.4.309.0 -
Hi,
Looks like it could be a regression. Can you check if it still happens with the latest version of Qt ? It's the 6.9 series at this time.
-
Seems to be the problem with QVulkanWindowPrivate handling of semaphores: it uses only two sets of semaphores, while number of images in the swapchain is 3. Number of sets of semaphores is limited by frameLag variable, which is hardcoded to be 2 (https://github.com/qt/qtbase/blob/e2bd1de82a0a8605a1732ea92c4a5e478018bd46/src/gui/vulkan/qvulkanwindow_p.h#L103). The code also references an example from VK_KHR_swapchain spec, which seems to have been removed.
If you build your QT from source, there might be a way to fix this - set frameLag to MAX_FRAME_LAG. Unfortunately, I use binary distribution and can't quickly check if that helps.
-
You should check the bug report system to see if it's something known and if not, please open a ticket providing minimal compilable example that triggers the crash.