summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarek Olšák <[email protected]>2013-05-29 19:26:56 +0200
committerMarek Olšák <[email protected]>2013-06-13 03:54:13 +0200
commit72a086b8b2a58044be1a66dc09d9cb8b0d3da719 (patch)
treee5d55be1c307c9b451751ce9c9b794c62fc4fb3d
parentd6d4a9a2e87d9ed2c5b3a6acee771ff55a903e47 (diff)
gallium/u_format: add a new helper for initializing pipe_blit_info::mask
Reviewed-by: Brian Paul <[email protected]>
-rw-r--r--src/gallium/auxiliary/util/u_format.h28
-rw-r--r--src/gallium/auxiliary/util/u_surface.c26
2 files changed, 29 insertions, 25 deletions
diff --git a/src/gallium/auxiliary/util/u_format.h b/src/gallium/auxiliary/util/u_format.h
index e4b9c365c97..4cace6ad1b9 100644
--- a/src/gallium/auxiliary/util/u_format.h
+++ b/src/gallium/auxiliary/util/u_format.h
@@ -31,6 +31,7 @@
#include "pipe/p_format.h"
+#include "pipe/p_defines.h"
#include "util/u_debug.h"
union pipe_color_union;
@@ -520,6 +521,33 @@ util_format_is_depth_and_stencil(enum pipe_format format)
util_format_has_stencil(desc);
}
+/**
+ * Return whether this is an RGBA, Z, S, or combined ZS format.
+ * Useful for initializing pipe_blit_info::mask.
+ */
+static INLINE unsigned
+util_format_get_mask(enum pipe_format format)
+{
+ const struct util_format_description *desc =
+ util_format_description(format);
+
+ if (!desc)
+ return 0;
+
+ if (util_format_has_depth(desc)) {
+ if (util_format_has_stencil(desc)) {
+ return PIPE_MASK_ZS;
+ } else {
+ return PIPE_MASK_Z;
+ }
+ } else {
+ if (util_format_has_stencil(desc)) {
+ return PIPE_MASK_S;
+ } else {
+ return PIPE_MASK_RGBA;
+ }
+ }
+}
/**
* Give the RGBA colormask of the channels that can be represented in this
diff --git a/src/gallium/auxiliary/util/u_surface.c b/src/gallium/auxiliary/util/u_surface.c
index 17591f11988..07997d2adc7 100644
--- a/src/gallium/auxiliary/util/u_surface.c
+++ b/src/gallium/auxiliary/util/u_surface.c
@@ -548,30 +548,6 @@ util_clear_depth_stencil(struct pipe_context *pipe,
}
-/* Return whether this is an RGBA, Z, S, or combined ZS format.
- */
-static unsigned
-get_format_mask(enum pipe_format format)
-{
- const struct util_format_description *desc = util_format_description(format);
-
- assert(desc);
-
- if (util_format_has_depth(desc)) {
- if (util_format_has_stencil(desc)) {
- return PIPE_MASK_ZS;
- } else {
- return PIPE_MASK_Z;
- }
- } else {
- if (util_format_has_stencil(desc)) {
- return PIPE_MASK_S;
- } else {
- return PIPE_MASK_RGBA;
- }
- }
-}
-
/* Return if the box is totally inside the resource.
*/
static boolean
@@ -654,7 +630,7 @@ boolean
util_try_blit_via_copy_region(struct pipe_context *ctx,
const struct pipe_blit_info *blit)
{
- unsigned mask = get_format_mask(blit->dst.format);
+ unsigned mask = util_format_get_mask(blit->dst.format);
/* No format conversions. */
if (blit->src.resource->format != blit->src.format ||