Only use glXCreateContext if glXCreateContextAttribsARB did not succeed.
If glXCreateContextAttribsARB does not succeed or is not available, we should fallback to using glXCreateContext. But we should not just create a context with glXCreateContext by default that is being thrown away if glXCreateContextAttribsARB succeeds. Otherwise glXMakeCurrent with context 0 might cause an unexpected context change when dealing with multiple contexts. Change-Id: I7627abbe2500b4006180653a1b3b074fe7aca1d3 Reviewed-by: Sean Harmer <sean.harmer@kdab.com>
This commit is contained in:
parent
41379f9580
commit
9828dace05
@ -88,13 +88,6 @@ QGLXContext::QGLXContext(QXcbScreen *screen, const QSurfaceFormat &format, QPlat
|
||||
GLXFBConfig config = qglx_findConfig(DISPLAY_FROM_XCB(screen),screen->screenNumber(),format);
|
||||
|
||||
if (config) {
|
||||
m_context = glXCreateNewContext(DISPLAY_FROM_XCB(screen), config, GLX_RGBA_TYPE, m_shareContext, TRUE);
|
||||
if (!m_context && m_shareContext) {
|
||||
// re-try without a shared glx context
|
||||
m_shareContext = 0;
|
||||
m_context = glXCreateNewContext(DISPLAY_FROM_XCB(screen), config, GLX_RGBA_TYPE, 0, TRUE);
|
||||
}
|
||||
|
||||
// Resolve entry point for glXCreateContextAttribsARB
|
||||
glXCreateContextAttribsARBProc glXCreateContextAttribsARB = 0;
|
||||
glXCreateContextAttribsARB = (glXCreateContextAttribsARBProc) glXGetProcAddress((const GLubyte*)"glXCreateContextAttribsARB");
|
||||
@ -116,19 +109,23 @@ QGLXContext::QGLXContext(QXcbScreen *screen, const QSurfaceFormat &format, QPlat
|
||||
|
||||
contextAttributes << None;
|
||||
|
||||
GLXContext context = 0;
|
||||
context = glXCreateContextAttribsARB(DISPLAY_FROM_XCB(screen), config, m_shareContext, true, contextAttributes.data());
|
||||
m_context = glXCreateContextAttribsARB(DISPLAY_FROM_XCB(screen), config, m_shareContext, true, contextAttributes.data());
|
||||
if (!m_context && m_shareContext) {
|
||||
// re-try without a shared glx context
|
||||
m_shareContext = 0;
|
||||
context = glXCreateContextAttribsARB(DISPLAY_FROM_XCB(screen), config, 0, true, contextAttributes.data());
|
||||
m_context = glXCreateContextAttribsARB(DISPLAY_FROM_XCB(screen), config, 0, true, contextAttributes.data());
|
||||
if (m_context)
|
||||
m_shareContext = 0;
|
||||
}
|
||||
}
|
||||
|
||||
// Set this as our context and destroy the old context
|
||||
if (context) {
|
||||
glXMakeCurrent(DISPLAY_FROM_XCB(screen), 0, 0);
|
||||
glXDestroyContext(DISPLAY_FROM_XCB(screen), m_context);
|
||||
m_context = context;
|
||||
// Could not create a context using glXCreateContextAttribsARB, falling back to glXCreateNewContext.
|
||||
if (!m_context) {
|
||||
m_context = glXCreateNewContext(DISPLAY_FROM_XCB(screen), config, GLX_RGBA_TYPE, m_shareContext, TRUE);
|
||||
if (!m_context && m_shareContext) {
|
||||
// re-try without a shared glx context
|
||||
m_context = glXCreateNewContext(DISPLAY_FROM_XCB(screen), config, GLX_RGBA_TYPE, 0, TRUE);
|
||||
if (m_context)
|
||||
m_shareContext = 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user