summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPaul Lemire <paul.lemire@kdab.com>2020-12-16 09:09:28 +0100
committerQt Cherry-pick Bot <cherrypick_bot@qt-project.org>2020-12-16 13:47:39 +0000
commit91e506d47fde60225375e54f154c5ac9096380f0 (patch)
treee35dbb192649a2d96b3f2cd0c08c4fcddae215af
parenteda3728a33585ebacfe5411ca2febd90dc10258a (diff)
RHI: compute viewport based on rendertarget size
So that behavior is consistent with the OpenGL renderer. Computed viewport size is QViewport::normalizedRect * current render target size. If current render target is the window, then its size is the same as the surface size. Change-Id: Icd8f8e18d8959ac045538b493fef690e3dd7221c Reviewed-by: Mike Krus <mike.krus@kdab.com> (cherry picked from commit 4794c7543726f2a460c9d16b0ae0154da39efd7c) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
-rw-r--r--src/plugins/renderers/rhi/renderer/renderer.cpp13
1 files changed, 7 insertions, 6 deletions
diff --git a/src/plugins/renderers/rhi/renderer/renderer.cpp b/src/plugins/renderers/rhi/renderer/renderer.cpp
index 345fffdf8..4925fd251 100644
--- a/src/plugins/renderers/rhi/renderer/renderer.cpp
+++ b/src/plugins/renderers/rhi/renderer/renderer.cpp
@@ -2650,12 +2650,13 @@ bool Renderer::executeCommandsSubmission(const RHIPassInfo &passInfo)
QRhiScissor scissor;
bool hasScissor = false;
{
- const float x = rv->viewport().x() * rv->surfaceSize().width();
- const float y = (1. - rv->viewport().y() - rv->viewport().height())
- * rv->surfaceSize().height();
- const float w = rv->viewport().width() * rv->surfaceSize().width();
- const float h = rv->viewport().height() * rv->surfaceSize().height();
- // qDebug() << x << y << w << h;
+ const QSize surfaceSize = rhiRenderTarget->pixelSize();
+
+ const float x = rv->viewport().x() * surfaceSize.width();
+ const float y = (1. - rv->viewport().y() - rv->viewport().height()) * surfaceSize.height();
+ const float w = rv->viewport().width() * surfaceSize.width();
+ const float h = rv->viewport().height() * surfaceSize.height();
+ // qDebug() << surfaceSize << x << y << w << h;
vp = { x, y, w, h };
}
// Scissoring