Merge pull request #14907 from iwubcode/texture_return_shared

VideoCommon: return a RcTcacheEntry (shared_ptr) from TextureCacheBase::Load()
This commit is contained in:
iwubcode
2026-10-04 19:02:07 -05:00
committed by GitHub
2 changed files with 7 additions and 7 deletions
+5 -5
View File
@@ -1239,7 +1239,7 @@ private:
std::vector<Level> levels; std::vector<Level> levels;
}; };
TCacheEntry* TextureCacheBase::Load(u32 stage) RcTcacheEntry TextureCacheBase::Load(u32 stage)
{ {
if (auto entry = LoadImpl(stage, false)) if (auto entry = LoadImpl(stage, false))
{ {
@@ -1248,19 +1248,19 @@ TCacheEntry* TextureCacheBase::Load(u32 stage)
return entry; return entry;
} }
InvalidateTexture(GetTexCacheIter(entry)); InvalidateTexture(GetTexCacheIter(entry.get()));
return LoadImpl(stage, true); return LoadImpl(stage, true);
} }
return nullptr; return nullptr;
} }
TCacheEntry* TextureCacheBase::LoadImpl(u32 stage, bool force_reload) RcTcacheEntry TextureCacheBase::LoadImpl(u32 stage, bool force_reload)
{ {
// if this stage was not invalidated by changes to texture registers, keep the current texture // if this stage was not invalidated by changes to texture registers, keep the current texture
if (!force_reload && TMEM::IsValid(stage) && m_bound_textures[stage]) if (!force_reload && TMEM::IsValid(stage) && m_bound_textures[stage])
{ {
TCacheEntry* entry = m_bound_textures[stage].get(); const auto& entry = m_bound_textures[stage];
// If the TMEM configuration is such that this texture is more or less guaranteed to still // 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 // be in TMEM, then we know we can reuse the old entry without even hashing the memory
// //
@@ -1308,7 +1308,7 @@ TCacheEntry* TextureCacheBase::LoadImpl(u32 stage, bool force_reload)
TMEM::Bind(texture_info.GetStage(), entry->NumBlocksX(), entry->NumBlocksY(), TMEM::Bind(texture_info.GetStage(), entry->NumBlocksX(), entry->NumBlocksY(),
entry->GetNumLevels() > 1, entry->format == TextureFormat::RGBA8); entry->GetNumLevels() > 1, entry->format == TextureFormat::RGBA8);
return entry.get(); return entry;
} }
RcTcacheEntry TextureCacheBase::GetTexture(const int textureCacheSafetyColorSampleSize, RcTcacheEntry TextureCacheBase::GetTexture(const int textureCacheSafetyColorSampleSize,
+2 -2
View File
@@ -278,7 +278,7 @@ public:
void Invalidate(); void Invalidate();
void ReleaseToPool(TCacheEntry* entry); void ReleaseToPool(TCacheEntry* entry);
TCacheEntry* Load(u32 stage); RcTcacheEntry Load(u32 stage);
RcTcacheEntry GetTexture(const int textureCacheSafetyColorSampleSize, RcTcacheEntry GetTexture(const int textureCacheSafetyColorSampleSize,
const TextureInfo& texture_info); const TextureInfo& texture_info);
RcTcacheEntry GetXFBTexture(u32 address, u32 width, u32 height, u32 stride, RcTcacheEntry GetXFBTexture(u32 address, u32 width, u32 height, u32 stride,
@@ -352,7 +352,7 @@ private:
static bool DidLinkedAssetsChange(const TCacheEntry& entry); static bool DidLinkedAssetsChange(const TCacheEntry& entry);
TCacheEntry* LoadImpl(u32 stage, bool force_reload); RcTcacheEntry LoadImpl(u32 stage, bool force_reload);
bool CreateUtilityTextures(); bool CreateUtilityTextures();