Mesa (master): mesa: Add missing format unpack for some integer texture formats.

Eric Anholt anholt at kemper.freedesktop.org
Fri Jan 27 20:07:28 UTC 2012


Module: Mesa
Branch: master
Commit: de24ccabd6494125e10017e0914b3298ea3791ea
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=de24ccabd6494125e10017e0914b3298ea3791ea

Author: Eric Anholt <eric at anholt.net>
Date:   Thu Jan 19 16:34:24 2012 -0800

mesa: Add missing format unpack for some integer texture formats.

This cut and paste is pretty awful.  I'm tempted to do a lot of this
using preprocessor tricks for customizing the parameter type from a
template function, but that's just a different sort of hideous.

Fixes 8 Intel oglconform int-textures cases.

NOTE: This is a candidate for the 8.0 branch.
v2: Add alpha formats, too.

Reviewed-by: Brian Paul <brianp at vmware.com>

---

 src/mesa/main/format_unpack.c |  321 +++++++++++++++++++++++++++++++++++++++++
 1 files changed, 321 insertions(+), 0 deletions(-)

diff --git a/src/mesa/main/format_unpack.c b/src/mesa/main/format_unpack.c
index ff98c69..a2d8891 100644
--- a/src/mesa/main/format_unpack.c
+++ b/src/mesa/main/format_unpack.c
@@ -2210,6 +2210,58 @@ unpack_int_rgba_RG_UINT32(const GLuint *src, GLuint dst[][4], GLuint n)
 }
 
 static void
+unpack_int_rgba_RG_UINT16(const GLushort *src, GLuint dst[][4], GLuint n)
+{
+   unsigned int i;
+
+   for (i = 0; i < n; i++) {
+      dst[i][0] = src[i * 2 + 0];
+      dst[i][1] = src[i * 2 + 1];
+      dst[i][2] = 0;
+      dst[i][3] = 1;
+   }
+}
+
+static void
+unpack_int_rgba_RG_INT16(const GLshort *src, GLuint dst[][4], GLuint n)
+{
+   unsigned int i;
+
+   for (i = 0; i < n; i++) {
+      dst[i][0] = src[i * 2 + 0];
+      dst[i][1] = src[i * 2 + 1];
+      dst[i][2] = 0;
+      dst[i][3] = 1;
+   }
+}
+
+static void
+unpack_int_rgba_RG_UINT8(const GLubyte *src, GLuint dst[][4], GLuint n)
+{
+   unsigned int i;
+
+   for (i = 0; i < n; i++) {
+      dst[i][0] = src[i * 2 + 0];
+      dst[i][1] = src[i * 2 + 1];
+      dst[i][2] = 0;
+      dst[i][3] = 1;
+   }
+}
+
+static void
+unpack_int_rgba_RG_INT8(const GLbyte *src, GLuint dst[][4], GLuint n)
+{
+   unsigned int i;
+
+   for (i = 0; i < n; i++) {
+      dst[i][0] = src[i * 2 + 0];
+      dst[i][1] = src[i * 2 + 1];
+      dst[i][2] = 0;
+      dst[i][3] = 1;
+   }
+}
+
+static void
 unpack_int_rgba_R_UINT32(const GLuint *src, GLuint dst[][4], GLuint n)
 {
    unsigned int i;
@@ -2223,6 +2275,113 @@ unpack_int_rgba_R_UINT32(const GLuint *src, GLuint dst[][4], GLuint n)
 }
 
 static void
