mesa/st: add RGTC format support.
authorDave Airlie <airlied@redhat.com>
Thu, 24 Feb 2011 23:24:15 +0000 (09:24 +1000)
committerDave Airlie <airlied@redhat.com>
Mon, 28 Feb 2011 03:35:35 +0000 (13:35 +1000)
this just adds a format check + format conversion.

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

index 2f45f470334ee5574fcc3af6c9f5e8b269d3ef72..d2098987d1d738c12cd004a66d07a5bdce825cf4 100644 (file)
@@ -416,6 +416,22 @@ void st_init_extensions(struct st_context *st)
       ctx->Extensions.S3_s3tc = GL_TRUE;
    }
 
+   if (screen->is_format_supported(screen, PIPE_FORMAT_RGTC1_UNORM,
+                                   PIPE_TEXTURE_2D, 0,
+                                   PIPE_BIND_SAMPLER_VIEW, 0) &&
+       screen->is_format_supported(screen, PIPE_FORMAT_RGTC1_SNORM,
+                                  PIPE_TEXTURE_2D, 0,
+                                   PIPE_BIND_SAMPLER_VIEW, 0) &&
+       screen->is_format_supported(screen, PIPE_FORMAT_RGTC2_UNORM,
+                                   PIPE_TEXTURE_2D, 0,
+                                   PIPE_BIND_SAMPLER_VIEW, 0) &&
+       screen->is_format_supported(screen, PIPE_FORMAT_RGTC2_SNORM,
+                                   PIPE_TEXTURE_2D, 0,
+                                   PIPE_BIND_SAMPLER_VIEW, 0)
+       ) {
+     ctx->Extensions.ARB_texture_compression_rgtc = GL_TRUE;
+   }
+
    /* ycbcr support */
    if (screen->is_format_supported(screen, PIPE_FORMAT_UYVY, 
                                    PIPE_TEXTURE_2D, 0,
index 577ee6189bdc819e1bf5083f61bdea71a834f1ff..c58ec9267dcffa93bf5c625dd325b7092287805d 100644 (file)
@@ -241,6 +241,14 @@ st_mesa_format_to_pipe_format(gl_format mesaFormat)
    case MESA_FORMAT_RGBA_UINT32:
       return PIPE_FORMAT_R32G32B32A32_USCALED;
 
+   case MESA_FORMAT_RED_RGTC1:
+      return PIPE_FORMAT_RGTC1_UNORM;
+   case MESA_FORMAT_SIGNED_RED_RGTC1:
+      return PIPE_FORMAT_RGTC1_SNORM;
+   case MESA_FORMAT_RG_RGTC2:
+      return PIPE_FORMAT_RGTC2_UNORM;
+   case MESA_FORMAT_SIGNED_RG_RGTC2:
+      return PIPE_FORMAT_RGTC2_SNORM;
    default:
       assert(0);
       return PIPE_FORMAT_NONE;
@@ -380,6 +388,15 @@ st_pipe_format_to_mesa_format(enum pipe_format format)
    case PIPE_FORMAT_R32G32B32A32_USCALED:
       return MESA_FORMAT_RGBA_UINT32;
 
+   case PIPE_FORMAT_RGTC1_UNORM:
+      return MESA_FORMAT_RED_RGTC1;
+   case PIPE_FORMAT_RGTC1_SNORM:
+      return MESA_FORMAT_SIGNED_RED_RGTC1;
+   case PIPE_FORMAT_RGTC2_UNORM:
+      return MESA_FORMAT_RG_RGTC2;
+   case PIPE_FORMAT_RGTC2_SNORM:
+      return MESA_FORMAT_SIGNED_RG_RGTC2;
+
    default:
       assert(0);
       return MESA_FORMAT_NONE;