GS: Fine gained change detection for mips/trifilter/anisotropy

This commit is contained in:
Connor McLaughlin 2022-01-01 20:20:16 +10:00 committed by refractionpcsx2
parent 0872d024f9
commit ec0543335e
7 changed files with 36 additions and 9 deletions

View File

@ -731,7 +731,6 @@ void GSUpdateConfig(const Pcsx2Config::GSOptions& new_config)
// Options which aren't using the global struct yet, so we need to recreate all GS objects.
if (
GSConfig.GPUPaletteConversion != old_config.GPUPaletteConversion ||
GSConfig.ConservativeFramebuffer != old_config.ConservativeFramebuffer ||
GSConfig.AutoFlushSW != old_config.AutoFlushSW ||
GSConfig.PreloadFrameWithGSData != old_config.PreloadFrameWithGSData ||
@ -754,9 +753,7 @@ void GSUpdateConfig(const Pcsx2Config::GSOptions& new_config)
GSConfig.SaveDepth != old_config.SaveDepth ||
GSConfig.UpscaleMultiplier != old_config.UpscaleMultiplier ||
GSConfig.HWMipmap != old_config.HWMipmap ||
GSConfig.CRCHack != old_config.CRCHack ||
GSConfig.MaxAnisotropy != old_config.MaxAnisotropy ||
GSConfig.SWExtraThreads != old_config.SWExtraThreads ||
GSConfig.SWExtraThreadsHeight != old_config.SWExtraThreadsHeight ||
@ -781,6 +778,25 @@ void GSUpdateConfig(const Pcsx2Config::GSOptions& new_config)
// This is where we would do finer-grained checks in the future.
// For example, flushing the texture cache when mipmap settings change.
if (GSConfig.HWMipmap != old_config.HWMipmap || GSConfig.CRCHack != old_config.CRCHack)
{
// for automatic mipmaps, we need to reload the crc
s_gs->SetGameCRC(s_gs->GetGameCRC(), s_gs->GetGameCRCOptions());
}
// reload texture cache when trilinear filtering or mipmap options change
if (GSConfig.HWMipmap != old_config.HWMipmap ||
GSConfig.UserHacks_TriFilter != old_config.UserHacks_TriFilter ||
GSConfig.GPUPaletteConversion != old_config.GPUPaletteConversion)
{
s_gs->PurgeTextureCache();
s_gs->PurgePool();
}
// clear out the sampler cache when AF options change, since the anisotropy gets baked into them
if (GSConfig.MaxAnisotropy != old_config.MaxAnisotropy)
g_gs_device->ClearSamplerCache();
}
void GSSwitchRenderer(GSRendererType new_renderer)

View File

@ -566,6 +566,8 @@ void GSRenderer::KeyEvent(const HostKeyEvent& e)
#define VK_HOME XK_Home
#endif
// NOTE: These are all BROKEN! They mess with GS thread state from the UI thread.
switch (e.key)
{
case VK_F5:
@ -593,6 +595,10 @@ void GSRenderer::PurgePool()
g_gs_device->PurgePool();
}
void GSRenderer::PurgeTextureCache()
{
}
bool GSRenderer::SaveSnapshotToMemory(u32 width, u32 height, std::vector<u32>* pixels)
{
GSTexture* const current = g_gs_device->GetCurrent();

View File

@ -56,7 +56,8 @@ public:
virtual bool BeginCapture(std::string& filename);
virtual void EndCapture();
void PurgePool();
virtual void PurgePool() override;
virtual void PurgeTextureCache();
bool SaveSnapshotToMemory(u32 width, u32 height, std::vector<u32>* pixels);
};

View File

@ -192,6 +192,12 @@ void GSRendererHW::Destroy()
GSRenderer::Destroy();
}
void GSRendererHW::PurgeTextureCache()
{
GSRenderer::PurgeTextureCache();
m_tc->RemoveAll();
}
void GSRendererHW::SetGameCRC(u32 crc, int options)
{
GSRenderer::SetGameCRC(crc, options);

View File

@ -191,6 +191,8 @@ public:
void InvalidateLocalMem(const GIFRegBITBLTBUF& BITBLTBUF, const GSVector4i& r, bool clut = false) override;
void Draw() override;
void PurgeTextureCache() override;
// Called by the texture cache to know if current texture is useful
virtual bool IsDummyTexture() const { return false; }
};

View File

@ -24,7 +24,6 @@
#define XXH_INLINE_ALL 1
#include "xxhash.h"
bool GSTextureCache::m_paltex = false;
bool GSTextureCache::m_disable_partial_invalidation = false;
bool GSTextureCache::m_wrap_gs_mem = false;
@ -53,8 +52,6 @@ GSTextureCache::GSTextureCache(GSRenderer* r)
m_wrap_gs_mem = false;
}
m_paltex = theApp.GetConfigB("paltex");
// In theory 4MB is enough but 9MB is safer for overflow (8MB
// isn't enough in custom resolution)
// Test: onimusha 3 PAL 60Hz
@ -1612,7 +1609,7 @@ GSTextureCache::Source* GSTextureCache::CreateSource(const GIFRegTEX0& TEX0, con
}
else
{
if (m_paltex && psm.pal > 0)
if (GSConfig.GPUPaletteConversion && psm.pal > 0)
{
src->m_texture = g_gs_device->CreateTexture(tw, th, false, GSTexture::Format::UNorm8);
AttachPaletteToSource(src, psm.pal, true);

View File

@ -221,7 +221,6 @@ protected:
PaletteMap m_palette_map;
SourceMap m_src;
FastList<Target*> m_dst[2];
static bool m_paltex;
bool m_preload_frame;
u8* m_temp;
bool m_can_convert_depth;