summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMichel Dänzer <[email protected]>2009-04-04 16:04:59 +0200
committerMichel Dänzer <[email protected]>2009-04-04 16:04:59 +0200
commitba14b043bc1ab87e8e5e46e6e909a8def9535028 (patch)
tree38d4c58fcee1af9f9c4857ff708826623c66c9e8 /src
parentb0ce91518646b62169594da661dd92ac899cbd6f (diff)
gallium: Add utility helper for packing combined depth/stencil values.
Diffstat (limited to 'src')
-rw-r--r--src/gallium/auxiliary/util/u_pack_color.h20
-rw-r--r--src/mesa/state_tracker/st_cb_clear.c16
2 files changed, 23 insertions, 13 deletions
diff --git a/src/gallium/auxiliary/util/u_pack_color.h b/src/gallium/auxiliary/util/u_pack_color.h
index e0e8aa8e9fe..e05d0322532 100644
--- a/src/gallium/auxiliary/util/u_pack_color.h
+++ b/src/gallium/auxiliary/util/u_pack_color.h
@@ -440,6 +440,26 @@ util_pack_z(enum pipe_format format, double z)
return 0;
}
}
+
+
+/**
+ * Note: it's assumed that z is in [0,1] and s in [0,255]
+ */
+static INLINE uint
+util_pack_z_stencil(enum pipe_format format, double z, uint s)
+{
+ switch (format) {
+ case PIPE_FORMAT_S8Z24_UNORM:
+ return util_pack_z(format, z) | s << 24;
+ case PIPE_FORMAT_Z24S8_UNORM:
+ return util_pack_z(format, z) | s;
+ default:
+ debug_print_format("gallium: unhandled format in util_pack_z_stencil()",
+ format);
+ assert(0);
+ return 0;
+ }
+}
/**
diff --git a/src/mesa/state_tracker/st_cb_clear.c b/src/mesa/state_tracker/st_cb_clear.c
index 020684b4e14..bec32db0502 100644
--- a/src/mesa/state_tracker/st_cb_clear.c
+++ b/src/mesa/state_tracker/st_cb_clear.c
@@ -460,19 +460,9 @@ clear_depth_stencil_buffer(GLcontext *ctx, struct gl_renderbuffer *rb)
}
else {
/* clear whole buffer w/out masking */
- GLuint clearValue = util_pack_z(strb->surface->format, ctx->Depth.Clear);
-
- switch (strb->surface->format) {
- case PIPE_FORMAT_S8Z24_UNORM:
- clearValue |= ctx->Stencil.Clear << 24;
- break;
- case PIPE_FORMAT_Z24S8_UNORM:
- clearValue |= ctx->Stencil.Clear;
- break;
- default:
- assert(0);
- }
-
+ GLuint clearValue = util_pack_z_stencil(strb->surface->format,
+ ctx->Depth.Clear,
+ ctx->Stencil.Clear);
ctx->st->pipe->clear(ctx->st->pipe, strb->surface, clearValue);
}
}