summaryrefslogtreecommitdiff
path: root/Source/Core/Common/GL/GLInterface/GLX.cpp
diff options
context:
space:
mode:
authorAnthony <Helios747@users.noreply.github.com>2017-08-05 00:54:28 -0700
committerGitHub <noreply@github.com>2017-08-05 00:54:28 -0700
commit3c5112bb21d2829c48622467c1993c3deb3e4412 (patch)
treebcd8a44ba1e7a63c85712fe9469f9db623cce77c /Source/Core/Common/GL/GLInterface/GLX.cpp
parent4f2fd3a9e527358694c594b0eafbe1865979d3c3 (diff)
parent287859c5e13f2e6e35edc021bccf9ef08737537d (diff)
Merge pull request #5856 from stenzek/optimus-crash
Fix ubershader crashes with primus/bumblebee
Diffstat (limited to 'Source/Core/Common/GL/GLInterface/GLX.cpp')
-rw-r--r--Source/Core/Common/GL/GLInterface/GLX.cpp19
1 files changed, 13 insertions, 6 deletions
diff --git a/Source/Core/Common/GL/GLInterface/GLX.cpp b/Source/Core/Common/GL/GLInterface/GLX.cpp
index e6a018e1d3..3a9a601838 100644
--- a/Source/Core/Common/GL/GLInterface/GLX.cpp
+++ b/Source/Core/Common/GL/GLInterface/GLX.cpp
@@ -148,9 +148,9 @@ bool cInterfaceGLX::Create(void* window_handle, bool stereo, bool core)
if (!ctx || s_glxError)
{
ERROR_LOG(VIDEO, "Unable to create GL context.");
+ XSetErrorHandler(oldHandler);
return false;
}
- XSetErrorHandler(oldHandler);
std::string tmp;
std::istringstream buffer(glXQueryExtensionsString(dpy, screen));
@@ -172,8 +172,11 @@ bool cInterfaceGLX::Create(void* window_handle, bool stereo, bool core)
if (!CreateWindowSurface())
{
ERROR_LOG(VIDEO, "Error: CreateWindowSurface failed\n");
+ XSetErrorHandler(oldHandler);
return false;
}
+
+ XSetErrorHandler(oldHandler);
return true;
}
@@ -182,6 +185,7 @@ bool cInterfaceGLX::Create(cInterfaceBase* main_context)
cInterfaceGLX* glx_context = static_cast<cInterfaceGLX*>(main_context);
m_has_handle = false;
+ m_supports_pbuffer = glx_context->m_supports_pbuffer;
dpy = glx_context->dpy;
fbconfig = glx_context->fbconfig;
s_glxError = false;
@@ -193,15 +197,18 @@ bool cInterfaceGLX::Create(cInterfaceBase* main_context)
if (!ctx || s_glxError)
{
ERROR_LOG(VIDEO, "Unable to create GL context.");
+ XSetErrorHandler(oldHandler);
return false;
}
- XSetErrorHandler(oldHandler);
- if (!CreateWindowSurface())
+ if (m_supports_pbuffer && !CreateWindowSurface())
{
ERROR_LOG(VIDEO, "Error: CreateWindowSurface failed\n");
+ XSetErrorHandler(oldHandler);
return false;
}
+
+ XSetErrorHandler(oldHandler);
return true;
}
@@ -235,7 +242,7 @@ bool cInterfaceGLX::CreateWindowSurface()
win = XWindow.CreateXWindow(m_host_window, vi);
XFree(vi);
}
- else
+ else if (m_supports_pbuffer)
{
win = m_pbuffer = glXCreateGLXPbufferSGIX(dpy, fbconfig, 1, 1, nullptr);
if (!m_pbuffer)
@@ -247,11 +254,11 @@ bool cInterfaceGLX::CreateWindowSurface()
void cInterfaceGLX::DestroyWindowSurface()
{
- if (!m_pbuffer)
+ if (m_has_handle)
{
XWindow.DestroyXWindow();
}
- else
+ else if (m_supports_pbuffer && m_pbuffer)
{
glXDestroyGLXPbufferSGIX(dpy, m_pbuffer);
m_pbuffer = 0;