OpenGlDisplayPlugin: Add possibility to present frames only once.

Don't present frame more than once in OpenXrDisplayPlugin.
This commit is contained in:
Lubosz Sarnecki 2024-03-16 15:55:42 +01:00
parent 479b1aa6da
commit ae5c1d8d00
3 changed files with 10 additions and 0 deletions

View file

@ -743,6 +743,13 @@ void OpenGLDisplayPlugin::present(const std::shared_ptr<RefreshRateController>&
}
gpu::Backend::freeGPUMemSize.set(gpu::gl::getFreeDedicatedMemory());
// Drop current frame after presenting it once.
// This is required for the OpenXR frame cycle, since we call xrEndFrame after presenting.
// xrEndFrame must not be called multiple times.
if (_presentOnlyOnce) {
_currentFrame.reset();
}
} else if (alwaysPresent()) {
refreshRateController->clockEndTime();
internalPresent();

View file

@ -201,4 +201,6 @@ protected:
QImage getScreenshot(float aspectRatio);
QImage getSecondaryCameraScreenshot();
bool _presentOnlyOnce = false;
};

View file

@ -20,6 +20,7 @@ constexpr GLint XR_PREFERRED_COLOR_FORMAT = GL_SRGB8_ALPHA8;
OpenXrDisplayPlugin::OpenXrDisplayPlugin(std::shared_ptr<OpenXrContext> c) {
_context = c;
_presentOnlyOnce = true;
}
bool OpenXrDisplayPlugin::isSupported() const {