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.
/** 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
/*@}*/
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;
#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);
}
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");
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");
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");
# 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,
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;