summaryrefslogtreecommitdiff
path: root/src/mesa/main
diff options
context:
space:
mode:
authorKenneth Graunke <kenneth@whitecape.org>2013-04-22 23:52:22 -0700
committerKenneth Graunke <kenneth@whitecape.org>2013-04-23 22:13:02 -0700
commitcef31bb290f9fa58b8393e355a0d86a90ee20e14 (patch)
treea7c55aa7d2de17e0421c58e686efdf00ab533380 /src/mesa/main
parent995051ee34f9c29461b6e9cad27df5e375688218 (diff)
mesa: Add unpack functions for A/I/L/LA [U]INT8/16/32 formats.
NOTE: This is a candidate for stable branches. Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=63569 Signed-off-by: Kenneth Graunke <kenneth@whitecape.org> Reviewed-by: Brian Paul <brianp@vmware.com>
Diffstat (limited to 'src/mesa/main')
-rw-r--r--src/mesa/main/format_unpack.c327
1 files changed, 327 insertions, 0 deletions
diff --git a/src/mesa/main/format_unpack.c b/src/mesa/main/format_unpack.c
index 19ed43caa97..0a8b8b18383 100644
--- a/src/mesa/main/format_unpack.c
+++ b/src/mesa/main/format_unpack.c
@@ -1075,6 +1075,305 @@ unpack_RG_FLOAT16(const void *src, GLfloat dst[][4], GLuint n)
}
}
+static void
+unpack_ALPHA_UINT8(const void *src, GLfloat dst[][4], GLuint n)
+{
+ const GLubyte *s = (const GLubyte *) src;
+ GLuint i;
+ for (i = 0; i < n; i++) {
+ dst[i][RCOMP] =
+ dst[i][GCOMP] =
+ dst[i][BCOMP] = 0.0;
+ dst[i][ACOMP] = (GLfloat) s[i];
+ }
+}
+
+static void
+unpack_ALPHA_UINT16(const void *src, GLfloat dst[][4], GLuint n)
+{
+ const GLushort *s = (const GLushort *) src;
+ GLuint i;
+ for (i = 0; i < n; i++) {
+ dst[i][RCOMP] =
+ dst[i][GCOMP] =
+ dst[i][BCOMP] = 0.0;
+ dst[i][ACOMP] = (GLfloat) s[i];
+ }
+}
+
+static void
+unpack_ALPHA_UINT32(const void *src, GLfloat dst[][4], GLuint n)
+{
+ const GLuint *s = (const GLuint *) src;
+ GLuint i;
+ for (i = 0; i < n; i++) {
+ dst[i][RCOMP] =
+ dst[i][GCOMP] =
+ dst[i][BCOMP] = 0.0;
+ dst[i][ACOMP] = (GLfloat) s[i];
+ }
+}
+
+static void
+unpack_ALPHA_INT8(const void *src, GLfloat dst[][4], GLuint n)
+{
+ const GLbyte *s = (const GLbyte *) src;
+ GLuint i;
+ for (i = 0; i < n; i++) {
+ dst[i][RCOMP] =
+ dst[i][GCOMP] =
+ dst[i][BCOMP] = 0.0;
+ dst[i][ACOMP] = (GLfloat) s[i];
+ }
+}
+
+static void
+unpack_ALPHA_INT16(const void *src, GLfloat dst[][4], GLuint n)
+{
+ const GLshort *s = (const GLshort *) src;
+ GLuint i;
+ for (i = 0; i < n; i++) {
+ dst[i][RCOMP] =
+ dst[i][GCOMP] =
+ dst[i][BCOMP] = 0.0;
+ dst[i][ACOMP] = (GLfloat) s[i];
+ }
+}
+
+static void
+unpack_ALPHA_INT32(const void *src, GLfloat dst[][4], GLuint n)
+{
+ const GLint *s = (const GLint *) src;
+ GLuint i;
+ for (i = 0; i < n; i++) {
+ dst[i][RCOMP] =
+ dst[i][GCOMP] =
+ dst[i][BCOMP] = 0.0;
+ dst[i][ACOMP] = (GLfloat) s[i];
+ }
+}
+
+static void
+unpack_INTENSITY_UINT8(const void *src, GLfloat dst[][4], GLuint n)
+{
+ const GLubyte *s = (const GLubyte *) src;
+ GLuint i;
+ for (i = 0; i < n; i++) {
+ dst[i][RCOMP] =
+ dst[i][GCOMP] =
+ dst[i][BCOMP] =
+ dst[i][ACOMP] = (GLfloat) s[i];
+ }
+}
+
+static void
+unpack_INTENSITY_UINT16(const void *src, GLfloat dst[][4], GLuint n)
+{
+ const GLushort *s = (const GLushort *) src;
+ GLuint i;
+ for (i = 0; i < n; i++) {
+ dst[i][RCOMP] =
+ dst[i][GCOMP] =
+ dst[i][BCOMP] =
+ dst[i][ACOMP] = (GLfloat) s[i];
+ }
+}
+
+static void
+unpack_INTENSITY_UINT32(const void *src, GLfloat dst[][4], GLuint n)
+{
+ const GLuint *s = (const GLuint *) src;
+ GLuint i;
+ for (i = 0; i < n; i++) {
+ dst[i][RCOMP] =
+ dst[i][GCOMP] =
+ dst[i][BCOMP] =
+ dst[i][ACOMP] = (GLfloat) s[i];
+ }
+}
+
+static void
+unpack_INTENSITY_INT8(const void *src, GLfloat dst[][4], GLuint n)
+{
+ const GLbyte *s = (const GLbyte *) src;
+ GLuint i;
+ for (i = 0; i < n; i++) {
+ dst[i][RCOMP] =
+ dst[i][GCOMP] =
+ dst[i][BCOMP] =
+ dst[i][ACOMP] = (GLfloat) s[i];
+ }
+}
+
+static void
+unpack_INTENSITY_INT16(const void *src, GLfloat dst[][4], GLuint n)
+{
+ const GLshort *s = (const GLshort *) src;
+ GLuint i;
+ for (i = 0; i < n; i++) {
+ dst[i][RCOMP] =
+ dst[i][GCOMP] =
+ dst[i][BCOMP] =
+ dst[i][ACOMP] = (GLfloat) s[i];
+ }
+}
+
+static void
+unpack_INTENSITY_INT32(const void *src, GLfloat dst[][4], GLuint n)
+{
+ const GLint *s = (const GLint *) src;
+ GLuint i;
+ for (i = 0; i < n; i++) {
+ dst[i][RCOMP] =
+ dst[i][GCOMP] =
+ dst[i][BCOMP] =
+ dst[i][ACOMP] = (GLfloat) s[i];
+ }
+}
+
+static void
+unpack_LUMINANCE_UINT8(const void *src, GLfloat dst[][4], GLuint n)
+{
+ const GLubyte *s = (const GLubyte *) src;
+ GLuint i;
+ for (i = 0; i < n; i++) {
+ dst[i][RCOMP] = dst[i][GCOMP] = dst[i][BCOMP] = (GLfloat) s[i];
+ dst[i][ACOMP] = 1.0;
+ }
+}
+
+static void
+unpack_LUMINANCE_UINT16(const void *src, GLfloat dst[][4], GLuint n)
+{
+ const GLushort *s = (const GLushort *) src;
+ GLuint i;
+ for (i = 0; i < n; i++) {
+ dst[i][RCOMP] = dst[i][GCOMP] = dst[i][BCOMP] = (GLfloat) s[i];
+ dst[i][ACOMP] = 1.0;
+ }
+}
+
+static void
+unpack_LUMINANCE_UINT32(const void *src, GLfloat dst[][4], GLuint n)
+{
+ const GLuint *s = (const GLuint *) src;
+ GLuint i;
+ for (i = 0; i < n; i++) {
+ dst[i][RCOMP] = dst[i][GCOMP] = dst[i][BCOMP] = (GLfloat) s[i];
+ dst[i][ACOMP] = 1.0;
+ }
+}
+
+static void
+unpack_LUMINANCE_INT8(const void *src, GLfloat dst[][4], GLuint n)
+{
+ const GLbyte *s = (const GLbyte *) src;
+ GLuint i;
+ for (i = 0; i < n; i++) {
+ dst[i][RCOMP] = dst[i][GCOMP] = dst[i][BCOMP] = (GLfloat) s[i];
+ dst[i][ACOMP] = 1.0;
+ }
+}
+
+static void
+unpack_LUMINANCE_INT16(const void *src, GLfloat dst[][4], GLuint n)
+{
+ const GLshort *s = (const GLshort *) src;
+ GLuint i;
+ for (i = 0; i < n; i++) {
+ dst[i][RCOMP] = dst[i][GCOMP] = dst[i][BCOMP] = (GLfloat) s[i];
+ dst[i][ACOMP] = 1.0;
+ }
+}
+
+static void
+unpack_LUMINANCE_INT32(const void *src, GLfloat dst[][4], GLuint n)
+{
+ const GLint *s = (const GLint *) src;
+ GLuint i;
+ for (i = 0; i < n; i++) {
+ dst[i][RCOMP] = dst[i][GCOMP] = dst[i][BCOMP] = (GLfloat) s[i];
+ dst[i][ACOMP] = 1.0;
+ }
+}
+
+static void
+unpack_LUMINANCE_ALPHA_UINT8(const void *src, GLfloat dst[][4], GLuint n)
+{
+ const GLubyte *s = (const GLubyte *) src;
+ GLuint i;
+ for (i = 0; i < n; i++) {
+ dst[i][RCOMP] =
+ dst[i][GCOMP] =
+ dst[i][BCOMP] = (GLfloat) s[2*i+0];
+ dst[i][ACOMP] = (GLfloat) s[2*i+1];
+ }
+}
+
+static void
+unpack_LUMINANCE_ALPHA_UINT16(const void *src, GLfloat dst[][4], GLuint n)
+{
+ const GLushort *s = (const GLushort *) src;
+ GLuint i;
+ for (i = 0; i < n; i++) {
+ dst[i][RCOMP] =
+ dst[i][GCOMP] =
+ dst[i][BCOMP] = (GLfloat) s[2*i+0];
+ dst[i][ACOMP] = (GLfloat) s[2*i+1];
+ }
+}
+
+static void
+unpack_LUMINANCE_ALPHA_UINT32(const void *src, GLfloat dst[][4], GLuint n)
+{
+ const GLuint *s = (const GLuint *) src;
+ GLuint i;
+ for (i = 0; i < n; i++) {
+ dst[i][RCOMP] =
+ dst[i][GCOMP] =
+ dst[i][BCOMP] = (GLfloat) s[2*i+0];
+ dst[i][ACOMP] = (GLfloat) s[2*i+1];
+ }
+}
+
+static void
+unpack_LUMINANCE_ALPHA_INT8(const void *src, GLfloat dst[][4], GLuint n)
+{
+ const GLbyte *s = (const GLbyte *) src;
+ GLuint i;
+ for (i = 0; i < n; i++) {
+ dst[i][RCOMP] =
+ dst[i][GCOMP] =
+ dst[i][BCOMP] = (GLfloat) s[2*i+0];
+ dst[i][ACOMP] = (GLfloat) s[2*i+1];
+ }
+}
+
+static void
+unpack_LUMINANCE_ALPHA_INT16(const void *src, GLfloat dst[][4], GLuint n)
+{
+ const GLshort *s = (const GLshort *) src;
+ GLuint i;
+ for (i = 0; i < n; i++) {
+ dst[i][RCOMP] =
+ dst[i][GCOMP] =
+ dst[i][BCOMP] = (GLfloat) s[2*i+0];
+ dst[i][ACOMP] = (GLfloat) s[2*i+1];
+ }
+}
+
+static void
+unpack_LUMINANCE_ALPHA_INT32(const void *src, GLfloat dst[][4], GLuint n)
+{
+ const GLint *s = (const GLint *) src;
+ GLuint i;
+ for (i = 0; i < n; i++) {
+ dst[i][RCOMP] =
+ dst[i][GCOMP] =
+ dst[i][BCOMP] = (GLfloat) s[2*i+0];
+ dst[i][ACOMP] = (GLfloat) s[2*i+1];
+ }
+}
static void
unpack_R_INT8(const void *src, GLfloat dst[][4], GLuint n)
@@ -2063,6 +2362,34 @@ get_unpack_rgba_function(gl_format format)
table[MESA_FORMAT_RG_FLOAT32] = unpack_RG_FLOAT32;
table[MESA_FORMAT_RG_FLOAT16] = unpack_RG_FLOAT16;
+ table[MESA_FORMAT_ALPHA_UINT8] = unpack_ALPHA_UINT8;
+ table[MESA_FORMAT_ALPHA_UINT16] = unpack_ALPHA_UINT16;
+ table[MESA_FORMAT_ALPHA_UINT32] = unpack_ALPHA_UINT32;
+ table[MESA_FORMAT_ALPHA_INT8] = unpack_ALPHA_INT8;
+ table[MESA_FORMAT_ALPHA_INT16] = unpack_ALPHA_INT16;
+ table[MESA_FORMAT_ALPHA_INT32] = unpack_ALPHA_INT32;
+
+ table[MESA_FORMAT_INTENSITY_UINT8] = unpack_INTENSITY_UINT8;
+ table[MESA_FORMAT_INTENSITY_UINT16] = unpack_INTENSITY_UINT16;
+ table[MESA_FORMAT_INTENSITY_UINT32] = unpack_INTENSITY_UINT32;
+ table[MESA_FORMAT_INTENSITY_INT8] = unpack_INTENSITY_INT8;
+ table[MESA_FORMAT_INTENSITY_INT16] = unpack_INTENSITY_INT16;
+ table[MESA_FORMAT_INTENSITY_INT32] = unpack_INTENSITY_INT32;
+
+ table[MESA_FORMAT_LUMINANCE_UINT8] = unpack_LUMINANCE_UINT8;
+ table[MESA_FORMAT_LUMINANCE_UINT16] = unpack_LUMINANCE_UINT16;
+ table[MESA_FORMAT_LUMINANCE_UINT32] = unpack_LUMINANCE_UINT32;
+ table[MESA_FORMAT_LUMINANCE_INT8] = unpack_LUMINANCE_INT8;
+ table[MESA_FORMAT_LUMINANCE_INT16] = unpack_LUMINANCE_INT16;
+ table[MESA_FORMAT_LUMINANCE_INT32] = unpack_LUMINANCE_INT32;
+
+ table[MESA_FORMAT_LUMINANCE_ALPHA_UINT8] = unpack_LUMINANCE_ALPHA_UINT8;
+ table[MESA_FORMAT_LUMINANCE_ALPHA_UINT16] = unpack_LUMINANCE_ALPHA_UINT16;
+ table[MESA_FORMAT_LUMINANCE_ALPHA_UINT32] = unpack_LUMINANCE_ALPHA_UINT32;
+ table[MESA_FORMAT_LUMINANCE_ALPHA_INT8] = unpack_LUMINANCE_ALPHA_INT8;
+ table[MESA_FORMAT_LUMINANCE_ALPHA_INT16] = unpack_LUMINANCE_ALPHA_INT16;
+ table[MESA_FORMAT_LUMINANCE_ALPHA_INT32] = unpack_LUMINANCE_ALPHA_INT32;
+
table[MESA_FORMAT_R_INT8] = unpack_R_INT8;
table[MESA_FORMAT_RG_INT8] = unpack_RG_INT8;
table[MESA_FORMAT_RGB_INT8] = unpack_RGB_INT8;