From 5876388c657ede0b17c2a55d4590f5ff95ec1f55 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Fri, 10 Sep 2021 01:13:28 +0200 Subject: [PATCH] Vulkan scissor fix (validation errors). --- Common/GPU/Vulkan/VulkanRenderManager.h | 17 +++++++++++++---- GPU/Common/PostShader.cpp | 2 +- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/Common/GPU/Vulkan/VulkanRenderManager.h b/Common/GPU/Vulkan/VulkanRenderManager.h index 1914f5214c..d2adc7d346 100644 --- a/Common/GPU/Vulkan/VulkanRenderManager.h +++ b/Common/GPU/Vulkan/VulkanRenderManager.h @@ -185,13 +185,22 @@ public: // Clamp to curWidth_/curHeight_. Apparently an issue. if ((int)(rc.offset.x + rc.extent.width) > curWidth_) { - rc.extent.width = curWidth_ - rc.offset.x; + int newWidth = curWidth_ - rc.offset.x; + rc.extent.width = std::max(1, newWidth); + if (rc.offset.x >= curWidth_) { + // Fallback. + rc.offset.x = curWidth_ - rc.extent.width; + } } + if ((int)(rc.offset.y + rc.extent.height) > curHeight_) { - rc.extent.height = curHeight_ - rc.offset.y; + int newHeight = curHeight_ - rc.offset.y; + rc.extent.height = std::max(1, newHeight); + if (rc.offset.y >= curHeight_) { + // Fallback. + rc.offset.y = curHeight_ - rc.extent.height; + } } - _dbg_assert_((int)(rc.offset.x + rc.extent.width) <= curWidth_); - _dbg_assert_((int)(rc.offset.y + rc.extent.height) <= curHeight_); curRenderArea_.Apply(rc); VkRenderData data{ VKRRenderCommand::SCISSOR }; diff --git a/GPU/Common/PostShader.cpp b/GPU/Common/PostShader.cpp index fbb7297dea..b174b78191 100644 --- a/GPU/Common/PostShader.cpp +++ b/GPU/Common/PostShader.cpp @@ -83,7 +83,7 @@ void LoadPostShaderInfo(const std::vector &directories) { std::vector fileInfo; VFSGetFileListing(directories[d].c_str(), &fileInfo, "ini:"); - if (fileInfo.size() == 0) { + if (fileInfo.empty()) { File::GetFilesInDir(directories[d], &fileInfo, "ini:"); }