diff options
author | Mike Erwin <significant.bit@gmail.com> | 2016-01-04 09:03:47 +0300 |
---|---|---|
committer | Mike Erwin <significant.bit@gmail.com> | 2016-01-04 09:03:47 +0300 |
commit | 2e8a8403079ead2e9fd6a9cb1fc3f5cbf405a2bd (patch) | |
tree | d550af1aef4b30503acf7f53a264df65e9f2eb26 /source | |
parent | 193b38cc4776298feccd8eb6e47daa820b3b9e68 (diff) |
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.
Diffstat (limited to 'source')
-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) |