[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [49274] branches/soc-2012-swiss_cheese/ source/gameengine/Ketsji/BL_Texture.cpp: Caching the results of BL_Texture: :GetMaxUnits()'s glGet call.

Mitchell Stokes mogurijin at gmail.com
Fri Jul 27 05:10:50 CEST 2012


Revision: 49274
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=49274
Author:   moguri
Date:     2012-07-27 03:10:45 +0000 (Fri, 27 Jul 2012)
Log Message:
-----------
Caching the results of BL_Texture::GetMaxUnits()'s glGet call. This reduces the overall Capture Time reported by Nvidia Nsight for glGetIntegerv from 7.21% to 5.38% (about a 25% reduction), and dropped glGetIntegerv from the second highest Capture Time to fourth.

Modified Paths:
--------------
    branches/soc-2012-swiss_cheese/source/gameengine/Ketsji/BL_Texture.cpp

Modified: branches/soc-2012-swiss_cheese/source/gameengine/Ketsji/BL_Texture.cpp
===================================================================
--- branches/soc-2012-swiss_cheese/source/gameengine/Ketsji/BL_Texture.cpp	2012-07-27 01:43:05 UTC (rev 49273)
+++ branches/soc-2012-swiss_cheese/source/gameengine/Ketsji/BL_Texture.cpp	2012-07-27 03:10:45 UTC (rev 49274)
@@ -60,6 +60,7 @@
 
 typedef std::map<char*, BL_TextureObject> BL_TextureMap;
 static BL_TextureMap g_textureManager;
+static GLint g_max_units = -1;
 
 
 BL_Texture::BL_Texture()
@@ -373,14 +374,17 @@
 
 int BL_Texture::GetMaxUnits()
 {
-	GLint unit=0;
-
-	if (GLEW_ARB_multitexture) {
-		glGetIntegerv(GL_MAX_TEXTURE_UNITS_ARB, &unit);
-		return (MAXTEX>=unit?unit:MAXTEX);
+	if (g_max_units < 0) {
+		GLint unit;
+		if (GLEW_ARB_multitexture) {
+			glGetIntegerv(GL_MAX_TEXTURE_UNITS_ARB, &unit);
+			g_max_units = (MAXTEX>=unit)?unit:MAXTEX;
+		} else {
+			g_max_units = 0;
+		}
 	}
 
-	return 0;
+	return g_max_units;
 }
 
 void BL_Texture::ActivateFirst()




More information about the Bf-blender-cvs mailing list