gsdx ogl: test adaptive/late vsync driver support

Supported on GLX (but not Linux free driver) and WGL
This commit is contained in:
Gregory Hainaut 2017-07-03 22:36:31 +02:00
parent 2e4643a398
commit 17d2d9217b
4 changed files with 18 additions and 4 deletions

View File

@ -24,7 +24,7 @@
#if defined(__unix__)
GSWndOGL::GSWndOGL()
: m_NativeWindow(0), m_NativeDisplay(NULL), m_context(0), m_swapinterval_ext(NULL), m_swapinterval_mesa(NULL)
: m_NativeWindow(0), m_NativeDisplay(nullptr), m_context(0), m_has_late_vsync(false), m_swapinterval_ext(nullptr), m_swapinterval_mesa(nullptr)
{
}
@ -126,6 +126,9 @@ void GSWndOGL::PopulateWndGlFunction()
{
m_swapinterval_ext = (PFNGLXSWAPINTERVALEXTPROC) glXGetProcAddress((const GLubyte*) "glXSwapIntervalEXT");
m_swapinterval_mesa = (PFNGLXSWAPINTERVALMESAPROC)glXGetProcAddress((const GLubyte*) "glXSwapIntervalMESA");
const char* ext = glXQueryExtensionsString(m_NativeDisplay, DefaultScreen(m_NativeDisplay));
m_has_late_vsync = m_swapinterval_ext && ext && strstr(ext, "GLX_EXT_swap_control");
}
bool GSWndOGL::Attach(void* handle, bool managed)

View File

@ -30,6 +30,7 @@ class GSWndOGL final : public GSWndGL
Window m_NativeWindow;
Display* m_NativeDisplay;
GLXContext m_context;
bool m_has_late_vsync;
PFNGLXSWAPINTERVALEXTPROC m_swapinterval_ext;
PFNGLXSWAPINTERVALMESAPROC m_swapinterval_mesa;
@ -38,7 +39,7 @@ class GSWndOGL final : public GSWndGL
void CreateContext(int major, int minor);
void SetSwapInterval(int vsync);
bool HasLateVsyncSupport() { return false; }
bool HasLateVsyncSupport() { return m_has_late_vsync; }
public:
GSWndOGL();

View File

@ -40,7 +40,7 @@ static void win_error(const char* msg, bool fatal = true)
GSWndWGL::GSWndWGL()
: m_NativeWindow(NULL), m_NativeDisplay(NULL), m_context(NULL)
: m_NativeWindow(nullptr), m_NativeDisplay(nullptr), m_context(nullptr), m_has_late_vsync(false)
{
}
@ -142,6 +142,15 @@ void GSWndWGL::DetachContext()
void GSWndWGL::PopulateWndGlFunction()
{
m_swapinterval = (PFNWGLSWAPINTERVALEXTPROC)wglGetProcAddress("wglSwapIntervalEXT");
// To ease the process, extension management is itself an extension. Clever isn't it!
PFNWGLGETEXTENSIONSSTRINGARBPROC wglGetExtensionsStringARB = (PFNWGLGETEXTENSIONSSTRINGARBPROC)wglGetProcAddress("wglGetExtensionsStringARB");
if (wglGetExtensionsStringARB) {
const char* ext = wglGetExtensionsStringARB(m_NativeDisplay);
m_has_late_vsync = m_swapinterval && ext && strstr(ext, "WGL_EXT_swap_control_tear");
} else {
m_has_late_vsync = false;
}
}
bool GSWndWGL::Attach(void* handle, bool managed)

View File

@ -28,6 +28,7 @@ class GSWndWGL : public GSWndGL
HWND m_NativeWindow;
HDC m_NativeDisplay;
HGLRC m_context;
bool m_has_late_vsync;
PFNWGLSWAPINTERVALEXTPROC m_swapinterval;
@ -38,7 +39,7 @@ class GSWndWGL : public GSWndGL
void OpenWGLDisplay();
void SetSwapInterval(int vsync);
bool HasLateVsyncSupport() { return false; }
bool HasLateVsyncSupport() { return m_has_late_vsync; }
static LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam);