Simplify the params for the safe texture cache

after some test the more relevant parameters were the color samples and the tlut max size.
so delete the rest of the parameters and define 3 modes:
Safe : the two values are set to 0 meaning all the texture data and all the tlut data are hashed this is the most correct and slowwwwwwwwwww way
Normal: 37 samples are taken from the color textures an the firs 4096 bytes of the tlut are hashed, is a lot faster than safe mode but in some games i observe small glitches.
Fast: 8 samples are taken from the color textures an the first 1024 bytes are hashed from the tlut, is a little slower than the unsafe cache but at least all the games i tested have correct text output and fast frame rate. the glitches in dinamyc color textures are more noticeable in this mode
this values could be improved, if you find a better combination please post it and the game it fixes and i will update the source.
for the moment, as my time is limited by a lot of work, only implemented the d3d gui, if someone can implement the opengl gui will be a lot of help for me.
please test a lot and let me know the results.


git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@5135 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
Rodolfo Osvaldo Bogado 2010-02-26 12:54:08 +00:00
parent 0718385f27
commit 02189ec5e0
7 changed files with 100 additions and 50 deletions

View File

@ -63,12 +63,8 @@ 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", "SafeTextureCacheIndexedSamples", &iSafeTextureCache_IndexedSamples,0);
iniFile.Get("Settings", "SafeTextureCacheTlutSamples", &iSafeTextureCache_TlutSamples,0);
iniFile.Get("Settings", "SafeTextureCacheColorMaxSize", &iSafeTextureCache_ColorMaxSize,0);
iniFile.Get("Settings", "SafeTextureCacheIndexedMaxSize", &iSafeTextureCache_IndexedMaxSize,0);
iniFile.Get("Settings", "SafeTextureCacheTlutMaxSize", &iSafeTextureCache_TlutMaxSize,0);
iniFile.Get("Settings", "SafeTextureCacheColorSamples", &iSafeTextureCache_ColorSamples,37);
iniFile.Get("Settings", "SafeTextureCacheTlutMaxSize", &iSafeTextureCache_TlutMaxSize,1024);
iniFile.Get("Settings", "ShowFPS", &bShowFPS, false); // Settings
iniFile.Get("Settings", "OverlayStats", &bOverlayStats, false);
@ -137,16 +133,8 @@ void VideoConfig::GameIniLoad(const char *ini_file)
//Safe texture cache params
if (iniFile.Exists("Video", "SafeTextureCacheColorSamples"))
iniFile.Get("Video", "SafeTextureCacheColorSamples", &iSafeTextureCache_ColorSamples,37);
if (iniFile.Exists("Video", "SafeTextureCacheIndexedSamples"))
iniFile.Get("Video", "SafeTextureCacheIndexedSamples", &iSafeTextureCache_IndexedSamples,0);
if (iniFile.Exists("Video", "SafeTextureCacheTlutSamples"))
iniFile.Get("Video", "SafeTextureCacheTlutSamples", &iSafeTextureCache_TlutSamples,0);
if (iniFile.Exists("Video", "SafeTextureCacheColorMaxSize"))
iniFile.Get("Video", "SafeTextureCacheColorMaxSize", &iSafeTextureCache_ColorMaxSize,0);
if (iniFile.Exists("Video", "SafeTextureCacheIndexedMaxSize"))
iniFile.Get("Video", "SafeTextureCacheIndexedMaxSize", &iSafeTextureCache_IndexedMaxSize,0);
if (iniFile.Exists("Video", "SafeTextureCacheTlutMaxSize"))
iniFile.Get("Video", "SafeTextureCacheTlutMaxSize", &iSafeTextureCache_TlutMaxSize,0);
iniFile.Get("Video", "SafeTextureCacheTlutMaxSize", &iSafeTextureCache_TlutMaxSize,1024);
if (iniFile.Exists("Video", "MSAA"))
iniFile.Get("Video", "MSAA", &iMultisampleMode, 0);
@ -181,10 +169,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", "SafeTextureCacheIndexedSamples", iSafeTextureCache_IndexedSamples);
iniFile.Set("Settings", "SafeTextureCacheTlutSamples", iSafeTextureCache_TlutSamples);
iniFile.Set("Settings", "SafeTextureCacheColorMaxSize", iSafeTextureCache_ColorMaxSize);
iniFile.Set("Settings", "SafeTextureCacheIndexedMaxSize", iSafeTextureCache_IndexedMaxSize);
iniFile.Set("Settings", "SafeTextureCacheTlutMaxSize", iSafeTextureCache_TlutMaxSize);
iniFile.Set("Settings", "ShowFPS", bShowFPS);

