Move pf_is_depth_and_stencil() to u_format auxiliary module.
authorMichal Krol <michal@vmware.com>
Thu, 3 Dec 2009 09:20:49 +0000 (10:20 +0100)
committerMichal Krol <michal@vmware.com>
Thu, 3 Dec 2009 09:20:49 +0000 (10:20 +0100)
src/gallium/auxiliary/util/u_format.h
src/gallium/include/pipe/p_format.h
src/mesa/state_tracker/st_cb_clear.c
src/mesa/state_tracker/st_cb_drawpixels.c
src/mesa/state_tracker/st_cb_texture.c

index cd883d38ca866a63175d6783afdf1321a4ef1abb..e57c9e00233a4cd22ef304f9cb586f1b56d779ef 100644 (file)
@@ -141,6 +141,24 @@ util_format_is_depth_or_stencil(enum pipe_format format)
    return desc->colorspace == UTIL_FORMAT_COLORSPACE_ZS ? TRUE : FALSE;
 }
 
+static INLINE boolean 
+util_format_is_depth_and_stencil(enum pipe_format format)
+{
+   const struct util_format_description *desc = util_format_description(format);
+
+   assert(format);
+   if (!format) {
+      return FALSE;
+   }
+
+   if (desc->colorspace != UTIL_FORMAT_COLORSPACE_ZS) {
+      return FALSE;
+   }
+
+   return (desc->swizzle[0] != UTIL_FORMAT_SWIZZLE_NONE &&
+           desc->swizzle[1] != UTIL_FORMAT_SWIZZLE_NONE) ? TRUE : FALSE;
+}
+
 
 /*
  * Format access functions.
index 16ac95be9b68875b9cf9185dda04b05686fc76f2..69639ab011dab277b637ffe6c5fe97fa5ddda504 100644 (file)
@@ -548,13 +548,6 @@ pf_get_2d_size(const struct pipe_format_block *block, size_t stride, unsigned he
    return pf_get_nblocksy(block, height)*stride;
 }
 
-static INLINE boolean 
-pf_is_depth_and_stencil( enum pipe_format format )
-{
-   return (pf_get_component_bits( format, PIPE_FORMAT_COMP_Z ) != 0 &&
-           pf_get_component_bits( format, PIPE_FORMAT_COMP_S ) != 0);
-}
-
 enum pipe_video_chroma_format
 {
    PIPE_VIDEO_CHROMA_FORMAT_420,
index e83b6c92efb7ed340a99df357fefdc86190ca0dc..72b30e7c0435882b07d776b014ac30e30bf242bd 100644 (file)
@@ -52,6 +52,7 @@
 #include "pipe/p_inlines.h"
 #include "pipe/p_state.h"
 #include "pipe/p_defines.h"
+#include "util/u_format.h"
 #include "util/u_pack_color.h"
 #include "util/u_simple_shaders.h"
 #include "util/u_draw_quad.h"
@@ -341,7 +342,7 @@ static INLINE GLboolean
 check_clear_depth_with_quad(GLcontext *ctx, struct gl_renderbuffer *rb)
 {
    const struct st_renderbuffer *strb = st_renderbuffer(rb);
-   const GLboolean isDS = pf_is_depth_and_stencil(strb->surface->format);
+   const GLboolean isDS = util_format_is_depth_and_stencil(strb->surface->format);
 
    if (ctx->Scissor.Enabled &&
        (ctx->Scissor.X != 0 ||
@@ -365,7 +366,7 @@ static INLINE GLboolean
 check_clear_stencil_with_quad(GLcontext *ctx, struct gl_renderbuffer *rb)
 {
    const struct st_renderbuffer *strb = st_renderbuffer(rb);
-   const GLboolean isDS = pf_is_depth_and_stencil(strb->surface->format);
+   const GLboolean isDS = util_format_is_depth_and_stencil(strb->surface->format);
    const GLuint stencilMax = 0xff;
    const GLboolean maskStencil
       = (ctx->Stencil.WriteMask[0] & stencilMax) != stencilMax;
index 03617b7a939e5b0858476c92367590149f327b7b..0889cd6d2c2a4587cb1f3694959ee65466d31a3d 100644 (file)
@@ -63,6 +63,7 @@
 #include "tgsi/tgsi_ureg.h"
 #include "util/u_tile.h"
 #include "util/u_draw_quad.h"
+#include "util/u_format.h"
 #include "util/u_math.h"
 #include "util/u_rect.h"
 #include "shader/prog_instruction.h"
@@ -1083,7 +1084,7 @@ st_CopyPixels(GLcontext *ctx, GLint srcx, GLint srcy,
       if (ST_DEBUG & DEBUG_FALLBACK)
          debug_printf("%s: fallback processing\n", __FUNCTION__);
 
-      if (type == GL_DEPTH && pf_is_depth_and_stencil(pt->format))
+      if (type == GL_DEPTH && util_format_is_depth_and_stencil(pt->format))
          transfer_usage = PIPE_TRANSFER_READ_WRITE;
       else
          transfer_usage = PIPE_TRANSFER_WRITE;
index 676a7df6fdc5bf5f0709299b3824cb6b136ba9f5..bf17f33fc14402cc8052e2224ce69ce60fcbf324 100644 (file)
@@ -635,7 +635,7 @@ st_TexImage(GLcontext * ctx,
 
    if (stImage->pt) {
       if (format == GL_DEPTH_COMPONENT &&
-          pf_is_depth_and_stencil(stImage->pt->format))
+          util_format_is_depth_and_stencil(stImage->pt->format))
          transfer_usage = PIPE_TRANSFER_READ_WRITE;
       else
          transfer_usage = PIPE_TRANSFER_WRITE;
@@ -1042,7 +1042,7 @@ st_TexSubimage(GLcontext *ctx, GLint dims, GLenum target, GLint level,
       unsigned face = _mesa_tex_target_to_face(target);
 
       if (format == GL_DEPTH_COMPONENT &&
-          pf_is_depth_and_stencil(stImage->pt->format))
+          util_format_is_depth_and_stencil(stImage->pt->format))
          transfer_usage = PIPE_TRANSFER_READ_WRITE;
       else
          transfer_usage = PIPE_TRANSFER_WRITE;
@@ -1267,7 +1267,7 @@ fallback_copy_texsubimage(GLcontext *ctx, GLenum target, GLint level,
 
    if ((baseFormat == GL_DEPTH_COMPONENT ||
         baseFormat == GL_DEPTH_STENCIL) &&
-       pf_is_depth_and_stencil(stImage->pt->format))
+       util_format_is_depth_and_stencil(stImage->pt->format))
       transfer_usage = PIPE_TRANSFER_READ_WRITE;
    else
       transfer_usage = PIPE_TRANSFER_WRITE;