From: Brian Paul Date: Sat, 21 Feb 2009 20:23:04 +0000 (-0700) Subject: mesa: re-org texgen state X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=9705cff2033f1771a39ac3bb78eb5fcea522218a;p=mesa.git mesa: re-org texgen state New gl_texgen struct allows quite a bit of code reduction. --- diff --git a/src/mesa/drivers/dri/r200/r200_texstate.c b/src/mesa/drivers/dri/r200/r200_texstate.c index 3f9a2f4ac1b..0ad5651cd47 100644 --- a/src/mesa/drivers/dri/r200/r200_texstate.c +++ b/src/mesa/drivers/dri/r200/r200_texstate.c @@ -1366,27 +1366,27 @@ static GLboolean r200_validate_texgen( GLcontext *ctx, GLuint unit ) fprintf(stderr, "%s unit %d\n", __FUNCTION__, unit); if (texUnit->TexGenEnabled & S_BIT) { - mode = texUnit->GenModeS; + mode = texUnit->GenS.Mode; } else { tgcm |= R200_TEXGEN_COMP_S << (unit * 4); } if (texUnit->TexGenEnabled & T_BIT) { - if (texUnit->GenModeT != mode) + if (texUnit->GenT.Mode != mode) mixed_fallback = GL_TRUE; } else { tgcm |= R200_TEXGEN_COMP_T << (unit * 4); } if (texUnit->TexGenEnabled & R_BIT) { - if (texUnit->GenModeR != mode) + if (texUnit->GenR.Mode != mode) mixed_fallback = GL_TRUE; } else { tgcm |= R200_TEXGEN_COMP_R << (unit * 4); } if (texUnit->TexGenEnabled & Q_BIT) { - if (texUnit->GenModeQ != mode) + if (texUnit->GenQ.Mode != mode) mixed_fallback = GL_TRUE; } else { tgcm |= R200_TEXGEN_COMP_Q << (unit * 4); @@ -1395,8 +1395,8 @@ static GLboolean r200_validate_texgen( GLcontext *ctx, GLuint unit ) if (mixed_fallback) { if (R200_DEBUG & DEBUG_FALLBACKS) fprintf(stderr, "fallback mixed texgen, 0x%x (0x%x 0x%x 0x%x 0x%x)\n", - texUnit->TexGenEnabled, texUnit->GenModeS, texUnit->GenModeT, - texUnit->GenModeR, texUnit->GenModeQ); + texUnit->TexGenEnabled, texUnit->GenS.Mode, texUnit->GenT.Mode, + texUnit->GenR.Mode, texUnit->GenQ.Mode); return GL_FALSE; } @@ -1414,8 +1414,10 @@ static GLboolean r200_validate_texgen( GLcontext *ctx, GLuint unit ) switch (mode) { case GL_OBJECT_LINEAR: { GLuint needtgenable = r200_need_dis_texgen( texUnit->TexGenEnabled, - texUnit->ObjectPlaneS, texUnit->ObjectPlaneT, - texUnit->ObjectPlaneR, texUnit->ObjectPlaneQ ); + texUnit->GenS.ObjectPlane, + texUnit->GenT.ObjectPlane, + texUnit->GenR.ObjectPlane, + texUnit->GenQ.ObjectPlane ); if (needtgenable & (S_BIT | T_BIT)) { if (R200_DEBUG & DEBUG_FALLBACKS) fprintf(stderr, "fallback mixed texgen / obj plane, 0x%x\n", @@ -1431,17 +1433,19 @@ static GLboolean r200_validate_texgen( GLcontext *ctx, GLuint unit ) tgi |= R200_TEXGEN_INPUT_OBJ << inputshift; set_texgen_matrix( rmesa, unit, - (texUnit->TexGenEnabled & S_BIT) ? texUnit->ObjectPlaneS : I, - (texUnit->TexGenEnabled & T_BIT) ? texUnit->ObjectPlaneT : I + 4, - (texUnit->TexGenEnabled & R_BIT) ? texUnit->ObjectPlaneR : I + 8, - (texUnit->TexGenEnabled & Q_BIT) ? texUnit->ObjectPlaneQ : I + 12); + (texUnit->TexGenEnabled & S_BIT) ? texUnit->GenS.ObjectPlane : I, + (texUnit->TexGenEnabled & T_BIT) ? texUnit->GenT.ObjectPlane : I + 4, + (texUnit->TexGenEnabled & R_BIT) ? texUnit->GenR.ObjectPlane : I + 8, + (texUnit->TexGenEnabled & Q_BIT) ? texUnit->GenQ.ObjectPlane : I + 12); } break; case GL_EYE_LINEAR: { GLuint needtgenable = r200_need_dis_texgen( texUnit->TexGenEnabled, - texUnit->EyePlaneS, texUnit->EyePlaneT, - texUnit->EyePlaneR, texUnit->EyePlaneQ ); + texUnit->GenS.EyePlane, + texUnit->GenT.EyePlane, + texUnit->GenR.EyePlane, + texUnit->GenQ.EyePlane ); if (needtgenable & (S_BIT | T_BIT)) { if (R200_DEBUG & DEBUG_FALLBACKS) fprintf(stderr, "fallback mixed texgen / eye plane, 0x%x\n", @@ -1456,10 +1460,10 @@ static GLboolean r200_validate_texgen( GLcontext *ctx, GLuint unit ) } tgi |= R200_TEXGEN_INPUT_EYE << inputshift; set_texgen_matrix( rmesa, unit, - (texUnit->TexGenEnabled & S_BIT) ? texUnit->EyePlaneS : I, - (texUnit->TexGenEnabled & T_BIT) ? texUnit->EyePlaneT : I + 4, - (texUnit->TexGenEnabled & R_BIT) ? texUnit->EyePlaneR : I + 8, - (texUnit->TexGenEnabled & Q_BIT) ? texUnit->EyePlaneQ : I + 12); + (texUnit->TexGenEnabled & S_BIT) ? texUnit->GenS.EyePlane : I, + (texUnit->TexGenEnabled & T_BIT) ? texUnit->GenT.EyePlane : I + 4, + (texUnit->TexGenEnabled & R_BIT) ? texUnit->GenR.EyePlane : I + 8, + (texUnit->TexGenEnabled & Q_BIT) ? texUnit->GenQ.EyePlane : I + 12); } break; @@ -1495,7 +1499,7 @@ static GLboolean r200_validate_texgen( GLcontext *ctx, GLuint unit ) */ if (R200_DEBUG & DEBUG_FALLBACKS) fprintf(stderr, "fallback unsupported texgen, %d\n", - texUnit->GenModeS); + texUnit->GenS.Mode); return GL_FALSE; } diff --git a/src/mesa/drivers/dri/radeon/radeon_texstate.c b/src/mesa/drivers/dri/radeon/radeon_texstate.c index 1e2f654addf..b165205c093 100644 --- a/src/mesa/drivers/dri/radeon/radeon_texstate.c +++ b/src/mesa/drivers/dri/radeon/radeon_texstate.c @@ -1023,11 +1023,11 @@ static GLboolean radeon_validate_texgen( GLcontext *ctx, GLuint unit ) */ else if ( (texUnit->TexGenEnabled & S_BIT) && (texUnit->TexGenEnabled & T_BIT) && - (texUnit->GenModeS == texUnit->GenModeT) ) { + (texUnit->GenS.Mode == texUnit->GenT.Mode) ) { if ( ((texUnit->TexGenEnabled & R_BIT) && - (texUnit->GenModeS != texUnit->GenModeR)) || + (texUnit->GenS.Mode != texUnit->GenR.Mode)) || ((texUnit->TexGenEnabled & Q_BIT) && - (texUnit->GenModeS != texUnit->GenModeQ)) ) { + (texUnit->GenS.Mode != texUnit->GenQ.Mode)) ) { /* Mixed modes, fallback: */ if (RADEON_DEBUG & DEBUG_FALLBACKS) @@ -1051,23 +1051,23 @@ static GLboolean radeon_validate_texgen( GLcontext *ctx, GLuint unit ) rmesa->hw.tcl.cmd[TCL_OUTPUT_VTXFMT] |= RADEON_Q_BIT(unit); } - switch (texUnit->GenModeS) { + switch (texUnit->GenS.Mode) { case GL_OBJECT_LINEAR: rmesa->TexGenEnabled |= RADEON_TEXGEN_INPUT_OBJ << inputshift; set_texgen_matrix( rmesa, unit, - texUnit->ObjectPlaneS, - texUnit->ObjectPlaneT, - texUnit->ObjectPlaneR, - texUnit->ObjectPlaneQ); + texUnit->GenS.ObjectPlane, + texUnit->GenT.ObjectPlane, + texUnit->GenR.ObjectPlane, + texUnit->GenQ.ObjectPlane); break; case GL_EYE_LINEAR: rmesa->TexGenEnabled |= RADEON_TEXGEN_INPUT_EYE << inputshift; set_texgen_matrix( rmesa, unit, - texUnit->EyePlaneS, - texUnit->EyePlaneT, - texUnit->EyePlaneR, - texUnit->EyePlaneQ); + texUnit->GenS.EyePlane, + texUnit->GenT.EyePlane, + texUnit->GenR.EyePlane, + texUnit->GenQ.EyePlane); break; case GL_REFLECTION_MAP_NV: diff --git a/src/mesa/main/attrib.c b/src/mesa/main/attrib.c index add0045959c..dc33eb1fac2 100644 --- a/src/mesa/main/attrib.c +++ b/src/mesa/main/attrib.c @@ -699,26 +699,26 @@ pop_texture_group(GLcontext *ctx, struct texture_state *texstate) } _mesa_TexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, unit->EnvMode); _mesa_TexEnvfv(GL_TEXTURE_ENV, GL_TEXTURE_ENV_COLOR, unit->EnvColor); - _mesa_TexGeni(GL_S, GL_TEXTURE_GEN_MODE, unit->GenModeS); - _mesa_TexGeni(GL_T, GL_TEXTURE_GEN_MODE, unit->GenModeT); - _mesa_TexGeni(GL_R, GL_TEXTURE_GEN_MODE, unit->GenModeR); - _mesa_TexGeni(GL_Q, GL_TEXTURE_GEN_MODE, unit->GenModeQ); - _mesa_TexGenfv(GL_S, GL_OBJECT_PLANE, unit->ObjectPlaneS); - _mesa_TexGenfv(GL_T, GL_OBJECT_PLANE, unit->ObjectPlaneT); - _mesa_TexGenfv(GL_R, GL_OBJECT_PLANE, unit->ObjectPlaneR); - _mesa_TexGenfv(GL_Q, GL_OBJECT_PLANE, unit->ObjectPlaneQ); + _mesa_TexGeni(GL_S, GL_TEXTURE_GEN_MODE, unit->GenS.Mode); + _mesa_TexGeni(GL_T, GL_TEXTURE_GEN_MODE, unit->GenT.Mode); + _mesa_TexGeni(GL_R, GL_TEXTURE_GEN_MODE, unit->GenR.Mode); + _mesa_TexGeni(GL_Q, GL_TEXTURE_GEN_MODE, unit->GenQ.Mode); + _mesa_TexGenfv(GL_S, GL_OBJECT_PLANE, unit->GenS.ObjectPlane); + _mesa_TexGenfv(GL_T, GL_OBJECT_PLANE, unit->GenT.ObjectPlane); + _mesa_TexGenfv(GL_R, GL_OBJECT_PLANE, unit->GenR.ObjectPlane); + _mesa_TexGenfv(GL_Q, GL_OBJECT_PLANE, unit->GenQ.ObjectPlane); /* Eye plane done differently to avoid re-transformation */ { struct gl_texture_unit *destUnit = &ctx->Texture.Unit[u]; - COPY_4FV(destUnit->EyePlaneS, unit->EyePlaneS); - COPY_4FV(destUnit->EyePlaneT, unit->EyePlaneT); - COPY_4FV(destUnit->EyePlaneR, unit->EyePlaneR); - COPY_4FV(destUnit->EyePlaneQ, unit->EyePlaneQ); + COPY_4FV(destUnit->GenS.EyePlane, unit->GenS.EyePlane); + COPY_4FV(destUnit->GenT.EyePlane, unit->GenT.EyePlane); + COPY_4FV(destUnit->GenR.EyePlane, unit->GenR.EyePlane); + COPY_4FV(destUnit->GenQ.EyePlane, unit->GenQ.EyePlane); if (ctx->Driver.TexGen) { - ctx->Driver.TexGen(ctx, GL_S, GL_EYE_PLANE, unit->EyePlaneS); - ctx->Driver.TexGen(ctx, GL_T, GL_EYE_PLANE, unit->EyePlaneT); - ctx->Driver.TexGen(ctx, GL_R, GL_EYE_PLANE, unit->EyePlaneR); - ctx->Driver.TexGen(ctx, GL_Q, GL_EYE_PLANE, unit->EyePlaneQ); + ctx->Driver.TexGen(ctx, GL_S, GL_EYE_PLANE, unit->GenS.EyePlane); + ctx->Driver.TexGen(ctx, GL_T, GL_EYE_PLANE, unit->GenT.EyePlane); + ctx->Driver.TexGen(ctx, GL_R, GL_EYE_PLANE, unit->GenR.EyePlane); + ctx->Driver.TexGen(ctx, GL_Q, GL_EYE_PLANE, unit->GenQ.EyePlane); } } _mesa_set_enable(ctx, GL_TEXTURE_GEN_S, diff --git a/src/mesa/main/ffvertex_prog.c b/src/mesa/main/ffvertex_prog.c index d70b78f2586..42c8cc97c08 100644 --- a/src/mesa/main/ffvertex_prog.c +++ b/src/mesa/main/ffvertex_prog.c @@ -293,16 +293,16 @@ static void make_state_key( GLcontext *ctx, struct state_key *key ) key->unit[i].texgen_mode0 = translate_texgen( texUnit->TexGenEnabled & (1<<0), - texUnit->GenModeS ); + texUnit->GenS.Mode ); key->unit[i].texgen_mode1 = translate_texgen( texUnit->TexGenEnabled & (1<<1), - texUnit->GenModeT ); + texUnit->GenT.Mode ); key->unit[i].texgen_mode2 = translate_texgen( texUnit->TexGenEnabled & (1<<2), - texUnit->GenModeR ); + texUnit->GenR.Mode ); key->unit[i].texgen_mode3 = translate_texgen( texUnit->TexGenEnabled & (1<<3), - texUnit->GenModeQ ); + texUnit->GenQ.Mode ); } } } diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h index 235d6b6bb54..92fe4cb77d8 100644 --- a/src/mesa/main/mtypes.h +++ b/src/mesa/main/mtypes.h @@ -1492,6 +1492,18 @@ struct gl_tex_env_combine_state }; +/** + * Texture coord generation state. + */ +struct gl_texgen +{ + GLenum Mode; /**< GL_EYE_LINEAR, GL_SPHERE_MAP, etc */ + GLbitfield _ModeBit; /**< TEXGEN_x bit corresponding to Mode */ + GLfloat ObjectPlane[4]; + GLfloat EyePlane[4]; +}; + + /** * Texture unit state. Contains enable flags, texture environment/function/ * combiners, texgen state, pointers to current texture objects and @@ -1504,28 +1516,14 @@ struct gl_texture_unit GLenum EnvMode; /**< GL_MODULATE, GL_DECAL, GL_BLEND, etc. */ GLfloat EnvColor[4]; + + struct gl_texgen GenS; + struct gl_texgen GenT; + struct gl_texgen GenR; + struct gl_texgen GenQ; GLbitfield TexGenEnabled; /**< Bitwise-OR of [STRQ]_BIT values */ - /** \name Tex coord generation mode - * Either GL_OBJECT_LINEAR, GL_EYE_LINEAR or GL_SPHERE_MAP. */ - /*@{*/ - GLenum GenModeS; - GLenum GenModeT; - GLenum GenModeR; - GLenum GenModeQ; - /*@}*/ - GLbitfield _GenBitS; - GLbitfield _GenBitT; - GLbitfield _GenBitR; - GLbitfield _GenBitQ; - GLbitfield _GenFlags; /**< bitwise or of _GenBit[STRQ] */ - GLfloat ObjectPlaneS[4]; - GLfloat ObjectPlaneT[4]; - GLfloat ObjectPlaneR[4]; - GLfloat ObjectPlaneQ[4]; - GLfloat EyePlaneS[4]; - GLfloat EyePlaneT[4]; - GLfloat EyePlaneR[4]; - GLfloat EyePlaneQ[4]; + GLbitfield _GenFlags; /**< Bitwise-OR of Gen[STRQ]._ModeBit */ + GLfloat LodBias; /**< for biasing mipmap levels */ /** diff --git a/src/mesa/main/texgen.c b/src/mesa/main/texgen.c index d2baecb92ac..e3feb024c31 100644 --- a/src/mesa/main/texgen.c +++ b/src/mesa/main/texgen.c @@ -1,8 +1,9 @@ /* * Mesa 3-D graphics library - * Version: 7.1 + * Version: 7.5 * * Copyright (C) 1999-2008 Brian Paul All Rights Reserved. + * Copyright (C) 2009 VMware, Inc. All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), @@ -37,12 +38,33 @@ #include "math/m_matrix.h" +/** + * Return texgen state for given coordinate + */ +static struct gl_texgen * +get_texgen(struct gl_texture_unit *texUnit, GLenum coord) +{ + switch (coord) { + case GL_S: + return &texUnit->GenS; + case GL_T: + return &texUnit->GenT; + case GL_R: + return &texUnit->GenR; + case GL_Q: + return &texUnit->GenQ; + default: + return NULL; + } +} + void GLAPIENTRY _mesa_TexGenfv( GLenum coord, GLenum pname, const GLfloat *params ) { - GET_CURRENT_CONTEXT(ctx); struct gl_texture_unit *texUnit; + struct gl_texgen *texgen; + GET_CURRENT_CONTEXT(ctx); ASSERT_OUTSIDE_BEGIN_END(ctx); if (MESA_VERBOSE&(VERBOSE_API|VERBOSE_TEXTURE)) @@ -59,210 +81,79 @@ _mesa_TexGenfv( GLenum coord, GLenum pname, const GLfloat *params ) texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit]; - switch (coord) { - case GL_S: - if (pname==GL_TEXTURE_GEN_MODE) { - GLenum mode = (GLenum) (GLint) *params; - GLbitfield bits; - switch (mode) { - case GL_OBJECT_LINEAR: - bits = TEXGEN_OBJ_LINEAR; - break; - case GL_EYE_LINEAR: - bits = TEXGEN_EYE_LINEAR; - break; - case GL_REFLECTION_MAP_NV: - bits = TEXGEN_REFLECTION_MAP_NV; - break; - case GL_NORMAL_MAP_NV: - bits = TEXGEN_NORMAL_MAP_NV; - break; - case GL_SPHERE_MAP: - bits = TEXGEN_SPHERE_MAP; - break; - default: - _mesa_error( ctx, GL_INVALID_ENUM, "glTexGenfv(param)" ); - return; - } - if (texUnit->GenModeS == mode) - return; - FLUSH_VERTICES(ctx, _NEW_TEXTURE); - texUnit->GenModeS = mode; - texUnit->_GenBitS = bits; - } - else if (pname==GL_OBJECT_PLANE) { - if (TEST_EQ_4V(texUnit->ObjectPlaneS, params)) - return; - FLUSH_VERTICES(ctx, _NEW_TEXTURE); - COPY_4FV(texUnit->ObjectPlaneS, params); - } - else if (pname==GL_EYE_PLANE) { - GLfloat tmp[4]; - /* Transform plane equation by the inverse modelview matrix */ - if (_math_matrix_is_dirty(ctx->ModelviewMatrixStack.Top)) { - _math_matrix_analyse( ctx->ModelviewMatrixStack.Top ); - } - _mesa_transform_vector( tmp, params, ctx->ModelviewMatrixStack.Top->inv ); - if (TEST_EQ_4V(texUnit->EyePlaneS, tmp)) - return; - FLUSH_VERTICES(ctx, _NEW_TEXTURE); - COPY_4FV(texUnit->EyePlaneS, tmp); - } - else { - _mesa_error( ctx, GL_INVALID_ENUM, "glTexGenfv(pname)" ); - return; - } - break; - case GL_T: - if (pname==GL_TEXTURE_GEN_MODE) { - GLenum mode = (GLenum) (GLint) *params; - GLbitfield bitt; - switch (mode) { - case GL_OBJECT_LINEAR: - bitt = TEXGEN_OBJ_LINEAR; - break; - case GL_EYE_LINEAR: - bitt = TEXGEN_EYE_LINEAR; - break; - case GL_REFLECTION_MAP_NV: - bitt = TEXGEN_REFLECTION_MAP_NV; - break; - case GL_NORMAL_MAP_NV: - bitt = TEXGEN_NORMAL_MAP_NV; - break; - case GL_SPHERE_MAP: - bitt = TEXGEN_SPHERE_MAP; - break; - default: - _mesa_error( ctx, GL_INVALID_ENUM, "glTexGenfv(param)" ); - return; - } - if (texUnit->GenModeT == mode) - return; - FLUSH_VERTICES(ctx, _NEW_TEXTURE); - texUnit->GenModeT = mode; - texUnit->_GenBitT = bitt; - } - else if (pname==GL_OBJECT_PLANE) { - if (TEST_EQ_4V(texUnit->ObjectPlaneT, params)) - return; - FLUSH_VERTICES(ctx, _NEW_TEXTURE); - COPY_4FV(texUnit->ObjectPlaneT, params); - } - else if (pname==GL_EYE_PLANE) { - GLfloat tmp[4]; - /* Transform plane equation by the inverse modelview matrix */ - if (_math_matrix_is_dirty(ctx->ModelviewMatrixStack.Top)) { - _math_matrix_analyse( ctx->ModelviewMatrixStack.Top ); - } - _mesa_transform_vector( tmp, params, ctx->ModelviewMatrixStack.Top->inv ); - if (TEST_EQ_4V(texUnit->EyePlaneT, tmp)) - return; - FLUSH_VERTICES(ctx, _NEW_TEXTURE); - COPY_4FV(texUnit->EyePlaneT, tmp); - } - else { - _mesa_error( ctx, GL_INVALID_ENUM, "glTexGenfv(pname)" ); - return; - } - break; - case GL_R: - if (pname==GL_TEXTURE_GEN_MODE) { - GLenum mode = (GLenum) (GLint) *params; - GLbitfield bitr; - switch (mode) { - case GL_OBJECT_LINEAR: - bitr = TEXGEN_OBJ_LINEAR; - break; - case GL_REFLECTION_MAP_NV: - bitr = TEXGEN_REFLECTION_MAP_NV; - break; - case GL_NORMAL_MAP_NV: - bitr = TEXGEN_NORMAL_MAP_NV; - break; - case GL_EYE_LINEAR: - bitr = TEXGEN_EYE_LINEAR; - break; - default: - _mesa_error( ctx, GL_INVALID_ENUM, "glTexGenfv(param)" ); - return; - } - if (texUnit->GenModeR == mode) - return; - FLUSH_VERTICES(ctx, _NEW_TEXTURE); - texUnit->GenModeR = mode; - texUnit->_GenBitR = bitr; - } - else if (pname==GL_OBJECT_PLANE) { - if (TEST_EQ_4V(texUnit->ObjectPlaneR, params)) - return; - FLUSH_VERTICES(ctx, _NEW_TEXTURE); - COPY_4FV(texUnit->ObjectPlaneR, params); - } - else if (pname==GL_EYE_PLANE) { - GLfloat tmp[4]; - /* Transform plane equation by the inverse modelview matrix */ - if (_math_matrix_is_dirty(ctx->ModelviewMatrixStack.Top)) { - _math_matrix_analyse( ctx->ModelviewMatrixStack.Top ); - } - _mesa_transform_vector( tmp, params, ctx->ModelviewMatrixStack.Top->inv ); - if (TEST_EQ_4V(texUnit->EyePlaneR, tmp)) - return; - FLUSH_VERTICES(ctx, _NEW_TEXTURE); - COPY_4FV(texUnit->EyePlaneR, tmp); - } - else { - _mesa_error( ctx, GL_INVALID_ENUM, "glTexGenfv(pname)" ); - return; - } - break; - case GL_Q: - if (pname==GL_TEXTURE_GEN_MODE) { - GLenum mode = (GLenum) (GLint) *params; - GLbitfield bitq; - switch (mode) { - case GL_OBJECT_LINEAR: - bitq = TEXGEN_OBJ_LINEAR; - break; - case GL_EYE_LINEAR: - bitq = TEXGEN_EYE_LINEAR; - break; - default: - _mesa_error( ctx, GL_INVALID_ENUM, "glTexGenfv(param)" ); - return; - } - if (texUnit->GenModeQ == mode) - return; - FLUSH_VERTICES(ctx, _NEW_TEXTURE); - texUnit->GenModeQ = mode; - texUnit->_GenBitQ = bitq; - } - else if (pname==GL_OBJECT_PLANE) { - if (TEST_EQ_4V(texUnit->ObjectPlaneQ, params)) - return; - FLUSH_VERTICES(ctx, _NEW_TEXTURE); - COPY_4FV(texUnit->ObjectPlaneQ, params); - } - else if (pname==GL_EYE_PLANE) { - GLfloat tmp[4]; - /* Transform plane equation by the inverse modelview matrix */ - if (_math_matrix_is_dirty(ctx->ModelviewMatrixStack.Top)) { - _math_matrix_analyse( ctx->ModelviewMatrixStack.Top ); - } - _mesa_transform_vector( tmp, params, ctx->ModelviewMatrixStack.Top->inv ); - if (TEST_EQ_4V(texUnit->EyePlaneQ, tmp)) - return; - FLUSH_VERTICES(ctx, _NEW_TEXTURE); - COPY_4FV(texUnit->EyePlaneQ, tmp); - } - else { - _mesa_error( ctx, GL_INVALID_ENUM, "glTexGenfv(pname)" ); - return; - } - break; - default: - _mesa_error( ctx, GL_INVALID_ENUM, "glTexGenfv(coord)" ); - return; + texgen = get_texgen(texUnit, coord); + if (!texgen) { + _mesa_error(ctx, GL_INVALID_ENUM, "glTexGen(coord)"); + return; + } + + switch (pname) { + case GL_TEXTURE_GEN_MODE: + { + GLenum mode = (GLenum) (GLint) params[0]; + GLbitfield bit = 0x0; + if (texgen->Mode == mode) + return; + switch (mode) { + case GL_OBJECT_LINEAR: + bit = TEXGEN_OBJ_LINEAR; + break; + case GL_EYE_LINEAR: + bit = TEXGEN_EYE_LINEAR; + break; + case GL_SPHERE_MAP: + if (coord == GL_S || coord == GL_T) + bit = TEXGEN_SPHERE_MAP; + break; + case GL_REFLECTION_MAP_NV: + if (coord != GL_Q) + bit = TEXGEN_REFLECTION_MAP_NV; + break; + case GL_NORMAL_MAP_NV: + if (coord != GL_Q) + bit = TEXGEN_NORMAL_MAP_NV; + break; + default: + ; /* nop */ + } + if (!bit) { + _mesa_error( ctx, GL_INVALID_ENUM, "glTexGenfv(param)" ); + return; + } + FLUSH_VERTICES(ctx, _NEW_TEXTURE); + texgen->Mode = mode; + texgen->_ModeBit = bit; + } + break; + + case GL_OBJECT_PLANE: + { + if (TEST_EQ_4V(texgen->ObjectPlane, params)) + return; + FLUSH_VERTICES(ctx, _NEW_TEXTURE); + COPY_4FV(texgen->ObjectPlane, params); + } + break; + + case GL_EYE_PLANE: + { + GLfloat tmp[4]; + /* Transform plane equation by the inverse modelview matrix */ + if (_math_matrix_is_dirty(ctx->ModelviewMatrixStack.Top)) { + _math_matrix_analyse(ctx->ModelviewMatrixStack.Top); + } + _mesa_transform_vector(tmp, params, + ctx->ModelviewMatrixStack.Top->inv); + if (TEST_EQ_4V(texgen->EyePlane, tmp)) + return; + FLUSH_VERTICES(ctx, _NEW_TEXTURE); + COPY_4FV(texgen->EyePlane, tmp); + } + break; + + default: + _mesa_error( ctx, GL_INVALID_ENUM, "glTexGenfv(pname)" ); + return; } if (ctx->Driver.TexGen) @@ -330,7 +221,8 @@ _mesa_TexGeni( GLenum coord, GLenum pname, GLint param ) void GLAPIENTRY _mesa_GetTexGendv( GLenum coord, GLenum pname, GLdouble *params ) { - const struct gl_texture_unit *texUnit; + struct gl_texture_unit *texUnit; + struct gl_texgen *texgen; GET_CURRENT_CONTEXT(ctx); ASSERT_OUTSIDE_BEGIN_END(ctx); @@ -341,70 +233,24 @@ _mesa_GetTexGendv( GLenum coord, GLenum pname, GLdouble *params ) texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit]; - switch (coord) { - case GL_S: - if (pname==GL_TEXTURE_GEN_MODE) { - params[0] = ENUM_TO_DOUBLE(texUnit->GenModeS); - } - else if (pname==GL_OBJECT_PLANE) { - COPY_4V( params, texUnit->ObjectPlaneS ); - } - else if (pname==GL_EYE_PLANE) { - COPY_4V( params, texUnit->EyePlaneS ); - } - else { - _mesa_error( ctx, GL_INVALID_ENUM, "glGetTexGendv(pname)" ); - return; - } - break; - case GL_T: - if (pname==GL_TEXTURE_GEN_MODE) { - params[0] = ENUM_TO_DOUBLE(texUnit->GenModeT); - } - else if (pname==GL_OBJECT_PLANE) { - COPY_4V( params, texUnit->ObjectPlaneT ); - } - else if (pname==GL_EYE_PLANE) { - COPY_4V( params, texUnit->EyePlaneT ); - } - else { - _mesa_error( ctx, GL_INVALID_ENUM, "glGetTexGendv(pname)" ); - return; - } - break; - case GL_R: - if (pname==GL_TEXTURE_GEN_MODE) { - params[0] = ENUM_TO_DOUBLE(texUnit->GenModeR); - } - else if (pname==GL_OBJECT_PLANE) { - COPY_4V( params, texUnit->ObjectPlaneR ); - } - else if (pname==GL_EYE_PLANE) { - COPY_4V( params, texUnit->EyePlaneR ); - } - else { - _mesa_error( ctx, GL_INVALID_ENUM, "glGetTexGendv(pname)" ); - return; - } - break; - case GL_Q: - if (pname==GL_TEXTURE_GEN_MODE) { - params[0] = ENUM_TO_DOUBLE(texUnit->GenModeQ); - } - else if (pname==GL_OBJECT_PLANE) { - COPY_4V( params, texUnit->ObjectPlaneQ ); - } - else if (pname==GL_EYE_PLANE) { - COPY_4V( params, texUnit->EyePlaneQ ); - } - else { - _mesa_error( ctx, GL_INVALID_ENUM, "glGetTexGendv(pname)" ); - return; - } - break; - default: - _mesa_error( ctx, GL_INVALID_ENUM, "glGetTexGendv(coord)" ); - return; + texgen = get_texgen(texUnit, coord); + if (!texgen) { + _mesa_error(ctx, GL_INVALID_ENUM, "glGetTexGendv(coord)"); + return; + } + + switch (pname) { + case GL_TEXTURE_GEN_MODE: + params[0] = ENUM_TO_DOUBLE(texgen->Mode); + break; + case GL_OBJECT_PLANE: + COPY_4V(params, texgen->ObjectPlane); + break; + case GL_EYE_PLANE: + COPY_4V(params, texgen->EyePlane); + break; + default: + _mesa_error( ctx, GL_INVALID_ENUM, "glGetTexGendv(pname)" ); } } @@ -413,7 +259,8 @@ _mesa_GetTexGendv( GLenum coord, GLenum pname, GLdouble *params ) void GLAPIENTRY _mesa_GetTexGenfv( GLenum coord, GLenum pname, GLfloat *params ) { - const struct gl_texture_unit *texUnit; + struct gl_texture_unit *texUnit; + struct gl_texgen *texgen; GET_CURRENT_CONTEXT(ctx); ASSERT_OUTSIDE_BEGIN_END(ctx); @@ -424,70 +271,24 @@ _mesa_GetTexGenfv( GLenum coord, GLenum pname, GLfloat *params ) texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit]; - switch (coord) { - case GL_S: - if (pname==GL_TEXTURE_GEN_MODE) { - params[0] = ENUM_TO_FLOAT(texUnit->GenModeS); - } - else if (pname==GL_OBJECT_PLANE) { - COPY_4V( params, texUnit->ObjectPlaneS ); - } - else if (pname==GL_EYE_PLANE) { - COPY_4V( params, texUnit->EyePlaneS ); - } - else { - _mesa_error( ctx, GL_INVALID_ENUM, "glGetTexGenfv(pname)" ); - return; - } - break; - case GL_T: - if (pname==GL_TEXTURE_GEN_MODE) { - params[0] = ENUM_TO_FLOAT(texUnit->GenModeT); - } - else if (pname==GL_OBJECT_PLANE) { - COPY_4V( params, texUnit->ObjectPlaneT ); - } - else if (pname==GL_EYE_PLANE) { - COPY_4V( params, texUnit->EyePlaneT ); - } - else { - _mesa_error( ctx, GL_INVALID_ENUM, "glGetTexGenfv(pname)" ); - return; - } - break; - case GL_R: - if (pname==GL_TEXTURE_GEN_MODE) { - params[0] = ENUM_TO_FLOAT(texUnit->GenModeR); - } - else if (pname==GL_OBJECT_PLANE) { - COPY_4V( params, texUnit->ObjectPlaneR ); - } - else if (pname==GL_EYE_PLANE) { - COPY_4V( params, texUnit->EyePlaneR ); - } - else { - _mesa_error( ctx, GL_INVALID_ENUM, "glGetTexGenfv(pname)" ); - return; - } - break; - case GL_Q: - if (pname==GL_TEXTURE_GEN_MODE) { - params[0] = ENUM_TO_FLOAT(texUnit->GenModeQ); - } - else if (pname==GL_OBJECT_PLANE) { - COPY_4V( params, texUnit->ObjectPlaneQ ); - } - else if (pname==GL_EYE_PLANE) { - COPY_4V( params, texUnit->EyePlaneQ ); - } - else { - _mesa_error( ctx, GL_INVALID_ENUM, "glGetTexGenfv(pname)" ); - return; - } - break; - default: - _mesa_error( ctx, GL_INVALID_ENUM, "glGetTexGenfv(coord)" ); - return; + texgen = get_texgen(texUnit, coord); + if (!texgen) { + _mesa_error(ctx, GL_INVALID_ENUM, "glGetTexGenfv(coord)"); + return; + } + + switch (pname) { + case GL_TEXTURE_GEN_MODE: + params[0] = ENUM_TO_FLOAT(texgen->Mode); + break; + case GL_OBJECT_PLANE: + COPY_4V(params, texgen->ObjectPlane); + break; + case GL_EYE_PLANE: + COPY_4V(params, texgen->EyePlane); + break; + default: + _mesa_error( ctx, GL_INVALID_ENUM, "glGetTexGenfv(pname)" ); } } @@ -496,7 +297,8 @@ _mesa_GetTexGenfv( GLenum coord, GLenum pname, GLfloat *params ) void GLAPIENTRY _mesa_GetTexGeniv( GLenum coord, GLenum pname, GLint *params ) { - const struct gl_texture_unit *texUnit; + struct gl_texture_unit *texUnit; + struct gl_texgen *texgen; GET_CURRENT_CONTEXT(ctx); ASSERT_OUTSIDE_BEGIN_END(ctx); @@ -507,94 +309,30 @@ _mesa_GetTexGeniv( GLenum coord, GLenum pname, GLint *params ) texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit]; - switch (coord) { - case GL_S: - if (pname==GL_TEXTURE_GEN_MODE) { - params[0] = texUnit->GenModeS; - } - else if (pname==GL_OBJECT_PLANE) { - params[0] = (GLint) texUnit->ObjectPlaneS[0]; - params[1] = (GLint) texUnit->ObjectPlaneS[1]; - params[2] = (GLint) texUnit->ObjectPlaneS[2]; - params[3] = (GLint) texUnit->ObjectPlaneS[3]; - } - else if (pname==GL_EYE_PLANE) { - params[0] = (GLint) texUnit->EyePlaneS[0]; - params[1] = (GLint) texUnit->EyePlaneS[1]; - params[2] = (GLint) texUnit->EyePlaneS[2]; - params[3] = (GLint) texUnit->EyePlaneS[3]; - } - else { - _mesa_error( ctx, GL_INVALID_ENUM, "glGetTexGeniv(pname)" ); - return; - } - break; - case GL_T: - if (pname==GL_TEXTURE_GEN_MODE) { - params[0] = texUnit->GenModeT; - } - else if (pname==GL_OBJECT_PLANE) { - params[0] = (GLint) texUnit->ObjectPlaneT[0]; - params[1] = (GLint) texUnit->ObjectPlaneT[1]; - params[2] = (GLint) texUnit->ObjectPlaneT[2]; - params[3] = (GLint) texUnit->ObjectPlaneT[3]; - } - else if (pname==GL_EYE_PLANE) { - params[0] = (GLint) texUnit->EyePlaneT[0]; - params[1] = (GLint) texUnit->EyePlaneT[1]; - params[2] = (GLint) texUnit->EyePlaneT[2]; - params[3] = (GLint) texUnit->EyePlaneT[3]; - } - else { - _mesa_error( ctx, GL_INVALID_ENUM, "glGetTexGeniv(pname)" ); - return; - } - break; - case GL_R: - if (pname==GL_TEXTURE_GEN_MODE) { - params[0] = texUnit->GenModeR; - } - else if (pname==GL_OBJECT_PLANE) { - params[0] = (GLint) texUnit->ObjectPlaneR[0]; - params[1] = (GLint) texUnit->ObjectPlaneR[1]; - params[2] = (GLint) texUnit->ObjectPlaneR[2]; - params[3] = (GLint) texUnit->ObjectPlaneR[3]; - } - else if (pname==GL_EYE_PLANE) { - params[0] = (GLint) texUnit->EyePlaneR[0]; - params[1] = (GLint) texUnit->EyePlaneR[1]; - params[2] = (GLint) texUnit->EyePlaneR[2]; - params[3] = (GLint) texUnit->EyePlaneR[3]; - } - else { - _mesa_error( ctx, GL_INVALID_ENUM, "glGetTexGeniv(pname)" ); - return; - } - break; - case GL_Q: - if (pname==GL_TEXTURE_GEN_MODE) { - params[0] = texUnit->GenModeQ; - } - else if (pname==GL_OBJECT_PLANE) { - params[0] = (GLint) texUnit->ObjectPlaneQ[0]; - params[1] = (GLint) texUnit->ObjectPlaneQ[1]; - params[2] = (GLint) texUnit->ObjectPlaneQ[2]; - params[3] = (GLint) texUnit->ObjectPlaneQ[3]; - } - else if (pname==GL_EYE_PLANE) { - params[0] = (GLint) texUnit->EyePlaneQ[0]; - params[1] = (GLint) texUnit->EyePlaneQ[1]; - params[2] = (GLint) texUnit->EyePlaneQ[2]; - params[3] = (GLint) texUnit->EyePlaneQ[3]; - } - else { - _mesa_error( ctx, GL_INVALID_ENUM, "glGetTexGeniv(pname)" ); - return; - } - break; - default: - _mesa_error( ctx, GL_INVALID_ENUM, "glGetTexGeniv(coord)" ); - return; + texgen = get_texgen(texUnit, coord); + if (!texgen) { + _mesa_error(ctx, GL_INVALID_ENUM, "glGetTexGeniv(coord)"); + return; + } + + switch (pname) { + case GL_TEXTURE_GEN_MODE: + params[0] = texgen->Mode; + break; + case GL_OBJECT_PLANE: + params[0] = (GLint) texgen->ObjectPlane[0]; + params[1] = (GLint) texgen->ObjectPlane[1]; + params[2] = (GLint) texgen->ObjectPlane[2]; + params[3] = (GLint) texgen->ObjectPlane[3]; + break; + case GL_EYE_PLANE: + params[0] = (GLint) texgen->EyePlane[0]; + params[1] = (GLint) texgen->EyePlane[1]; + params[2] = (GLint) texgen->EyePlane[2]; + params[3] = (GLint) texgen->EyePlane[3]; + break; + default: + _mesa_error( ctx, GL_INVALID_ENUM, "glGetTexGeniv(pname)" ); } } diff --git a/src/mesa/main/texstate.c b/src/mesa/main/texstate.c index 6586a486464..053097cec0e 100644 --- a/src/mesa/main/texstate.c +++ b/src/mesa/main/texstate.c @@ -85,23 +85,10 @@ _mesa_copy_texture_state( const GLcontext *src, GLcontext *dst ) dst->Texture.Unit[i].EnvMode = src->Texture.Unit[i].EnvMode; COPY_4V(dst->Texture.Unit[i].EnvColor, src->Texture.Unit[i].EnvColor); dst->Texture.Unit[i].TexGenEnabled = src->Texture.Unit[i].TexGenEnabled; - dst->Texture.Unit[i].GenModeS = src->Texture.Unit[i].GenModeS; - dst->Texture.Unit[i].GenModeT = src->Texture.Unit[i].GenModeT; - dst->Texture.Unit[i].GenModeR = src->Texture.Unit[i].GenModeR; - dst->Texture.Unit[i].GenModeQ = src->Texture.Unit[i].GenModeQ; - dst->Texture.Unit[i]._GenBitS = src->Texture.Unit[i]._GenBitS; - dst->Texture.Unit[i]._GenBitT = src->Texture.Unit[i]._GenBitT; - dst->Texture.Unit[i]._GenBitR = src->Texture.Unit[i]._GenBitR; - dst->Texture.Unit[i]._GenBitQ = src->Texture.Unit[i]._GenBitQ; - dst->Texture.Unit[i]._GenFlags = src->Texture.Unit[i]._GenFlags; - COPY_4V(dst->Texture.Unit[i].ObjectPlaneS, src->Texture.Unit[i].ObjectPlaneS); - COPY_4V(dst->Texture.Unit[i].ObjectPlaneT, src->Texture.Unit[i].ObjectPlaneT); - COPY_4V(dst->Texture.Unit[i].ObjectPlaneR, src->Texture.Unit[i].ObjectPlaneR); - COPY_4V(dst->Texture.Unit[i].ObjectPlaneQ, src->Texture.Unit[i].ObjectPlaneQ); - COPY_4V(dst->Texture.Unit[i].EyePlaneS, src->Texture.Unit[i].EyePlaneS); - COPY_4V(dst->Texture.Unit[i].EyePlaneT, src->Texture.Unit[i].EyePlaneT); - COPY_4V(dst->Texture.Unit[i].EyePlaneR, src->Texture.Unit[i].EyePlaneR); - COPY_4V(dst->Texture.Unit[i].EyePlaneQ, src->Texture.Unit[i].EyePlaneQ); + dst->Texture.Unit[i].GenS = src->Texture.Unit[i].GenS; + dst->Texture.Unit[i].GenT = src->Texture.Unit[i].GenT; + dst->Texture.Unit[i].GenR = src->Texture.Unit[i].GenR; + dst->Texture.Unit[i].GenQ = src->Texture.Unit[i].GenQ; dst->Texture.Unit[i].LodBias = src->Texture.Unit[i].LodBias; /* GL_EXT_texture_env_combine */ @@ -655,16 +642,16 @@ update_texture_state( GLcontext *ctx ) if (texUnit->TexGenEnabled) { if (texUnit->TexGenEnabled & S_BIT) { - texUnit->_GenFlags |= texUnit->_GenBitS; + texUnit->_GenFlags |= texUnit->GenS._ModeBit; } if (texUnit->TexGenEnabled & T_BIT) { - texUnit->_GenFlags |= texUnit->_GenBitT; - } - if (texUnit->TexGenEnabled & Q_BIT) { - texUnit->_GenFlags |= texUnit->_GenBitQ; + texUnit->_GenFlags |= texUnit->GenT._ModeBit; } if (texUnit->TexGenEnabled & R_BIT) { - texUnit->_GenFlags |= texUnit->_GenBitR; + texUnit->_GenFlags |= texUnit->GenR._ModeBit; + } + if (texUnit->TexGenEnabled & Q_BIT) { + texUnit->_GenFlags |= texUnit->GenQ._ModeBit; } ctx->Texture._TexGenEnabled |= ENABLE_TEXGEN(unit); @@ -756,24 +743,24 @@ init_texture_unit( GLcontext *ctx, GLuint unit ) texUnit->_CurrentCombine = & texUnit->_EnvMode; texUnit->TexGenEnabled = 0; - texUnit->GenModeS = GL_EYE_LINEAR; - texUnit->GenModeT = GL_EYE_LINEAR; - texUnit->GenModeR = GL_EYE_LINEAR; - texUnit->GenModeQ = GL_EYE_LINEAR; - texUnit->_GenBitS = TEXGEN_EYE_LINEAR; - texUnit->_GenBitT = TEXGEN_EYE_LINEAR; - texUnit->_GenBitR = TEXGEN_EYE_LINEAR; - texUnit->_GenBitQ = TEXGEN_EYE_LINEAR; + texUnit->GenS.Mode = GL_EYE_LINEAR; + texUnit->GenT.Mode = GL_EYE_LINEAR; + texUnit->GenR.Mode = GL_EYE_LINEAR; + texUnit->GenQ.Mode = GL_EYE_LINEAR; + texUnit->GenS._ModeBit = TEXGEN_EYE_LINEAR; + texUnit->GenT._ModeBit = TEXGEN_EYE_LINEAR; + texUnit->GenR._ModeBit = TEXGEN_EYE_LINEAR; + texUnit->GenQ._ModeBit = TEXGEN_EYE_LINEAR; /* Yes, these plane coefficients are correct! */ - ASSIGN_4V( texUnit->ObjectPlaneS, 1.0, 0.0, 0.0, 0.0 ); - ASSIGN_4V( texUnit->ObjectPlaneT, 0.0, 1.0, 0.0, 0.0 ); - ASSIGN_4V( texUnit->ObjectPlaneR, 0.0, 0.0, 0.0, 0.0 ); - ASSIGN_4V( texUnit->ObjectPlaneQ, 0.0, 0.0, 0.0, 0.0 ); - ASSIGN_4V( texUnit->EyePlaneS, 1.0, 0.0, 0.0, 0.0 ); - ASSIGN_4V( texUnit->EyePlaneT, 0.0, 1.0, 0.0, 0.0 ); - ASSIGN_4V( texUnit->EyePlaneR, 0.0, 0.0, 0.0, 0.0 ); - ASSIGN_4V( texUnit->EyePlaneQ, 0.0, 0.0, 0.0, 0.0 ); + ASSIGN_4V( texUnit->GenS.ObjectPlane, 1.0, 0.0, 0.0, 0.0 ); + ASSIGN_4V( texUnit->GenT.ObjectPlane, 0.0, 1.0, 0.0, 0.0 ); + ASSIGN_4V( texUnit->GenR.ObjectPlane, 0.0, 0.0, 0.0, 0.0 ); + ASSIGN_4V( texUnit->GenQ.ObjectPlane, 0.0, 0.0, 0.0, 0.0 ); + ASSIGN_4V( texUnit->GenS.EyePlane, 1.0, 0.0, 0.0, 0.0 ); + ASSIGN_4V( texUnit->GenT.EyePlane, 0.0, 1.0, 0.0, 0.0 ); + ASSIGN_4V( texUnit->GenR.EyePlane, 0.0, 0.0, 0.0, 0.0 ); + ASSIGN_4V( texUnit->GenQ.EyePlane, 0.0, 0.0, 0.0, 0.0 ); /* initialize current texture object ptrs to the shared default objects */ _mesa_reference_texobj(&texUnit->Current1D, ctx->Shared->Default1D); diff --git a/src/mesa/shader/prog_statevars.c b/src/mesa/shader/prog_statevars.c index e1db30b78f4..1f7d87ccc94 100644 --- a/src/mesa/shader/prog_statevars.c +++ b/src/mesa/shader/prog_statevars.c @@ -206,28 +206,28 @@ _mesa_fetch_state(GLcontext *ctx, const gl_state_index state[], /* state[2] is the texgen attribute */ switch (state[2]) { case STATE_TEXGEN_EYE_S: - COPY_4V(value, ctx->Texture.Unit[unit].EyePlaneS); + COPY_4V(value, ctx->Texture.Unit[unit].GenS.EyePlane); return; case STATE_TEXGEN_EYE_T: - COPY_4V(value, ctx->Texture.Unit[unit].EyePlaneT); + COPY_4V(value, ctx->Texture.Unit[unit].GenT.EyePlane); return; case STATE_TEXGEN_EYE_R: - COPY_4V(value, ctx->Texture.Unit[unit].EyePlaneR); + COPY_4V(value, ctx->Texture.Unit[unit].GenR.EyePlane); return; case STATE_TEXGEN_EYE_Q: - COPY_4V(value, ctx->Texture.Unit[unit].EyePlaneQ); + COPY_4V(value, ctx->Texture.Unit[unit].GenQ.EyePlane); return; case STATE_TEXGEN_OBJECT_S: - COPY_4V(value, ctx->Texture.Unit[unit].ObjectPlaneS); + COPY_4V(value, ctx->Texture.Unit[unit].GenS.ObjectPlane); return; case STATE_TEXGEN_OBJECT_T: - COPY_4V(value, ctx->Texture.Unit[unit].ObjectPlaneT); + COPY_4V(value, ctx->Texture.Unit[unit].GenT.ObjectPlane); return; case STATE_TEXGEN_OBJECT_R: - COPY_4V(value, ctx->Texture.Unit[unit].ObjectPlaneR); + COPY_4V(value, ctx->Texture.Unit[unit].GenR.ObjectPlane); return; case STATE_TEXGEN_OBJECT_Q: - COPY_4V(value, ctx->Texture.Unit[unit].ObjectPlaneQ); + COPY_4V(value, ctx->Texture.Unit[unit].GenQ.ObjectPlane); return; default: _mesa_problem(ctx, "Invalid texgen state in fetch_state"); diff --git a/src/mesa/tnl/t_rasterpos.c b/src/mesa/tnl/t_rasterpos.c index 14d79eab541..04fb1d8f8c2 100644 --- a/src/mesa/tnl/t_rasterpos.c +++ b/src/mesa/tnl/t_rasterpos.c @@ -301,12 +301,12 @@ compute_texgen(GLcontext *ctx, const GLfloat vObj[4], const GLfloat vEye[4], mInv = 0.0F; if (texUnit->TexGenEnabled & S_BIT) { - switch (texUnit->GenModeS) { + switch (texUnit->GenS.Mode) { case GL_OBJECT_LINEAR: - texcoord[0] = DOT4(vObj, texUnit->ObjectPlaneS); + texcoord[0] = DOT4(vObj, texUnit->GenS.ObjectPlane); break; case GL_EYE_LINEAR: - texcoord[0] = DOT4(vEye, texUnit->EyePlaneS); + texcoord[0] = DOT4(vEye, texUnit->GenS.EyePlane); break; case GL_SPHERE_MAP: texcoord[0] = rx * mInv + 0.5F; @@ -324,12 +324,12 @@ compute_texgen(GLcontext *ctx, const GLfloat vObj[4], const GLfloat vEye[4], } if (texUnit->TexGenEnabled & T_BIT) { - switch (texUnit->GenModeT) { + switch (texUnit->GenT.Mode) { case GL_OBJECT_LINEAR: - texcoord[1] = DOT4(vObj, texUnit->ObjectPlaneT); + texcoord[1] = DOT4(vObj, texUnit->GenT.ObjectPlane); break; case GL_EYE_LINEAR: - texcoord[1] = DOT4(vEye, texUnit->EyePlaneT); + texcoord[1] = DOT4(vEye, texUnit->GenT.EyePlane); break; case GL_SPHERE_MAP: texcoord[1] = ry * mInv + 0.5F; @@ -347,12 +347,12 @@ compute_texgen(GLcontext *ctx, const GLfloat vObj[4], const GLfloat vEye[4], } if (texUnit->TexGenEnabled & R_BIT) { - switch (texUnit->GenModeR) { + switch (texUnit->GenR.Mode) { case GL_OBJECT_LINEAR: - texcoord[2] = DOT4(vObj, texUnit->ObjectPlaneR); + texcoord[2] = DOT4(vObj, texUnit->GenR.ObjectPlane); break; case GL_EYE_LINEAR: - texcoord[2] = DOT4(vEye, texUnit->EyePlaneR); + texcoord[2] = DOT4(vEye, texUnit->GenR.EyePlane); break; case GL_REFLECTION_MAP: texcoord[2] = rz; @@ -367,12 +367,12 @@ compute_texgen(GLcontext *ctx, const GLfloat vObj[4], const GLfloat vEye[4], } if (texUnit->TexGenEnabled & Q_BIT) { - switch (texUnit->GenModeQ) { + switch (texUnit->GenQ.Mode) { case GL_OBJECT_LINEAR: - texcoord[3] = DOT4(vObj, texUnit->ObjectPlaneQ); + texcoord[3] = DOT4(vObj, texUnit->GenQ.ObjectPlane); break; case GL_EYE_LINEAR: - texcoord[3] = DOT4(vEye, texUnit->EyePlaneQ); + texcoord[3] = DOT4(vEye, texUnit->GenQ.EyePlane); break; default: _mesa_problem(ctx, "Bad Q texgen in compute_texgen()"); diff --git a/src/mesa/tnl/t_vb_texgen.c b/src/mesa/tnl/t_vb_texgen.c index 14d3876e547..7c1819b223c 100644 --- a/src/mesa/tnl/t_vb_texgen.c +++ b/src/mesa/tnl/t_vb_texgen.c @@ -367,16 +367,16 @@ static void texgen( GLcontext *ctx, if (texUnit->TexGenEnabled & S_BIT) { GLuint i; - switch (texUnit->GenModeS) { + switch (texUnit->GenS.Mode) { case GL_OBJECT_LINEAR: _mesa_dotprod_tab[obj->size]( (GLfloat *)out->data, sizeof(out->data[0]), obj, - texUnit->ObjectPlaneS ); + texUnit->GenS.ObjectPlane ); break; case GL_EYE_LINEAR: _mesa_dotprod_tab[eye->size]( (GLfloat *)out->data, sizeof(out->data[0]), eye, - texUnit->EyePlaneS ); + texUnit->GenS.EyePlane ); break; case GL_SPHERE_MAP: for (i = 0; i < count; i++) @@ -400,16 +400,16 @@ static void texgen( GLcontext *ctx, if (texUnit->TexGenEnabled & T_BIT) { GLuint i; - switch (texUnit->GenModeT) { + switch (texUnit->GenT.Mode) { case GL_OBJECT_LINEAR: _mesa_dotprod_tab[obj->size]( &(out->data[0][1]), sizeof(out->data[0]), obj, - texUnit->ObjectPlaneT ); + texUnit->GenT.ObjectPlane ); break; case GL_EYE_LINEAR: _mesa_dotprod_tab[eye->size]( &(out->data[0][1]), sizeof(out->data[0]), eye, - texUnit->EyePlaneT ); + texUnit->GenT.EyePlane ); break; case GL_SPHERE_MAP: for (i = 0; i < count; i++) @@ -433,16 +433,16 @@ static void texgen( GLcontext *ctx, if (texUnit->TexGenEnabled & R_BIT) { GLuint i; - switch (texUnit->GenModeR) { + switch (texUnit->GenR.Mode) { case GL_OBJECT_LINEAR: _mesa_dotprod_tab[obj->size]( &(out->data[0][2]), sizeof(out->data[0]), obj, - texUnit->ObjectPlaneR ); + texUnit->GenR.ObjectPlane ); break; case GL_EYE_LINEAR: _mesa_dotprod_tab[eye->size]( &(out->data[0][2]), sizeof(out->data[0]), eye, - texUnit->EyePlaneR ); + texUnit->GenR.EyePlane ); break; case GL_REFLECTION_MAP_NV: for (i=0;iTexGenEnabled & Q_BIT) { - switch (texUnit->GenModeQ) { + switch (texUnit->GenQ.Mode) { case GL_OBJECT_LINEAR: _mesa_dotprod_tab[obj->size]( &(out->data[0][3]), sizeof(out->data[0]), obj, - texUnit->ObjectPlaneQ ); + texUnit->GenQ.ObjectPlane ); break; case GL_EYE_LINEAR: _mesa_dotprod_tab[eye->size]( &(out->data[0][3]), sizeof(out->data[0]), eye, - texUnit->EyePlaneQ ); + texUnit->GenQ.EyePlane ); break; default: _mesa_problem(ctx, "Bad Q texgen");