From e2fb87fae0e9c131335a7e5b3417dc7c1458b3e9 Mon Sep 17 00:00:00 2001 From: zhyk Date: Tue, 23 Jun 2015 15:48:19 +0800 Subject: [PATCH 1/3] Move throttling code from Core_RunLoop to UpdateRunLoop. --- Core/Core.cpp | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/Core/Core.cpp b/Core/Core.cpp index 5153b2e4b7e3..b9f764be68dc 100644 --- a/Core/Core.cpp +++ b/Core/Core.cpp @@ -153,6 +153,9 @@ bool UpdateScreenScale(int width, int height, bool smallWindow) { } void UpdateRunLoop() { + time_update(); + double startTime = time_now_d(); + if (windowHidden && g_Config.bPauseWhenMinimized) { sleep_ms(16); return; @@ -167,6 +170,16 @@ void UpdateRunLoop() { if (GetUIState() != UISTATE_EXIT) { NativeRender(); } + + if (GetUIState() != UISTATE_INGAME) { + // Simple throttling to not burn the GPU in the menu. + time_update(); + double diffTime = time_now_d() - startTime; + int sleepTime = (int)(1000.0 / 60.0) - (int)(diffTime * 1000.0); + + if (sleepTime > 0) + sleep_ms(sleepTime); + } } #if defined(USING_WIN_UI) @@ -186,27 +199,15 @@ void GPU_SwapBuffers() { void Core_RunLoop() { while ((GetUIState() != UISTATE_INGAME || !PSP_IsInited()) && GetUIState() != UISTATE_EXIT) { - time_update(); -#if defined(USING_WIN_UI) - double startTime = time_now_d(); UpdateRunLoop(); - - // Simple throttling to not burn the GPU in the menu. - time_update(); - double diffTime = time_now_d() - startTime; - int sleepTime = (int)(1000.0 / 60.0) - (int)(diffTime * 1000.0); - if (sleepTime > 0) - Sleep(sleepTime); +#if defined(USING_WIN_UI) if (!windowHidden) { GPU_SwapBuffers(); } -#else - UpdateRunLoop(); #endif } while (!coreState && GetUIState() == UISTATE_INGAME) { - time_update(); UpdateRunLoop(); #if defined(USING_WIN_UI) if (!windowHidden && !Core_IsStepping()) { From 43a81f608e0a007aee2fad0c8931e3ee4cdbc7b2 Mon Sep 17 00:00:00 2001 From: zhyk Date: Tue, 23 Jun 2015 15:53:03 +0800 Subject: [PATCH 2/3] Make vsync works on non-win32 platforms. --- GPU/GLES/GLES_GPU.cpp | 2 +- UI/GameSettingsScreen.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/GPU/GLES/GLES_GPU.cpp b/GPU/GLES/GLES_GPU.cpp index aa5ab008d7be..a359c0d92efb 100644 --- a/GPU/GLES/GLES_GPU.cpp +++ b/GPU/GLES/GLES_GPU.cpp @@ -539,7 +539,7 @@ void GLES_GPU::BeginFrame() { } inline void GLES_GPU::UpdateVsyncInterval(bool force) { -#ifdef _WIN32 +#ifndef USING_GLES2 int desiredVSyncInterval = g_Config.bVSync ? 1 : 0; if (PSP_CoreParameter().unthrottle) { desiredVSyncInterval = 0; diff --git a/UI/GameSettingsScreen.cpp b/UI/GameSettingsScreen.cpp index 6d542e3b3f24..9512b37e5c6c 100644 --- a/UI/GameSettingsScreen.cpp +++ b/UI/GameSettingsScreen.cpp @@ -197,7 +197,7 @@ void GameSettingsScreen::CreateViews() { hwscale->OnChoice.Handle(this, &GameSettingsScreen::OnHwScaleChange); // To refresh the display mode #endif -#ifdef _WIN32 +#ifndef USING_GLES2 graphicsSettings->Add(new CheckBox(&g_Config.bVSync, gs->T("VSync"))); #endif CheckBox *mipmapping = graphicsSettings->Add(new CheckBox(&g_Config.bMipMap, gs->T("Mipmapping"))); From 3c9d92452ff3d3e01fcd528e339250f9712895a8 Mon Sep 17 00:00:00 2001 From: zhykzhykzhyk Date: Sun, 28 Jun 2015 17:54:53 +0800 Subject: [PATCH 3/3] Add PSP_IsInited() to throttling condition --- Core/Core.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Core/Core.cpp b/Core/Core.cpp index b9f764be68dc..14ae476d1c49 100644 --- a/Core/Core.cpp +++ b/Core/Core.cpp @@ -171,7 +171,7 @@ void UpdateRunLoop() { NativeRender(); } - if (GetUIState() != UISTATE_INGAME) { + if (GetUIState() != UISTATE_INGAME || !PSP_IsInited()) { // Simple throttling to not burn the GPU in the menu. time_update(); double diffTime = time_now_d() - startTime;