GS: Remove unused offsets (tex/fzb)

This commit is contained in:
Stenzek 2023-04-02 23:26:40 +10:00 committed by refractionpcsx2
parent 38bf916231
commit 4313c64d9d
5 changed files with 44 additions and 66 deletions

View File

@ -48,8 +48,6 @@ public:
{
GSOffset fb;
GSOffset zb;
GSOffset tex;
GSPixelOffset* fzb;
GSPixelOffset4* fzb4;
} offset;

View File

@ -162,8 +162,6 @@ void GSState::Reset(bool hardware_reset)
m_env.CTXT[i].offset.fb = m_mem.GetOffset(m_env.CTXT[i].FRAME.Block(), m_env.CTXT[i].FRAME.FBW, m_env.CTXT[i].FRAME.PSM);
m_env.CTXT[i].offset.zb = m_mem.GetOffset(m_env.CTXT[i].ZBUF.Block(), m_env.CTXT[i].FRAME.FBW, m_env.CTXT[i].ZBUF.PSM);
m_env.CTXT[i].offset.tex = m_mem.GetOffset(m_env.CTXT[i].TEX0.TBP0, m_env.CTXT[i].TEX0.TBW, m_env.CTXT[i].TEX0.PSM);
m_env.CTXT[i].offset.fzb = m_mem.GetPixelOffset(m_env.CTXT[i].FRAME, m_env.CTXT[i].ZBUF);
m_env.CTXT[i].offset.fzb4 = m_mem.GetPixelOffset4(m_env.CTXT[i].FRAME, m_env.CTXT[i].ZBUF);
}
@ -752,7 +750,7 @@ void GSState::GIFRegHandlerRGBAQ(const GIFReg* RESTRICT r)
void GSState::GIFRegHandlerST(const GIFReg* RESTRICT r)
{
m_v.ST = (GSVector4i)r->ST;
m_v.ST = r->ST;
#if defined(PCSX2_DEVBUILD) || defined(_DEBUG)
if (std::isnan(m_v.ST.S) || std::isnan(m_v.ST.T))
@ -830,10 +828,7 @@ void GSState::ApplyTEX0(GIFRegTEX0& TEX0)
TEX0.CPSM &= 0xa; // 1010b
if ((TEX0.U32[0] ^ m_env.CTXT[i].TEX0.U32[0]) & 0x3ffffff) // TBP0 TBW PSM
m_env.CTXT[i].offset.tex = m_mem.GetOffset(TEX0.TBP0, TEX0.TBW, TEX0.PSM);
m_env.CTXT[i].TEX0 = (GSVector4i)TEX0;
m_env.CTXT[i].TEX0 = TEX0;
if (wt)
{
@ -970,7 +965,7 @@ void GSState::GIFRegHandlerCLAMP(const GIFReg* RESTRICT r)
{
GL_REG("CLAMP_%d = 0x%x_%x", i, r->U32[1], r->U32[0]);
m_env.CTXT[i].CLAMP = (GSVector4i)r->CLAMP;
m_env.CTXT[i].CLAMP = r->CLAMP;
if (i == m_prev_env.PRIM.CTXT)
{
@ -995,7 +990,7 @@ void GSState::GIFRegHandlerTEX1(const GIFReg* RESTRICT r)
{
GL_REG("TEX1_%d = 0x%x_%x", i, r->U32[1], r->U32[0]);
m_env.CTXT[i].TEX1 = (GSVector4i)r->TEX1;
m_env.CTXT[i].TEX1 = r->TEX1;
if (i == m_prev_env.PRIM.CTXT)
{
@ -1064,7 +1059,7 @@ void GSState::GIFRegHandlerPRMODE(const GIFReg* RESTRICT r)
return;
const u32 _PRIM = m_env.PRIM.PRIM;
m_env.PRIM = (GSVector4i)r->PRMODE;
m_env.PRIM = r->PRMODE;
m_env.PRIM.PRIM = _PRIM;
if (m_prev_env.PRIM.U32[0] ^ m_env.PRIM.U32[0])
@ -1079,12 +1074,12 @@ void GSState::GIFRegHandlerTEXCLUT(const GIFReg* RESTRICT r)
{
GL_REG("TEXCLUT = 0x%x_%x", r->U32[1], r->U32[0]);
m_env.TEXCLUT = (GSVector4i)r->TEXCLUT;
m_env.TEXCLUT = r->TEXCLUT;
}
void GSState::GIFRegHandlerSCANMSK(const GIFReg* RESTRICT r)
{
m_env.SCANMSK = (GSVector4i)r->SCANMSK;
m_env.SCANMSK = r->SCANMSK;
if (m_env.SCANMSK.MSK & 2)
m_scanmask_used = 2;
@ -1100,7 +1095,7 @@ void GSState::GIFRegHandlerMIPTBP1(const GIFReg* RESTRICT r)
{
GL_REG("MIPTBP1_%d = 0x%x_%x", i, r->U32[1], r->U32[0]);
m_env.CTXT[i].MIPTBP1 = (GSVector4i)r->MIPTBP1;
m_env.CTXT[i].MIPTBP1 = r->MIPTBP1;
if (i == m_prev_env.PRIM.CTXT)
{
@ -1116,7 +1111,7 @@ void GSState::GIFRegHandlerMIPTBP2(const GIFReg* RESTRICT r)
{
GL_REG("MIPTBP2_%d = 0x%x_%x", i, r->U32[1], r->U32[0]);
m_env.CTXT[i].MIPTBP2 = (GSVector4i)r->MIPTBP2;
m_env.CTXT[i].MIPTBP2 = r->MIPTBP2;
if (i == m_prev_env.PRIM.CTXT)
{
@ -1131,7 +1126,7 @@ void GSState::GIFRegHandlerTEXA(const GIFReg* RESTRICT r)
{
GL_REG("TEXA = 0x%x_%x", r->U32[1], r->U32[0]);
m_env.TEXA = (GSVector4i)r->TEXA;
m_env.TEXA = r->TEXA;
if (m_prev_env.TEXA != m_env.TEXA)
m_dirty_gs_regs |= (1 << DIRTY_REG_TEXA);
@ -1143,7 +1138,7 @@ void GSState::GIFRegHandlerFOGCOL(const GIFReg* RESTRICT r)
{
GL_REG("FOGCOL = 0x%x_%x", r->U32[1], r->U32[0]);
m_env.FOGCOL = (GSVector4i)r->FOGCOL;
m_env.FOGCOL = r->FOGCOL;
if (m_prev_env.FOGCOL != m_env.FOGCOL)
m_dirty_gs_regs |= (1 << DIRTY_REG_FOGCOL);
@ -1165,7 +1160,7 @@ void GSState::GIFRegHandlerTEXFLUSH(const GIFReg* RESTRICT r)
template <int i>
void GSState::GIFRegHandlerSCISSOR(const GIFReg* RESTRICT r)
{
m_env.CTXT[i].SCISSOR = (GSVector4i)r->SCISSOR;
m_env.CTXT[i].SCISSOR = r->SCISSOR;
if (i == m_prev_env.PRIM.CTXT)
{
@ -1185,7 +1180,7 @@ void GSState::GIFRegHandlerALPHA(const GIFReg* RESTRICT r)
{
GL_REG("ALPHA = 0x%x_%x", r->U32[1], r->U32[0]);
m_env.CTXT[i].ALPHA = (GSVector4i)r->ALPHA;
m_env.CTXT[i].ALPHA = r->ALPHA;
// value of 3 is not allowed by the spec
// acts like 2 on real hw, so just clamp it
@ -1210,7 +1205,7 @@ void GSState::GIFRegHandlerDIMX(const GIFReg* RESTRICT r)
if (r->DIMX != m_env.DIMX)
update = true;
m_env.DIMX = (GSVector4i)r->DIMX;
m_env.DIMX = r->DIMX;
if (update)
m_env.UpdateDIMX();
@ -1223,7 +1218,7 @@ void GSState::GIFRegHandlerDIMX(const GIFReg* RESTRICT r)
void GSState::GIFRegHandlerDTHE(const GIFReg* RESTRICT r)
{
m_env.DTHE = (GSVector4i)r->DTHE;
m_env.DTHE = r->DTHE;
if (m_prev_env.DTHE != m_env.DTHE)
m_dirty_gs_regs |= (1 << DIRTY_REG_DTHE);
@ -1233,7 +1228,7 @@ void GSState::GIFRegHandlerDTHE(const GIFReg* RESTRICT r)
void GSState::GIFRegHandlerCOLCLAMP(const GIFReg* RESTRICT r)
{
m_env.COLCLAMP = (GSVector4i)r->COLCLAMP;
m_env.COLCLAMP = r->COLCLAMP;
if (m_prev_env.COLCLAMP != m_env.COLCLAMP)
m_dirty_gs_regs |= (1 << DIRTY_REG_COLCLAMP);
@ -1244,7 +1239,7 @@ void GSState::GIFRegHandlerCOLCLAMP(const GIFReg* RESTRICT r)
template <int i>
void GSState::GIFRegHandlerTEST(const GIFReg* RESTRICT r)
{
m_env.CTXT[i].TEST = (GSVector4i)r->TEST;
m_env.CTXT[i].TEST = r->TEST;
if (i == m_prev_env.PRIM.CTXT)
{
@ -1257,8 +1252,7 @@ void GSState::GIFRegHandlerTEST(const GIFReg* RESTRICT r)
void GSState::GIFRegHandlerPABE(const GIFReg* RESTRICT r)
{
m_env.PABE = (GSVector4i)r->PABE;
m_env.PABE = r->PABE;
if (m_prev_env.PABE != m_env.PABE)
m_dirty_gs_regs |= (1 << DIRTY_REG_PABE);
@ -1269,7 +1263,7 @@ void GSState::GIFRegHandlerPABE(const GIFReg* RESTRICT r)
template <int i>
void GSState::GIFRegHandlerFBA(const GIFReg* RESTRICT r)
{
m_env.CTXT[i].FBA = (GSVector4i)r->FBA;
m_env.CTXT[i].FBA = r->FBA;
if (i == m_prev_env.PRIM.CTXT)
{
@ -1298,11 +1292,10 @@ void GSState::GIFRegHandlerFRAME(const GIFReg* RESTRICT r)
{
m_env.CTXT[i].offset.fb = m_mem.GetOffset(NewFrame.Block(), NewFrame.FBW, NewFrame.PSM);
m_env.CTXT[i].offset.zb = m_mem.GetOffset(m_env.CTXT[i].ZBUF.Block(), NewFrame.FBW, m_env.CTXT[i].ZBUF.PSM);
m_env.CTXT[i].offset.fzb = m_mem.GetPixelOffset(NewFrame, m_env.CTXT[i].ZBUF);
m_env.CTXT[i].offset.fzb4 = m_mem.GetPixelOffset4(NewFrame, m_env.CTXT[i].ZBUF);
}
m_env.CTXT[i].FRAME = (GSVector4i)NewFrame;
m_env.CTXT[i].FRAME = NewFrame;
switch (m_env.CTXT[i].FRAME.PSM)
{
@ -1356,11 +1349,10 @@ void GSState::GIFRegHandlerZBUF(const GIFReg* RESTRICT r)
if ((m_env.CTXT[i].ZBUF.U32[0] ^ ZBUF.U32[0]) & 0x3f0001ff) // ZBP PSM
{
m_env.CTXT[i].offset.zb = m_mem.GetOffset(ZBUF.Block(), m_env.CTXT[i].FRAME.FBW, ZBUF.PSM);
m_env.CTXT[i].offset.fzb = m_mem.GetPixelOffset(m_env.CTXT[i].FRAME, ZBUF);
m_env.CTXT[i].offset.fzb4 = m_mem.GetPixelOffset4(m_env.CTXT[i].FRAME, ZBUF);
}
m_env.CTXT[i].ZBUF = (GSVector4i)ZBUF;
m_env.CTXT[i].ZBUF = ZBUF;
if (i == m_prev_env.PRIM.CTXT)
{
@ -1388,7 +1380,7 @@ void GSState::GIFRegHandlerBITBLTBUF(const GIFReg* RESTRICT r)
if (r->BITBLTBUF != m_env.BITBLTBUF)
FlushWrite();
m_env.BITBLTBUF = (GSVector4i)r->BITBLTBUF;
m_env.BITBLTBUF = r->BITBLTBUF;
}
void GSState::GIFRegHandlerTRXPOS(const GIFReg* RESTRICT r)
@ -1398,7 +1390,7 @@ void GSState::GIFRegHandlerTRXPOS(const GIFReg* RESTRICT r)
if (r->TRXPOS != m_env.TRXPOS)
FlushWrite();
m_env.TRXPOS = (GSVector4i)r->TRXPOS;
m_env.TRXPOS = r->TRXPOS;
}
void GSState::GIFRegHandlerTRXREG(const GIFReg* RESTRICT r)
@ -1407,7 +1399,7 @@ void GSState::GIFRegHandlerTRXREG(const GIFReg* RESTRICT r)
if (r->TRXREG != m_env.TRXREG)
FlushWrite();
m_env.TRXREG = (GSVector4i)r->TRXREG;
m_env.TRXREG = r->TRXREG;
}
void GSState::GIFRegHandlerTRXDIR(const GIFReg* RESTRICT r)
@ -1416,7 +1408,7 @@ void GSState::GIFRegHandlerTRXDIR(const GIFReg* RESTRICT r)
Flush(GSFlushReason::GSTRANSFER);
m_env.TRXDIR = (GSVector4i)r->TRXDIR;
m_env.TRXDIR = r->TRXDIR;
switch (m_env.TRXDIR.XDIR)
{
@ -2556,8 +2548,6 @@ int GSState::Defrost(const freezeData* fd)
m_env.CTXT[i].offset.fb = m_mem.GetOffset(m_env.CTXT[i].FRAME.Block(), m_env.CTXT[i].FRAME.FBW, m_env.CTXT[i].FRAME.PSM);
m_env.CTXT[i].offset.zb = m_mem.GetOffset(m_env.CTXT[i].ZBUF.Block(), m_env.CTXT[i].FRAME.FBW, m_env.CTXT[i].ZBUF.PSM);
m_env.CTXT[i].offset.tex = m_mem.GetOffset(m_env.CTXT[i].TEX0.TBP0, m_env.CTXT[i].TEX0.TBW, m_env.CTXT[i].TEX0.PSM);
m_env.CTXT[i].offset.fzb = m_mem.GetPixelOffset(m_env.CTXT[i].FRAME, m_env.CTXT[i].ZBUF);
m_env.CTXT[i].offset.fzb4 = m_mem.GetPixelOffset4(m_env.CTXT[i].FRAME, m_env.CTXT[i].ZBUF);
}

View File

@ -1082,7 +1082,7 @@ void GSRendererHW::SwSpriteRender()
GL_INS("SwSpriteRender: Dest 0x%x W:%d F:%s, size(%d %d)", m_context->FRAME.Block(), m_context->FRAME.FBW, psm_str(m_context->FRAME.PSM), w, h);
const GSOffset& spo = m_context->offset.tex;
const GSOffset spo = m_mem.GetOffset(m_context->TEX0.TBP0, m_context->TEX0.TBW, m_context->TEX0.PSM);
const GSOffset& dpo = m_context->offset.fb;
const bool alpha_blending_enabled = PRIM->ABE;
@ -1591,8 +1591,6 @@ void GSRendererHW::Draw()
m_context->FRAME.FBP = m_split_texture_shuffle_start_FBP;
m_context->offset.fb = GSOffset(GSLocalMemory::m_psm[m_context->FRAME.PSM].info, m_context->FRAME.Block(),
m_context->FRAME.FBW, m_context->FRAME.PSM);
m_context->offset.tex = GSOffset(GSLocalMemory::m_psm[m_context->TEX0.PSM].info, m_context->TEX0.TBP0,
m_context->TEX0.TBW, m_context->TEX0.PSM);
}
const auto cleanup_cancelled_draw = [&]() {
@ -1604,8 +1602,6 @@ void GSRendererHW::Draw()
{
m_context->offset.fb = GSOffset(GSLocalMemory::m_psm[m_context->FRAME.PSM].info, m_context->FRAME.Block(),
m_context->FRAME.FBW, m_context->FRAME.PSM);
m_context->offset.tex = GSOffset(GSLocalMemory::m_psm[m_context->TEX0.PSM].info, m_context->TEX0.TBP0,
m_context->TEX0.TBW, m_context->TEX0.PSM);
}
};
@ -1756,8 +1752,6 @@ void GSRendererHW::Draw()
TEX0 = GetTex0Layer(0);
}
m_context->offset.tex = m_mem.GetOffset(TEX0.TBP0, TEX0.TBW, TEX0.PSM);
tmm = GetTextureMinMax(TEX0, MIP_CLAMP, m_vt.IsLinear(), false);
// Snowblind games set TW/TH to 1024, and use UVs for smaller textures inside that.
@ -1978,8 +1972,6 @@ void GSRendererHW::Draw()
{
const GIFRegTEX0 MIP_TEX0(GetTex0Layer(layer));
m_context->offset.tex = m_mem.GetOffset(MIP_TEX0.TBP0, MIP_TEX0.TBW, MIP_TEX0.PSM);
MIP_CLAMP.MINU >>= 1;
MIP_CLAMP.MINV >>= 1;
MIP_CLAMP.MAXU >>= 1;
@ -2293,8 +2285,6 @@ void GSRendererHW::Draw()
{
m_context->offset.fb = GSOffset(GSLocalMemory::m_psm[m_context->FRAME.PSM].info, m_context->FRAME.Block(),
m_context->FRAME.FBW, m_context->FRAME.PSM);
m_context->offset.tex = GSOffset(GSLocalMemory::m_psm[m_context->TEX0.PSM].info, m_context->TEX0.TBP0,
m_context->TEX0.TBW, m_context->TEX0.PSM);
}
//

View File

@ -619,7 +619,7 @@ GSTextureCache::Source* GSTextureCache::LookupDepthSource(const GIFRegTEX0& TEX0
else
{
src->SetPages();
m_src.Add(src, TEX0, g_gs_renderer->m_context->offset.tex);
m_src.Add(src, TEX0);
}
if (palette)
@ -3133,7 +3133,7 @@ GSTextureCache::Source* GSTextureCache::CreateSource(const GIFRegTEX0& TEX0, con
if (src != m_temporary_source)
{
src->SetPages();
m_src.Add(src, TEX0, g_gs_renderer->m_context->offset.tex);
m_src.Add(src, TEX0);
}
return src;
@ -3417,9 +3417,10 @@ GSTextureCache::Source* GSTextureCache::CreateMergedSource(GIFRegTEX0 TEX0, GIFR
src->m_target = true;
// Can't use the normal SetPages() here, it'll try to use TW/TH, which might be bad.
src->m_pages = g_gs_renderer->m_context->offset.tex.pageLooperForRect(GSVector4i(0, 0, tex_width, tex_height));
const GSOffset offset = g_gs_renderer->m_mem.GetOffset(TEX0.TBP0, TEX0.TBW, TEX0.PSM);
src->m_pages = offset.pageLooperForRect(GSVector4i(0, 0, tex_width, tex_height));
m_src.Add(src, TEX0);
m_src.Add(src, TEX0, g_gs_renderer->m_context->offset.tex);
return src;
}
@ -3878,8 +3879,9 @@ void GSTextureCache::Source::SetPages()
m_p2t = g_gs_renderer->m_mem.GetPage2TileMap(m_TEX0);
}
const GSOffset offset = g_gs_renderer->m_mem.GetOffset(m_TEX0.TBP0, m_TEX0.TBW, m_TEX0.PSM);
const GSVector4i rect(m_region.GetRect(tw, th));
m_pages = g_gs_renderer->m_context->offset.tex.pageLooperForRect(rect);
m_pages = offset.pageLooperForRect(rect);
}
void GSTextureCache::Source::Update(const GSVector4i& rect, int level)
@ -3913,7 +3915,7 @@ void GSTextureCache::Source::Update(const GSVector4i& rect, int level)
if (region_rect.eq(r.rintersect(region_rect)))
m_complete_layers |= (1u << level);
const GSOffset& off = g_gs_renderer->m_context->offset.tex;
const GSOffset off = g_gs_renderer->m_mem.GetOffset(m_TEX0.TBP0, m_TEX0.TBW, m_TEX0.PSM);
GSOffset::BNHelper bn = off.bnMulti(r.left, r.top);
u32 blocks = 0;
@ -3937,7 +3939,7 @@ void GSTextureCache::Source::Update(const GSVector4i& rect, int level)
{
m_valid[row] |= col;
Write(GSVector4i(x, y, x + bs.x, y + bs.y), level);
Write(GSVector4i(x, y, x + bs.x, y + bs.y), level, off);
blocks++;
}
@ -3958,7 +3960,7 @@ void GSTextureCache::Source::Update(const GSVector4i& rect, int level)
{
m_valid[row] |= col;
Write(GSVector4i(x, y, x + bs.x, y + bs.y), level);
Write(GSVector4i(x, y, x + bs.x, y + bs.y), level, off);
blocks++;
}
@ -3969,7 +3971,7 @@ void GSTextureCache::Source::Update(const GSVector4i& rect, int level)
if (blocks > 0)
{
g_perfmon.Put(GSPerfMon::Unswizzle, bs.x * bs.y * blocks << (m_palette ? 2 : 0));
Flush(m_write.count, level);
Flush(m_write.count, level, off);
}
}
@ -3994,7 +3996,7 @@ void GSTextureCache::Source::UpdateLayer(const GIFRegTEX0& TEX0, const GSVector4
m_TEX0 = old_TEX0;
}
void GSTextureCache::Source::Write(const GSVector4i& r, int layer)
void GSTextureCache::Source::Write(const GSVector4i& r, int layer, const GSOffset& off)
{
if (!m_write.rect)
m_write.rect = static_cast<GSVector4i*>(_aligned_malloc(3 * sizeof(GSVector4i), 32));
@ -4026,11 +4028,11 @@ void GSTextureCache::Source::Write(const GSVector4i& r, int layer)
if (m_write.count > 2)
{
Flush(1, layer);
Flush(1, layer, off);
}
}
void GSTextureCache::Source::Flush(u32 count, int layer)
void GSTextureCache::Source::Flush(u32 count, int layer, const GSOffset& off)
{
// This function as written will not work for paletted formats copied from framebuffers
// because they are 8 or 4 bit formats on the GS and the GS local memory module reads
@ -4049,8 +4051,6 @@ void GSTextureCache::Source::Flush(u32 count, int layer)
GSLocalMemory& mem = g_gs_renderer->m_mem;
const GSOffset& off = g_gs_renderer->m_context->offset.tex;
GSLocalMemory::readTexture rtx = psm.rtx;
if (m_palette)
@ -4435,7 +4435,7 @@ bool GSTextureCache::Target::ResizeTexture(int new_unscaled_width, int new_unsca
// GSTextureCache::SourceMap
void GSTextureCache::SourceMap::Add(Source* s, const GIFRegTEX0& TEX0, const GSOffset& off)
void GSTextureCache::SourceMap::Add(Source* s, const GIFRegTEX0& TEX0)
{
m_surfaces.insert(s);

View File

@ -244,8 +244,8 @@ public:
void PreloadLevel(int level);
void Write(const GSVector4i& r, int layer);
void Flush(u32 count, int layer);
void Write(const GSVector4i& r, int layer, const GSOffset& off);
void Flush(u32 count, int layer, const GSOffset& off);
public:
HashCacheEntry* m_from_hash_cache = nullptr;
@ -316,7 +316,7 @@ public:
std::unordered_set<Source*> m_surfaces;
std::array<FastList<Source*>, MAX_PAGES> m_map;
void Add(Source* s, const GIFRegTEX0& TEX0, const GSOffset& off);
void Add(Source* s, const GIFRegTEX0& TEX0);
void RemoveAll();
void RemoveAt(Source* s);
};