From f27315c821cbdf5762ca355bd4c8db76cbe1a2dd Mon Sep 17 00:00:00 2001 From: kd-11 Date: Sun, 22 Feb 2026 21:36:54 +0300 Subject: [PATCH] vk: Support explicit mutable format list - Actually important for performance reasons --- rpcs3/Emu/RSX/VK/vkutils/ex.h | 16 ++++++++++++++++ rpcs3/Emu/RSX/VK/vkutils/image.cpp | 14 ++++++++++++-- rpcs3/Emu/RSX/VK/vkutils/image.h | 5 +++-- 3 files changed, 31 insertions(+), 4 deletions(-) diff --git a/rpcs3/Emu/RSX/VK/vkutils/ex.h b/rpcs3/Emu/RSX/VK/vkutils/ex.h index 361ae1d32d..1a80ffbbf5 100644 --- a/rpcs3/Emu/RSX/VK/vkutils/ex.h +++ b/rpcs3/Emu/RSX/VK/vkutils/ex.h @@ -39,6 +39,22 @@ namespace vk VkDescriptorBufferInfoEx() = default; VkDescriptorBufferInfoEx(const vk::buffer& buffer, u64 offset, u64 range); }; + + struct VkFormatEx + { + VkFormat baseFormat = VK_FORMAT_UNDEFINED; + VkFormat* pViewFormats = nullptr; + u32 viewFormatCount = 0u; + + VkFormatEx() = default; + + VkFormatEx(VkFormat format) + : baseFormat(format) + {} + + operator VkFormat() const { return baseFormat; } + bool is_mutable() const { return viewFormatCount != 0; } + }; } // Re-export diff --git a/rpcs3/Emu/RSX/VK/vkutils/image.cpp b/rpcs3/Emu/RSX/VK/vkutils/image.cpp index c6238ac6e8..b58a95c29b 100644 --- a/rpcs3/Emu/RSX/VK/vkutils/image.cpp +++ b/rpcs3/Emu/RSX/VK/vkutils/image.cpp @@ -47,7 +47,7 @@ namespace vk const memory_type_info& memory_type, u32 access_flags, VkImageType image_type, - VkFormat format, + const VkFormatEx& format, u32 width, u32 height, u32 depth, u32 mipmaps, u32 layers, VkSampleCountFlagBits samples, @@ -59,7 +59,6 @@ namespace vk rsx::format_class format_class) : m_device(dev) { - info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; info.imageType = image_type; info.format = format; info.extent = { width, height, depth }; @@ -84,6 +83,16 @@ namespace vk info.pQueueFamilyIndices = concurrency_queue_families.data(); } + VkImageFormatListCreateInfo format_list = { .sType = VK_STRUCTURE_TYPE_IMAGE_FORMAT_LIST_CREATE_INFO }; + if (format.is_mutable()) + { + info.flags |= VK_IMAGE_CREATE_MUTABLE_FORMAT_BIT; + + format_list.pViewFormats = format.pViewFormats; + format_list.viewFormatCount = format.viewFormatCount; + info.pNext = &format_list; + } + create_impl(dev, access_flags, memory_type, allocation_pool); m_storage_aspect = get_aspect_flags(format); @@ -100,6 +109,7 @@ namespace vk } m_format_class = format_class; + info.pNext = nullptr; } // TODO: Ctor that uses a provided memory heap diff --git a/rpcs3/Emu/RSX/VK/vkutils/image.h b/rpcs3/Emu/RSX/VK/vkutils/image.h index abf708559d..a301db6a6d 100644 --- a/rpcs3/Emu/RSX/VK/vkutils/image.h +++ b/rpcs3/Emu/RSX/VK/vkutils/image.h @@ -5,6 +5,7 @@ #include "commands.h" #include "device.h" +#include "ex.h" #include "memory.h" #include "unique_resource.h" @@ -46,14 +47,14 @@ namespace vk VkComponentMapping native_component_map = { VK_COMPONENT_SWIZZLE_R, VK_COMPONENT_SWIZZLE_G, VK_COMPONENT_SWIZZLE_B, VK_COMPONENT_SWIZZLE_A }; VkImageLayout current_layout = VK_IMAGE_LAYOUT_UNDEFINED; u32 current_queue_family = VK_QUEUE_FAMILY_IGNORED; - VkImageCreateInfo info = {}; + VkImageCreateInfo info = { .sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO }; std::shared_ptr memory; image(const vk::render_device& dev, const memory_type_info& memory_type, u32 access_flags, VkImageType image_type, - VkFormat format, + const VkFormatEx& format, u32 width, u32 height, u32 depth, u32 mipmaps, u32 layers, VkSampleCountFlagBits samples,