st/mesa: add LATC and 3DC support
authorMarek Olšák <maraeo@gmail.com>
Mon, 7 Mar 2011 01:24:43 +0000 (02:24 +0100)
committerMarek Olšák <maraeo@gmail.com>
Tue, 8 Mar 2011 22:52:37 +0000 (23:52 +0100)
softpipe passes all tests.

src/mesa/state_tracker/st_extensions.c
src/mesa/state_tracker/st_format.c
src/mesa/state_tracker/st_gen_mipmap.c

index 6bbf68accdd31c40a463c8faf598e20d8e5c1092..d96985a3747d2db31a7df83264c5a857a4c987d2 100644 (file)
@@ -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,
index 22a1450cfe7e39f9ca489a099da26e755525c58e..6b89bae7d16f0ef5704be498de56b49000fb754b 100644 (file)
@@ -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.
index a12a32e114865197d871e5e06ecbb125d66ccb73..f8b23d11d037c557a1bb7b572feb442620eb0d80 100644 (file)
@@ -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;