From 2e8a8403079ead2e9fd6a9cb1fc3f5cbf405a2bd Mon Sep 17 00:00:00 2001 From: Mike Erwin Date: Mon, 4 Jan 2016 01:03:47 -0500 Subject: 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. --- source/blender/gpu/intern/gpu_extensions.c | 40 +++++++++++++++++++++--------- 1 file changed, 28 insertions(+), 12 deletions(-) (limited to 'source') 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) -- cgit v1.2.3