GS: Remove second source of truth for HWMipmap

This commit is contained in:
Connor McLaughlin 2022-03-03 23:28:29 +10:00 committed by refractionpcsx2
parent 2e199d47a8
commit f376c8f7ae
6 changed files with 16 additions and 14 deletions

View File

@ -804,14 +804,14 @@ 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)
if (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 ||
if ((GSConfig.UseHardwareRenderer() && GSConfig.HWMipmap != old_config.HWMipmap) ||
GSConfig.TexturePreloading != old_config.TexturePreloading ||
GSConfig.UserHacks_TriFilter != old_config.UserHacks_TriFilter ||
GSConfig.GPUPaletteConversion != old_config.GPUPaletteConversion)

View File

@ -132,6 +132,7 @@ GSState::GSState()
Reset();
ResetHandlers();
UpdateMipmapEnabled();
}
GSState::~GSState()
@ -314,6 +315,11 @@ void GSState::ResetHandlers()
m_fpGIFRegHandlers[GIF_A_D_REG_LABEL] = &GSState::GIFRegHandlerNull;
}
void GSState::UpdateMipmapEnabled()
{
m_mipmap = GSConfig.UseHardwareRenderer() ? (GSConfig.HWMipmap >= HWMipmapLevel::Basic) : GSConfig.Mipmap;
}
bool GSState::isinterlaced()
{
return !!m_regs->SMODE2.INT;

View File

@ -258,6 +258,7 @@ public:
virtual ~GSState();
void ResetHandlers();
void UpdateMipmapEnabled();
int GetFramebufferHeight();
void SaturateOutputSize(GSVector4i& r);

View File

@ -27,7 +27,6 @@ GSRendererHW::GSRendererHW()
, m_custom_height(1024)
, m_tc(new GSTextureCache(this))
, m_src(nullptr)
, m_hw_mipmap(GSConfig.HWMipmap)
, m_userhacks_tcoffset(false)
, m_userhacks_tcoffset_x(0)
, m_userhacks_tcoffset_y(0)
@ -35,7 +34,7 @@ GSRendererHW::GSRendererHW()
, m_reset(false)
, m_lod(GSVector2i(0, 0))
{
m_mipmap = (m_hw_mipmap >= HWMipmapLevel::Basic);
m_mipmap = (GSConfig.HWMipmap >= HWMipmapLevel::Basic);
if (GSConfig.UserHacks)
{
@ -183,9 +182,6 @@ void GSRendererHW::SetGameCRC(u32 crc, int options)
m_hacks.SetGameCRC(m_game);
m_hw_mipmap = GSConfig.HWMipmap;
m_mipmap = (m_hw_mipmap >= HWMipmapLevel::Basic);
GSTextureReplacements::GameChanged();
}
@ -1367,7 +1363,7 @@ void GSRendererHW::Draw()
// upload the full chain (with offset) for the hash cache, in case some other texture uses more levels
// for basic mipmapping, we can get away with just doing the base image, since all the mips get generated anyway.
hash_lod_range = GSVector2i(m_lod.x, (m_hw_mipmap == HWMipmapLevel::Full) ? mxl : m_lod.x);
hash_lod_range = GSVector2i(m_lod.x, (GSConfig.HWMipmap == HWMipmapLevel::Full) ? mxl : m_lod.x);
MIP_CLAMP.MINU >>= m_lod.x;
MIP_CLAMP.MINV >>= m_lod.x;
@ -1392,7 +1388,7 @@ void GSRendererHW::Draw()
TextureMinMaxResult tmm = GetTextureMinMax(TEX0, MIP_CLAMP, m_vt.IsLinear());
m_src = tex_psm.depth ? m_tc->LookupDepthSource(TEX0, env.TEXA, tmm.coverage) :
m_tc->LookupSource(TEX0, env.TEXA, tmm.coverage, (m_hw_mipmap >= HWMipmapLevel::Basic ||
m_tc->LookupSource(TEX0, env.TEXA, tmm.coverage, (GSConfig.HWMipmap >= HWMipmapLevel::Basic ||
GSConfig.UserHacks_TriFilter == TriFiltering::Forced) ? &hash_lod_range : nullptr);
int tw = 1 << TEX0.TW;
@ -1447,7 +1443,7 @@ void GSRendererHW::Draw()
}
// Round 2
if (IsMipMapActive() && m_hw_mipmap == HWMipmapLevel::Full && !tex_psm.depth && !m_src->m_from_hash_cache)
if (IsMipMapActive() && GSConfig.HWMipmap == HWMipmapLevel::Full && !tex_psm.depth && !m_src->m_from_hash_cache)
{
// Upload remaining texture layers
const GSVector4 tmin = m_vt.m_min.t;

View File

@ -138,7 +138,6 @@ protected:
GSTextureCache* m_tc;
GSVector4i m_r;
GSTextureCache::Source* m_src;
HWMipmapLevel m_hw_mipmap;
virtual void DrawPrims(GSTexture* rt, GSTexture* ds, GSTextureCache::Source* tex) = 0;

View File

@ -956,7 +956,7 @@ void GSRendererNew::EmulateTextureSampler(const GSTextureCache::Source* tex)
const bool need_mipmap = IsMipMapDraw();
const bool shader_emulated_sampler = tex->m_palette || cpsm.fmt != 0 || complex_wms_wmt || psm.depth;
const bool trilinear_manual = need_mipmap && m_hw_mipmap == HWMipmapLevel::Full;
const bool trilinear_manual = need_mipmap && GSConfig.HWMipmap == HWMipmapLevel::Full;
bool bilinear = m_vt.IsLinear();
int trilinear = 0;
@ -965,11 +965,11 @@ void GSRendererNew::EmulateTextureSampler(const GSTextureCache::Source* tex)
{
case TriFiltering::Forced:
trilinear = static_cast<u8>(GS_MIN_FILTER::Linear_Mipmap_Linear);
trilinear_auto = !need_mipmap || m_hw_mipmap != HWMipmapLevel::Full;
trilinear_auto = !need_mipmap || GSConfig.HWMipmap != HWMipmapLevel::Full;
break;
case TriFiltering::PS2:
if (need_mipmap && m_hw_mipmap != HWMipmapLevel::Full)
if (need_mipmap && GSConfig.HWMipmap != HWMipmapLevel::Full)
{
trilinear = m_context->TEX1.MMIN;
trilinear_auto = true;