gallium: depth textures have usage depth_stencil instead of render_target
authorRoland Scheidegger <sroland@tungstengraphics.com>
Fri, 9 May 2008 13:04:33 +0000 (15:04 +0200)
committerRoland Scheidegger <sroland@tungstengraphics.com>
Fri, 9 May 2008 14:56:23 +0000 (16:56 +0200)
src/mesa/state_tracker/st_cb_fbo.c
src/mesa/state_tracker/st_cb_texture.c
src/mesa/state_tracker/st_texture.h

index 3e592730f831d2e461654e3e2babdbd025c10186..3560a040c859a53af5fc68df6bdc27acee93766b 100644 (file)
@@ -77,12 +77,6 @@ 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()
  * This is called to allocate the original drawing surface, and
index c0dba4cf2dab36b919c06d7cc53ad73900c8e16c..fb78c879895afd037a2b82a49a80d46b3f3b3c7a 100644 (file)
@@ -272,6 +272,7 @@ guess_and_alloc_texture(struct st_context *st,
    GLuint height = stImage->base.Height2;
    GLuint depth = stImage->base.Depth2;
    GLuint i, comp_byte = 0;
+   enum pipe_format fmt;
 
    DBG("%s\n", __FUNCTION__);
 
@@ -331,15 +332,18 @@ guess_and_alloc_texture(struct st_context *st,
    if (stImage->base.IsCompressed)
       comp_byte = compressed_num_bytes(stImage->base.TexFormat->MesaFormat);
 
+   fmt = st_mesa_format_to_pipe_format(stImage->base.TexFormat->MesaFormat);
    stObj->pt = st_texture_create(st,
                                  gl_target_to_pipe(stObj->base.Target),
-                                 st_mesa_format_to_pipe_format(stImage->base.TexFormat->MesaFormat),
+                                 fmt,
                                  lastLevel,
                                  width,
                                  height,
                                  depth,
                                  comp_byte,
-                                 ( PIPE_TEXTURE_USAGE_RENDER_TARGET |
+                                 ( (pf_is_depth_stencil(fmt) ?
+                                   PIPE_TEXTURE_USAGE_DEPTH_STENCIL :
+                                   PIPE_TEXTURE_USAGE_RENDER_TARGET) |
                                    PIPE_TEXTURE_USAGE_SAMPLER ));
 
    DBG("%s - success\n", __FUNCTION__);
@@ -1510,16 +1514,19 @@ st_finalize_texture(GLcontext *ctx,
    /* May need to create a new gallium texture:
     */
    if (!stObj->pt) {
+      const enum pipe_format fmt =
+         st_mesa_format_to_pipe_format(firstImage->base.TexFormat->MesaFormat);
       stObj->pt = st_texture_create(ctx->st,
                                     gl_target_to_pipe(stObj->base.Target),
-                                    st_mesa_format_to_pipe_format(firstImage->base.TexFormat->MesaFormat),
+                                    fmt,
                                     stObj->lastLevel,
                                     firstImage->base.Width2,
                                     firstImage->base.Height2,
                                     firstImage->base.Depth2,
                                     comp_byte,
-
-                                    ( PIPE_TEXTURE_USAGE_RENDER_TARGET |
+                                    ( (pf_is_depth_stencil(fmt) ?
+                                      PIPE_TEXTURE_USAGE_DEPTH_STENCIL :
+                                      PIPE_TEXTURE_USAGE_RENDER_TARGET) |
                                       PIPE_TEXTURE_USAGE_SAMPLER ));
 
       if (!stObj->pt) {
index 55d1a367b507a0ad3de73471099e8d05b665f6a1..3febe6a7cb069a0e23398b9246839f90f47b864b 100644 (file)
@@ -93,6 +93,11 @@ st_get_stobj_texture(struct st_texture_object *stObj)
    return stObj ? stObj->pt : NULL;
 }
 
+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;
+}
 
 
 extern struct pipe_texture *