From dddcea5a9a38ae4832ccf9544d4b097e80df2e34 Mon Sep 17 00:00:00 2001 From: degasus Date: Fri, 16 May 2014 18:41:01 +0200 Subject: TexCache: don't invalidate efb copys because of config changes We'll loose data on invalidating them. So just keep them until a new copy is done. A wrong scaled copy is better than no copy if the game doesn't creates a new one. --- Source/Core/VideoCommon/TextureCacheBase.cpp | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) (limited to 'Source/Core/VideoCommon/TextureCacheBase.cpp') diff --git a/Source/Core/VideoCommon/TextureCacheBase.cpp b/Source/Core/VideoCommon/TextureCacheBase.cpp index ce9b724b8f..70e8f0433f 100644 --- a/Source/Core/VideoCommon/TextureCacheBase.cpp +++ b/Source/Core/VideoCommon/TextureCacheBase.cpp @@ -116,11 +116,7 @@ void TextureCache::OnConfigChanged(VideoConfig& config) } // TODO: Probably shouldn't clear all render targets here, just mark them dirty or something. - if (config.bEFBCopyCacheEnable != backup_config.s_copy_cache_enable || // TODO: not sure if this is needed? - config.bCopyEFBToTexture != backup_config.s_copy_efb_to_texture || - config.bCopyEFBScaled != backup_config.s_copy_efb_scaled || - config.bEFBCopyEnable != backup_config.s_copy_efb || - config.iEFBScale != backup_config.s_efb_scale) + if (config.bEFBCopyCacheEnable != backup_config.s_copy_cache_enable) // TODO: not sure if this is needed? { g_texture_cache->ClearRenderTargets(); } @@ -134,10 +130,6 @@ void TextureCache::OnConfigChanged(VideoConfig& config) } backup_config.s_colorsamples = config.iSafeTextureCache_ColorSamples; - backup_config.s_copy_efb_to_texture = config.bCopyEFBToTexture; - backup_config.s_copy_efb_scaled = config.bCopyEFBScaled; - backup_config.s_copy_efb = config.bEFBCopyEnable; - backup_config.s_efb_scale = config.iEFBScale; backup_config.s_texfmt_overlay = config.bTexFmtOverlayEnable; backup_config.s_texfmt_overlay_center = config.bTexFmtOverlayCenter; backup_config.s_hires_textures = config.bHiresTextures; -- cgit v1.2.3 From 774596dbed35c2d69d8b70d58c4190cb1b42d1ac Mon Sep 17 00:00:00 2001 From: degasus Date: Fri, 16 May 2014 21:57:14 +0200 Subject: TexCache: rename OverlapsMemoryRange --- Source/Core/VideoCommon/TextureCacheBase.cpp | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) (limited to 'Source/Core/VideoCommon/TextureCacheBase.cpp') diff --git a/Source/Core/VideoCommon/TextureCacheBase.cpp b/Source/Core/VideoCommon/TextureCacheBase.cpp index 70e8f0433f..94ac0d2848 100644 --- a/Source/Core/VideoCommon/TextureCacheBase.cpp +++ b/Source/Core/VideoCommon/TextureCacheBase.cpp @@ -181,8 +181,7 @@ void TextureCache::InvalidateRange(u32 start_address, u32 size) tcend = textures.end(); while (iter != tcend) { - const int rangePosition = iter->second->IntersectsMemoryRange(start_address, size); - if (0 == rangePosition) + if (iter->second->OverlapsMemoryRange(start_address, size)) { delete iter->second; textures.erase(iter++); @@ -205,8 +204,7 @@ void TextureCache::MakeRangeDynamic(u32 start_address, u32 size) for (; iter != tcend; ++iter) { - const int rangePosition = iter->second->IntersectsMemoryRange(start_address, size); - if (0 == rangePosition) + if (iter->second->OverlapsMemoryRange(start_address, size)) { iter->second->SetHashes(TEXHASH_INVALID); } @@ -223,15 +221,15 @@ bool TextureCache::Find(u32 start_address, u64 hash) return false; } -int TextureCache::TCacheEntryBase::IntersectsMemoryRange(u32 range_address, u32 range_size) const +bool TextureCache::TCacheEntryBase::OverlapsMemoryRange(u32 range_address, u32 range_size) const { if (addr + size_in_bytes < range_address) - return -1; + return false; if (addr >= range_address + range_size) - return 1; + return false; - return 0; + return true; } void TextureCache::ClearRenderTargets() -- cgit v1.2.3 From 6ba613fbd3e7ecca0357adaab2e7fac422480a54 Mon Sep 17 00:00:00 2001 From: degasus Date: Mon, 19 May 2014 18:27:59 +0200 Subject: TexCache: unify global variables --- Source/Core/VideoCommon/TextureCacheBase.cpp | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) (limited to 'Source/Core/VideoCommon/TextureCacheBase.cpp') diff --git a/Source/Core/VideoCommon/TextureCacheBase.cpp b/Source/Core/VideoCommon/TextureCacheBase.cpp index 94ac0d2848..870e79552b 100644 --- a/Source/Core/VideoCommon/TextureCacheBase.cpp +++ b/Source/Core/VideoCommon/TextureCacheBase.cpp @@ -19,11 +19,9 @@ #include "VideoCommon/TextureCacheBase.h" #include "VideoCommon/VideoConfig.h" -enum -{ - TEXTURE_KILL_THRESHOLD = 200, - RENDER_TARGET_KILL_THRESHOLD = 3, -}; +static const u64 TEXHASH_INVALID = 0; +static const int TEXTURE_KILL_THRESHOLD = 200; +static const int RENDER_TARGET_KILL_THRESHOLD = 3; TextureCache *g_texture_cache; -- cgit v1.2.3 From 1c98a43203263b73da32c19085492c94214a56cb Mon Sep 17 00:00:00 2001 From: degasus Date: Mon, 19 May 2014 18:31:38 +0200 Subject: TexCache: clean up frameCount handling --- Source/Core/VideoCommon/TextureCacheBase.cpp | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) (limited to 'Source/Core/VideoCommon/TextureCacheBase.cpp') diff --git a/Source/Core/VideoCommon/TextureCacheBase.cpp b/Source/Core/VideoCommon/TextureCacheBase.cpp index 870e79552b..d963727232 100644 --- a/Source/Core/VideoCommon/TextureCacheBase.cpp +++ b/Source/Core/VideoCommon/TextureCacheBase.cpp @@ -22,6 +22,7 @@ static const u64 TEXHASH_INVALID = 0; static const int TEXTURE_KILL_THRESHOLD = 200; static const int RENDER_TARGET_KILL_THRESHOLD = 3; +static const u64 FRAMECOUNT_INVALID = 0; TextureCache *g_texture_cache; @@ -136,13 +137,17 @@ void TextureCache::OnConfigChanged(VideoConfig& config) backup_config.s_efb_mono_depth = config.bStereoEFBMonoDepth; } -void TextureCache::Cleanup() +void TextureCache::Cleanup(int _frameCount) { TexCache::iterator iter = textures.begin(); TexCache::iterator tcend = textures.end(); while (iter != tcend) { - if (frameCount > TEXTURE_KILL_THRESHOLD + iter->second->frameCount && + if(iter->second->frameCount == FRAMECOUNT_INVALID) + { + iter->second->frameCount = _frameCount; + } + if (_frameCount > TEXTURE_KILL_THRESHOLD + iter->second->frameCount && // EFB copies living on the host GPU are unrecoverable and thus shouldn't be deleted !iter->second->IsEfbCopy()) { @@ -159,7 +164,7 @@ void TextureCache::Cleanup() { auto rt = render_target_pool[i]; - if (frameCount > RENDER_TARGET_KILL_THRESHOLD + rt->frameCount) + if (_frameCount > RENDER_TARGET_KILL_THRESHOLD + rt->frameCount) { delete rt; render_target_pool[i] = render_target_pool.back(); @@ -277,7 +282,7 @@ static u32 CalculateLevelSize(u32 level_0_size, u32 level) // Used by TextureCache::Load static TextureCache::TCacheEntryBase* ReturnEntry(unsigned int stage, TextureCache::TCacheEntryBase* entry) { - entry->frameCount = frameCount; + entry->frameCount = FRAMECOUNT_INVALID; entry->Bind(stage); GFX_DEBUGGER_PAUSE_AT(NEXT_TEXTURE_CHANGE, true); @@ -873,7 +878,7 @@ void TextureCache::CopyRenderTargetToTexture(u32 dstAddr, unsigned int dstFormat entry->type = TCET_EC_VRAM; } - entry->frameCount = frameCount; + entry->frameCount = FRAMECOUNT_INVALID; entry->FromRenderTarget(dstAddr, dstFormat, srcFormat, srcRect, isIntensity, scaleByHalf, cbufid, colmat); } -- cgit v1.2.3 From 2b47df07b6e256e04f28e6b28faaa45b9fccf17c Mon Sep 17 00:00:00 2001 From: degasus Date: Sat, 31 May 2014 12:40:22 +0200 Subject: TexCache: use c++11 syntax for std::map::erase --- Source/Core/VideoCommon/TextureCacheBase.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'Source/Core/VideoCommon/TextureCacheBase.cpp') diff --git a/Source/Core/VideoCommon/TextureCacheBase.cpp b/Source/Core/VideoCommon/TextureCacheBase.cpp index d963727232..88737a1e95 100644 --- a/Source/Core/VideoCommon/TextureCacheBase.cpp +++ b/Source/Core/VideoCommon/TextureCacheBase.cpp @@ -152,7 +152,7 @@ void TextureCache::Cleanup(int _frameCount) !iter->second->IsEfbCopy()) { delete iter->second; - textures.erase(iter++); + iter = textures.erase(iter); } else { -- cgit v1.2.3 From 1261f5f7f4f15fba126119eda0d0639568e2b101 Mon Sep 17 00:00:00 2001 From: degasus Date: Sun, 11 Jan 2015 12:48:04 +0100 Subject: TextureCache: inline arguments into texture cache --- Source/Core/VideoCommon/TextureCacheBase.cpp | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) (limited to 'Source/Core/VideoCommon/TextureCacheBase.cpp') diff --git a/Source/Core/VideoCommon/TextureCacheBase.cpp b/Source/Core/VideoCommon/TextureCacheBase.cpp index 88737a1e95..561c3e24ea 100644 --- a/Source/Core/VideoCommon/TextureCacheBase.cpp +++ b/Source/Core/VideoCommon/TextureCacheBase.cpp @@ -290,10 +290,20 @@ static TextureCache::TCacheEntryBase* ReturnEntry(unsigned int stage, TextureCac return entry; } -TextureCache::TCacheEntryBase* TextureCache::Load(unsigned int const stage, - u32 const address, unsigned int width, unsigned int height, int const texformat, - unsigned int const tlutaddr, int const tlutfmt, bool const use_mipmaps, unsigned int maxlevel, bool const from_tmem) +TextureCache::TCacheEntryBase* TextureCache::Load(const u32 stage) { + const FourTexUnits &tex = bpmem.tex[stage >> 2]; + const u32 id = stage & 3; + const u32 address = (tex.texImage3[id].image_base/* & 0x1FFFFF*/) << 5; + u32 width = tex.texImage0[id].width + 1; + u32 height = tex.texImage0[id].height + 1; + const int texformat = tex.texImage0[id].format; + const u32 tlutaddr = tex.texTlut[id].tmem_offset << 9; + const u32 tlutfmt = tex.texTlut[id].tlut_format; + const bool use_mipmaps = (tex.texMode0[id].min_filter & 3) != 0; + u32 maxlevel = (tex.texMode1[id].max_lod + 0xf) / 0x10; + const bool from_tmem = tex.texImage1[id].image_type != 0; + if (0 == address) return nullptr; -- cgit v1.2.3 From d640453274099f2cead75df3f137f4b06522d92c Mon Sep 17 00:00:00 2001 From: degasus Date: Sun, 11 Jan 2015 12:58:27 +0100 Subject: TexCache: cleanup max texture level --- Source/Core/VideoCommon/TextureCacheBase.cpp | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'Source/Core/VideoCommon/TextureCacheBase.cpp') diff --git a/Source/Core/VideoCommon/TextureCacheBase.cpp b/Source/Core/VideoCommon/TextureCacheBase.cpp index 561c3e24ea..99bac2b519 100644 --- a/Source/Core/VideoCommon/TextureCacheBase.cpp +++ b/Source/Core/VideoCommon/TextureCacheBase.cpp @@ -301,7 +301,7 @@ TextureCache::TCacheEntryBase* TextureCache::Load(const u32 stage) const u32 tlutaddr = tex.texTlut[id].tmem_offset << 9; const u32 tlutfmt = tex.texTlut[id].tlut_format; const bool use_mipmaps = (tex.texMode0[id].min_filter & 3) != 0; - u32 maxlevel = (tex.texMode1[id].max_lod + 0xf) / 0x10; + u32 tex_levels = (tex.texMode1[id].max_lod + 0xf) / 0x10 + 1; const bool from_tmem = tex.texImage1[id].image_type != 0; if (0 == address) @@ -359,8 +359,8 @@ TextureCache::TCacheEntryBase* TextureCache::Load(const u32 stage) // D3D doesn't like when the specified mipmap count would require more than one 1x1-sized LOD in the mipmap chain // e.g. 64x64 with 7 LODs would have the mipmap chain 64x64,32x32,16x16,8x8,4x4,2x2,1x1,1x1, so we limit the mipmap count to 6 there - while (g_ActiveConfig.backend_info.bUseMinimalMipCount && std::max(width, height) >> maxlevel == 0) - --maxlevel; + while (g_ActiveConfig.backend_info.bUseMinimalMipCount && std::max(width, height) >> (tex_levels - 1) == 0) + --tex_levels; TCacheEntryBase *entry = textures[texID]; if (entry) @@ -383,7 +383,7 @@ TextureCache::TCacheEntryBase* TextureCache::Load(const u32 stage) // 2. b) For normal textures, all texture parameters need to match if (address == entry->addr && tex_hash == entry->hash && full_format == entry->format && - entry->num_mipmaps > maxlevel && entry->native_width == nativeW && entry->native_height == nativeH) + entry->tex_levels >= tex_levels && entry->native_width == nativeW && entry->native_height == nativeH) { return ReturnEntry(stage, entry); } @@ -397,7 +397,7 @@ TextureCache::TCacheEntryBase* TextureCache::Load(const u32 stage) width == entry->virtual_width && height == entry->virtual_height && full_format == entry->format && - entry->num_mipmaps > maxlevel) || + entry->tex_levels >= tex_levels) || (entry->type == TCET_EC_DYNAMIC && entry->native_width == width && entry->native_height == height)) && @@ -460,7 +460,7 @@ TextureCache::TCacheEntryBase* TextureCache::Load(const u32 stage) } } - u32 texLevels = use_mipmaps ? (maxlevel + 1) : 1; + u32 texLevels = use_mipmaps ? tex_levels : 1; const bool using_custom_lods = hires_tex && hires_tex->m_levels.size() >= texLevels; // Only load native mips if their dimensions fit to our virtual texture dimensions const bool use_native_mips = use_mipmaps && !using_custom_lods && (width == nativeW && height == nativeH); @@ -478,14 +478,14 @@ TextureCache::TCacheEntryBase* TextureCache::Load(const u32 stage) // TODO: This is the wrong value. We should be storing the number of levels our actual texture has. // But that will currently make the above "existing entry" tests fail as "texLevels" is not calculated until after. // Currently, we might try to reuse a texture which appears to have more levels than actual, maybe.. - entry->num_mipmaps = maxlevel + 1; + entry->tex_levels = tex_levels; entry->num_layers = 1; entry->type = TCET_NORMAL; GFX_DEBUGGER_PAUSE_AT(NEXT_NEW_TEXTURE, true); } - entry->SetGeneralParameters(address, texture_size, full_format, entry->num_mipmaps, entry->num_layers); + entry->SetGeneralParameters(address, texture_size, full_format, entry->tex_levels, entry->num_layers); entry->SetDimensions(nativeW, nativeH, width, height); entry->hash = tex_hash; -- cgit v1.2.3 From d95e5e2b6fdbdcc7af201a4fc1fa1389bbdf0ad5 Mon Sep 17 00:00:00 2001 From: degasus Date: Sun, 11 Jan 2015 15:03:41 +0100 Subject: TexCache: create a const Config struct --- Source/Core/VideoCommon/TextureCacheBase.cpp | 41 +++++++++++----------------- 1 file changed, 16 insertions(+), 25 deletions(-) (limited to 'Source/Core/VideoCommon/TextureCacheBase.cpp') diff --git a/Source/Core/VideoCommon/TextureCacheBase.cpp b/Source/Core/VideoCommon/TextureCacheBase.cpp index 99bac2b519..fd64f9b701 100644 --- a/Source/Core/VideoCommon/TextureCacheBase.cpp +++ b/Source/Core/VideoCommon/TextureCacheBase.cpp @@ -13,6 +13,7 @@ #include "Core/HW/Memmap.h" #include "VideoCommon/Debugger.h" +#include "VideoCommon/FramebufferManagerBase.h" #include "VideoCommon/HiresTextures.h" #include "VideoCommon/RenderBase.h" #include "VideoCommon/Statistics.h" @@ -383,7 +384,7 @@ TextureCache::TCacheEntryBase* TextureCache::Load(const u32 stage) // 2. b) For normal textures, all texture parameters need to match if (address == entry->addr && tex_hash == entry->hash && full_format == entry->format && - entry->tex_levels >= tex_levels && entry->native_width == nativeW && entry->native_height == nativeH) + entry->config.levels >= tex_levels && entry->native_width == nativeW && entry->native_height == nativeH) { return ReturnEntry(stage, entry); } @@ -394,14 +395,14 @@ TextureCache::TCacheEntryBase* TextureCache::Load(const u32 stage) // TODO: Don't we need to force texture decoding to RGBA8 for dynamic EFB copies? // TODO: Actually, it should be enough if the internal texture format matches... if (((entry->type == TCET_NORMAL && - width == entry->virtual_width && - height == entry->virtual_height && + width == entry->config.width && + height == entry->config.height && full_format == entry->format && - entry->tex_levels >= tex_levels) || + entry->config.levels >= tex_levels) || (entry->type == TCET_EC_DYNAMIC && entry->native_width == width && entry->native_height == height)) && - entry->num_layers == 1) + entry->config.layers == 1) { // reuse the texture } @@ -470,23 +471,13 @@ TextureCache::TCacheEntryBase* TextureCache::Load(const u32 stage) if (nullptr == entry) { textures[texID] = entry = g_texture_cache->CreateTexture(width, height, texLevels, pcfmt); - - // Sometimes, we can get around recreating a texture if only the number of mip levels changes - // e.g. if our texture cache entry got too many mipmap levels we can limit the number of used levels by setting the appropriate render states - // Thus, we don't update this member for every Load, but just whenever the texture gets recreated - - // TODO: This is the wrong value. We should be storing the number of levels our actual texture has. - // But that will currently make the above "existing entry" tests fail as "texLevels" is not calculated until after. - // Currently, we might try to reuse a texture which appears to have more levels than actual, maybe.. - entry->tex_levels = tex_levels; - entry->num_layers = 1; entry->type = TCET_NORMAL; GFX_DEBUGGER_PAUSE_AT(NEXT_NEW_TEXTURE, true); } - entry->SetGeneralParameters(address, texture_size, full_format, entry->tex_levels, entry->num_layers); - entry->SetDimensions(nativeW, nativeH, width, height); + entry->SetGeneralParameters(address, texture_size, full_format); + entry->SetDimensions(nativeW, nativeH); entry->hash = tex_hash; // load texture @@ -854,12 +845,12 @@ void TextureCache::CopyRenderTargetToTexture(u32 dstAddr, unsigned int dstFormat TCacheEntryBase *entry = textures[dstAddr]; if (entry) { - if (entry->type == TCET_EC_DYNAMIC && entry->native_width == tex_w && entry->native_height == tex_h && entry->num_layers == efb_layers) + if (entry->type == TCET_EC_DYNAMIC && entry->native_width == tex_w && entry->native_height == tex_h && entry->config.layers == efb_layers) { scaled_tex_w = tex_w; scaled_tex_h = tex_h; } - else if (!(entry->type == TCET_EC_VRAM && entry->virtual_width == scaled_tex_w && entry->virtual_height == scaled_tex_h && entry->num_layers == efb_layers)) + else if (!(entry->type == TCET_EC_VRAM && entry->config.width == scaled_tex_w && entry->config.height == scaled_tex_h && entry->config.layers == efb_layers)) { if (entry->type == TCET_EC_VRAM) { @@ -879,11 +870,11 @@ void TextureCache::CopyRenderTargetToTexture(u32 dstAddr, unsigned int dstFormat if (nullptr == entry) { // create the texture - textures[dstAddr] = entry = AllocateRenderTarget(scaled_tex_w, scaled_tex_h); + textures[dstAddr] = entry = AllocateRenderTarget(scaled_tex_w, scaled_tex_h, FramebufferManagerBase::GetEFBLayers()); // TODO: Using the wrong dstFormat, dumb... - entry->SetGeneralParameters(dstAddr, 0, dstFormat, 1, efb_layers); - entry->SetDimensions(tex_w, tex_h, scaled_tex_w, scaled_tex_h); + entry->SetGeneralParameters(dstAddr, 0, dstFormat); + entry->SetDimensions(tex_w, tex_h); entry->SetHashes(TEXHASH_INVALID); entry->type = TCET_EC_VRAM; } @@ -893,13 +884,13 @@ void TextureCache::CopyRenderTargetToTexture(u32 dstAddr, unsigned int dstFormat entry->FromRenderTarget(dstAddr, dstFormat, srcFormat, srcRect, isIntensity, scaleByHalf, cbufid, colmat); } -TextureCache::TCacheEntryBase* TextureCache::AllocateRenderTarget(unsigned int width, unsigned int height) +TextureCache::TCacheEntryBase* TextureCache::AllocateRenderTarget(unsigned int width, unsigned int height, unsigned int layers) { for (size_t i = 0; i < render_target_pool.size(); ++i) { auto rt = render_target_pool[i]; - if (rt->virtual_width != width || rt->virtual_height != height) + if (rt->config.width != width || rt->config.height != height || rt->config.layers != layers) continue; render_target_pool[i] = render_target_pool.back(); @@ -908,7 +899,7 @@ TextureCache::TCacheEntryBase* TextureCache::AllocateRenderTarget(unsigned int w return rt; } - return g_texture_cache->CreateRenderTargetTexture(width, height); + return g_texture_cache->CreateRenderTargetTexture(width, height, layers); } void TextureCache::FreeRenderTarget(TCacheEntryBase* entry) -- cgit v1.2.3 From 744b1c162441b296e0af121d5ca6e95761587b6e Mon Sep 17 00:00:00 2001 From: degasus Date: Sun, 11 Jan 2015 15:15:14 +0100 Subject: TexCache: rewrite level calculation --- Source/Core/VideoCommon/TextureCacheBase.cpp | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'Source/Core/VideoCommon/TextureCacheBase.cpp') diff --git a/Source/Core/VideoCommon/TextureCacheBase.cpp b/Source/Core/VideoCommon/TextureCacheBase.cpp index fd64f9b701..885c78e9a9 100644 --- a/Source/Core/VideoCommon/TextureCacheBase.cpp +++ b/Source/Core/VideoCommon/TextureCacheBase.cpp @@ -358,10 +358,9 @@ TextureCache::TCacheEntryBase* TextureCache::Load(const u32 stage) tex_hash ^= tlut_hash; } - // D3D doesn't like when the specified mipmap count would require more than one 1x1-sized LOD in the mipmap chain - // e.g. 64x64 with 7 LODs would have the mipmap chain 64x64,32x32,16x16,8x8,4x4,2x2,1x1,1x1, so we limit the mipmap count to 6 there - while (g_ActiveConfig.backend_info.bUseMinimalMipCount && std::max(width, height) >> (tex_levels - 1) == 0) - --tex_levels; + // GPUs don't like when the specified mipmap count would require more than one 1x1-sized LOD in the mipmap chain + // e.g. 64x64 with 7 LODs would have the mipmap chain 64x64,32x32,16x16,8x8,4x4,2x2,1x1,0x0, so we limit the mipmap count to 6 there + tex_levels = std::min(IntLog2(std::max(width, height)) + 1, tex_levels); TCacheEntryBase *entry = textures[texID]; if (entry) -- cgit v1.2.3 From a9eb08b85da62944c1cde1594239a19af4559d02 Mon Sep 17 00:00:00 2001 From: degasus Date: Sun, 11 Jan 2015 22:41:04 +0100 Subject: TexCache: Choose texture based on mipmap count --- Source/Core/VideoCommon/TextureCacheBase.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'Source/Core/VideoCommon/TextureCacheBase.cpp') diff --git a/Source/Core/VideoCommon/TextureCacheBase.cpp b/Source/Core/VideoCommon/TextureCacheBase.cpp index 885c78e9a9..b5418069ca 100644 --- a/Source/Core/VideoCommon/TextureCacheBase.cpp +++ b/Source/Core/VideoCommon/TextureCacheBase.cpp @@ -383,7 +383,7 @@ TextureCache::TCacheEntryBase* TextureCache::Load(const u32 stage) // 2. b) For normal textures, all texture parameters need to match if (address == entry->addr && tex_hash == entry->hash && full_format == entry->format && - entry->config.levels >= tex_levels && entry->native_width == nativeW && entry->native_height == nativeH) + entry->native_levels >= tex_levels && entry->native_width == nativeW && entry->native_height == nativeH) { return ReturnEntry(stage, entry); } @@ -476,7 +476,7 @@ TextureCache::TCacheEntryBase* TextureCache::Load(const u32 stage) } entry->SetGeneralParameters(address, texture_size, full_format); - entry->SetDimensions(nativeW, nativeH); + entry->SetDimensions(nativeW, nativeH, tex_levels); entry->hash = tex_hash; // load texture @@ -873,7 +873,7 @@ void TextureCache::CopyRenderTargetToTexture(u32 dstAddr, unsigned int dstFormat // TODO: Using the wrong dstFormat, dumb... entry->SetGeneralParameters(dstAddr, 0, dstFormat); - entry->SetDimensions(tex_w, tex_h); + entry->SetDimensions(tex_w, tex_h, 1); entry->SetHashes(TEXHASH_INVALID); entry->type = TCET_EC_VRAM; } -- cgit v1.2.3 From 22e06daf5c41c3d201edba8c22c85df5bafee63b Mon Sep 17 00:00:00 2001 From: degasus Date: Sun, 11 Jan 2015 23:11:04 +0100 Subject: TexCache: recreate the entry on level missmatch --- Source/Core/VideoCommon/TextureCacheBase.cpp | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'Source/Core/VideoCommon/TextureCacheBase.cpp') diff --git a/Source/Core/VideoCommon/TextureCacheBase.cpp b/Source/Core/VideoCommon/TextureCacheBase.cpp index b5418069ca..a2b32410f9 100644 --- a/Source/Core/VideoCommon/TextureCacheBase.cpp +++ b/Source/Core/VideoCommon/TextureCacheBase.cpp @@ -466,6 +466,13 @@ TextureCache::TCacheEntryBase* TextureCache::Load(const u32 stage) const bool use_native_mips = use_mipmaps && !using_custom_lods && (width == nativeW && height == nativeH); texLevels = (use_native_mips || using_custom_lods) ? texLevels : 1; // TODO: Should be forced to 1 for non-pow2 textures (e.g. efb copies with automatically adjusted IR) + if (entry && entry->config.levels != texLevels) + { + // delete the texture and make a new one + delete entry; + entry = nullptr; + } + // create the entry/texture if (nullptr == entry) { -- cgit v1.2.3