X-Git-Url: https://git.libre-soc.org/?a=blobdiff_plain;f=src%2Fmesa%2Fmain%2Ftexenv.c;h=5d0dc6cc4e9690a579690c5fc23a417d5e72178d;hb=8a4114b9294c8e8f5bb977be47cc7764c9cdf490;hp=b9efe8683bbcd5c4eb836586c4f1deb4afa40c7b;hpb=dd404bc94f78a1766527becee03f8ef6ae3a799b;p=mesa.git diff --git a/src/mesa/main/texenv.c b/src/mesa/main/texenv.c index b9efe8683bb..5d0dc6cc4e9 100644 --- a/src/mesa/main/texenv.c +++ b/src/mesa/main/texenv.c @@ -1,6 +1,5 @@ /* * Mesa 3-D graphics library - * Version: 7.5 * * Copyright (C) 1999-2008 Brian Paul All Rights Reserved. * Copyright (C) 2009 VMware, Inc. All Rights Reserved. @@ -18,9 +17,10 @@ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR + * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, + * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR + * OTHER DEALINGS IN THE SOFTWARE. */ /** @@ -42,13 +42,13 @@ #define TE_ERROR(errCode, msg, value) \ - _mesa_error(ctx, errCode, msg, _mesa_lookup_enum_by_nr(value)); + _mesa_error(ctx, errCode, msg, _mesa_enum_to_string(value)); /** Set texture env mode */ static void set_env_mode(struct gl_context *ctx, - struct gl_texture_unit *texUnit, + struct gl_fixedfunc_texture_unit *texUnit, GLenum mode) { GLboolean legal; @@ -77,7 +77,7 @@ set_env_mode(struct gl_context *ctx, } if (legal) { - FLUSH_VERTICES(ctx, _NEW_TEXTURE); + FLUSH_VERTICES(ctx, _NEW_TEXTURE_STATE); texUnit->EnvMode = mode; } else { @@ -88,12 +88,12 @@ set_env_mode(struct gl_context *ctx, static void set_env_color(struct gl_context *ctx, - struct gl_texture_unit *texUnit, + struct gl_fixedfunc_texture_unit *texUnit, const GLfloat *color) { if (TEST_EQ_4V(color, texUnit->EnvColorUnclamped)) return; - FLUSH_VERTICES(ctx, _NEW_TEXTURE); + FLUSH_VERTICES(ctx, _NEW_TEXTURE_STATE); COPY_4FV(texUnit->EnvColorUnclamped, color); texUnit->EnvColor[0] = CLAMP(color[0], 0.0F, 1.0F); texUnit->EnvColor[1] = CLAMP(color[1], 0.0F, 1.0F); @@ -103,9 +103,9 @@ set_env_color(struct gl_context *ctx, /** Set an RGB or A combiner mode/function */ -static void +static bool set_combiner_mode(struct gl_context *ctx, - struct gl_texture_unit *texUnit, + struct gl_fixedfunc_texture_unit *texUnit, GLenum pname, GLenum mode) { GLboolean legal; @@ -138,45 +138,43 @@ set_combiner_mode(struct gl_context *ctx, legal = (ctx->API == API_OPENGL_COMPAT && ctx->Extensions.ATI_texture_env_combine3); break; - case GL_BUMP_ENVMAP_ATI: - legal = (ctx->API == API_OPENGL_COMPAT && - ctx->Extensions.ATI_envmap_bumpmap && - pname == GL_COMBINE_RGB); - break; default: legal = GL_FALSE; } if (!legal) { TE_ERROR(GL_INVALID_ENUM, "glTexEnv(param=%s)", mode); - return; + return false; } switch (pname) { case GL_COMBINE_RGB: if (texUnit->Combine.ModeRGB == mode) - return; - FLUSH_VERTICES(ctx, _NEW_TEXTURE); + return true; + FLUSH_VERTICES(ctx, _NEW_TEXTURE_STATE); texUnit->Combine.ModeRGB = mode; break; case GL_COMBINE_ALPHA: if (texUnit->Combine.ModeA == mode) - return; - FLUSH_VERTICES(ctx, _NEW_TEXTURE); + return true; + FLUSH_VERTICES(ctx, _NEW_TEXTURE_STATE); texUnit->Combine.ModeA = mode; break; default: TE_ERROR(GL_INVALID_ENUM, "glTexEnv(pname=%s)", pname); + return false; } + + return true; } /** Set an RGB or A combiner source term */ -static void +static bool set_combiner_source(struct gl_context *ctx, - struct gl_texture_unit *texUnit, + struct gl_fixedfunc_texture_unit *texUnit, GLenum pname, GLenum param) { GLuint term; @@ -204,13 +202,13 @@ set_combiner_source(struct gl_context *ctx, break; default: TE_ERROR(GL_INVALID_ENUM, "glTexEnv(pname=%s)", pname); - return; + return false; } if ((term == 3) && (ctx->API != API_OPENGL_COMPAT || !ctx->Extensions.NV_texture_env_combine4)) { TE_ERROR(GL_INVALID_ENUM, "glTexEnv(pname=%s)", pname); - return; + return false; } assert(term < MAX_COMBINER_TERMS); @@ -251,22 +249,24 @@ set_combiner_source(struct gl_context *ctx, if (!legal) { TE_ERROR(GL_INVALID_ENUM, "glTexEnv(param=%s)", param); - return; + return false; } - FLUSH_VERTICES(ctx, _NEW_TEXTURE); + FLUSH_VERTICES(ctx, _NEW_TEXTURE_STATE); if (alpha) texUnit->Combine.SourceA[term] = param; else texUnit->Combine.SourceRGB[term] = param; + + return true; } /** Set an RGB or A combiner operand term */ -static void +static bool set_combiner_operand(struct gl_context *ctx, - struct gl_texture_unit *texUnit, + struct gl_fixedfunc_texture_unit *texUnit, GLenum pname, GLenum param) { GLuint term; @@ -291,13 +291,13 @@ set_combiner_operand(struct gl_context *ctx, break; default: TE_ERROR(GL_INVALID_ENUM, "glTexEnv(pname=%s)", pname); - return; + return false; } if ((term == 3) && (ctx->API != API_OPENGL_COMPAT || !ctx->Extensions.NV_texture_env_combine4)) { TE_ERROR(GL_INVALID_ENUM, "glTexEnv(pname=%s)", pname); - return; + return false; } assert(term < MAX_COMBINER_TERMS); @@ -333,21 +333,23 @@ set_combiner_operand(struct gl_context *ctx, if (!legal) { TE_ERROR(GL_INVALID_ENUM, "glTexEnv(param=%s)", param); - return; + return false; } - FLUSH_VERTICES(ctx, _NEW_TEXTURE); + FLUSH_VERTICES(ctx, _NEW_TEXTURE_STATE); if (alpha) texUnit->Combine.OperandA[term] = param; else texUnit->Combine.OperandRGB[term] = param; + + return true; } -static void +static bool set_combiner_scale(struct gl_context *ctx, - struct gl_texture_unit *texUnit, + struct gl_fixedfunc_texture_unit *texUnit, GLenum pname, GLfloat scale) { GLuint shift; @@ -364,47 +366,58 @@ set_combiner_scale(struct gl_context *ctx, else { _mesa_error( ctx, GL_INVALID_VALUE, "glTexEnv(GL_RGB_SCALE not 1, 2 or 4)" ); - return; + return false; } switch (pname) { case GL_RGB_SCALE: if (texUnit->Combine.ScaleShiftRGB == shift) - return; - FLUSH_VERTICES(ctx, _NEW_TEXTURE); + return true; + FLUSH_VERTICES(ctx, _NEW_TEXTURE_STATE); texUnit->Combine.ScaleShiftRGB = shift; break; case GL_ALPHA_SCALE: if (texUnit->Combine.ScaleShiftA == shift) - return; - FLUSH_VERTICES(ctx, _NEW_TEXTURE); + return true; + FLUSH_VERTICES(ctx, _NEW_TEXTURE_STATE); texUnit->Combine.ScaleShiftA = shift; break; default: TE_ERROR(GL_INVALID_ENUM, "glTexEnv(pname=%s)", pname); + return false; } -} + return true; +} -void GLAPIENTRY -_mesa_TexEnvfv( GLenum target, GLenum pname, const GLfloat *param ) +static void +_mesa_texenvfv_indexed( struct gl_context* ctx, GLuint texunit, GLenum target, + GLenum pname, const GLfloat *param ) { const GLint iparam0 = (GLint) param[0]; - struct gl_texture_unit *texUnit; GLuint maxUnit; - GET_CURRENT_CONTEXT(ctx); maxUnit = (target == GL_POINT_SPRITE_NV && pname == GL_COORD_REPLACE_NV) ? ctx->Const.MaxTextureCoordUnits : ctx->Const.MaxCombinedTextureImageUnits; - if (ctx->Texture.CurrentUnit >= maxUnit) { - _mesa_error(ctx, GL_INVALID_OPERATION, "glTexEnvfv(current unit)"); + if (texunit >= maxUnit) { + _mesa_error(ctx, GL_INVALID_OPERATION, "glTexEnvfv(texunit=%d)", texunit); return; } - texUnit = _mesa_get_current_tex_unit(ctx); - if (target == GL_TEXTURE_ENV) { + struct gl_fixedfunc_texture_unit *texUnit = + _mesa_get_fixedfunc_tex_unit(ctx, texunit); + + /* The GL spec says that we should report an error if the unit is greater + * than GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS, but in practice, only + * fixed-function units are usable. This is probably a spec bug. + * Ignore glTexEnv(GL_TEXTURE_ENV) calls for non-fixed-func units, + * because we don't want to process calls that have no effect. + */ + if (!texUnit) + return; + switch (pname) { case GL_TEXTURE_ENV_MODE: set_env_mode(ctx, texUnit, (GLenum) iparam0); @@ -414,7 +427,8 @@ _mesa_TexEnvfv( GLenum target, GLenum pname, const GLfloat *param ) break; case GL_COMBINE_RGB: case GL_COMBINE_ALPHA: - set_combiner_mode(ctx, texUnit, pname, (GLenum) iparam0); + if (!set_combiner_mode(ctx, texUnit, pname, (GLenum) iparam0)) + return; break; case GL_SOURCE0_RGB: case GL_SOURCE1_RGB: @@ -424,7 +438,8 @@ _mesa_TexEnvfv( GLenum target, GLenum pname, const GLfloat *param ) case GL_SOURCE1_ALPHA: case GL_SOURCE2_ALPHA: case GL_SOURCE3_ALPHA_NV: - set_combiner_source(ctx, texUnit, pname, (GLenum) iparam0); + if (!set_combiner_source(ctx, texUnit, pname, (GLenum) iparam0)) + return; break; case GL_OPERAND0_RGB: case GL_OPERAND1_RGB: @@ -434,31 +449,13 @@ _mesa_TexEnvfv( GLenum target, GLenum pname, const GLfloat *param ) case GL_OPERAND1_ALPHA: case GL_OPERAND2_ALPHA: case GL_OPERAND3_ALPHA_NV: - set_combiner_operand(ctx, texUnit, pname, (GLenum) iparam0); + if (!set_combiner_operand(ctx, texUnit, pname, (GLenum) iparam0)) + return; break; case GL_RGB_SCALE: case GL_ALPHA_SCALE: - set_combiner_scale(ctx, texUnit, pname, param[0]); - break; - case GL_BUMP_TARGET_ATI: - if (ctx->API != API_OPENGL_COMPAT || !ctx->Extensions.ATI_envmap_bumpmap) { - _mesa_error( ctx, GL_INVALID_ENUM, "glTexEnv(pname=0x%x)", pname ); - return; - } - if ((iparam0 < GL_TEXTURE0) || - (iparam0 > GL_TEXTURE31)) { - /* spec doesn't say this but it seems logical */ - _mesa_error( ctx, GL_INVALID_ENUM, "glTexEnv(param=0x%x)", iparam0); - return; - } - if (!((1 << (iparam0 - GL_TEXTURE0)) & ctx->Const.SupportedBumpUnits)) { - _mesa_error( ctx, GL_INVALID_VALUE, "glTexEnv(param=0x%x)", iparam0); - return; - } - else { - FLUSH_VERTICES(ctx, _NEW_TEXTURE); - texUnit->BumpTarget = iparam0; - } + if (!set_combiner_scale(ctx, texUnit, pname, param[0])) + return; break; default: _mesa_error( ctx, GL_INVALID_ENUM, "glTexEnv(pname)" ); @@ -466,10 +463,13 @@ _mesa_TexEnvfv( GLenum target, GLenum pname, const GLfloat *param ) } } else if (target == GL_TEXTURE_FILTER_CONTROL_EXT) { + struct gl_texture_unit *texUnit = + _mesa_get_tex_unit(ctx, texunit); + if (pname == GL_TEXTURE_LOD_BIAS_EXT) { if (texUnit->LodBias == param[0]) return; - FLUSH_VERTICES(ctx, _NEW_TEXTURE); + FLUSH_VERTICES(ctx, _NEW_TEXTURE_OBJECT); texUnit->LodBias = param[0]; } else { @@ -485,17 +485,20 @@ _mesa_TexEnvfv( GLenum target, GLenum pname, const GLfloat *param ) return; } if (pname == GL_COORD_REPLACE_NV) { - if (iparam0 == GL_TRUE || iparam0 == GL_FALSE) { - /* It's kind of weird to set point state via glTexEnv, - * but that's what the spec calls for. - */ - const GLboolean state = (GLboolean) iparam0; - if (ctx->Point.CoordReplace[ctx->Texture.CurrentUnit] == state) + /* It's kind of weird to set point state via glTexEnv, + * but that's what the spec calls for. + */ + if (iparam0 == GL_TRUE) { + if (ctx->Point.CoordReplace & (1u << texunit)) return; FLUSH_VERTICES(ctx, _NEW_POINT); - ctx->Point.CoordReplace[ctx->Texture.CurrentUnit] = state; - } - else { + ctx->Point.CoordReplace |= (1u << texunit); + } else if (iparam0 == GL_FALSE) { + if (~(ctx->Point.CoordReplace) & (1u << texunit)) + return; + FLUSH_VERTICES(ctx, _NEW_POINT); + ctx->Point.CoordReplace &= ~(1u << texunit); + } else { _mesa_error( ctx, GL_INVALID_VALUE, "glTexEnv(param=0x%x)", iparam0); return; } @@ -507,24 +510,32 @@ _mesa_TexEnvfv( GLenum target, GLenum pname, const GLfloat *param ) } else { _mesa_error(ctx, GL_INVALID_ENUM, "glTexEnv(target=%s)", - _mesa_lookup_enum_by_nr(target)); + _mesa_enum_to_string(target)); return; } if (MESA_VERBOSE&(VERBOSE_API|VERBOSE_TEXTURE)) _mesa_debug(ctx, "glTexEnv %s %s %.1f(%s) ...\n", - _mesa_lookup_enum_by_nr(target), - _mesa_lookup_enum_by_nr(pname), + _mesa_enum_to_string(target), + _mesa_enum_to_string(pname), *param, - _mesa_lookup_enum_by_nr((GLenum) iparam0)); + _mesa_enum_to_string((GLenum) iparam0)); /* Tell device driver about the new texture environment */ if (ctx->Driver.TexEnv) { - (*ctx->Driver.TexEnv)( ctx, target, pname, param ); + ctx->Driver.TexEnv(ctx, target, pname, param); } } +void GLAPIENTRY +_mesa_TexEnvfv( GLenum target, GLenum pname, const GLfloat *param ) +{ + GET_CURRENT_CONTEXT(ctx); + _mesa_texenvfv_indexed(ctx, ctx->Texture.CurrentUnit, target, pname, param); +} + + void GLAPIENTRY _mesa_TexEnvf( GLenum target, GLenum pname, GLfloat param ) { @@ -535,7 +546,6 @@ _mesa_TexEnvf( GLenum target, GLenum pname, GLfloat param ) } - void GLAPIENTRY _mesa_TexEnvi( GLenum target, GLenum pname, GLint param ) { @@ -564,13 +574,67 @@ _mesa_TexEnviv( GLenum target, GLenum pname, const GLint *param ) } +void GLAPIENTRY +_mesa_MultiTexEnvfEXT( GLenum texunit, GLenum target, + GLenum pname, GLfloat param ) +{ + GET_CURRENT_CONTEXT(ctx); + GLfloat p[4]; + p[0] = param; + p[1] = p[2] = p[3] = 0.0; + _mesa_texenvfv_indexed(ctx, texunit - GL_TEXTURE0, target, pname, p); +} + +void GLAPIENTRY +_mesa_MultiTexEnvfvEXT( GLenum texunit, GLenum target, + GLenum pname, const GLfloat *param ) +{ + GET_CURRENT_CONTEXT(ctx); + _mesa_texenvfv_indexed(ctx, texunit - GL_TEXTURE0, target, pname, param); +} + + +void GLAPIENTRY +_mesa_MultiTexEnviEXT( GLenum texunit, GLenum target, + GLenum pname, GLint param ) +{ + GET_CURRENT_CONTEXT(ctx); + GLfloat p[4]; + p[0] = (GLfloat) param; + p[1] = p[2] = p[3] = 0.0; + _mesa_texenvfv_indexed( ctx, texunit - GL_TEXTURE0, target, pname, p ); +} + + +void GLAPIENTRY +_mesa_MultiTexEnvivEXT( GLenum texunit, GLenum target, + GLenum pname, const GLint *param ) +{ + GET_CURRENT_CONTEXT(ctx); + GLfloat p[4]; + if (pname == GL_TEXTURE_ENV_COLOR) { + p[0] = INT_TO_FLOAT( param[0] ); + p[1] = INT_TO_FLOAT( param[1] ); + p[2] = INT_TO_FLOAT( param[2] ); + p[3] = INT_TO_FLOAT( param[3] ); + } + else { + p[0] = (GLfloat) param[0]; + p[1] = p[2] = p[3] = 0; /* init to zero, just to be safe */ + } + _mesa_texenvfv_indexed( ctx, texunit - GL_TEXTURE0, target, pname, p ); +} + + + /** * Helper for glGetTexEnvi/f() * \return value of queried pname or -1 if error. */ static GLint -get_texenvi(struct gl_context *ctx, const struct gl_texture_unit *texUnit, +get_texenvi(struct gl_context *ctx, + const struct gl_fixedfunc_texture_unit *texUnit, GLenum pname) { switch (pname) { @@ -641,16 +705,6 @@ get_texenvi(struct gl_context *ctx, const struct gl_texture_unit *texUnit, return 1 << texUnit->Combine.ScaleShiftRGB; case GL_ALPHA_SCALE: return 1 << texUnit->Combine.ScaleShiftA; - case GL_BUMP_TARGET_ATI: - /* spec doesn't say so, but I think this should be queryable */ - if (ctx->API == API_OPENGL_COMPAT && ctx->Extensions.ATI_envmap_bumpmap) { - return texUnit->BumpTarget; - } - else { - _mesa_error(ctx, GL_INVALID_ENUM, "glGetTexEnvfv(pname)"); - } - break; - default: _mesa_error(ctx, GL_INVALID_ENUM, "glGetTexEnvfv(pname)"); break; @@ -660,28 +714,36 @@ get_texenvi(struct gl_context *ctx, const struct gl_texture_unit *texUnit, } - -void GLAPIENTRY -_mesa_GetTexEnvfv( GLenum target, GLenum pname, GLfloat *params ) +static void +_mesa_gettexenvfv_indexed( GLuint texunit, GLenum target, GLenum pname, GLfloat *params ) { GLuint maxUnit; - const struct gl_texture_unit *texUnit; GET_CURRENT_CONTEXT(ctx); maxUnit = (target == GL_POINT_SPRITE_NV && pname == GL_COORD_REPLACE_NV) ? ctx->Const.MaxTextureCoordUnits : ctx->Const.MaxCombinedTextureImageUnits; - if (ctx->Texture.CurrentUnit >= maxUnit) { - _mesa_error(ctx, GL_INVALID_OPERATION, "glGetTexEnvfv(current unit)"); + if (texunit >= maxUnit) { + _mesa_error(ctx, GL_INVALID_OPERATION, "glGetTexEnvfv(texunit=%d)", texunit); return; } - texUnit = _mesa_get_current_tex_unit(ctx); - if (target == GL_TEXTURE_ENV) { + struct gl_fixedfunc_texture_unit *texUnit = + _mesa_get_fixedfunc_tex_unit(ctx, texunit); + + /* The GL spec says that we should report an error if the unit is greater + * than GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS, but in practice, only + * fixed-function units are usable. This is probably a spec bug. + * Ignore calls for non-fixed-func units, because we don't process + * glTexEnv for them either. + */ + if (!texUnit) + return; + if (pname == GL_TEXTURE_ENV_COLOR) { if(ctx->NewState & (_NEW_BUFFERS | _NEW_FRAG_CLAMP)) _mesa_update_state(ctx); - if (_mesa_get_clamp_fragment_color(ctx)) + if (_mesa_get_clamp_fragment_color(ctx, ctx->DrawBuffer)) COPY_4FV( params, texUnit->EnvColor ); else COPY_4FV( params, texUnit->EnvColorUnclamped ); @@ -694,6 +756,8 @@ _mesa_GetTexEnvfv( GLenum target, GLenum pname, GLfloat *params ) } } else if (target == GL_TEXTURE_FILTER_CONTROL_EXT) { + const struct gl_texture_unit *texUnit = _mesa_get_tex_unit(ctx, texunit); + if (pname == GL_TEXTURE_LOD_BIAS_EXT) { *params = texUnit->LodBias; } @@ -710,7 +774,10 @@ _mesa_GetTexEnvfv( GLenum target, GLenum pname, GLfloat *params ) return; } if (pname == GL_COORD_REPLACE_NV) { - *params = (GLfloat) ctx->Point.CoordReplace[ctx->Texture.CurrentUnit]; + if (ctx->Point.CoordReplace & (1u << texunit)) + *params = 1.0f; + else + *params = 0.0f; } else { _mesa_error( ctx, GL_INVALID_ENUM, "glGetTexEnvfv(pname)" ); @@ -724,23 +791,34 @@ _mesa_GetTexEnvfv( GLenum target, GLenum pname, GLfloat *params ) } -void GLAPIENTRY -_mesa_GetTexEnviv( GLenum target, GLenum pname, GLint *params ) +static void +_mesa_gettexenviv_indexed( GLuint texunit, GLenum target, + GLenum pname, GLint *params ) { GLuint maxUnit; - const struct gl_texture_unit *texUnit; GET_CURRENT_CONTEXT(ctx); maxUnit = (target == GL_POINT_SPRITE_NV && pname == GL_COORD_REPLACE_NV) ? ctx->Const.MaxTextureCoordUnits : ctx->Const.MaxCombinedTextureImageUnits; - if (ctx->Texture.CurrentUnit >= maxUnit) { - _mesa_error(ctx, GL_INVALID_OPERATION, "glGetTexEnviv(current unit)"); + if (texunit >= maxUnit) { + _mesa_error(ctx, GL_INVALID_OPERATION, "glGetTexEnviv(texunit=%d)", + texunit); return; } - texUnit = _mesa_get_current_tex_unit(ctx); - if (target == GL_TEXTURE_ENV) { + struct gl_fixedfunc_texture_unit *texUnit = + _mesa_get_fixedfunc_tex_unit(ctx, texunit); + + /* The GL spec says that we should report an error if the unit is greater + * than GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS, but in practice, only + * fixed-function units are usable. This is probably a spec bug. + * Ignore calls for non-fixed-func units, because we don't process + * glTexEnv for them either. + */ + if (!texUnit) + return; + if (pname == GL_TEXTURE_ENV_COLOR) { params[0] = FLOAT_TO_INT( texUnit->EnvColor[0] ); params[1] = FLOAT_TO_INT( texUnit->EnvColor[1] ); @@ -755,6 +833,8 @@ _mesa_GetTexEnviv( GLenum target, GLenum pname, GLint *params ) } } else if (target == GL_TEXTURE_FILTER_CONTROL_EXT) { + const struct gl_texture_unit *texUnit = _mesa_get_tex_unit(ctx, texunit); + if (pname == GL_TEXTURE_LOD_BIAS_EXT) { *params = (GLint) texUnit->LodBias; } @@ -771,7 +851,10 @@ _mesa_GetTexEnviv( GLenum target, GLenum pname, GLint *params ) return; } if (pname == GL_COORD_REPLACE_NV) { - *params = (GLint) ctx->Point.CoordReplace[ctx->Texture.CurrentUnit]; + if (ctx->Point.CoordReplace & (1u << texunit)) + *params = GL_TRUE; + else + *params = GL_FALSE; } else { _mesa_error( ctx, GL_INVALID_ENUM, "glGetTexEnviv(pname)" ); @@ -785,165 +868,33 @@ _mesa_GetTexEnviv( GLenum target, GLenum pname, GLint *params ) } -/** - * Why does ATI_envmap_bumpmap require new entrypoints? Should just - * reuse TexEnv ones... - */ void GLAPIENTRY -_mesa_TexBumpParameterivATI( GLenum pname, const GLint *param ) +_mesa_GetTexEnvfv( GLenum target, GLenum pname, GLfloat *params ) { - GLfloat p[4]; GET_CURRENT_CONTEXT(ctx); - - if (!ctx->Extensions.ATI_envmap_bumpmap) { - /* This isn't an "official" error case, but let's tell the user - * that something's wrong. - */ - _mesa_error(ctx, GL_INVALID_OPERATION, "glTexBumpParameterivATI"); - return; - } - - if (pname == GL_BUMP_ROT_MATRIX_ATI) { - /* hope that conversion is correct here */ - p[0] = INT_TO_FLOAT( param[0] ); - p[1] = INT_TO_FLOAT( param[1] ); - p[2] = INT_TO_FLOAT( param[2] ); - p[3] = INT_TO_FLOAT( param[3] ); - } - else { - p[0] = (GLfloat) param[0]; - p[1] = p[2] = p[3] = 0.0F; /* init to zero, just to be safe */ - } - _mesa_TexBumpParameterfvATI( pname, p ); + _mesa_gettexenvfv_indexed(ctx->Texture.CurrentUnit, target, pname, params); } void GLAPIENTRY -_mesa_TexBumpParameterfvATI( GLenum pname, const GLfloat *param ) +_mesa_GetMultiTexEnvfvEXT( GLenum texunit, GLenum target, + GLenum pname, GLfloat *params ) { - struct gl_texture_unit *texUnit; - GET_CURRENT_CONTEXT(ctx); - - if (!ctx->Extensions.ATI_envmap_bumpmap) { - _mesa_error(ctx, GL_INVALID_OPERATION, "glTexBumpParameterfvATI"); - return; - } - - texUnit = _mesa_get_current_tex_unit(ctx); - - if (pname == GL_BUMP_ROT_MATRIX_ATI) { - if (TEST_EQ_4V(param, texUnit->RotMatrix)) - return; - FLUSH_VERTICES(ctx, _NEW_TEXTURE); - COPY_4FV(texUnit->RotMatrix, param); - } - else { - _mesa_error( ctx, GL_INVALID_ENUM, "glTexBumpParameter(pname)" ); - return; - } - /* Drivers might want to know about this, instead of dedicated function - just shove it into TexEnv where it really belongs anyway */ - if (ctx->Driver.TexEnv) { - (*ctx->Driver.TexEnv)( ctx, 0, pname, param ); - } + _mesa_gettexenvfv_indexed(texunit - GL_TEXTURE0, target, pname, params); } void GLAPIENTRY -_mesa_GetTexBumpParameterivATI( GLenum pname, GLint *param ) +_mesa_GetTexEnviv( GLenum target, GLenum pname, GLint *params ) { - const struct gl_texture_unit *texUnit; - GLuint i; GET_CURRENT_CONTEXT(ctx); - - if (!ctx->Extensions.ATI_envmap_bumpmap) { - _mesa_error(ctx, GL_INVALID_OPERATION, "glGetTexBumpParameterivATI"); - return; - } - - texUnit = _mesa_get_current_tex_unit(ctx); - - if (pname == GL_BUMP_ROT_MATRIX_SIZE_ATI) { - /* spec leaves open to support larger matrices. - Don't think anyone would ever want to use it - (and apps almost certainly would not understand it and - thus fail to submit matrices correctly) so hardcode this. */ - *param = 4; - } - else if (pname == GL_BUMP_ROT_MATRIX_ATI) { - /* hope that conversion is correct here */ - param[0] = FLOAT_TO_INT(texUnit->RotMatrix[0]); - param[1] = FLOAT_TO_INT(texUnit->RotMatrix[1]); - param[2] = FLOAT_TO_INT(texUnit->RotMatrix[2]); - param[3] = FLOAT_TO_INT(texUnit->RotMatrix[3]); - } - else if (pname == GL_BUMP_NUM_TEX_UNITS_ATI) { - GLint count = 0; - for (i = 0; i < ctx->Const.MaxTextureImageUnits; i++) { - if (ctx->Const.SupportedBumpUnits & (1 << i)) { - count++; - } - } - *param = count; - } - else if (pname == GL_BUMP_TEX_UNITS_ATI) { - for (i = 0; i < ctx->Const.MaxTextureImageUnits; i++) { - if (ctx->Const.SupportedBumpUnits & (1 << i)) { - *param++ = i + GL_TEXTURE0; - } - } - } - else { - _mesa_error( ctx, GL_INVALID_ENUM, "glGetTexBumpParameter(pname)" ); - return; - } + _mesa_gettexenviv_indexed(ctx->Texture.CurrentUnit, target, pname, params); } void GLAPIENTRY -_mesa_GetTexBumpParameterfvATI( GLenum pname, GLfloat *param ) +_mesa_GetMultiTexEnvivEXT( GLenum texunit, GLenum target, + GLenum pname, GLint *params ) { - const struct gl_texture_unit *texUnit; - GLuint i; - GET_CURRENT_CONTEXT(ctx); - - if (!ctx->Extensions.ATI_envmap_bumpmap) { - _mesa_error(ctx, GL_INVALID_OPERATION, "glGetTexBumpParameterfvATI"); - return; - } - - texUnit = _mesa_get_current_tex_unit(ctx); - - if (pname == GL_BUMP_ROT_MATRIX_SIZE_ATI) { - /* spec leaves open to support larger matrices. - Don't think anyone would ever want to use it - (and apps might not understand it) so hardcode this. */ - *param = 4.0F; - } - else if (pname == GL_BUMP_ROT_MATRIX_ATI) { - param[0] = texUnit->RotMatrix[0]; - param[1] = texUnit->RotMatrix[1]; - param[2] = texUnit->RotMatrix[2]; - param[3] = texUnit->RotMatrix[3]; - } - else if (pname == GL_BUMP_NUM_TEX_UNITS_ATI) { - GLint count = 0; - for (i = 0; i < ctx->Const.MaxTextureImageUnits; i++) { - if (ctx->Const.SupportedBumpUnits & (1 << i)) { - count++; - } - } - *param = (GLfloat) count; - } - else if (pname == GL_BUMP_TEX_UNITS_ATI) { - for (i = 0; i < ctx->Const.MaxTextureImageUnits; i++) { - if (ctx->Const.SupportedBumpUnits & (1 << i)) { - *param++ = (GLfloat) (i + GL_TEXTURE0); - } - } - } - else { - _mesa_error( ctx, GL_INVALID_ENUM, "glGetTexBumpParameter(pname)" ); - return; - } + _mesa_gettexenviv_indexed(texunit - GL_TEXTURE0, target, pname, params); }