st/mesa: don't set RENDER_TARGET/DEPTH_STENCIL flag for compressed textures
[mesa.git] / src / mesa / state_tracker / st_format.c
index 3e767507eefb953fb9062a53aad8be264ddd7305..2e40659b19ea103d496e014e522c594613a2acae 100644 (file)
@@ -386,25 +386,6 @@ default_srgba_format(struct pipe_screen *screen,
 }
 
 
-/**
- * Search list of formats for first RGBA format with >8 bits/channel.
- */
-static enum pipe_format
-default_deep_rgba_format(struct pipe_screen *screen, 
-                         enum pipe_texture_target target,
-                         unsigned tex_usage, 
-                         unsigned geom_flags)
-{
-   if (screen->is_format_supported(screen, PIPE_FORMAT_R16G16B16A16_SNORM, target, tex_usage, geom_flags)) {
-      return PIPE_FORMAT_R16G16B16A16_SNORM;
-   }
-   if (tex_usage & PIPE_BIND_RENDER_TARGET)
-      return default_rgba_format(screen, target, tex_usage, geom_flags);
-   else
-      return PIPE_FORMAT_NONE;
-}
-
-
 /**
  * Given an OpenGL internalFormat value for a texture or surface, return
  * the best matching PIPE_FORMAT_x, or PIPE_FORMAT_NONE if there's no match.
@@ -431,10 +412,7 @@ st_choose_format(struct pipe_screen *screen, GLenum internalFormat,
    case GL_COMPRESSED_RGB:
       return default_rgb_format( screen, target, tex_usage, geom_flags );
    case GL_RGBA16:
-      if (tex_usage & PIPE_BIND_RENDER_TARGET)
-         return default_deep_rgba_format( screen, target, tex_usage, geom_flags );
-      else
-         return default_rgba_format( screen, target, tex_usage, geom_flags );
+      return default_rgba_format( screen, target, tex_usage, geom_flags );
 
    case GL_RGBA4:
    case GL_RGBA2:
@@ -683,11 +661,13 @@ st_ChooseTextureFormat(GLcontext *ctx, GLint internalFormat,
     * An alternative would be to destroy and re-create a texture when
     * we first start rendering to it.
     */
-   if (_mesa_is_depth_format(internalFormat) ||
-       _mesa_is_depthstencil_format(internalFormat))
-      usage |= PIPE_BIND_DEPTH_STENCIL;
-   else 
-      usage |= PIPE_BIND_RENDER_TARGET;
+   if (!_mesa_is_compressed_format(ctx, internalFormat)) {
+      if (_mesa_is_depth_format(internalFormat) ||
+          _mesa_is_depthstencil_format(internalFormat))
+         usage |= PIPE_BIND_DEPTH_STENCIL;
+      else 
+         usage |= PIPE_BIND_RENDER_TARGET;
+   }
 
    pFormat = st_choose_format(ctx->st->pipe->screen, internalFormat,
                               PIPE_TEXTURE_2D, usage);