Commit: 2e8a8403079ead2e9fd6a9cb1fc3f5cbf405a2bd
Author: Mike Erwin
Date:   Mon Jan 4 01:03:47 2016 -0500
Branches: master
https://developer.blender.org/rB2e8a8403079ead2e9fd6a9cb1fc3f5cbf405a2bd

OpenGL: GPU_legacy_support workaround for nVidia

nVidia Linux driver reports GL_CONTEXT_PROFILE_MASK = 0, which is a bug.
In that case check for the ARB_compatibility extension.

Non-buggy drivers will continue to use
GL_CONTEXT_COMPATIBILITY_PROFILE_BIT.

Thx to Dr Hackerman for reporting.

===================================================================

M       source/blender/gpu/intern/gpu_extensions.c

===================================================================

diff --git a/source/blender/gpu/intern/gpu_extensions.c 
b/source/blender/gpu/intern/gpu_extensions.c
index ab0e49e..b0ecf35 100644
--- a/source/blender/gpu/intern/gpu_extensions.c
+++ b/source/blender/gpu/intern/gpu_extensions.c
@@ -230,23 +230,39 @@ void gpu_extensions_exit(void)
 
 bool GPU_legacy_support(void)
 {
-       // return whether or not current GL context is compatible with legacy 
OpenGL
+       /* return whether or not current GL context is compatible with legacy 
OpenGL */
+       static bool checked = false;
+       static bool support = true;
 
-       if (GLEW_VERSION_3_2) {
-               static GLint profile = 0;
-
-               if (profile == 0) {
+       if (!checked) {
+               if (GLEW_VERSION_3_2) {
+                       GLint profile;
                        glGetIntegerv(GL_CONTEXT_PROFILE_MASK, &profile);
+
+                       if (G.debug & G_DEBUG_GPU) {
+                               printf("GL_CONTEXT_PROFILE_MASK = %#x (%s 
profile)\n", profile,
+                                      profile & 
GL_CONTEXT_COMPATIBILITY_PROFILE_BIT ? "compatibility" :
+                                      profile & GL_CONTEXT_CORE_PROFILE_BIT ? 
"core" : "unknown");
+                       }
+
+                       if (profile == 0) {
+                               /* workaround for nVidia's Linux driver */
+                               support = GLEW_ARB_compatibility;
+                       }
+                       else {
+                               support = profile & 
GL_CONTEXT_COMPATIBILITY_PROFILE_BIT;
+                       }
+               }
+               else if (GLEW_VERSION_3_1) {
+                       support = GLEW_ARB_compatibility;
                }
 
-               return profile & GL_CONTEXT_COMPATIBILITY_PROFILE_BIT;
-       }
-       else if (GLEW_VERSION_3_1) {
-               return GLEW_ARB_compatibility;
-       }
-       else {
-               return true;
+               /* any OpenGL version <= 3.0 is legacy, so support remains true 
*/
+
+               checked = true;
        }
+
+       return support;
 }
 
 bool GPU_glsl_support(void)

_______________________________________________
Bf-blender-cvs mailing list
[email protected]
http://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to