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.
This commit is contained in:
parent
9818734e01
commit
d059d03034
|
@ -467,14 +467,15 @@ alloc_shared_state( GLcontext *ctx )
|
||||||
|
|
||||||
/* Create default texture objects */
|
/* Create default texture objects */
|
||||||
for (i = 0; i < NUM_TEXTURE_TARGETS; i++) {
|
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] = {
|
static const GLenum targets[NUM_TEXTURE_TARGETS] = {
|
||||||
GL_TEXTURE_1D,
|
GL_TEXTURE_2D_ARRAY_EXT,
|
||||||
GL_TEXTURE_2D,
|
|
||||||
GL_TEXTURE_3D,
|
|
||||||
GL_TEXTURE_CUBE_MAP,
|
|
||||||
GL_TEXTURE_RECTANGLE_NV,
|
|
||||||
GL_TEXTURE_1D_ARRAY_EXT,
|
GL_TEXTURE_1D_ARRAY_EXT,
|
||||||
GL_TEXTURE_2D_ARRAY_EXT
|
GL_TEXTURE_CUBE_MAP,
|
||||||
|
GL_TEXTURE_3D,
|
||||||
|
GL_TEXTURE_RECTANGLE_NV,
|
||||||
|
GL_TEXTURE_2D,
|
||||||
|
GL_TEXTURE_1D
|
||||||
};
|
};
|
||||||
ss->DefaultTex[i] = ctx->Driver.NewTextureObject(ctx, 0, targets[i]);
|
ss->DefaultTex[i] = ctx->Driver.NewTextureObject(ctx, 0, targets[i]);
|
||||||
if (!ss->DefaultTex[i])
|
if (!ss->DefaultTex[i])
|
||||||
|
|
|
@ -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.
|
||||||
*/
|
*/
|
||||||
/*@{*/
|
enum {
|
||||||
#define TEXTURE_1D_INDEX 0
|
TEXTURE_2D_ARRAY_INDEX,
|
||||||
#define TEXTURE_2D_INDEX 1
|
TEXTURE_1D_ARRAY_INDEX,
|
||||||
#define TEXTURE_3D_INDEX 2
|
TEXTURE_CUBE_INDEX,
|
||||||
#define TEXTURE_CUBE_INDEX 3
|
TEXTURE_3D_INDEX,
|
||||||
#define TEXTURE_RECT_INDEX 4
|
TEXTURE_RECT_INDEX,
|
||||||
#define TEXTURE_1D_ARRAY_INDEX 5
|
TEXTURE_2D_INDEX,
|
||||||
#define TEXTURE_2D_ARRAY_INDEX 6
|
TEXTURE_1D_INDEX,
|
||||||
/*@}*/
|
NUM_TEXTURE_TARGETS
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Bit flags for each type of texture object
|
* Bit flags for each type of texture object
|
||||||
* Used for Texture.Unit[]._ReallyEnabled flags.
|
* 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_CUBE_BIT (1 << TEXTURE_CUBE_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_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_2D_BIT (1 << TEXTURE_2D_INDEX)
|
||||||
|
#define TEXTURE_1D_BIT (1 << TEXTURE_1D_INDEX)
|
||||||
/*@}*/
|
/*@}*/
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -548,7 +548,7 @@ update_texture_state( GLcontext *ctx )
|
||||||
for (unit = 0; unit < ctx->Const.MaxTextureImageUnits; unit++) {
|
for (unit = 0; unit < ctx->Const.MaxTextureImageUnits; unit++) {
|
||||||
struct gl_texture_unit *texUnit = &ctx->Texture.Unit[unit];
|
struct gl_texture_unit *texUnit = &ctx->Texture.Unit[unit];
|
||||||
GLbitfield enableBits;
|
GLbitfield enableBits;
|
||||||
GLuint tex;
|
GLuint texIndex;
|
||||||
|
|
||||||
texUnit->_Current = NULL;
|
texUnit->_Current = NULL;
|
||||||
texUnit->_ReallyEnabled = 0;
|
texUnit->_ReallyEnabled = 0;
|
||||||
|
@ -575,26 +575,12 @@ update_texture_state( GLcontext *ctx )
|
||||||
if (enableBits == 0x0)
|
if (enableBits == 0x0)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
for (tex = 0; tex < NUM_TEXTURE_TARGETS; tex++) {
|
|
||||||
ASSERT(texUnit->CurrentTex[tex]);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Look for the highest-priority texture target that's enabled and
|
/* 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
|
* complete. That's the one we'll use for texturing. If we're using
|
||||||
* a fragment program we're guaranteed that bitcount(enabledBits) <= 1.
|
* 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++) {
|
for (texIndex = 0; texIndex < NUM_TEXTURE_TARGETS; texIndex++) {
|
||||||
/* 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];
|
|
||||||
texture_override(ctx, texUnit, enableBits,
|
texture_override(ctx, texUnit, enableBits,
|
||||||
texUnit->CurrentTex[texIndex], 1 << texIndex);
|
texUnit->CurrentTex[texIndex], 1 << texIndex);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue