Mesa (master): swr: [rasterizer core] clamp scissor rects to current tile rect

Tim Rowley torowley at kemper.freedesktop.org
Wed Aug 17 22:12:46 UTC 2016


Module: Mesa
Branch: master
Commit: 812b45d04958e31e7a3bfc7331308374e8b73afa
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=812b45d04958e31e7a3bfc7331308374e8b73afa

Author: Tim Rowley <timothy.o.rowley at intel.com>
Date:   Fri Aug 12 16:59:25 2016 -0600

swr: [rasterizer core] clamp scissor rects to current tile rect

Signed-off-by: Tim Rowley <timothy.o.rowley at intel.com>

---

 src/gallium/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 79f45eb..e66cdc3 100644
--- a/src/gallium/drivers/swr/rasterizer/core/utils.h
+++ b/src/gallium/drivers/swr/rasterizer/core/utils.h
@@ -29,6 +29,7 @@
 
 #include <string.h>
 #include <type_traits>
+#include <algorithm>
 #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




More information about the mesa-commit mailing list