Don't entirely wipe out per-index TIC cache efter each execution

Keep a copy of the old TIC entry and view even after purge caches and use the execution number to check validity instead, if that doesn't match then just memcmp can be used as opposed to a full hash and map lookup.
This commit is contained in:
Billy Laws 2022-10-09 13:39:08 +01:00
parent 98c0cc3e7f
commit a3369637a9
2 changed files with 18 additions and 6 deletions

View File

@ -28,7 +28,6 @@ namespace skyline::gpu::interconnect::maxwell3d {
void Textures::MarkAllDirty() { void Textures::MarkAllDirty() {
texturePool.MarkDirty(true); texturePool.MarkDirty(true);
std::fill(textureHeaderCache.begin(), textureHeaderCache.end(), nullptr);
} }
static texture::Format ConvertTicFormat(TextureImageControl::FormatWord format, bool srgb) { static texture::Format ConvertTicFormat(TextureImageControl::FormatWord format, bool srgb) {
@ -182,9 +181,15 @@ namespace skyline::gpu::interconnect::maxwell3d {
auto textureHeaders{texturePool.UpdateGet(ctx).textureHeaders}; auto textureHeaders{texturePool.UpdateGet(ctx).textureHeaders};
if (textureHeaderCache.size() != textureHeaders.size()) { if (textureHeaderCache.size() != textureHeaders.size()) {
textureHeaderCache.resize(textureHeaders.size()); textureHeaderCache.resize(textureHeaders.size());
std::fill(textureHeaderCache.begin(), textureHeaderCache.end(), nullptr); std::fill(textureHeaderCache.begin(), textureHeaderCache.end(), CacheEntry{});
} else if (auto cached{textureHeaderCache[index]}) { } else if (auto &cached{textureHeaderCache[index]}; cached.view) {
return cached; 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]}; TextureImageControl &textureHeader{textureHeaders[index]};
@ -310,7 +315,7 @@ namespace skyline::gpu::interconnect::maxwell3d {
texture = ctx.executor.AcquireTextureManager().FindOrCreate(guest, ctx.executor.tag); texture = ctx.executor.AcquireTextureManager().FindOrCreate(guest, ctx.executor.tag);
} }
textureHeaderCache[index] = texture.get(); textureHeaderCache[index] = {textureHeader, texture.get(), ctx.executor.executionNumber};
return texture.get(); return texture.get();
} }
} }

View File

@ -36,7 +36,12 @@ namespace skyline::gpu::interconnect::maxwell3d {
tsl::robin_map<TextureImageControl, std::shared_ptr<TextureView>, util::ObjectHash<TextureImageControl>> textureHeaderStore; tsl::robin_map<TextureImageControl, std::shared_ptr<TextureView>, util::ObjectHash<TextureImageControl>> textureHeaderStore;
std::vector<TextureView *> textureHeaderCache; struct CacheEntry {
TextureImageControl tic;
TextureView *view;
u32 executionNumber;
};
std::vector<CacheEntry> textureHeaderCache;
public: public:
Textures(DirtyManager &manager, const TexturePoolState::EngineRegisters &engine); Textures(DirtyManager &manager, const TexturePoolState::EngineRegisters &engine);
@ -44,5 +49,7 @@ namespace skyline::gpu::interconnect::maxwell3d {
void MarkAllDirty(); void MarkAllDirty();
TextureView *GetTexture(InterconnectContext &ctx, u32 index, Shader::TextureType shaderType); TextureView *GetTexture(InterconnectContext &ctx, u32 index, Shader::TextureType shaderType);
Shader::TextureType GetTextureType(InterconnectContext &ctx, u32 index);
}; };
} }