diff options
author | Laszlo Agocs <laszlo.agocs@qt.io> | 2022-08-05 10:50:26 +0200 |
---|---|---|
committer | Laszlo Agocs <laszlo.agocs@qt.io> | 2022-08-05 18:10:00 +0200 |
commit | cb139dbdb8d7ff1f9e9be24623697035677c9774 (patch) | |
tree | a6b4407aaa7a4317002e65e2c5ad656e938e0c36 | |
parent | 6423a657c7179e7e0f00c14dccc94b237b3160b8 (diff) |
rhi: gl: Unify end/finish behavior
Issue a glFlush in endOffscreenFrame. This matches endFrame which
flushes either implicitly (swapBuffers) or explicitly with SkipPresent
(glFlush). This will then benefit producer-consumer setups where a
context renders into a texture using begin/endOffscreenFrame and then
the texture is consumed in another context.
In addition, make finish() issue a glFinish().
Pick-to: 6.4
Change-Id: I0a3115255ad2ac82b730e26d1ca7e88377c5a28c
Reviewed-by: Piotr Srebrny <piotr.srebrny@qt.io>
Reviewed-by: Andy Nichols <andy.nichols@qt.io>
-rw-r--r-- | src/gui/rhi/qrhigles2.cpp | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/src/gui/rhi/qrhigles2.cpp b/src/gui/rhi/qrhigles2.cpp index 4c079e0ace..a9f954dc88 100644 --- a/src/gui/rhi/qrhigles2.cpp +++ b/src/gui/rhi/qrhigles2.cpp @@ -1944,6 +1944,12 @@ QRhi::FrameOpResult QRhiGles2::endOffscreenFrame(QRhi::EndFrameFlags flags) executeCommandBuffer(&ofr.cbWrapper); + // Just as endFrame() does a flush when skipping the swapBuffers(), do it + // here as well. This has the added benefit of playing nice when rendering + // to a texture from a context and then consuming that texture from + // another, sharing context. + f->glFlush(); + return QRhi::FrameOpSuccess; } @@ -1965,6 +1971,12 @@ QRhi::FrameOpResult QRhiGles2::finish() executeCommandBuffer(¤tSwapChain->cb); currentSwapChain->cb.resetCommands(); } + // Do an actual glFinish(). May seem superfluous, but this is what + // matches most other backends e.g. Vulkan/Metal that do a heavyweight + // wait-for-idle blocking in their finish(). More importantly, this + // allows clients simply call finish() in threaded or shared context + // situations where one explicitly needs to do a glFlush or Finish. + f->glFinish(); } return QRhi::FrameOpSuccess; } |