GS: Double buffer the EE transfer queue

This commit is contained in:
refractionpcsx2 2023-06-24 03:21:02 +01:00
parent 3c0b7f7724
commit 795d0a6682
3 changed files with 18 additions and 10 deletions

View File

@ -113,6 +113,7 @@ GSState::GSState()
GrowVertexBuffer(); GrowVertexBuffer();
m_draw_transfers.clear(); m_draw_transfers.clear();
m_draw_transfers_double_buff.clear();
PRIM = &m_env.PRIM; PRIM = &m_env.PRIM;
//CSR->rREV = 0x20; //CSR->rREV = 0x20;

View File

@ -235,6 +235,7 @@ public:
u32 m_dirty_gs_regs = 0; u32 m_dirty_gs_regs = 0;
int m_backed_up_ctx = 0; int m_backed_up_ctx = 0;
std::vector<GSUploadQueue> m_draw_transfers; std::vector<GSUploadQueue> m_draw_transfers;
std::vector<GSUploadQueue> m_draw_transfers_double_buff;
static int s_n; static int s_n;
static int s_last_transfer_draw_n; static int s_last_transfer_draw_n;

View File

@ -119,15 +119,19 @@ void GSRendererHW::VSync(u32 field, bool registers_written, bool idle_frame)
m_force_preload--; m_force_preload--;
if (m_force_preload == 0) if (m_force_preload == 0)
{ {
for (auto iter = m_draw_transfers.begin(); iter != m_draw_transfers.end();) for (auto iter = m_draw_transfers.rbegin(); iter != m_draw_transfers.rend(); iter++)
{ {
if ((s_n - iter->draw) > 5) if ((s_n - iter->draw) > 5)
iter = m_draw_transfers.erase(iter); break;
else else // Keep the last 5 draws worth of transfers.
{ {
iter++; GSUploadQueue transfer = *iter;
m_draw_transfers_double_buff.push_back(transfer);
} }
} }
m_draw_transfers.clear();
// Flip EE queue.
m_draw_transfers.swap(m_draw_transfers_double_buff);
} }
} }
else if (!idle_frame) else if (!idle_frame)
@ -136,18 +140,20 @@ void GSRendererHW::VSync(u32 field, bool registers_written, bool idle_frame)
// Rocky Legend does this with the main menu FMV's. // Rocky Legend does this with the main menu FMV's.
if (s_last_transfer_draw_n == s_n) if (s_last_transfer_draw_n == s_n)
{ {
for (auto iter = m_draw_transfers.begin(); iter != m_draw_transfers.end();) for (auto iter = m_draw_transfers.rbegin(); iter != m_draw_transfers.rend(); iter++)
{ {
if ((s_n - iter->draw) > 5) if ((s_n - iter->draw) > 5)
iter = m_draw_transfers.erase(iter); break;
else else // Keep the last 5 draws worth of transfers.
{ {
iter++; GSUploadQueue transfer = *iter;
m_draw_transfers_double_buff.push_back(transfer);
} }
} }
} }
else
m_draw_transfers.clear(); m_draw_transfers.clear();
// Flip EE queue.
m_draw_transfers.swap(m_draw_transfers_double_buff);
} }
if (GSConfig.LoadTextureReplacements) if (GSConfig.LoadTextureReplacements)