st/mesa: call is_format_supported() for compressed formats
authorBrian Paul <brianp@vmware.com>
Tue, 27 Apr 2010 15:18:57 +0000 (09:18 -0600)
committerBrian Paul <brianp@vmware.com>
Tue, 27 Apr 2010 15:19:02 +0000 (09:19 -0600)
These compressed format switch cases shouldn't be hit if we don't
support the compressed texture extensions, but let's be safe and
ask the driver if they're supported as we do in other cases.

src/mesa/state_tracker/st_format.c

index 1e51300bb695dfdddb87fd2d4184faca78163b42..0c3e16631a049acc9a511f9f1407c718b1e55264 100644 (file)
@@ -524,18 +524,34 @@ st_choose_format(struct pipe_screen *screen, GLenum internalFormat,
    case GL_RGB_S3TC:
    case GL_RGB4_S3TC:
    case GL_COMPRESSED_RGB_S3TC_DXT1_EXT:
-      return PIPE_FORMAT_DXT1_RGB;
+      if (screen->is_format_supported(screen, PIPE_FORMAT_DXT1_RGB,
+                                      target, tex_usage, geom_flags))
+         return PIPE_FORMAT_DXT1_RGB;
+      else
+         return PIPE_FORMAT_NONE;
 
    case GL_COMPRESSED_RGBA_S3TC_DXT1_EXT:
-      return PIPE_FORMAT_DXT1_RGBA;
+      if (screen->is_format_supported(screen, PIPE_FORMAT_DXT1_RGBA,
+                                      target, tex_usage, geom_flags))
+         return PIPE_FORMAT_DXT1_RGBA;
+      else
+         return PIPE_FORMAT_NONE;
 
    case GL_RGBA_S3TC:
    case GL_RGBA4_S3TC:
    case GL_COMPRESSED_RGBA_S3TC_DXT3_EXT:
-      return PIPE_FORMAT_DXT3_RGBA;
+      if (screen->is_format_supported(screen, PIPE_FORMAT_DXT3_RGBA,
+                                      target, tex_usage, geom_flags))
+         return PIPE_FORMAT_DXT3_RGBA;
+      else
+         return PIPE_FORMAT_NONE;
 
    case GL_COMPRESSED_RGBA_S3TC_DXT5_EXT:
-      return PIPE_FORMAT_DXT5_RGBA;
+      if (screen->is_format_supported(screen, PIPE_FORMAT_DXT5_RGBA,
+                                      target, tex_usage, geom_flags))
+         return PIPE_FORMAT_DXT5_RGBA;
+      else
+         return PIPE_FORMAT_NONE;
 
 #if 0
    case GL_COMPRESSED_RGB_FXT1_3DFX: