Add an option to toggle caching EFB->RAM copies.

skid_au had implemented this in a previous revision and enabled it by default, but it caused glitches if STC wasn't set to "safe" (which kinda defeated the purpose since it slowed down stuff again).

Also renamed the "safe texture cache" to "accurate texture cache", since setting the "safe" texture cache to "safe" sounds kind of silly..

git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@6625 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
NeoBrainX 2010-12-20 14:48:46 +00:00
parent bb8918a2ca
commit 60ed57b32a
6 changed files with 45 additions and 22 deletions

View File

@ -338,7 +338,7 @@ void CISOProperties::CreateGUIControls(bool IsWad)
ForceFiltering = new wxCheckBox(m_GameConfig, ID_FORCEFILTERING, _("Force Filtering"), wxDefaultPosition, wxDefaultSize, wxCHK_3STATE|wxCHK_ALLOW_3RD_STATE_FOR_USER, wxDefaultValidator);
EFBCopyEnable = new wxCheckBox(m_GameConfig, ID_EFBCOPYENABLE, _("Enable Copy to EFB"), wxDefaultPosition, wxDefaultSize, wxCHK_3STATE|wxCHK_ALLOW_3RD_STATE_FOR_USER, wxDefaultValidator);
EFBToTextureEnable = new wxCheckBox(m_GameConfig, ID_EFBTOTEXTUREENABLE, _("Enable EFB To Texture"), wxDefaultPosition, wxDefaultSize, wxCHK_3STATE|wxCHK_ALLOW_3RD_STATE_FOR_USER, wxDefaultValidator);
SafeTextureCache = new wxCheckBox(m_GameConfig, ID_SAFETEXTURECACHE, _("Safe Texture Cache"), wxDefaultPosition, wxDefaultSize, wxCHK_3STATE|wxCHK_ALLOW_3RD_STATE_FOR_USER, wxDefaultValidator);
SafeTextureCache = new wxCheckBox(m_GameConfig, ID_SAFETEXTURECACHE, _("Accurate Texture Cache"), wxDefaultPosition, wxDefaultSize, wxCHK_3STATE|wxCHK_ALLOW_3RD_STATE_FOR_USER, wxDefaultValidator);
DstAlphaPass = new wxCheckBox(m_GameConfig, ID_DSTALPHAPASS, _("Distance Alpha Pass"), wxDefaultPosition, wxDefaultSize, wxCHK_3STATE|wxCHK_ALLOW_3RD_STATE_FOR_USER, wxDefaultValidator);
UseXFB = new wxCheckBox(m_GameConfig, ID_USEXFB, _("Use XFB"), wxDefaultPosition, wxDefaultSize, wxCHK_3STATE|wxCHK_ALLOW_3RD_STATE_FOR_USER, wxDefaultValidator);
UseZTPSpeedupHack = new wxCheckBox(m_GameConfig, ID_ZTP_SPEEDUP, _("ZTP hack"), wxDefaultPosition, wxDefaultSize, wxCHK_3STATE|wxCHK_ALLOW_3RD_STATE_FOR_USER, wxDefaultValidator);

View File

@ -64,8 +64,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,512);
iniFile.Get("Settings", "SafeTextureCacheColorSamples", &iSafeTextureCache_ColorSamples,512);
iniFile.Get("Settings", "ShowFPS", &bShowFPS, false); // Settings
iniFile.Get("Settings", "OverlayStats", &bOverlayStats, false);
iniFile.Get("Settings", "OverlayProjStats", &bOverlayProjStats, false);
@ -108,6 +108,7 @@ void VideoConfig::Load(const char *ini_file)
iniFile.Get("Hacks", "EFBCopyDisableHotKey", &bOSDHotKey, 0);
iniFile.Get("Hacks", "EFBToTextureEnable", &bCopyEFBToTexture, false);
iniFile.Get("Hacks", "EFBScaledCopy", &bCopyEFBScaled, true);
iniFile.Get("Hacks", "EFBCopyCacheEnable", &bEFBCopyCacheEnable, false);
iniFile.Get("Hacks", "ProjectionHack", &iPhackvalue, 0);
iniFile.Get("Hardware", "Adapter", &iAdapter, 0);
@ -222,8 +223,9 @@ void VideoConfig::Save(const char *ini_file)
iniFile.Set("Hacks", "EFBCopyDisableHotKey", bOSDHotKey);
iniFile.Set("Hacks", "EFBToTextureEnable", bCopyEFBToTexture);
iniFile.Set("Hacks", "EFBScaledCopy", bCopyEFBScaled);
iniFile.Set("Hacks", "EFBCopyCacheEnable", bEFBCopyCacheEnable);
iniFile.Set("Hacks", "ProjectionHack", iPhackvalue);
iniFile.Set("Hardware", "Adapter", iAdapter);
iniFile.Save(ini_file);

