summaryrefslogtreecommitdiffstats
path: root/src/mesa/main/teximage.c
diff options
context:
space:
mode:
authorChristian König <[email protected]>2011-06-05 00:11:41 +0200
committerChristian König <[email protected]>2011-06-05 00:11:41 +0200
commit1eb957bb4108123bea95b818e0544e3b5f255e08 (patch)
treed7febd8e6cc841ab16dca53f031322ec47d5ccd9 /src/mesa/main/teximage.c
parenta6c76c8a90dc8995feed3c61b02dbd8408149036 (diff)
parent6491e9593d5cbc5644eb02593a2f562447efdcbb (diff)
Merge remote-tracking branch 'origin/master' into pipe-video
Diffstat (limited to 'src/mesa/main/teximage.c')
-rw-r--r--src/mesa/main/teximage.c35
1 files changed, 11 insertions, 24 deletions
diff --git a/src/mesa/main/teximage.c b/src/mesa/main/teximage.c
index 8fb54c693e0..3e429110ae9 100644
--- a/src/mesa/main/teximage.c
+++ b/src/mesa/main/teximage.c
@@ -81,31 +81,18 @@ _mesa_free_texmemory(void *m)
/*
- * Compute floor(log_base_2(n)).
- * If n < 0 return -1.
+ * Returns the floor form of binary logarithm for a 32-bit integer.
*/
-static int
-logbase2( int n )
+static GLuint
+logbase2(GLuint n)
{
- GLint i = 1;
- GLint log2 = 0;
-
- if (n < 0)
- return -1;
-
- if (n == 0)
- return 0;
-
- while ( n > i ) {
- i *= 2;
- log2++;
- }
- if (i != n) {
- return log2 - 1;
- }
- else {
- return log2;
- }
+ GLuint pos = 0;
+ if (n >= 1<<16) { n >>= 16; pos += 16; }
+ if (n >= 1<< 8) { n >>= 8; pos += 8; }
+ if (n >= 1<< 4) { n >>= 4; pos += 4; }
+ if (n >= 1<< 2) { n >>= 2; pos += 2; }
+ if (n >= 1<< 1) { pos += 1; }
+ return pos;
}
@@ -2693,7 +2680,7 @@ texsubimage(struct gl_context *ctx, GLuint dims, GLenum target, GLint level,
format, type, texImage)) {
/* error was recorded */
}
- else if (width > 0 && height > 0 && height > 0) {
+ else if (width > 0 && height > 0 && depth > 0) {
/* If we have a border, offset=-1 is legal. Bias by border width. */
switch (dims) {
case 3: