Branimir Karadžić 8 years ago
parent
commit
aa2a9deb5f
7 changed files with 34 additions and 9 deletions
  1. 26 1
      src/bgfx_p.h
  2. 1 1
      src/renderer_d3d11.cpp
  3. 2 2
      src/renderer_d3d12.cpp
  4. 1 1
      src/renderer_d3d9.cpp
  5. 1 1
      src/renderer_gl.cpp
  6. 1 1
      src/renderer_mtl.mm
  7. 2 2
      src/renderer_vk.cpp

+ 26 - 1
src/bgfx_p.h

@@ -273,6 +273,18 @@ namespace bgfx
 
 	struct Rect
 	{
+		Rect()
+		{
+		}
+
+		Rect(uint16_t _x, uint16_t _y, uint16_t _width, uint16_t _height)
+			: m_x(_x)
+			, m_y(_y)
+			, m_width(_width)
+			, m_height(_height)
+		{
+		}
+
 		void clear()
 		{
 			m_x =
@@ -294,7 +306,15 @@ namespace bgfx
 				;
 		}
 
-		void intersect(const Rect& _a, const Rect& _b)
+		void set(uint16_t _x, uint16_t _y, uint16_t _width, uint16_t _height)
+		{
+			m_x = _x;
+			m_y = _y;
+			m_width  = _width;
+			m_height = _height;
+		}
+
+		void setIntersect(const Rect& _a, const Rect& _b)
 		{
 			using namespace bx;
 			const uint16_t sx = uint16_max(_a.m_x, _b.m_x);
@@ -307,6 +327,11 @@ namespace bgfx
 			m_height = (uint16_t)uint32_satsub(ey, sy);
 		}
 
+		void intersect(const Rect& _a)
+		{
+			setIntersect(*this, _a);
+		}
+
 		uint16_t m_x;
 		uint16_t m_y;
 		uint16_t m_width;

+ 1 - 1
src/renderer_d3d11.cpp

@@ -5754,7 +5754,7 @@ BX_PRAGMA_DIAGNOSTIC_POP();
 					else
 					{
 						Rect scissorRect;
-						scissorRect.intersect(viewScissorRect, _render->m_rectCache.m_cache[scissor]);
+						scissorRect.setIntersect(viewScissorRect, _render->m_rectCache.m_cache[scissor]);
 						if (scissorRect.isZeroArea() )
 						{
 							continue;

+ 2 - 2
src/renderer_d3d12.cpp

@@ -4909,7 +4909,7 @@ data.NumQualityLevels = 0;
 					if (BGFX_CLEAR_NONE != clr.m_flags)
 					{
 						Rect clearRect = rect;
-						clearRect.intersect(rect, viewScissorRect);
+						clearRect.setIntersect(rect, viewScissorRect);
 						clearQuad(clearRect, clr, _render->m_colorPalette);
 					}
 
@@ -5372,7 +5372,7 @@ data.NumQualityLevels = 0;
 						{
 							restoreScissor = true;
 							Rect scissorRect;
-							scissorRect.intersect(viewScissorRect,_render->m_rectCache.m_cache[scissor]);
+							scissorRect.setIntersect(viewScissorRect,_render->m_rectCache.m_cache[scissor]);
 							if (scissorRect.isZeroArea() )
 							{
 								continue;

+ 1 - 1
src/renderer_d3d9.cpp

@@ -3795,7 +3795,7 @@ namespace bgfx { namespace d3d9
 					else
 					{
 						Rect scissorRect;
-						scissorRect.intersect(viewScissorRect, _render->m_rectCache.m_cache[scissor]);
+						scissorRect.setIntersect(viewScissorRect, _render->m_rectCache.m_cache[scissor]);
 						if (scissorRect.isZeroArea() )
 						{
 							continue;

+ 1 - 1
src/renderer_gl.cpp

@@ -6601,7 +6601,7 @@ namespace bgfx { namespace gl
 					else
 					{
 						Rect scissorRect;
-						scissorRect.intersect(viewScissorRect, _render->m_rectCache.m_cache[scissor]);
+						scissorRect.setIntersect(viewScissorRect, _render->m_rectCache.m_cache[scissor]);
 						if (scissorRect.isZeroArea() )
 						{
 							continue;

+ 1 - 1
src/renderer_mtl.mm

@@ -3416,7 +3416,7 @@ namespace bgfx { namespace mtl
 					else
 					{
 						Rect scissorRect;
-						scissorRect.intersect(viewScissorRect, _render->m_rectCache.m_cache[scissor]);
+						scissorRect.setIntersect(viewScissorRect, _render->m_rectCache.m_cache[scissor]);
 						if (scissorRect.isZeroArea() )
 						{
 							continue;

+ 2 - 2
src/renderer_vk.cpp

@@ -3805,7 +3805,7 @@ BX_UNUSED(currentSamplerStateIdx);
 					if (BGFX_CLEAR_NONE != clr.m_flags)
 					{
 						Rect clearRect = rect;
-						clearRect.intersect(rect, viewScissorRect);
+						clearRect.setIntersect(rect, viewScissorRect);
 						clearQuad(clearRect, clr, _render->m_colorPalette);
 					}
 
@@ -4261,7 +4261,7 @@ BX_UNUSED(currentSamplerStateIdx);
 						{
 							restoreScissor = true;
 							Rect scissorRect;
-							scissorRect.intersect(viewScissorRect,_render->m_rectCache.m_cache[scissor]);
+							scissorRect.setIntersect(viewScissorRect,_render->m_rectCache.m_cache[scissor]);
 							if (scissorRect.isZeroArea() )
 							{
 								continue;