From f20fd61e4fec35d93152113045e3ca3916e98022 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=91=D1=80=D0=B0=D0=BD=D0=B8=D0=BC=D0=B8=D1=80=20=D0=9A?= =?UTF-8?q?=D0=B0=D1=80=D0=B0=D1=9F=D0=B8=D1=9B?= Date: Sat, 22 Aug 2020 09:10:49 -0700 Subject: [PATCH] Revert "[ VK/DX12] Bring setScissor on par with the other renderers (#2239)" This reverts commit fbd7e9efd69c1e6c6c52af4155d2c0afc9b2a219. --- src/renderer_d3d12.cpp | 15 ++++++++++----- src/renderer_vk.cpp | 11 +++++++---- 2 files changed, 17 insertions(+), 9 deletions(-) diff --git a/src/renderer_d3d12.cpp b/src/renderer_d3d12.cpp index e4c4fb5a3..efcbf06cd 100644 --- a/src/renderer_d3d12.cpp +++ b/src/renderer_d3d12.cpp @@ -5893,7 +5893,7 @@ namespace bgfx { namespace d3d12 bool wasCompute = false; bool viewHasScissor = false; - bool scissorEnabled = false; + bool restoreScissor = false; Rect viewScissorRect; viewScissorRect.clear(); @@ -6033,6 +6033,7 @@ namespace bgfx { namespace d3d12 rc.right = viewScissorRect.m_x + viewScissorRect.m_width; rc.bottom = viewScissorRect.m_y + viewScissorRect.m_height; m_commandList->RSSetScissorRects(1, &rc); + restoreScissor = false; Clear& clr = _render->m_view[view].m_clear; if (BGFX_CLEAR_NONE != clr.m_flags) @@ -6529,9 +6530,10 @@ namespace bgfx { namespace d3d12 if (UINT16_MAX == scissor) { - scissorEnabled = viewHasScissor; - if (viewHasScissor) + if (restoreScissor + || viewHasScissor) { + restoreScissor = false; D3D12_RECT rc; rc.left = viewScissorRect.m_x; rc.top = viewScissorRect.m_y; @@ -6542,11 +6544,14 @@ namespace bgfx { namespace d3d12 } else { - + restoreScissor = true; Rect scissorRect; scissorRect.setIntersect(viewScissorRect, _render->m_frameCache.m_rectCache.m_cache[scissor]); + if (scissorRect.isZeroArea() ) + { + continue; + } - scissorEnabled = true; D3D12_RECT rc; rc.left = scissorRect.m_x; rc.top = scissorRect.m_y; diff --git a/src/renderer_vk.cpp b/src/renderer_vk.cpp index ea9038132..99b374ac6 100644 --- a/src/renderer_vk.cpp +++ b/src/renderer_vk.cpp @@ -5944,7 +5944,7 @@ VK_DESTROY bool wasCompute = false; bool viewHasScissor = false; - bool scissorEnabled = false; + bool restoreScissor = false; Rect viewScissorRect; viewScissorRect.clear(); @@ -6097,6 +6097,8 @@ VK_DESTROY rc.extent.height = viewScissorRect.m_height; vkCmdSetScissor(m_commandBuffer, 0, 1, &rc); + restoreScissor = false; + Clear& clr = _render->m_view[view].m_clear; if (BGFX_CLEAR_NONE != clr.m_flags) { @@ -6394,9 +6396,10 @@ VK_DESTROY if (UINT16_MAX == scissor) { - scissorEnabled = viewHasScissor; - if (viewHasScissor) + if (restoreScissor + || viewHasScissor) { + restoreScissor = false; VkRect2D rc; rc.offset.x = viewScissorRect.m_x; rc.offset.y = viewScissorRect.m_y; @@ -6407,10 +6410,10 @@ VK_DESTROY } else { + restoreScissor = true; Rect scissorRect; scissorRect.setIntersect(viewScissorRect, _render->m_frameCache.m_rectCache.m_cache[scissor]); - scissorEnabled = true; VkRect2D rc; rc.offset.x = scissorRect.m_x; rc.offset.y = scissorRect.m_y;