[Mesa-dev] [PATCH] format_unpack: add 8/16 rgba/rgb types.

Dave Airlie airlied at gmail.com
Sun Nov 27 12:54:34 PST 2011


From: Dave Airlie <airlied at redhat.com>

fixing these makes piglit fbo-integer pass on softpipe.

Signed-off-by: Dave Airlie <airlied at redhat.com>
---
 src/mesa/main/format_unpack.c |  135 +++++++++++++++++++++++++++++++++++++++++
 1 files changed, 135 insertions(+), 0 deletions(-)

diff --git a/src/mesa/main/format_unpack.c b/src/mesa/main/format_unpack.c
index 2d2e6a8..a6f0ad0 100644
--- a/src/mesa/main/format_unpack.c
+++ b/src/mesa/main/format_unpack.c
@@ -1572,6 +1572,58 @@ unpack_int_rgba_RGBA_UINT32(const GLuint *src, GLuint dst[][4], GLuint n)
 }
 
 static void
+unpack_int_rgba_RGBA_UINT8(const GLubyte *src, GLuint dst[][4], GLuint n)
+{
+   unsigned int i;
+
+   for (i = 0; i < n; i++) {
+      dst[i][0] = src[i * 4 + 0];
+      dst[i][1] = src[i * 4 + 1];
+      dst[i][2] = src[i * 4 + 2];
+      dst[i][3] = src[i * 4 + 3];
+   }
+}
+
+static void
+unpack_int_rgba_RGBA_INT8(const GLbyte *src, GLuint dst[][4], GLuint n)
+{
+   unsigned int i;
+
+   for (i = 0; i < n; i++) {
+      dst[i][0] = src[i * 4 + 0];
+      dst[i][1] = src[i * 4 + 1];
+      dst[i][2] = src[i * 4 + 2];
+      dst[i][3] = src[i * 4 + 3];
+   }
+}
+
+static void
+unpack_int_rgba_RGBA_UINT16(const GLushort *src, GLuint dst[][4], GLuint n)
+{
+   unsigned int i;
+
+   for (i = 0; i < n; i++) {
+      dst[i][0] = src[i * 4 + 0];
+      dst[i][1] = src[i * 4 + 1];
+      dst[i][2] = src[i * 4 + 2];
+      dst[i][3] = src[i * 4 + 3];
+   }
+}
+
+static void
+unpack_int_rgba_RGBA_INT16(const GLshort *src, GLuint dst[][4], GLuint n)
+{
+   unsigned int i;
+
+   for (i = 0; i < n; i++) {
+      dst[i][0] = src[i * 4 + 0];
+      dst[i][1] = src[i * 4 + 1];
+      dst[i][2] = src[i * 4 + 2];
+      dst[i][3] = src[i * 4 + 3];
+   }
+}
+
+static void
 unpack_int_rgba_RGB_UINT32(const GLuint *src, GLuint dst[][4], GLuint n)
 {
    unsigned int i;
@@ -1585,6 +1637,59 @@ unpack_int_rgba_RGB_UINT32(const GLuint *src, GLuint dst[][4], GLuint n)
 }
 
 static void
+unpack_int_rgba_RGB_UINT16(const GLushort *src, GLuint dst[][4], GLuint n)
+{
+   unsigned int i;
+
+   for (i = 0; i < n; i++) {
+      dst[i][0] = src[i * 3 + 0];
+      dst[i][1] = src[i * 3 + 1];
+      dst[i][2] = src[i * 3 + 2];
+      dst[i][3] = 1;
+   }
+}
+
+static void
+unpack_int_rgba_RGB_INT16(const GLshort *src, GLuint dst[][4], GLuint n)
+{
+   unsigned int i;
+
+   for (i = 0; i < n; i++) {
+      dst[i][0] = src[i * 3 + 0];
+      dst[i][1] = src[i * 3 + 1];
+      dst[i][2] = src[i * 3 + 2];
+      dst[i][3] = 1;
+   }
+}
+
+static void
+unpack_int_rgba_RGB_UINT8(const GLubyte *src, GLuint dst[][4], GLuint n)
+{
+   unsigned int i;
+
+   for (i = 0; i < n; i++) {
+      dst[i][0] = src[i * 3 + 0];
+      dst[i][1] = src[i * 3 + 1];
+      dst[i][2] = src[i * 3 + 2];
+      dst[i][3] = 1;
+   }
+}
+
+
+static void
+unpack_int_rgba_RGB_INT8(const GLbyte *src, GLuint dst[][4], GLuint n)
+{
+   unsigned int i;
+
+   for (i = 0; i < n; i++) {
+      dst[i][0] = src[i * 3 + 0];
+      dst[i][1] = src[i * 3 + 1];
+      dst[i][2] = src[i * 3 + 2];
+      dst[i][3] = 1;
+   }
+}
+
+static void
 unpack_int_rgba_RG_UINT32(const GLuint *src, GLuint dst[][4], GLuint n)
 {
    unsigned int i;
@@ -1668,10 +1773,40 @@ _mesa_unpack_int_rgba_row(gl_format format, GLuint n,
    case MESA_FORMAT_RGBA_INT32:
       unpack_int_rgba_RGBA_UINT32(src, dst, n);
       break;
+
+   case MESA_FORMAT_RGBA_UINT8:
+      unpack_int_rgba_RGBA_UINT8(src, dst, n);
+      break;
+   case MESA_FORMAT_RGBA_INT8:
+      unpack_int_rgba_RGBA_INT8(src, dst, n);
+      break;
+
+   case MESA_FORMAT_RGBA_UINT16:
+      unpack_int_rgba_RGBA_UINT16(src, dst, n);
+      break;
+   case MESA_FORMAT_RGBA_INT16:
+      unpack_int_rgba_RGBA_INT16(src, dst, n);
+      break;
+
    case MESA_FORMAT_RGB_UINT32:
    case MESA_FORMAT_RGB_INT32:
       unpack_int_rgba_RGB_UINT32(src, dst, n);
       break;
+
+   case MESA_FORMAT_RGB_UINT8:
+      unpack_int_rgba_RGB_UINT8(src, dst, n);
+      break;
+   case MESA_FORMAT_RGB_INT8:
+      unpack_int_rgba_RGB_INT8(src, dst, n);
+      break;
+
+   case MESA_FORMAT_RGB_UINT16:
+      unpack_int_rgba_RGB_UINT16(src, dst, n);
+      break;
+   case MESA_FORMAT_RGB_INT16:
+      unpack_int_rgba_RGB_INT16(src, dst, n);
+      break;
+
    case MESA_FORMAT_RG_UINT32:
    case MESA_FORMAT_RG_INT32:
       unpack_int_rgba_RG_UINT32(src, dst, n);
-- 
1.7.7.3



More information about the mesa-dev mailing list