summaryrefslogtreecommitdiffstats
path: root/src/gallium/auxiliary/util
diff options
context:
space:
mode:
authorMichal Krol <[email protected]>2009-12-03 10:52:47 +0100
committerMichal Krol <[email protected]>2009-12-03 10:52:47 +0100
commit6df42d80234d13676fc3207cf44f0e371e3372b5 (patch)
tree7ab6d37b68aeae719167900f7daa7d9addf86a95 /src/gallium/auxiliary/util
parent0bed834be4a174d20b31a6cbcf066774bf749929 (diff)
Move pf_get_block() to u_format auxiliary module.
Diffstat (limited to 'src/gallium/auxiliary/util')
-rw-r--r--src/gallium/auxiliary/util/u_blit.c3
-rw-r--r--src/gallium/auxiliary/util/u_format.h26
-rw-r--r--src/gallium/auxiliary/util/u_surface.c3
3 files changed, 29 insertions, 3 deletions
diff --git a/src/gallium/auxiliary/util/u_blit.c b/src/gallium/auxiliary/util/u_blit.c
index 5372df57352..df2bcf2d021 100644
--- a/src/gallium/auxiliary/util/u_blit.c
+++ b/src/gallium/auxiliary/util/u_blit.c
@@ -42,6 +42,7 @@
#include "util/u_blit.h"
#include "util/u_draw_quad.h"
+#include "util/u_format.h"
#include "util/u_math.h"
#include "util/u_memory.h"
#include "util/u_simple_shaders.h"
@@ -357,7 +358,7 @@ util_blit_pixels_writemask(struct blit_state *ctx,
texTemp.width0 = srcW;
texTemp.height0 = srcH;
texTemp.depth0 = 1;
- pf_get_block(src->format, &texTemp.block);
+ util_format_get_block(src->format, &texTemp.block);
tex = screen->texture_create(screen, &texTemp);
if (!tex)
diff --git a/src/gallium/auxiliary/util/u_format.h b/src/gallium/auxiliary/util/u_format.h
index e57c9e00233..583b62e606b 100644
--- a/src/gallium/auxiliary/util/u_format.h
+++ b/src/gallium/auxiliary/util/u_format.h
@@ -50,7 +50,7 @@ struct util_format_block
/** Block height in pixels */
unsigned height;
- /** Block size in bytes */
+ /** Block size in bits */
unsigned bits;
};
@@ -159,6 +159,30 @@ util_format_is_depth_and_stencil(enum pipe_format format)
desc->swizzle[1] != UTIL_FORMAT_SWIZZLE_NONE) ? TRUE : FALSE;
}
+/**
+ * Describe pixel format's block.
+ *
+ * @sa http://msdn2.microsoft.com/en-us/library/ms796147.aspx
+ */
+static INLINE void
+util_format_get_block(enum pipe_format format,
+ struct pipe_format_block *block)
+{
+ const struct util_format_description *desc = util_format_description(format);
+
+ assert(format);
+ if (!format) {
+ block->size = 0;
+ block->width = 1;
+ block->height = 1;
+ return;
+ }
+
+ block->size = desc->block.bits / 8;
+ block->width = desc->block.width;
+ block->height = desc->block.height;
+}
+
/*
* Format access functions.
diff --git a/src/gallium/auxiliary/util/u_surface.c b/src/gallium/auxiliary/util/u_surface.c
index de8c266db83..9c84ca733b0 100644
--- a/src/gallium/auxiliary/util/u_surface.c
+++ b/src/gallium/auxiliary/util/u_surface.c
@@ -36,6 +36,7 @@
#include "pipe/p_state.h"
#include "pipe/p_defines.h"
+#include "util/u_format.h"
#include "util/u_surface.h"
@@ -82,7 +83,7 @@ util_create_rgba_surface(struct pipe_screen *screen,
templ.width0 = width;
templ.height0 = height;
templ.depth0 = 1;
- pf_get_block(format, &templ.block);
+ util_format_get_block(format, &templ.block);
templ.tex_usage = usage;
*textureOut = screen->texture_create(screen, &templ);