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