From 1f1f8d1037cc4aaa0fe09512e5846aa1f0836599 Mon Sep 17 00:00:00 2001 From: kalaposfos13 <153381648+kalaposfos13@users.noreply.github.com> Date: Sun, 20 Apr 2025 19:15:12 +0200 Subject: [PATCH] Use a cleaner error check --- src/video_core/renderer_vulkan/liverpool_to_vk.h | 5 ++--- src/video_core/texture_cache/image_info.cpp | 5 ++--- src/video_core/texture_cache/image_view.cpp | 5 ++--- 3 files changed, 6 insertions(+), 9 deletions(-) diff --git a/src/video_core/renderer_vulkan/liverpool_to_vk.h b/src/video_core/renderer_vulkan/liverpool_to_vk.h index 942f7cfe8..29593991c 100644 --- a/src/video_core/renderer_vulkan/liverpool_to_vk.h +++ b/src/video_core/renderer_vulkan/liverpool_to_vk.h @@ -100,14 +100,13 @@ static inline bool IsFormatStencilCompatible(vk::Format fmt) { } } -static inline vk::Format PromoteFormatToDepth(vk::Format fmt, bool& valid) { +static inline vk::Format PromoteFormatToDepth(vk::Format fmt) { if (fmt == vk::Format::eR32Sfloat || fmt == vk::Format::eR32Uint) { return vk::Format::eD32Sfloat; } else if (fmt == vk::Format::eR16Unorm) { return vk::Format::eD16Unorm; } - valid = false; - return fmt; // move the unreachable one step up to be able to print more info + return vk::Format::eUndefined; } } // namespace Vulkan::LiverpoolToVK diff --git a/src/video_core/texture_cache/image_info.cpp b/src/video_core/texture_cache/image_info.cpp index 53d61c51e..1056e5d78 100644 --- a/src/video_core/texture_cache/image_info.cpp +++ b/src/video_core/texture_cache/image_info.cpp @@ -128,10 +128,9 @@ ImageInfo::ImageInfo(const AmdGpu::Image& image, const Shader::ImageResource& de pixel_format = LiverpoolToVK::SurfaceFormat(image.GetDataFmt(), image.GetNumberFmt()); // Override format if image is forced to be a depth target, except if the image is a dummy one if (desc.is_depth && (image.width != 0 && image.height != 0)) { - bool valid = true; - pixel_format = Vulkan::LiverpoolToVK::PromoteFormatToDepth(pixel_format, valid); + pixel_format = Vulkan::LiverpoolToVK::PromoteFormatToDepth(pixel_format); ASSERT_MSG( - valid, + pixel_format != vk::Format::eUndefined, "PromoteFormatToDepth failed, info dump: format: {}, size: {}x{}, data_format: {}", vk::to_string(pixel_format), image.width + 1, image.height + 1, AmdGpu::NameOf(image.GetDataFmt())); diff --git a/src/video_core/texture_cache/image_view.cpp b/src/video_core/texture_cache/image_view.cpp index 4d02f3bf6..37c8067e4 100644 --- a/src/video_core/texture_cache/image_view.cpp +++ b/src/video_core/texture_cache/image_view.cpp @@ -39,10 +39,9 @@ ImageViewInfo::ImageViewInfo(const AmdGpu::Image& image, const Shader::ImageReso format = Vulkan::LiverpoolToVK::SurfaceFormat(dfmt, nfmt); // Override format if image is forced to be a depth target, except if the image is a dummy one if (desc.is_depth && (image.width != 0 && image.height != 0)) { - bool valid = true; - format = Vulkan::LiverpoolToVK::PromoteFormatToDepth(format, valid); + format = Vulkan::LiverpoolToVK::PromoteFormatToDepth(format); ASSERT_MSG( - valid, + format != vk::Format::eUndefined, "PromoteFormatToDepth failed, info dump: format: {}, size: {}x{}, data_format: {}", vk::to_string(format), image.width, image.height, AmdGpu::NameOf(image.GetDataFmt())); }