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.
This commit is contained in:
Rachel Bryk 2013-03-18 20:41:45 -04:00
parent c5033e8594
commit 7c2c4662a7
7 changed files with 19 additions and 3 deletions

View File

@ -104,6 +104,7 @@ static bool g_requestRefreshInfo = false;
static int g_pauseAndLockDepth = 0; static int g_pauseAndLockDepth = 0;
SCoreStartupParameter g_CoreStartupParameter; SCoreStartupParameter g_CoreStartupParameter;
bool isTabPressed = false;
std::string GetStateFileName() { return g_stateFileName; } std::string GetStateFileName() { return g_stateFileName; }
void SetStateFileName(std::string val) { g_stateFileName = val; } void SetStateFileName(std::string val) { g_stateFileName = val; }
@ -603,9 +604,13 @@ void VideoThrottle()
u32 TargetVPS = (SConfig::GetInstance().m_Framelimit > 2) ? u32 TargetVPS = (SConfig::GetInstance().m_Framelimit > 2) ?
(SConfig::GetInstance().m_Framelimit - 1) * 5 : VideoInterface::TargetRefreshRate; (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 // 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')) 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 frametime = ((SConfig::GetInstance().b_UseFPS)? Common::AtomicLoad(DrawnFrame) : DrawnVideo) * 1000 / TargetVPS;
u32 timeDifference = (u32)Timer.GetTimeDifference(); u32 timeDifference = (u32)Timer.GetTimeDifference();

View File

@ -38,6 +38,8 @@ namespace Core
// TODO: kill, use SConfig instead // TODO: kill, use SConfig instead
extern SCoreStartupParameter g_CoreStartupParameter; extern SCoreStartupParameter g_CoreStartupParameter;
extern bool isTabPressed;
void Callback_VideoCopiedToXFB(bool video_update); void Callback_VideoCopiedToXFB(bool video_update);
enum EState enum EState

View File

@ -22,6 +22,7 @@
#include "VideoConfig.h" #include "VideoConfig.h"
#include "VideoCommon.h" #include "VideoCommon.h"
#include "FileUtil.h" #include "FileUtil.h"
#include "Core.h"
VideoConfig g_Config; VideoConfig g_Config;
VideoConfig g_ActiveConfig; VideoConfig g_ActiveConfig;
@ -292,3 +293,8 @@ void VideoConfig::GameIniSave(const char* default_ini, const char* game_ini)
iniFile.Save(game_ini); iniFile.Save(game_ini);
} }
bool VideoConfig::IsVSync()
{
return Core::isTabPressed ? false : bVSync;
}

View File

@ -67,6 +67,7 @@ struct VideoConfig
void Save(const char *ini_file); void Save(const char *ini_file);
void GameIniSave(const char* default_ini, const char* game_ini); void GameIniSave(const char* default_ini, const char* game_ini);
void UpdateProjectionHack(); void UpdateProjectionHack();
bool IsVSync();
// General // General
bool bVSync; bool bVSync;

View File

@ -520,7 +520,7 @@ void EndFrame()
void Present() void Present()
{ {
// TODO: Is 1 the correct value for vsyncing? // TODO: Is 1 the correct value for vsyncing?
swapchain->Present((UINT)g_ActiveConfig.bVSync, 0); swapchain->Present((UINT)g_ActiveConfig.IsVSync(), 0);
} }
} // namespace D3D } // namespace D3D

View File

@ -223,7 +223,7 @@ void InitPP(int adapter, int f, int aa_mode, D3DPRESENT_PARAMETERS *pp)
yres = pp->BackBufferHeight = client.bottom - client.top; yres = pp->BackBufferHeight = client.bottom - client.top;
} }
pp->SwapEffect = D3DSWAPEFFECT_DISCARD; 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; pp->Windowed = !g_Config.b3DVision;
} }

View File

@ -314,7 +314,7 @@ Renderer::Renderer()
s_backbuffer_height = (int)GLInterface->GetBackBufferHeight(); s_backbuffer_height = (int)GLInterface->GetBackBufferHeight();
// Handle VSync on/off // Handle VSync on/off
int swapInterval = g_ActiveConfig.bVSync ? 1 : 0; int swapInterval = g_ActiveConfig.IsVSync() ? 1 : 0;
GLInterface->SwapInterval(swapInterval); GLInterface->SwapInterval(swapInterval);
// check the max texture width and height // 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(); 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. // Clean out old stuff from caches. It's not worth it to clean out the shader caches.
DLCache::ProgressiveCleanup(); DLCache::ProgressiveCleanup();
TextureCache::Cleanup(); TextureCache::Cleanup();