[Mesa-dev] [PATCH 4/4] st/mesa: add LATC and 3DC support

Marek Olšák maraeo at gmail.com
Sun Mar 6 19:28:09 PST 2011


softpipe passes all tests.
---
 src/mesa/state_tracker/st_extensions.c |   21 ++++++++++++
 src/mesa/state_tracker/st_format.c     |   54 ++++++++++++++++++++++++++++++-
 src/mesa/state_tracker/st_gen_mipmap.c |    4 ++-
 3 files changed, 76 insertions(+), 3 deletions(-)

diff --git a/src/mesa/state_tracker/st_extensions.c b/src/mesa/state_tracker/st_extensions.c
index 6bbf68a..d96985a 100644
--- a/src/mesa/state_tracker/st_extensions.c
+++ b/src/mesa/state_tracker/st_extensions.c
@@ -432,6 +432,27 @@ void st_init_extensions(struct st_context *st)
      ctx->Extensions.ARB_texture_compression_rgtc = GL_TRUE;
    }
 
+   if (screen->is_format_supported(screen, PIPE_FORMAT_LATC1_UNORM,
+                                   PIPE_TEXTURE_2D, 0,
+                                   PIPE_BIND_SAMPLER_VIEW, 0) &&
+       screen->is_format_supported(screen, PIPE_FORMAT_LATC1_SNORM,
+                                   PIPE_TEXTURE_2D, 0,
+                                   PIPE_BIND_SAMPLER_VIEW, 0) &&
+       screen->is_format_supported(screen, PIPE_FORMAT_LATC2_UNORM,
+                                   PIPE_TEXTURE_2D, 0,
+                                   PIPE_BIND_SAMPLER_VIEW, 0) &&
+       screen->is_format_supported(screen, PIPE_FORMAT_LATC2_SNORM,
+                                   PIPE_TEXTURE_2D, 0,
+                                   PIPE_BIND_SAMPLER_VIEW, 0)) {
+      ctx->Extensions.EXT_texture_compression_latc = GL_TRUE;
+   }
+
+   if (screen->is_format_supported(screen, PIPE_FORMAT_LATC2_UNORM,
+                                   PIPE_TEXTURE_2D, 0,
+                                   PIPE_BIND_SAMPLER_VIEW, 0)) {
+      ctx->Extensions.ATI_texture_compression_3dc = GL_TRUE;
+   }
+
    /* ycbcr support */
    if (screen->is_format_supported(screen, PIPE_FORMAT_UYVY, 
                                    PIPE_TEXTURE_2D, 0,
diff --git a/src/mesa/state_tracker/st_format.c b/src/mesa/state_tracker/st_format.c
index 22a1450..6b89bae 100644
--- a/src/mesa/state_tracker/st_format.c
+++ b/src/mesa/state_tracker/st_format.c
@@ -249,6 +249,16 @@ st_mesa_format_to_pipe_format(gl_format mesaFormat)
       return PIPE_FORMAT_RGTC2_UNORM;
    case MESA_FORMAT_SIGNED_RG_RGTC2:
       return PIPE_FORMAT_RGTC2_SNORM;
+
+   case MESA_FORMAT_L_LATC1:
+      return PIPE_FORMAT_LATC1_UNORM;
+   case MESA_FORMAT_SIGNED_L_LATC1:
+      return PIPE_FORMAT_LATC1_SNORM;
+   case MESA_FORMAT_LA_LATC2:
+      return PIPE_FORMAT_LATC2_UNORM;
+   case MESA_FORMAT_SIGNED_LA_LATC2:
+      return PIPE_FORMAT_LATC2_SNORM;
+
    default:
       assert(0);
       return PIPE_FORMAT_NONE;
@@ -397,6 +407,15 @@ st_pipe_format_to_mesa_format(enum pipe_format format)
    case PIPE_FORMAT_RGTC2_SNORM:
       return MESA_FORMAT_SIGNED_RG_RGTC2;
 
+   case PIPE_FORMAT_LATC1_UNORM:
+      return MESA_FORMAT_L_LATC1;
+   case PIPE_FORMAT_LATC1_SNORM:
+      return MESA_FORMAT_SIGNED_L_LATC1;
+   case PIPE_FORMAT_LATC2_UNORM:
+      return MESA_FORMAT_LA_LATC2;
+   case PIPE_FORMAT_LATC2_SNORM:
+      return MESA_FORMAT_SIGNED_LA_LATC2;
+
    default:
       assert(0);
       return MESA_FORMAT_NONE;
@@ -612,7 +631,6 @@ st_choose_format(struct pipe_screen *screen, GLenum internalFormat,
    case GL_LUMINANCE:
    case GL_LUMINANCE4:
    case GL_LUMINANCE8:
-   case GL_COMPRESSED_LUMINANCE:
       if (screen->is_format_supported( screen, PIPE_FORMAT_L8_UNORM, target,
                                        sample_count, bindings, geom_flags ))
          return PIPE_FORMAT_L8_UNORM;
@@ -630,7 +648,6 @@ st_choose_format(struct pipe_screen *screen, GLenum internalFormat,
    case GL_LUMINANCE_ALPHA:
    case GL_LUMINANCE6_ALPHA2:
    case GL_LUMINANCE8_ALPHA8:
-   case GL_COMPRESSED_LUMINANCE_ALPHA:
       if (screen->is_format_supported( screen, PIPE_FORMAT_L8A8_UNORM, target,
                                        sample_count, bindings, geom_flags ))
          return PIPE_FORMAT_L8A8_UNORM;
@@ -901,6 +918,39 @@ st_choose_format(struct pipe_screen *screen, GLenum internalFormat,
 	      return PIPE_FORMAT_RGTC2_SNORM;
       return PIPE_FORMAT_NONE;
 
+   case GL_COMPRESSED_LUMINANCE:
+   case GL_COMPRESSED_LUMINANCE_LATC1_EXT:
+      if (screen->is_format_supported(screen, PIPE_FORMAT_LATC1_UNORM, target,
+                                      sample_count, bindings, geom_flags))
+              return PIPE_FORMAT_LATC1_UNORM;
+      if (screen->is_format_supported(screen, PIPE_FORMAT_L8_UNORM, target,
+                                      sample_count, bindings, geom_flags))
+              return PIPE_FORMAT_L8_UNORM;
+      return PIPE_FORMAT_NONE;
+
+   case GL_COMPRESSED_SIGNED_LUMINANCE_LATC1_EXT:
+      if (screen->is_format_supported(screen, PIPE_FORMAT_LATC1_SNORM, target,
+                                      sample_count, bindings, geom_flags))
+              return PIPE_FORMAT_LATC1_SNORM;
+      return PIPE_FORMAT_NONE;
+
+   case GL_COMPRESSED_LUMINANCE_ALPHA:
+   case GL_COMPRESSED_LUMINANCE_ALPHA_LATC2_EXT:
+   case GL_COMPRESSED_LUMINANCE_ALPHA_3DC_ATI:
+      if (screen->is_format_supported(screen, PIPE_FORMAT_LATC2_UNORM, target,
+                                      sample_count, bindings, geom_flags))
+              return PIPE_FORMAT_LATC2_UNORM;
+      if (screen->is_format_supported(screen, PIPE_FORMAT_L8A8_UNORM, target,
+                                      sample_count, bindings, geom_flags))
+              return PIPE_FORMAT_L8A8_UNORM;
+      return PIPE_FORMAT_NONE;
+
+   case GL_COMPRESSED_SIGNED_LUMINANCE_ALPHA_LATC2_EXT:
+      if (screen->is_format_supported(screen, PIPE_FORMAT_LATC2_SNORM, target,
+                                      sample_count, bindings, geom_flags))
+              return PIPE_FORMAT_LATC2_SNORM;
+      return PIPE_FORMAT_NONE;
+
    /* signed/unsigned integer formats.
     * XXX Mesa only has formats for RGBA signed/unsigned integer formats.
     * If/when new formats are added this code should be updated.
diff --git a/src/mesa/state_tracker/st_gen_mipmap.c b/src/mesa/state_tracker/st_gen_mipmap.c
index a12a32e..f8b23d1 100644
--- a/src/mesa/state_tracker/st_gen_mipmap.c
+++ b/src/mesa/state_tracker/st_gen_mipmap.c
@@ -205,7 +205,9 @@ fallback_generate_mipmap(struct gl_context *ctx, GLenum target,
 
    if (compressed) {
       if (texObj->Image[face][baseLevel]->TexFormat == MESA_FORMAT_SIGNED_RED_RGTC1 ||
-	  texObj->Image[face][baseLevel]->TexFormat == MESA_FORMAT_SIGNED_RG_RGTC2)
+          texObj->Image[face][baseLevel]->TexFormat == MESA_FORMAT_SIGNED_RG_RGTC2 ||
+          texObj->Image[face][baseLevel]->TexFormat == MESA_FORMAT_SIGNED_L_LATC1 ||
+          texObj->Image[face][baseLevel]->TexFormat == MESA_FORMAT_SIGNED_LA_LATC2)
          datatype = GL_FLOAT;
       else
          datatype = GL_UNSIGNED_BYTE;
-- 
1.7.1



More information about the mesa-dev mailing list