[Mesa-dev] [PATCH 4/6] r128: Merge texformat fallbacks into core.

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


This drops the texture format forcing like for mga.
---
 src/mesa/drivers/dri/r128/r128_context.c |   17 +++--
 src/mesa/drivers/dri/r128/r128_context.h |    2 -
 src/mesa/drivers/dri/r128/r128_screen.c  |    7 +-
 src/mesa/drivers/dri/r128/r128_tex.c     |  118 ------------------------------
 src/mesa/main/texformat.c                |    6 ++
 5 files changed, 19 insertions(+), 131 deletions(-)

diff --git a/src/mesa/drivers/dri/r128/r128_context.c b/src/mesa/drivers/dri/r128/r128_context.c
index 7860708..b5a6eff 100644
--- a/src/mesa/drivers/dri/r128/r128_context.c
+++ b/src/mesa/drivers/dri/r128/r128_context.c
@@ -175,12 +175,6 @@ GLboolean r128CreateContext( gl_api api,
       driSetTextureSwapCounterLocation( rmesa->texture_heaps[i],
 					& rmesa->c_textureSwaps );
    }
-   rmesa->texture_depth = driQueryOptioni (&rmesa->optionCache,
-					   "texture_depth");
-   if (rmesa->texture_depth == DRI_CONF_TEXTURE_DEPTH_FB)
-      rmesa->texture_depth = ( r128scrn->cpp == 4 ) ?
-	 DRI_CONF_TEXTURE_DEPTH_32 : DRI_CONF_TEXTURE_DEPTH_16;
-
 
    rmesa->RenderIndex = -1;		/* Impossible value */
    rmesa->vert_buf = NULL;
@@ -208,6 +202,17 @@ GLboolean r128CreateContext( gl_api api,
 				 GL_FALSE,
 				 0 );
 
+   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_RGB565] = GL_TRUE;
+   ctx->texture_format_supported[MESA_FORMAT_CI8] = 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;
+
    /* No wide points.
     */
    ctx->Const.MinPointSize = 1.0;
diff --git a/src/mesa/drivers/dri/r128/r128_context.h b/src/mesa/drivers/dri/r128/r128_context.h
index 65ddb3b..2742daf 100644
--- a/src/mesa/drivers/dri/r128/r128_context.h
+++ b/src/mesa/drivers/dri/r128/r128_context.h
@@ -157,8 +157,6 @@ struct r128_context {
 
    r128TexObjPtr CurrentTexObj[2];
 
-   int texture_depth;
- 
    /* Fallback rasterization functions 
     */
    r128_point_func draw_point;
diff --git a/src/mesa/drivers/dri/r128/r128_screen.c b/src/mesa/drivers/dri/r128/r128_screen.c
index 7626a15..15b6625 100644
--- a/src/mesa/drivers/dri/r128/r128_screen.c
+++ b/src/mesa/drivers/dri/r128/r128_screen.c
@@ -57,9 +57,6 @@ DRI_CONF_BEGIN
     DRI_CONF_SECTION_PERFORMANCE
         DRI_CONF_VBLANK_MODE(DRI_CONF_VBLANK_DEF_INTERVAL_0)
     DRI_CONF_SECTION_END
-    DRI_CONF_SECTION_QUALITY
-        DRI_CONF_TEXTURE_DEPTH(DRI_CONF_TEXTURE_DEPTH_FB)
-    DRI_CONF_SECTION_END
     DRI_CONF_SECTION_DEBUG
         DRI_CONF_NO_RAST(false)
 #if ENABLE_PERF_BOXES
@@ -68,9 +65,9 @@ DRI_CONF_BEGIN
     DRI_CONF_SECTION_END
 DRI_CONF_END;
 #if ENABLE_PERF_BOXES
-static const GLuint __driNConfigOptions = 4;
-#else
 static const GLuint __driNConfigOptions = 3;
+#else
+static const GLuint __driNConfigOptions = 2;
 #endif
 
 #if 1
diff --git a/src/mesa/drivers/dri/r128/r128_tex.c b/src/mesa/drivers/dri/r128/r128_tex.c
index b5a19b5..ac989aa 100644
--- a/src/mesa/drivers/dri/r128/r128_tex.c
+++ b/src/mesa/drivers/dri/r128/r128_tex.c
@@ -171,123 +171,6 @@ static r128TexObjPtr r128AllocTexObj( struct gl_texture_object *texObj )
    return t;
 }
 
