Merge branch 'llvm-cliptest-viewport'
[mesa.git] / src / mesa / drivers / dri / sis / sis_texstate.c
index 23f72589a7e2dd3e4f5754281777af5b3a3cac2a..daec2393211b3809cd0241aceebbfbbcab59032e 100644 (file)
@@ -18,13 +18,12 @@ Software.
 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 NON-INFRINGEMENT. IN NO EVENT SHALL
-ATI, PRECISION INSIGHT AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM,
+ERIC ANHOLT OR SILICON INTEGRATED SYSTEMS CORP 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.
 
 **************************************************************************/
-/* $XFree86$ */
 
 /*
  * Authors:
@@ -32,14 +31,13 @@ USE OR OTHER DEALINGS IN THE SOFTWARE.
  *   Eric Anholt <anholt@FreeBSD.org>
  */
 
-#include "glheader.h"
-#include "imports.h"
-#include "context.h"
-#include "macros.h"
-#include "texformat.h"
+#include "main/glheader.h"
+#include "main/imports.h"
+#include "main/colormac.h"
+#include "main/context.h"
+#include "main/macros.h"
 
 #include "sis_context.h"
-#include "sis_state.h"
 #include "sis_tex.h"
 #include "sis_tris.h"
 #include "sis_alloc.h"
@@ -48,11 +46,12 @@ static GLint TransferTexturePitch (GLint dwPitch);
 
 /* Handle texenv stuff, called from validate_texture (renderstart) */
 static void
