summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChad Versace <chad.versace@linux.intel.com>2012-07-10 16:23:39 -0700
committerChad Versace <chad.versace@linux.intel.com>2012-07-16 14:07:57 -0700
commitd7458e401e97aea882309855cc72730aa3b39920 (patch)
tree3e0b856df59b7881ba08e755df91fc7997ca8a11
parent7250cd506baa0bd4649b30d87509cdd0cbc06a57 (diff)
gallium/util, mesa: Refactor etc1 unpack function
Move the body of util_etc1_rgb8_unpack_rgba_unorm8 into a new function that can be shared between gallium and dri drivers, texcompress_etc_tmp.h:etc1_unpack_rgba8888. CC: Chia-I <olv@lunarg.com> Reviewed-by: Kenneth Graunke <kenneth@whitecape.org> Signed-off-by: Chad Versace <chad.versace@linux.intel.com>
-rw-r--r--src/gallium/auxiliary/util/u_format_etc.c25
-rw-r--r--src/mesa/main/texcompress_etc_tmp.h34
2 files changed, 35 insertions, 24 deletions
diff --git a/src/gallium/auxiliary/util/u_format_etc.c b/src/gallium/auxiliary/util/u_format_etc.c
index 7500e1ed650..f909b16081a 100644
--- a/src/gallium/auxiliary/util/u_format_etc.c
+++ b/src/gallium/auxiliary/util/u_format_etc.c
@@ -13,30 +13,7 @@
void
util_format_etc1_rgb8_unpack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
{
- const unsigned bw = 4, bh = 4, bs = 8, comps = 4;
- struct etc1_block block;
- unsigned x, y, i, j;
-
- for (y = 0; y < height; y += bh) {
- const uint8_t *src = src_row;
-
- for (x = 0; x < width; x+= bw) {
- etc1_parse_block(&block, src);
-
- for (j = 0; j < bh; j++) {
- uint8_t *dst = dst_row + (y + j) * dst_stride + x * comps;
- for (i = 0; i < bw; i++) {
- etc1_fetch_texel(&block, i, j, dst);
- dst[3] = 255;
- dst += comps;
- }
- }
-
- src += bs;
- }
-
- src_row += src_stride;
- }
+ etc1_unpack_rgba8888(dst_row, dst_stride, src_row, src_stride, width, height);
}
void
diff --git a/src/mesa/main/texcompress_etc_tmp.h b/src/mesa/main/texcompress_etc_tmp.h
index 5c8c6decf8d..8bbb2cde83e 100644
--- a/src/mesa/main/texcompress_etc_tmp.h
+++ b/src/mesa/main/texcompress_etc_tmp.h
@@ -134,3 +134,37 @@ TAG(etc1_fetch_texel)(const struct TAG(etc1_block) *block,
dst[1] = TAG(etc1_clamp)(base_color[1], modifier);
dst[2] = TAG(etc1_clamp)(base_color[2], modifier);
}
+
+static void
+etc1_unpack_rgba8888(uint8_t *dst_row,
+ unsigned dst_stride,
+ const uint8_t *src_row,
+ unsigned src_stride,
+ unsigned width,
+ unsigned height)
+{
+ const unsigned bw = 4, bh = 4, bs = 8, comps = 4;
+ struct etc1_block block;
+ unsigned x, y, i, j;
+
+ for (y = 0; y < height; y += bh) {
+ const uint8_t *src = src_row;
+
+ for (x = 0; x < width; x+= bw) {
+ etc1_parse_block(&block, src);
+
+ for (j = 0; j < bh; j++) {
+ uint8_t *dst = dst_row + (y + j) * dst_stride + x * comps;
+ for (i = 0; i < bw; i++) {
+ etc1_fetch_texel(&block, i, j, dst);
+ dst[3] = 255;
+ dst += comps;
+ }
+ }
+
+ src += bs;
+ }
+
+ src_row += src_stride;
+ }
+}