gsdx ogl: factorize SetVSync

Move common logic into base class
Add API to handle late Vsync (only stub)
This commit is contained in:
Gregory Hainaut 2017-07-03 22:13:59 +02:00
parent 2204885fbb
commit 2e4643a398
8 changed files with 28 additions and 8 deletions

View File

@ -191,3 +191,13 @@ void GSWndGL::FullContextInit()
PopulateGlFunction();
PopulateWndGlFunction();
}
void GSWndGL::SetVSync(int vsync)
{
if (!HasLateVsyncSupport() && vsync < 0)
m_vsync = -vsync; // Late vsync not supported, fallback to standard vsync
else
m_vsync = vsync;
SetSwapInterval(m_vsync);
}

View File

@ -60,6 +60,7 @@ class GSWndGL : public GSWnd
{
protected:
bool m_ctx_attached;
int m_vsync;
bool IsContextAttached() const { return m_ctx_attached; }
void PopulateGlFunction();
@ -67,8 +68,11 @@ protected:
void FullContextInit();
virtual void CreateContext(int major, int minor) = 0;
virtual void SetSwapInterval(int vsync) = 0;
virtual bool HasLateVsyncSupport() = 0;
public:
GSWndGL() : m_ctx_attached(false) {};
GSWndGL() : m_ctx_attached(false), m_vsync(0) {};
virtual ~GSWndGL() {};
virtual bool Create(const string& title, int w, int h) = 0;
@ -88,5 +92,5 @@ public:
virtual void Hide() = 0;
virtual void HideFrame() = 0;
virtual void Flip() = 0;
virtual void SetVSync(int vsync) = 0;
virtual void SetVSync(int vsync) final;
};

View File

@ -235,7 +235,7 @@ GSVector4i GSWndEGL::GetClientRect()
return GSVector4i(0, 0, w, h);
}
void GSWndEGL::SetVSync(int vsync)
void GSWndEGL::SetSwapInterval(int vsync)
{
// 0 -> disable vsync
// n -> wait n frame

View File

@ -42,6 +42,9 @@ class GSWndEGL : public GSWndGL
void CreateContext(int major, int minor);
void BindAPI();
void SetSwapInterval(int vsync) final;
bool HasLateVsyncSupport() final { return false; }
void OpenEGLDisplay();
void CloseEGLDisplay();
@ -66,7 +69,6 @@ public:
void* GetProcAddress(const char* name, bool opt = false) final;
void Flip() final;
void SetVSync(int vsync) final;
// Deprecated API
void Show() final {};

View File

@ -235,7 +235,7 @@ bool GSWndOGL::SetWindowText(const char* title)
return true;
}
void GSWndOGL::SetVSync(int vsync)
void GSWndOGL::SetSwapInterval(int vsync)
{
// m_swapinterval uses an integer as parameter
// 0 -> disable vsync

View File

@ -37,6 +37,9 @@ class GSWndOGL final : public GSWndGL
void PopulateWndGlFunction();
void CreateContext(int major, int minor);
void SetSwapInterval(int vsync);
bool HasLateVsyncSupport() { return false; }
public:
GSWndOGL();
virtual ~GSWndOGL() {};
@ -58,7 +61,6 @@ public:
void Hide();
void HideFrame();
void Flip();
void SetVSync(int vsync);
};
#endif

View File

@ -315,7 +315,7 @@ void* GSWndWGL::GetProcAddress(const char* name, bool opt)
//TODO: check extensions supported or not
//FIXME : extension allocation
void GSWndWGL::SetVSync(int vsync)
void GSWndWGL::SetSwapInterval(int vsync)
{
// m_swapinterval uses an integer as parameter
// 0 -> disable vsync

View File

@ -37,6 +37,9 @@ class GSWndWGL : public GSWndGL
void CloseWGLDisplay();
void OpenWGLDisplay();
void SetSwapInterval(int vsync);
bool HasLateVsyncSupport() { return false; }
static LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam);
public:
@ -60,7 +63,6 @@ public:
void Hide();
void HideFrame();
void Flip();
void SetVSync(int vsync);
};
#endif