TextureCacheBase: Re-wrap GetTexture comment

This commit is contained in:
Pokechu22 2021-11-04 12:11:51 -07:00
parent f4f4dbbc63
commit e7d5f8ad5c
1 changed files with 16 additions and 28 deletions

View File

@ -1300,42 +1300,30 @@ TextureCacheBase::GetTexture(const int textureCacheSafetyColorSampleSize, Textur
// Search the texture cache for textures by address
//
// Find all texture cache entries for the current texture address, and decide whether to use one
// of
// them, or to create a new one
// of them, or to create a new one
//
// In most cases, the fastest way is to use only one texture cache entry for the same address.
// Usually,
// when a texture changes, the old version of the texture is unlikely to be used again. If there
// were
// new cache entries created for normal texture updates, there would be a slowdown due to a huge
// amount
// of unused cache entries. Also thanks to texture pooling, overwriting an existing cache entry is
// faster than creating a new one from scratch.
// Usually, when a texture changes, the old version of the texture is unlikely to be used again.
// If there were new cache entries created for normal texture updates, there would be a slowdown
// due to a huge amount of unused cache entries. Also thanks to texture pooling, overwriting an
// existing cache entry is faster than creating a new one from scratch.
//
// Some games use the same address for different textures though. If the same cache entry was used
// in
// this case, it would be constantly overwritten, and effectively there wouldn't be any caching
// for
// those textures. Examples for this are Metroid Prime and Castlevania 3. Metroid Prime has
// multiple
// sets of fonts on each other stored in a single texture and uses the palette to make different
// characters visible or invisible. In Castlevania 3 some textures are used for 2 different things
// or
// at least in 2 different ways(size 1024x1024 vs 1024x256).
// in this case, it would be constantly overwritten, and effectively there wouldn't be any caching
// for those textures. Examples for this are Metroid Prime and Castlevania 3. Metroid Prime has
// multiple sets of fonts on each other stored in a single texture and uses the palette to make
// different characters visible or invisible. In Castlevania 3 some textures are used for 2
// different things or at least in 2 different ways (size 1024x1024 vs 1024x256).
//
// To determine whether to use multiple cache entries or a single entry, use the following
// heuristic:
// If the same texture address is used several times during the same frame, assume the address is
// used
// for different purposes and allow creating an additional cache entry. If there's at least one
// entry
// that hasn't been used for the same frame, then overwrite it, in order to keep the cache as
// small as
// possible. If the current texture is found in the cache, use that entry.
// heuristic: If the same texture address is used several times during the same frame, assume the
// address is used for different purposes and allow creating an additional cache entry. If there's
// at least one entry that hasn't been used for the same frame, then overwrite it, in order to
// keep the cache as small as possible. If the current texture is found in the cache, use that
// entry.
//
// For efb copies, the entry created in CopyRenderTargetToTexture always has to be used, or else
// it was
// done in vain.
// it was done in vain.
auto iter_range = textures_by_address.equal_range(texture_info.GetRawAddress());
TexAddrCache::iterator iter = iter_range.first;
TexAddrCache::iterator oldest_entry = iter;