mirror of https://github.com/PCSX2/pcsx2.git
gsdx ogl: test adaptive/late vsync driver support
Supported on GLX (but not Linux free driver) and WGL
This commit is contained in:
parent
2e4643a398
commit
17d2d9217b
|
@ -24,7 +24,7 @@
|
||||||
|
|
||||||
#if defined(__unix__)
|
#if defined(__unix__)
|
||||||
GSWndOGL::GSWndOGL()
|
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_ext = (PFNGLXSWAPINTERVALEXTPROC) glXGetProcAddress((const GLubyte*) "glXSwapIntervalEXT");
|
||||||
m_swapinterval_mesa = (PFNGLXSWAPINTERVALMESAPROC)glXGetProcAddress((const GLubyte*) "glXSwapIntervalMESA");
|
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)
|
bool GSWndOGL::Attach(void* handle, bool managed)
|
||||||
|
|
|
@ -30,6 +30,7 @@ class GSWndOGL final : public GSWndGL
|
||||||
Window m_NativeWindow;
|
Window m_NativeWindow;
|
||||||
Display* m_NativeDisplay;
|
Display* m_NativeDisplay;
|
||||||
GLXContext m_context;
|
GLXContext m_context;
|
||||||
|
bool m_has_late_vsync;
|
||||||
|
|
||||||
PFNGLXSWAPINTERVALEXTPROC m_swapinterval_ext;
|
PFNGLXSWAPINTERVALEXTPROC m_swapinterval_ext;
|
||||||
PFNGLXSWAPINTERVALMESAPROC m_swapinterval_mesa;
|
PFNGLXSWAPINTERVALMESAPROC m_swapinterval_mesa;
|
||||||
|
@ -38,7 +39,7 @@ class GSWndOGL final : public GSWndGL
|
||||||
void CreateContext(int major, int minor);
|
void CreateContext(int major, int minor);
|
||||||
|
|
||||||
void SetSwapInterval(int vsync);
|
void SetSwapInterval(int vsync);
|
||||||
bool HasLateVsyncSupport() { return false; }
|
bool HasLateVsyncSupport() { return m_has_late_vsync; }
|
||||||
|
|
||||||
public:
|
public:
|
||||||
GSWndOGL();
|
GSWndOGL();
|
||||||
|
|
|
@ -40,7 +40,7 @@ static void win_error(const char* msg, bool fatal = true)
|
||||||
|
|
||||||
|
|
||||||
GSWndWGL::GSWndWGL()
|
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()
|
void GSWndWGL::PopulateWndGlFunction()
|
||||||
{
|
{
|
||||||
m_swapinterval = (PFNWGLSWAPINTERVALEXTPROC)wglGetProcAddress("wglSwapIntervalEXT");
|
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)
|
bool GSWndWGL::Attach(void* handle, bool managed)
|
||||||
|
|
|
@ -28,6 +28,7 @@ class GSWndWGL : public GSWndGL
|
||||||
HWND m_NativeWindow;
|
HWND m_NativeWindow;
|
||||||
HDC m_NativeDisplay;
|
HDC m_NativeDisplay;
|
||||||
HGLRC m_context;
|
HGLRC m_context;
|
||||||
|
bool m_has_late_vsync;
|
||||||
|
|
||||||
PFNWGLSWAPINTERVALEXTPROC m_swapinterval;
|
PFNWGLSWAPINTERVALEXTPROC m_swapinterval;
|
||||||
|
|
||||||
|
@ -38,7 +39,7 @@ class GSWndWGL : public GSWndGL
|
||||||
void OpenWGLDisplay();
|
void OpenWGLDisplay();
|
||||||
|
|
||||||
void SetSwapInterval(int vsync);
|
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);
|
static LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue