Added an option for "Safe texture cache". Prevents Metroid Prime 1 from caching but can cause texture glitches.

git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@1291 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
hrydgard 2008-11-24 20:04:51 +00:00
parent b9c6f7cb89
commit 06aeab0414
5 changed files with 27 additions and 6 deletions

View File

@ -49,13 +49,14 @@ void Config::Load()
iniFile.Get("Settings", "KeepAR", &bKeepAR, false); iniFile.Get("Settings", "KeepAR", &bKeepAR, false);
iniFile.Get("Settings", "HideCursor", &bHideCursor, false); iniFile.Get("Settings", "HideCursor", &bHideCursor, false);
iniFile.Get("Settings", "SafeTextureCache", &bSafeTextureCache, false); // Settings
iniFile.Get("Settings", "ShowFPS", &bShowFPS, false); // Settings iniFile.Get("Settings", "ShowFPS", &bShowFPS, false); // Settings
iniFile.Get("Settings", "OverlayStats", &bOverlayStats, false); iniFile.Get("Settings", "OverlayStats", &bOverlayStats, false);
iniFile.Get("Settings", "DLOptimize", &iCompileDLsLevel, 0); iniFile.Get("Settings", "DLOptimize", &iCompileDLsLevel, 0);
iniFile.Get("Settings", "DumpTextures", &bDumpTextures, 0); iniFile.Get("Settings", "DumpTextures", &bDumpTextures, 0);
iniFile.Get("Settings", "ShowShaderErrors", &bShowShaderErrors, 0); iniFile.Get("Settings", "ShowShaderErrors", &bShowShaderErrors, 0);
iniFile.Get("Settings", "Multisample", &iMultisampleMode, 0); iniFile.Get("Settings", "Multisample", &iMultisampleMode, 0);
if(iMultisampleMode == 0) if (iMultisampleMode == 0)
iMultisampleMode = 1; iMultisampleMode = 1;
std::string s; std::string s;
iniFile.Get("Settings", "TexDumpPath", &s, 0); iniFile.Get("Settings", "TexDumpPath", &s, 0);
@ -95,6 +96,7 @@ void Config::Save()
iniFile.Set("Settings", "KeepAR", bKeepAR); iniFile.Set("Settings", "KeepAR", bKeepAR);
iniFile.Set("Settings", "HideCursor", bHideCursor); iniFile.Set("Settings", "HideCursor", bHideCursor);
iniFile.Set("Settings", "SafeTextureCache", bSafeTextureCache);
iniFile.Set("Settings", "ShowFPS", bShowFPS); iniFile.Set("Settings", "ShowFPS", bShowFPS);
iniFile.Set("Settings", "OverlayStats", bOverlayStats); iniFile.Set("Settings", "OverlayStats", bOverlayStats);
iniFile.Set("Settings", "DLOptimize", iCompileDLsLevel); iniFile.Set("Settings", "DLOptimize", iCompileDLsLevel);

View File

@ -39,6 +39,7 @@ struct Config
bool bStretchToFit; bool bStretchToFit;
bool bKeepAR; bool bKeepAR;
bool bHideCursor; bool bHideCursor;
bool bSafeTextureCache;
// Enhancements // Enhancements
int iMultisampleMode; int iMultisampleMode;

View File

@ -50,6 +50,7 @@ BEGIN_EVENT_TABLE(ConfigDialog,wxDialog)
EVT_CHECKBOX(ID_EFBTOTEXTUREDISABLEHOTKEY, ConfigDialog::AdvancedSettingsChanged) EVT_CHECKBOX(ID_EFBTOTEXTUREDISABLEHOTKEY, ConfigDialog::AdvancedSettingsChanged)
EVT_CHECKBOX(ID_PROJECTIONHACK1,ConfigDialog::AdvancedSettingsChanged) EVT_CHECKBOX(ID_PROJECTIONHACK1,ConfigDialog::AdvancedSettingsChanged)
EVT_CHECKBOX(ID_PROJECTIONHACK2,ConfigDialog::AdvancedSettingsChanged) EVT_CHECKBOX(ID_PROJECTIONHACK2,ConfigDialog::AdvancedSettingsChanged)
EVT_CHECKBOX(ID_SAFETEXTURECACHE,ConfigDialog::AdvancedSettingsChanged)
EVT_DIRPICKER_CHANGED(ID_TEXTUREPATH, ConfigDialog::TexturePathChange) EVT_DIRPICKER_CHANGED(ID_TEXTUREPATH, ConfigDialog::TexturePathChange)
END_EVENT_TABLE() END_EVENT_TABLE()
@ -209,6 +210,11 @@ void ConfigDialog::CreateGUIControls()
#endif #endif
m_EFBToTextureDisableHotKey->SetValue(g_Config.bEBFToTextureDisableHotKey); m_EFBToTextureDisableHotKey->SetValue(g_Config.bEBFToTextureDisableHotKey);
m_SafeTextureCache = new wxCheckBox(m_PageAdvanced, ID_SAFETEXTURECACHE, wxT("Safe texture cache"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator);
m_SafeTextureCache->SetToolTip(wxT("This is useful to prevent Metroid Prime from crashing, but can cause problems in other games."));
m_SafeTextureCache->Enable(true);
m_SafeTextureCache->SetValue(g_Config.bSafeTextureCache);
m_ProjectionHax1 = new wxCheckBox(m_PageAdvanced, ID_PROJECTIONHACK1, wxT("Projection before R945"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator); m_ProjectionHax1 = new wxCheckBox(m_PageAdvanced, ID_PROJECTIONHACK1, wxT("Projection before R945"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator);
m_ProjectionHax1->SetToolTip(wxT("This may reveal otherwise invisible graphics" m_ProjectionHax1->SetToolTip(wxT("This may reveal otherwise invisible graphics"
" in\ngames like Mario Galaxy or Ikaruga.")); " in\ngames like Mario Galaxy or Ikaruga."));
@ -248,6 +254,7 @@ void ConfigDialog::CreateGUIControls()
sHacks->Add(m_EFBToTextureDisableHotKey, wxGBPosition(0, 1), wxGBSpan(1, 1), wxALL, 5); sHacks->Add(m_EFBToTextureDisableHotKey, wxGBPosition(0, 1), wxGBSpan(1, 1), wxALL, 5);
sHacks->Add(m_ProjectionHax1, wxGBPosition(1, 0), wxGBSpan(1, 1), wxALL, 5); sHacks->Add(m_ProjectionHax1, wxGBPosition(1, 0), wxGBSpan(1, 1), wxALL, 5);
sHacks->Add(m_ProjectionHax2, wxGBPosition(2, 0), wxGBSpan(1, 2), wxALL, 5); sHacks->Add(m_ProjectionHax2, wxGBPosition(2, 0), wxGBSpan(1, 2), wxALL, 5);
sHacks->Add(m_SafeTextureCache, wxGBPosition(3, 0), wxGBSpan(1, 1), wxALL, 5);
sbHacks->Add(sHacks); sbHacks->Add(sHacks);
sAdvanced->Add(sbHacks, 0, wxEXPAND|wxALL, 5); sAdvanced->Add(sbHacks, 0, wxEXPAND|wxALL, 5);
m_PageAdvanced->SetSizer(sAdvanced); m_PageAdvanced->SetSizer(sAdvanced);
@ -384,6 +391,9 @@ void ConfigDialog::AdvancedSettingsChanged(wxCommandEvent& event)
case ID_PROJECTIONHACK2: case ID_PROJECTIONHACK2:
g_Config.bProjectionHax2 = m_ProjectionHax2->IsChecked(); g_Config.bProjectionHax2 = m_ProjectionHax2->IsChecked();
break; break;
case ID_SAFETEXTURECACHE:
g_Config.bSafeTextureCache = m_SafeTextureCache->IsChecked();
break;
default: default:
break; break;
} }

View File

@ -96,6 +96,7 @@ class ConfigDialog : public wxDialog
wxCheckBox *m_EFBToTextureDisable, *m_EFBToTextureDisableHotKey; wxCheckBox *m_EFBToTextureDisable, *m_EFBToTextureDisableHotKey;
wxCheckBox *m_ProjectionHax1; wxCheckBox *m_ProjectionHax1;
wxCheckBox *m_ProjectionHax2; wxCheckBox *m_ProjectionHax2;
wxCheckBox *m_SafeTextureCache;
enum enum
{ {
@ -131,6 +132,7 @@ class ConfigDialog : public wxDialog
ID_WIREFRAME, ID_WIREFRAME,
ID_DISABLELIGHTING, ID_DISABLELIGHTING,
ID_DISABLETEXTURING, ID_DISABLETEXTURING,
ID_SAFETEXTURECACHE,
ID_DUMPTEXTURES, ID_DUMPTEXTURES,
ID_TEXTUREPATH, ID_TEXTUREPATH,

View File

@ -108,9 +108,11 @@ void TextureMngr::TCacheEntry::Destroy()
{ {
glDeleteTextures(1, &texture); glDeleteTextures(1, &texture);
if (!isRenderTarget) { if (!isRenderTarget) {
u32 *ptr = (u32*)g_VideoInitialize.pGetMemoryPointer(addr + hashoffset*4); if (!g_Config.bSafeTextureCache) {
if (*ptr == hash) u32 *ptr = (u32*)g_VideoInitialize.pGetMemoryPointer(addr + hashoffset * 4);
*ptr = oldpixel; if (*ptr == hash)
*ptr = oldpixel;
}
} }
texture = 0; texture = 0;
} }
@ -255,10 +257,14 @@ TextureMngr::TCacheEntry* TextureMngr::Load(int texstage, u32 address, int width
TCacheEntry& entry = textures[address]; TCacheEntry& entry = textures[address];
entry.hashoffset = 0; entry.hashoffset = 0;
entry.hash = (u32)(((double)rand() / RAND_MAX) * 0xFFFFFFFF);
entry.paletteHash = palhash; entry.paletteHash = palhash;
entry.oldpixel = ((u32 *)ptr)[entry.hashoffset]; entry.oldpixel = ((u32 *)ptr)[entry.hashoffset];
((u32 *)ptr)[entry.hashoffset] = entry.hash; if (g_Config.bSafeTextureCache) {
entry.hash = entry.oldpixel;
} else {
entry.hash = (u32)(((double)rand() / RAND_MAX) * 0xFFFFFFFF);
((u32 *)ptr)[entry.hashoffset] = entry.hash;
}
entry.addr = address; entry.addr = address;
entry.isRenderTarget = false; entry.isRenderTarget = false;