diff options
author | Laszlo Agocs <laszlo.agocs@qt.io> | 2017-03-23 18:38:13 +0100 |
---|---|---|
committer | Laszlo Agocs <laszlo.agocs@qt.io> | 2017-03-26 22:40:14 +0000 |
commit | 92dce210a2ca97161b4fc9cb1991585816982ff7 (patch) | |
tree | b1b1f270dee9711d5f352e16e6dca8722570f901 /src/gui/vulkan | |
parent | 9a9195c8060d904dfad4ad9f51b5575d434a6037 (diff) |
QVulkanWindow: Add missing device wait after user code
In a multi-threaded setup it is not unlikely that
releaseSwapChainResources() will wait for and submit any remaining
frame building. Hence a wait is necessary also after invoking the user's
implementation.
Change-Id: I3c963c05c1c3981980da5e4ff9c572df24a1e473
Reviewed-by: Andy Nichols <andy.nichols@qt.io>
Diffstat (limited to 'src/gui/vulkan')
-rw-r--r-- | src/gui/vulkan/qvulkanwindow.cpp | 23 |
1 files changed, 17 insertions, 6 deletions
diff --git a/src/gui/vulkan/qvulkanwindow.cpp b/src/gui/vulkan/qvulkanwindow.cpp index 7acc6f4c8e..d5af71cd4b 100644 --- a/src/gui/vulkan/qvulkanwindow.cpp +++ b/src/gui/vulkan/qvulkanwindow.cpp @@ -925,8 +925,10 @@ void QVulkanWindowPrivate::reset() devFuncs->vkDeviceWaitIdle(dev); - if (renderer) + if (renderer) { renderer->releaseResources(); + devFuncs->vkDeviceWaitIdle(dev); + } if (defaultRenderPass) { devFuncs->vkDestroyRenderPass(dev, defaultRenderPass, nullptr); @@ -1436,8 +1438,10 @@ void QVulkanWindowPrivate::releaseSwapChain() devFuncs->vkDeviceWaitIdle(dev); - if (renderer) + if (renderer) { renderer->releaseSwapChainResources(); + devFuncs->vkDeviceWaitIdle(dev); + } for (int i = 0; i < frameLag; ++i) { FrameResources &frame(frameRes[i]); @@ -1676,8 +1680,8 @@ void QVulkanWindowRenderer::initResources() have multiple calls to initSwapChainResources() and releaseSwapChainResources() calls in-between. - Accessors like swapChainImageSize() are only guaranteed to return valid - values inside this function and afterwards, up until + Accessors like QVulkanWindow::swapChainImageSize() are only guaranteed to + return valid values inside this function and afterwards, up until releaseSwapChainResources() is called. This is also the place where size-dependent calculations (for example, the @@ -1698,9 +1702,16 @@ void QVulkanWindowRenderer::initSwapChainResources() followed by a new call to initSwapChainResources() at a later point. QVulkanWindow takes care of waiting for the device to become idle before - invoking this function. + and after invoking this function. The default implementation is empty. + + \note This is the last place to act with all graphics resources intact + before QVulkanWindow starts releasing them. It is therefore essential that + implementations with an asynchronous, potentially multi-threaded + startNextFrame() perform a blocking wait and call + QVulkanWindow::frameReady() before returning from this function in case + there is a pending frame submission. */ void QVulkanWindowRenderer::releaseSwapChainResources() { @@ -1714,7 +1725,7 @@ void QVulkanWindowRenderer::releaseSwapChainResources() followed by an initResources() at a later point. QVulkanWindow takes care of waiting for the device to become idle before - invoking this function. + and after invoking this function. The default implementation is empty. */ |