View File

@ -118,6 +118,7 @@ struct VideoConfig
bool bEFBAccessEnable;
bool bDlistCachingEnable;
bool bEFBCopyEnable;
bool bEFBCopyCacheEnable;
bool bOSDHotKey;
bool bHack;
bool bCopyEFBToTexture;

View File

@ -101,6 +101,7 @@ wxString opencl_tooltip = wxT("");
wxString dlc_tooltip = wxT("");
wxString hotkeys_tooltip = wxT("");
wxString ppshader_tooltip = wxT("");
wxString cache_efb_copies_tooltip = wxT("When using EFB to RAM we very often need to decode RAM data to a VRAM texture, which is a very time-consuming task.\nWith this option enabled, we'll skip decoding a texture if it didn't change.\nThis results in a nice speedup, but possibly causes glitches.\nIf you have any problems with this option enabled you should either try increasing the safety of the texture cache or disable this option.\n(NOTE: The safier the texture cache is adjusted the lower the speedup will be; accurate texture cache set to \"safe\" might actually be slower!)");
VideoConfigDiag::VideoConfigDiag(wxWindow* parent, const std::string &title, const std::string& _ininame)
: wxDialog(parent, -1,
@ -249,14 +250,17 @@ VideoConfigDiag::VideoConfigDiag(wxWindow* parent, const std::string &title, con
SettingCheckBox* efbcopy_enable = new SettingCheckBox(page_general, wxT("Enable"), efb_copy_tooltip, vconfig.bEFBCopyEnable);
_connect_macro_(efbcopy_enable, VideoConfigDiag::Event_EfbCopy, wxEVT_COMMAND_CHECKBOX_CLICKED, this);
efbcopy_texture = new SettingRadioButton(page_general, wxT("Texture"), efb_copy_tooltip, vconfig.bCopyEFBToTexture, false, wxRB_GROUP);
efbcopy_texture->SetToolTip(efb_copy_texture_tooltip);
efbcopy_ram = new SettingRadioButton(page_general, wxT("RAM"), efb_copy_tooltip, vconfig.bCopyEFBToTexture, true);
efbcopy_ram->SetToolTip(efb_copy_ram_tooltip);
efbcopy_texture = new SettingRadioButton(page_general, wxT("Texture"), efb_copy_texture_tooltip, vconfig.bCopyEFBToTexture, false, wxRB_GROUP);
_connect_macro_(efbcopy_texture, VideoConfigDiag::Event_EfbCopyToTexture, wxEVT_COMMAND_RADIOBUTTON_SELECTED, this);
efbcopy_ram = new SettingRadioButton(page_general, wxT("RAM"), efb_copy_ram_tooltip, vconfig.bCopyEFBToTexture, true);
_connect_macro_(efbcopy_ram, VideoConfigDiag::Event_EfbCopyToRam, wxEVT_COMMAND_RADIOBUTTON_SELECTED, this);
cache_efb_copies = new SettingCheckBox(page_general, wxT("Enable cache"), cache_efb_copies_tooltip, vconfig.bEFBCopyCacheEnable);
group_efbcopy->Add(efbcopy_enable, 0, wxLEFT | wxRIGHT | wxBOTTOM, 5);
group_efbcopy->AddStretchSpacer(1);
group_efbcopy->Add(efbcopy_texture, 0, wxRIGHT, 5);
group_efbcopy->Add(efbcopy_ram, 0, wxRIGHT, 5);
group_efbcopy->Add(cache_efb_copies, 0, wxRIGHT, 5);
if (!vconfig.backend_info.bSupportsEFBToRAM)
{
efbcopy_ram->Disable();
@ -267,12 +271,16 @@ VideoConfigDiag::VideoConfigDiag(wxWindow* parent, const std::string &title, con
{
efbcopy_ram->Disable();
efbcopy_texture->Disable();
cache_efb_copies->Disable();
}
else if (vconfig.bCopyEFBToTexture)
cache_efb_copies->Disable();
}
// - safe texture cache
{
wxStaticBoxSizer* const group_safetex = new wxStaticBoxSizer(wxHORIZONTAL, page_general, wxT("Safe Texture Cache"));
wxStaticBoxSizer* const group_safetex = new wxStaticBoxSizer(wxHORIZONTAL, page_general, wxT("Accurate texture cache"));
szr_general->Add(group_safetex, 0, wxEXPAND | wxLEFT | wxRIGHT | wxBOTTOM, 5);
SettingCheckBox* stc_enable = new SettingCheckBox(page_general, wxT("Enable"), stc_tooltip, vconfig.bSafeTextureCache);
@ -285,20 +293,23 @@ VideoConfigDiag::VideoConfigDiag(wxWindow* parent, const std::string &title, con
stc_safe->SetToolTip(stc_speed_tooltip);
_connect_macro_(stc_safe, VideoConfigDiag::Event_StcSafe, wxEVT_COMMAND_RADIOBUTTON_SELECTED, this);
group_safetex->Add(stc_safe, 0, wxRIGHT, 5);
if (0 == vconfig.iSafeTextureCache_ColorSamples)
stc_safe->SetValue(true);
stc_normal = new wxRadioButton(page_general, -1, wxT("Normal"));
stc_normal->SetToolTip(stc_speed_tooltip);
_connect_macro_(stc_normal, VideoConfigDiag::Event_StcNormal, wxEVT_COMMAND_RADIOBUTTON_SELECTED, this);
group_safetex->Add(stc_normal, 0, wxRIGHT, 5);
if (512 == vconfig.iSafeTextureCache_ColorSamples)
stc_normal->SetValue(true);
stc_fast = new wxRadioButton(page_general, -1, wxT("Fast"));
stc_fast->SetToolTip(stc_speed_tooltip);
_connect_macro_(stc_fast, VideoConfigDiag::Event_StcFast, wxEVT_COMMAND_RADIOBUTTON_SELECTED, this);
group_safetex->Add(stc_fast, 0, wxRIGHT, 5);
if (0 == vconfig.iSafeTextureCache_ColorSamples)
stc_safe->SetValue(true);
if (512 == vconfig.iSafeTextureCache_ColorSamples)
stc_normal->SetValue(true);
if (128 == vconfig.iSafeTextureCache_ColorSamples)
stc_fast->SetValue(true);
@ -308,6 +319,7 @@ VideoConfigDiag::VideoConfigDiag(wxWindow* parent, const std::string &title, con
stc_normal->Disable();
stc_fast->Disable();
}
}
}
@ -445,4 +457,4 @@ VideoConfigDiag::VideoConfigDiag(wxWindow* parent, const std::string &title, con
SetSizerAndFit(szr_main);
Center();
}
}

View File

@ -442,11 +442,15 @@ u64 EncodeToRamFromTexture(u32 address,LPDIRECT3DTEXTURE9 source_texture, u32 So
int readStride = (expandedWidth * cacheBytes) / TexDecoder_GetBlockWidthInTexels(format);
EncodeToRamUsingShader(texconv_shader, source_texture, scaledSource, dest_ptr, expandedWidth / samples, expandedHeight, readStride, true, bScaleByHalf > 0);
u64 hash = GetHash64(dest_ptr,size_in_bytes,g_ActiveConfig.iSafeTextureCache_ColorSamples);
u64 hash = 0;
if (g_ActiveConfig.bEFBCopyCacheEnable)
{
hash = GetHash64(dest_ptr,size_in_bytes,g_ActiveConfig.iSafeTextureCache_ColorSamples);
// If the texture in RAM is already in the texture cache, do not copy it again as it has not changed.
if (TextureCache::Find(address, hash))
return hash;
// If the texture in RAM is already in the texture cache, do not copy it again as it has not changed.
if (TextureCache::Find(address, hash))
return hash;
}
TextureCache::MakeRangeDynamic(address,size_in_bytes);
return hash;

View File

@ -369,11 +369,15 @@ u64 EncodeToRamFromTexture(u32 address,GLuint source_texture, bool bFromZBuffer,
int readStride = (expandedWidth * cacheBytes) / TexDecoder_GetBlockWidthInTexels(format);
EncodeToRamUsingShader(texconv_shader, source_texture, scaledSource, dest_ptr, expandedWidth / samples, expandedHeight, readStride, true, bScaleByHalf > 0 && !bFromZBuffer);
u64 hash = GetHash64(dest_ptr,size_in_bytes,g_ActiveConfig.iSafeTextureCache_ColorSamples);
u64 hash = 0;
if (g_ActiveConfig.bEFBCopyCacheEnable)
{
u64 hash = GetHash64(dest_ptr,size_in_bytes,g_ActiveConfig.iSafeTextureCache_ColorSamples);
// If the texture in RAM is already in the texture cache, do not copy it again as it has not changed.
if (TextureCache::Find(address, hash))
return hash;
// If the texture in RAM is already in the texture cache, do not copy it again as it has not changed.
if (TextureCache::Find(address, hash))
return hash;
}
TextureCache::MakeRangeDynamic(address,size_in_bytes);
return hash;