Mesa (master): st/mesa: re-do binding flags in st_ChooseTextureFormat(), again

Brian Paul brianp at kemper.freedesktop.org
Fri Apr 23 19:18:09 UTC 2010


Module: Mesa
Branch: master
Commit: 4aa4fe8e2103ee43e77f404ef790125dd4d690e5
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=4aa4fe8e2103ee43e77f404ef790125dd4d690e5

Author: Brian Paul <brianp at vmware.com>
Date:   Fri Apr 23 13:13:27 2010 -0600

st/mesa: re-do binding flags in st_ChooseTextureFormat(), again

Try to specify render target bindings flags first.  If that fails, try
again with just sampler view binding.  Note that we try to create the
texture resource with render target binding flags later when we allocate
the texture.  Then, in FBO validation, we check if we can actually render
to the textures.  If that fails, we generate GL_FRAMEBUFFER_UNSUPPORTED_EXT.

Changes suggested by Jose.

---

 src/mesa/state_tracker/st_format.c |   29 +++++++++++++++++------------
 1 files changed, 17 insertions(+), 12 deletions(-)

diff --git a/src/mesa/state_tracker/st_format.c b/src/mesa/state_tracker/st_format.c
index 2e40659..fa6dd2d 100644
--- a/src/mesa/state_tracker/st_format.c
+++ b/src/mesa/state_tracker/st_format.c
@@ -651,28 +651,33 @@ st_ChooseTextureFormat(GLcontext *ctx, GLint internalFormat,
                        GLenum format, GLenum type)
 {
    enum pipe_format pFormat;
-   uint usage = PIPE_BIND_SAMPLER_VIEW;
+   uint bindings;
 
    (void) format;
    (void) type;
 
    /* GL textures may wind up being render targets, but we don't know
     * that in advance.  Specify potential render target flags now.
-    * An alternative would be to destroy and re-create a texture when
-    * we first start rendering to it.
     */
-   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;
-   }
+   if (_mesa_is_depth_format(internalFormat) ||
+       _mesa_is_depthstencil_format(internalFormat))
+      bindings = PIPE_BIND_SAMPLER_VIEW | PIPE_BIND_DEPTH_STENCIL;
+   else 
+      bindings = PIPE_BIND_SAMPLER_VIEW | PIPE_BIND_RENDER_TARGET;
 
    pFormat = st_choose_format(ctx->st->pipe->screen, internalFormat,
-                              PIPE_TEXTURE_2D, usage);
-   if (pFormat == PIPE_FORMAT_NONE)
+                              PIPE_TEXTURE_2D, bindings);
+
+   if (pFormat == PIPE_FORMAT_NONE) {
+      /* try choosing format again, this time without render target bindings */
+      pFormat = st_choose_format(ctx->st->pipe->screen, internalFormat,
+                                 PIPE_TEXTURE_2D, PIPE_BIND_SAMPLER_VIEW);
+   }
+
+   if (pFormat == PIPE_FORMAT_NONE) {
+      /* no luck at all */
       return MESA_FORMAT_NONE;
+   }
 
    return st_pipe_format_to_mesa_format(pFormat);
 }




More information about the mesa-commit mailing list