summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorBrian Paul <brian.paul@tungstengraphics.com>2006-04-13 19:21:58 +0000
committerBrian Paul <brian.paul@tungstengraphics.com>2006-04-13 19:21:58 +0000
commitda238ee06a8d169eb590aa5e50998136f1b5aba5 (patch)
tree5900bcd798bb50b2ba4582f828624fde8df49baf /src
parent564b2aa2ef8d5b859bb51d39024373a4865e93e9 (diff)
Fix comment about MaxTextureUnits, needs to be min of coord and image units.
See bug 5994. Also add a few assertions. Use MaxTextureUnits in get.c code. There's probably other places where we need to clean-up the usage of the MaxTexture[Coord/Image]Units constants.
Diffstat (limited to 'src')
-rw-r--r--src/mesa/main/config.h6
-rw-r--r--src/mesa/main/context.c9
-rw-r--r--src/mesa/main/get.c6
-rw-r--r--src/mesa/main/get_gen.py3
-rw-r--r--src/mesa/main/mtypes.h2
5 files changed, 17 insertions, 9 deletions
diff --git a/src/mesa/main/config.h b/src/mesa/main/config.h
index af4e7aad05..95555cb7d4 100644
--- a/src/mesa/main/config.h
+++ b/src/mesa/main/config.h
@@ -108,7 +108,11 @@
/** Maximum rectangular texture size - GL_NV_texture_rectangle */
#define MAX_TEXTURE_RECT_SIZE 2048
-/** Number of texture units - GL_ARB_multitexture */
+/** Number of texture units - GL_ARB_multitexture
+ * This needs to be the larger of MAX_TEXTURE_COORD_UNITS and
+ * MAX_TEXTURE_IMAGE_UNITS seen below, since MAX_TEXTURE_UNITS is used
+ * to dimension some arrays that store both coord and image data.
+*/
#define MAX_TEXTURE_UNITS 8
/*@}*/
diff --git a/src/mesa/main/context.c b/src/mesa/main/context.c
index 92dcdfd4ff..544a3036c6 100644
--- a/src/mesa/main/context.c
+++ b/src/mesa/main/context.c
@@ -959,14 +959,18 @@ _mesa_init_constants( GLcontext *ctx )
assert(MAX_TEXTURE_LEVELS >= MAX_3D_TEXTURE_LEVELS);
assert(MAX_TEXTURE_LEVELS >= MAX_CUBE_TEXTURE_LEVELS);
+ assert(MAX_TEXTURE_UNITS >= MAX_TEXTURE_COORD_UNITS);
+ assert(MAX_TEXTURE_UNITS >= MAX_TEXTURE_IMAGE_UNITS);
+
/* Constants, may be overriden (usually only reduced) by device drivers */
ctx->Const.MaxTextureLevels = MAX_TEXTURE_LEVELS;
ctx->Const.Max3DTextureLevels = MAX_3D_TEXTURE_LEVELS;
ctx->Const.MaxCubeTextureLevels = MAX_CUBE_TEXTURE_LEVELS;
ctx->Const.MaxTextureRectSize = MAX_TEXTURE_RECT_SIZE;
- ctx->Const.MaxTextureUnits = MAX_TEXTURE_UNITS;
ctx->Const.MaxTextureCoordUnits = MAX_TEXTURE_COORD_UNITS;
ctx->Const.MaxTextureImageUnits = MAX_TEXTURE_IMAGE_UNITS;
+ ctx->Const.MaxTextureUnits = MIN2(ctx->Const.MaxTextureCoordUnits,
+ ctx->Const.MaxTextureImageUnits);
ctx->Const.MaxTextureMaxAnisotropy = MAX_TEXTURE_MAX_ANISOTROPY;
ctx->Const.MaxTextureLodBias = MAX_TEXTURE_LOD_BIAS;
ctx->Const.MaxArrayLockSize = MAX_ARRAY_LOCK_SIZE;
@@ -1041,7 +1045,8 @@ _mesa_init_constants( GLcontext *ctx )
#endif
/* sanity checks */
- ASSERT(ctx->Const.MaxTextureUnits == MAX2(ctx->Const.MaxTextureImageUnits, ctx->Const.MaxTextureCoordUnits));
+ ASSERT(ctx->Const.MaxTextureUnits == MIN2(ctx->Const.MaxTextureImageUnits,
+ ctx->Const.MaxTextureCoordUnits));
ASSERT(ctx->Const.FragmentProgram.MaxLocalParams <= MAX_PROGRAM_LOCAL_PARAMS);
ASSERT(ctx->Const.VertexProgram.MaxLocalParams <= MAX_PROGRAM_LOCAL_PARAMS);
}
diff --git a/src/mesa/main/get.c b/src/mesa/main/get.c
index 7147c9a5cc..9b322908d1 100644
--- a/src/mesa/main/get.c
+++ b/src/mesa/main/get.c
@@ -1040,7 +1040,7 @@ _mesa_GetBooleanv( GLenum pname, GLboolean *params )
break;
case GL_MAX_TEXTURE_UNITS_ARB:
CHECK_EXT1(ARB_multitexture, "GetBooleanv");
- params[0] = INT_TO_BOOLEAN(MIN2(ctx->Const.MaxTextureImageUnits, ctx->Const.MaxTextureCoordUnits));
+ params[0] = INT_TO_BOOLEAN(ctx->Const.MaxTextureUnits);
break;
case GL_ACTIVE_TEXTURE_ARB:
CHECK_EXT1(ARB_multitexture, "GetBooleanv");
@@ -2858,7 +2858,7 @@ _mesa_GetFloatv( GLenum pname, GLfloat *params )
break;
case GL_MAX_TEXTURE_UNITS_ARB:
CHECK_EXT1(ARB_multitexture, "GetFloatv");
- params[0] = (GLfloat)(MIN2(ctx->Const.MaxTextureImageUnits, ctx->Const.MaxTextureCoordUnits));
+ params[0] = (GLfloat)(ctx->Const.MaxTextureUnits);
break;
case GL_ACTIVE_TEXTURE_ARB:
CHECK_EXT1(ARB_multitexture, "GetFloatv");
@@ -4676,7 +4676,7 @@ _mesa_GetIntegerv( GLenum pname, GLint *params )
break;
case GL_MAX_TEXTURE_UNITS_ARB:
CHECK_EXT1(ARB_multitexture, "GetIntegerv");
- params[0] = MIN2(ctx->Const.MaxTextureImageUnits, ctx->Const.MaxTextureCoordUnits);
+ params[0] = ctx->Const.MaxTextureUnits;
break;
case GL_ACTIVE_TEXTURE_ARB:
CHECK_EXT1(ARB_multitexture, "GetIntegerv");
diff --git a/src/mesa/main/get_gen.py b/src/mesa/main/get_gen.py
index 5b3d35fc44..9dd6b8f79e 100644
--- a/src/mesa/main/get_gen.py
+++ b/src/mesa/main/get_gen.py
@@ -495,8 +495,7 @@ StateVars = [
# GL_ARB_multitexture
( "GL_MAX_TEXTURE_UNITS_ARB", GLint,
- ["MIN2(ctx->Const.MaxTextureImageUnits, ctx->Const.MaxTextureCoordUnits)"],
- "", ["ARB_multitexture"] ),
+ ["ctx->Const.MaxTextureUnits"], "", ["ARB_multitexture"] ),
( "GL_ACTIVE_TEXTURE_ARB", GLint,
[ "GL_TEXTURE0_ARB + ctx->Texture.CurrentUnit"], "", ["ARB_multitexture"] ),
( "GL_CLIENT_ACTIVE_TEXTURE_ARB", GLint,
diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h
index c443411b62..c8831386bb 100644
--- a/src/mesa/main/mtypes.h
+++ b/src/mesa/main/mtypes.h
@@ -2302,7 +2302,7 @@ struct gl_constants
GLint MaxTextureRectSize; /* GL_NV_texture_rectangle */
GLuint MaxTextureCoordUnits;
GLuint MaxTextureImageUnits;
- GLuint MaxTextureUnits; /* = MAX(CoordUnits, ImageUnits) */
+ GLuint MaxTextureUnits; /* = MIN(CoordUnits, ImageUnits) */
GLfloat MaxTextureMaxAnisotropy; /* GL_EXT_texture_filter_anisotropic */
GLfloat MaxTextureLodBias; /* GL_EXT_texture_lod_bias */
GLuint MaxArrayLockSize;