[Mesa-dev] [PATCH] st/mesa: set PIPE_BIND_RENDER_TARGET for sRGB formats if UNORM is supported

Marek Olšák maraeo at gmail.com
Thu Mar 3 21:41:32 PST 2011


Because the format can be changed to UNORM in a sampler view.

This fixes:
state_tracker/st_atom_framebuffer.c:163:update_framebuffer_state:
Assertion `framebuffer->cbufs[i]->texture->bind & (1 << 1)' failed.
---
 src/mesa/state_tracker/st_cb_texture.c |   13 +++++++++++--
 1 files changed, 11 insertions(+), 2 deletions(-)

diff --git a/src/mesa/state_tracker/st_cb_texture.c b/src/mesa/state_tracker/st_cb_texture.c
index c3c4246..1e793dc 100644
--- a/src/mesa/state_tracker/st_cb_texture.c
+++ b/src/mesa/state_tracker/st_cb_texture.c
@@ -227,8 +227,17 @@ default_bindings(struct st_context *st, enum pipe_format format)
 
    if (screen->is_format_supported(screen, format, target, 0, bindings, geom))
       return bindings;
-   else
-      return PIPE_BIND_SAMPLER_VIEW;
+   else {
+      /* Try non-sRGB. */
+      const gl_format linearFormat =
+         _mesa_get_srgb_format_linear(st_pipe_format_to_mesa_format(format));
+      format = st_mesa_format_to_pipe_format(linearFormat);
+
+      if (screen->is_format_supported(screen, format, target, 0, bindings, geom))
+         return bindings;
+      else
+         return PIPE_BIND_SAMPLER_VIEW;
+   }
 }
 
 
-- 
1.7.1



More information about the mesa-dev mailing list