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>
bb10
Laszlo Agocs 2022-08-05 10:50:26 +02:00
parent 6423a657c7
commit cb139dbdb8
1 changed files with 12 additions and 0 deletions

View File

@ -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(&currentSwapChain->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;
}