mirror of https://github.com/PCSX2/pcsx2.git
gsdx ogl: factorize SetVSync
Move common logic into base class Add API to handle late Vsync (only stub)
This commit is contained in:
parent
2204885fbb
commit
2e4643a398
|
@ -191,3 +191,13 @@ void GSWndGL::FullContextInit()
|
||||||
PopulateGlFunction();
|
PopulateGlFunction();
|
||||||
PopulateWndGlFunction();
|
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);
|
||||||
|
}
|
||||||
|
|
|
@ -60,6 +60,7 @@ class GSWndGL : public GSWnd
|
||||||
{
|
{
|
||||||
protected:
|
protected:
|
||||||
bool m_ctx_attached;
|
bool m_ctx_attached;
|
||||||
|
int m_vsync;
|
||||||
|
|
||||||
bool IsContextAttached() const { return m_ctx_attached; }
|
bool IsContextAttached() const { return m_ctx_attached; }
|
||||||
void PopulateGlFunction();
|
void PopulateGlFunction();
|
||||||
|
@ -67,8 +68,11 @@ protected:
|
||||||
void FullContextInit();
|
void FullContextInit();
|
||||||
virtual void CreateContext(int major, int minor) = 0;
|
virtual void CreateContext(int major, int minor) = 0;
|
||||||
|
|
||||||
|
virtual void SetSwapInterval(int vsync) = 0;
|
||||||
|
virtual bool HasLateVsyncSupport() = 0;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
GSWndGL() : m_ctx_attached(false) {};
|
GSWndGL() : m_ctx_attached(false), m_vsync(0) {};
|
||||||
virtual ~GSWndGL() {};
|
virtual ~GSWndGL() {};
|
||||||
|
|
||||||
virtual bool Create(const string& title, int w, int h) = 0;
|
virtual bool Create(const string& title, int w, int h) = 0;
|
||||||
|
@ -88,5 +92,5 @@ public:
|
||||||
virtual void Hide() = 0;
|
virtual void Hide() = 0;
|
||||||
virtual void HideFrame() = 0;
|
virtual void HideFrame() = 0;
|
||||||
virtual void Flip() = 0;
|
virtual void Flip() = 0;
|
||||||
virtual void SetVSync(int vsync) = 0;
|
virtual void SetVSync(int vsync) final;
|
||||||
};
|
};
|
||||||
|
|
|
@ -235,7 +235,7 @@ GSVector4i GSWndEGL::GetClientRect()
|
||||||
return GSVector4i(0, 0, w, h);
|
return GSVector4i(0, 0, w, h);
|
||||||
}
|
}
|
||||||
|
|
||||||
void GSWndEGL::SetVSync(int vsync)
|
void GSWndEGL::SetSwapInterval(int vsync)
|
||||||
{
|
{
|
||||||
// 0 -> disable vsync
|
// 0 -> disable vsync
|
||||||
// n -> wait n frame
|
// n -> wait n frame
|
||||||
|
|
|
@ -42,6 +42,9 @@ class GSWndEGL : public GSWndGL
|
||||||
void CreateContext(int major, int minor);
|
void CreateContext(int major, int minor);
|
||||||
void BindAPI();
|
void BindAPI();
|
||||||
|
|
||||||
|
void SetSwapInterval(int vsync) final;
|
||||||
|
bool HasLateVsyncSupport() final { return false; }
|
||||||
|
|
||||||
void OpenEGLDisplay();
|
void OpenEGLDisplay();
|
||||||
void CloseEGLDisplay();
|
void CloseEGLDisplay();
|
||||||
|
|
||||||
|
@ -66,7 +69,6 @@ public:
|
||||||
void* GetProcAddress(const char* name, bool opt = false) final;
|
void* GetProcAddress(const char* name, bool opt = false) final;
|
||||||
|
|
||||||
void Flip() final;
|
void Flip() final;
|
||||||
void SetVSync(int vsync) final;
|
|
||||||
|
|
||||||
// Deprecated API
|
// Deprecated API
|
||||||
void Show() final {};
|
void Show() final {};
|
||||||
|
|
|
@ -235,7 +235,7 @@ bool GSWndOGL::SetWindowText(const char* title)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void GSWndOGL::SetVSync(int vsync)
|
void GSWndOGL::SetSwapInterval(int vsync)
|
||||||
{
|
{
|
||||||
// m_swapinterval uses an integer as parameter
|
// m_swapinterval uses an integer as parameter
|
||||||
// 0 -> disable vsync
|
// 0 -> disable vsync
|
||||||
|
|
|
@ -37,6 +37,9 @@ class GSWndOGL final : public GSWndGL
|
||||||
void PopulateWndGlFunction();
|
void PopulateWndGlFunction();
|
||||||
void CreateContext(int major, int minor);
|
void CreateContext(int major, int minor);
|
||||||
|
|
||||||
|
void SetSwapInterval(int vsync);
|
||||||
|
bool HasLateVsyncSupport() { return false; }
|
||||||
|
|
||||||
public:
|
public:
|
||||||
GSWndOGL();
|
GSWndOGL();
|
||||||
virtual ~GSWndOGL() {};
|
virtual ~GSWndOGL() {};
|
||||||
|
@ -58,7 +61,6 @@ public:
|
||||||
void Hide();
|
void Hide();
|
||||||
void HideFrame();
|
void HideFrame();
|
||||||
void Flip();
|
void Flip();
|
||||||
void SetVSync(int vsync);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -315,7 +315,7 @@ void* GSWndWGL::GetProcAddress(const char* name, bool opt)
|
||||||
|
|
||||||
//TODO: check extensions supported or not
|
//TODO: check extensions supported or not
|
||||||
//FIXME : extension allocation
|
//FIXME : extension allocation
|
||||||
void GSWndWGL::SetVSync(int vsync)
|
void GSWndWGL::SetSwapInterval(int vsync)
|
||||||
{
|
{
|
||||||
// m_swapinterval uses an integer as parameter
|
// m_swapinterval uses an integer as parameter
|
||||||
// 0 -> disable vsync
|
// 0 -> disable vsync
|
||||||
|
|
|
@ -37,6 +37,9 @@ class GSWndWGL : public GSWndGL
|
||||||
void CloseWGLDisplay();
|
void CloseWGLDisplay();
|
||||||
void OpenWGLDisplay();
|
void OpenWGLDisplay();
|
||||||
|
|
||||||
|
void SetSwapInterval(int vsync);
|
||||||
|
bool HasLateVsyncSupport() { return false; }
|
||||||
|
|
||||||
static LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam);
|
static LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
@ -60,7 +63,6 @@ public:
|
||||||
void Hide();
|
void Hide();
|
||||||
void HideFrame();
|
void HideFrame();
|
||||||
void Flip();
|
void Flip();
|
||||||
void SetVSync(int vsync);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Reference in New Issue