[Bf-blender-cvs] [05ffe2d] master: OpenGL: choose compatible GLSL version

Mike Erwin noreply at git.blender.org
Mon Nov 23 05:43:51 CET 2015


Commit: 05ffe2d174115b9f9fc2322dbafcfb4543d3809d
Author: Mike Erwin
Date:   Sun Nov 22 20:40:54 2015 -0500
Branches: master
https://developer.blender.org/rB05ffe2d174115b9f9fc2322dbafcfb4543d3809d

OpenGL: choose compatible GLSL version

Fix GLSL version & geometry shader support query to consider core vs
compatibility.

All shaders need to be compatible with each other, and for now that
means GLSL 120. For drivers that support compatibility profiles, choose
the highest available (up to 150). If only core profile is supported,
max out at GLSL 130.

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

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 c0ada3c..52b2bb9 100644
--- a/source/blender/gpu/intern/gpu_extensions.c
+++ b/source/blender/gpu/intern/gpu_extensions.c
@@ -301,15 +301,16 @@ bool GPU_bicubic_bump_support(void)
 
 bool GPU_geometry_shader_support(void)
 {
-	return GLEW_VERSION_3_2 || GLEW_EXT_geometry_shader4;
+	/* in GL 3.2 geometry shaders are fully supported
+	 * core profile clashes with our other shaders so accept compatibility only
+	 * other GL versions can use EXT_geometry_shader4 if available
+	 */
+	return (GLEW_VERSION_3_2 && GLEW_ARB_compatibility) || GLEW_EXT_geometry_shader4;
 }
 
 static bool GPU_geometry_shader_support_via_extension(void)
 {
-	/* in GL 3.2 geometry shaders are fully supported
-	 * GL < 3.2 can use EXT_geometry_shader4 if available
-	 */
-	return !GLEW_VERSION_3_2 && GLEW_EXT_geometry_shader4;
+	return GLEW_EXT_geometry_shader4 && !(GLEW_VERSION_3_2 && GLEW_ARB_compatibility);
 }
 
 bool GPU_instanced_drawing_support(void)
@@ -1656,15 +1657,27 @@ static void shader_print_errors(const char *task, const char *log, const char **
 static const char *gpu_shader_version()
 {
 	if (GLEW_VERSION_3_2) {
-		return "#version 150 compatibility\n";
-		/* highest version that is widely supported
-		 * gives us native geometry shaders!
-		 * use compatibility profile so we can continue using builtin shader input/output names
-		 */
+		if (GLEW_ARB_compatibility) {
+			return "#version 150 compatibility\n";
+			/* highest version that is widely supported
+			 * gives us native geometry shaders!
+			 * use compatibility profile so we can continue using builtin shader input/output names
+			 */
+		}
+		else {
+			return "#version 130\n";
+			/* latest version that is compatible with existing shaders */
+		}
 	}
 	else if (GLEW_VERSION_3_1) {
-		return "#version 140\n";
-		/* also need the ARB_compatibility extension, handled below */
+		if (GLEW_ARB_compatibility) {
+			return "#version 140\n";
+			/* also need the ARB_compatibility extension, handled below */
+		}
+		else {
+			return "#version 130\n";
+			/* latest version that is compatible with existing shaders */
+		}
 	}
 	else if (GLEW_VERSION_3_0) {
 		return "#version 130\n";
@@ -1694,7 +1707,7 @@ static void gpu_shader_standard_extensions(char defines[MAX_EXT_DEFINE_LENGTH],
 		strcat(defines, "#extension GL_EXT_geometry_shader4: enable\n");
 	}
 
-	if (GLEW_VERSION_3_1 && !GLEW_VERSION_3_2) {
+	if (GLEW_VERSION_3_1 && !GLEW_VERSION_3_2 && GLEW_ARB_compatibility) {
 		strcat(defines, "#extension GL_ARB_compatibility: enable\n");
 	}




More information about the Bf-blender-cvs mailing list