diff options
| author | JosJuice <josjuice@gmail.com> | 2026-01-18 12:59:25 +0100 |
|---|---|---|
| committer | JosJuice <josjuice@gmail.com> | 2026-01-18 13:04:06 +0100 |
| commit | fb07406f102eaa2d237c95c35e8853680d902b6a (patch) | |
| tree | 9177a4784a336d799ed01d64f727ce3126af520d /Source/Core/VideoCommon/TextureCacheBase.cpp | |
| parent | 373e35ed5b3202bd91c05f6dd1f49fcee449d2a5 (diff) | |
VideoCommon: Defer creating TextureInfo
TextureCacheBase::LoadImpl has a hot path where the passed-in
TextureInfo never gets used. Instead of passing in a TextureInfo, let's
pass in the stage and create the TextureInfo from the stage if needed.
This unlocks somewhere above an additional 4% performance boost in the
Hoth level of Rogue Squadron 2 on my PC. Performance varies, making it
difficult for me to measure, so treat this as a very approximate number.
Diffstat (limited to 'Source/Core/VideoCommon/TextureCacheBase.cpp')
| -rw-r--r-- | Source/Core/VideoCommon/TextureCacheBase.cpp | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/Source/Core/VideoCommon/TextureCacheBase.cpp b/Source/Core/VideoCommon/TextureCacheBase.cpp index d27234dee9..4b048ef2ac 100644 --- a/Source/Core/VideoCommon/TextureCacheBase.cpp +++ b/Source/Core/VideoCommon/TextureCacheBase.cpp @@ -1231,9 +1231,9 @@ private: std::vector<Level> levels; }; -TCacheEntry* TextureCacheBase::Load(const TextureInfo& texture_info) +TCacheEntry* TextureCacheBase::Load(u32 stage) { - if (auto entry = LoadImpl(texture_info, false)) + if (auto entry = LoadImpl(stage, false)) { if (!DidLinkedAssetsChange(*entry)) { @@ -1241,19 +1241,18 @@ TCacheEntry* TextureCacheBase::Load(const TextureInfo& texture_info) } InvalidateTexture(GetTexCacheIter(entry)); - return LoadImpl(texture_info, true); + return LoadImpl(stage, true); } return nullptr; } -TCacheEntry* TextureCacheBase::LoadImpl(const TextureInfo& texture_info, bool force_reload) +TCacheEntry* TextureCacheBase::LoadImpl(u32 stage, bool force_reload) { // if this stage was not invalidated by changes to texture registers, keep the current texture - if (!force_reload && TMEM::IsValid(texture_info.GetStage()) && - m_bound_textures[texture_info.GetStage()]) + if (!force_reload && TMEM::IsValid(stage) && m_bound_textures[stage]) { - TCacheEntry* entry = m_bound_textures[texture_info.GetStage()].get(); + TCacheEntry* entry = m_bound_textures[stage].get(); // If the TMEM configuration is such that this texture is more or less guaranteed to still // be in TMEM, then we know we can reuse the old entry without even hashing the memory // @@ -1263,7 +1262,7 @@ TCacheEntry* TextureCacheBase::LoadImpl(const TextureInfo& texture_info, bool fo // // Spyro: A Hero's Tail is known for (deliberately?) using such overwritten textures // in it's bloom effect, which breaks without giving it the invalidated texture. - if (TMEM::IsCached(texture_info.GetStage())) + if (TMEM::IsCached(stage)) { return entry; } @@ -1276,6 +1275,7 @@ TCacheEntry* TextureCacheBase::LoadImpl(const TextureInfo& texture_info, bool fo } } + const TextureInfo texture_info = TextureInfo::FromStage(stage); auto entry = GetTexture(g_ActiveConfig.iSafeTextureCache_ColorSamples, texture_info); if (!entry) |
