diff options
-rw-r--r-- | source/blender/gpu/intern/gpu_extensions.c | 40 |
1 files changed, 28 insertions, 12 deletions
diff --git a/source/blender/gpu/intern/gpu_extensions.c b/source/blender/gpu/intern/gpu_extensions.c index ab0e49e84c3..b0ecf35735a 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) |