diff --git a/Common/GPU/Vulkan/VulkanContext.cpp b/Common/GPU/Vulkan/VulkanContext.cpp index ef139e4ca7..9435c988d3 100644 --- a/Common/GPU/Vulkan/VulkanContext.cpp +++ b/Common/GPU/Vulkan/VulkanContext.cpp @@ -537,9 +537,13 @@ void VulkanContext::ChooseDevice(int physical_device) { break; } } - if (deviceInfo_.preferredDepthStencilFormat == VK_FORMAT_UNDEFINED) { - // WTF? This is bad. - ERROR_LOG(G3D, "Could not find a usable depth stencil format."); + + _assert_msg_(deviceInfo_.preferredDepthStencilFormat != VK_FORMAT_UNDEFINED, "Could not find a usable depth stencil format."); + VkFormatProperties preferredProps; + vkGetPhysicalDeviceFormatProperties(physical_devices_[physical_device_], deviceInfo_.preferredDepthStencilFormat, &preferredProps); + if ((preferredProps.optimalTilingFeatures & VK_FORMAT_FEATURE_BLIT_SRC_BIT) && + (preferredProps.optimalTilingFeatures & VK_FORMAT_FEATURE_BLIT_DST_BIT)) { + deviceInfo_.canBlitToPreferredDepthStencilFormat = true; } // This is as good a place as any to do this. diff --git a/Common/GPU/Vulkan/VulkanContext.h b/Common/GPU/Vulkan/VulkanContext.h index a14f96bdd7..ec2fa44beb 100644 --- a/Common/GPU/Vulkan/VulkanContext.h +++ b/Common/GPU/Vulkan/VulkanContext.h @@ -52,6 +52,7 @@ enum WindowSystem { struct VulkanPhysicalDeviceInfo { VkFormat preferredDepthStencilFormat; + bool canBlitToPreferredDepthStencilFormat; }; // This is a bit repetitive... diff --git a/GPU/Common/FramebufferManagerCommon.cpp b/GPU/Common/FramebufferManagerCommon.cpp index 5ecc84dd88..cb656a35ef 100644 --- a/GPU/Common/FramebufferManagerCommon.cpp +++ b/GPU/Common/FramebufferManagerCommon.cpp @@ -471,7 +471,7 @@ void FramebufferManagerCommon::BlitFramebufferDepth(VirtualFramebuffer *src, Vir int h = std::min(src->renderHeight, dst->renderHeight); // Note: We prefer Blit ahead of Copy here, since at least on GL, Copy will always also copy stencil which we don't want. See #9740. - if (gstate_c.Supports(GPU_SUPPORTS_FRAMEBUFFER_BLIT)) { + if (gstate_c.Supports(GPU_SUPPORTS_FRAMEBUFFER_BLIT_TO_DEPTH)) { draw_->BlitFramebuffer(src->fbo, 0, 0, w, h, dst->fbo, 0, 0, w, h, Draw::FB_DEPTH_BIT, Draw::FB_BLIT_NEAREST, "BlitFramebufferDepth"); RebindFramebuffer("BlitFramebufferDepth"); } else if (gstate_c.Supports(GPU_SUPPORTS_COPY_IMAGE)) { diff --git a/GPU/GPUState.h b/GPU/GPUState.h index f012e023bc..b23b6fd1fb 100644 --- a/GPU/GPUState.h +++ b/GPU/GPUState.h @@ -490,6 +490,7 @@ enum { GPU_ROUND_DEPTH_TO_16BIT = FLAG_BIT(23), // Can be disabled either per game or if we use a real 16-bit depth buffer GPU_SUPPORTS_TEXTURE_LOD_CONTROL = FLAG_BIT(24), GPU_SUPPORTS_FRAMEBUFFER_BLIT = FLAG_BIT(26), + GPU_SUPPORTS_FRAMEBUFFER_BLIT_TO_DEPTH = FLAG_BIT(27), GPU_SUPPORTS_OES_TEXTURE_NPOT = FLAG_BIT(28), GPU_NEEDS_Z_EQUAL_W_HACK = FLAG_BIT(29), GPU_PREFER_CPU_DOWNLOAD = FLAG_BIT(30), diff --git a/GPU/Vulkan/GPU_Vulkan.cpp b/GPU/Vulkan/GPU_Vulkan.cpp index 197774e8d5..caa979b8b8 100644 --- a/GPU/Vulkan/GPU_Vulkan.cpp +++ b/GPU/Vulkan/GPU_Vulkan.cpp @@ -233,6 +233,10 @@ void GPU_Vulkan::CheckGPUFeatures() { features |= GPU_SUPPORTS_TEXTURE_FLOAT; features |= GPU_PREFER_CPU_DOWNLOAD; + if (vulkan_->GetDeviceInfo().canBlitToPreferredDepthStencilFormat) { + features |= GPU_SUPPORTS_FRAMEBUFFER_BLIT_TO_DEPTH; + } + if (vulkan_->GetDeviceFeatures().enabled.wideLines) { features |= GPU_SUPPORTS_WIDE_LINES; }