gallium: identify depth-stencil textures
authorKeith Whitwell <keith@tungstengraphics.com>
Fri, 2 May 2008 16:56:01 +0000 (17:56 +0100)
committerKeith Whitwell <keith@tungstengraphics.com>
Fri, 2 May 2008 16:56:01 +0000 (17:56 +0100)
And don't use the display-target path to allocate them.

src/gallium/include/pipe/p_state.h
src/mesa/state_tracker/st_cb_fbo.c

index d7565dff96059f8052284319fe24442d5ec13468..4936b7f5077525fc7083706f952c35518de27c17 100644 (file)
@@ -286,7 +286,8 @@ struct pipe_surface
 
 #define PIPE_TEXTURE_USAGE_RENDER_TARGET   0x1
 #define PIPE_TEXTURE_USAGE_DISPLAY_TARGET  0x2 /* ie a backbuffer */
-#define PIPE_TEXTURE_USAGE_SAMPLER         0x4
+#define PIPE_TEXTURE_USAGE_DEPTH_STENCIL   0x4
+#define PIPE_TEXTURE_USAGE_SAMPLER         0x8
 
 /**
  * Texture object.
index 21d61e216381ae2c0700d900b8d615122c9cc35d..cb5736f7c3d5f76558f96f4f1a2f78be30b344d4 100644 (file)
@@ -77,6 +77,11 @@ init_renderbuffer_bits(struct st_renderbuffer *strb,
    return info.size;
 }
 
+static INLINE GLboolean pf_is_depth_stencil( enum pipe_format format )
+{
+   return (pf_get_component_bits( format, PIPE_FORMAT_COMP_Z ) +
+           pf_get_component_bits( format, PIPE_FORMAT_COMP_S )) != 0;
+}
 
 /**
  * gl_renderbuffer::AllocStorage()
@@ -117,8 +122,15 @@ st_renderbuffer_alloc_storage(GLcontext * ctx, struct gl_renderbuffer *rb,
    template.height[0] = height;
    template.depth[0] = 1;
    template.last_level = 0;
-   template.tex_usage = (PIPE_TEXTURE_USAGE_DISPLAY_TARGET |
-                         PIPE_TEXTURE_USAGE_RENDER_TARGET);
+
+   if (pf_is_depth_stencil(template.format)) {
+      template.tex_usage = PIPE_TEXTURE_USAGE_DEPTH_STENCIL;
+   }
+   else {
+      template.tex_usage = (PIPE_TEXTURE_USAGE_DISPLAY_TARGET |
+                            PIPE_TEXTURE_USAGE_RENDER_TARGET);
+   }
+
 
    /* Probably need dedicated flags for surface usage too: 
     */