summaryrefslogtreecommitdiffstats
path: root/src/gallium/auxiliary
diff options
context:
space:
mode:
authorMichal Krol <[email protected]>2009-12-03 11:17:37 +0100
committerMichal Krol <[email protected]>2009-12-03 11:17:37 +0100
commitcceeab39ea541b1be1521114316d660a77769c2a (patch)
tree15cd3f121b20cb37edee1312bff5a7ebe4d7dd01 /src/gallium/auxiliary
parent6df42d80234d13676fc3207cf44f0e371e3372b5 (diff)
Move pf_get_bits/size() to u_format auxiliary module.
Diffstat (limited to 'src/gallium/auxiliary')
-rw-r--r--src/gallium/auxiliary/util/u_format.h29
-rw-r--r--src/gallium/auxiliary/util/u_gen_mipmap.c5
2 files changed, 32 insertions, 2 deletions
diff --git a/src/gallium/auxiliary/util/u_format.h b/src/gallium/auxiliary/util/u_format.h
index 583b62e606b..3ac53840247 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.
diff --git a/src/gallium/auxiliary/util/u_gen_mipmap.c b/src/gallium/auxiliary/util/u_gen_mipmap.c
index f67f1e458d4..70ec925d152 100644
--- a/src/gallium/auxiliary/util/u_gen_mipmap.c
+++ b/src/gallium/auxiliary/util/u_gen_mipmap.c
@@ -41,6 +41,7 @@
#include "pipe/p_shader_tokens.h"
#include "pipe/p_state.h"
+#include "util/u_format.h"
#include "util/u_memory.h"
#include "util/u_draw_quad.h"
#include "util/u_gen_mipmap.h"
@@ -996,7 +997,7 @@ reduce_2d(enum pipe_format pformat,
{
enum dtype datatype;
uint comps;
- const int bpt = pf_get_size(pformat);
+ const int bpt = util_format_get_size(pformat);
const ubyte *srcA, *srcB;
ubyte *dst;
int row;
@@ -1035,7 +1036,7 @@ reduce_3d(enum pipe_format pformat,
int dstWidth, int dstHeight, int dstDepth,
int dstRowStride, ubyte *dstPtr)
{
- const int bpt = pf_get_size(pformat);
+ const int bpt = util_format_get_size(pformat);
const int border = 0;
int img, row;
int bytesPerSrcImage, bytesPerDstImage;