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>
This commit is contained in:
David Edmundson 2023-03-31 10:20:07 +01:00
parent 1c5c1df43e
commit 4863810065
3 changed files with 20 additions and 0 deletions

View File

@ -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;

View File

@ -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

View File

@ -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;