st/mesa: add option to choose a texture format that we won't render to.
authorDave Airlie <airlied@redhat.com>
Thu, 7 Oct 2010 04:04:03 +0000 (14:04 +1000)
committerDave Airlie <airlied@redhat.com>
Tue, 12 Oct 2010 23:30:04 +0000 (09:30 +1000)
We need a texture to put the drawpixels stuff into, an S8 texture is less
memory/bandwidth than the 32-bit X24S8, but we might not be able to render
directly to an S8, so this lets us specify we won't be rendering to this
texture.

src/mesa/state_tracker/st_cb_drawpixels.c
src/mesa/state_tracker/st_format.c
src/mesa/state_tracker/st_format.h

index fb1fec1aefd1198ac0f7d1d5a4d52ed20a140d0e..7e5791775ace03b9f861a956fc4adc2804fabd8e 100644 (file)
@@ -330,7 +330,7 @@ make_texture(struct st_context *st,
 
    baseFormat = base_format(format);
 
-   mformat = st_ChooseTextureFormat(ctx, baseFormat, format, type);
+   mformat = st_ChooseTextureFormat_renderable(ctx, baseFormat, format, type, GL_FALSE);
    assert(mformat);
 
    pipeFormat = st_mesa_format_to_pipe_format(mformat);
index b7c54cef841df83c14b44cf037d3f2946b963e01..cc585f9ce2ef3ba5c4d1e21d78614aaaf0cf46fe 100644 (file)
@@ -781,8 +781,8 @@ st_choose_renderbuffer_format(struct pipe_screen *screen,
  * Called via ctx->Driver.chooseTextureFormat().
  */
 gl_format
-st_ChooseTextureFormat(GLcontext *ctx, GLint internalFormat,
-                       GLenum format, GLenum type)
+st_ChooseTextureFormat_renderable(GLcontext *ctx, GLint internalFormat,
+                                 GLenum format, GLenum type, GLboolean renderable)
 {
    struct pipe_screen *screen = st_context(ctx)->pipe->screen;
    enum pipe_format pFormat;
@@ -794,11 +794,14 @@ st_ChooseTextureFormat(GLcontext *ctx, GLint internalFormat,
    /* GL textures may wind up being render targets, but we don't know
     * that in advance.  Specify potential render target flags now.
     */
-   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;
+   bindings = PIPE_BIND_SAMPLER_VIEW;
+   if (renderable == GL_TRUE) {
+      if (_mesa_is_depth_format(internalFormat) ||
+         _mesa_is_depth_or_stencil_format(internalFormat))
+        bindings |= PIPE_BIND_DEPTH_STENCIL;
+      else 
+        bindings |= PIPE_BIND_RENDER_TARGET;
+   }
 
    pFormat = st_choose_format(screen, internalFormat,
                               PIPE_TEXTURE_2D, 0, bindings);
@@ -817,6 +820,13 @@ st_ChooseTextureFormat(GLcontext *ctx, GLint internalFormat,
    return st_pipe_format_to_mesa_format(pFormat);
 }
 
+gl_format
+st_ChooseTextureFormat(GLcontext *ctx, GLint internalFormat,
+                       GLenum format, GLenum type)
+{
+   return st_ChooseTextureFormat_renderable(ctx, internalFormat,
+                                           format, type, GL_TRUE);
+}
 
 /**
  * Test if a gallium format is equivalent to a GL format/type.
index 841c58cadc88b763d84df75f742e24efaac290ee..4e3a9b1d83efcb6490876e2b5a056987461b810c 100644 (file)
@@ -59,6 +59,10 @@ st_choose_renderbuffer_format(struct pipe_screen *screen,
                               GLenum internalFormat, unsigned sample_count);
 
 
+gl_format
+st_ChooseTextureFormat_renderable(GLcontext *ctx, GLint internalFormat,
+                                 GLenum format, GLenum type, GLboolean renderable);
+
 extern gl_format
 st_ChooseTextureFormat(GLcontext * ctx, GLint internalFormat,
                        GLenum format, GLenum type);