From e7fda28ac67c1024ebeeb1f3e70f638a5eb6c7d2 Mon Sep 17 00:00:00 2001 From: Billy Laws Date: Sun, 6 Nov 2022 19:23:52 +0000 Subject: [PATCH] Skip over textures in cache which have been replaced with a layer/mip match --- .../skyline/gpu/interconnect/maxwell_3d/textures.cpp | 4 ++-- app/src/main/cpp/skyline/gpu/texture/texture.h | 1 + app/src/main/cpp/skyline/gpu/texture_manager.cpp | 11 +++++++++-- 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/app/src/main/cpp/skyline/gpu/interconnect/maxwell_3d/textures.cpp b/app/src/main/cpp/skyline/gpu/interconnect/maxwell_3d/textures.cpp index 5ce4f95a..f78e6730 100644 --- a/app/src/main/cpp/skyline/gpu/interconnect/maxwell_3d/textures.cpp +++ b/app/src/main/cpp/skyline/gpu/interconnect/maxwell_3d/textures.cpp @@ -192,7 +192,7 @@ namespace skyline::gpu::interconnect::maxwell3d { if (cached.executionNumber == ctx.executor.executionNumber) return cached.view; - if (cached.tic == textureHeaders[index]) { + if (cached.tic == textureHeaders[index] && !cached.view->texture->replaced) { cached.executionNumber = ctx.executor.executionNumber; return cached.view; } @@ -201,7 +201,7 @@ namespace skyline::gpu::interconnect::maxwell3d { TextureImageControl &textureHeader{textureHeaders[index]}; auto &texture{textureHeaderStore[textureHeader]}; - if (!texture) { + if (!texture || texture->texture->replaced) { // If the entry didn't exist prior then we need to convert the TIC to a GuestTexture GuestTexture guest{}; if (auto format{ConvertTicFormat(textureHeader.formatWord, textureHeader.isSrgb)}) { diff --git a/app/src/main/cpp/skyline/gpu/texture/texture.h b/app/src/main/cpp/skyline/gpu/texture/texture.h index 808eb4d8..3ce1e7ca 100644 --- a/app/src/main/cpp/skyline/gpu/texture/texture.h +++ b/app/src/main/cpp/skyline/gpu/texture/texture.h @@ -470,6 +470,7 @@ namespace skyline::gpu { size_t deswizzledSurfaceSize{}; //!< The size of the guest surface with linear tiling, calculated with the guest format which may differ from the host format size_t surfaceSize{}; //!< The size of the entire surface given linear tiling, this contains all mip levels and layers vk::SampleCountFlagBits sampleCount; + bool replaced{}; /** * @brief Creates a texture object wrapping the supplied backing with the supplied attributes diff --git a/app/src/main/cpp/skyline/gpu/texture_manager.cpp b/app/src/main/cpp/skyline/gpu/texture_manager.cpp index 62a957b0..5880d575 100644 --- a/app/src/main/cpp/skyline/gpu/texture_manager.cpp +++ b/app/src/main/cpp/skyline/gpu/texture_manager.cpp @@ -40,7 +40,7 @@ namespace skyline::gpu { while (hostMapping != textures.begin() && (--hostMapping)->end() > guestMapping.begin()) { auto &hostMappings{hostMapping->texture->guest->mappings}; - if (!hostMapping->contains(guestMapping)) + if (!hostMapping->contains(guestMapping) || hostMapping->texture->replaced) continue; // We need to check that all corresponding mappings in the candidate texture and the guest texture match up @@ -96,8 +96,15 @@ namespace skyline::gpu { layerMemOffset += matchGuestTexture.GetLayerStride(); } - if (matched) + if (matched) { + if (layerMipMatch) + layerMipMatch->replaced = true; + + if (fullMatch) + fullMatch->replaced = true; + layerMipMatch = hostMapping->texture; + } } } }