Fix a few issues with the intel anv vulkan driver from mesa (#514)

* add fallback format for d16UnormS8Uint which is not supported by intel

* fix depth/stencil buffer creation issues causing asserts in intel driver
This commit is contained in:
Random 2024-08-24 14:50:46 +02:00 committed by GitHub
parent 2c540fbecb
commit fc745ee767
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 11 additions and 6 deletions

View File

@ -306,6 +306,7 @@ std::span<const vk::Format> GetAllFormats() {
vk::Format::eBc7UnormBlock, vk::Format::eBc7UnormBlock,
vk::Format::eD16Unorm, vk::Format::eD16Unorm,
vk::Format::eD16UnormS8Uint, vk::Format::eD16UnormS8Uint,
vk::Format::eD24UnormS8Uint,
vk::Format::eD32Sfloat, vk::Format::eD32Sfloat,
vk::Format::eD32SfloatS8Uint, vk::Format::eD32SfloatS8Uint,
vk::Format::eR4G4B4A4UnormPack16, vk::Format::eR4G4B4A4UnormPack16,

View File

@ -481,6 +481,8 @@ bool Instance::IsFormatSupported(const vk::Format format) const {
vk::Format Instance::GetAlternativeFormat(const vk::Format format) const { vk::Format Instance::GetAlternativeFormat(const vk::Format format) const {
if (format == vk::Format::eB5G6R5UnormPack16) { if (format == vk::Format::eB5G6R5UnormPack16) {
return vk::Format::eR5G6B5UnormPack16; return vk::Format::eR5G6B5UnormPack16;
} else if (format == vk::Format::eD16UnormS8Uint) {
return vk::Format::eD24UnormS8Uint;
} }
return format; return format;
} }

View File

@ -73,14 +73,15 @@ static vk::ImageUsageFlags ImageUsageFlags(const ImageInfo& info) {
if (!info.IsBlockCoded() && !info.IsPacked()) { if (!info.IsBlockCoded() && !info.IsPacked()) {
usage |= vk::ImageUsageFlagBits::eColorAttachment; usage |= vk::ImageUsageFlagBits::eColorAttachment;
} }
}
// In cases where an image is created as a render/depth target and cleared with compute, // In cases where an image is created as a render/depth target and cleared with compute,
// we cannot predict whether it will be used as a storage image. A proper solution would // we cannot predict whether it will be used as a storage image. A proper solution would
// involve re-creating the resource with a new configuration and copying previous content into // involve re-creating the resource with a new configuration and copying previous content
// it. However, for now, we will set storage usage for all images (if the format allows), // into it. However, for now, we will set storage usage for all images (if the format
// sacrificing a bit of performance. Note use of ExtendedUsage flag set by default. // allows), sacrificing a bit of performance. Note use of ExtendedUsage flag set by default.
usage |= vk::ImageUsageFlagBits::eStorage; usage |= vk::ImageUsageFlagBits::eStorage;
}
return usage; return usage;
} }

View File

@ -200,6 +200,7 @@ ImageView& TextureCache::FindDepthTarget(const ImageInfo& image_info,
Image& image = slot_images[image_id]; Image& image = slot_images[image_id];
image.flags |= ImageFlagBits::GpuModified; image.flags |= ImageFlagBits::GpuModified;
image.flags &= ~ImageFlagBits::CpuModified; image.flags &= ~ImageFlagBits::CpuModified;
image.aspect_mask = vk::ImageAspectFlagBits::eDepth | vk::ImageAspectFlagBits::eStencil;
const auto new_layout = view_info.is_storage ? vk::ImageLayout::eDepthStencilAttachmentOptimal const auto new_layout = view_info.is_storage ? vk::ImageLayout::eDepthStencilAttachmentOptimal
: vk::ImageLayout::eDepthStencilReadOnlyOptimal; : vk::ImageLayout::eDepthStencilReadOnlyOptimal;