From 6761636bf7f3f90b7c82e4ac7be79d9d6a032d52 Mon Sep 17 00:00:00 2001 From: Laszlo Agocs Date: Wed, 23 Sep 2020 10:07:36 +0200 Subject: Map swap interval 0 to NoVSync with all the APIs What exactly this will cause is another question. But at least now the traditional OpenGL way of setting the QSurfaceFormat's swapInterval 0 will have an effect with the other APIs as well. Change-Id: I6d50952502a70e84828ed87347e2a948299f6f42 Reviewed-by: Andy Nichols --- src/quick/scenegraph/qsgrenderloop.cpp | 8 +++++++- src/quick/scenegraph/qsgthreadedrenderloop.cpp | 10 +++++++++- 2 files changed, 16 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/quick/scenegraph/qsgrenderloop.cpp b/src/quick/scenegraph/qsgrenderloop.cpp index 80f022ddb4..2924516eaf 100644 --- a/src/quick/scenegraph/qsgrenderloop.cpp +++ b/src/quick/scenegraph/qsgrenderloop.cpp @@ -526,15 +526,21 @@ void QSGGuiThreadRenderLoop::renderWindow(QQuickWindow *window) rhiSupport->prepareWindowForRhi(window); QRhiSwapChain::Flags flags = QRhiSwapChain::UsedAsTransferSource; // may be used in a grab + const QSurfaceFormat requestedFormat = window->requestedFormat(); // QQ is always premul alpha. Decide based on alphaBufferSize in // requestedFormat(). (the platform plugin can override format() but // what matters here is what the application wanted, hence using the // requested one) - const bool alpha = window->requestedFormat().alphaBufferSize() > 0; + const bool alpha = requestedFormat.alphaBufferSize() > 0; if (alpha) flags |= QRhiSwapChain::SurfaceHasPreMulAlpha; + // Request NoVSync if swap interval was set to 0. What this means in + // practice is another question, but at least we tried. + if (requestedFormat.swapInterval() == 0) + flags |= QRhiSwapChain::NoVSync; + cd->swapchain = rhi->newSwapChain(); static bool depthBufferEnabled = qEnvironmentVariableIsEmpty("QSG_NO_DEPTH_BUFFER"); if (depthBufferEnabled) { diff --git a/src/quick/scenegraph/qsgthreadedrenderloop.cpp b/src/quick/scenegraph/qsgthreadedrenderloop.cpp index a4bd6ba7ef..bdd0d20d64 100644 --- a/src/quick/scenegraph/qsgthreadedrenderloop.cpp +++ b/src/quick/scenegraph/qsgthreadedrenderloop.cpp @@ -930,13 +930,21 @@ void QSGRenderThread::ensureRhi() if (rhi && !cd->swapchain) { cd->rhi = rhi; QRhiSwapChain::Flags flags = QRhiSwapChain::UsedAsTransferSource; // may be used in a grab + const QSurfaceFormat requestedFormat = window->requestedFormat(); + // QQ is always premul alpha. Decide based on alphaBufferSize in // requestedFormat(). (the platform plugin can override format() but // what matters here is what the application wanted, hence using the // requested one) - const bool alpha = window->requestedFormat().alphaBufferSize() > 0; + const bool alpha = requestedFormat.alphaBufferSize() > 0; if (alpha) flags |= QRhiSwapChain::SurfaceHasPreMulAlpha; + + // Request NoVSync if swap interval was set to 0. What this means in + // practice is another question, but at least we tried. + if (requestedFormat.swapInterval() == 0) + flags |= QRhiSwapChain::NoVSync; + cd->swapchain = rhi->newSwapChain(); static bool depthBufferEnabled = qEnvironmentVariableIsEmpty("QSG_NO_DEPTH_BUFFER"); if (depthBufferEnabled) { -- cgit v1.2.3