Skip PromoteFormatToDepth in the case of a dummy image

Also add more debug info in case of a failure
This commit is contained in:
kalaposfos13 2025-04-20 15:02:58 +02:00
parent 46b88bd10f
commit 7fa2d0ea42
3 changed files with 20 additions and 7 deletions

View File

@ -100,13 +100,14 @@ static inline bool IsFormatStencilCompatible(vk::Format fmt) {
} }
} }
static inline vk::Format PromoteFormatToDepth(vk::Format fmt) { static inline vk::Format PromoteFormatToDepth(vk::Format fmt, bool& valid) {
if (fmt == vk::Format::eR32Sfloat || fmt == vk::Format::eR32Uint) { if (fmt == vk::Format::eR32Sfloat || fmt == vk::Format::eR32Uint) {
return vk::Format::eD32Sfloat; return vk::Format::eD32Sfloat;
} else if (fmt == vk::Format::eR16Unorm) { } else if (fmt == vk::Format::eR16Unorm) {
return vk::Format::eD16Unorm; return vk::Format::eD16Unorm;
} }
UNREACHABLE_MSG("Unexpected depth format {}", vk::to_string(fmt)); valid = false;
return fmt; // move the unreachable one step up to be able to print more info
} }
} // namespace Vulkan::LiverpoolToVK } // namespace Vulkan::LiverpoolToVK

View File

@ -126,9 +126,15 @@ ImageInfo::ImageInfo(const AmdGpu::Liverpool::DepthBuffer& buffer, u32 num_slice
ImageInfo::ImageInfo(const AmdGpu::Image& image, const Shader::ImageResource& desc) noexcept { ImageInfo::ImageInfo(const AmdGpu::Image& image, const Shader::ImageResource& desc) noexcept {
tiling_mode = image.GetTilingMode(); tiling_mode = image.GetTilingMode();
pixel_format = LiverpoolToVK::SurfaceFormat(image.GetDataFmt(), image.GetNumberFmt()); pixel_format = LiverpoolToVK::SurfaceFormat(image.GetDataFmt(), image.GetNumberFmt());
// Override format if image is forced to be a depth target // Override format if image is forced to be a depth target, except if the image is a dummy one
if (desc.is_depth) { if (desc.is_depth && (image.width != 0 && image.height != 0)) {
pixel_format = LiverpoolToVK::PromoteFormatToDepth(pixel_format); bool valid = true;
pixel_format = Vulkan::LiverpoolToVK::PromoteFormatToDepth(pixel_format, valid);
ASSERT_MSG(
valid,
"PromoteFormatToDepth failed, info dump: format: {}, size: {}x{}, data_format: {}",
vk::to_string(pixel_format), image.width + 1, image.height + 1,
AmdGpu::NameOf(image.GetDataFmt()));
} }
type = ConvertImageType(image.GetType()); type = ConvertImageType(image.GetType());
props.is_tiled = image.IsTiled(); props.is_tiled = image.IsTiled();

View File

@ -37,8 +37,14 @@ ImageViewInfo::ImageViewInfo(const AmdGpu::Image& image, const Shader::ImageReso
nfmt = AmdGpu::NumberFormat::Unorm; nfmt = AmdGpu::NumberFormat::Unorm;
} }
format = Vulkan::LiverpoolToVK::SurfaceFormat(dfmt, nfmt); format = Vulkan::LiverpoolToVK::SurfaceFormat(dfmt, nfmt);
if (desc.is_depth) { // Override format if image is forced to be a depth target, except if the image is a dummy one
format = Vulkan::LiverpoolToVK::PromoteFormatToDepth(format); if (desc.is_depth && (image.width != 0 && image.height != 0)) {
bool valid = true;
format = Vulkan::LiverpoolToVK::PromoteFormatToDepth(format, valid);
ASSERT_MSG(
valid,
"PromoteFormatToDepth failed, info dump: format: {}, size: {}x{}, data_format: {}",
vk::to_string(format), image.width, image.height, AmdGpu::NameOf(image.GetDataFmt()));
} }
range.base.level = image.base_level; range.base.level = image.base_level;