vk: Support explicit mutable format list

- Actually important for performance reasons
This commit is contained in:
kd-11 2026-02-22 21:36:54 +03:00 committed by kd-11
parent 794abe2025
commit f27315c821
3 changed files with 31 additions and 4 deletions

View file

@ -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

View file

@ -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

View file

@ -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<vk::memory_block> 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,