Skip to content

Commit

Permalink
VideoCommon: Remember to flush buffers after multiple EFB copies
Browse files Browse the repository at this point in the history
  • Loading branch information
TellowKrinkle committed Jun 23, 2022
1 parent 2bd72df commit 0a6becc
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
14 changes: 14 additions & 0 deletions Source/Core/VideoCommon/VertexManagerBase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -757,6 +757,16 @@ void VertexManagerBase::OnDraw()
{
m_draw_counter++;

// If the last efb copy was too close to the one before it, don't forget about it until the next
// efb copy happens (which might not be for a long time)
u32 diff = m_draw_counter - m_last_efb_copy_draw_counter;
if (m_unflushed_efb_copy && diff > MINIMUM_DRAW_CALLS_PER_COMMAND_BUFFER_FOR_READBACK)
{
g_renderer->Flush();
m_unflushed_efb_copy = false;
m_last_efb_copy_draw_counter = m_draw_counter;
}

// If we didn't have any CPU access last frame, do nothing.
if (m_scheduled_command_buffer_kicks.empty() || !m_allow_background_execution)
return;
Expand Down Expand Up @@ -794,8 +804,12 @@ void VertexManagerBase::OnEFBCopyToRAM()
const u32 diff = m_draw_counter - m_last_efb_copy_draw_counter;
m_last_efb_copy_draw_counter = m_draw_counter;
if (diff < MINIMUM_DRAW_CALLS_PER_COMMAND_BUFFER_FOR_READBACK)
{
m_unflushed_efb_copy = true;
return;
}

m_unflushed_efb_copy = false;
g_renderer->Flush();
}

Expand Down
1 change: 1 addition & 0 deletions Source/Core/VideoCommon/VertexManagerBase.h
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,7 @@ class VertexManagerBase
// CPU access tracking
u32 m_draw_counter = 0;
u32 m_last_efb_copy_draw_counter = 0;
bool m_unflushed_efb_copy = false;
std::vector<u32> m_cpu_accesses_this_frame;
std::vector<u32> m_scheduled_command_buffer_kicks;
bool m_allow_background_execution = true;
Expand Down

0 comments on commit 0a6becc

Please sign in to comment.