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

The spec/validation layers say this is invalid.
This commit is contained in:
Stenzek 2019-04-28 16:01:07 +10:00
parent 906ccdb1b4
commit 5399995c61
1 changed files with 13 additions and 0 deletions

View File

@ -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);
}