OpenGL: better context creation on Windows
Compatibility profile was working fine, this is mostly to get the highest GL core profile version available. Our minimum requirement is 3.3 core profile. When we request a specific GL version: - AMD and Intel give us exactly this version - NVIDIA gives at least this version <-- desired behavior so we ask for 4.5, 4.4 ... 3.3 in descending order to get the best version on the user's system. Accept OpenGL 3.0 on Mesa instead of 3.3+ compatibility profile. (requested by @LazyDodo) This will be removed after we finish moving to core profile. Part of T49012 and T51164
This commit is contained in:
parent
9c87bb124a
commit
75a759ea5e
|
@ -878,6 +878,7 @@ GHOST_TSuccess GHOST_ContextWGL::initializeDrawingContext()
|
|||
else
|
||||
m_hGLRC = s_sharedHGLRC;
|
||||
}
|
||||
#ifdef WITH_LEGACY_OPENGL
|
||||
else {
|
||||
if (m_contextProfileMask != 0)
|
||||
fprintf(stderr, "Warning! Legacy WGL is unable to select between OpenGL profiles.");
|
||||
|
@ -893,6 +894,7 @@ GHOST_TSuccess GHOST_ContextWGL::initializeDrawingContext()
|
|||
else
|
||||
m_hGLRC = s_sharedHGLRC;
|
||||
}
|
||||
#endif // WITH_LEGACY_OPENGL
|
||||
|
||||
if (!WIN32_CHK(m_hGLRC != NULL)) {
|
||||
::wglMakeCurrent(prevHDC, prevHGLRC);
|
||||
|
@ -944,7 +946,13 @@ GHOST_TSuccess GHOST_ContextWGL::initializeDrawingContext()
|
|||
MB_OK | MB_ICONERROR);
|
||||
exit(0);
|
||||
}
|
||||
#if defined(WITH_LEGACY_OPENGL)
|
||||
else if (version[0] < '3') {
|
||||
// relax requirements for Mesa, which uses GL 3.0
|
||||
// while other drivers use GL 3.3+ compatibility profile
|
||||
#else
|
||||
else if (version[0] < '3' || (version[0] == '3' && version[2] < '3')) {
|
||||
#endif
|
||||
MessageBox(m_hWnd, "Blender requires a graphics driver with OpenGL 3.3 support.\n\n"
|
||||
"The program will now close.",
|
||||
"Blender - Unsupported Graphics Driver!",
|
||||
|
|
|
@ -612,36 +612,71 @@ GHOST_Context *GHOST_WindowWin32::newDrawingContext(GHOST_TDrawingContextType ty
|
|||
{
|
||||
if (type == GHOST_kDrawingContextTypeOpenGL) {
|
||||
|
||||
const int profile_mask =
|
||||
#if defined(WITH_GL_PROFILE_CORE)
|
||||
WGL_CONTEXT_CORE_PROFILE_BIT_ARB;
|
||||
#elif defined(WITH_GL_PROFILE_COMPAT)
|
||||
WGL_CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB;
|
||||
#else
|
||||
# error // must specify either core or compat at build time
|
||||
#endif
|
||||
// During development:
|
||||
// ask for 2.1 context, driver gives latest compatibility profile
|
||||
// (we check later to ensure it's >= 3.3 on Windows)
|
||||
//
|
||||
// Final Blender 2.8:
|
||||
// try 4.x core profile
|
||||
// try 3.3 core profile
|
||||
// no fallbacks
|
||||
|
||||
GHOST_Context *context = new GHOST_ContextWGL(
|
||||
// TODO(merwin): query version of initial dummy context, request that + profile + debug
|
||||
|
||||
GHOST_Context *context;
|
||||
|
||||
#if defined(WITH_GL_PROFILE_CORE)
|
||||
// our minimum requirement is 3.3 core profile
|
||||
// when we request a specific GL version:
|
||||
// - AMD and Intel give us exactly this version
|
||||
// - NVIDIA gives at least this version <-- desired behavior
|
||||
// so we ask for 4.5, 4.4 ... 3.3 in descending order to get the best version on the user's system
|
||||
for (int minor = 5; minor >= 0; --minor) {
|
||||
context = new GHOST_ContextWGL(
|
||||
m_wantStereoVisual,
|
||||
m_wantAlphaBackground,
|
||||
m_wantNumOfAASamples,
|
||||
m_hWnd,
|
||||
m_hDC,
|
||||
WGL_CONTEXT_CORE_PROFILE_BIT_ARB,
|
||||
4, minor,
|
||||
(m_debug_context ? WGL_CONTEXT_DEBUG_BIT_ARB : 0),
|
||||
GHOST_OPENGL_WGL_RESET_NOTIFICATION_STRATEGY);
|
||||
|
||||
if (context->initializeDrawingContext())
|
||||
return context;
|
||||
else
|
||||
delete context;
|
||||
}
|
||||
|
||||
context = new GHOST_ContextWGL(
|
||||
m_wantStereoVisual,
|
||||
m_wantAlphaBackground,
|
||||
m_wantNumOfAASamples,
|
||||
m_hWnd,
|
||||
m_hDC,
|
||||
profile_mask,
|
||||
#if 0
|
||||
3, 3, // specific GL version requested
|
||||
// AMD gives us exactly this version
|
||||
// NVIDIA gives at least this version <-- desired behavior
|
||||
#else
|
||||
2, 1, // any GL version >= 2.1 (hopefully the latest)
|
||||
// we check later to ensure it's >= 3.3 on Windows
|
||||
// TODO(merwin): fix properly!
|
||||
// 2.1 ignores the profile bit & is incompatible with core profile
|
||||
// query version of initial dummy context, request that + profile + debug
|
||||
#endif
|
||||
WGL_CONTEXT_CORE_PROFILE_BIT_ARB,
|
||||
3, 3,
|
||||
(m_debug_context ? WGL_CONTEXT_DEBUG_BIT_ARB : 0),
|
||||
GHOST_OPENGL_WGL_RESET_NOTIFICATION_STRATEGY);
|
||||
|
||||
#elif defined(WITH_GL_PROFILE_COMPAT)
|
||||
// ask for 2.1 context, driver gives any GL version >= 2.1 (hopefully the latest compatibility profile)
|
||||
// 2.1 ignores the profile bit & is incompatible with core profile
|
||||
context = new GHOST_ContextWGL(
|
||||
m_wantStereoVisual,
|
||||
m_wantAlphaBackground,
|
||||
m_wantNumOfAASamples,
|
||||
m_hWnd,
|
||||
m_hDC,
|
||||
0, // no profile bit
|
||||
2, 1,
|
||||
(m_debug_context ? WGL_CONTEXT_DEBUG_BIT_ARB : 0),
|
||||
GHOST_OPENGL_WGL_RESET_NOTIFICATION_STRATEGY);
|
||||
#else
|
||||
# error // must specify either core or compat at build time
|
||||
#endif
|
||||
|
||||
if (context->initializeDrawingContext())
|
||||
return context;
|
||||
else
|
||||
|
|
Loading…
Reference in New Issue