From 7c2c4662a74354a5e4554dd68c7110a58651e0d0 Mon Sep 17 00:00:00 2001 From: Rachel Bryk Date: Mon, 18 Mar 2013 20:41:45 -0400 Subject: [PATCH] Disable Vsync while holding tab to disable the frame limit, and allow toggling vsync while emulation is running in OGL. D3D9 still doesn't support changing vsync while emulation is running. Fixes issue 6111. --- Source/Core/Core/Src/Core.cpp | 5 +++++ Source/Core/Core/Src/Core.h | 2 ++ Source/Core/VideoCommon/Src/VideoConfig.cpp | 6 ++++++ Source/Core/VideoCommon/Src/VideoConfig.h | 1 + Source/Plugins/Plugin_VideoDX11/Src/D3DBase.cpp | 2 +- Source/Plugins/Plugin_VideoDX9/Src/D3DBase.cpp | 2 +- Source/Plugins/Plugin_VideoOGL/Src/Render.cpp | 4 +++- 7 files changed, 19 insertions(+), 3 deletions(-) diff --git a/Source/Core/Core/Src/Core.cpp b/Source/Core/Core/Src/Core.cpp index 61e3e404ed..7c0015dbbb 100644 --- a/Source/Core/Core/Src/Core.cpp +++ b/Source/Core/Core/Src/Core.cpp @@ -104,6 +104,7 @@ static bool g_requestRefreshInfo = false; static int g_pauseAndLockDepth = 0; SCoreStartupParameter g_CoreStartupParameter; +bool isTabPressed = false; std::string GetStateFileName() { return g_stateFileName; } void SetStateFileName(std::string val) { g_stateFileName = val; } @@ -603,9 +604,13 @@ void VideoThrottle() u32 TargetVPS = (SConfig::GetInstance().m_Framelimit > 2) ? (SConfig::GetInstance().m_Framelimit - 1) * 5 : VideoInterface::TargetRefreshRate; + if (Host_GetKeyState('\t')) + isTabPressed = true; + // Disable the frame-limiter when the throttle (Tab) key is held down. Audio throttle: m_Framelimit = 2 if (SConfig::GetInstance().m_Framelimit && SConfig::GetInstance().m_Framelimit != 2 && !Host_GetKeyState('\t')) { + isTabPressed = false; u32 frametime = ((SConfig::GetInstance().b_UseFPS)? Common::AtomicLoad(DrawnFrame) : DrawnVideo) * 1000 / TargetVPS; u32 timeDifference = (u32)Timer.GetTimeDifference(); diff --git a/Source/Core/Core/Src/Core.h b/Source/Core/Core/Src/Core.h index ac55419db3..2b88b16510 100644 --- a/Source/Core/Core/Src/Core.h +++ b/Source/Core/Core/Src/Core.h @@ -38,6 +38,8 @@ namespace Core // TODO: kill, use SConfig instead extern SCoreStartupParameter g_CoreStartupParameter; +extern bool isTabPressed; + void Callback_VideoCopiedToXFB(bool video_update); enum EState diff --git a/Source/Core/VideoCommon/Src/VideoConfig.cpp b/Source/Core/VideoCommon/Src/VideoConfig.cpp index 3606d6944b..8ca3026a91 100644 --- a/Source/Core/VideoCommon/Src/VideoConfig.cpp +++ b/Source/Core/VideoCommon/Src/VideoConfig.cpp @@ -22,6 +22,7 @@ #include "VideoConfig.h" #include "VideoCommon.h" #include "FileUtil.h" +#include "Core.h" VideoConfig g_Config; VideoConfig g_ActiveConfig; @@ -292,3 +293,8 @@ void VideoConfig::GameIniSave(const char* default_ini, const char* game_ini) iniFile.Save(game_ini); } + +bool VideoConfig::IsVSync() +{ + return Core::isTabPressed ? false : bVSync; +} diff --git a/Source/Core/VideoCommon/Src/VideoConfig.h b/Source/Core/VideoCommon/Src/VideoConfig.h index d99e8c974e..b43a96e3df 100644 --- a/Source/Core/VideoCommon/Src/VideoConfig.h +++ b/Source/Core/VideoCommon/Src/VideoConfig.h @@ -67,6 +67,7 @@ struct VideoConfig void Save(const char *ini_file); void GameIniSave(const char* default_ini, const char* game_ini); void UpdateProjectionHack(); + bool IsVSync(); // General bool bVSync; diff --git a/Source/Plugins/Plugin_VideoDX11/Src/D3DBase.cpp b/Source/Plugins/Plugin_VideoDX11/Src/D3DBase.cpp index 1dcc6dd193..873f3a47fd 100644 --- a/Source/Plugins/Plugin_VideoDX11/Src/D3DBase.cpp +++ b/Source/Plugins/Plugin_VideoDX11/Src/D3DBase.cpp @@ -520,7 +520,7 @@ void EndFrame() void Present() { // TODO: Is 1 the correct value for vsyncing? - swapchain->Present((UINT)g_ActiveConfig.bVSync, 0); + swapchain->Present((UINT)g_ActiveConfig.IsVSync(), 0); } } // namespace D3D diff --git a/Source/Plugins/Plugin_VideoDX9/Src/D3DBase.cpp b/Source/Plugins/Plugin_VideoDX9/Src/D3DBase.cpp index 31466d1c84..b3d241fe14 100644 --- a/Source/Plugins/Plugin_VideoDX9/Src/D3DBase.cpp +++ b/Source/Plugins/Plugin_VideoDX9/Src/D3DBase.cpp @@ -223,7 +223,7 @@ void InitPP(int adapter, int f, int aa_mode, D3DPRESENT_PARAMETERS *pp) yres = pp->BackBufferHeight = client.bottom - client.top; } pp->SwapEffect = D3DSWAPEFFECT_DISCARD; - pp->PresentationInterval = g_Config.bVSync ? D3DPRESENT_INTERVAL_DEFAULT : D3DPRESENT_INTERVAL_IMMEDIATE; + pp->PresentationInterval = g_Config.IsVSync() ? D3DPRESENT_INTERVAL_DEFAULT : D3DPRESENT_INTERVAL_IMMEDIATE; pp->Windowed = !g_Config.b3DVision; } diff --git a/Source/Plugins/Plugin_VideoOGL/Src/Render.cpp b/Source/Plugins/Plugin_VideoOGL/Src/Render.cpp index 33544d0c5e..05d0adf012 100644 --- a/Source/Plugins/Plugin_VideoOGL/Src/Render.cpp +++ b/Source/Plugins/Plugin_VideoOGL/Src/Render.cpp @@ -314,7 +314,7 @@ Renderer::Renderer() s_backbuffer_height = (int)GLInterface->GetBackBufferHeight(); // Handle VSync on/off - int swapInterval = g_ActiveConfig.bVSync ? 1 : 0; + int swapInterval = g_ActiveConfig.IsVSync() ? 1 : 0; GLInterface->SwapInterval(swapInterval); // check the max texture width and height @@ -1307,6 +1307,8 @@ void Renderer::Swap(u32 xfbAddr, FieldType field, u32 fbWidth, u32 fbHeight,cons GL_REPORT_ERRORD(); + GLInterface->SwapInterval(g_ActiveConfig.IsVSync() ? 1 : 0); + // Clean out old stuff from caches. It's not worth it to clean out the shader caches. DLCache::ProgressiveCleanup(); TextureCache::Cleanup();