Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
RachelBryk committed Mar 19, 2013
1 parent c5033e8 commit 7c2c466
Show file tree
Hide file tree
Showing 7 changed files with 19 additions and 3 deletions.
5 changes: 5 additions & 0 deletions Source/Core/Core/Src/Core.cpp
Expand Up @@ -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; }
Expand Down Expand Up @@ -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();
Expand Down
2 changes: 2 additions & 0 deletions Source/Core/Core/Src/Core.h
Expand Up @@ -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
Expand Down
6 changes: 6 additions & 0 deletions Source/Core/VideoCommon/Src/VideoConfig.cpp
Expand Up @@ -22,6 +22,7 @@
#include "VideoConfig.h"
#include "VideoCommon.h"
#include "FileUtil.h"
#include "Core.h"

VideoConfig g_Config;
VideoConfig g_ActiveConfig;
Expand Down Expand Up @@ -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;
}
1 change: 1 addition & 0 deletions Source/Core/VideoCommon/Src/VideoConfig.h
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion Source/Plugins/Plugin_VideoDX11/Src/D3DBase.cpp
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion Source/Plugins/Plugin_VideoDX9/Src/D3DBase.cpp
Expand Up @@ -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;
}

Expand Down
4 changes: 3 additions & 1 deletion Source/Plugins/Plugin_VideoOGL/Src/Render.cpp
Expand Up @@ -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
Expand Down Expand Up @@ -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();
Expand Down

0 comments on commit 7c2c466

Please sign in to comment.