TextureCache: Remove unsafe texture cache
This commit is contained in:
parent
8c2d87f668
commit
5239ba88c9
|
@ -455,18 +455,14 @@ VideoConfigDiag::VideoConfigDiag(wxWindow* parent, const std::string &title, con
|
||||||
wxStaticBoxSizer* const szr_safetex = new wxStaticBoxSizer(wxHORIZONTAL, page_hacks, _("Texture Cache"));
|
wxStaticBoxSizer* const szr_safetex = new wxStaticBoxSizer(wxHORIZONTAL, page_hacks, _("Texture Cache"));
|
||||||
|
|
||||||
// TODO: Use wxSL_MIN_MAX_LABELS or wxSL_VALUE_LABEL with wx 2.9.1
|
// TODO: Use wxSL_MIN_MAX_LABELS or wxSL_VALUE_LABEL with wx 2.9.1
|
||||||
wxSlider* const stc_slider = new wxSlider(page_hacks, wxID_ANY, 0, 0, 3, wxDefaultPosition, wxDefaultSize, wxSL_HORIZONTAL|wxSL_BOTTOM);
|
wxSlider* const stc_slider = new wxSlider(page_hacks, wxID_ANY, 0, 0, 2, wxDefaultPosition, wxDefaultSize, wxSL_HORIZONTAL|wxSL_BOTTOM);
|
||||||
_connect_macro_(stc_slider, VideoConfigDiag::Event_Stc, wxEVT_COMMAND_SLIDER_UPDATED, this);
|
_connect_macro_(stc_slider, VideoConfigDiag::Event_Stc, wxEVT_COMMAND_SLIDER_UPDATED, this);
|
||||||
RegisterControl(stc_slider, wxGetTranslation(stc_desc));
|
RegisterControl(stc_slider, wxGetTranslation(stc_desc));
|
||||||
|
|
||||||
if (vconfig.bSafeTextureCache)
|
|
||||||
{
|
|
||||||
if (vconfig.iSafeTextureCache_ColorSamples == 0) stc_slider->SetValue(0);
|
if (vconfig.iSafeTextureCache_ColorSamples == 0) stc_slider->SetValue(0);
|
||||||
else if (vconfig.iSafeTextureCache_ColorSamples == 512) stc_slider->SetValue(1);
|
else if (vconfig.iSafeTextureCache_ColorSamples == 512) stc_slider->SetValue(1);
|
||||||
else if (vconfig.iSafeTextureCache_ColorSamples == 128) stc_slider->SetValue(2);
|
else if (vconfig.iSafeTextureCache_ColorSamples == 128) stc_slider->SetValue(2);
|
||||||
else stc_slider->Disable(); // Using custom number of samples; TODO: Inform the user why this is disabled..
|
else stc_slider->Disable(); // Using custom number of samples; TODO: Inform the user why this is disabled..
|
||||||
}
|
|
||||||
else stc_slider->SetValue(3);
|
|
||||||
|
|
||||||
szr_safetex->Add(new wxStaticText(page_hacks, wxID_ANY, _("Accuracy:")), 0, wxALL, 5);
|
szr_safetex->Add(new wxStaticText(page_hacks, wxID_ANY, _("Accuracy:")), 0, wxALL, 5);
|
||||||
szr_safetex->AddStretchSpacer(1);
|
szr_safetex->AddStretchSpacer(1);
|
||||||
|
|
|
@ -120,12 +120,7 @@ protected:
|
||||||
void Event_Stc(wxCommandEvent &ev)
|
void Event_Stc(wxCommandEvent &ev)
|
||||||
{
|
{
|
||||||
int samples[] = { 0, 512, 128 };
|
int samples[] = { 0, 512, 128 };
|
||||||
if (ev.GetInt() < 3)
|
|
||||||
{
|
|
||||||
vconfig.iSafeTextureCache_ColorSamples = samples[ev.GetInt()];
|
vconfig.iSafeTextureCache_ColorSamples = samples[ev.GetInt()];
|
||||||
vconfig.bSafeTextureCache = true;
|
|
||||||
}
|
|
||||||
else vconfig.bSafeTextureCache = false;
|
|
||||||
|
|
||||||
ev.Skip();
|
ev.Skip();
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,28 +23,19 @@ enum
|
||||||
|
|
||||||
TextureCache *g_texture_cache;
|
TextureCache *g_texture_cache;
|
||||||
|
|
||||||
GC_ALIGNED16(u8 *TextureCache::temp) = NULL;
|
GC_ALIGNED16(u8 *TextureCache::temp) = NULL;
|
||||||
|
|
||||||
TextureCache::TexCache TextureCache::textures;
|
TextureCache::TexCache TextureCache::textures;
|
||||||
bool TextureCache::DeferredInvalidate;
|
bool TextureCache::DeferredInvalidate;
|
||||||
|
|
||||||
TextureCache::TCacheEntryBase::~TCacheEntryBase()
|
TextureCache::TCacheEntryBase::~TCacheEntryBase()
|
||||||
{
|
{
|
||||||
if (0 == addr)
|
|
||||||
return;
|
|
||||||
|
|
||||||
if (!isRenderTarget && !g_ActiveConfig.bSafeTextureCache)
|
|
||||||
{
|
|
||||||
u32 *const ptr = (u32*)Memory::GetPointer(addr);
|
|
||||||
if (ptr && *ptr == hash)
|
|
||||||
*ptr = oldpixel;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
TextureCache::TextureCache()
|
TextureCache::TextureCache()
|
||||||
{
|
{
|
||||||
if (!temp)
|
if (!temp)
|
||||||
temp =(u8*) AllocateAlignedMemory(TEMP_SIZE,16);
|
temp = (u8*)AllocateAlignedMemory(TEMP_SIZE,16);
|
||||||
TexDecoder_SetTexFmtOverlayOptions(g_ActiveConfig.bTexFmtOverlayEnable, g_ActiveConfig.bTexFmtOverlayCenter);
|
TexDecoder_SetTexFmtOverlayOptions(g_ActiveConfig.bTexFmtOverlayEnable, g_ActiveConfig.bTexFmtOverlayCenter);
|
||||||
if(g_ActiveConfig.bHiresTextures && !g_ActiveConfig.bDumpTextures)
|
if(g_ActiveConfig.bHiresTextures && !g_ActiveConfig.bDumpTextures)
|
||||||
HiresTextures::Init(SConfig::GetInstance().m_LocalCoreStartupParameter.m_strUniqueID.c_str());
|
HiresTextures::Init(SConfig::GetInstance().m_LocalCoreStartupParameter.m_strUniqueID.c_str());
|
||||||
|
@ -198,7 +189,7 @@ TextureCache::TCacheEntryBase* TextureCache::Load(unsigned int stage,
|
||||||
if (isPaletteTexture)
|
if (isPaletteTexture)
|
||||||
full_format = texformat | (tlutfmt << 16);
|
full_format = texformat | (tlutfmt << 16);
|
||||||
|
|
||||||
if (isPaletteTexture && (g_ActiveConfig.bSafeTextureCache || g_ActiveConfig.bHiresTextures || g_ActiveConfig.bDumpTextures))
|
if (isPaletteTexture)
|
||||||
{
|
{
|
||||||
const u32 palette_size = TexDecoder_GetPaletteSize(texformat);
|
const u32 palette_size = TexDecoder_GetPaletteSize(texformat);
|
||||||
tlut_hash = GetHash64(&texMem[tlutaddr], palette_size, g_ActiveConfig.iSafeTextureCache_ColorSamples);
|
tlut_hash = GetHash64(&texMem[tlutaddr], palette_size, g_ActiveConfig.iSafeTextureCache_ColorSamples);
|
||||||
|
@ -212,7 +203,6 @@ TextureCache::TCacheEntryBase* TextureCache::Load(unsigned int stage,
|
||||||
// we must make sure that a paletted texture gets assigned multiple IDs for each tlut used.
|
// we must make sure that a paletted texture gets assigned multiple IDs for each tlut used.
|
||||||
//
|
//
|
||||||
// TODO: Because texID isn't always the same as the address now, CopyRenderTargetToTexture might be broken now
|
// TODO: Because texID isn't always the same as the address now, CopyRenderTargetToTexture might be broken now
|
||||||
if (g_ActiveConfig.bSafeTextureCache)
|
|
||||||
texID ^= ((u32)tlut_hash) ^(u32)(tlut_hash >> 32);
|
texID ^= ((u32)tlut_hash) ^(u32)(tlut_hash >> 32);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -225,40 +215,15 @@ TextureCache::TCacheEntryBase* TextureCache::Load(unsigned int stage,
|
||||||
TCacheEntryBase *entry = textures[texID];
|
TCacheEntryBase *entry = textures[texID];
|
||||||
if (entry)
|
if (entry)
|
||||||
{
|
{
|
||||||
// hires texture loading and texture dumping require accurate hashes
|
// 1. Calculate reference hash:
|
||||||
if (g_ActiveConfig.bSafeTextureCache || g_ActiveConfig.bHiresTextures || g_ActiveConfig.bDumpTextures)
|
// calculated from RAM texture data for normal textures. Hashes for paletted textures are modified by tlut_hash. 0 for virtual EFB copies.
|
||||||
{
|
hash_value = texHash = GetHash64(ptr, texture_size, g_ActiveConfig.iSafeTextureCache_ColorSamples);
|
||||||
texHash = GetHash64(ptr, texture_size, g_ActiveConfig.iSafeTextureCache_ColorSamples);
|
|
||||||
|
|
||||||
if (isPaletteTexture)
|
if (isPaletteTexture)
|
||||||
texHash ^= tlut_hash;
|
hash_value = texHash ^= tlut_hash;
|
||||||
|
|
||||||
if (g_ActiveConfig.bSafeTextureCache)
|
|
||||||
hash_value = texHash;
|
|
||||||
}
|
|
||||||
|
|
||||||
// 1. Adjust reference hash:
|
|
||||||
// safe texcache: reference hash was calculated above for normal textures. 0 for virtual EFB copies.
|
|
||||||
// unsafe texcache: 0 for virtual EFB copies. Safe hash for dynamic EFB copies. First pixel for normal textures.
|
|
||||||
if (g_ActiveConfig.bSafeTextureCache)
|
|
||||||
{
|
|
||||||
if (g_ActiveConfig.bCopyEFBToTexture && (entry->isRenderTarget || entry->isDynamic))
|
if (g_ActiveConfig.bCopyEFBToTexture && (entry->isRenderTarget || entry->isDynamic))
|
||||||
hash_value = TEXHASH_INVALID;
|
hash_value = TEXHASH_INVALID;
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if (!(entry->isRenderTarget || entry->isDynamic))
|
|
||||||
hash_value = *(u32*)ptr;
|
|
||||||
else if (g_ActiveConfig.bCopyEFBToTexture)
|
|
||||||
hash_value = TEXHASH_INVALID;
|
|
||||||
else
|
|
||||||
{
|
|
||||||
hash_value = GetHash64(ptr, texture_size, g_ActiveConfig.iSafeTextureCache_ColorSamples);
|
|
||||||
|
|
||||||
if (isPaletteTexture)
|
|
||||||
hash_value ^= tlut_hash; // TODO: Ugly, this is using Safe Texture Cache parameters in nonsafe TC
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// 2. a) For EFB copies, only the hash and the texture address need to match
|
// 2. a) For EFB copies, only the hash and the texture address need to match
|
||||||
if ((entry->isRenderTarget || entry->isDynamic) && hash_value == entry->hash && address == entry->addr)
|
if ((entry->isRenderTarget || entry->isDynamic) && hash_value == entry->hash && address == entry->addr)
|
||||||
|
@ -344,12 +309,7 @@ TextureCache::TCacheEntryBase* TextureCache::Load(unsigned int stage,
|
||||||
entry->SetGeneralParameters(address, texture_size, full_format, entry->num_mipmaps);
|
entry->SetGeneralParameters(address, texture_size, full_format, entry->num_mipmaps);
|
||||||
entry->SetDimensions(nativeW, nativeH, width, height);
|
entry->SetDimensions(nativeW, nativeH, width, height);
|
||||||
entry->SetEFBCopyParameters(false, texture_is_dynamic);
|
entry->SetEFBCopyParameters(false, texture_is_dynamic);
|
||||||
entry->oldpixel = *(u32*)ptr;
|
|
||||||
|
|
||||||
if (g_ActiveConfig.bSafeTextureCache || entry->isDynamic)
|
|
||||||
entry->hash = hash_value;
|
entry->hash = hash_value;
|
||||||
else
|
|
||||||
entry->hash = *(u32*)ptr = (u32)(((double)rand() / RAND_MAX) * 0xFFFFFFFF);
|
|
||||||
|
|
||||||
// load texture
|
// load texture
|
||||||
entry->Load(width, height, expandedWidth, 0, (texLevels == 0));
|
entry->Load(width, height, expandedWidth, 0, (texLevels == 0));
|
||||||
|
|
|
@ -38,9 +38,6 @@ public:
|
||||||
// used to delete textures which haven't been used for TEXTURE_KILL_THRESHOLD frames
|
// used to delete textures which haven't been used for TEXTURE_KILL_THRESHOLD frames
|
||||||
int frameCount;
|
int frameCount;
|
||||||
|
|
||||||
// deprecated members
|
|
||||||
u32 oldpixel;
|
|
||||||
|
|
||||||
|
|
||||||
void SetGeneralParameters(u32 addr, u32 size, u32 format, unsigned int num_mipmaps)
|
void SetGeneralParameters(u32 addr, u32 size, u32 format, unsigned int num_mipmaps)
|
||||||
{
|
{
|
||||||
|
|
|
@ -58,11 +58,7 @@ void VideoConfig::Load(const char *ini_file)
|
||||||
iniFile.Get("Settings", "UseXFB", &bUseXFB, 0);
|
iniFile.Get("Settings", "UseXFB", &bUseXFB, 0);
|
||||||
iniFile.Get("Settings", "UseRealXFB", &bUseRealXFB, 0);
|
iniFile.Get("Settings", "UseRealXFB", &bUseRealXFB, 0);
|
||||||
iniFile.Get("Settings", "UseNativeMips", &bUseNativeMips, false);
|
iniFile.Get("Settings", "UseNativeMips", &bUseNativeMips, false);
|
||||||
|
|
||||||
iniFile.Get("Settings", "SafeTextureCache", &bSafeTextureCache, true); // Settings
|
|
||||||
//Safe texture cache params
|
|
||||||
iniFile.Get("Settings", "SafeTextureCacheColorSamples", &iSafeTextureCache_ColorSamples,128);
|
iniFile.Get("Settings", "SafeTextureCacheColorSamples", &iSafeTextureCache_ColorSamples,128);
|
||||||
|
|
||||||
iniFile.Get("Settings", "ShowFPS", &bShowFPS, false); // Settings
|
iniFile.Get("Settings", "ShowFPS", &bShowFPS, false); // Settings
|
||||||
iniFile.Get("Settings", "ShowInputDisplay", &bShowInputDisplay, false);
|
iniFile.Get("Settings", "ShowInputDisplay", &bShowInputDisplay, false);
|
||||||
iniFile.Get("Settings", "OverlayStats", &bOverlayStats, false);
|
iniFile.Get("Settings", "OverlayStats", &bOverlayStats, false);
|
||||||
|
@ -134,7 +130,6 @@ void VideoConfig::GameIniLoad(const char *ini_file)
|
||||||
iniFile.GetIfExists("Video_Settings", "UseXFB", &bUseXFB);
|
iniFile.GetIfExists("Video_Settings", "UseXFB", &bUseXFB);
|
||||||
iniFile.GetIfExists("Video_Settings", "UseRealXFB", &bUseRealXFB);
|
iniFile.GetIfExists("Video_Settings", "UseRealXFB", &bUseRealXFB);
|
||||||
iniFile.GetIfExists("Video_Settings", "UseNativeMips", &bUseNativeMips);
|
iniFile.GetIfExists("Video_Settings", "UseNativeMips", &bUseNativeMips);
|
||||||
iniFile.GetIfExists("Video_Settings", "SafeTextureCache", &bSafeTextureCache);
|
|
||||||
iniFile.GetIfExists("Video_Settings", "SafeTextureCacheColorSamples", &iSafeTextureCache_ColorSamples);
|
iniFile.GetIfExists("Video_Settings", "SafeTextureCacheColorSamples", &iSafeTextureCache_ColorSamples);
|
||||||
iniFile.GetIfExists("Video_Settings", "DLOptimize", &iCompileDLsLevel);
|
iniFile.GetIfExists("Video_Settings", "DLOptimize", &iCompileDLsLevel);
|
||||||
iniFile.GetIfExists("Video_Settings", "HiresTextures", &bHiresTextures);
|
iniFile.GetIfExists("Video_Settings", "HiresTextures", &bHiresTextures);
|
||||||
|
@ -196,11 +191,7 @@ void VideoConfig::Save(const char *ini_file)
|
||||||
iniFile.Set("Settings", "UseXFB", bUseXFB);
|
iniFile.Set("Settings", "UseXFB", bUseXFB);
|
||||||
iniFile.Set("Settings", "UseRealXFB", bUseRealXFB);
|
iniFile.Set("Settings", "UseRealXFB", bUseRealXFB);
|
||||||
iniFile.Set("Settings", "UseNativeMips", bUseNativeMips);
|
iniFile.Set("Settings", "UseNativeMips", bUseNativeMips);
|
||||||
|
|
||||||
iniFile.Set("Settings", "SafeTextureCache", bSafeTextureCache);
|
|
||||||
//safe texture cache params
|
|
||||||
iniFile.Set("Settings", "SafeTextureCacheColorSamples", iSafeTextureCache_ColorSamples);
|
iniFile.Set("Settings", "SafeTextureCacheColorSamples", iSafeTextureCache_ColorSamples);
|
||||||
|
|
||||||
iniFile.Set("Settings", "ShowFPS", bShowFPS);
|
iniFile.Set("Settings", "ShowFPS", bShowFPS);
|
||||||
iniFile.Set("Settings", "ShowInputDisplay", bShowInputDisplay);
|
iniFile.Set("Settings", "ShowInputDisplay", bShowInputDisplay);
|
||||||
iniFile.Set("Settings", "OverlayStats", bOverlayStats);
|
iniFile.Set("Settings", "OverlayStats", bOverlayStats);
|
||||||
|
@ -279,7 +270,6 @@ void VideoConfig::GameIniSave(const char* default_ini, const char* game_ini)
|
||||||
SET_IF_DIFFERS("Video_Settings", "UseXFB", bUseXFB);
|
SET_IF_DIFFERS("Video_Settings", "UseXFB", bUseXFB);
|
||||||
SET_IF_DIFFERS("Video_Settings", "UseRealXFB", bUseRealXFB);
|
SET_IF_DIFFERS("Video_Settings", "UseRealXFB", bUseRealXFB);
|
||||||
SET_IF_DIFFERS("Video_Settings", "UseNativeMips", bUseNativeMips);
|
SET_IF_DIFFERS("Video_Settings", "UseNativeMips", bUseNativeMips);
|
||||||
SET_IF_DIFFERS("Video_Settings", "SafeTextureCache", bSafeTextureCache);
|
|
||||||
SET_IF_DIFFERS("Video_Settings", "SafeTextureCacheColorSamples", iSafeTextureCache_ColorSamples);
|
SET_IF_DIFFERS("Video_Settings", "SafeTextureCacheColorSamples", iSafeTextureCache_ColorSamples);
|
||||||
SET_IF_DIFFERS("Video_Settings", "DLOptimize", iCompileDLsLevel);
|
SET_IF_DIFFERS("Video_Settings", "DLOptimize", iCompileDLsLevel);
|
||||||
SET_IF_DIFFERS("Video_Settings", "HiresTextures", bHiresTextures);
|
SET_IF_DIFFERS("Video_Settings", "HiresTextures", bHiresTextures);
|
||||||
|
|
|
@ -129,7 +129,6 @@ struct VideoConfig
|
||||||
bool bOSDHotKey;
|
bool bOSDHotKey;
|
||||||
bool bCopyEFBToTexture;
|
bool bCopyEFBToTexture;
|
||||||
bool bCopyEFBScaled;
|
bool bCopyEFBScaled;
|
||||||
bool bSafeTextureCache;
|
|
||||||
int iSafeTextureCache_ColorSamples;
|
int iSafeTextureCache_ColorSamples;
|
||||||
int iPhackvalue[4];
|
int iPhackvalue[4];
|
||||||
std::string sPhackvalue[2];
|
std::string sPhackvalue[2];
|
||||||
|
|
|
@ -1106,12 +1106,11 @@ void Renderer::Swap(u32 xfbAddr, FieldType field, u32 fbWidth, u32 fbHeight,cons
|
||||||
DLCache::ProgressiveCleanup();
|
DLCache::ProgressiveCleanup();
|
||||||
TextureCache::Cleanup();
|
TextureCache::Cleanup();
|
||||||
|
|
||||||
// reload textures if these settings changed
|
// Reload textures if this settings changes
|
||||||
if (g_Config.bSafeTextureCache != g_ActiveConfig.bSafeTextureCache ||
|
if (g_Config.bUseNativeMips != g_ActiveConfig.bUseNativeMips)
|
||||||
g_Config.bUseNativeMips != g_ActiveConfig.bUseNativeMips)
|
|
||||||
TextureCache::Invalidate(false);
|
TextureCache::Invalidate(false);
|
||||||
|
|
||||||
// Enable any configuration changes
|
// Enable configuration changes
|
||||||
UpdateActiveConfig();
|
UpdateActiveConfig();
|
||||||
|
|
||||||
SetWindowSize(fbWidth, fbHeight);
|
SetWindowSize(fbWidth, fbHeight);
|
||||||
|
|
|
@ -1114,12 +1114,11 @@ void Renderer::Swap(u32 xfbAddr, FieldType field, u32 fbWidth, u32 fbHeight,cons
|
||||||
DLCache::ProgressiveCleanup();
|
DLCache::ProgressiveCleanup();
|
||||||
TextureCache::Cleanup();
|
TextureCache::Cleanup();
|
||||||
|
|
||||||
// reload textures if these settings changed
|
// Reload textures if these settings changed
|
||||||
if (g_Config.bSafeTextureCache != g_ActiveConfig.bSafeTextureCache ||
|
if (g_Config.bUseNativeMips != g_ActiveConfig.bUseNativeMips)
|
||||||
g_Config.bUseNativeMips != g_ActiveConfig.bUseNativeMips)
|
|
||||||
TextureCache::Invalidate(false);
|
TextureCache::Invalidate(false);
|
||||||
|
|
||||||
// Enable any configuration changes
|
// Enable configuration changes
|
||||||
UpdateActiveConfig();
|
UpdateActiveConfig();
|
||||||
|
|
||||||
SetWindowSize(fbWidth, fbHeight);
|
SetWindowSize(fbWidth, fbHeight);
|
||||||
|
|
|
@ -1394,8 +1394,7 @@ void Renderer::Swap(u32 xfbAddr, FieldType field, u32 fbWidth, u32 fbHeight,cons
|
||||||
g_Config.iSaveTargetId = 0;
|
g_Config.iSaveTargetId = 0;
|
||||||
|
|
||||||
// reload textures if these settings changed
|
// reload textures if these settings changed
|
||||||
if (g_Config.bSafeTextureCache != g_ActiveConfig.bSafeTextureCache ||
|
if (g_Config.bUseNativeMips != g_ActiveConfig.bUseNativeMips)
|
||||||
g_Config.bUseNativeMips != g_ActiveConfig.bUseNativeMips)
|
|
||||||
TextureCache::Invalidate(false);
|
TextureCache::Invalidate(false);
|
||||||
|
|
||||||
if (g_Config.bCopyEFBToTexture != g_ActiveConfig.bCopyEFBToTexture)
|
if (g_Config.bCopyEFBToTexture != g_ActiveConfig.bCopyEFBToTexture)
|
||||||
|
|
Loading…
Reference in New Issue