summaryrefslogtreecommitdiff
path: root/src/gallium/auxiliary/util/u_format.h
diff options
context:
space:
mode:
authorMichal Krol <michal@vmware.com>2009-12-03 11:17:37 +0100
committerMichal Krol <michal@vmware.com>2009-12-03 11:17:37 +0100
commitcceeab39ea541b1be1521114316d660a77769c2a (patch)
tree15cd3f121b20cb37edee1312bff5a7ebe4d7dd01 /src/gallium/auxiliary/util/u_format.h
parent6df42d80234d13676fc3207cf44f0e371e3372b5 (diff)
Move pf_get_bits/size() to u_format auxiliary module.
Diffstat (limited to 'src/gallium/auxiliary/util/u_format.h')
-rw-r--r--src/gallium/auxiliary/util/u_format.h29
1 files changed, 29 insertions, 0 deletions
diff --git a/src/gallium/auxiliary/util/u_format.h b/src/gallium/auxiliary/util/u_format.h
index 583b62e606..3ac5384024 100644
--- a/src/gallium/auxiliary/util/u_format.h
+++ b/src/gallium/auxiliary/util/u_format.h
@@ -183,6 +183,35 @@ util_format_get_block(enum pipe_format format,
block->height = desc->block.height;
}
+/**
+ * Return total bits needed for the pixel format.
+ */
+static INLINE uint
+util_format_get_bits(enum pipe_format format)
+{
+ const struct util_format_description *desc = util_format_description(format);
+
+ assert(format);
+ if (!format) {
+ return 0;
+ }
+
+ return desc->block.bits / (desc->block.width * desc->block.height);
+}
+
+/**
+ * Return bytes per pixel for the given format.
+ */
+static INLINE uint
+util_format_get_size(enum pipe_format format)
+{
+ uint bits = util_format_get_bits(format);
+
+ assert(bits % 8 == 0);
+
+ return bits / 8;
+}
+
/*
* Format access functions.