Fix comment about MaxTextureUnits, needs to be min of coord and image units.
authorBrian Paul <brian.paul@tungstengraphics.com>
Thu, 13 Apr 2006 19:21:58 +0000 (19:21 +0000)
committerBrian Paul <brian.paul@tungstengraphics.com>
Thu, 13 Apr 2006 19:21:58 +0000 (19:21 +0000)
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.

src/mesa/main/config.h
src/mesa/main/context.c
src/mesa/main/get.c
src/mesa/main/get_gen.py
src/mesa/main/mtypes.h

index af4e7aad05b39cdd5a14a1f272e7e8096fbe68fe..95555cb7d47353df71fbf52b31246779d52a70fd 100644 (file)
 /** 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
 
 /*@}*/
index 92dcdfd4ffc1ffc3065ba7af70accdc40d1e14ce..544a3036c6ca1f2f81312c0b46815c3b5f6e6a15 100644 (file)
@@ -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);
 }
index 7147c9a5ccc0e696dc8140c0904bd690ab953040..9b322908d111f0cf70a052f3d3bdfddd15bad834 100644 (file)
@@ -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");
index 5b3d35fc4461672be68ce274011925fc3302f68a..9dd6b8f79eb3b0cc3d2260a7d1381d712595287c 100644 (file)
@@ -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,
index c443411b629135e5ee1144c504ff51e7531c697e..c8831386bb66f1c142e7d056fd893f9c988f37c9 100644 (file)
@@ -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;