+unpack_int_rgba_R_UINT16(const GLushort *src, GLuint dst[][4], GLuint n)
+{
+   unsigned int i;
+
+   for (i = 0; i < n; i++) {
+      dst[i][0] = src[i];
+      dst[i][1] = 0;
+      dst[i][2] = 0;
+      dst[i][3] = 1;
+   }
+}
+
+static void
+unpack_int_rgba_R_INT16(const GLshort *src, GLuint dst[][4], GLuint n)
+{
+   unsigned int i;
+
+   for (i = 0; i < n; i++) {
+      dst[i][0] = src[i];
+      dst[i][1] = 0;
+      dst[i][2] = 0;
+      dst[i][3] = 1;
+   }
+}
+
+static void
+unpack_int_rgba_R_UINT8(const GLubyte *src, GLuint dst[][4], GLuint n)
+{
+   unsigned int i;
+
+   for (i = 0; i < n; i++) {
+      dst[i][0] = src[i];
+      dst[i][1] = 0;
+      dst[i][2] = 0;
+      dst[i][3] = 1;
+   }
+}
+
+static void
+unpack_int_rgba_R_INT8(const GLbyte *src, GLuint dst[][4], GLuint n)
+{
+   unsigned int i;
+
+   for (i = 0; i < n; i++) {
+      dst[i][0] = src[i];
+      dst[i][1] = 0;
+      dst[i][2] = 0;
+      dst[i][3] = 1;
+   }
+}
+
+static void
+unpack_int_rgba_ALPHA_UINT32(const GLuint *src, GLuint dst[][4], GLuint n)
+{
+   unsigned int i;
+
+   for (i = 0; i < n; i++) {
+      dst[i][0] = dst[i][1] = dst[i][2] = 0;
+      dst[i][3] = src[i];
+   }
+}
+
+static void
+unpack_int_rgba_ALPHA_UINT16(const GLushort *src, GLuint dst[][4], GLuint n)
+{
+   unsigned int i;
+
+   for (i = 0; i < n; i++) {
+      dst[i][0] = dst[i][1] = dst[i][2] = 0;
+      dst[i][3] = src[i];
+   }
+}
+
+static void
+unpack_int_rgba_ALPHA_INT16(const GLshort *src, GLuint dst[][4], GLuint n)
+{
+   unsigned int i;
+
+   for (i = 0; i < n; i++) {
+      dst[i][0] = dst[i][1] = dst[i][2] = 0;
+      dst[i][3] = src[i];
+   }
+}
+
+static void
+unpack_int_rgba_ALPHA_UINT8(const GLubyte *src, GLuint dst[][4], GLuint n)
+{
+   unsigned int i;
+
+   for (i = 0; i < n; i++) {
+      dst[i][0] = dst[i][1] = dst[i][2] = 0;
+      dst[i][3] = src[i];
+   }
+}
+
+static void
+unpack_int_rgba_ALPHA_INT8(const GLbyte *src, GLuint dst[][4], GLuint n)
+{
+   unsigned int i;
+
+   for (i = 0; i < n; i++) {
+      dst[i][0] = dst[i][1] = dst[i][2] = 0;
+      dst[i][3] = src[i];
+   }
+}
+
+static void
 unpack_int_rgba_LUMINANCE_UINT32(const GLuint *src, GLuint dst[][4], GLuint n)
 {
    unsigned int i;
@@ -2245,6 +2404,50 @@ unpack_int_rgba_LUMINANCE_ALPHA_UINT32(const GLuint *src, GLuint dst[][4], GLuin
 }
 
 static void
+unpack_int_rgba_LUMINANCE_ALPHA_UINT16(const GLushort *src, GLuint dst[][4], GLuint n)
+{
+   unsigned int i;
+
+   for (i = 0; i < n; i++) {
+      dst[i][0] = dst[i][1] = dst[i][2] = src[i * 2 + 0];
+      dst[i][3] = src[i * 2 + 1];
+   }
+}
+
+static void
+unpack_int_rgba_LUMINANCE_ALPHA_INT16(const GLshort *src, GLuint dst[][4], GLuint n)
+{
+   unsigned int i;
+
+   for (i = 0; i < n; i++) {
+      dst[i][0] = dst[i][1] = dst[i][2] = src[i * 2 + 0];
+      dst[i][3] = src[i * 2 + 1];
+   }
+}
+
+static void
+unpack_int_rgba_LUMINANCE_ALPHA_UINT8(const GLubyte *src, GLuint dst[][4], GLuint n)
+{
+   unsigned int i;
+
+   for (i = 0; i < n; i++) {
+      dst[i][0] = dst[i][1] = dst[i][2] = src[i * 2 + 0];
+      dst[i][3] = src[i * 2 + 1];
+   }
+}
+
+static void
+unpack_int_rgba_LUMINANCE_ALPHA_INT8(const GLbyte *src, GLuint dst[][4], GLuint n)
+{
+   unsigned int i;
+
+   for (i = 0; i < n; i++) {
+      dst[i][0] = dst[i][1] = dst[i][2] = src[i * 2 + 0];
+      dst[i][3] = src[i * 2 + 1];
+   }
+}
+
+static void
 unpack_int_rgba_INTENSITY_UINT32(const GLuint *src, GLuint dst[][4], GLuint n)
 {
    unsigned int i;
@@ -2255,6 +2458,46 @@ unpack_int_rgba_INTENSITY_UINT32(const GLuint *src, GLuint dst[][4], GLuint n)
 }
 
 static void
+unpack_int_rgba_INTENSITY_UINT16(const GLushort *src, GLuint dst[][4], GLuint n)
+{
+   unsigned int i;
+
+   for (i = 0; i < n; i++) {
+      dst[i][0] = dst[i][1] = dst[i][2] = dst[i][3] = src[i];
+   }
+}
+
+static void
+unpack_int_rgba_INTENSITY_INT16(const GLshort *src, GLuint dst[][4], GLuint n)
+{
+   unsigned int i;
+
+   for (i = 0; i < n; i++) {
+      dst[i][0] = dst[i][1] = dst[i][2] = dst[i][3] = src[i];
+   }
+}
+
+static void
+unpack_int_rgba_INTENSITY_UINT8(const GLubyte *src, GLuint dst[][4], GLuint n)
+{
+   unsigned int i;
+
+   for (i = 0; i < n; i++) {
+      dst[i][0] = dst[i][1] = dst[i][2] = dst[i][3] = src[i];
+   }
+}
+
+static void
+unpack_int_rgba_INTENSITY_INT8(const GLbyte *src, GLuint dst[][4], GLuint n)
+{
+   unsigned int i;
+
+   for (i = 0; i < n; i++) {
+      dst[i][0] = dst[i][1] = dst[i][2] = dst[i][3] = src[i];
+   }
+}
+
+static void
 unpack_int_rgba_ARGB2101010_UINT(const GLuint *src, GLuint dst[][4], GLuint n)
 {
    unsigned int i;
@@ -2318,24 +2561,102 @@ _mesa_unpack_uint_rgba_row(gl_format format, GLuint n,
    case MESA_FORMAT_RG_INT32:
       unpack_int_rgba_RG_UINT32(src, dst, n);
       break;
+
+   case MESA_FORMAT_RG_UINT16:
+      unpack_int_rgba_RG_UINT16(src, dst, n);
+      break;
+   case MESA_FORMAT_RG_INT16:
+      unpack_int_rgba_RG_INT16(src, dst, n);
+      break;
+
+   case MESA_FORMAT_RG_UINT8:
+      unpack_int_rgba_RG_UINT8(src, dst, n);
+      break;
+   case MESA_FORMAT_RG_INT8:
+      unpack_int_rgba_RG_INT8(src, dst, n);
+      break;
+
    case MESA_FORMAT_R_UINT32:
    case MESA_FORMAT_R_INT32:
       unpack_int_rgba_R_UINT32(src, dst, n);
       break;
 
+   case MESA_FORMAT_R_UINT16:
+      unpack_int_rgba_R_UINT16(src, dst, n);
+      break;
+   case MESA_FORMAT_R_INT16:
+      unpack_int_rgba_R_INT16(src, dst, n);
+      break;
+
+   case MESA_FORMAT_R_UINT8:
+      unpack_int_rgba_R_UINT8(src, dst, n);
+      break;
+   case MESA_FORMAT_R_INT8:
+      unpack_int_rgba_R_INT8(src, dst, n);
+      break;
+
+   case MESA_FORMAT_ALPHA_UINT32:
+   case MESA_FORMAT_ALPHA_INT32:
+      unpack_int_rgba_ALPHA_UINT32(src, dst, n);
+      break;
+
+   case MESA_FORMAT_ALPHA_UINT16:
+      unpack_int_rgba_ALPHA_UINT16(src, dst, n);
+      break;
+   case MESA_FORMAT_ALPHA_INT16:
+      unpack_int_rgba_ALPHA_INT16(src, dst, n);
+      break;
+
+   case MESA_FORMAT_ALPHA_UINT8:
+      unpack_int_rgba_ALPHA_UINT8(src, dst, n);
+      break;
+   case MESA_FORMAT_ALPHA_INT8:
+      unpack_int_rgba_ALPHA_INT8(src, dst, n);
+      break;
+
    case MESA_FORMAT_LUMINANCE_UINT32:
    case MESA_FORMAT_LUMINANCE_INT32:
       unpack_int_rgba_LUMINANCE_UINT32(src, dst, n);
       break;
+
    case MESA_FORMAT_LUMINANCE_ALPHA_UINT32:
    case MESA_FORMAT_LUMINANCE_ALPHA_INT32:
       unpack_int_rgba_LUMINANCE_ALPHA_UINT32(src, dst, n);
       break;
+
+   case MESA_FORMAT_LUMINANCE_ALPHA_UINT16:
+      unpack_int_rgba_LUMINANCE_ALPHA_UINT16(src, dst, n);
+      break;
+   case MESA_FORMAT_LUMINANCE_ALPHA_INT16:
+      unpack_int_rgba_LUMINANCE_ALPHA_INT16(src, dst, n);
+      break;
+
+   case MESA_FORMAT_LUMINANCE_ALPHA_UINT8:
+      unpack_int_rgba_LUMINANCE_ALPHA_UINT8(src, dst, n);
+      break;
+   case MESA_FORMAT_LUMINANCE_ALPHA_INT8:
+      unpack_int_rgba_LUMINANCE_ALPHA_INT8(src, dst, n);
+      break;
+
    case MESA_FORMAT_INTENSITY_UINT32:
    case MESA_FORMAT_INTENSITY_INT32:
       unpack_int_rgba_INTENSITY_UINT32(src, dst, n);
       break;
 
+   case MESA_FORMAT_INTENSITY_UINT16:
+      unpack_int_rgba_INTENSITY_UINT16(src, dst, n);
+      break;
+   case MESA_FORMAT_INTENSITY_INT16:
+      unpack_int_rgba_INTENSITY_INT16(src, dst, n);
+      break;
+
+   case MESA_FORMAT_INTENSITY_UINT8:
+      unpack_int_rgba_INTENSITY_UINT8(src, dst, n);
+      break;
+   case MESA_FORMAT_INTENSITY_INT8:
+      unpack_int_rgba_INTENSITY_INT8(src, dst, n);
+      break;
+
    case MESA_FORMAT_ARGB2101010_UINT:
       unpack_int_rgba_ARGB2101010_UINT(src, dst, n);
       break;




More information about the mesa-commit mailing list