View File

@ -120,10 +120,6 @@ struct VideoConfig
bool bCopyEFBScaled;
bool bSafeTextureCache;
int iSafeTextureCache_ColorSamples;
int iSafeTextureCache_IndexedSamples;
int iSafeTextureCache_TlutSamples;
int iSafeTextureCache_ColorMaxSize;
int iSafeTextureCache_IndexedMaxSize;
int iSafeTextureCache_TlutMaxSize;
bool bFIFOBPhack;
int iPhackvalue;

View File

@ -95,6 +95,26 @@ struct TabDirect3D : public W32Util::Tab
Button_SetCheck(GetDlgItem(hDlg, IDC_RENDER_TO_MAINWINDOW), g_Config.RenderToMainframe);
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)
{
Button_SetCheck(GetDlgItem(hDlg, IDC_SAFE_TEXTURE_CACHE_SAFE), true);
}
else
{
if(g_Config.iSafeTextureCache_ColorSamples > 36 && g_Config.iSafeTextureCache_TlutMaxSize > 4095)
{
Button_SetCheck(GetDlgItem(hDlg, IDC_SAFE_TEXTURE_CACHE_NORMAL), true);
}
else
{
Button_SetCheck(GetDlgItem(hDlg, IDC_SAFE_TEXTURE_CACHE_FAST), true);
}
}
Button_Enable(GetDlgItem(hDlg, IDC_SAFE_TEXTURE_CACHE_SAFE),g_Config.bSafeTextureCache);
Button_Enable(GetDlgItem(hDlg, IDC_SAFE_TEXTURE_CACHE_NORMAL),g_Config.bSafeTextureCache);
Button_Enable(GetDlgItem(hDlg, IDC_SAFE_TEXTURE_CACHE_FAST),g_Config.bSafeTextureCache);
Button_SetCheck(GetDlgItem(hDlg, IDC_EFB_ACCESS_ENABLE), g_Config.bEFBAccessEnable);
Button_GetCheck(GetDlgItem(hDlg,IDC_RENDER_TO_MAINWINDOW)) ? Button_Enable(GetDlgItem(hDlg,IDC_FULLSCREENENABLE), false) : Button_Enable(GetDlgItem(hDlg,IDC_FULLSCREENENABLE), true);
}
@ -111,6 +131,9 @@ struct TabDirect3D : public W32Util::Tab
break;
case IDC_SAFE_TEXTURE_CACHE:
g_Config.bSafeTextureCache = Button_GetCheck(GetDlgItem(hDlg, IDC_SAFE_TEXTURE_CACHE)) == 0 ? false : true;
Button_Enable(GetDlgItem(hDlg, IDC_SAFE_TEXTURE_CACHE_SAFE),g_Config.bSafeTextureCache);
Button_Enable(GetDlgItem(hDlg, IDC_SAFE_TEXTURE_CACHE_NORMAL),g_Config.bSafeTextureCache);
Button_Enable(GetDlgItem(hDlg, IDC_SAFE_TEXTURE_CACHE_FAST),g_Config.bSafeTextureCache);
break;
case IDC_EFB_ACCESS_ENABLE:
g_Config.bEFBAccessEnable = Button_GetCheck(GetDlgItem(hDlg, IDC_EFB_ACCESS_ENABLE)) == 0 ? false : true;
@ -135,6 +158,36 @@ struct TabDirect3D : public W32Util::Tab
g_Config.bFullscreen = Button_GetCheck(GetDlgItem(hDlg, IDC_FULLSCREENENABLE)) ? true : false;
g_Config.bVSync = Button_GetCheck(GetDlgItem(hDlg, IDC_VSYNC)) ? true : false;
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;
}
else
{
if(Button_GetCheck(GetDlgItem(hDlg, IDC_SAFE_TEXTURE_CACHE_NORMAL)))
{
if(g_Config.iSafeTextureCache_ColorSamples < 37)
{
g_Config.iSafeTextureCache_ColorSamples = 37;
}
if(g_Config.iSafeTextureCache_TlutMaxSize < 4096)
{
g_Config.iSafeTextureCache_TlutMaxSize = 4096;
}
}
else
{
if(g_Config.iSafeTextureCache_ColorSamples > 36 || 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.Save((std::string(File::GetUserPath(D_CONFIG_IDX)) + "gfx_dx9.ini").c_str());
}
};

View File

@ -167,12 +167,11 @@ TextureCache::TCacheEntry *TextureCache::Load(int stage, u32 address, int width,
// 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);
tempsize = (g_ActiveConfig.iSafeTextureCache_IndexedMaxSize != 0 && g_ActiveConfig.iSafeTextureCache_IndexedMaxSize < tempsize)?g_ActiveConfig.iSafeTextureCache_IndexedMaxSize : tempsize;
texHash = TexDecoder_GetHash64(ptr,tempsize,g_ActiveConfig.iSafeTextureCache_IndexedSamples);
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,g_ActiveConfig.iSafeTextureCache_TlutSamples);
u32 tlutHash = TexDecoder_GetHash32(&texMem[tlutaddr], tempsize,0);
texHash ^= tlutHash;
if (g_ActiveConfig.bSafeTextureCache)
{
@ -182,7 +181,6 @@ TextureCache::TCacheEntry *TextureCache::Load(int stage, u32 address, int width,
else
{
int tempsize = TexDecoder_GetTextureSizeInBytes(expandedWidth, expandedHeight, tex_format);
tempsize = (g_ActiveConfig.iSafeTextureCache_ColorMaxSize != 0 && g_ActiveConfig.iSafeTextureCache_ColorMaxSize < tempsize)?g_ActiveConfig.iSafeTextureCache_ColorMaxSize : tempsize;
texHash = TexDecoder_GetHash64(ptr, tempsize,g_ActiveConfig.iSafeTextureCache_ColorSamples);
}
if (g_ActiveConfig.bSafeTextureCache)

View File

@ -35,9 +35,13 @@
#define IDC_FORCEANISOTROPY 1027
#define IDC_LOADHIRESTEXTURE 1028
#define IDC_EFBSCALEDCOPY 1029
#define IDC_OSDHOTKEY 1030
#define IDC_OSDHOTKEY 1030
#define IDC_COMBO2 1040
#define IDC_ASPECTRATIO 1040
#define IDC_SAFE_TEXTURE_CACHE_SAFE 1041
#define IDC_SAFE_TEXTURE_CACHE_NORMAL 1042
#define IDC_RADIO3 1043
#define IDC_SAFE_TEXTURE_CACHE_FAST 1043
#define IDC_CHECK1 1100
#define IDC_STATIC -1
@ -47,7 +51,7 @@
#ifndef APSTUDIO_READONLY_SYMBOLS
#define _APS_NEXT_RESOURCE_VALUE 106
#define _APS_NEXT_COMMAND_VALUE 40001
#define _APS_NEXT_CONTROL_VALUE 1041
#define _APS_NEXT_CONTROL_VALUE 1044
#define _APS_NEXT_SYMED_VALUE 101
#endif
#endif

View File

@ -40,23 +40,27 @@ IDD_SETTINGS DIALOGEX 0, 0, 244, 183
STYLE DS_SETFONT | DS_FIXEDSYS | WS_CHILD | WS_BORDER | WS_SYSMENU
FONT 8, "MS Shell Dlg", 0, 0, 0x0
BEGIN
LTEXT "&Graphics card:",IDC_STATIC,7,9,61,8
COMBOBOX IDC_ADAPTER,68,7,169,48,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP
CONTROL "&Fullscreen",IDC_FULLSCREENENABLE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,68,25,56,8
CONTROL "&V-Sync",IDC_VSYNC,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,68,38,141,8
CONTROL "&Render to main window",IDC_RENDER_TO_MAINWINDOW,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,68,50,141,8
LTEXT "Full&screen resolution:",IDC_STATIC,7,86,69,8
COMBOBOX IDC_RESOLUTION,87,85,150,73,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP
LTEXT "&Windowed resolution:",IDC_STATIC,7,106,74,8
COMBOBOX IDC_RESOLUTIONWINDOWED,87,104,150,73,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP
LTEXT "&Anti-alias mode:",IDC_STATIC,7,127,56,8
COMBOBOX IDC_ANTIALIASMODE,68,125,169,73,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP
LTEXT "&Aspect Ratio:",IDC_STATIC,7,66,52,8
CONTROL "&Widescreen Hack",IDC_WIDESCREEN_HACK,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,170,66,67,10
CONTROL "&Safe Texture Cache",IDC_SAFE_TEXTURE_CACHE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,68,143,85,11
CONTROL "&Enable CPU->EFB access (can cause slowdowns, enables pull stars in SMG and lens flare in Zeldas)",IDC_EFB_ACCESS_ENABLE,
"Button",BS_AUTOCHECKBOX | BS_MULTILINE | WS_TABSTOP,68,153,169,23
COMBOBOX IDC_ASPECTRATIO,68,64,97,57,CBS_DROPDOWNLIST | CBS_SORT | WS_VSCROLL | WS_TABSTOP
LTEXT "&Graphics card:",IDC_STATIC,9,9,49,8
COMBOBOX IDC_ADAPTER,68,7,162,48,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP
CONTROL "&Fullscreen",IDC_FULLSCREENENABLE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,68,25,44,8
CONTROL "&V-Sync",IDC_VSYNC,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,114,25,36,8
CONTROL "&Render to main window",IDC_RENDER_TO_MAINWINDOW,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,150,25,87,8
LTEXT "&Windowed",IDC_STATIC,14,89,40,8
COMBOBOX IDC_RESOLUTIONWINDOWED,68,87,162,73,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP
LTEXT "&Anti-alias mode:",IDC_STATIC,9,113,51,8
COMBOBOX IDC_ANTIALIASMODE,68,111,162,73,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP
LTEXT "&Aspect Ratio:",IDC_STATIC,9,40,48,8
CONTROL "&Widescreen Hack",IDC_WIDESCREEN_HACK,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,161,40,67,10
CONTROL "&Safe Texture Cache",IDC_SAFE_TEXTURE_CACHE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,7,157,80,11
CONTROL "&Enable CPU->EFB access ",IDC_EFB_ACCESS_ENABLE,"Button",BS_AUTOCHECKBOX | BS_MULTILINE | WS_TABSTOP,7,136,94,11
COMBOBOX IDC_ASPECTRATIO,68,39,89,57,CBS_DROPDOWNLIST | CBS_SORT | WS_VSCROLL | WS_TABSTOP
GROUPBOX "Safe Texture Cache Mode",IDC_STATIC,109,147,125,27
GROUPBOX "Resolutions",IDC_STATIC,7,56,230,50
LTEXT "Full&screen:",IDC_STATIC,14,68,36,8
COMBOBOX IDC_RESOLUTION,68,67,162,73,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP
CONTROL "Safe",IDC_SAFE_TEXTURE_CACHE_SAFE,"Button",BS_AUTORADIOBUTTON,117,158,27,10
CONTROL "Normal",IDC_SAFE_TEXTURE_CACHE_NORMAL,"Button",BS_AUTORADIOBUTTON,154,158,38,10
CONTROL "Fast",IDC_SAFE_TEXTURE_CACHE_FAST,"Button",BS_AUTORADIOBUTTON,198,158,30,10
END
IDD_ADVANCED DIALOGEX 0, 0, 244, 200
@ -180,3 +184,16 @@ END
#endif // English (U.S.) resources
/////////////////////////////////////////////////////////////////////////////
#ifndef APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// Generated from the TEXTINCLUDE 3 resource.
//
/////////////////////////////////////////////////////////////////////////////
#endif // not APSTUDIO_INVOKED

View File

@ -275,12 +275,11 @@ TextureMngr::TCacheEntry* TextureMngr::Load(int texstage, u32 address, int width
// 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);
tempsize = (g_ActiveConfig.iSafeTextureCache_IndexedMaxSize != 0 && g_ActiveConfig.iSafeTextureCache_IndexedMaxSize < tempsize)?g_ActiveConfig.iSafeTextureCache_IndexedMaxSize : tempsize;
texHash = TexDecoder_GetHash64(ptr,tempsize,g_ActiveConfig.iSafeTextureCache_IndexedSamples);
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,g_ActiveConfig.iSafeTextureCache_TlutSamples);
u32 tlutHash = TexDecoder_GetHash32(&texMem[tlutaddr], tempsize,0);
texHash ^= tlutHash;
if (g_ActiveConfig.bSafeTextureCache)
{
@ -290,7 +289,6 @@ TextureMngr::TCacheEntry* TextureMngr::Load(int texstage, u32 address, int width
else
{
int tempsize = TexDecoder_GetTextureSizeInBytes(expandedWidth, expandedHeight, tex_format);
tempsize = (g_ActiveConfig.iSafeTextureCache_ColorMaxSize != 0 && g_ActiveConfig.iSafeTextureCache_ColorMaxSize < tempsize)?g_ActiveConfig.iSafeTextureCache_ColorMaxSize : tempsize;
texHash = TexDecoder_GetHash64(ptr, tempsize,g_ActiveConfig.iSafeTextureCache_ColorSamples);
}
if (g_ActiveConfig.bSafeTextureCache)