-sis_set_texture_env0( GLcontext *ctx, struct gl_texture_object *texObj,
+sis_set_texture_env0( struct gl_context *ctx, struct gl_texture_object *texObj,
    int unit )
 {
    sisContextPtr smesa = SIS_CONTEXT(ctx);
-   
+   GLubyte c[4];
+
    __GLSiSHardware *prev = &smesa->prev;
    __GLSiSHardware *current = &smesa->current;
 
@@ -60,111 +59,122 @@ sis_set_texture_env0( GLcontext *ctx, struct gl_texture_object *texObj,
 
    sisTexObjPtr t = texObj->DriverData;
 
-   /*
-   current->hwTexBlendClr0 = RGB_STAGE1; 
-   current->hwTexBlendAlpha0 = A_STAGE1;
-   */
-
    switch (texture_unit->EnvMode)
    {
    case GL_REPLACE:
-      FALLBACK(smesa, SIS_FALLBACK_TEXENV0, 0);
       switch (t->format)
       {
       case GL_ALPHA:
-         current->hwTexBlendClr0 = A_REPLACE_RGB_STAGE0;
-         current->hwTexBlendAlpha0 = A_REPLACE_A_STAGE0;
+         current->hwTexBlendColor0 = STAGE0_C_CF;
+         current->hwTexBlendAlpha0 = STAGE0_A_AS;
          break;
       case GL_LUMINANCE:
       case GL_RGB:
-         current->hwTexBlendClr0 = RGB_REPLACE__RGB_STAGE0;
-         current->hwTexBlendAlpha0 = RGB_REPLACE__A_STAGE0;
+      case GL_YCBCR_MESA:
+         current->hwTexBlendColor0 = STAGE0_C_CS;
+         current->hwTexBlendAlpha0 = STAGE0_A_AF;
          break;
       case GL_INTENSITY:
       case GL_LUMINANCE_ALPHA:
       case GL_RGBA:
-         current->hwTexBlendClr0 = RGBA_REPLACE__RGB_STAGE0;
-         current->hwTexBlendAlpha0 = RGBA_REPLACE__A_STAGE0;
+         current->hwTexBlendColor0 = STAGE0_C_CS;
+         current->hwTexBlendAlpha0 = STAGE0_A_AS;
          break;
+      default:
+        sis_fatal_error("unknown base format 0x%x\n", t->format);
       }
       break;
 
    case GL_MODULATE:
-      FALLBACK(smesa, SIS_FALLBACK_TEXENV0, 0);
       switch (t->format)
       {
       case GL_ALPHA:
-         current->hwTexBlendClr0 = A_MODULATE_RGB_STAGE0;
-         current->hwTexBlendAlpha0 = A_MODULATE_A_STAGE0;
+         current->hwTexBlendColor0 = STAGE0_C_CF;
+         current->hwTexBlendAlpha0 = STAGE0_A_AFAS;
          break;
       case GL_LUMINANCE:
       case GL_RGB:
-         current->hwTexBlendClr0 = RGB_MODULATE__RGB_STAGE0;
-         current->hwTexBlendAlpha0 = RGB_MODULATE__A_STAGE0;
+      case GL_YCBCR_MESA:
+         current->hwTexBlendColor0 = STAGE0_C_CFCS;
+         current->hwTexBlendAlpha0 = STAGE0_A_AF;
          break;
       case GL_INTENSITY:
       case GL_LUMINANCE_ALPHA:
       case GL_RGBA:
-         current->hwTexBlendClr0 = RGBA_MODULATE__RGB_STAGE0;
-         current->hwTexBlendAlpha0 = RGBA_MODULATE__A_STAGE0;
+         current->hwTexBlendColor0 = STAGE0_C_CFCS;
+         current->hwTexBlendAlpha0 = STAGE0_A_AFAS;
          break;
+      default:
+        sis_fatal_error("unknown base format 0x%x\n", t->format);
       }
       break;
 
    case GL_DECAL:
-      FALLBACK(smesa, SIS_FALLBACK_TEXENV0, 0);
       switch (t->format)
       {
       case GL_RGB:
-         current->hwTexBlendClr0 = RGB_DECAL__RGB_STAGE0;
-         current->hwTexBlendAlpha0 = RGB_DECAL__A_STAGE0;
+      case GL_YCBCR_MESA:
+         current->hwTexBlendColor0 = STAGE0_C_CS;
+         current->hwTexBlendAlpha0 = STAGE0_A_AF;
          break;
       case GL_RGBA:
-         current->hwTexBlendClr0 = RGBA_DECAL__RGB_STAGE0;
-         current->hwTexBlendAlpha0 = RGBA_DECAL__A_STAGE0;
+         current->hwTexBlendColor0 = STAGE0_C_CFOMAS_CSAS;
+         current->hwTexBlendAlpha0 = STAGE0_A_AF;
          break;
+      case GL_ALPHA:
+      case GL_LUMINANCE:
+      case GL_INTENSITY:
+      case GL_LUMINANCE_ALPHA:
+         current->hwTexBlendColor0 = STAGE0_C_CF;
+         current->hwTexBlendAlpha0 = STAGE0_A_AF;
+         break;
+      default:
+        sis_fatal_error("unknown base format 0x%x\n", t->format);
       }
       break;
 
    case GL_BLEND:
-      FALLBACK(smesa, SIS_FALLBACK_TEXENV0, 1);
-#if 0 /* XXX Blending broken */
-      current->hwTexEnvColor =
-         ((GLint) (texture_unit->EnvColor[3])) << 24 |
-         ((GLint) (texture_unit->EnvColor[0])) << 16 |
-         ((GLint) (texture_unit->EnvColor[1])) << 8 |
-         ((GLint) (texture_unit->EnvColor[2]));
+      UNCLAMPED_FLOAT_TO_RGBA_CHAN(c, texture_unit->EnvColor);
+      current->hwTexEnvColor = ((GLint) (c[3])) << 24 |
+                              ((GLint) (c[0])) << 16 |
+                              ((GLint) (c[1])) << 8 |
+                              ((GLint) (c[2]));
       switch (t->format)
       {
       case GL_ALPHA:
-         current->hwTexBlendClr0 = A_BLEND_RGB_STAGE0;
-         current->hwTexBlendAlpha0 = A_BLEND_A_STAGE0;
+         current->hwTexBlendColor0 = STAGE0_C_CF;
+         current->hwTexBlendAlpha0 = STAGE0_A_AFAS;
          break;
       case GL_LUMINANCE:
       case GL_RGB:
-         current->hwTexBlendClr0 = RGB_BLEND__RGB_STAGE0;
-         current->hwTexBlendAlpha0 = RGB_BLEND__A_STAGE0;
+      case GL_YCBCR_MESA:
+         current->hwTexBlendColor0 = STAGE0_C_CFOMCS_CCCS;
+         current->hwTexBlendAlpha0 = STAGE0_A_AF;
          break;
       case GL_INTENSITY:
-         current->hwTexBlendClr0 = I_BLEND__RGB_STAGE0;
-         current->hwTexBlendAlpha0 = I_BLEND__A_STAGE0;
+         current->hwTexBlendColor0 = STAGE0_C_CFOMCS_CCCS;
+         current->hwTexBlendAlpha0 = STAGE0_A_AFOMAS_ACAS;
          break;
       case GL_LUMINANCE_ALPHA:
       case GL_RGBA:
-         current->hwTexBlendClr0 = RGBA_BLEND__RGB_STAGE0;
-         current->hwTexBlendAlpha0 = RGBA_BLEND__A_STAGE0;
+         current->hwTexBlendColor0 = STAGE0_C_CFOMCS_CCCS;
+         current->hwTexBlendAlpha0 = STAGE0_A_AFAS;
          break;
+      default:
+        sis_fatal_error("unknown base format 0x%x\n", t->format);
       }
       break;
-#endif
+
+   default:
+      sis_fatal_error("unknown env mode 0x%x\n", texture_unit->EnvMode);
    }
 
-   if ((current->hwTexBlendClr0 != prev->hwTexBlendClr0) ||
+   if ((current->hwTexBlendColor0 != prev->hwTexBlendColor0) ||
        (current->hwTexBlendAlpha0 != prev->hwTexBlendAlpha0) ||
        (current->hwTexEnvColor != prev->hwTexEnvColor))
    {
       prev->hwTexEnvColor = current->hwTexEnvColor;
-      prev->hwTexBlendClr0 = current->hwTexBlendClr0;
+      prev->hwTexBlendColor0 = current->hwTexBlendColor0;
       prev->hwTexBlendAlpha0 = current->hwTexBlendAlpha0;
       smesa->GlobalFlag |= GFLAG_TEXTUREENV;
    }
@@ -172,10 +182,11 @@ sis_set_texture_env0( GLcontext *ctx, struct gl_texture_object *texObj,
 
 /* Handle texenv stuff, called from validate_texture (renderstart) */
 static void
-sis_set_texture_env1( GLcontext *ctx, struct gl_texture_object *texObj,
+sis_set_texture_env1( struct gl_context *ctx, struct gl_texture_object *texObj,
    int unit)
 {
    sisContextPtr smesa = SIS_CONTEXT(ctx);
+   GLubyte c[4];
 
    __GLSiSHardware *prev = &smesa->prev;
    __GLSiSHardware *current = &smesa->current;
@@ -184,110 +195,121 @@ sis_set_texture_env1( GLcontext *ctx, struct gl_texture_object *texObj,
 
    sisTexObjPtr t = texObj->DriverData;
 
-   /*
-   current->hwTexBlendClr1 = RGB_STAGE1; current->hwTexBlendAlpha1 =
-   A_STAGE1;
-   */
-
    switch (texture_unit->EnvMode)
    {
    case GL_REPLACE:
-      FALLBACK(smesa, SIS_FALLBACK_TEXENV1, 0);
       switch (t->format)
       {
       case GL_ALPHA:
-         current->hwTexBlendClr1 = A_REPLACE_RGB_STAGE1;
-         current->hwTexBlendAlpha1 = A_REPLACE_A_STAGE1;
+         current->hwTexBlendColor1 = STAGE1_C_CF;
+         current->hwTexBlendAlpha1 = STAGE1_A_AS;
          break;
       case GL_LUMINANCE:
       case GL_RGB:
-         current->hwTexBlendClr1 = RGB_REPLACE__RGB_STAGE1;
-         current->hwTexBlendAlpha1 = RGB_REPLACE__A_STAGE1;
+      case GL_YCBCR_MESA:
+         current->hwTexBlendColor1 = STAGE1_C_CS;
+         current->hwTexBlendAlpha1 = STAGE1_A_AF;
          break;
       case GL_INTENSITY:
       case GL_LUMINANCE_ALPHA:
       case GL_RGBA:
-         current->hwTexBlendClr1 = RGBA_REPLACE__RGB_STAGE1;
-         current->hwTexBlendAlpha1 = RGBA_REPLACE__A_STAGE1;
+         current->hwTexBlendColor1 = STAGE1_C_CS;
+         current->hwTexBlendAlpha1 = STAGE1_A_AS;
          break;
+      default:
+        sis_fatal_error("unknown base format 0x%x\n", t->format);
       }
       break;
 
    case GL_MODULATE:
-      FALLBACK(smesa, SIS_FALLBACK_TEXENV1, 0);
       switch (t->format)
       {
       case GL_ALPHA:
-         current->hwTexBlendClr1 = A_MODULATE_RGB_STAGE1;
-         current->hwTexBlendAlpha1 = A_MODULATE_A_STAGE1;
+         current->hwTexBlendColor1 = STAGE1_C_CF;
+         current->hwTexBlendAlpha1 = STAGE1_A_AFAS;
          break;
       case GL_LUMINANCE:
       case GL_RGB:
-         current->hwTexBlendClr1 = RGB_MODULATE__RGB_STAGE1;
-         current->hwTexBlendAlpha1 = RGB_MODULATE__A_STAGE1;
+      case GL_YCBCR_MESA:
+         current->hwTexBlendColor1 = STAGE1_C_CFCS;
+         current->hwTexBlendAlpha1 = STAGE1_A_AF;
          break;
       case GL_INTENSITY:
       case GL_LUMINANCE_ALPHA:
       case GL_RGBA:
-         current->hwTexBlendClr1 = RGBA_MODULATE__RGB_STAGE1;
-         current->hwTexBlendAlpha1 = RGBA_MODULATE__A_STAGE1;
+         current->hwTexBlendColor1 = STAGE1_C_CFCS;
+         current->hwTexBlendAlpha1 = STAGE1_A_AFAS;
          break;
+      default:
+        sis_fatal_error("unknown base format 0x%x\n", t->format);
       }
       break;
 
    case GL_DECAL:
-      FALLBACK(smesa, SIS_FALLBACK_TEXENV1, 0);
       switch (t->format)
       {
       case GL_RGB:
-         current->hwTexBlendClr1 = RGB_DECAL__RGB_STAGE1;
-         current->hwTexBlendAlpha1 = RGB_DECAL__A_STAGE1;
+      case GL_YCBCR_MESA:
+         current->hwTexBlendColor1 = STAGE1_C_CS;
+         current->hwTexBlendAlpha1 = STAGE1_A_AF;
          break;
       case GL_RGBA:
-         current->hwTexBlendClr1 = RGBA_DECAL__RGB_STAGE1;
-         current->hwTexBlendAlpha1 = RGBA_DECAL__A_STAGE1;
+         current->hwTexBlendColor1 = STAGE1_C_CFOMAS_CSAS;
+         current->hwTexBlendAlpha1 = STAGE1_A_AF;
+         break;
+      case GL_ALPHA:
+      case GL_LUMINANCE:
+      case GL_INTENSITY:
+      case GL_LUMINANCE_ALPHA:
+         current->hwTexBlendColor1 = STAGE1_C_CF;
+         current->hwTexBlendAlpha1 = STAGE1_A_AF;
          break;
+      default:
+        sis_fatal_error("unknown base format 0x%x\n", t->format);
       }
       break;
 
    case GL_BLEND:
-      FALLBACK(smesa, SIS_FALLBACK_TEXENV1, 1);
-#if 0 /* XXX Blending broken */
-      current->hwTexEnvColor =
-         ((GLint) (texture_unit->EnvColor[3])) << 24 |
-         ((GLint) (texture_unit->EnvColor[0])) << 16 |
-         ((GLint) (texture_unit->EnvColor[1])) << 8 |
-         ((GLint) (texture_unit->EnvColor[2]));
+      UNCLAMPED_FLOAT_TO_RGBA_CHAN(c, texture_unit->EnvColor);
+      current->hwTexEnvColor = ((GLint) (c[3])) << 24 |
+                              ((GLint) (c[0])) << 16 |
+                              ((GLint) (c[1])) << 8 |
+                              ((GLint) (c[2]));
       switch (t->format)
       {
       case GL_ALPHA:
-         current->hwTexBlendClr1 = A_BLEND_RGB_STAGE1;
-         current->hwTexBlendAlpha1 = A_BLEND_A_STAGE1;
+         current->hwTexBlendColor1 = STAGE1_C_CF;
+         current->hwTexBlendAlpha1 = STAGE1_A_AFAS;
          break;
       case GL_LUMINANCE:
       case GL_RGB:
-         current->hwTexBlendClr1 = RGB_BLEND__RGB_STAGE1;
-         current->hwTexBlendAlpha1 = RGB_BLEND__A_STAGE1;
+      case GL_YCBCR_MESA:
+         current->hwTexBlendColor1 = STAGE1_C_CFOMCS_CCCS;
+         current->hwTexBlendAlpha1 = STAGE1_A_AF;
          break;
       case GL_INTENSITY:
-         current->hwTexBlendClr1 = I_BLEND__RGB_STAGE1;
-         current->hwTexBlendAlpha1 = I_BLEND__A_STAGE1;
+         current->hwTexBlendColor1 = STAGE1_C_CFOMCS_CCCS;
+         current->hwTexBlendAlpha1 = STAGE1_A_AFOMAS_ACAS;
          break;
       case GL_LUMINANCE_ALPHA:
       case GL_RGBA:
-         current->hwTexBlendClr1 = RGBA_BLEND__RGB_STAGE1;
-         current->hwTexBlendAlpha1 = RGBA_BLEND__A_STAGE1;
+         current->hwTexBlendColor1 = STAGE1_C_CFOMCS_CCCS;
+         current->hwTexBlendAlpha1 = STAGE1_A_AFAS;
          break;
+      default:
+        sis_fatal_error("unknown base format 0x%x\n", t->format);
       }
       break;
-#endif
+
+   default:
+      sis_fatal_error("unknown env mode 0x%x\n", texture_unit->EnvMode);
    }
 
-   if ((current->hwTexBlendClr1 != prev->hwTexBlendClr1) ||
+   if ((current->hwTexBlendColor1 != prev->hwTexBlendColor1) ||
        (current->hwTexBlendAlpha1 != prev->hwTexBlendAlpha1) ||
        (current->hwTexEnvColor != prev->hwTexEnvColor))
    {
-      prev->hwTexBlendClr1 = current->hwTexBlendClr1;
+      prev->hwTexBlendColor1 = current->hwTexBlendColor1;
       prev->hwTexBlendAlpha1 = current->hwTexBlendAlpha1;
       prev->hwTexEnvColor = current->hwTexEnvColor;
       smesa->GlobalFlag |= GFLAG_TEXTUREENV_1;
@@ -296,7 +318,7 @@ sis_set_texture_env1( GLcontext *ctx, struct gl_texture_object *texObj,
 
 /* Returns 0 if a software fallback is necessary */
 static GLboolean
-sis_set_texobj_parm( GLcontext *ctx, struct gl_texture_object *texObj,
+sis_set_texobj_parm( struct gl_context *ctx, struct gl_texture_object *texObj,
    int hw_unit )
 {
    sisContextPtr smesa = SIS_CONTEXT(ctx);
@@ -327,7 +349,7 @@ sis_set_texobj_parm( GLcontext *ctx, struct gl_texture_object *texObj,
       lastLevel = texObj->BaseLevel + (GLint)(texObj->MaxLod + 0.5);
       lastLevel = MAX2(lastLevel, texObj->BaseLevel);
       lastLevel = MIN2(lastLevel, texObj->BaseLevel +
-         texObj->Image[texObj->BaseLevel]->MaxLog2);
+         texObj->Image[0][texObj->BaseLevel]->MaxLog2);
       lastLevel = MIN2(lastLevel, texObj->MaxLevel);
       lastLevel = MAX2(firstLevel, lastLevel); /* need at least one level */
    }
@@ -391,14 +413,21 @@ sis_set_texobj_parm( GLcontext *ctx, struct gl_texture_object *texObj,
    case GL_REPEAT:
       current->texture[hw_unit].hwTextureSet |= MASK_TextureWrapU;
       break;
+   case GL_MIRRORED_REPEAT:
+      current->texture[hw_unit].hwTextureSet |= MASK_TextureMirrorU;
+      break;
    case GL_CLAMP:
       current->texture[hw_unit].hwTextureSet |= MASK_TextureClampU;
+       /* XXX: GL_CLAMP isn't conformant, but falling back makes the situation
+        * worse in other programs at the moment.
+        */
+      /*ok = 0;*/
       break;
    case GL_CLAMP_TO_EDGE:
-      /* 
-      * ?? not support yet 
-      */
-      ok = 0;
+      current->texture[hw_unit].hwTextureSet |= MASK_TextureClampU;
+      break;
+   case GL_CLAMP_TO_BORDER:
+      current->texture[hw_unit].hwTextureSet |= MASK_TextureBorderU;
       break;
    }
 
@@ -407,34 +436,35 @@ sis_set_texobj_parm( GLcontext *ctx, struct gl_texture_object *texObj,
    case GL_REPEAT:
       current->texture[hw_unit].hwTextureSet |= MASK_TextureWrapV;
       break;
+   case GL_MIRRORED_REPEAT:
+      current->texture[hw_unit].hwTextureSet |= MASK_TextureMirrorV;
+      break;
    case GL_CLAMP:
       current->texture[hw_unit].hwTextureSet |= MASK_TextureClampV;
+       /* XXX: GL_CLAMP isn't conformant, but falling back makes the situation
+        * worse in other programs at the moment.
+        */
+      /*ok = 0;*/
       break;
    case GL_CLAMP_TO_EDGE:
-      /* 
-      * ?? not support yet 
-      */
-      ok = 0;
+      current->texture[hw_unit].hwTextureSet |= MASK_TextureClampV;
+      break;
+   case GL_CLAMP_TO_BORDER:
+      current->texture[hw_unit].hwTextureSet |= MASK_TextureBorderV;
       break;
    }
 
-/*
-   if (current->texture[hw_unit].hwTextureSet & MASK_TextureClampU) {
-      current->texture[hw_unit].hwTextureSet &= ~MASK_TextureClampU;
-      current->texture[hw_unit].hwTextureSet |= MASK_TextureBorderU;
-   }
-   
-   if (current->texture[hw_unit].hwTextureSet & MASK_TextureClampV) {
-      current->texture[hw_unit].hwTextureSet &= ~MASK_TextureClampV;
-      current->texture[hw_unit].hwTextureSet |= MASK_TextureBorderV;
+   {
+      GLubyte c[4];
+      CLAMPED_FLOAT_TO_UBYTE(c[0], texObj->BorderColor.f[0]);
+      CLAMPED_FLOAT_TO_UBYTE(c[1], texObj->BorderColor.f[1]);
+      CLAMPED_FLOAT_TO_UBYTE(c[2], texObj->BorderColor.f[2]);
+      CLAMPED_FLOAT_TO_UBYTE(c[3], texObj->BorderColor.f[3]);
+
+      current->texture[hw_unit].hwTextureBorderColor = 
+         PACK_COLOR_8888(c[3], c[0], c[1], c[2]);
    }
-*/
-   current->texture[hw_unit].hwTextureBorderColor = 
-      ((GLuint) texObj->BorderColor[3] << 24) + 
-      ((GLuint) texObj->BorderColor[0] << 16) + 
-      ((GLuint) texObj->BorderColor[1] << 8) + 
-      ((GLuint) texObj->BorderColor[2]);
-   
+
    if (current->texture[hw_unit].hwTextureBorderColor !=
        prev->texture[hw_unit].hwTextureBorderColor) 
    {
@@ -447,9 +477,9 @@ sis_set_texobj_parm( GLcontext *ctx, struct gl_texture_object *texObj,
    }
 
    current->texture[hw_unit].hwTextureSet |=
-      texObj->Image[firstLevel]->WidthLog2 << 4;
+      texObj->Image[0][firstLevel]->WidthLog2 << 4;
    current->texture[hw_unit].hwTextureSet |=
-      texObj->Image[firstLevel]->HeightLog2;
+      texObj->Image[0][firstLevel]->HeightLog2;
 
    if (hw_unit == 0)
       smesa->GlobalFlag |= GFLAG_TEXTUREADDRESS;
@@ -553,7 +583,7 @@ sis_set_texobj_parm( GLcontext *ctx, struct gl_texture_object *texObj,
 
 /* Disable a texture unit, called from validate_texture */
 static void
-sis_reset_texture_env (GLcontext *ctx, int hw_unit)
+sis_reset_texture_env (struct gl_context *ctx, int hw_unit)
 {
    sisContextPtr smesa = SIS_CONTEXT(ctx);
 
@@ -562,27 +592,27 @@ sis_reset_texture_env (GLcontext *ctx, int hw_unit)
 
    if (hw_unit == 1)
    {
-      current->hwTexBlendClr1 = RGB_STAGE1;
-      current->hwTexBlendAlpha1 = A_STAGE1;
+      current->hwTexBlendColor1 = STAGE1_C_CF;
+      current->hwTexBlendAlpha1 = STAGE1_A_AF;
       
-      if ((current->hwTexBlendClr1 != prev->hwTexBlendClr1) ||
+      if ((current->hwTexBlendColor1 != prev->hwTexBlendColor1) ||
           (current->hwTexBlendAlpha1 != prev->hwTexBlendAlpha1) ||
           (current->hwTexEnvColor != prev->hwTexEnvColor))
       {
-         prev->hwTexBlendClr1 = current->hwTexBlendClr1;
+         prev->hwTexBlendColor1 = current->hwTexBlendColor1;
          prev->hwTexBlendAlpha1 = current->hwTexBlendAlpha1;
          prev->hwTexEnvColor = current->hwTexEnvColor;
          smesa->GlobalFlag |= GFLAG_TEXTUREENV_1;
       }
    } else {
-      current->hwTexBlendClr0 = RGB_STAGE1;
-      current->hwTexBlendAlpha0 = A_STAGE1;
+      current->hwTexBlendColor0 = STAGE0_C_CF;
+      current->hwTexBlendAlpha0 = STAGE0_A_AF;
       
-      if ((current->hwTexBlendClr0 != prev->hwTexBlendClr0) ||
+      if ((current->hwTexBlendColor0 != prev->hwTexBlendColor0) ||
           (current->hwTexBlendAlpha0 != prev->hwTexBlendAlpha0) ||
           (current->hwTexEnvColor != prev->hwTexEnvColor))
       {
-         prev->hwTexBlendClr0 = current->hwTexBlendClr0;
+         prev->hwTexBlendColor0 = current->hwTexBlendColor0;
          prev->hwTexBlendAlpha0 = current->hwTexBlendAlpha0;
          prev->hwTexEnvColor = current->hwTexEnvColor;
          smesa->GlobalFlag |= GFLAG_TEXTUREENV;
@@ -590,7 +620,7 @@ sis_reset_texture_env (GLcontext *ctx, int hw_unit)
    }
 }
 
-static void updateTextureUnit( GLcontext *ctx, int unit )
+static void updateTextureUnit( struct gl_context *ctx, int unit )
 {
    sisContextPtr smesa = SIS_CONTEXT( ctx );
    const struct gl_texture_unit *texUnit = &ctx->Texture.Unit[unit];
@@ -626,7 +656,7 @@ static void updateTextureUnit( GLcontext *ctx, int unit )
 }
 
 
-void sisUpdateTextureState( GLcontext *ctx )
+void sisUpdateTextureState( struct gl_context *ctx )
 {
    sisContextPtr smesa = SIS_CONTEXT( ctx );
    int i;