Enable GL_ARB_texture_mirrored_repeat on Savage4. Refactor the code that
authorIan Romanick <idr@us.ibm.com>
Thu, 22 Sep 2005 21:25:31 +0000 (21:25 +0000)
committerIan Romanick <idr@us.ibm.com>
Thu, 22 Sep 2005 21:25:31 +0000 (21:25 +0000)
sets the texture wrap mode and texture filter mode for Savage4 to the new
functions savage4_set_wrap_mode and savage4_set_filter_mode.

This was tested with texwrap and tunnel.

src/mesa/drivers/dri/savage/savage_xmesa.c
src/mesa/drivers/dri/savage/savagedd.c
src/mesa/drivers/dri/savage/savagetex.c

index c3c0a8c97162b440f62dd1324dbf791451a60d51..bf8ec304f7979aefd2c9339a4a104491c4300432 100644 (file)
@@ -142,6 +142,7 @@ static const struct dri_extension card_extensions[] =
 static const struct dri_extension s4_extensions[] =
 {
     { "GL_ARB_texture_env_add",            NULL },
+    { "GL_ARB_texture_mirrored_repeat",    NULL },
     { NULL,                                NULL }
 };
 
index 72d7d33ce32e5355fe1cafb24f93f3ce1fe8f944..ced44e562f7d2539407b73560066bf26cee4d48b 100644 (file)
@@ -42,7 +42,7 @@
 #include "utils.h"
 
 
-#define DRIVER_DATE "20050501"
+#define DRIVER_DATE "20050829"
 
 /***************************************
  * Mesa's Driver Functions
index 5584e371e69e5d2cd7485941261c0763cc1765be..ce9d1def8efbf9dcc5816f38c95a82e64a3fcec3 100644 (file)
@@ -1086,6 +1086,78 @@ static void savageUploadTexImages( savageContextPtr imesa, savageTexObjPtr t )
 }
 
 
+static void
+savage4_set_wrap_mode( savageContextPtr imesa, unsigned unit,
+                     GLenum s_mode, GLenum t_mode )
+{
+    switch( s_mode ) {
+    case GL_REPEAT:
+       imesa->regs.s4.texCtrl[ unit ].ni.uMode = TAM_Wrap;
+       break;
+    case GL_CLAMP:
+    case GL_CLAMP_TO_EDGE:
+       imesa->regs.s4.texCtrl[ unit ].ni.uMode = TAM_Clamp;
+       break;
+    case GL_MIRRORED_REPEAT:
+       imesa->regs.s4.texCtrl[ unit ].ni.uMode = TAM_Mirror;
+       break;
+    }
+
+    switch( t_mode ) {
+    case GL_REPEAT:
+       imesa->regs.s4.texCtrl[ unit ].ni.vMode = TAM_Wrap;
+       break;
+    case GL_CLAMP:
+    case GL_CLAMP_TO_EDGE:
+       imesa->regs.s4.texCtrl[ unit ].ni.vMode = TAM_Clamp;
+       break;
+    case GL_MIRRORED_REPEAT:
+       imesa->regs.s4.texCtrl[ unit ].ni.vMode = TAM_Mirror;
+       break;
+    }
+}
+
+
+/**
+ * Sets the hardware bits for the specified GL texture filter modes.
+ * 
+ * \todo
+ * Does the Savage4 have the ability to select the magnification filter?
+ */
+static void
+savage4_set_filter_mode( savageContextPtr imesa, unsigned unit,
+                        GLenum minFilter, GLenum magFilter )
+{
+    (void) magFilter;
+
+    switch (minFilter) {
+    case GL_NEAREST:
+       imesa->regs.s4.texCtrl[ unit ].ni.filterMode   = TFM_Point;
+       imesa->regs.s4.texCtrl[ unit ].ni.mipmapEnable = GL_FALSE;
+       break;
+
+    case GL_LINEAR:
+       imesa->regs.s4.texCtrl[ unit ].ni.filterMode   = TFM_Bilin;
+       imesa->regs.s4.texCtrl[ unit ].ni.mipmapEnable = GL_FALSE;
+       break;
+
+    case GL_NEAREST_MIPMAP_NEAREST:
+       imesa->regs.s4.texCtrl[ unit ].ni.filterMode   = TFM_Point;
+       imesa->regs.s4.texCtrl[ unit ].ni.mipmapEnable = GL_TRUE;
+       break;
+
+    case GL_LINEAR_MIPMAP_NEAREST:
+       imesa->regs.s4.texCtrl[ unit ].ni.filterMode   = TFM_Bilin;
+       imesa->regs.s4.texCtrl[ unit ].ni.mipmapEnable = GL_TRUE;
+       break;
+
+    case GL_NEAREST_MIPMAP_LINEAR:
+    case GL_LINEAR_MIPMAP_LINEAR:
+       imesa->regs.s4.texCtrl[ unit ].ni.filterMode   = TFM_Trilin;
+       imesa->regs.s4.texCtrl[ unit ].ni.mipmapEnable = GL_TRUE;
+       break;
+    }
+}
 
 
 static void savageUpdateTex0State_s4( GLcontext *ctx )
