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 d570175e..dcb40691 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 @@ -28,7 +28,6 @@ namespace skyline::gpu::interconnect::maxwell3d { void Textures::MarkAllDirty() { texturePool.MarkDirty(true); - std::fill(textureHeaderCache.begin(), textureHeaderCache.end(), nullptr); } static texture::Format ConvertTicFormat(TextureImageControl::FormatWord format, bool srgb) { @@ -182,9 +181,15 @@ namespace skyline::gpu::interconnect::maxwell3d { auto textureHeaders{texturePool.UpdateGet(ctx).textureHeaders}; if (textureHeaderCache.size() != textureHeaders.size()) { textureHeaderCache.resize(textureHeaders.size()); - std::fill(textureHeaderCache.begin(), textureHeaderCache.end(), nullptr); - } else if (auto cached{textureHeaderCache[index]}) { - return cached; + std::fill(textureHeaderCache.begin(), textureHeaderCache.end(), CacheEntry{}); + } else if (auto &cached{textureHeaderCache[index]}; cached.view) { + if (cached.executionNumber == ctx.executor.executionNumber) + return cached.view; + + if (cached.tic == textureHeaders[index]) { + cached.executionNumber = ctx.executor.executionNumber; + return cached.view; + } } TextureImageControl &textureHeader{textureHeaders[index]}; @@ -310,7 +315,7 @@ namespace skyline::gpu::interconnect::maxwell3d { texture = ctx.executor.AcquireTextureManager().FindOrCreate(guest, ctx.executor.tag); } - textureHeaderCache[index] = texture.get(); + textureHeaderCache[index] = {textureHeader, texture.get(), ctx.executor.executionNumber}; return texture.get(); } } \ No newline at end of file diff --git a/app/src/main/cpp/skyline/gpu/interconnect/maxwell_3d/textures.h b/app/src/main/cpp/skyline/gpu/interconnect/maxwell_3d/textures.h index 3367d1e1..26202f13 100644 --- a/app/src/main/cpp/skyline/gpu/interconnect/maxwell_3d/textures.h +++ b/app/src/main/cpp/skyline/gpu/interconnect/maxwell_3d/textures.h @@ -36,7 +36,12 @@ namespace skyline::gpu::interconnect::maxwell3d { tsl::robin_map, util::ObjectHash> textureHeaderStore; - std::vector textureHeaderCache; + struct CacheEntry { + TextureImageControl tic; + TextureView *view; + u32 executionNumber; + }; + std::vector textureHeaderCache; public: Textures(DirtyManager &manager, const TexturePoolState::EngineRegisters &engine); @@ -44,5 +49,7 @@ namespace skyline::gpu::interconnect::maxwell3d { void MarkAllDirty(); TextureView *GetTexture(InterconnectContext &ctx, u32 index, Shader::TextureType shaderType); + + Shader::TextureType GetTextureType(InterconnectContext &ctx, u32 index); }; }