Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Invalidate the texture cache using the GPU thread when the CPU thread…
… makes a request.

Fixes issue 6350.
  • Loading branch information
skidau committed Jun 8, 2013
1 parent 3ff2a3a commit 196d152
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 3 deletions.
2 changes: 1 addition & 1 deletion Source/Core/Core/Src/HLE/HLE_Misc.cpp
Expand Up @@ -311,7 +311,7 @@ void ExecuteDOL(u8* dolFile, u32 fileSize)
}

PowerPC::ppcState.iCache.Reset();
TextureCache::Invalidate();
TextureCache::RequestInvalidateTextureCache();

CWII_IPC_HLE_Device_usb_oh1_57e_305* s_Usb = GetUsbPointer();
size_t size = s_Usb->m_WiiMotes.size();
Expand Down
13 changes: 12 additions & 1 deletion Source/Core/VideoCommon/Src/TextureCacheBase.cpp
Expand Up @@ -32,6 +32,7 @@ TextureCache::TexCache TextureCache::textures;

TextureCache::BackupConfig TextureCache::backup_config;

bool invalidate_texture_cache_requested;

TextureCache::TCacheEntryBase::~TCacheEntryBase()
{
Expand All @@ -49,6 +50,13 @@ TextureCache::TextureCache()
HiresTextures::Init(SConfig::GetInstance().m_LocalCoreStartupParameter.m_strUniqueID.c_str());

SetHash64Function(g_ActiveConfig.bHiresTextures || g_ActiveConfig.bDumpTextures);

invalidate_texture_cache_requested = false;
}

void TextureCache::RequestInvalidateTextureCache()
{
invalidate_texture_cache_requested = true;
}

void TextureCache::Invalidate()
Expand Down Expand Up @@ -80,7 +88,8 @@ void TextureCache::OnConfigChanged(VideoConfig& config)
if (config.iSafeTextureCache_ColorSamples != backup_config.s_colorsamples ||
config.bTexFmtOverlayEnable != backup_config.s_texfmt_overlay ||
config.bTexFmtOverlayCenter != backup_config.s_texfmt_overlay_center ||
config.bHiresTextures != backup_config.s_hires_textures)
config.bHiresTextures != backup_config.s_hires_textures ||
invalidate_texture_cache_requested)
{
g_texture_cache->Invalidate();

Expand All @@ -89,6 +98,8 @@ void TextureCache::OnConfigChanged(VideoConfig& config)

SetHash64Function(g_ActiveConfig.bHiresTextures || g_ActiveConfig.bDumpTextures);
TexDecoder_SetTexFmtOverlayOptions(g_ActiveConfig.bTexFmtOverlayEnable, g_ActiveConfig.bTexFmtOverlayCenter);

invalidate_texture_cache_requested = false;
}

// TODO: Probably shouldn't clear all render targets here, just mark them dirty or something.
Expand Down
3 changes: 2 additions & 1 deletion Source/Core/VideoCommon/Src/TextureCacheBase.h
Expand Up @@ -107,6 +107,8 @@ class TextureCache
static void CopyRenderTargetToTexture(u32 dstAddr, unsigned int dstFormat, unsigned int srcFormat,
const EFBRectangle& srcRect, bool isIntensity, bool scaleByHalf);

static void RequestInvalidateTextureCache();

protected:
TextureCache();

Expand All @@ -118,7 +120,6 @@ class TextureCache
static PC_TexFormat LoadCustomTexture(u64 tex_hash, int texformat, unsigned int level, unsigned int& width, unsigned int& height);
static void DumpTexture(TCacheEntryBase* entry, unsigned int level);


typedef std::map<u32, TCacheEntryBase*> TexCache;

static TexCache textures;
Expand Down

0 comments on commit 196d152

Please sign in to comment.