summaryrefslogtreecommitdiffstats
path: root/src/mesa/main
diff options
context:
space:
mode:
Diffstat (limited to 'src/mesa/main')
-rw-r--r--src/mesa/main/colortab.c2
-rw-r--r--src/mesa/main/enums.c12
-rw-r--r--src/mesa/main/ffvertex_prog.c8
-rw-r--r--src/mesa/main/histogram.c2
-rw-r--r--src/mesa/main/imports.h10
-rw-r--r--src/mesa/main/pixel.c6
-rw-r--r--src/mesa/main/rastpos.c6
-rw-r--r--src/mesa/main/teximage.c36
8 files changed, 52 insertions, 30 deletions
diff --git a/src/mesa/main/colortab.c b/src/mesa/main/colortab.c
index 97120398f9b..bd9cf438b4f 100644
--- a/src/mesa/main/colortab.c
+++ b/src/mesa/main/colortab.c
@@ -383,7 +383,7 @@ _mesa_ColorTable( GLenum target, GLenum internalFormat,
return;
}
- if (width < 0 || (width != 0 && _mesa_bitcount(width) != 1)) {
+ if (width < 0 || (width != 0 && !_mesa_is_pow_two(width))) {
/* error */
if (proxy) {
table->Size = 0;
diff --git a/src/mesa/main/enums.c b/src/mesa/main/enums.c
index 15e7d5b96ce..4796f3027ad 100644
--- a/src/mesa/main/enums.c
+++ b/src/mesa/main/enums.c
@@ -4866,8 +4866,10 @@ const char *_mesa_lookup_enum_by_nr( int nr )
{
unsigned * i;
- i = (unsigned *)_mesa_bsearch( & nr, reduced_enums, Elements(reduced_enums),
- sizeof(reduced_enums[0]), (cfunc) compar_nr );
+ i = (unsigned *) _mesa_bsearch(& nr, reduced_enums,
+ Elements(reduced_enums),
+ sizeof(reduced_enums[0]),
+ (cfunc) compar_nr);
if ( i != NULL ) {
return & enum_string_table[ all_enums[ *i ].offset ];
@@ -4884,8 +4886,10 @@ int _mesa_lookup_enum_by_name( const char *symbol )
enum_elt * f = NULL;
if ( symbol != NULL ) {
- f = (enum_elt *)_mesa_bsearch( symbol, all_enums, Elements(all_enums),
- sizeof( enum_elt ), (cfunc) compar_name );
+ f = (enum_elt *) _mesa_bsearch(symbol, all_enums,
+ Elements(all_enums),
+ sizeof( enum_elt ),
+ (cfunc) compar_name);
}
return (f != NULL) ? f->n : -1;
diff --git a/src/mesa/main/ffvertex_prog.c b/src/mesa/main/ffvertex_prog.c
index 64a4788aa4b..ec0a5e3896d 100644
--- a/src/mesa/main/ffvertex_prog.c
+++ b/src/mesa/main/ffvertex_prog.c
@@ -736,11 +736,16 @@ static void emit_normalize_vec3( struct tnl_program *p,
struct ureg dest,
struct ureg src )
{
+#if 0
+ /* XXX use this when drivers are ready for NRM3 */
+ emit_op1(p, OPCODE_NRM3, dest, WRITEMASK_XYZ, src);
+#else
struct ureg tmp = get_temp(p);
emit_op2(p, OPCODE_DP3, tmp, WRITEMASK_X, src, src);
emit_op1(p, OPCODE_RSQ, tmp, WRITEMASK_X, tmp);
emit_op2(p, OPCODE_MUL, dest, 0, src, swizzle1(tmp, X));
release_temp(p, tmp);
+#endif
}
static void emit_passthrough( struct tnl_program *p,
@@ -1316,6 +1321,9 @@ static void build_lighting( struct tnl_program *p )
emit_op3(p, OPCODE_MAD, res0, mask0, swizzle1(lit,Y), diffuse, _bfc0);
emit_op3(p, OPCODE_MAD, res1, mask1, swizzle1(lit,Z), specular, _bfc1);
+ /* restore negate flag for next lighting */
+ dots = negate(dots);
+
release_temp(p, ambient);
release_temp(p, diffuse);
release_temp(p, specular);
diff --git a/src/mesa/main/histogram.c b/src/mesa/main/histogram.c
index 77c458d540c..905c1ad8301 100644
--- a/src/mesa/main/histogram.c
+++ b/src/mesa/main/histogram.c
@@ -955,7 +955,7 @@ _mesa_Histogram(GLenum target, GLsizei width, GLenum internalFormat, GLboolean s
}
}
- if (width != 0 && _mesa_bitcount(width) != 1) {
+ if (width != 0 && !_mesa_is_pow_two(width)) {
if (target == GL_PROXY_HISTOGRAM) {
error = GL_TRUE;
}
diff --git a/src/mesa/main/imports.h b/src/mesa/main/imports.h
index 0e6e301fdeb..bab00420710 100644
--- a/src/mesa/main/imports.h
+++ b/src/mesa/main/imports.h
@@ -462,6 +462,16 @@ static INLINE int iceil(float f)
#endif
+/**
+ * Is x a power of two?
+ */
+static INLINE int
+_mesa_is_pow_two(int x)
+{
+ return !(x & (x - 1));
+}
+
+
/***
*** UNCLAMPED_FLOAT_TO_UBYTE: clamp float to [0,1] and map to ubyte in [0,255]
*** CLAMPED_FLOAT_TO_UBYTE: map float known to be in [0,1] to ubyte in [0,255]
diff --git a/src/mesa/main/pixel.c b/src/mesa/main/pixel.c
index c98506b2bb0..8d24a201f07 100644
--- a/src/mesa/main/pixel.c
+++ b/src/mesa/main/pixel.c
@@ -150,7 +150,7 @@ _mesa_PixelMapfv( GLenum map, GLsizei mapsize, const GLfloat *values )
if (map >= GL_PIXEL_MAP_S_TO_S && map <= GL_PIXEL_MAP_I_TO_A) {
/* test that mapsize is a power of two */
- if (_mesa_bitcount((GLuint) mapsize) != 1) {
+ if (!_mesa_is_pow_two(mapsize)) {
_mesa_error( ctx, GL_INVALID_VALUE, "glPixelMapfv(mapsize)" );
return;
}
@@ -209,7 +209,7 @@ _mesa_PixelMapuiv(GLenum map, GLsizei mapsize, const GLuint *values )
if (map >= GL_PIXEL_MAP_S_TO_S && map <= GL_PIXEL_MAP_I_TO_A) {
/* test that mapsize is a power of two */
- if (_mesa_bitcount((GLuint) mapsize) != 1) {
+ if (!_mesa_is_pow_two(mapsize)) {
_mesa_error( ctx, GL_INVALID_VALUE, "glPixelMapuiv(mapsize)" );
return;
}
@@ -282,7 +282,7 @@ _mesa_PixelMapusv(GLenum map, GLsizei mapsize, const GLushort *values )
if (map >= GL_PIXEL_MAP_S_TO_S && map <= GL_PIXEL_MAP_I_TO_A) {
/* test that mapsize is a power of two */
- if (_mesa_bitcount((GLuint) mapsize) != 1) {
+ if (!_mesa_is_pow_two(mapsize)) {
_mesa_error( ctx, GL_INVALID_VALUE, "glPixelMapuiv(mapsize)" );
return;
}
diff --git a/src/mesa/main/rastpos.c b/src/mesa/main/rastpos.c
index 155140f3ccc..9842172f460 100644
--- a/src/mesa/main/rastpos.c
+++ b/src/mesa/main/rastpos.c
@@ -50,12 +50,12 @@ rasterpos(GLfloat x, GLfloat y, GLfloat z, GLfloat w)
p[2] = z;
p[3] = w;
- if (ctx->NewState)
- _mesa_update_state( ctx );
-
ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx);
FLUSH_CURRENT(ctx, 0);
+ if (ctx->NewState)
+ _mesa_update_state( ctx );
+
ctx->Driver.RasterPos(ctx, p);
}
diff --git a/src/mesa/main/teximage.c b/src/mesa/main/teximage.c
index cddd9df0164..a5e0db736ed 100644
--- a/src/mesa/main/teximage.c
+++ b/src/mesa/main/teximage.c
@@ -1,5 +1,5 @@
/*
- * Mesa 3-D graphics library
+ * mesa 3-D graphics library
* Version: 7.1
*
* Copyright (C) 1999-2008 Brian Paul All Rights Reserved.
@@ -1244,9 +1244,9 @@ _mesa_init_teximage_fields(GLcontext *ctx, GLenum target,
img->IsCompressed = GL_FALSE;
img->CompressedSize = 0;
- if ((width == 1 || _mesa_bitcount(img->Width2) == 1) &&
- (height == 1 || _mesa_bitcount(img->Height2) == 1) &&
- (depth == 1 || _mesa_bitcount(img->Depth2) == 1))
+ if ((width == 1 || _mesa_is_pow_two(img->Width2)) &&
+ (height == 1 || _mesa_is_pow_two(img->Height2)) &&
+ (depth == 1 || _mesa_is_pow_two(img->Depth2)))
img->_IsPowerOfTwo = GL_TRUE;
else
img->_IsPowerOfTwo = GL_FALSE;
@@ -1317,7 +1317,7 @@ _mesa_test_proxy_teximage(GLcontext *ctx, GLenum target, GLint level,
maxSize = 1 << (ctx->Const.MaxTextureLevels - 1);
if (width < 2 * border || width > 2 + maxSize ||
(!ctx->Extensions.ARB_texture_non_power_of_two &&
- width >0 && _mesa_bitcount(width - 2 * border) != 1) ||
+ width >0 && !_mesa_is_pow_two(width - 2 * border)) ||
level >= ctx->Const.MaxTextureLevels) {
/* bad width or level */
return GL_FALSE;
@@ -1327,10 +1327,10 @@ _mesa_test_proxy_teximage(GLcontext *ctx, GLenum target, GLint level,
maxSize = 1 << (ctx->Const.MaxTextureLevels - 1);
if (width < 2 * border || width > 2 + maxSize ||
(!ctx->Extensions.ARB_texture_non_power_of_two &&
- width > 0 && _mesa_bitcount(width - 2 * border) != 1) ||
+ width > 0 && !_mesa_is_pow_two(width - 2 * border)) ||
height < 2 * border || height > 2 + maxSize ||
(!ctx->Extensions.ARB_texture_non_power_of_two &&
- height > 0 && _mesa_bitcount(height - 2 * border) != 1) ||
+ height > 0 && !_mesa_is_pow_two(height - 2 * border)) ||
level >= ctx->Const.MaxTextureLevels) {
/* bad width or height or level */
return GL_FALSE;
@@ -1340,13 +1340,13 @@ _mesa_test_proxy_teximage(GLcontext *ctx, GLenum target, GLint level,
maxSize = 1 << (ctx->Const.Max3DTextureLevels - 1);
if (width < 2 * border || width > 2 + maxSize ||
(!ctx->Extensions.ARB_texture_non_power_of_two &&
- width > 0 && _mesa_bitcount(width - 2 * border) != 1) ||
+ width > 0 && !_mesa_is_pow_two(width - 2 * border)) ||
height < 2 * border || height > 2 + maxSize ||
(!ctx->Extensions.ARB_texture_non_power_of_two &&
- height > 0 && _mesa_bitcount(height - 2 * border) != 1) ||
+ height > 0 && !_mesa_is_pow_two(height - 2 * border)) ||
depth < 2 * border || depth > 2 + maxSize ||
(!ctx->Extensions.ARB_texture_non_power_of_two &&
- depth > 0 && _mesa_bitcount(depth - 2 * border) != 1) ||
+ depth > 0 && !_mesa_is_pow_two(depth - 2 * border)) ||
level >= ctx->Const.Max3DTextureLevels) {
/* bad width or height or depth or level */
return GL_FALSE;
@@ -1364,10 +1364,10 @@ _mesa_test_proxy_teximage(GLcontext *ctx, GLenum target, GLint level,
maxSize = 1 << (ctx->Const.MaxCubeTextureLevels - 1);
if (width < 2 * border || width > 2 + maxSize ||
(!ctx->Extensions.ARB_texture_non_power_of_two &&
- width > 0 && _mesa_bitcount(width - 2 * border) != 1) ||
+ width > 0 && !_mesa_is_pow_two(width - 2 * border)) ||
height < 2 * border || height > 2 + maxSize ||
(!ctx->Extensions.ARB_texture_non_power_of_two &&
- height > 0 && _mesa_bitcount(height - 2 * border) != 1) ||
+ height > 0 && !_mesa_is_pow_two(height - 2 * border)) ||
level >= ctx->Const.MaxCubeTextureLevels) {
/* bad width or height */
return GL_FALSE;
@@ -1377,7 +1377,7 @@ _mesa_test_proxy_teximage(GLcontext *ctx, GLenum target, GLint level,
maxSize = 1 << (ctx->Const.MaxTextureLevels - 1);
if (width < 2 * border || width > 2 + maxSize ||
(!ctx->Extensions.ARB_texture_non_power_of_two &&
- width > 0 && _mesa_bitcount(width - 2 * border) != 1) ||
+ width > 0 && !_mesa_is_pow_two(width - 2 * border)) ||
level >= ctx->Const.MaxTextureLevels) {
/* bad width or level */
return GL_FALSE;
@@ -1391,10 +1391,10 @@ _mesa_test_proxy_teximage(GLcontext *ctx, GLenum target, GLint level,
maxSize = 1 << (ctx->Const.MaxTextureLevels - 1);
if (width < 2 * border || width > 2 + maxSize ||
(!ctx->Extensions.ARB_texture_non_power_of_two &&
- width > 0 && _mesa_bitcount(width - 2 * border) != 1) ||
+ width > 0 && !_mesa_is_pow_two(width - 2 * border)) ||
height < 2 * border || height > 2 + maxSize ||
(!ctx->Extensions.ARB_texture_non_power_of_two &&
- height > 0 && _mesa_bitcount(height - 2 * border) != 1) ||
+ height > 0 && !_mesa_is_pow_two(height - 2 * border)) ||
level >= ctx->Const.MaxTextureLevels) {
/* bad width or height or level */
return GL_FALSE;
@@ -3284,16 +3284,16 @@ compressed_texture_error_check(GLcontext *ctx, GLint dimensions,
* XXX We should probably use the proxy texture error check function here.
*/
if (width < 1 || width > maxTextureSize ||
- (!ctx->Extensions.ARB_texture_non_power_of_two && _mesa_bitcount(width) != 1))
+ (!ctx->Extensions.ARB_texture_non_power_of_two && !_mesa_is_pow_two(width)))
return GL_INVALID_VALUE;
if ((height < 1 || height > maxTextureSize ||
- (!ctx->Extensions.ARB_texture_non_power_of_two && _mesa_bitcount(height) != 1))
+ (!ctx->Extensions.ARB_texture_non_power_of_two && !_mesa_is_pow_two(height)))
&& dimensions > 1)
return GL_INVALID_VALUE;
if ((depth < 1 || depth > maxTextureSize ||
- (!ctx->Extensions.ARB_texture_non_power_of_two && _mesa_bitcount(depth) != 1))
+ (!ctx->Extensions.ARB_texture_non_power_of_two && !_mesa_is_pow_two(depth)))
&& dimensions > 2)
return GL_INVALID_VALUE;