Skip to content
Permalink
Browse files

Vulkan: Don't set a negative offset in scissor rect

The spec/validation layers say this is invalid.
  • Loading branch information...
stenzek committed Apr 28, 2019
1 parent 906ccdb commit 5399995c611f6ae4197baca2cd5e3746f4827d1e
Showing with 13 additions and 0 deletions.
  1. +13 −0 Source/Core/VideoBackends/Vulkan/Renderer.cpp
@@ -561,6 +561,19 @@ void Renderer::SetScissorRect(const MathUtil::Rectangle<int>& rc)
{
VkRect2D scissor = {{rc.left, rc.top},
{static_cast<u32>(rc.GetWidth()), static_cast<u32>(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);
}

0 comments on commit 5399995

Please sign in to comment.
You can’t perform that action at this time.