liverpool_to_vk: Add R32Uint depth promote. (#2145)

This commit is contained in:
squidbus 2025-01-15 07:33:15 -08:00 committed by GitHub
parent c10f9b8269
commit 53d0a309cc
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 30 additions and 4 deletions

View file

@ -71,8 +71,35 @@ vk::ClearValue ColorBufferClearValue(const AmdGpu::Liverpool::ColorBuffer& color
vk::SampleCountFlagBits NumSamples(u32 num_samples, vk::SampleCountFlags supported_flags); vk::SampleCountFlagBits NumSamples(u32 num_samples, vk::SampleCountFlags supported_flags);
static inline bool IsFormatDepthCompatible(vk::Format fmt) {
switch (fmt) {
// 32-bit float compatible
case vk::Format::eD32Sfloat:
case vk::Format::eR32Sfloat:
case vk::Format::eR32Uint:
// 16-bit unorm compatible
case vk::Format::eD16Unorm:
case vk::Format::eR16Unorm:
return true;
default:
return false;
}
}
static inline bool IsFormatStencilCompatible(vk::Format fmt) {
switch (fmt) {
// 8-bit uint compatible
case vk::Format::eS8Uint:
case vk::Format::eR8Uint:
case vk::Format::eR8Unorm:
return true;
default:
return false;
}
}
static inline vk::Format PromoteFormatToDepth(vk::Format fmt) { static inline vk::Format PromoteFormatToDepth(vk::Format fmt) {
if (fmt == vk::Format::eR32Sfloat) { 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;

View file

@ -82,13 +82,12 @@ ImageView::ImageView(const Vulkan::Instance& instance, const ImageViewInfo& info
vk::Format format = info.format; vk::Format format = info.format;
vk::ImageAspectFlags aspect = image.aspect_mask; vk::ImageAspectFlags aspect = image.aspect_mask;
if (image.aspect_mask & vk::ImageAspectFlagBits::eDepth && if (image.aspect_mask & vk::ImageAspectFlagBits::eDepth &&
(format == vk::Format::eR32Sfloat || format == vk::Format::eD32Sfloat || Vulkan::LiverpoolToVK::IsFormatDepthCompatible(format)) {
format == vk::Format::eR16Unorm || format == vk::Format::eD16Unorm)) {
format = image.info.pixel_format; format = image.info.pixel_format;
aspect = vk::ImageAspectFlagBits::eDepth; aspect = vk::ImageAspectFlagBits::eDepth;
} }
if (image.aspect_mask & vk::ImageAspectFlagBits::eStencil && if (image.aspect_mask & vk::ImageAspectFlagBits::eStencil &&
(format == vk::Format::eR8Uint || format == vk::Format::eR8Unorm)) { Vulkan::LiverpoolToVK::IsFormatStencilCompatible(format)) {
format = image.info.pixel_format; format = image.info.pixel_format;
aspect = vk::ImageAspectFlagBits::eStencil; aspect = vk::ImageAspectFlagBits::eStencil;
} }