mesa: Remove EXT_texture_env_add extension enable flag
[mesa.git] / src / mesa / main / texenv.c
index 95547a500ee3b15e6d5aed22b99d8c9817444818..9d47c7bba45de90cf471ee5350dee7d864b8a0de 100644 (file)
 #include "main/context.h"
 #include "main/enums.h"
 #include "main/macros.h"
+#include "main/mtypes.h"
+#include "main/state.h"
 #include "main/texenv.h"
+#include "main/texstate.h"
 
 
 #define TE_ERROR(errCode, msg, value)                          \
@@ -43,7 +46,7 @@
 
 /** Set texture env mode */
 static void
-set_env_mode(GLcontext *ctx,
+set_env_mode(struct gl_context *ctx,
              struct gl_texture_unit *texUnit,
              GLenum mode)
 {
@@ -57,15 +60,13 @@ set_env_mode(GLcontext *ctx,
    case GL_BLEND:
    case GL_DECAL:
    case GL_REPLACE:
+   case GL_ADD:
       legal = GL_TRUE;
       break;
    case GL_REPLACE_EXT:
       mode = GL_REPLACE; /* GL_REPLACE_EXT != GL_REPLACE */
       legal = GL_TRUE;
       break;
-   case GL_ADD:
-      legal = ctx->Extensions.EXT_texture_env_add;
-      break;
    case GL_COMBINE:
       legal = (ctx->Extensions.EXT_texture_env_combine ||
                ctx->Extensions.ARB_texture_env_combine);
@@ -88,25 +89,24 @@ set_env_mode(GLcontext *ctx,
 
 
 static void
-set_env_color(GLcontext *ctx,
+set_env_color(struct gl_context *ctx,
               struct gl_texture_unit *texUnit,
               const GLfloat *color)
 {
-   GLfloat tmp[4];
-   tmp[0] = CLAMP(color[0], 0.0F, 1.0F);
-   tmp[1] = CLAMP(color[1], 0.0F, 1.0F);
-   tmp[2] = CLAMP(color[2], 0.0F, 1.0F);
-   tmp[3] = CLAMP(color[3], 0.0F, 1.0F);
-   if (TEST_EQ_4V(tmp, texUnit->EnvColor))
+   if (TEST_EQ_4V(color, texUnit->EnvColorUnclamped))
       return;
    FLUSH_VERTICES(ctx, _NEW_TEXTURE);
-   COPY_4FV(texUnit->EnvColor, tmp);
+   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);
+   texUnit->EnvColor[2] = CLAMP(color[2], 0.0F, 1.0F);
+   texUnit->EnvColor[3] = CLAMP(color[3], 0.0F, 1.0F);
 }
 
 
 /** Set an RGB or A combiner mode/function */
 static void
-set_combiner_mode(GLcontext *ctx,
+set_combiner_mode(struct gl_context *ctx,
                   struct gl_texture_unit *texUnit,
                   GLenum pname, GLenum mode)
 {
@@ -142,7 +142,11 @@ set_combiner_mode(GLcontext *ctx,
    case GL_MODULATE_ADD_ATI:
    case GL_MODULATE_SIGNED_ADD_ATI:
    case GL_MODULATE_SUBTRACT_ATI:
-      legal =ctx->Extensions.ATI_texture_env_combine3;
+      legal = ctx->Extensions.ATI_texture_env_combine3;
+      break;
+   case GL_BUMP_ENVMAP_ATI:
+      legal = (ctx->Extensions.ATI_envmap_bumpmap &&
+               pname == GL_COMBINE_RGB);
       break;
    default:
       legal = GL_FALSE;
@@ -176,11 +180,11 @@ set_combiner_mode(GLcontext *ctx,
 
 /** Set an RGB or A combiner source term */
 static void
-set_combiner_source(GLcontext *ctx,
+set_combiner_source(struct gl_context *ctx,
                     struct gl_texture_unit *texUnit,
                     GLenum pname, GLenum param)
 {
-   GLuint src;
+   GLuint term;
    GLboolean alpha, legal;
 
    if (!ctx->Extensions.EXT_texture_env_combine &&
@@ -190,59 +194,36 @@ set_combiner_source(GLcontext *ctx,
    }
 
    /*
-    * Translate pname to (src, alpha).
+    * Translate pname to (term, alpha).
+    *
+    * The enums were given sequential values for a reason.
     */
    switch (pname) {
    case GL_SOURCE0_RGB:
-      src = 0;
-      alpha = GL_FALSE;
-      break;
    case GL_SOURCE1_RGB:
-      src = 1;
-      alpha = GL_FALSE;
-      break;
    case GL_SOURCE2_RGB:
-      src = 2;
-      alpha = GL_FALSE;
-      break;
    case GL_SOURCE3_RGB_NV:
-      if (ctx->Extensions.NV_texture_env_combine4) {
-         src = 3;
-         alpha = GL_FALSE;
-      }
-      else {
-         TE_ERROR(GL_INVALID_ENUM, "glTexEnv(pname=%s)", pname);
-         return;
-      }
+      term = pname - GL_SOURCE0_RGB;
+      alpha = GL_FALSE;
       break;
    case GL_SOURCE0_ALPHA:
-      src = 0;
-      alpha = GL_TRUE;
-      break;
    case GL_SOURCE1_ALPHA:
-      src = 1;
-      alpha = GL_TRUE;
-      break;
    case GL_SOURCE2_ALPHA:
-      src = 2;
-      alpha = GL_TRUE;
-      break;
    case GL_SOURCE3_ALPHA_NV:
-      if (ctx->Extensions.NV_texture_env_combine4) {
-         src = 3;
-         alpha = GL_TRUE;
-      }
-      else {
-         TE_ERROR(GL_INVALID_ENUM, "glTexEnv(pname=%s)", pname);
-         return;
-      }
+      term = pname - GL_SOURCE0_ALPHA;
+      alpha = GL_TRUE;
       break;
    default:
       TE_ERROR(GL_INVALID_ENUM, "glTexEnv(pname=%s)", pname);
       return;
    }
 
-   assert(src < 4);
+   if ((term == 3) && !ctx->Extensions.NV_texture_env_combine4) {
+      TE_ERROR(GL_INVALID_ENUM, "glTexEnv(pname=%s)", pname);
+      return;
+   }
+
+   assert(term < MAX_COMBINER_TERMS);
 
    /*
     * Error-check param (the source term)
@@ -284,19 +265,19 @@ set_combiner_source(GLcontext *ctx,
    FLUSH_VERTICES(ctx, _NEW_TEXTURE);
 
    if (alpha)
-      texUnit->Combine.SourceA[src] = param;
+      texUnit->Combine.SourceA[term] = param;
    else
-      texUnit->Combine.SourceRGB[src] = param;
+      texUnit->Combine.SourceRGB[term] = param;
 }
 
 
 /** Set an RGB or A combiner operand term */
 static void
-set_combiner_operand(GLcontext *ctx,
+set_combiner_operand(struct gl_context *ctx,
                      struct gl_texture_unit *texUnit,
                      GLenum pname, GLenum param)
 {
-   GLuint op;
+   GLuint term;
    GLboolean alpha, legal;
 
    if (!ctx->Extensions.EXT_texture_env_combine &&
@@ -305,69 +286,34 @@ set_combiner_operand(GLcontext *ctx,
       return;
    }
 
+   /* The enums were given sequential values for a reason.
+    */
    switch (pname) {
    case GL_OPERAND0_RGB:
-      op = 0;
-      alpha = GL_FALSE;
-      break;
    case GL_OPERAND1_RGB:
-      op = 1;
-      alpha = GL_FALSE;
-      break;
    case GL_OPERAND2_RGB:
-      if (ctx->Extensions.ARB_texture_env_combine) {
-         op = 2;
-         alpha = GL_FALSE;
-      }
-      else {
-         TE_ERROR(GL_INVALID_ENUM, "glTexEnv(pname=%s)", pname);
-         return;
-      }
-      break;
    case GL_OPERAND3_RGB_NV:
-      if (ctx->Extensions.NV_texture_env_combine4) {
-         op = 3;
-         alpha = GL_FALSE;
-      }
-      else {
-         TE_ERROR(GL_INVALID_ENUM, "glTexEnv(pname=%s)", pname);
-         return;
-      }
+      term = pname - GL_OPERAND0_RGB;
+      alpha = GL_FALSE;
       break;
    case GL_OPERAND0_ALPHA:
-      op = 0;
-      alpha = GL_TRUE;
-      break;
    case GL_OPERAND1_ALPHA:
-      op = 1;
-      alpha = GL_TRUE;
-      break;
    case GL_OPERAND2_ALPHA:
-      if (ctx->Extensions.ARB_texture_env_combine) {
-         op = 2;
-         alpha = GL_TRUE;
-      }
-      else {
-         TE_ERROR(GL_INVALID_ENUM, "glTexEnv(pname=%s)", pname);
-         return;
-      }
-      break;
    case GL_OPERAND3_ALPHA_NV:
-      if (ctx->Extensions.NV_texture_env_combine4) {
-         op = 3;
-         alpha = GL_TRUE;
-      }
-      else {
-         TE_ERROR(GL_INVALID_ENUM, "glTexEnv(pname=%s)", pname);
-         return;
-      }
+      term = pname - GL_OPERAND0_ALPHA;
+      alpha = GL_TRUE;
       break;
    default:
       TE_ERROR(GL_INVALID_ENUM, "glTexEnv(pname=%s)", pname);
       return;
    }
 
-   assert(op < 4);
+   if ((term == 3) && !ctx->Extensions.NV_texture_env_combine4) {
+      TE_ERROR(GL_INVALID_ENUM, "glTexEnv(pname=%s)", pname);
+      return;
+   }
+
+   assert(term < MAX_COMBINER_TERMS);
 
    /*
     * Error-check param (the source operand)
@@ -375,10 +321,23 @@ set_combiner_operand(GLcontext *ctx,
    switch (param) {
    case GL_SRC_COLOR:
    case GL_ONE_MINUS_SRC_COLOR:
-      legal = !alpha;
+      /* The color input can only be used with GL_OPERAND[01]_RGB in the EXT
+       * version.  In the ARB and NV versions they can be used for any RGB
+       * operand.
+       */
+      legal = !alpha
+        && ((term < 2) || ctx->Extensions.ARB_texture_env_combine
+            || ctx->Extensions.NV_texture_env_combine4);
       break;
-   case GL_SRC_ALPHA:
    case GL_ONE_MINUS_SRC_ALPHA:
+      /* GL_ONE_MINUS_SRC_ALPHA can only be used with
+       * GL_OPERAND[01]_(RGB|ALPHA) in the EXT version.  In the ARB and NV
+       * versions it can be used for any operand.
+       */
+      legal = (term < 2) || ctx->Extensions.ARB_texture_env_combine
+        || ctx->Extensions.NV_texture_env_combine4;
+      break;
+   case GL_SRC_ALPHA:
       legal = GL_TRUE;
       break;
    default:
@@ -393,14 +352,14 @@ set_combiner_operand(GLcontext *ctx,
    FLUSH_VERTICES(ctx, _NEW_TEXTURE);
 
    if (alpha)
-      texUnit->Combine.OperandA[op] = param;
+      texUnit->Combine.OperandA[term] = param;
    else
-      texUnit->Combine.OperandRGB[op] = param;
+      texUnit->Combine.OperandRGB[term] = param;
 }
 
 
 static void
-set_combiner_scale(GLcontext *ctx,
+set_combiner_scale(struct gl_context *ctx,
                    struct gl_texture_unit *texUnit,
                    GLenum pname, GLfloat scale)
 {
@@ -450,31 +409,33 @@ set_combiner_scale(GLcontext *ctx,
 void GLAPIENTRY
 _mesa_TexEnvfv( GLenum target, GLenum pname, const GLfloat *param )
 {
+   const GLint iparam0 = (GLint) param[0];
+   struct gl_texture_unit *texUnit;
    GLuint maxUnit;
+
    GET_CURRENT_CONTEXT(ctx);
-   struct gl_texture_unit *texUnit;
    ASSERT_OUTSIDE_BEGIN_END(ctx);
 
    maxUnit = (target == GL_POINT_SPRITE_NV && pname == GL_COORD_REPLACE_NV)
-      ? ctx->Const.MaxTextureCoordUnits : ctx->Const.MaxTextureImageUnits;
+      ? ctx->Const.MaxTextureCoordUnits : ctx->Const.MaxCombinedTextureImageUnits;
    if (ctx->Texture.CurrentUnit >= maxUnit) {
       _mesa_error(ctx, GL_INVALID_OPERATION, "glTexEnvfv(current unit)");
       return;
    }
 
-   texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit];
+   texUnit = _mesa_get_current_tex_unit(ctx);
 
    if (target == GL_TEXTURE_ENV) {
       switch (pname) {
       case GL_TEXTURE_ENV_MODE:
-         set_env_mode(ctx, texUnit, (GLenum) (GLint) param[0]);
+         set_env_mode(ctx, texUnit, (GLenum) iparam0);
          break;
       case GL_TEXTURE_ENV_COLOR:
          set_env_color(ctx, texUnit, param);
          break;
       case GL_COMBINE_RGB:
       case GL_COMBINE_ALPHA:
-         set_combiner_mode(ctx, texUnit, pname, (GLenum) (GLint) param[0]);
+         set_combiner_mode(ctx, texUnit, pname, (GLenum) iparam0);
         break;
       case GL_SOURCE0_RGB:
       case GL_SOURCE1_RGB:
@@ -484,7 +445,7 @@ _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) (GLint) param[0]);
+         set_combiner_source(ctx, texUnit, pname, (GLenum) iparam0);
         break;
       case GL_OPERAND0_RGB:
       case GL_OPERAND1_RGB:
@@ -494,12 +455,32 @@ _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) (GLint) param[0]);
+         set_combiner_operand(ctx, texUnit, pname, (GLenum) iparam0);
         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->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;
+        }
+        break;
       default:
         _mesa_error( ctx, GL_INVALID_ENUM, "glTexEnv(pname)" );
         return;
@@ -530,19 +511,18 @@ _mesa_TexEnvfv( GLenum target, GLenum pname, const GLfloat *param )
         return;
       }
       if (pname == GL_COORD_REPLACE_NV) {
-         const GLenum value = (GLenum) param[0];
-         if (value == GL_TRUE || value == GL_FALSE) {
+         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) value;
+            const GLboolean state = (GLboolean) iparam0;
             if (ctx->Point.CoordReplace[ctx->Texture.CurrentUnit] == state)
                return;
             FLUSH_VERTICES(ctx, _NEW_POINT);
             ctx->Point.CoordReplace[ctx->Texture.CurrentUnit] = state;
          }
          else {
-            _mesa_error( ctx, GL_INVALID_VALUE, "glTexEnv(param=0x%x)", value);
+            _mesa_error( ctx, GL_INVALID_VALUE, "glTexEnv(param=0x%x)", iparam0);
             return;
          }
       }
@@ -561,7 +541,7 @@ _mesa_TexEnvfv( GLenum target, GLenum pname, const GLfloat *param )
                   _mesa_lookup_enum_by_nr(target),
                   _mesa_lookup_enum_by_nr(pname),
                   *param,
-                  _mesa_lookup_enum_by_nr((GLenum) (GLint) *param));
+                  _mesa_lookup_enum_by_nr((GLenum) iparam0));
 
    /* Tell device driver about the new texture environment */
    if (ctx->Driver.TexEnv) {
@@ -573,7 +553,10 @@ _mesa_TexEnvfv( GLenum target, GLenum pname, const GLfloat *param )
 void GLAPIENTRY
 _mesa_TexEnvf( GLenum target, GLenum pname, GLfloat param )
 {
-   _mesa_TexEnvfv( target, pname, &param );
+   GLfloat p[4];
+   p[0] = param;
+   p[1] = p[2] = p[3] = 0.0;
+   _mesa_TexEnvfv( target, pname, p );
 }
 
 
@@ -612,7 +595,7 @@ _mesa_TexEnviv( GLenum target, GLenum pname, const GLint *param )
  * \return  value of queried pname or -1 if error.
  */
 static GLint
-get_texenvi(GLcontext *ctx, const struct gl_texture_unit *texUnit,
+get_texenvi(struct gl_context *ctx, const struct gl_texture_unit *texUnit,
             GLenum pname)
 {
    switch (pname) {
@@ -735,8 +718,19 @@ get_texenvi(GLcontext *ctx, const struct gl_texture_unit *texUnit,
          _mesa_error(ctx, GL_INVALID_ENUM, "glGetTexEnvfv(pname)");
       }
       break;
+   case GL_BUMP_TARGET_ATI:
+      /* spec doesn't say so, but I think this should be queryable */
+      if (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;
    }
 
    return -1; /* error */
@@ -753,17 +747,22 @@ _mesa_GetTexEnvfv( GLenum target, GLenum pname, GLfloat *params )
    ASSERT_OUTSIDE_BEGIN_END(ctx);
 
    maxUnit = (target == GL_POINT_SPRITE_NV && pname == GL_COORD_REPLACE_NV)
-      ? ctx->Const.MaxTextureCoordUnits : ctx->Const.MaxTextureImageUnits;
+      ? ctx->Const.MaxTextureCoordUnits : ctx->Const.MaxCombinedTextureImageUnits;
    if (ctx->Texture.CurrentUnit >= maxUnit) {
       _mesa_error(ctx, GL_INVALID_OPERATION, "glGetTexEnvfv(current unit)");
       return;
    }
 
-   texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit];
+   texUnit = _mesa_get_current_tex_unit(ctx);
 
    if (target == GL_TEXTURE_ENV) {
       if (pname == GL_TEXTURE_ENV_COLOR) {
-         COPY_4FV( params, texUnit->EnvColor );
+         if(ctx->NewState & (_NEW_BUFFERS | _NEW_FRAG_CLAMP))
+            _mesa_update_state(ctx);
+         if(ctx->Color._ClampFragmentColor)
+            COPY_4FV( params, texUnit->EnvColor );
+         else
+            COPY_4FV( params, texUnit->EnvColorUnclamped );
       }
       else {
          GLint val = get_texenvi(ctx, texUnit, pname);
@@ -817,13 +816,13 @@ _mesa_GetTexEnviv( GLenum target, GLenum pname, GLint *params )
    ASSERT_OUTSIDE_BEGIN_END(ctx);
 
    maxUnit = (target == GL_POINT_SPRITE_NV && pname == GL_COORD_REPLACE_NV)
-      ? ctx->Const.MaxTextureCoordUnits : ctx->Const.MaxTextureImageUnits;
+      ? ctx->Const.MaxTextureCoordUnits : ctx->Const.MaxCombinedTextureImageUnits;
    if (ctx->Texture.CurrentUnit >= maxUnit) {
       _mesa_error(ctx, GL_INVALID_OPERATION, "glGetTexEnviv(current unit)");
       return;
    }
 
-   texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit];
+   texUnit = _mesa_get_current_tex_unit(ctx);
 
    if (target == GL_TEXTURE_ENV) {
       if (pname == GL_TEXTURE_ENV_COLOR) {
@@ -875,3 +874,169 @@ _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 )
+{
+   GLfloat p[4];
+   GET_CURRENT_CONTEXT(ctx);
+   ASSERT_OUTSIDE_BEGIN_END(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 );
+}
+
+
+void GLAPIENTRY
+_mesa_TexBumpParameterfvATI( GLenum pname, const GLfloat *param )
+{
+   struct gl_texture_unit *texUnit;
+   GET_CURRENT_CONTEXT(ctx);
+   ASSERT_OUTSIDE_BEGIN_END(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 );
+   }
+}
+
+
+void GLAPIENTRY
+_mesa_GetTexBumpParameterivATI( GLenum pname, GLint *param )
+{
+   const struct gl_texture_unit *texUnit;
+   GLuint i;
+   GET_CURRENT_CONTEXT(ctx);
+   ASSERT_OUTSIDE_BEGIN_END(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;
+   }
+}
+
+
+void GLAPIENTRY
+_mesa_GetTexBumpParameterfvATI( GLenum pname, GLfloat *param )
+{
+   const struct gl_texture_unit *texUnit;
+   GLuint i;
+   GET_CURRENT_CONTEXT(ctx);
+   ASSERT_OUTSIDE_BEGIN_END(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;
+   }
+}