swr: [rasterizer core] clamp scissor rects to current tile rect
authorTim Rowley <timothy.o.rowley@intel.com>
Fri, 12 Aug 2016 22:59:25 +0000 (16:59 -0600)
committerTim Rowley <timothy.o.rowley@intel.com>
Wed, 17 Aug 2016 22:08:55 +0000 (17:08 -0500)
Signed-off-by: Tim Rowley <timothy.o.rowley@intel.com>
src/gallium/drivers/swr/rasterizer/core/utils.h

index 79f45ebf25d4fee6f4c00b6c539da76b8dd633b1..e66cdc34bae65677a744757a75d8c80d1518492e 100644 (file)
@@ -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