From e9a691e95ec40794ab120d1bbf6a8361cceb4024 Mon Sep 17 00:00:00 2001 From: squidbus <175574877+squidbus@users.noreply.github.com> Date: Sun, 8 Dec 2024 00:19:39 -0800 Subject: [PATCH] image_view: Add more BGRA storage format swizzles. (#1693) --- .../renderer_vulkan/vk_instance.cpp | 5 +++-- src/video_core/texture_cache/image_view.cpp | 21 ++++++++++++++----- 2 files changed, 19 insertions(+), 7 deletions(-) diff --git a/src/video_core/renderer_vulkan/vk_instance.cpp b/src/video_core/renderer_vulkan/vk_instance.cpp index 49e4987db..81784eb60 100644 --- a/src/video_core/renderer_vulkan/vk_instance.cpp +++ b/src/video_core/renderer_vulkan/vk_instance.cpp @@ -70,8 +70,9 @@ std::unordered_map GetFormatProperties( static constexpr std::array misc_formats = { vk::Format::eA2R10G10B10UnormPack32, vk::Format::eA8B8G8R8UnormPack32, vk::Format::eA8B8G8R8SrgbPack32, vk::Format::eB8G8R8A8Unorm, - vk::Format::eB8G8R8A8Srgb, vk::Format::eR5G6B5UnormPack16, - vk::Format::eD24UnormS8Uint, + vk::Format::eB8G8R8A8Snorm, vk::Format::eB8G8R8A8Uint, + vk::Format::eB8G8R8A8Sint, vk::Format::eB8G8R8A8Srgb, + vk::Format::eR5G6B5UnormPack16, vk::Format::eD24UnormS8Uint, }; for (const auto& format : misc_formats) { if (!format_properties.contains(format)) { diff --git a/src/video_core/texture_cache/image_view.cpp b/src/video_core/texture_cache/image_view.cpp index 61cabdf11..57a58c714 100644 --- a/src/video_core/texture_cache/image_view.cpp +++ b/src/video_core/texture_cache/image_view.cpp @@ -58,11 +58,22 @@ bool IsIdentityMapping(u32 dst_sel, u32 num_components) { } vk::Format TrySwizzleFormat(vk::Format format, u32 dst_sel) { - if (format == vk::Format::eR8G8B8A8Unorm && dst_sel == 0b111100101110) { - return vk::Format::eB8G8R8A8Unorm; - } - if (format == vk::Format::eR8G8B8A8Srgb && dst_sel == 0b111100101110) { - return vk::Format::eB8G8R8A8Srgb; + // BGRA + if (dst_sel == 0b111100101110) { + switch (format) { + case vk::Format::eR8G8B8A8Unorm: + return vk::Format::eB8G8R8A8Unorm; + case vk::Format::eR8G8B8A8Snorm: + return vk::Format::eB8G8R8A8Snorm; + case vk::Format::eR8G8B8A8Uint: + return vk::Format::eB8G8R8A8Uint; + case vk::Format::eR8G8B8A8Sint: + return vk::Format::eB8G8R8A8Sint; + case vk::Format::eR8G8B8A8Srgb: + return vk::Format::eB8G8R8A8Srgb; + default: + break; + } } return format; }