-
-/* Called by the _mesa_store_teximage[123]d() functions. */
-static gl_format
-r128ChooseTextureFormat( GLcontext *ctx, GLint internalFormat,
-                         GLenum format, GLenum type )
-{
-   r128ContextPtr rmesa = R128_CONTEXT(ctx);
-   const GLboolean do32bpt =
-       ( rmesa->texture_depth == DRI_CONF_TEXTURE_DEPTH_32 );
-   const GLboolean force16bpt =
-       ( rmesa->texture_depth == DRI_CONF_TEXTURE_DEPTH_FORCE_16 );
-   (void) format;
-   (void) type;
-
-   switch ( internalFormat ) {
-   /* non-sized formats with alpha */
-   case GL_INTENSITY:
-   case GL_COMPRESSED_INTENSITY:
-   case GL_ALPHA:
-   case GL_COMPRESSED_ALPHA:
-   case 2:
-   case GL_LUMINANCE_ALPHA:
-   case GL_COMPRESSED_LUMINANCE_ALPHA:
-   case 4:
-   case GL_RGBA:
-   case GL_COMPRESSED_RGBA:
-      if (do32bpt)
-         return _dri_texformat_argb8888;
-      else
-         return _dri_texformat_argb4444;
-
-   /* 16-bit formats with alpha */
-   case GL_INTENSITY4:
-   case GL_ALPHA4:
-   case GL_LUMINANCE4_ALPHA4:
-   case GL_RGBA2:
-   case GL_RGBA4:
-      return _dri_texformat_argb4444;
-
-   /* 32-bit formats with alpha */
-   case GL_INTENSITY8:
-   case GL_INTENSITY12:
-   case GL_INTENSITY16:
-   case GL_ALPHA8:
-   case GL_ALPHA12:
-   case GL_ALPHA16:
-   case GL_LUMINANCE6_ALPHA2:
-   case GL_LUMINANCE8_ALPHA8:
-   case GL_LUMINANCE12_ALPHA4:
-   case GL_LUMINANCE12_ALPHA12:
-   case GL_LUMINANCE16_ALPHA16:
-   case GL_RGB5_A1:
-   case GL_RGBA8:
-   case GL_RGB10_A2:
-   case GL_RGBA12:
-   case GL_RGBA16:
-      if (!force16bpt)
-         return _dri_texformat_argb8888;
-      else
-         return _dri_texformat_argb4444;
-
-   /* non-sized formats without alpha */
-   case 1:
-   case GL_LUMINANCE:
-   case GL_COMPRESSED_LUMINANCE:
-   case 3:
-   case GL_RGB:
-   case GL_COMPRESSED_RGB:
-      if (do32bpt)
-         return _dri_texformat_argb8888;
-      else
-         return _dri_texformat_rgb565;
-
-   /* 16-bit formats without alpha */
-   case GL_LUMINANCE4:
-   case GL_R3_G3_B2:
-   case GL_RGB4:
-   case GL_RGB5:
-      return _dri_texformat_rgb565;
-
-   /* 32-bit formats without alpha */
-   case GL_LUMINANCE8:
-   case GL_LUMINANCE12:
-   case GL_LUMINANCE16:
-   case GL_RGB8:
-   case GL_RGB10:
-   case GL_RGB12:
-   case GL_RGB16:
-      if (!force16bpt)
-         return _dri_texformat_argb8888;
-      else
-         return _dri_texformat_rgb565;
-
-   /* color-indexed formats */
-   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 _dri_texformat_ci8;
-
-   case GL_YCBCR_MESA:
-      if (type == GL_UNSIGNED_SHORT_8_8_APPLE ||
-          type == GL_UNSIGNED_BYTE)
-         return MESA_FORMAT_YCBCR;
-      else
-         return MESA_FORMAT_YCBCR_REV;
-
-   default:
-      _mesa_problem( ctx, "unexpected format in %s", __FUNCTION__ );
-      return MESA_FORMAT_NONE;
-   }
-}
-
-
 static void r128TexImage1D( GLcontext *ctx, GLenum target, GLint level,
 			    GLint internalFormat,
 			    GLint width, GLint border,
@@ -600,7 +483,6 @@ r128NewTextureObject( GLcontext *ctx, GLuint name, GLenum target )
 void r128InitTextureFuncs( struct dd_function_table *functions )
 {
    functions->TexEnv			= r128TexEnv;
-   functions->ChooseTextureFormat	= r128ChooseTextureFormat;
    functions->TexImage1D		= r128TexImage1D;
    functions->TexSubImage1D		= r128TexSubImage1D;
    functions->TexImage2D		= r128TexImage2D;
diff --git a/src/mesa/main/texformat.c b/src/mesa/main/texformat.c
index c8ada5b..c32262d 100644
--- a/src/mesa/main/texformat.c
+++ b/src/mesa/main/texformat.c
@@ -119,6 +119,7 @@ _mesa_choose_tex_format( GLcontext *ctx, GLint internalFormat,
 	 break;
       case GL_RGB4:
          RETURN_IF_SUPPORTED(MESA_FORMAT_RGB565_REV); /* just to test another format */
+         RETURN_IF_SUPPORTED(MESA_FORMAT_RGB565);
 	 break;
       case GL_RGB5:
          RETURN_IF_SUPPORTED(MESA_FORMAT_RGB565);
@@ -140,11 +141,13 @@ _mesa_choose_tex_format( GLcontext *ctx, GLint internalFormat,
       case GL_ALPHA8:
          RETURN_IF_SUPPORTED(MESA_FORMAT_A8);
          RETURN_IF_SUPPORTED(MESA_FORMAT_AL88);
+         RETURN_IF_SUPPORTED(MESA_FORMAT_ARGB8888);
 	 break;
       case GL_ALPHA4:
          RETURN_IF_SUPPORTED(MESA_FORMAT_A8);
          RETURN_IF_SUPPORTED(MESA_FORMAT_ARGB4444);
          RETURN_IF_SUPPORTED(MESA_FORMAT_AL88);
+         RETURN_IF_SUPPORTED(MESA_FORMAT_ARGB8888);
 	 break;
 
       /* Luminance formats */
@@ -155,11 +158,14 @@ _mesa_choose_tex_format( GLcontext *ctx, GLint internalFormat,
       case GL_LUMINANCE8:
          RETURN_IF_SUPPORTED(MESA_FORMAT_L8);
          RETURN_IF_SUPPORTED(MESA_FORMAT_AL88);
+         RETURN_IF_SUPPORTED(MESA_FORMAT_ARGB8888);
 	 break;
       case GL_LUMINANCE4:
          RETURN_IF_SUPPORTED(MESA_FORMAT_L8);
          RETURN_IF_SUPPORTED(MESA_FORMAT_ARGB4444);
          RETURN_IF_SUPPORTED(MESA_FORMAT_AL88);
+         RETURN_IF_SUPPORTED(MESA_FORMAT_RGB565);
+         RETURN_IF_SUPPORTED(MESA_FORMAT_ARGB8888);
 	 break;
 
       /* Luminance/Alpha formats */
-- 
1.7.1



More information about the mesa-dev mailing list