From 532e58414c227af0c7428ba8dbad3152916d74cd Mon Sep 17 00:00:00 2001 From: Lioncash Date: Sat, 24 Aug 2019 18:42:37 -0400 Subject: [PATCH] D3D11: Invert conditional within setScissor() Turns the condition into a guard clause, which allows unindenting all of the code within the function by one level. --- lib/graphicsdev/D3D11.cpp | 41 +++++++++++++++++++++------------------ 1 file changed, 22 insertions(+), 19 deletions(-) diff --git a/lib/graphicsdev/D3D11.cpp b/lib/graphicsdev/D3D11.cpp index 5028a79..440ea25 100644 --- a/lib/graphicsdev/D3D11.cpp +++ b/lib/graphicsdev/D3D11.cpp @@ -1072,26 +1072,29 @@ struct D3D11CommandQueue final : IGraphicsCommandQueue { } void setScissor(const SWindowRect& rect) override { - if (m_boundTarget) { - int boundHeight = 0; - switch (m_boundTarget->type()) { - case TextureType::Render: { - const auto* const ctarget = m_boundTarget.cast(); - boundHeight = ctarget->m_height; - break; - } - case TextureType::CubeRender: { - const auto* const ctarget = m_boundTarget.cast(); - boundHeight = ctarget->m_width; - break; - } - default: - break; - } - const D3D11_RECT d3drect = {LONG(rect.location[0]), LONG(boundHeight - rect.location[1] - rect.size[1]), - LONG(rect.location[0] + rect.size[0]), LONG(boundHeight - rect.location[1])}; - m_deferredCtx->RSSetScissorRects(1, &d3drect); + if (!m_boundTarget) { + return; } + + int boundHeight = 0; + switch (m_boundTarget->type()) { + case TextureType::Render: { + const auto* const ctarget = m_boundTarget.cast(); + boundHeight = ctarget->m_height; + break; + } + case TextureType::CubeRender: { + const auto* const ctarget = m_boundTarget.cast(); + boundHeight = ctarget->m_width; + break; + } + default: + break; + } + + const D3D11_RECT d3drect = {LONG(rect.location[0]), LONG(boundHeight - rect.location[1] - rect.size[1]), + LONG(rect.location[0] + rect.size[0]), LONG(boundHeight - rect.location[1])}; + m_deferredCtx->RSSetScissorRects(1, &d3drect); } std::unordered_map> m_texResizes;