Instead of invalidating texcache whenever the graphics configuration dialog gets opened, clean up textures on configuration changes.
This commit is contained in:
parent
30de244050
commit
8d30ac462a
|
@ -66,8 +66,6 @@ void VideoConfigDiag::Event_Close(wxCloseEvent& ev)
|
|||
g_Config.Save((File::GetUserPath(D_CONFIG_IDX) + ininame + ".ini").c_str());
|
||||
|
||||
EndModal(wxID_OK);
|
||||
|
||||
TextureCache::InvalidateDefer(); // For settings like hi-res textures/texture format/etc.
|
||||
}
|
||||
|
||||
wxString backend_desc = wxTRANSLATE("Selects what graphics API to use internally.\nDirect3D 9 usually is the fastest one. OpenGL is more accurate though. Direct3D 11 is somewhere between the two.\nNote that the Direct3D backends are only available on Windows.\n\nIf unsure, use Direct3D 9.");
|
||||
|
|
|
@ -82,9 +82,11 @@ bool Renderer::s_EnableDLCachingAfterRecording;
|
|||
|
||||
unsigned int Renderer::prev_efb_format = (unsigned int)-1;
|
||||
|
||||
|
||||
Renderer::Renderer() : frame_data(NULL), bLastFrameDumped(false)
|
||||
{
|
||||
UpdateActiveConfig();
|
||||
TextureCache::OnConfigChanged(g_ActiveConfig);
|
||||
|
||||
#if defined _WIN32 || defined HAVE_LIBAV
|
||||
bAVIDumping = false;
|
||||
|
@ -130,11 +132,6 @@ void Renderer::RenderToXFB(u32 xfbAddr, u32 fbWidth, u32 fbHeight, const EFBRect
|
|||
g_renderer->Swap(xfbAddr, FIELD_PROGRESSIVE, fbWidth, fbHeight,sourceRc,Gamma);
|
||||
Common::AtomicStoreRelease(s_swapRequested, false);
|
||||
}
|
||||
|
||||
if (TextureCache::DeferredInvalidate)
|
||||
{
|
||||
TextureCache::Invalidate(false);
|
||||
}
|
||||
}
|
||||
|
||||
void Renderer::CalculateTargetScale(int x, int y, int &scaledX, int &scaledY)
|
||||
|
|
|
@ -42,7 +42,9 @@ GC_ALIGNED16(u8 *TextureCache::temp) = NULL;
|
|||
unsigned int TextureCache::temp_size;
|
||||
|
||||
TextureCache::TexCache TextureCache::textures;
|
||||
bool TextureCache::DeferredInvalidate;
|
||||
|
||||
TextureCache::BackupConfig TextureCache::backup_config;
|
||||
|
||||
|
||||
TextureCache::TCacheEntryBase::~TCacheEntryBase()
|
||||
{
|
||||
|
@ -59,6 +61,7 @@ TextureCache::TextureCache()
|
|||
SetHash64Function(g_ActiveConfig.bHiresTextures || g_ActiveConfig.bDumpTextures);
|
||||
}
|
||||
|
||||
// TODO: Kill shutdown parameter...
|
||||
void TextureCache::Invalidate(bool shutdown)
|
||||
{
|
||||
TexCache::iterator
|
||||
|
@ -75,13 +78,6 @@ void TextureCache::Invalidate(bool shutdown)
|
|||
if(g_ActiveConfig.bHiresTextures && !g_ActiveConfig.bDumpTextures)
|
||||
HiresTextures::Init(SConfig::GetInstance().m_LocalCoreStartupParameter.m_strUniqueID.c_str());
|
||||
SetHash64Function(g_ActiveConfig.bHiresTextures || g_ActiveConfig.bDumpTextures);
|
||||
|
||||
DeferredInvalidate = false;
|
||||
}
|
||||
|
||||
void TextureCache::InvalidateDefer()
|
||||
{
|
||||
DeferredInvalidate = true;
|
||||
}
|
||||
|
||||
TextureCache::~TextureCache()
|
||||
|
@ -94,6 +90,40 @@ TextureCache::~TextureCache()
|
|||
}
|
||||
}
|
||||
|
||||
void TextureCache::OnConfigChanged(VideoConfig& config)
|
||||
{
|
||||
if (!g_texture_cache)
|
||||
goto skip_checks;
|
||||
|
||||
// TODO: Invalidating texcache is really stupid in some of these cases
|
||||
if (config.iSafeTextureCache_ColorSamples != backup_config.s_colorsamples ||
|
||||
config.bTexFmtOverlayEnable != backup_config.s_texfmt_overlay ||
|
||||
config.bTexFmtOverlayCenter != backup_config.s_texfmt_overlay_center ||
|
||||
config.bHiresTextures != backup_config.s_hires_textures)
|
||||
g_texture_cache->Invalidate(false);
|
||||
|
||||
// TODO: Probably shouldn't clear all render targets here, just mark them dirty or something.
|
||||
if (config.bEFBCopyCacheEnable != backup_config.s_copy_cache_enable || // TODO: not sure if this is needed?
|
||||
config.bCopyEFBToTexture != backup_config.s_copy_efb_to_texture ||
|
||||
config.bCopyEFBScaled != backup_config.s_copy_efb_scaled ||
|
||||
config.bEFBCopyEnable != backup_config.s_copy_efb ||
|
||||
config.iEFBScale != backup_config.s_efb_scale)
|
||||
{
|
||||
g_texture_cache->ClearRenderTargets();
|
||||
}
|
||||
|
||||
skip_checks:
|
||||
backup_config.s_colorsamples = config.iSafeTextureCache_ColorSamples;
|
||||
backup_config.s_copy_efb_to_texture = config.bCopyEFBToTexture;
|
||||
backup_config.s_copy_efb_scaled = config.bCopyEFBScaled;
|
||||
backup_config.s_copy_efb = config.bEFBCopyEnable;
|
||||
backup_config.s_efb_scale = config.iEFBScale;
|
||||
backup_config.s_texfmt_overlay = config.bTexFmtOverlayEnable;
|
||||
backup_config.s_texfmt_overlay_center = config.bTexFmtOverlayCenter;
|
||||
backup_config.s_hires_textures = config.bHiresTextures;
|
||||
backup_config.s_copy_cache_enable = config.bEFBCopyCacheEnable;
|
||||
}
|
||||
|
||||
void TextureCache::Cleanup()
|
||||
{
|
||||
TexCache::iterator iter = textures.begin();
|
||||
|
|
|
@ -27,6 +27,8 @@
|
|||
|
||||
#include "CommonTypes.h"
|
||||
|
||||
struct VideoConfig;
|
||||
|
||||
class TextureCache
|
||||
{
|
||||
public:
|
||||
|
@ -100,10 +102,10 @@ public:
|
|||
|
||||
virtual ~TextureCache(); // needs virtual for DX11 dtor
|
||||
|
||||
static void OnConfigChanged(VideoConfig& config);
|
||||
static void Cleanup();
|
||||
|
||||
static void Invalidate(bool shutdown);
|
||||
static void InvalidateDefer();
|
||||
static void InvalidateRange(u32 start_address, u32 size);
|
||||
static void MakeRangeDynamic(u32 start_address, u32 size);
|
||||
static void ClearRenderTargets(); // currently only used by OGL
|
||||
|
@ -118,8 +120,6 @@ public:
|
|||
static void CopyRenderTargetToTexture(u32 dstAddr, unsigned int dstFormat, unsigned int srcFormat,
|
||||
const EFBRectangle& srcRect, bool isIntensity, bool scaleByHalf);
|
||||
|
||||
static bool DeferredInvalidate;
|
||||
|
||||
protected:
|
||||
TextureCache();
|
||||
|
||||
|
@ -135,6 +135,19 @@ private:
|
|||
typedef std::map<u32, TCacheEntryBase*> TexCache;
|
||||
|
||||
static TexCache textures;
|
||||
|
||||
// Backup configuration values
|
||||
static struct BackupConfig {
|
||||
int s_colorsamples;
|
||||
bool s_copy_efb_to_texture;
|
||||
bool s_copy_efb_scaled;
|
||||
bool s_copy_efb;
|
||||
int s_efb_scale;
|
||||
bool s_texfmt_overlay;
|
||||
bool s_texfmt_overlay_center;
|
||||
bool s_hires_textures;
|
||||
bool s_copy_cache_enable;
|
||||
} backup_config;
|
||||
};
|
||||
|
||||
extern TextureCache *g_texture_cache;
|
||||
|
|
|
@ -135,7 +135,7 @@ struct VideoConfig
|
|||
bool bEnablePerPixelDepth;
|
||||
|
||||
int iLog; // CONF_ bits
|
||||
int iSaveTargetId;
|
||||
int iSaveTargetId; // TODO: Should be dropped
|
||||
|
||||
//currently unused:
|
||||
int iCompileDLsLevel;
|
||||
|
|
|
@ -1111,6 +1111,7 @@ void Renderer::Swap(u32 xfbAddr, FieldType field, u32 fbWidth, u32 fbHeight,cons
|
|||
|
||||
// Enable configuration changes
|
||||
UpdateActiveConfig();
|
||||
TextureCache::OnConfigChanged(g_ActiveConfig);
|
||||
|
||||
SetWindowSize(fbWidth, fbHeight);
|
||||
|
||||
|
|
|
@ -1117,6 +1117,7 @@ void Renderer::Swap(u32 xfbAddr, FieldType field, u32 fbWidth, u32 fbHeight,cons
|
|||
|
||||
// Enable configuration changes
|
||||
UpdateActiveConfig();
|
||||
TextureCache::OnConfigChanged(g_ActiveConfig);
|
||||
|
||||
SetWindowSize(fbWidth, fbHeight);
|
||||
|
||||
|
|
|
@ -1437,11 +1437,8 @@ void Renderer::Swap(u32 xfbAddr, FieldType field, u32 fbWidth, u32 fbHeight,cons
|
|||
GL_REPORT_ERRORD();
|
||||
g_Config.iSaveTargetId = 0;
|
||||
|
||||
// reload textures if these settings changed
|
||||
if (g_Config.bCopyEFBToTexture != g_ActiveConfig.bCopyEFBToTexture)
|
||||
TextureCache::ClearRenderTargets();
|
||||
|
||||
UpdateActiveConfig();
|
||||
TextureCache::OnConfigChanged(g_ActiveConfig);
|
||||
|
||||
// For testing zbuffer targets.
|
||||
// Renderer::SetZBufferRender();
|
||||
|
|
Loading…
Reference in New Issue