From 51d64c298d7127dd7a7e616887196ef6b8f184f3 Mon Sep 17 00:00:00 2001 From: CamilleLaVey Date: Sat, 19 Sep 2026 04:40:22 -0400 Subject: [PATCH] Some reviews on storage views --- .../renderer_vulkan/vk_texture_cache.cpp | 35 +++++++++++++++++-- 1 file changed, 32 insertions(+), 3 deletions(-) diff --git a/src/video_core/renderer_vulkan/vk_texture_cache.cpp b/src/video_core/renderer_vulkan/vk_texture_cache.cpp index c44546c254..f3142215ff 100644 --- a/src/video_core/renderer_vulkan/vk_texture_cache.cpp +++ b/src/video_core/renderer_vulkan/vk_texture_cache.cpp @@ -180,7 +180,7 @@ constexpr VkBorderColor ConvertBorderColor(const std::array& color) { !device.IsStorageBuffer16BitAccessSupported()) { return false; } - if (IsPixelFormatASTC(format) || VideoCore::Surface::IsPixelFormatBCn(format)) { + if (DefaultBlockWidth(format) != 1 || DefaultBlockHeight(format) != 1) { return false; } if (VideoCore::Surface::GetFormatType(format) != SurfaceType::ColorTexture) { @@ -204,6 +204,29 @@ constexpr VkBorderColor ConvertBorderColor(const std::array& color) { return IsUnswizzleAcceleratedFormat(device, info.format); } +[[nodiscard]] std::array ShaderStorageViewFormats(PixelFormat format) { + if (VideoCore::Surface::GetFormatType(format) != SurfaceType::ColorTexture) { + return {}; + } + if (DefaultBlockWidth(format) != 1 || DefaultBlockHeight(format) != 1) { + return {}; + } + switch (BytesPerBlock(format)) { + case 1: + return {VK_FORMAT_R8_UINT, VK_FORMAT_R8_SINT}; + case 2: + return {VK_FORMAT_R16_UINT, VK_FORMAT_R16_SINT}; + case 4: + return {VK_FORMAT_R32_UINT, VK_FORMAT_UNDEFINED}; + case 8: + return {VK_FORMAT_R32G32_UINT, VK_FORMAT_UNDEFINED}; + case 16: + return {VK_FORMAT_R32G32B32A32_UINT, VK_FORMAT_UNDEFINED}; + default: + return {}; + } +} + [[nodiscard]] VkImageCreateInfo MakeImageCreateInfo(const Device& device, const ImageInfo& info, std::optional format_override = {}) { auto format_info = @@ -1002,8 +1025,6 @@ TextureCacheRuntime::TextureCacheRuntime(const Device& device_, Scheduler& sched const auto image_format = static_cast(index_a); if (IsPixelFormatASTC(image_format) && !device.IsOptimalAstcSupported()) { view_formats[index_a].push_back(VK_FORMAT_A8B8G8R8_UNORM_PACK32); - } else if (IsUnswizzleAcceleratedFormat(device, image_format)) { - view_formats[index_a].push_back(UnswizzleStorageFormat(BytesPerBlock(image_format))); } for (size_t index_b = 0; index_b < VideoCore::Surface::MaxPixelFormat; index_b++) { const auto view_format = static_cast(index_b); @@ -1013,6 +1034,14 @@ TextureCacheRuntime::TextureCacheRuntime(const Device& device_, Scheduler& sched view_formats[index_a].push_back(view_info.format); } } + auto& formats = view_formats[index_a]; + for (const VkFormat storage_format : ShaderStorageViewFormats(image_format)) { + if (storage_format == VK_FORMAT_UNDEFINED || + std::ranges::find(formats, storage_format) != formats.end()) { + continue; + } + formats.push_back(storage_format); + } } }