st/mesa: use RGTC for GL_COMPRESSED_RED/RG if possible
authorMarek Olšák <maraeo@gmail.com>
Tue, 1 Mar 2011 20:15:38 +0000 (21:15 +0100)
committerMarek Olšák <maraeo@gmail.com>
Wed, 2 Mar 2011 02:46:27 +0000 (03:46 +0100)
With proper fallback formats.

src/mesa/state_tracker/st_format.c

index c58ec9267dcffa93bf5c625dd325b7092287805d..22a1450cfe7e39f9ca489a099da26e755525c58e 100644 (file)
@@ -674,8 +674,6 @@ st_choose_format(struct pipe_screen *screen, GLenum internalFormat,
       }
       return PIPE_FORMAT_NONE;
 
-   case GL_COMPRESSED_RED:
-   case GL_COMPRESSED_RG:
    case GL_COMPRESSED_RGB:
       /* can only sample from compressed formats */
       if (bindings & ~PIPE_BIND_SAMPLER_VIEW)
@@ -871,10 +869,14 @@ st_choose_format(struct pipe_screen *screen, GLenum internalFormat,
              return PIPE_FORMAT_R16G16_UNORM;
       return PIPE_FORMAT_NONE;
 
+   case GL_COMPRESSED_RED:
    case GL_COMPRESSED_RED_RGTC1:
       if (screen->is_format_supported(screen, PIPE_FORMAT_RGTC1_UNORM, target,
                                      sample_count, bindings, geom_flags))
              return PIPE_FORMAT_RGTC1_UNORM;
+      if (screen->is_format_supported(screen, PIPE_FORMAT_R8_UNORM, target,
+                                     sample_count, bindings, geom_flags))
+             return PIPE_FORMAT_R8_UNORM;
       return PIPE_FORMAT_NONE;
 
    case GL_COMPRESSED_SIGNED_RED_RGTC1:
@@ -883,10 +885,14 @@ st_choose_format(struct pipe_screen *screen, GLenum internalFormat,
              return PIPE_FORMAT_RGTC1_SNORM;
       return PIPE_FORMAT_NONE;
 
+   case GL_COMPRESSED_RG:
    case GL_COMPRESSED_RG_RGTC2:
       if (screen->is_format_supported(screen, PIPE_FORMAT_RGTC2_UNORM, target,
                                      sample_count, bindings, geom_flags))
              return PIPE_FORMAT_RGTC2_UNORM;
+      if (screen->is_format_supported(screen, PIPE_FORMAT_R8G8_UNORM, target,
+                                     sample_count, bindings, geom_flags))
+             return PIPE_FORMAT_R8G8_UNORM;
       return PIPE_FORMAT_NONE;
 
    case GL_COMPRESSED_SIGNED_RG_RGTC2: