Add an option to present/skip presenting duplicate frames

Currently, we do not display every second frame in 25fps/30fps games
which run to vsync. This improves performance as there's less rendering
for the GPU to perform, but when combined with vsync, could cause frame
pacing issues.

This commit adds an option to force every frame generated by the console
to be displayed to the host, which may improve pacing for these games.
This commit is contained in:
Stenzek
2020-01-14 10:57:35 +10:00
parent efc1ee8e6a
commit 11ba623f26
11 changed files with 60 additions and 17 deletions

View File

@ -1190,8 +1190,10 @@ void Renderer::Swap(u32 xfb_addr, u32 fb_width, u32 fb_stride, u32 fb_height, u6
MathUtil::Rectangle<int> xfb_rect;
const auto* xfb_entry =
g_texture_cache->GetXFBTexture(xfb_addr, fb_width, fb_height, fb_stride, &xfb_rect);
if (xfb_entry && xfb_entry->id != m_last_xfb_id)
if (xfb_entry &&
(!g_ActiveConfig.bSkipPresentingDuplicateXFBs || xfb_entry->id != m_last_xfb_id))
{
const bool is_duplicate_frame = xfb_entry->id == m_last_xfb_id;
m_last_xfb_id = xfb_entry->id;
// Since we use the common pipelines here and draw vertices if a batch is currently being
@ -1235,20 +1237,24 @@ void Renderer::Swap(u32 xfb_addr, u32 fb_width, u32 fb_stride, u32 fb_height, u6
SetWindowSize(xfb_rect.GetWidth(), xfb_rect.GetHeight());
}
m_fps_counter.Update();
if (!is_duplicate_frame)
{
m_fps_counter.Update();
DolphinAnalytics::PerformanceSample perf_sample;
perf_sample.speed_ratio = SystemTimers::GetEstimatedEmulationPerformance();
perf_sample.num_prims = g_stats.this_frame.num_prims + g_stats.this_frame.num_dl_prims;
perf_sample.num_draw_calls = g_stats.this_frame.num_draw_calls;
DolphinAnalytics::Instance().ReportPerformanceInfo(std::move(perf_sample));
DolphinAnalytics::PerformanceSample perf_sample;
perf_sample.speed_ratio = SystemTimers::GetEstimatedEmulationPerformance();
perf_sample.num_prims = g_stats.this_frame.num_prims + g_stats.this_frame.num_dl_prims;
perf_sample.num_draw_calls = g_stats.this_frame.num_draw_calls;
DolphinAnalytics::Instance().ReportPerformanceInfo(std::move(perf_sample));
if (IsFrameDumping())
DumpCurrentFrame(xfb_entry->texture.get(), xfb_rect, ticks);
if (IsFrameDumping())
DumpCurrentFrame(xfb_entry->texture.get(), xfb_rect, ticks);
// Begin new frame
m_frame_count++;
g_stats.ResetFrame();
}
// Begin new frame
m_frame_count++;
g_stats.ResetFrame();
g_shader_cache->RetrieveAsyncShaders();
g_vertex_manager->OnEndFrame();
BeginImGuiFrame();
@ -1263,16 +1269,18 @@ void Renderer::Swap(u32 xfb_addr, u32 fb_width, u32 fb_stride, u32 fb_height, u6
// rate and not waiting for vblank. Otherwise, we'd end up with a huge list of pending copies.
g_texture_cache->FlushEFBCopies();
// Remove stale EFB/XFB copies.
g_texture_cache->Cleanup(m_frame_count);
if (!is_duplicate_frame)
{
// Remove stale EFB/XFB copies.
g_texture_cache->Cleanup(m_frame_count);
Core::Callback_VideoCopiedToXFB(true);
}
// Handle any config changes, this gets propogated to the backend.
CheckForConfigChanges();
g_Config.iSaveTargetId = 0;
EndUtilityDrawing();
Core::Callback_VideoCopiedToXFB(true);
}
else
{