From 9d0d8461a938bd3e66c5eddce4da21ce4935dcc9 Mon Sep 17 00:00:00 2001 From: Squall-Leonhart Date: Mon, 18 Sep 2023 04:14:01 +1000 Subject: [PATCH] Check that the Extent3D TileShift only operates on a 3D ASTC Texture by checking Mip count It appears that previously the Extent3D Tileshift could apply to Mip 0 of 2D Textures in some cases, this is responsible for breaking Asterix and Obelix, the Recall animation in TOTK and an older version of the Tanslation pack for Tsukihime -A Piece of Blue Glass Moon. I'm open to someone with a better explanation for why these changes fix things, while not regressing TOTKs gloom. --- src/video_core/texture_cache/util.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/video_core/texture_cache/util.cpp b/src/video_core/texture_cache/util.cpp index a83f5d41cf..da8fd469ca 100644 --- a/src/video_core/texture_cache/util.cpp +++ b/src/video_core/texture_cache/util.cpp @@ -68,6 +68,7 @@ struct LevelInfo { Extent2D tile_size; u32 bpp_log2; u32 tile_width_spacing; + u32 num_levels; }; [[nodiscard]] constexpr u32 AdjustTileSize(u32 shift, u32 unit_factor, u32 dimension) { @@ -166,7 +167,7 @@ template } [[nodiscard]] constexpr Extent3D TileShift(const LevelInfo& info, u32 level) { - if (level == 0) { + if (level == 0 && info.num_levels == 1) { return Extent3D{ .width = info.block.width, .height = info.block.height, @@ -1294,9 +1295,9 @@ u32 MapSizeBytes(const ImageBase& image) { static_assert(CalculateLevelSize(LevelInfo{{1920, 1080, 1}, {0, 2, 0}, {1, 1}, 2, 0}, 0) == 0x7f8000); -static_assert(CalculateLevelSize(LevelInfo{{32, 32, 1}, {0, 0, 4}, {1, 1}, 4, 0}, 0) == 0x40000); +static_assert(CalculateLevelSize(LevelInfo{{32, 32, 1}, {0, 0, 4}, {1, 1}, 4, 0, 1}, 0) == 0x40000); -static_assert(CalculateLevelSize(LevelInfo{{128, 8, 1}, {0, 4, 0}, {1, 1}, 4, 0}, 0) == 0x40000); +static_assert(CalculateLevelSize(LevelInfo{{128, 8, 1}, {0, 4, 0}, {1, 1}, 4, 0, 1}, 0) == 0x40000); static_assert(CalculateLevelOffset(PixelFormat::R8_SINT, {1920, 1080, 1}, {0, 2, 0}, 0, 7) == 0x2afc00);