diff options
| author | David Edmundson <davidedmundson@kde.org> | 2023-03-31 10:20:07 +0100 |
|---|---|---|
| committer | David Edmundson <davidedmundson@kde.org> | 2023-04-28 08:37:10 +0100 |
| commit | 486381006558b22175176473dd53cc4d75a45bcf (patch) | |
| tree | f5eca26e805f8a520628e7d233d4770b8b335ac2 /src | |
| parent | 1c5c1df43e2be10c46c13461888b012c89938150 (diff) | |
Call into platform hooks for start and end frames
This closely matches QPlatformOpenGLContext which in turn, where it can
be used by backends to guard low level resources.
Change-Id: Ia44cebced6cdf94497279c47d3c35c0e02e4cb0e
Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
Diffstat (limited to 'src')
| -rw-r--r-- | src/gui/rhi/qrhivulkan.cpp | 7 | ||||
| -rw-r--r-- | src/gui/vulkan/qplatformvulkaninstance.cpp | 11 | ||||
| -rw-r--r-- | src/gui/vulkan/qplatformvulkaninstance.h | 2 |
3 files changed, 20 insertions, 0 deletions
diff --git a/src/gui/rhi/qrhivulkan.cpp b/src/gui/rhi/qrhivulkan.cpp index 17e291eee1b..2f8afb389a2 100644 --- a/src/gui/rhi/qrhivulkan.cpp +++ b/src/gui/rhi/qrhivulkan.cpp @@ -3,6 +3,7 @@ #include "qrhivulkan_p_p.h" #include "qrhivulkanext_p.h" +#include <qpa/qplatformvulkaninstance.h> #define VMA_IMPLEMENTATION #define VMA_DYNAMIC_VULKAN_FUNCTIONS 1 @@ -1695,6 +1696,8 @@ QRhi::FrameOpResult QRhiVulkan::beginFrame(QRhiSwapChain *swapChain, QRhi::Begin const int frameResIndex = swapChainD->bufferCount > 1 ? swapChainD->currentFrameSlot : 0; QVkSwapChain::FrameResources &frame(swapChainD->frameRes[frameResIndex]); + inst->handle()->beginFrame(swapChainD->window); + if (!frame.imageAcquired) { // Wait if we are too far ahead, i.e. the thread gets throttled based on the presentation rate // (note that we are using FIFO mode -> vsync) @@ -1803,6 +1806,10 @@ QRhi::FrameOpResult QRhiVulkan::endFrame(QRhiSwapChain *swapChain, QRhi::EndFram QVkSwapChain *swapChainD = QRHI_RES(QVkSwapChain, swapChain); Q_ASSERT(currentSwapChain == swapChainD); + auto cleanup = qScopeGuard([this, swapChainD] { + inst->handle()->endFrame(swapChainD->window); + }); + recordPrimaryCommandBuffer(&swapChainD->cbWrapper); int frameResIndex = swapChainD->bufferCount > 1 ? swapChainD->currentFrameSlot : 0; diff --git a/src/gui/vulkan/qplatformvulkaninstance.cpp b/src/gui/vulkan/qplatformvulkaninstance.cpp index 2955f2f3001..2685a5c6f8c 100644 --- a/src/gui/vulkan/qplatformvulkaninstance.cpp +++ b/src/gui/vulkan/qplatformvulkaninstance.cpp @@ -64,4 +64,15 @@ void QPlatformVulkanInstance::setDebugUtilsFilters(const QList<QVulkanInstance:: Q_UNUSED(filters); } +void QPlatformVulkanInstance::beginFrame(QWindow *window) +{ + Q_UNUSED(window); +} + +void QPlatformVulkanInstance::endFrame(QWindow *window) +{ + Q_UNUSED(window); +} + + QT_END_NAMESPACE diff --git a/src/gui/vulkan/qplatformvulkaninstance.h b/src/gui/vulkan/qplatformvulkaninstance.h index 40ba602524c..d34cb77d1b7 100644 --- a/src/gui/vulkan/qplatformvulkaninstance.h +++ b/src/gui/vulkan/qplatformvulkaninstance.h @@ -46,6 +46,8 @@ public: virtual void presentQueued(QWindow *window); virtual void setDebugFilters(const QList<QVulkanInstance::DebugFilter> &filters); virtual void setDebugUtilsFilters(const QList<QVulkanInstance::DebugUtilsFilter> &filters); + virtual void beginFrame(QWindow *window); + virtual void endFrame(QWindow *window); private: QScopedPointer<QPlatformVulkanInstancePrivate> d_ptr; |
