GS: Make TEXFLUSH a flag instead

This commit is contained in:
Stenzek 2023-04-23 17:29:01 +10:00 committed by refractionpcsx2
parent 33b2f6331c
commit 0367851b8e
2 changed files with 19 additions and 25 deletions

View File

@ -188,6 +188,7 @@ void GSState::Reset(bool hardware_reset)
m_vertex.next = 0;
m_index.tail = 0;
m_scanmask_used = 0;
m_texflush_flag = false;
m_dirty_gs_regs = 0;
m_backed_up_ctx = -1;
@ -407,9 +408,6 @@ void GSState::DumpVertices(const std::string& filename)
case GSFlushReason::CLUTCHANGE:
file << "CLUT CHANGE (RELOAD REQ)";
break;
case GSFlushReason::TEXFLUSH:
file << "TEXFLUSH CALL";
break;
case GSFlushReason::GSTRANSFER:
file << "GS TRANSFER";
break;
@ -1168,12 +1166,7 @@ void GSState::GIFRegHandlerFOGCOL(const GIFReg* RESTRICT r)
void GSState::GIFRegHandlerTEXFLUSH(const GIFReg* RESTRICT r)
{
GL_REG("TEXFLUSH = 0x%x_%x PRIM TME %x", r->U32[1], r->U32[0], PRIM->TME);
// Some games do a single sprite draw to itself, then flush the texture cache, then use that texture again.
// This won't get picked up by the new autoflush logic (which checks for page crossings for the PS2 Texture Cache flush)
// so we need to do it here.
if (IsAutoFlushEnabled() && IsAutoFlushDraw(PRIM->PRIM))
Flush(GSFlushReason::TEXFLUSH);
m_texflush_flag = true;
}
template <int i>
@ -1580,6 +1573,9 @@ void GSState::FlushPrim()
{
GL_REG("FlushPrim ctxt %d", PRIM->CTXT);
// clear texture cache flushed flag, since we're reading from it
m_texflush_flag = PRIM->TME ? false : m_texflush_flag;
// internal frame rate detection based on sprite blits to the display framebuffer
{
const u32 FRAME_FBP = m_context->FRAME.FBP;
@ -2955,7 +2951,7 @@ __forceinline void GSState::HandleAutoFlush()
const GSVector4i tex_page = tex_rect.xyxy() & page_mask;
// Crossed page since last draw end
if(!tex_page.eq(last_tex_page))
if (!tex_page.eq(last_tex_page) || m_texflush_flag)
{
const u32 frame_mask = GSLocalMemory::m_psm[m_context->TEX0.PSM].fmsk;
const bool frame_hit = (m_context->FRAME.Block() == m_context->TEX0.TBP0) && !(m_context->TEST.ATE && m_context->TEST.ATST == 0 && m_context->TEST.AFAIL == 2) && ((m_context->FRAME.FBMSK & frame_mask) != frame_mask);

View File

@ -144,10 +144,6 @@ protected:
GSVector4i m_scissor = {};
GSVector4i m_ofxy = {};
u8 m_scanmask_used = 0;
bool tex_flushed = true;
bool m_isPackedUV_HackFlag = false;
struct
{
GSVertex* buff;
@ -228,6 +224,9 @@ public:
std::unique_ptr<GSDumpBase> m_dump;
bool m_nativeres = false;
bool m_mipmap = false;
bool m_texflush_flag = false;
bool m_isPackedUV_HackFlag = false;
u8 m_scanmask_used = 0;
u8 m_force_preload = 0;
u32 m_dirty_gs_regs = 0;
int m_backed_up_ctx = 0;
@ -268,17 +267,16 @@ public:
RESET = 1 << 1,
CONTEXTCHANGE = 1 << 2,
CLUTCHANGE = 1 << 3,
TEXFLUSH = 1 << 4,
GSTRANSFER = 1 << 5,
UPLOADDIRTYTEX = 1 << 6,
LOCALTOLOCALMOVE = 1 << 7,
DOWNLOADFIFO = 1 << 8,
SAVESTATE = 1 << 9,
LOADSTATE = 1 << 10,
AUTOFLUSH = 1 << 11,
VSYNC = 1 << 12,
GSREOPEN = 1 << 13,
VERTEXCOUNT = 1 << 14,
GSTRANSFER = 1 << 4,
UPLOADDIRTYTEX = 1 << 5,
LOCALTOLOCALMOVE = 1 << 6,
DOWNLOADFIFO = 1 << 7,
SAVESTATE = 1 << 8,
LOADSTATE = 1 << 9,
AUTOFLUSH = 1 << 10,
VSYNC = 1 << 11,
GSREOPEN = 1 << 12,
VERTEXCOUNT = 1 << 13,
};
GSFlushReason m_state_flush_reason = UNKNOWN;