[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [58415] branches/soc-2013-viewport_fx/ source/blender/gpu: GPU_LEGACY - Runtime flag to determine if compatibiity profile is available .

Jason Wilkins Jason.A.Wilkins at gmail.com
Fri Jul 19 21:38:30 CEST 2013


Revision: 58415
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=58415
Author:   jwilkins
Date:     2013-07-19 19:38:29 +0000 (Fri, 19 Jul 2013)
Log Message:
-----------
GPU_LEGACY - Runtime flag to determine if compatibiity profile is available.

Just a stub now.

Also, polished the get_max_textures function, since it seems to be a good example of how OpenGL versioning can be complicated by the history of changes to OpenGL and the existence of ES.

Modified Paths:
--------------
    branches/soc-2013-viewport_fx/source/blender/gpu/GPU_compatibility.h
    branches/soc-2013-viewport_fx/source/blender/gpu/intern/gpu_extensions.c

Modified: branches/soc-2013-viewport_fx/source/blender/gpu/GPU_compatibility.h
===================================================================
--- branches/soc-2013-viewport_fx/source/blender/gpu/GPU_compatibility.h	2013-07-19 19:19:15 UTC (rev 58414)
+++ branches/soc-2013-viewport_fx/source/blender/gpu/GPU_compatibility.h	2013-07-19 19:38:29 UTC (rev 58415)
@@ -55,4 +55,8 @@
 
 
 
+#define GPU_LEGACY 1 // XXX jwilkins: ToDo, will be runtime variable indicating that legacy opengl is in use or compatibility profile is loaded
+
+
+
 #endif /* __GPU_COMPATIBILITY_H_ */

Modified: branches/soc-2013-viewport_fx/source/blender/gpu/intern/gpu_extensions.c
===================================================================
--- branches/soc-2013-viewport_fx/source/blender/gpu/intern/gpu_extensions.c	2013-07-19 19:19:15 UTC (rev 58414)
+++ branches/soc-2013-viewport_fx/source/blender/gpu/intern/gpu_extensions.c	2013-07-19 19:38:29 UTC (rev 58415)
@@ -117,38 +117,47 @@
 	return GG.maxtexsize;
 }
 
-static GLint calc_max_textures(void)
+/*
+Computes the maximum number of textures 'n' that
+can be referenced by ActiveTexture(TEXTURE0+n-1)
+
+This is for any use of ActiveTexture.
+
+Individual limits, such as for the multitexture extension, gl_TexCoord,
+vertex shaders, fragment shader, etc. will each have different limits.
+*/
+static GLint get_max_textures(void)
 {
 	GLint maxTextureUnits;
 	GLint maxTextureCoords;
 	GLint maxCombinedTextureImageUnits;
 
-	if (GLEW_VERSION_1_3 || GLEW_ARB_multitexture) {
-		glGetIntegerv(
-			GL_MAX_TEXTURE_UNITS,
-			&maxTextureUnits);
+	/* There has to be at least one texture so count that here */
+	maxTextureUnits = 1;
+
+#if !defined(GLEW_ES_ONLY)
+	if (GPU_LEGACY && (GLEW_VERSION_1_3 || GLEW_ARB_multitexture)) {
+		/* Multitexture typically supports only 2 or 4 texture stages even on modern hardware. */
+		glGetIntegerv(GL_MAX_TEXTURE_UNITS, &maxTextureUnits);
 	}
-	else {
-		maxTextureUnits = 1;
-	}
+#endif
 
-	if (GLEW_VERSION_2_0 || GLEW_ARB_fragment_program) {
+	/* Set to zero here in case they do not get set later */
+	maxTextureCoords             = 0;
+	maxCombinedTextureImageUnits = 0;
+
+	if (GLEW_VERSION_2_0 || GLEW_ES_VERSION_2_0 || GLEW_ARB_fragment_program) {
 #if !defined(GLEW_ES_ONLY)
-		maxTextureCoords = 0; // in case of error
-		glGetIntegerv(
-			GL_MAX_TEXTURE_COORDS,
-			&maxTextureCoords);
+		if (GPU_LEGACY) {
+			/* size of gl_TexCoord array in GLSL */
+			glGetIntegerv(GL_MAX_TEXTURE_COORDS, &maxTextureCoords);
+		}
 #endif
 
-		maxCombinedTextureImageUnits = 0; // in case of error
-		glGetIntegerv(
-			GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS,
-			&maxCombinedTextureImageUnits);
+		/* Number of textures accessible by vertex, fragment, and geometry shaders combined. */
+		/* Individually the limits for each of those programmable units may be smaller. */
+		glGetIntegerv(GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS, &maxCombinedTextureImageUnits);
 	}
-	else {
-		maxTextureCoords             = 0;
-		maxCombinedTextureImageUnits = 0;
-	}
 
 	return MAX3(maxTextureUnits, maxTextureCoords, maxCombinedTextureImageUnits);
 }
@@ -173,7 +182,7 @@
 	gpuInitializeViewFuncs();
 	GPU_codegen_init();
 
-	GG.maxtextures = calc_max_textures();
+	GG.maxtextures = get_max_textures();
 
 #if defined(WITH_GL_PROFILE_ES20) || defined(WITH_GL_PROFILE_CORE)
 	gpu_object_init_gles();




More information about the Bf-blender-cvs mailing list