@@ -1301,39 +1373,8 @@ static void savageUpdateTex0State_s4( GLcontext *ctx )
       break;                   
    }
 
-    imesa->regs.s4.texCtrl[0].ni.uMode =
-       t->setup.sWrapMode == GL_REPEAT ? 0 : 1;
-    imesa->regs.s4.texCtrl[0].ni.vMode = 
-       t->setup.tWrapMode == GL_REPEAT ? 0 : 1;
-
-    switch (t->setup.minFilter)
-    {
-        case GL_NEAREST:
-            imesa->regs.s4.texCtrl[0].ni.filterMode   = TFM_Point;
-            imesa->regs.s4.texCtrl[0].ni.mipmapEnable = GL_FALSE;
-            break;
-
-        case GL_LINEAR:
-            imesa->regs.s4.texCtrl[0].ni.filterMode   = TFM_Bilin;
-            imesa->regs.s4.texCtrl[0].ni.mipmapEnable = GL_FALSE;
-            break;
-
-        case GL_NEAREST_MIPMAP_NEAREST:
-            imesa->regs.s4.texCtrl[0].ni.filterMode   = TFM_Point;
-            imesa->regs.s4.texCtrl[0].ni.mipmapEnable = GL_TRUE;
-            break;
-
-        case GL_LINEAR_MIPMAP_NEAREST:
-            imesa->regs.s4.texCtrl[0].ni.filterMode   = TFM_Bilin;
-            imesa->regs.s4.texCtrl[0].ni.mipmapEnable = GL_TRUE;
-            break;
-
-        case GL_NEAREST_MIPMAP_LINEAR:
-        case GL_LINEAR_MIPMAP_LINEAR:
-            imesa->regs.s4.texCtrl[0].ni.filterMode   = TFM_Trilin;
-            imesa->regs.s4.texCtrl[0].ni.mipmapEnable = GL_TRUE;
-            break;
-    }
+    savage4_set_wrap_mode( imesa, 0, t->setup.sWrapMode, t->setup.tWrapMode );
+    savage4_set_filter_mode( imesa, 0, t->setup.minFilter, t->setup.magFilter );
 
     if((ctx->Texture.Unit[0].LodBias !=0.0F) ||
        (imesa->regs.s4.texCtrl[0].ni.dBias != 0))
@@ -1514,45 +1555,14 @@ static void savageUpdateTex1State_s4( GLcontext *ctx )
       break;
 
    default:
-      fprintf(stderr, "unkown tex 1 env mode\n");
+      fprintf(stderr, "unknown tex 1 env mode\n");
       exit(1);
       break;                   
    }
 
-    imesa->regs.s4.texCtrl[1].ni.uMode =
-       t->setup.sWrapMode == GL_REPEAT ? 0 : 1;
-    imesa->regs.s4.texCtrl[1].ni.vMode =
-       t->setup.tWrapMode == GL_REPEAT ? 0 : 1;
+    savage4_set_wrap_mode( imesa, 1, t->setup.sWrapMode, t->setup.tWrapMode );
+    savage4_set_filter_mode( imesa, 1, t->setup.minFilter, t->setup.magFilter );
 
-    switch (t->setup.minFilter)
-    {
-        case GL_NEAREST:
-            imesa->regs.s4.texCtrl[1].ni.filterMode   = TFM_Point;
-            imesa->regs.s4.texCtrl[1].ni.mipmapEnable = GL_FALSE;
-            break;
-
-        case GL_LINEAR:
-            imesa->regs.s4.texCtrl[1].ni.filterMode   = TFM_Bilin;
-            imesa->regs.s4.texCtrl[1].ni.mipmapEnable = GL_FALSE;
-            break;
-
-        case GL_NEAREST_MIPMAP_NEAREST:
-            imesa->regs.s4.texCtrl[1].ni.filterMode   = TFM_Point;
-            imesa->regs.s4.texCtrl[1].ni.mipmapEnable = GL_TRUE;
-            break;
-
-        case GL_LINEAR_MIPMAP_NEAREST:
-            imesa->regs.s4.texCtrl[1].ni.filterMode   = TFM_Bilin;
-            imesa->regs.s4.texCtrl[1].ni.mipmapEnable = GL_TRUE;
-            break;
-
-        case GL_NEAREST_MIPMAP_LINEAR:
-        case GL_LINEAR_MIPMAP_LINEAR:
-            imesa->regs.s4.texCtrl[1].ni.filterMode   = TFM_Trilin;
-            imesa->regs.s4.texCtrl[1].ni.mipmapEnable = GL_TRUE;
-            break;
-    }
-    
     if((ctx->Texture.Unit[1].LodBias !=0.0F) ||
        (imesa->regs.s4.texCtrl[1].ni.dBias != 0))
     {
@@ -1650,7 +1660,7 @@ static void savageUpdateTexState_s3d( GLcontext *ctx )
        imesa->regs.s3d.drawCtrl.ni.texBlendCtrl = SAVAGETBC_MODULATEALPHA_S3D;
        break;
     default:
-       fprintf(stderr, "unkown tex env mode\n");
+       fprintf(stderr, "unknown tex env mode\n");
        /*exit(1);*/
        break;                  
     }