diff --git a/GPU/Common/FramebufferCommon.cpp b/GPU/Common/FramebufferCommon.cpp index c00afc1a26c8..91b339b7a0dc 100644 --- a/GPU/Common/FramebufferCommon.cpp +++ b/GPU/Common/FramebufferCommon.cpp @@ -1355,7 +1355,7 @@ void FramebufferManagerCommon::FindTransferFramebuffers(VirtualFramebuffer *&dst // Some games use mismatching bitdepths. But make sure the stride matches. // If it doesn't, generally this means we detected the framebuffer with too large a height. - bool match = yOffset < dstYOffset && yOffset < vfb->height; + bool match = yOffset < dstYOffset && (int)yOffset <= (int)vfb->height - dstHeight; if (match && vfb_byteStride != byteStride) { // Grand Knights History copies with a mismatching stride but a full line at a time. // Makes it hard to detect the wrong transfers in e.g. God of War. @@ -1385,7 +1385,7 @@ void FramebufferManagerCommon::FindTransferFramebuffers(VirtualFramebuffer *&dst const u32 byteOffset = srcBasePtr - vfb_address; const u32 byteStride = srcStride * bpp; const u32 yOffset = byteOffset / byteStride; - bool match = yOffset < srcYOffset && yOffset < vfb->height; + bool match = yOffset < srcYOffset && (int)yOffset <= (int)vfb->height - srcHeight; if (match && vfb_byteStride != byteStride) { if (width != srcStride || (byteStride * height != vfb_byteStride && byteStride * height != vfb_byteWidth)) { match = false; diff --git a/ext/native/thin3d/VulkanRenderManager.h b/ext/native/thin3d/VulkanRenderManager.h index 87de896d4fff..f27de5d85d84 100644 --- a/ext/native/thin3d/VulkanRenderManager.h +++ b/ext/native/thin3d/VulkanRenderManager.h @@ -12,6 +12,7 @@ #include "Common/Vulkan/VulkanContext.h" #include "math/dataconv.h" +#include "math/math_util.h" #include "thin3d/DataFormat.h" #include "thin3d/VulkanQueueRunner.h" @@ -117,7 +118,14 @@ class VulkanRenderManager { void SetViewport(const VkViewport &vp) { _dbg_assert_(G3D, curRenderStep_ && curRenderStep_->stepType == VKRStepType::RENDER); VkRenderData data{ VKRRenderCommand::VIEWPORT }; - data.viewport.vp = vp; + data.viewport.vp.x = vp.x; + data.viewport.vp.y = vp.y; + data.viewport.vp.width = vp.width; + data.viewport.vp.height = vp.height; + // We can't allow values outside this range unless we use VK_EXT_depth_range_unrestricted. + // Sometimes state mapping produces 65536/65535 which is slightly outside. + data.viewport.vp.maxDepth = clamp_value(vp.maxDepth, 0.0f, 1.0f); + data.viewport.vp.minDepth = clamp_value(vp.minDepth, 0.0f, 1.0f); curRenderStep_->commands.push_back(data); }