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 <eirik.aavitsland@qt.io>
This commit is contained in:
parent
f116221ab9
commit
0acab3c1ad
@ -260,11 +260,11 @@ bool qrhi_toTopLeftRenderTargetRect(const QSize &outputSize, const std::array<T,
|
||||
|
||||
const T widthOffset = *x < 0 ? -*x : 0;
|
||||
const T heightOffset = *y < 0 ? -*y : 0;
|
||||
*w = *x < outputWidth ? qMax<T>(0, inputWidth - widthOffset) : 0;
|
||||
*h = *y < outputHeight ? qMax<T>(0, inputHeight - heightOffset) : 0;
|
||||
|
||||
*x = qBound<T>(0, *x, outputWidth - 1);
|
||||
*y = qBound<T>(0, *y, outputHeight - 1);
|
||||
*w = qMax<T>(0, inputWidth - widthOffset);
|
||||
*h = qMax<T>(0, inputHeight - heightOffset);
|
||||
|
||||
if (*x + *w > outputWidth)
|
||||
*w = qMax<T>(0, outputWidth - *x);
|
||||
|
Loading…
Reference in New Issue
Block a user