From fd12ae1408f5e19a23cee6df4727a7b70ef0d312 Mon Sep 17 00:00:00 2001 From: Lioncash Date: Sun, 4 Aug 2019 23:23:02 -0400 Subject: [PATCH 1/3] VideoCommon/TextureCacheBase: Remove use of the texture cache global We can just call the functions that are part of the interface instead of using the global in order to execute those functions. --- Source/Core/VideoCommon/TextureCacheBase.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Source/Core/VideoCommon/TextureCacheBase.cpp b/Source/Core/VideoCommon/TextureCacheBase.cpp index 2f330bb2bc..b9b59145ff 100644 --- a/Source/Core/VideoCommon/TextureCacheBase.cpp +++ b/Source/Core/VideoCommon/TextureCacheBase.cpp @@ -572,7 +572,7 @@ void TextureCacheBase::DoSaveState(PointerWrap& p) p.Do(size); for (TCacheEntry* entry : entries_to_save) { - g_texture_cache->SerializeTexture(entry->texture.get(), entry->texture->GetConfig(), p); + SerializeTexture(entry->texture.get(), entry->texture->GetConfig(), p); entry->DoState(p); } p.DoMarker("TextureCacheEntries"); @@ -652,9 +652,9 @@ void TextureCacheBase::DoLoadState(PointerWrap& p) { // Even if the texture isn't valid, we still need to create the cache entry object // to update the point in the state state. We'll just throw it away if it's invalid. - auto tex = g_texture_cache->DeserializeTexture(p); + auto tex = DeserializeTexture(p); TCacheEntry* entry = new TCacheEntry(std::move(tex->texture), std::move(tex->framebuffer)); - entry->textures_by_hash_iter = g_texture_cache->textures_by_hash.end(); + entry->textures_by_hash_iter = textures_by_hash.end(); entry->DoState(p); if (entry->texture && commit_state) id_map.emplace(i, entry); From d52dd2e04f9e6e5dd7c690e5a485d7b32d61e7de Mon Sep 17 00:00:00 2001 From: Lioncash Date: Sun, 4 Aug 2019 23:28:11 -0400 Subject: [PATCH 2/3] VideoCommon/TextureCacheBase: Use emplace_back where applicable Same thing, less code. --- Source/Core/VideoCommon/TextureCacheBase.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Source/Core/VideoCommon/TextureCacheBase.cpp b/Source/Core/VideoCommon/TextureCacheBase.cpp index b9b59145ff..10f3b9f293 100644 --- a/Source/Core/VideoCommon/TextureCacheBase.cpp +++ b/Source/Core/VideoCommon/TextureCacheBase.cpp @@ -553,16 +553,16 @@ void TextureCacheBase::DoSaveState(PointerWrap& p) { if (ShouldSaveEntry(it.second)) { - u32 id = AddCacheEntryToMap(it.second); - textures_by_address_list.push_back(std::make_pair(it.first, id)); + const u32 id = AddCacheEntryToMap(it.second); + textures_by_address_list.emplace_back(it.first, id); } } for (const auto& it : textures_by_hash) { if (ShouldSaveEntry(it.second)) { - u32 id = AddCacheEntryToMap(it.second); - textures_by_hash_list.push_back(std::make_pair(it.first, id)); + const u32 id = AddCacheEntryToMap(it.second); + textures_by_hash_list.emplace_back(it.first, id); } } } From 07aa18eb2b7e7649ebac161ecd753ae81a1e5ccd Mon Sep 17 00:00:00 2001 From: Lioncash Date: Sun, 4 Aug 2019 23:30:24 -0400 Subject: [PATCH 3/3] VideoCommon/TextureCacheBase: Collapse for loop into a fill() in Invalidate() Same thing, less code. --- Source/Core/VideoCommon/TextureCacheBase.cpp | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/Source/Core/VideoCommon/TextureCacheBase.cpp b/Source/Core/VideoCommon/TextureCacheBase.cpp index 10f3b9f293..2951573908 100644 --- a/Source/Core/VideoCommon/TextureCacheBase.cpp +++ b/Source/Core/VideoCommon/TextureCacheBase.cpp @@ -122,11 +122,8 @@ void TextureCacheBase::Invalidate() { FlushEFBCopies(); InvalidateAllBindPoints(); - for (size_t i = 0; i < bound_textures.size(); ++i) - { - bound_textures[i] = nullptr; - } + bound_textures.fill(nullptr); for (auto& tex : textures_by_address) { delete tex.second;