From 0acab3c1ade23ac7b8dd16f87c2578a8cff0c505 Mon Sep 17 00:00:00 2001 From: Laszlo Agocs Date: Wed, 6 May 2020 13:30:03 +0200 Subject: [PATCH] rhi: Correct another scissor/viewport clamping problem When x or y are >= the width or height of the render target, then the width or height of the scissor/viewport rect is zero, no further logic is needed. This is different from the case of x or y being negative, because then there is still a chance that there is an in-bounds area (if width or height are large enough). It is important to make this check based on the original value of x and y, not the clamped ones. Otherwise we end up with a 1 pixel wide region even when the expected result is a width or height of 0. Previously the incorrect subtraction of 1 in the final clamping of w and h masked this, but once that is fixed, the issue fixed here becomes visible in the cubemap_scissor manual test. Change-Id: I3d4b0a163a16aa1116b1e838fa95c0faf7b56a3d Reviewed-by: Eirik Aavitsland --- src/gui/rhi/qrhi_p_p.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/gui/rhi/qrhi_p_p.h b/src/gui/rhi/qrhi_p_p.h index 729b85c4d5..cf725632f4 100644 --- a/src/gui/rhi/qrhi_p_p.h +++ b/src/gui/rhi/qrhi_p_p.h @@ -260,11 +260,11 @@ bool qrhi_toTopLeftRenderTargetRect(const QSize &outputSize, const std::array(0, inputWidth - widthOffset) : 0; + *h = *y < outputHeight ? qMax(0, inputHeight - heightOffset) : 0; *x = qBound(0, *x, outputWidth - 1); *y = qBound(0, *y, outputHeight - 1); - *w = qMax(0, inputWidth - widthOffset); - *h = qMax(0, inputHeight - heightOffset); if (*x + *w > outputWidth) *w = qMax(0, outputWidth - *x);