From 7110e2c1de1ede4346154ff69e23a9bd8a975496 Mon Sep 17 00:00:00 2001 From: Xphalnos <164882787+Xphalnos@users.noreply.github.com> Date: Fri, 3 Jan 2025 18:08:41 +0100 Subject: [PATCH] renderer_vulkan: Don't crash if Depth Format is not recognized --- src/video_core/renderer_vulkan/liverpool_to_vk.h | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/video_core/renderer_vulkan/liverpool_to_vk.h b/src/video_core/renderer_vulkan/liverpool_to_vk.h index a68280e7db8..4a67e7b75af 100644 --- a/src/video_core/renderer_vulkan/liverpool_to_vk.h +++ b/src/video_core/renderer_vulkan/liverpool_to_vk.h @@ -71,13 +71,17 @@ vk::ClearValue ColorBufferClearValue(const AmdGpu::Liverpool::ColorBuffer& color vk::SampleCountFlagBits NumSamples(u32 num_samples, vk::SampleCountFlags supported_flags); -static inline vk::Format PromoteFormatToDepth(vk::Format fmt) { - if (fmt == vk::Format::eR32Sfloat) { +static vk::Format PromoteFormatToDepth(vk::Format fmt) { + switch (fmt) { + case vk::Format::eR32Sfloat: return vk::Format::eD32Sfloat; - } else if (fmt == vk::Format::eR16Unorm) { + case vk::Format::eR16Unorm: return vk::Format::eD16Unorm; + default: + LOG_ERROR(Render_Vulkan, "Unexpected Depth Format {}", vk::to_string(fmt)); + break; } - UNREACHABLE(); + return fmt; } } // namespace Vulkan::LiverpoolToVK