fixed depth promotion to do not use stencil

This commit is contained in:
psucien 2024-09-19 23:02:10 +02:00
parent 2f689972e4
commit 183523a5c7
3 changed files with 14 additions and 7 deletions

View file

@ -4,6 +4,7 @@
#pragma once
#include <span>
#include "common/assert.h"
#include "video_core/amdgpu/liverpool.h"
#include "video_core/amdgpu/pixel_format.h"
#include "video_core/amdgpu/resource.h"
@ -55,4 +56,13 @@ vk::SampleCountFlagBits NumSamples(u32 num_samples, vk::SampleCountFlags support
void EmitQuadToTriangleListIndices(u8* out_indices, u32 num_vertices);
static inline vk::Format PromoteFormatToDepth(vk::Format fmt) {
if (fmt == vk::Format::eR32Sfloat) {
return vk::Format::eD32Sfloat;
} else if (fmt == vk::Format::eR16Unorm) {
return vk::Format::eD16Unorm;
}
UNREACHABLE();
}
} // namespace Vulkan::LiverpoolToVK

View file

@ -205,13 +205,7 @@ ImageInfo::ImageInfo(const AmdGpu::Image& image, bool force_depth /*= false*/) n
pixel_format = LiverpoolToVK::SurfaceFormat(image.GetDataFmt(), image.GetNumberFmt());
// Override format if image is forced to be a depth target
if (force_depth) {
if (pixel_format == vk::Format::eR32Sfloat || pixel_format == vk::Format::eR8Unorm) {
pixel_format = vk::Format::eD32SfloatS8Uint;
} else if (pixel_format == vk::Format::eR16Unorm) {
pixel_format = vk::Format::eD16UnormS8Uint;
} else {
UNREACHABLE();
}
pixel_format = LiverpoolToVK::PromoteFormatToDepth(pixel_format);
}
type = ConvertImageType(image.GetType());
props.is_tiled = image.IsTiled();

View file

@ -75,6 +75,9 @@ ImageViewInfo::ImageViewInfo(const AmdGpu::Image& image, const Shader::ImageReso
nfmt = AmdGpu::NumberFormat::Unorm;
}
format = Vulkan::LiverpoolToVK::SurfaceFormat(dfmt, nfmt);
if (desc.is_depth) {
format = Vulkan::LiverpoolToVK::PromoteFormatToDepth(format);
}
range.base.level = image.base_level;
range.base.layer = image.base_array;
range.extent.levels = image.last_level - image.base_level + 1;