VERY experimental Nintendo Switch 2 emulator
C++
Texture Cache: Fix ASTC textures
Fernando Sahmkowa1317c3a6e7a
diff --git a/src/video_core/renderer_opengl/gl_texture_cache.cpp b/src/video_core/renderer_opengl/gl_texture_cache.cppindex 052456f61d..31118886fb 100644--- a/src/video_core/renderer_opengl/gl_texture_cache.cpp+++ b/src/video_core/renderer_opengl/gl_texture_cache.cpp@@ -231,7 +231,7 @@ void ApplySwizzle(GLuint handle, PixelFormat format, std::array<SwizzleSource, 4[[nodiscard]] bool CanBeAccelerated(const TextureCacheRuntime& runtime,const VideoCommon::ImageInfo& info) {- if (IsPixelFormatASTC(info.format) && !runtime.HasNativeASTC()) {+ if (IsPixelFormatASTC(info.format) && info.size.depth == 1 && !runtime.HasNativeASTC()) {return Settings::values.accelerate_astc.GetValue() &&!Settings::values.async_astc.GetValue();}diff --git a/src/video_core/renderer_vulkan/vk_texture_cache.cpp b/src/video_core/renderer_vulkan/vk_texture_cache.cppindex 99dd1260a7..9ca7751c5c 100644--- a/src/video_core/renderer_vulkan/vk_texture_cache.cpp+++ b/src/video_core/renderer_vulkan/vk_texture_cache.cpp@@ -1268,7 +1268,7 @@ Image::Image(TextureCacheRuntime& runtime_, const ImageInfo& info_, GPUVAddr gpuif (IsPixelFormatASTC(info.format) && !runtime->device.IsOptimalAstcSupported()) {if (Settings::values.async_astc.GetValue()) {flags |= VideoCommon::ImageFlagBits::AsynchronousDecode;- } else if (Settings::values.accelerate_astc.GetValue()) {+ } else if (Settings::values.accelerate_astc.GetValue() && info.size.depth == 1) {flags |= VideoCommon::ImageFlagBits::AcceleratedUpload;}flags |= VideoCommon::ImageFlagBits::Converted;diff --git a/src/video_core/texture_cache/util.cpp b/src/video_core/texture_cache/util.cppindex de37db684c..f1071aa235 100644--- a/src/video_core/texture_cache/util.cpp+++ b/src/video_core/texture_cache/util.cpp@@ -896,11 +896,11 @@ void ConvertImage(std::span<const u8> input, const ImageInfo& info, std::span<u8ASSERT(copy.buffer_row_length == Common::AlignUp(mip_size.width, tile_size.width));ASSERT(copy.buffer_image_height == Common::AlignUp(mip_size.height, tile_size.height));if (IsPixelFormatASTC(info.format)) {- ASSERT(copy.image_extent.depth == 1);- Tegra::Texture::ASTC::Decompress(input.subspan(copy.buffer_offset),- copy.image_extent.width, copy.image_extent.height,- copy.image_subresource.num_layers, tile_size.width,- tile_size.height, output.subspan(output_offset));+ Tegra::Texture::ASTC::Decompress(+ input.subspan(copy.buffer_offset), copy.image_extent.width,+ copy.image_extent.height,+ copy.image_subresource.num_layers * copy.image_extent.depth, tile_size.width,+ tile_size.height, output.subspan(output_offset));} else {DecompressBC4(input.subspan(copy.buffer_offset), copy.image_extent,output.subspan(output_offset));