diff --git a/src/gui/kernel/qplatformopenglcontext.cpp b/src/gui/kernel/qplatformopenglcontext.cpp index 839ec008aa..048cbc6a4a 100644 --- a/src/gui/kernel/qplatformopenglcontext.cpp +++ b/src/gui/kernel/qplatformopenglcontext.cpp @@ -165,4 +165,20 @@ bool QPlatformOpenGLContext::parseOpenGLVersion(const QByteArray &versionString, return (majorOk && minorOk); } +/*! + Called when the RHI begins rendering a new frame in the context. Will always be paired with a + call to \l endFrame(). +*/ +void QPlatformOpenGLContext::beginFrame() +{ +} + +/*! + Called when the RHI ends rendering a in the context. Is always preceded by a call to + \l beginFrame(). +*/ +void QPlatformOpenGLContext::endFrame() +{ +} + QT_END_NAMESPACE diff --git a/src/gui/kernel/qplatformopenglcontext.h b/src/gui/kernel/qplatformopenglcontext.h index 034462e5f3..76cc992944 100644 --- a/src/gui/kernel/qplatformopenglcontext.h +++ b/src/gui/kernel/qplatformopenglcontext.h @@ -84,6 +84,9 @@ public: virtual bool makeCurrent(QPlatformSurface *surface) = 0; virtual void doneCurrent() = 0; + virtual void beginFrame(); + virtual void endFrame(); + virtual bool isSharing() const { return false; } virtual bool isValid() const { return true; } diff --git a/src/gui/rhi/qrhigles2.cpp b/src/gui/rhi/qrhigles2.cpp index aa1144a996..f0b97ce36a 100644 --- a/src/gui/rhi/qrhigles2.cpp +++ b/src/gui/rhi/qrhigles2.cpp @@ -43,6 +43,7 @@ #include #include #include +#include #include QT_BEGIN_NAMESPACE @@ -1769,6 +1770,8 @@ QRhi::FrameOpResult QRhiGles2::beginFrame(QRhiSwapChain *swapChain, QRhi::BeginF if (!ensureContext(swapChainD->surface)) return contextLost ? QRhi::FrameOpDeviceLost : QRhi::FrameOpError; + ctx->handle()->beginFrame(); + currentSwapChain = swapChainD; QRhiProfilerPrivate *rhiP = profilerPrivateOrNull(); @@ -1807,6 +1810,9 @@ QRhi::FrameOpResult QRhiGles2::endFrame(QRhiSwapChain *swapChain, QRhi::EndFrame swapChainD->frameCount += 1; currentSwapChain = nullptr; + + ctx->handle()->endFrame(); + return QRhi::FrameOpSuccess; }