From 4768f912b8c0f1b81d27884b1c8d166d8d7962a9 Mon Sep 17 00:00:00 2001 From: Gregory Hainaut Date: Sat, 4 Jun 2016 13:17:59 +0200 Subject: [PATCH] gsdx linux: add vsync support for free driver --- plugins/GSdx/GSWndOGL.cpp | 12 ++++++++---- plugins/GSdx/GSWndOGL.h | 3 ++- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/plugins/GSdx/GSWndOGL.cpp b/plugins/GSdx/GSWndOGL.cpp index f664eaafa0..42447f4a4a 100644 --- a/plugins/GSdx/GSWndOGL.cpp +++ b/plugins/GSdx/GSWndOGL.cpp @@ -24,7 +24,7 @@ #if defined(__unix__) GSWndOGL::GSWndOGL() - : m_NativeWindow(0), m_NativeDisplay(NULL), m_context(0), m_swapinterval(NULL) + : m_NativeWindow(0), m_NativeDisplay(NULL), m_context(0), m_swapinterval_ext(NULL), m_swapinterval_mesa(NULL) { } @@ -147,7 +147,8 @@ bool GSWndOGL::Attach(void* handle, bool managed) CheckContext(); - m_swapinterval = (PFNGLXSWAPINTERVALEXTPROC)glXGetProcAddress((const GLubyte*) "glXSwapIntervalEXT"); + m_swapinterval_ext = (PFNGLXSWAPINTERVALEXTPROC) glXGetProcAddress((const GLubyte*) "glXSwapIntervalEXT"); + m_swapinterval_mesa = (PFNGLXSWAPINTERVALMESAPROC)glXGetProcAddress((const GLubyte*) "glXSwapIntervalMESA"); PopulateGlFunction(); @@ -194,7 +195,8 @@ bool GSWndOGL::Create(const string& title, int w, int h) CheckContext(); - m_swapinterval = (PFNGLXSWAPINTERVALEXTPROC)glXGetProcAddress((const GLubyte*) "glXSwapIntervalEXT"); + m_swapinterval_ext = (PFNGLXSWAPINTERVALEXTPROC) glXGetProcAddress((const GLubyte*) "glXSwapIntervalEXT"); + m_swapinterval_mesa = (PFNGLXSWAPINTERVALMESAPROC)glXGetProcAddress((const GLubyte*) "glXSwapIntervalMESA"); PopulateGlFunction(); @@ -262,7 +264,9 @@ void GSWndOGL::SetVSync(bool enable) // m_swapinterval uses an integer as parameter // 0 -> disable vsync // n -> wait n frame - if (m_swapinterval) m_swapinterval(m_NativeDisplay, m_NativeWindow, (int)enable); + if (m_swapinterval_ext) m_swapinterval_ext(m_NativeDisplay, m_NativeWindow, (int)enable); + else if (m_swapinterval_mesa) m_swapinterval_mesa((int)enable); + else fprintf(stderr, "Failed to set VSync\n"); } void GSWndOGL::Flip() diff --git a/plugins/GSdx/GSWndOGL.h b/plugins/GSdx/GSWndOGL.h index c54e6f24e3..a4a1e362e9 100644 --- a/plugins/GSdx/GSWndOGL.h +++ b/plugins/GSdx/GSWndOGL.h @@ -31,7 +31,8 @@ class GSWndOGL final : public GSWndGL Display* m_NativeDisplay; GLXContext m_context; - PFNGLXSWAPINTERVALEXTPROC m_swapinterval; + PFNGLXSWAPINTERVALEXTPROC m_swapinterval_ext; + PFNGLXSWAPINTERVALMESAPROC m_swapinterval_mesa; void CreateContext(int major, int minor); void CheckContext();