HostDisplay: Add an option to decouple display fps from emulator fps

Makes Android so much faster...
This commit is contained in:
Connor McLaughlin
2020-11-03 15:58:40 +10:00
parent ae1e4b1b8f
commit 2c8a4ff154
10 changed files with 79 additions and 1 deletions

View File

@ -605,8 +605,10 @@ void CommonHostInterface::UpdateSpeedLimiterState()
!System::IsRunning() || (m_speed_limiter_enabled && g_settings.audio_sync_enabled && !is_non_standard_speed);
const bool video_sync_enabled =
!System::IsRunning() || (m_speed_limiter_enabled && g_settings.video_sync_enabled && !is_non_standard_speed);
const float max_display_fps = m_speed_limiter_enabled ? 0.0f : g_settings.display_max_fps;
Log_InfoPrintf("Syncing to %s%s", audio_sync_enabled ? "audio" : "",
(audio_sync_enabled && video_sync_enabled) ? " and video" : (video_sync_enabled ? "video" : ""));
Log_InfoPrintf("Max display fps: %f", max_display_fps);
if (m_audio_stream)
{
@ -616,7 +618,10 @@ void CommonHostInterface::UpdateSpeedLimiterState()
}
if (m_display)
{
m_display->SetDisplayMaxFPS(max_display_fps);
m_display->SetVSync(video_sync_enabled);
}
if (g_settings.increase_timer_resolution)
SetTimerResolutionIncreased(m_speed_limiter_enabled);
@ -2077,7 +2082,8 @@ void CommonHostInterface::CheckForSettingsChanges(const Settings& old_settings)
g_settings.audio_sync_enabled != old_settings.audio_sync_enabled ||
g_settings.speed_limiter_enabled != old_settings.speed_limiter_enabled ||
g_settings.increase_timer_resolution != old_settings.increase_timer_resolution ||
g_settings.emulation_speed != old_settings.emulation_speed)
g_settings.emulation_speed != old_settings.emulation_speed ||
g_settings.display_max_fps != old_settings.display_max_fps)
{
UpdateSpeedLimiterState();
}

View File

@ -661,6 +661,19 @@ void D3D11HostDisplay::DestroyImGuiContext()
bool D3D11HostDisplay::Render()
{
#ifndef LIBRETRO
if (ShouldSkipDisplayingFrame())
{
#ifdef WITH_IMGUI
if (ImGui::GetCurrentContext())
{
ImGui::Render();
ImGui_ImplDX11_NewFrame();
}
#endif
return false;
}
static constexpr std::array<float, 4> clear_color = {};
m_context->ClearRenderTargetView(m_swap_chain_rtv.Get(), clear_color.data());
m_context->OMSetRenderTargets(1, m_swap_chain_rtv.GetAddressOf(), nullptr);

View File

@ -464,6 +464,19 @@ void OpenGLHostDisplay::DestroyResources()
bool OpenGLHostDisplay::Render()
{
if (ShouldSkipDisplayingFrame())
{
#ifdef WITH_IMGUI
if (ImGui::GetCurrentContext())
{
ImGui::Render();
ImGui_ImplOpenGL3_NewFrame();
}
#endif
return false;
}
glDisable(GL_SCISSOR_TEST);
glBindFramebuffer(GL_DRAW_FRAMEBUFFER, 0);
glClearColor(0.0f, 0.0f, 0.0f, 1.0f);

View File

@ -539,6 +539,19 @@ bool VulkanHostDisplay::CreateImGuiContext()
bool VulkanHostDisplay::Render()
{
if (ShouldSkipDisplayingFrame())
{
#ifdef WITH_IMGUI
if (ImGui::GetCurrentContext())
{
ImGui::Render();
ImGui_ImplVulkan_NewFrame();
}
#endif
return false;
}
VkResult res = m_swap_chain->AcquireNextImage();
if (res != VK_SUCCESS)
{