From 812b45d04958e31e7a3bfc7331308374e8b73afa Mon Sep 17 00:00:00 2001 From: Tim Rowley Date: Fri, 12 Aug 2016 16:59:25 -0600 Subject: [PATCH] swr: [rasterizer core] clamp scissor rects to current tile rect Signed-off-by: Tim Rowley --- .../drivers/swr/rasterizer/core/utils.h | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/src/gallium/drivers/swr/rasterizer/core/utils.h b/src/gallium/drivers/swr/rasterizer/core/utils.h index 79f45ebf25d..e66cdc34bae 100644 --- a/src/gallium/drivers/swr/rasterizer/core/utils.h +++ b/src/gallium/drivers/swr/rasterizer/core/utils.h @@ -29,6 +29,7 @@ #include #include +#include #include "common/os.h" #include "common/simdintrin.h" #include "common/swr_assert.h" @@ -95,6 +96,23 @@ OSALIGNLINE(struct) BBOX { return !(*this == rhs); } + + BBOX& Intersect(const BBOX& other) + { + this->top = std::max(this->top, other.top); + this->bottom = std::min(this->bottom, other.bottom); + this->left = std::max(this->left, other.left); + this->right = std::min(this->right, other.right); + + if (right - left < 0 || + bottom - top < 0) + { + // Zero area + top = bottom = left = right = 0; + } + + return *this; + } }; struct simdBBox -- 2.30.2