summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChad Versace <chad.versace@linux.intel.com>2012-07-10 16:34:27 -0700
committerChad Versace <chad.versace@linux.intel.com>2012-07-16 14:07:57 -0700
commit8ec721264c7ae0f73a520362963b2691bf098b9b (patch)
treed78d24ef98120e85bd4710392af4c280fe476bc0
parentd7458e401e97aea882309855cc72730aa3b39920 (diff)
mesa: Add function for decoding ETC1 textures
Add function _mesa_etc1_unpack_rgba8888. It is intended to be used by glCompressedTexSubImage2D to decode ETC1 textures into RGBA. 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/mesa/main/texcompress_etc.c32
-rw-r--r--src/mesa/main/texcompress_etc.h8
2 files changed, 40 insertions, 0 deletions
diff --git a/src/mesa/main/texcompress_etc.c b/src/mesa/main/texcompress_etc.c
index 5b331a92a14..c645f52b9e1 100644
--- a/src/mesa/main/texcompress_etc.c
+++ b/src/mesa/main/texcompress_etc.c
@@ -69,3 +69,35 @@ _mesa_fetch_texel_2d_f_etc1_rgb8(const struct swrast_texture_image *texImage,
69 texel[BCOMP] = UBYTE_TO_FLOAT(dst[2]); 69 texel[BCOMP] = UBYTE_TO_FLOAT(dst[2]);
70 texel[ACOMP] = 1.0f; 70 texel[ACOMP] = 1.0f;
71} 71}
72
73/**
74 * Decode texture data in format `MESA_FORMAT_ETC1_RGB8` to
75 * `MESA_FORMAT_ABGR8888`.
76 *
77 * The size of the source data must be a multiple of the ETC1 block size,
78 * which is 8, even if the texture image's dimensions are not aligned to 4.
79 * From the GL_OES_compressed_ETC1_RGB8_texture spec:
80 * The texture is described as a number of 4x4 pixel blocks. If the
81 * texture (or a particular mip-level) is smaller than 4 pixels in
82 * any dimension (such as a 2x2 or a 8x1 texture), the texture is
83 * found in the upper left part of the block(s), and the rest of the
84 * pixels are not used. For instance, a texture of size 4x2 will be
85 * placed in the upper half of a 4x4 block, and the lower half of the
86 * pixels in the block will not be accessed.
87 *
88 * \param src_width in pixels
89 * \param src_height in pixels
90 * \param dst_stride in bytes
91 */
92void
93_mesa_etc1_unpack_rgba8888(uint8_t *dst_row,
94 unsigned dst_stride,
95 const uint8_t *src_row,
96 unsigned src_stride,
97 unsigned src_width,
98 unsigned src_height)
99{
100 etc1_unpack_rgba8888(dst_row, dst_stride,
101 src_row, src_stride,
102 src_width, src_height);
103}
diff --git a/src/mesa/main/texcompress_etc.h b/src/mesa/main/texcompress_etc.h
index 8e8427f8fd4..bfba4ff85e9 100644
--- a/src/mesa/main/texcompress_etc.h
+++ b/src/mesa/main/texcompress_etc.h
@@ -37,4 +37,12 @@ void
37_mesa_fetch_texel_2d_f_etc1_rgb8(const struct swrast_texture_image *texImage, 37_mesa_fetch_texel_2d_f_etc1_rgb8(const struct swrast_texture_image *texImage,
38 GLint i, GLint j, GLint k, GLfloat *texel); 38 GLint i, GLint j, GLint k, GLfloat *texel);
39 39
40void
41_mesa_etc1_unpack_rgba8888(uint8_t *dst_row,
42 unsigned dst_stride,
43 const uint8_t *src_row,
44 unsigned src_stride,
45 unsigned src_width,
46 unsigned src_height);
47
40#endif 48#endif