[Scummvm-cvs-logs] SF.net SVN: scummvm:[50907] scummvm/branches/gsoc2010-opengl/backends/ graphics/opengl/gltexture.cpp

vgvgf at users.sourceforge.net vgvgf at users.sourceforge.net
Thu Jul 15 06:20:22 CEST 2010


Revision: 50907
          http://scummvm.svn.sourceforge.net/scummvm/?rev=50907&view=rev
Author:   vgvgf
Date:     2010-07-15 04:20:21 +0000 (Thu, 15 Jul 2010)

Log Message:
-----------
Optimized nextHigher2.

Modified Paths:
--------------
    scummvm/branches/gsoc2010-opengl/backends/graphics/opengl/gltexture.cpp

Modified: scummvm/branches/gsoc2010-opengl/backends/graphics/opengl/gltexture.cpp
===================================================================
--- scummvm/branches/gsoc2010-opengl/backends/graphics/opengl/gltexture.cpp	2010-07-15 04:05:20 UTC (rev 50906)
+++ scummvm/branches/gsoc2010-opengl/backends/graphics/opengl/gltexture.cpp	2010-07-15 04:20:21 UTC (rev 50907)
@@ -41,17 +41,24 @@
 	return (numerator << 16) / denominator;
 }
 
-static GLuint nextHigher2(GLuint k) {
-	if (k == 0)
+static GLuint nextHigher2(GLuint v) {
+	if (v == 0)
 		return 1;
-	GLuint nextPow = 1;
-	while (nextPow <= k) {
-		nextPow <<= 1;
-	}
-	return nextPow;
+	v--;
+	v |= v >> 1;
+	v |= v >> 2;
+	v |= v >> 4;
+	v |= v >> 8;
+	v |= v >> 16;
+	return v++;
 }
 
 void GLTexture::initGLExtensions() {
+	static bool inited = false;
+
+	if (inited)
+		return;
+
 	const char* ext_string =
 		reinterpret_cast<const char*>(glGetString(GL_EXTENSIONS));
 	Common::StringTokenizer tokenizer(ext_string, " ");
@@ -60,6 +67,7 @@
 		if (token == "GL_ARB_texture_non_power_of_two")
 			npot_supported = true;
 	}
+	inited = true;
 }
 
 GLTexture::GLTexture(byte bpp, GLenum format, GLenum type)
@@ -100,6 +108,12 @@
 		// Already allocated a sufficiently large buffer
 		return;
 
+	nextHigher2(0);
+	nextHigher2(100);
+	nextHigher2(1025);
+	nextHigher2(9999);
+
+
 	if (npot_supported) {
 		_textureWidth = w;
 		_textureHeight = h;


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.




More information about the Scummvm-git-logs mailing list