diff --git a/Source/Core/VideoCommon/Src/VideoConfig.cpp b/Source/Core/VideoCommon/Src/VideoConfig.cpp index a023099ad1..3d9647c259 100644 --- a/Source/Core/VideoCommon/Src/VideoConfig.cpp +++ b/Source/Core/VideoCommon/Src/VideoConfig.cpp @@ -63,8 +63,7 @@ void VideoConfig::Load(const char *ini_file) iniFile.Get("Settings", "SafeTextureCache", &bSafeTextureCache, false); // Settings //Safe texture cache params - iniFile.Get("Settings", "SafeTextureCacheColorSamples", &iSafeTextureCache_ColorSamples,37); - iniFile.Get("Settings", "SafeTextureCacheTlutMaxSize", &iSafeTextureCache_TlutMaxSize,1024); + iniFile.Get("Settings", "SafeTextureCacheColorSamples", &iSafeTextureCache_ColorSamples,512); iniFile.Get("Settings", "ShowFPS", &bShowFPS, false); // Settings iniFile.Get("Settings", "OverlayStats", &bOverlayStats, false); @@ -132,9 +131,7 @@ void VideoConfig::GameIniLoad(const char *ini_file) iniFile.Get("Video", "SafeTextureCache", &bSafeTextureCache, false); //Safe texture cache params if (iniFile.Exists("Video", "SafeTextureCacheColorSamples")) - iniFile.Get("Video", "SafeTextureCacheColorSamples", &iSafeTextureCache_ColorSamples,37); - if (iniFile.Exists("Video", "SafeTextureCacheTlutMaxSize")) - iniFile.Get("Video", "SafeTextureCacheTlutMaxSize", &iSafeTextureCache_TlutMaxSize,1024); + iniFile.Get("Video", "SafeTextureCacheColorSamples", &iSafeTextureCache_ColorSamples,512); if (iniFile.Exists("Video", "MSAA")) iniFile.Get("Video", "MSAA", &iMultisampleMode, 0); @@ -169,7 +166,6 @@ void VideoConfig::Save(const char *ini_file) iniFile.Set("Settings", "SafeTextureCache", bSafeTextureCache); //safe texture cache params iniFile.Set("Settings", "SafeTextureCacheColorSamples", iSafeTextureCache_ColorSamples); - iniFile.Set("Settings", "SafeTextureCacheTlutMaxSize", iSafeTextureCache_TlutMaxSize); iniFile.Set("Settings", "ShowFPS", bShowFPS); iniFile.Set("Settings", "OverlayStats", bOverlayStats); diff --git a/Source/Core/VideoCommon/Src/VideoConfig.h b/Source/Core/VideoCommon/Src/VideoConfig.h index 9cb08d4082..d44de664dc 100644 --- a/Source/Core/VideoCommon/Src/VideoConfig.h +++ b/Source/Core/VideoCommon/Src/VideoConfig.h @@ -119,8 +119,7 @@ struct VideoConfig bool bCopyEFBToTexture; bool bCopyEFBScaled; bool bSafeTextureCache; - int iSafeTextureCache_ColorSamples; - int iSafeTextureCache_TlutMaxSize; + int iSafeTextureCache_ColorSamples; bool bFIFOBPhack; int iPhackvalue; bool bPhackvalue1, bPhackvalue2; diff --git a/Source/Plugins/Plugin_VideoDX9/Src/DlgSettings.cpp b/Source/Plugins/Plugin_VideoDX9/Src/DlgSettings.cpp index 6c14fb07ff..9c38fe2b48 100644 --- a/Source/Plugins/Plugin_VideoDX9/Src/DlgSettings.cpp +++ b/Source/Plugins/Plugin_VideoDX9/Src/DlgSettings.cpp @@ -96,13 +96,13 @@ struct TabDirect3D : public W32Util::Tab Button_SetCheck(GetDlgItem(hDlg, IDC_WIDESCREEN_HACK), g_Config.bWidescreenHack); Button_SetCheck(GetDlgItem(hDlg, IDC_SAFE_TEXTURE_CACHE), g_Config.bSafeTextureCache); - if(g_Config.iSafeTextureCache_ColorSamples == 0 && g_Config.iSafeTextureCache_TlutMaxSize == 0) + if(g_Config.iSafeTextureCache_ColorSamples == 0) { Button_SetCheck(GetDlgItem(hDlg, IDC_SAFE_TEXTURE_CACHE_SAFE), true); } else { - if(g_Config.iSafeTextureCache_ColorSamples > 36 && g_Config.iSafeTextureCache_TlutMaxSize > 4095) + if(g_Config.iSafeTextureCache_ColorSamples > 128) { Button_SetCheck(GetDlgItem(hDlg, IDC_SAFE_TEXTURE_CACHE_NORMAL), true); } @@ -160,32 +160,23 @@ struct TabDirect3D : public W32Util::Tab g_Config.RenderToMainframe = Button_GetCheck(GetDlgItem(hDlg, IDC_RENDER_TO_MAINWINDOW)) ? true : false; if(Button_GetCheck(GetDlgItem(hDlg, IDC_SAFE_TEXTURE_CACHE_SAFE))) { - g_Config.iSafeTextureCache_ColorSamples = 0; - g_Config.iSafeTextureCache_TlutMaxSize = 0; + g_Config.iSafeTextureCache_ColorSamples = 0; } else { if(Button_GetCheck(GetDlgItem(hDlg, IDC_SAFE_TEXTURE_CACHE_NORMAL))) { - if(g_Config.iSafeTextureCache_ColorSamples < 37) + if(g_Config.iSafeTextureCache_ColorSamples < 512) { - g_Config.iSafeTextureCache_ColorSamples = 37; - } - if(g_Config.iSafeTextureCache_TlutMaxSize < 4096) - { - g_Config.iSafeTextureCache_TlutMaxSize = 4096; - } + g_Config.iSafeTextureCache_ColorSamples = 512; + } } else { - if(g_Config.iSafeTextureCache_ColorSamples > 36 || g_Config.iSafeTextureCache_ColorSamples == 0) + if(g_Config.iSafeTextureCache_ColorSamples > 128 || g_Config.iSafeTextureCache_ColorSamples == 0) { - g_Config.iSafeTextureCache_ColorSamples = 8; - } - if(g_Config.iSafeTextureCache_TlutMaxSize > 1024 || g_Config.iSafeTextureCache_TlutMaxSize == 0) - { - g_Config.iSafeTextureCache_TlutMaxSize = 1024; - } + g_Config.iSafeTextureCache_ColorSamples = 128; + } } } g_Config.Save((std::string(File::GetUserPath(D_CONFIG_IDX)) + "gfx_dx9.ini").c_str()); diff --git a/Source/Plugins/Plugin_VideoDX9/Src/TextureCache.cpp b/Source/Plugins/Plugin_VideoDX9/Src/TextureCache.cpp index 3508acfc8b..b380546284 100644 --- a/Source/Plugins/Plugin_VideoDX9/Src/TextureCache.cpp +++ b/Source/Plugins/Plugin_VideoDX9/Src/TextureCache.cpp @@ -156,7 +156,7 @@ TextureCache::TCacheEntry *TextureCache::Load(int stage, u32 address, int width, if (g_ActiveConfig.bSafeTextureCache || g_ActiveConfig.bHiresTextures || g_ActiveConfig.bDumpTextures) { - + texHash = TexDecoder_GetHash64(ptr,TexDecoder_GetTextureSizeInBytes(expandedWidth, expandedHeight, tex_format),g_ActiveConfig.iSafeTextureCache_ColorSamples); if ((tex_format == GX_TF_C4) || (tex_format == GX_TF_C8) || (tex_format == GX_TF_C14X2)) { // WARNING! texID != address now => may break CopyRenderTargetToTexture (cf. TODO up) @@ -166,23 +166,13 @@ TextureCache::TCacheEntry *TextureCache::Load(int stage, u32 address, int width, // each other stored in a single texture, and uses the palette to make different characters // visible or invisible. Thus, unless we want to recreate the textures for every drawn character, // we must make sure that texture with different tluts get different IDs. - int tempsize = TexDecoder_GetTextureSizeInBytes(expandedWidth, expandedHeight, tex_format); - texHash = TexDecoder_GetHash64(ptr,tempsize,0); - - tempsize = TexDecoder_GetPaletteSize(tex_format); - tempsize = (g_ActiveConfig.iSafeTextureCache_TlutMaxSize != 0 && g_ActiveConfig.iSafeTextureCache_TlutMaxSize < tempsize)?g_ActiveConfig.iSafeTextureCache_TlutMaxSize : tempsize; - u32 tlutHash = TexDecoder_GetHash32(&texMem[tlutaddr], tempsize,0); + u64 tlutHash = TexDecoder_GetHash64(&texMem[tlutaddr], TexDecoder_GetPaletteSize(tex_format),g_ActiveConfig.iSafeTextureCache_ColorSamples); texHash ^= tlutHash; if (g_ActiveConfig.bSafeTextureCache) { - texID = texID ^ tlutHash; + texID = texID ^ ((u32)(tlutHash & 0xFFFFFFFF)) ^ ((u32)((tlutHash >> 32) & 0xFFFFFFFF)); } } - else - { - int tempsize = TexDecoder_GetTextureSizeInBytes(expandedWidth, expandedHeight, tex_format); - texHash = TexDecoder_GetHash64(ptr, tempsize,g_ActiveConfig.iSafeTextureCache_ColorSamples); - } if (g_ActiveConfig.bSafeTextureCache) hash_value = texHash; } diff --git a/Source/Plugins/Plugin_VideoOGL/Src/TextureMngr.cpp b/Source/Plugins/Plugin_VideoOGL/Src/TextureMngr.cpp index a51a7619ed..2a2be10dec 100644 --- a/Source/Plugins/Plugin_VideoOGL/Src/TextureMngr.cpp +++ b/Source/Plugins/Plugin_VideoOGL/Src/TextureMngr.cpp @@ -265,6 +265,7 @@ TextureMngr::TCacheEntry* TextureMngr::Load(int texstage, u32 address, int width FullFormat = (tex_format | (tlutfmt << 16)); if (g_ActiveConfig.bSafeTextureCache || g_ActiveConfig.bHiresTextures || g_ActiveConfig.bDumpTextures) { + texHash = TexDecoder_GetHash64(ptr,TexDecoder_GetTextureSizeInBytes(expandedWidth, expandedHeight, tex_format),g_ActiveConfig.iSafeTextureCache_ColorSamples); if ((tex_format == GX_TF_C4) || (tex_format == GX_TF_C8) || (tex_format == GX_TF_C14X2)) { // WARNING! texID != address now => may break CopyRenderTargetToTexture (cf. TODO up) @@ -274,23 +275,13 @@ TextureMngr::TCacheEntry* TextureMngr::Load(int texstage, u32 address, int width // each other stored in a single texture, and uses the palette to make different characters // visible or invisible. Thus, unless we want to recreate the textures for every drawn character, // we must make sure that texture with different tluts get different IDs. - int tempsize = TexDecoder_GetTextureSizeInBytes(expandedWidth, expandedHeight, tex_format); - texHash = TexDecoder_GetHash64(ptr,tempsize,0); - - tempsize = TexDecoder_GetPaletteSize(tex_format); - tempsize = (g_ActiveConfig.iSafeTextureCache_TlutMaxSize != 0 && g_ActiveConfig.iSafeTextureCache_TlutMaxSize < tempsize)?g_ActiveConfig.iSafeTextureCache_TlutMaxSize : tempsize; - u32 tlutHash = TexDecoder_GetHash32(&texMem[tlutaddr], tempsize,0); + u64 tlutHash = TexDecoder_GetHash64(&texMem[tlutaddr], TexDecoder_GetPaletteSize(tex_format),g_ActiveConfig.iSafeTextureCache_ColorSamples); texHash ^= tlutHash; if (g_ActiveConfig.bSafeTextureCache) { - texID = texID ^ tlutHash; + texID = texID ^ ((u32)(tlutHash & 0xFFFFFFFF)) ^ ((u32)((tlutHash >> 32) & 0xFFFFFFFF)); } } - else - { - int tempsize = TexDecoder_GetTextureSizeInBytes(expandedWidth, expandedHeight, tex_format); - texHash = TexDecoder_GetHash64(ptr, tempsize,g_ActiveConfig.iSafeTextureCache_ColorSamples); - } if (g_ActiveConfig.bSafeTextureCache) hash_value = texHash; }