[Mesa-dev] [PATCH 5/6] unichrome: Move to using the core ChooseTexFormat.

Eric Anholt eric at anholt.net
Fri Sep 24 17:08:51 PDT 2010


---
 src/mesa/drivers/dri/unichrome/via_context.c |   26 +++++
 src/mesa/drivers/dri/unichrome/via_tex.c     |  156 +-------------------------
 2 files changed, 28 insertions(+), 154 deletions(-)

diff --git a/src/mesa/drivers/dri/unichrome/via_context.c b/src/mesa/drivers/dri/unichrome/via_context.c
index 4298c94..fe8f670 100644
--- a/src/mesa/drivers/dri/unichrome/via_context.c
+++ b/src/mesa/drivers/dri/unichrome/via_context.c
@@ -583,6 +583,32 @@ viaCreateContext(gl_api api,
     ctx->DriverCtx = (void *)vmesa;
     vmesa->glCtx = ctx;
 
+    memset(&ctx->texture_format_supported, 0,
+	   sizeof(ctx->texture_format_supported));
+    ctx->texture_format_supported[MESA_FORMAT_ARGB8888] = GL_TRUE;
+    ctx->texture_format_supported[MESA_FORMAT_ARGB4444] = GL_TRUE;
+    ctx->texture_format_supported[MESA_FORMAT_ARGB1555] = GL_TRUE;
+    ctx->texture_format_supported[MESA_FORMAT_RGB565] = GL_TRUE;
+    ctx->texture_format_supported[MESA_FORMAT_CI8] = GL_TRUE;
+    ctx->texture_format_supported[MESA_FORMAT_L8] = GL_TRUE;
+    ctx->texture_format_supported[MESA_FORMAT_A8] = GL_TRUE;
+    ctx->texture_format_supported[MESA_FORMAT_I8] = GL_TRUE;
+    ctx->texture_format_supported[MESA_FORMAT_AL88] = GL_TRUE;
+
+    /* ctx->Extensions.MESA_ycbcr_texture */
+    ctx->texture_format_supported[MESA_FORMAT_YCBCR] = GL_TRUE;
+    ctx->texture_format_supported[MESA_FORMAT_YCBCR_REV] = GL_TRUE;
+
+    /* GL_3DFX_texture_compression_FXT1 */
+    ctx->texture_format_supported[MESA_FORMAT_RGB_FXT1] = GL_TRUE;
+    ctx->texture_format_supported[MESA_FORMAT_RGBA_FXT1] = GL_TRUE;
+
+    /* GL_EXT_texture_compression_s3tc */
+    ctx->texture_format_supported[MESA_FORMAT_RGB_DXT1] = GL_TRUE;
+    ctx->texture_format_supported[MESA_FORMAT_RGBA_DXT1] = GL_TRUE;
+    ctx->texture_format_supported[MESA_FORMAT_RGBA_DXT3] = GL_TRUE;
+    ctx->texture_format_supported[MESA_FORMAT_RGBA_DXT5] = GL_TRUE;
+
     /* Initialize the software rasterizer and helper modules.
      */
     _swrast_CreateContext(ctx);
diff --git a/src/mesa/drivers/dri/unichrome/via_tex.c b/src/mesa/drivers/dri/unichrome/via_tex.c
index 9ae9466..877c8b9 100644
--- a/src/mesa/drivers/dri/unichrome/via_tex.c
+++ b/src/mesa/drivers/dri/unichrome/via_tex.c
@@ -45,157 +45,6 @@
 #include "via_ioctl.h"
 #include "via_3d_reg.h"
 
-static gl_format
-viaChooseTexFormat( GLcontext *ctx, GLint internalFormat,
-		    GLenum format, GLenum type )
-{
-   struct via_context *vmesa = VIA_CONTEXT(ctx);
-   const GLboolean do32bpt = ( vmesa->viaScreen->bitsPerPixel == 32
-/* 			       && vmesa->viaScreen->textureSize > 4*1024*1024 */
-      );
-
-
-   switch ( internalFormat ) {
-   case 4:
-   case GL_RGBA:
-   case GL_COMPRESSED_RGBA:
-      if ( format == GL_BGRA ) {
-	 if ( type == GL_UNSIGNED_INT_8_8_8_8_REV ||
-	      type == GL_UNSIGNED_BYTE ) {
-	    return MESA_FORMAT_ARGB8888;
-	 }
-         else if ( type == GL_UNSIGNED_SHORT_4_4_4_4_REV ) {
-            return MESA_FORMAT_ARGB4444;
-	 }
-         else if ( type == GL_UNSIGNED_SHORT_1_5_5_5_REV ) {
-	    return MESA_FORMAT_ARGB1555;
-	 }
-      }
-      else if ( type == GL_UNSIGNED_BYTE ||
-		type == GL_UNSIGNED_INT_8_8_8_8_REV ||
-		type == GL_UNSIGNED_INT_8_8_8_8 ) {
-	 return MESA_FORMAT_ARGB8888;
-      }
-      return do32bpt ? MESA_FORMAT_ARGB8888 : MESA_FORMAT_ARGB4444;
-
-   case 3:
-   case GL_RGB:
-   case GL_COMPRESSED_RGB:
-      if ( format == GL_RGB && type == GL_UNSIGNED_SHORT_5_6_5 ) {
-	 return MESA_FORMAT_RGB565;
-      }
-      else if ( type == GL_UNSIGNED_BYTE ) {
-	 return MESA_FORMAT_ARGB8888;
-      }
-      return do32bpt ? MESA_FORMAT_ARGB8888 : MESA_FORMAT_RGB565;
-
-   case GL_RGBA8:
-   case GL_RGB10_A2:
-   case GL_RGBA12:
-   case GL_RGBA16:
-      return MESA_FORMAT_ARGB8888;
-
-   case GL_RGBA4:
-   case GL_RGBA2:
-      return MESA_FORMAT_ARGB4444;
-
-   case GL_RGB5_A1:
-      return MESA_FORMAT_ARGB1555;
-
-   case GL_RGB8:
-   case GL_RGB10:
-   case GL_RGB12:
-   case GL_RGB16:
-      return MESA_FORMAT_ARGB8888;
-
-   case GL_RGB5:
-   case GL_RGB4:
-   case GL_R3_G3_B2:
-      return MESA_FORMAT_RGB565;
-
-   case GL_ALPHA:
-   case GL_ALPHA4:
-   case GL_ALPHA8:
-   case GL_ALPHA12:
-   case GL_ALPHA16:
-   case GL_COMPRESSED_ALPHA:
-      return MESA_FORMAT_A8;
-
-   case 1:
-   case GL_LUMINANCE:
-   case GL_LUMINANCE4:
-   case GL_LUMINANCE8:
-   case GL_LUMINANCE12:
-   case GL_LUMINANCE16:
-   case GL_COMPRESSED_LUMINANCE:
-      return MESA_FORMAT_L8;
-
-   case 2:
-   case GL_LUMINANCE_ALPHA:
-   case GL_LUMINANCE4_ALPHA4:
-   case GL_LUMINANCE6_ALPHA2:
-   case GL_LUMINANCE8_ALPHA8:
-   case GL_LUMINANCE12_ALPHA4:
-   case GL_LUMINANCE12_ALPHA12:
-   case GL_LUMINANCE16_ALPHA16:
-   case GL_COMPRESSED_LUMINANCE_ALPHA:
-      return MESA_FORMAT_AL88;
-
-   case GL_INTENSITY:
-   case GL_INTENSITY4:
-   case GL_INTENSITY8:
-   case GL_INTENSITY12:
-   case GL_INTENSITY16:
-   case GL_COMPRESSED_INTENSITY:
-      return MESA_FORMAT_I8;
-
-   case GL_YCBCR_MESA:
-      if (type == GL_UNSIGNED_SHORT_8_8_MESA ||
-	  type == GL_UNSIGNED_BYTE)
-         return MESA_FORMAT_YCBCR;
-      else
-         return MESA_FORMAT_YCBCR_REV;
-
-   case GL_COMPRESSED_RGB_FXT1_3DFX:
-      return MESA_FORMAT_RGB_FXT1;
-   case GL_COMPRESSED_RGBA_FXT1_3DFX:
-      return MESA_FORMAT_RGBA_FXT1;
-
-   case GL_RGB_S3TC:
-   case GL_RGB4_S3TC:
-   case GL_COMPRESSED_RGB_S3TC_DXT1_EXT:
-      return MESA_FORMAT_RGB_DXT1;
-
-   case GL_COMPRESSED_RGBA_S3TC_DXT1_EXT:
-      return MESA_FORMAT_RGBA_DXT1;
-
-   case GL_RGBA_S3TC:
-   case GL_RGBA4_S3TC:
-   case GL_COMPRESSED_RGBA_S3TC_DXT3_EXT:
-      return MESA_FORMAT_RGBA_DXT3;
-
-   case GL_COMPRESSED_RGBA_S3TC_DXT5_EXT:
-      return MESA_FORMAT_RGBA_DXT5;
-
-   case GL_COLOR_INDEX:	
-   case GL_COLOR_INDEX1_EXT:	
-   case GL_COLOR_INDEX2_EXT:	
-   case GL_COLOR_INDEX4_EXT:	
-   case GL_COLOR_INDEX8_EXT:	
-   case GL_COLOR_INDEX12_EXT:	    
-   case GL_COLOR_INDEX16_EXT:
-      return MESA_FORMAT_CI8;
-
-   default:
-      fprintf(stderr, "unexpected texture format %s in %s\n", 
-	      _mesa_lookup_enum_by_nr(internalFormat),
-	      __FUNCTION__);
-      return MESA_FORMAT_NONE;
-   }
-
-   return MESA_FORMAT_NONE; /* never get here */
-}
-
 static int logbase2(int n)
 {
    GLint i = 1;
@@ -676,8 +525,8 @@ static void viaTexImage(GLcontext *ctx,
    }
 
    /* choose the texture format */
-   texImage->TexFormat = viaChooseTexFormat(ctx, internalFormat, 
-					    format, type);
+   texImage->TexFormat = ctx->Driver.ChooseTextureFormat(ctx, internalFormat,
+							 format, type);
 
    assert(texImage->TexFormat);
 
@@ -926,7 +775,6 @@ static void viaFreeTextureImageData( GLcontext *ctx,
 
 void viaInitTextureFuncs(struct dd_function_table * functions)
 {
-   functions->ChooseTextureFormat = viaChooseTexFormat;
    functions->TexImage1D = viaTexImage1D;
    functions->TexImage2D = viaTexImage2D;
    functions->TexSubImage1D = viaTexSubImage1D;
-- 
1.7.1



More information about the mesa-dev mailing list