Use a cleaner error check

This commit is contained in:
kalaposfos13 2025-04-20 19:15:12 +02:00
parent 7fa2d0ea42
commit 1f1f8d1037
3 changed files with 6 additions and 9 deletions

View File

@ -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

View File

@ -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()));

View File

@ -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()));
}