summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBrian Paul <[email protected]>2009-09-01 15:51:23 -0600
committerBrian Paul <[email protected]>2009-09-01 17:39:31 -0600
commitb5ec0a68589c5d8f0d4be2556ea6d6b01fd4e37d (patch)
treef86c6845c0bcacddf648580b18e6fe9728492d5c
parentf337e2c4954b4779dcf2c2b4e0e068cb3ed7b841 (diff)
mesa: simplify translate_tex_src_bit()
-rw-r--r--src/mesa/main/texenvprogram.c23
1 files changed, 3 insertions, 20 deletions
diff --git a/src/mesa/main/texenvprogram.c b/src/mesa/main/texenvprogram.c
index 08985814858..ea0aa448e18 100644
--- a/src/mesa/main/texenvprogram.c
+++ b/src/mesa/main/texenvprogram.c
@@ -241,27 +241,13 @@ static GLuint translate_mode( GLenum envMode, GLenum mode )
}
-#define TEXTURE_UNKNOWN_INDEX 7
-
/**
* Translate TEXTURE_x_BIT to TEXTURE_x_INDEX.
*/
static GLuint translate_tex_src_bit( GLbitfield bit )
{
- /* make sure number of switch cases is correct */
- assert(NUM_TEXTURE_TARGETS == 7);
- switch (bit) {
- case TEXTURE_1D_BIT: return TEXTURE_1D_INDEX;
- case TEXTURE_2D_BIT: return TEXTURE_2D_INDEX;
- case TEXTURE_RECT_BIT: return TEXTURE_RECT_INDEX;
- case TEXTURE_3D_BIT: return TEXTURE_3D_INDEX;
- case TEXTURE_CUBE_BIT: return TEXTURE_CUBE_INDEX;
- case TEXTURE_1D_ARRAY_BIT: return TEXTURE_1D_ARRAY_INDEX;
- case TEXTURE_2D_ARRAY_BIT: return TEXTURE_2D_ARRAY_INDEX;
- default:
- assert(0);
- return TEXTURE_UNKNOWN_INDEX;
- }
+ ASSERT(bit);
+ return _mesa_ffs(bit) - 1;
}
@@ -1230,7 +1216,7 @@ emit_texenv(struct texenv_fragment_program *p, GLuint unit)
static void load_texture( struct texenv_fragment_program *p, GLuint unit )
{
if (is_undef(p->src_texture[unit])) {
- GLuint texTarget = p->state->unit[unit].source_index;
+ const GLuint texTarget = p->state->unit[unit].source_index;
struct ureg texcoord;
struct ureg tmp = get_tex_temp( p );
@@ -1242,9 +1228,6 @@ static void load_texture( struct texenv_fragment_program *p, GLuint unit )
texcoord = p->texcoord_tex[unit];
}
- if (texTarget == TEXTURE_UNKNOWN_INDEX)
- program_error(p, "TexSrcBit");
-
/* TODO: Use D0_MASK_XY where possible.
*/
if (p->state->unit[unit].enabled) {