Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Erwin <significant.bit@gmail.com>2017-04-25 05:30:17 +0300
committerMike Erwin <significant.bit@gmail.com>2017-04-25 05:30:17 +0300
commit75a759ea5e9a4b4a52900e6383d67c81b7cbdabe (patch)
treec967541d8a11be094c96a77c7e6da1c07ea50371 /intern/ghost
parent9c87bb124a57e84abe60a75ba68002a6cc2a68ac (diff)
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
Diffstat (limited to 'intern/ghost')
-rw-r--r--intern/ghost/intern/GHOST_ContextWGL.cpp8
-rw-r--r--intern/ghost/intern/GHOST_WindowWin32.cpp75
2 files changed, 63 insertions, 20 deletions
diff --git a/intern/ghost/intern/GHOST_ContextWGL.cpp b/intern/ghost/intern/GHOST_ContextWGL.cpp
index f861631a94e..3538632ce40 100644
--- a/intern/ghost/intern/GHOST_ContextWGL.cpp
+++ b/intern/ghost/intern/GHOST_ContextWGL.cpp
@@ -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!",
diff --git a/intern/ghost/intern/GHOST_WindowWin32.cpp b/intern/ghost/intern/GHOST_WindowWin32.cpp
index 2c82e3a3f71..2a141f8770c 100644
--- a/intern/ghost/intern/GHOST_WindowWin32.cpp
+++ b/intern/ghost/intern/GHOST_WindowWin32.cpp
@@ -612,36 +612,71 @@ GHOST_Context *GHOST_WindowWin32::newDrawingContext(GHOST_TDrawingContextType ty
{
if (type == GHOST_kDrawingContextTypeOpenGL) {
- const int profile_mask =
+ // 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
+
+ // TODO(merwin): query version of initial dummy context, request that + profile + debug
+
+ GHOST_Context *context;
+
#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
+ // 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;
+ }
- GHOST_Context *context = new GHOST_ContextWGL(
+ 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