From 5399995c611f6ae4197baca2cd5e3746f4827d1e Mon Sep 17 00:00:00 2001 From: Stenzek Date: Sun, 28 Apr 2019 16:01:07 +1000 Subject: [PATCH] Vulkan: Don't set a negative offset in scissor rect The spec/validation layers say this is invalid. --- Source/Core/VideoBackends/Vulkan/Renderer.cpp | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/Source/Core/VideoBackends/Vulkan/Renderer.cpp b/Source/Core/VideoBackends/Vulkan/Renderer.cpp index 8d702adb45..ac3dbe4c2a 100644 --- a/Source/Core/VideoBackends/Vulkan/Renderer.cpp +++ b/Source/Core/VideoBackends/Vulkan/Renderer.cpp @@ -561,6 +561,19 @@ void Renderer::SetScissorRect(const MathUtil::Rectangle& rc) { VkRect2D scissor = {{rc.left, rc.top}, {static_cast(rc.GetWidth()), static_cast(rc.GetHeight())}}; + + // See Vulkan spec for vkCmdSetScissor: + // The x and y members of offset must be greater than or equal to 0. + if (scissor.offset.x < 0) + { + scissor.extent.width -= -scissor.offset.x; + scissor.offset.x = 0; + } + if (scissor.offset.y < 0) + { + scissor.extent.height -= -scissor.offset.y; + scissor.offset.y = 0; + } StateTracker::GetInstance()->SetScissor(scissor); }