OpenGL: Blender 2.8 on X11 requires GL 3.0
Implements the Linux part of T49012. Simplify the options for context creation. No options for legacy GL or EGL or ES2. Select 3.2 CORE or COMPATIBILITY profile at build time. If that fails, use a GL 3.0 context. This keeps Mesa supported while we work on full 3.2 core elsewhere in the code.
This commit is contained in:
@@ -255,9 +255,6 @@ const bool GLXEW_ARB_create_context_robustness =
|
||||
if (m_contextMajorVersion != 0) {
|
||||
attribs[i++] = GLX_CONTEXT_MAJOR_VERSION_ARB;
|
||||
attribs[i++] = m_contextMajorVersion;
|
||||
}
|
||||
|
||||
if (m_contextMinorVersion != 0) {
|
||||
attribs[i++] = GLX_CONTEXT_MINOR_VERSION_ARB;
|
||||
attribs[i++] = m_contextMinorVersion;
|
||||
}
|
||||
@@ -300,8 +297,8 @@ const bool GLXEW_ARB_create_context_robustness =
|
||||
}
|
||||
}
|
||||
else {
|
||||
/* Create legacy context */
|
||||
m_context = glXCreateContext(m_display, m_visualInfo, s_sharedContext, True);
|
||||
/* Don't create legacy context */
|
||||
fprintf(stderr, "Warning! GLX_ARB_create_context not available.\n");
|
||||
}
|
||||
|
||||
GHOST_TSuccess success;
|
||||
@@ -328,8 +325,14 @@ const bool GLXEW_ARB_create_context_robustness =
|
||||
|
||||
version = glGetString(GL_VERSION);
|
||||
|
||||
if (!version || version[0] < '2' || ((version[0] == '2') && (version[2] < '1'))) {
|
||||
fprintf(stderr, "Error! Blender requires OpenGL 2.1 to run. Try updating your drivers.\n");
|
||||
#if 0 // enable this when Blender switches to 3.2 core profile
|
||||
if (!version || version[0] < '3' || ((version[0] == '3') && (version[2] < '2'))) {
|
||||
fprintf(stderr, "Error! Blender requires OpenGL 3.2 to run. Try updating your drivers.\n");
|
||||
#else
|
||||
// with Mesa, the closest thing to 3.2 compatibility profile is 3.0
|
||||
if (!version || version[0] < '3') {
|
||||
fprintf(stderr, "Error! Blender requires OpenGL 3.0 (soon 3.2) to run. Try updating your drivers.\n");
|
||||
#endif
|
||||
fflush(stderr);
|
||||
/* ugly, but we get crashes unless a whole bunch of systems are patched. */
|
||||
exit(0);
|
||||
|
||||
@@ -1301,9 +1301,24 @@ GHOST_WindowX11::
|
||||
GHOST_Context *GHOST_WindowX11::newDrawingContext(GHOST_TDrawingContextType type)
|
||||
{
|
||||
if (type == GHOST_kDrawingContextTypeOpenGL) {
|
||||
#if !defined(WITH_GL_EGL)
|
||||
|
||||
// During development:
|
||||
// try 3.2 compatibility profile
|
||||
// fall back to 3.0 if needed
|
||||
//
|
||||
// Final Blender 2.8:
|
||||
// try 3.2 core profile
|
||||
// no fallbacks
|
||||
|
||||
const int profile_mask =
|
||||
#if defined(WITH_GL_PROFILE_CORE)
|
||||
GLX_CONTEXT_CORE_PROFILE_BIT_ARB;
|
||||
#elif defined(WITH_GL_PROFILE_COMPAT)
|
||||
GLX_CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB;
|
||||
#else
|
||||
# error // must specify either core or compat at build time
|
||||
#endif
|
||||
|
||||
GHOST_Context *context = new GHOST_ContextGLX(
|
||||
m_wantStereoVisual,
|
||||
m_wantNumOfAASamples,
|
||||
@@ -1311,82 +1326,34 @@ GHOST_Context *GHOST_WindowX11::newDrawingContext(GHOST_TDrawingContextType type
|
||||
m_display,
|
||||
m_visualInfo,
|
||||
(GLXFBConfig)m_fbconfig,
|
||||
GLX_CONTEXT_CORE_PROFILE_BIT_ARB,
|
||||
profile_mask,
|
||||
3, 2,
|
||||
GHOST_OPENGL_GLX_CONTEXT_FLAGS | (m_is_debug_context ? GLX_CONTEXT_DEBUG_BIT_ARB : 0),
|
||||
GHOST_OPENGL_GLX_RESET_NOTIFICATION_STRATEGY);
|
||||
#elif defined(WITH_GL_PROFILE_ES20)
|
||||
GHOST_Context *context = new GHOST_ContextGLX(
|
||||
m_wantStereoVisual,
|
||||
m_wantNumOfAASamples,
|
||||
m_window,
|
||||
m_display,
|
||||
m_visualInfo,
|
||||
(GLXFBConfig)m_fbconfig,
|
||||
GLX_CONTEXT_ES2_PROFILE_BIT_EXT,
|
||||
2, 0,
|
||||
GHOST_OPENGL_GLX_CONTEXT_FLAGS | (m_is_debug_context ? GLX_CONTEXT_DEBUG_BIT_ARB : 0),
|
||||
GHOST_OPENGL_GLX_RESET_NOTIFICATION_STRATEGY);
|
||||
#elif defined(WITH_GL_PROFILE_COMPAT)
|
||||
GHOST_Context *context = new GHOST_ContextGLX(
|
||||
m_wantStereoVisual,
|
||||
m_wantNumOfAASamples,
|
||||
m_window,
|
||||
m_display,
|
||||
m_visualInfo,
|
||||
(GLXFBConfig)m_fbconfig,
|
||||
0, // profile bit
|
||||
0, 0,
|
||||
GHOST_OPENGL_GLX_CONTEXT_FLAGS | (m_is_debug_context ? GLX_CONTEXT_DEBUG_BIT_ARB : 0),
|
||||
GHOST_OPENGL_GLX_RESET_NOTIFICATION_STRATEGY);
|
||||
#else
|
||||
# error
|
||||
#endif
|
||||
|
||||
#else
|
||||
|
||||
#if defined(WITH_GL_PROFILE_CORE)
|
||||
GHOST_Context *context = new GHOST_ContextEGL(
|
||||
m_wantStereoVisual,
|
||||
m_wantNumOfAASamples,
|
||||
m_window,
|
||||
m_display,
|
||||
EGL_CONTEXT_OPENGL_CORE_PROFILE_BIT,
|
||||
3, 2,
|
||||
GHOST_OPENGL_EGL_CONTEXT_FLAGS,
|
||||
GHOST_OPENGL_EGL_RESET_NOTIFICATION_STRATEGY,
|
||||
EGL_OPENGL_API);
|
||||
#elif defined(WITH_GL_PROFILE_ES20)
|
||||
GHOST_Context *context = new GHOST_ContextEGL(
|
||||
m_wantStereoVisual,
|
||||
m_wantNumOfAASamples,
|
||||
m_window,
|
||||
m_display,
|
||||
0, // profile bit
|
||||
2, 0,
|
||||
GHOST_OPENGL_EGL_CONTEXT_FLAGS,
|
||||
GHOST_OPENGL_EGL_RESET_NOTIFICATION_STRATEGY,
|
||||
EGL_OPENGL_ES_API);
|
||||
#elif defined(WITH_GL_PROFILE_COMPAT)
|
||||
GHOST_Context *context = new GHOST_ContextEGL(
|
||||
m_wantStereoVisual,
|
||||
m_wantNumOfAASamples,
|
||||
m_window,
|
||||
m_display,
|
||||
0, // profile bit
|
||||
0, 0,
|
||||
GHOST_OPENGL_EGL_CONTEXT_FLAGS,
|
||||
GHOST_OPENGL_EGL_RESET_NOTIFICATION_STRATEGY,
|
||||
EGL_OPENGL_API);
|
||||
#else
|
||||
# error
|
||||
#endif
|
||||
|
||||
#endif
|
||||
if (context->initializeDrawingContext())
|
||||
return context;
|
||||
else
|
||||
else {
|
||||
delete context;
|
||||
|
||||
// since that failed try 3.0 (mostly for Mesa, which doesn't implement compatibility profile)
|
||||
context = new GHOST_ContextGLX(
|
||||
m_wantStereoVisual,
|
||||
m_wantNumOfAASamples,
|
||||
m_window,
|
||||
m_display,
|
||||
m_visualInfo,
|
||||
(GLXFBConfig)m_fbconfig,
|
||||
0, // no profile bit
|
||||
3, 0,
|
||||
GHOST_OPENGL_GLX_CONTEXT_FLAGS | (m_is_debug_context ? GLX_CONTEXT_DEBUG_BIT_ARB : 0),
|
||||
GHOST_OPENGL_GLX_RESET_NOTIFICATION_STRATEGY);
|
||||
|
||||
if (context->initializeDrawingContext())
|
||||
return context;
|
||||
else
|
||||
delete context;
|
||||
}
|
||||
}
|
||||
|
||||
return NULL;
|
||||
|
||||
Reference in New Issue
Block a user