summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBrian Paul <[email protected]>2009-02-21 15:15:20 -0700
committerBrian Paul <[email protected]>2009-02-21 15:15:20 -0700
commitd059d030342fc232a5b54298c0591f5f814f4adb (patch)
tree63b709b44ac9a6b07f184ed8ac209654a192c665
parent9818734e0148510967ca9ee0d1aa8b196b509f02 (diff)
mesa: use enums for TEXTURE_x_INDEX values
Plus, put them in the order of highest to lowest priority to simplify the texture_override() loop.
-rw-r--r--src/mesa/main/context.c11
-rw-r--r--src/mesa/main/mtypes.h37
-rw-r--r--src/mesa/main/texstate.c20
3 files changed, 28 insertions, 40 deletions
diff --git a/src/mesa/main/context.c b/src/mesa/main/context.c
index 04848794aa2..75b3992a29d 100644
--- a/src/mesa/main/context.c
+++ b/src/mesa/main/context.c
@@ -467,14 +467,15 @@ alloc_shared_state( GLcontext *ctx )
/* Create default texture objects */
for (i = 0; i < NUM_TEXTURE_TARGETS; i++) {
+ /* NOTE: the order of these enums matches the TEXTURE_x_INDEX values */
static const GLenum targets[NUM_TEXTURE_TARGETS] = {
- GL_TEXTURE_1D,
- GL_TEXTURE_2D,
- GL_TEXTURE_3D,
+ GL_TEXTURE_2D_ARRAY_EXT,
+ GL_TEXTURE_1D_ARRAY_EXT,
GL_TEXTURE_CUBE_MAP,
+ GL_TEXTURE_3D,
GL_TEXTURE_RECTANGLE_NV,
- GL_TEXTURE_1D_ARRAY_EXT,
- GL_TEXTURE_2D_ARRAY_EXT
+ GL_TEXTURE_2D,
+ GL_TEXTURE_1D
};
ss->DefaultTex[i] = ctx->Driver.NewTextureObject(ctx, 0, targets[i]);
if (!ss->DefaultTex[i])
diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h
index 06cef3d670f..302b7aa74f0 100644
--- a/src/mesa/main/mtypes.h
+++ b/src/mesa/main/mtypes.h
@@ -1145,34 +1145,35 @@ struct gl_stencil_attrib
};
-/** 1D, 2D, 3D, CUBE, RECT, 1D_ARRAY, and 2D_ARRAY targets */
-#define NUM_TEXTURE_TARGETS 7
-
/**
- * An index for each type of texture object
+ * An index for each type of texture object. These correspond to the GL
+ * target target enums, such as GL_TEXTURE_2D, GL_TEXTURE_CUBE_MAP, etc.
+ * Note: the order is from highest priority to lowest priority.
*/
-/*@{*/
-#define TEXTURE_1D_INDEX 0
-#define TEXTURE_2D_INDEX 1
-#define TEXTURE_3D_INDEX 2
-#define TEXTURE_CUBE_INDEX 3
-#define TEXTURE_RECT_INDEX 4
-#define TEXTURE_1D_ARRAY_INDEX 5
-#define TEXTURE_2D_ARRAY_INDEX 6
-/*@}*/
+enum {
+ TEXTURE_2D_ARRAY_INDEX,
+ TEXTURE_1D_ARRAY_INDEX,
+ TEXTURE_CUBE_INDEX,
+ TEXTURE_3D_INDEX,
+ TEXTURE_RECT_INDEX,
+ TEXTURE_2D_INDEX,
+ TEXTURE_1D_INDEX,
+ NUM_TEXTURE_TARGETS
+};
+
/**
* Bit flags for each type of texture object
* Used for Texture.Unit[]._ReallyEnabled flags.
*/
/*@{*/
-#define TEXTURE_1D_BIT (1 << TEXTURE_1D_INDEX)
-#define TEXTURE_2D_BIT (1 << TEXTURE_2D_INDEX)
-#define TEXTURE_3D_BIT (1 << TEXTURE_3D_INDEX)
+#define TEXTURE_2D_ARRAY_BIT (1 << TEXTURE_2D_ARRAY_INDEX)
+#define TEXTURE_1D_ARRAY_BIT (1 << TEXTURE_1D_ARRAY_INDEX)
#define TEXTURE_CUBE_BIT (1 << TEXTURE_CUBE_INDEX)
+#define TEXTURE_3D_BIT (1 << TEXTURE_3D_INDEX)
#define TEXTURE_RECT_BIT (1 << TEXTURE_RECT_INDEX)
-#define TEXTURE_1D_ARRAY_BIT (1 << TEXTURE_1D_ARRAY_INDEX)
-#define TEXTURE_2D_ARRAY_BIT (1 << TEXTURE_2D_ARRAY_INDEX)
+#define TEXTURE_2D_BIT (1 << TEXTURE_2D_INDEX)
+#define TEXTURE_1D_BIT (1 << TEXTURE_1D_INDEX)
/*@}*/
diff --git a/src/mesa/main/texstate.c b/src/mesa/main/texstate.c
index 27927d60b03..3f16d49a419 100644
--- a/src/mesa/main/texstate.c
+++ b/src/mesa/main/texstate.c
@@ -548,7 +548,7 @@ update_texture_state( GLcontext *ctx )
for (unit = 0; unit < ctx->Const.MaxTextureImageUnits; unit++) {
struct gl_texture_unit *texUnit = &ctx->Texture.Unit[unit];
GLbitfield enableBits;
- GLuint tex;
+ GLuint texIndex;
texUnit->_Current = NULL;
texUnit->_ReallyEnabled = 0;
@@ -575,26 +575,12 @@ update_texture_state( GLcontext *ctx )
if (enableBits == 0x0)
continue;
- for (tex = 0; tex < NUM_TEXTURE_TARGETS; tex++) {
- ASSERT(texUnit->CurrentTex[tex]);
- }
-
/* Look for the highest-priority texture target that's enabled and
* complete. That's the one we'll use for texturing. If we're using
* a fragment program we're guaranteed that bitcount(enabledBits) <= 1.
+ * Note that the TEXTURE_x_INDEX values are in high to low priority.
*/
- for (tex = 0; tex < NUM_TEXTURE_TARGETS; tex++) {
- /* texture indexes from highest to lowest priority */
- static const GLuint targets[NUM_TEXTURE_TARGETS] = {
- TEXTURE_2D_ARRAY_INDEX,
- TEXTURE_1D_ARRAY_INDEX,
- TEXTURE_CUBE_INDEX,
- TEXTURE_3D_INDEX,
- TEXTURE_RECT_INDEX,
- TEXTURE_2D_INDEX,
- TEXTURE_1D_INDEX
- };
- GLuint texIndex = targets[tex];
+ for (texIndex = 0; texIndex < NUM_TEXTURE_TARGETS; texIndex++) {
texture_override(ctx, texUnit, enableBits,
texUnit->CurrentTex[texIndex], 1 << texIndex);
}