From 486a835d0a891df7fffeba59a0a4d75985c925df Mon Sep 17 00:00:00 2001 From: Billy Laws Date: Sat, 9 Apr 2022 12:54:28 +0100 Subject: [PATCH] Use guest texture view type to determine the underlying image type If we have a Nx1x1 image then determining the type from dimensions will result in a 1D image being created thus preventing us from creating a 2D view. By using the image view type we can avoid this for textures from TICs since we know in advance how they will be used --- .../main/cpp/skyline/gpu/texture/texture.cpp | 21 ++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/app/src/main/cpp/skyline/gpu/texture/texture.cpp b/app/src/main/cpp/skyline/gpu/texture/texture.cpp index d5553f16..24cb1f70 100644 --- a/app/src/main/cpp/skyline/gpu/texture/texture.cpp +++ b/app/src/main/cpp/skyline/gpu/texture/texture.cpp @@ -295,17 +295,32 @@ namespace skyline::gpu { if (format->vkAspect & (vk::ImageAspectFlagBits::eDepth | vk::ImageAspectFlagBits::eStencil)) usage |= vk::ImageUsageFlagBits::eDepthStencilAttachment; + // First attempt to derive type from dimensions + auto imageType{guest->dimensions.GetType()}; + + // Try to ensure that the image type is compatible with the given image view type since we can't create a 2D image view from a 1D image + if (imageType == vk::ImageType::e1D && guest->type != texture::TextureType::e1D && guest->type != texture::TextureType::e1DArray) { + switch (guest->type) { + case texture::TextureType::e3D: + imageType = vk::ImageType::e3D; + break; + default: + imageType = vk::ImageType::e2D; + break; + } + } + vk::ImageCreateFlags flags{gpu.traits.quirks.vkImageMutableFormatCostly ? vk::ImageCreateFlags{} : vk::ImageCreateFlagBits::eMutableFormat}; - if (guest->dimensions.GetType() == vk::ImageType::e2D && dimensions.width == dimensions.height && layerCount >= 6) + if (imageType == vk::ImageType::e2D && dimensions.width == dimensions.height && layerCount >= 6) flags |= vk::ImageCreateFlagBits::eCubeCompatible; - else if (guest->dimensions.GetType() == vk::ImageType::e3D) + else if (imageType == vk::ImageType::e3D) flags |= vk::ImageCreateFlagBits::e2DArrayCompatible; vk::ImageCreateInfo imageCreateInfo{ .flags = flags, - .imageType = guest->dimensions.GetType(), + .imageType = imageType, .format = *guest->format, .extent = guest->dimensions, .mipLevels = 1,