Browse Source

[vulkan] Correction on unconditional/ harcoded makeview 2D array vs compute shader 3D views

vk-experiments7
CamilleLaVey 4 weeks ago
parent
commit
3352f0662c
  1. 15
      src/video_core/renderer_vulkan/vk_texture_cache.cpp

15
src/video_core/renderer_vulkan/vk_texture_cache.cpp

@ -229,7 +229,8 @@ constexpr VkBorderColor ConvertBorderColor(const std::array<float, 4>& color) {
} }
[[nodiscard]] vk::ImageView MakeStorageView(const vk::Device& device, u32 level, VkImage image, [[nodiscard]] vk::ImageView MakeStorageView(const vk::Device& device, u32 level, VkImage image,
VkFormat format) {
VkFormat format,
VkImageViewType view_type = VK_IMAGE_VIEW_TYPE_2D_ARRAY) {
static constexpr VkImageViewUsageCreateInfo storage_image_view_usage_create_info{ static constexpr VkImageViewUsageCreateInfo storage_image_view_usage_create_info{
.sType = VK_STRUCTURE_TYPE_IMAGE_VIEW_USAGE_CREATE_INFO, .sType = VK_STRUCTURE_TYPE_IMAGE_VIEW_USAGE_CREATE_INFO,
.pNext = nullptr, .pNext = nullptr,
@ -240,7 +241,7 @@ constexpr VkBorderColor ConvertBorderColor(const std::array<float, 4>& color) {
.pNext = &storage_image_view_usage_create_info, .pNext = &storage_image_view_usage_create_info,
.flags = 0, .flags = 0,
.image = image, .image = image,
.viewType = VK_IMAGE_VIEW_TYPE_2D_ARRAY,
.viewType = view_type,
.format = format, .format = format,
.components{ .components{
.r = VK_COMPONENT_SWIZZLE_IDENTITY, .r = VK_COMPONENT_SWIZZLE_IDENTITY,
@ -1625,6 +1626,8 @@ Image::Image(TextureCacheRuntime& runtime_, const ImageInfo& info_, GPUVAddr gpu
flags |= VideoCommon::ImageFlagBits::CostlyLoad; flags |= VideoCommon::ImageFlagBits::CostlyLoad;
} }
if (!IsPixelFormatASTC(info.format) && !IsPixelFormatBCn(info.format) && if (!IsPixelFormatASTC(info.format) && !IsPixelFormatBCn(info.format) &&
VideoCore::Surface::GetFormatType(info.format) ==
VideoCore::Surface::SurfaceType::ColorTexture &&
(info.type == ImageType::e2D || info.type == ImageType::e3D || (info.type == ImageType::e2D || info.type == ImageType::e3D ||
info.type == ImageType::Linear)) { info.type == ImageType::Linear)) {
if (IsUnswizzleStorageFormatSupported(runtime->device, if (IsUnswizzleStorageFormatSupported(runtime->device,
@ -1649,8 +1652,14 @@ Image::Image(TextureCacheRuntime& runtime_, const ImageInfo& info_, GPUVAddr gpu
const auto& device = runtime->device.GetLogical(); const auto& device = runtime->device.GetLogical();
const VkFormat storage_format = const VkFormat storage_format =
UnswizzleStorageFormat(VideoCore::Surface::BytesPerBlock(info.format)); UnswizzleStorageFormat(VideoCore::Surface::BytesPerBlock(info.format));
const VkImageViewType storage_view_type = info.type == ImageType::e3D
? VK_IMAGE_VIEW_TYPE_3D
: info.type == ImageType::Linear
? VK_IMAGE_VIEW_TYPE_2D
: VK_IMAGE_VIEW_TYPE_2D_ARRAY;
for (s32 level = 0; level < info.resources.levels; ++level) { for (s32 level = 0; level < info.resources.levels; ++level) {
storage_image_views[level] = MakeStorageView(device, level, *original_image, storage_format);
storage_image_views[level] =
MakeStorageView(device, level, *original_image, storage_format, storage_view_type);
} }
} }
} }

Loading…
Cancel
Save