From 9d7698c468f4ea7da8bb4ec00520c98f11cca0fa Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Marek=20Ol=C5=A1=C3=A1k?= <maraeo@gmail.com>
Date: Tue, 26 Apr 2011 02:18:24 +0200
Subject: mesa: implement EXT_texture_shared_exponent

swrast support done.

There is no renderbuffer support in swrast, because it's not required
by the extension.

Reviewed-by: Brian Paul <brianp@vmware.com>
---
 src/mesa/main/pack.c | 82 ++++++++++++++++++++++++++++++++++++++++++++++++----
 1 file changed, 77 insertions(+), 5 deletions(-)

(limited to 'src/mesa/main/pack.c')

diff --git a/src/mesa/main/pack.c b/src/mesa/main/pack.c
index ad8ab9d..37608f2 100644
--- a/src/mesa/main/pack.c
+++ b/src/mesa/main/pack.c
@@ -37,6 +37,8 @@
 #include "mtypes.h"
 #include "pack.h"
 #include "pixeltransfer.h"
+#include "imports.h"
+#include "rgb9e5.h"
 
 
 /**
@@ -1892,6 +1894,14 @@ _mesa_pack_rgba_span_float(struct gl_context *ctx, GLuint n, GLfloat rgba[][4],
             }
          }
          break;
+      case GL_UNSIGNED_INT_5_9_9_9_REV:
+         {
+            GLuint *dst = (GLuint *) dstAddr;
+            for (i = 0; i < n; i++) {
+               dst[i] = float3_to_rgb9e5(rgba[i]);
+            }
+         }
+         break;
       default:
          _mesa_problem(ctx, "bad type in _mesa_pack_rgba_span_float");
          return;
@@ -2330,7 +2340,8 @@ extract_float_rgba(GLuint n, GLfloat rgba[][4],
           srcType == GL_UNSIGNED_INT_8_8_8_8 ||
           srcType == GL_UNSIGNED_INT_8_8_8_8_REV ||
           srcType == GL_UNSIGNED_INT_10_10_10_2 ||
-          srcType == GL_UNSIGNED_INT_2_10_10_10_REV);
+          srcType == GL_UNSIGNED_INT_2_10_10_10_REV ||
+          srcType == GL_UNSIGNED_INT_5_9_9_9_REV);
 
    get_component_mapping(srcFormat,
                          &rSrc, &gSrc, &bSrc, &aSrc,
@@ -2800,6 +2811,34 @@ extract_float_rgba(GLuint n, GLfloat rgba[][4],
             }
          }
          break;
+      case GL_UNSIGNED_INT_5_9_9_9_REV:
+         if (swapBytes) {
+            const GLuint *uisrc = (const GLuint *) src;
+            GLuint i;
+            GLfloat f[3];
+            for (i = 0; i < n; i ++) {
+               GLuint p = uisrc[i];
+               SWAP4BYTE(p);
+               rgb9e5_to_float3(p, f);
+               rgba[i][rDst] = f[0];
+               rgba[i][gDst] = f[1];
+               rgba[i][bDst] = f[2];
+               rgba[i][aDst] = 1.0F;
+            }
+         }
+         else {
+            const GLuint *uisrc = (const GLuint *) src;
+            GLuint i;
+            GLfloat f[3];
+            for (i = 0; i < n; i ++) {
+               rgb9e5_to_float3(uisrc[i], f);
+               rgba[i][rDst] = f[0];
+               rgba[i][gDst] = f[1];
+               rgba[i][bDst] = f[2];
+               rgba[i][aDst] = 1.0F;
+            }
+         }
+         break;
       default:
          _mesa_problem(NULL, "bad srcType in extract float data");
          break;
@@ -2902,7 +2941,8 @@ extract_uint_rgba(GLuint n, GLuint rgba[][4],
           srcType == GL_UNSIGNED_INT_8_8_8_8 ||
           srcType == GL_UNSIGNED_INT_8_8_8_8_REV ||
           srcType == GL_UNSIGNED_INT_10_10_10_2 ||
-          srcType == GL_UNSIGNED_INT_2_10_10_10_REV);
+          srcType == GL_UNSIGNED_INT_2_10_10_10_REV ||
+          srcType == GL_UNSIGNED_INT_5_9_9_9_REV);
 
    get_component_mapping(srcFormat,
                          &rSrc, &gSrc, &bSrc, &aSrc,
@@ -3266,6 +3306,35 @@ extract_uint_rgba(GLuint n, GLuint rgba[][4],
             }
          }
          break;
+      case GL_UNSIGNED_INT_5_9_9_9_REV:
+         if (swapBytes) {
+            const GLuint *uisrc = (const GLuint *) src;
+            GLuint i;
+            float f[3];
+            for (i = 0; i < n; i ++) {
+               GLuint p = uisrc[i];
+               SWAP4BYTE(p);
+               rgb9e5_to_float3(p, f);
+               rgba[i][rDst] = clamp_float_to_uint(f[0]);
+               rgba[i][gDst] = clamp_float_to_uint(f[1]);
+               rgba[i][bDst] = clamp_float_to_uint(f[2]);
+               rgba[i][aDst] = 1;
+            }
+         }
+         else {
+            const GLuint *uisrc = (const GLuint *) src;
+            GLuint i;
+            float f[3];
+            for (i = 0; i < n; i ++) {
+               GLuint p = uisrc[i];
+               rgb9e5_to_float3(p, f);
+               rgba[i][rDst] = clamp_float_to_uint(f[0]);
+               rgba[i][gDst] = clamp_float_to_uint(f[1]);
+               rgba[i][bDst] = clamp_float_to_uint(f[2]);
+               rgba[i][aDst] = 1;
+            }
+         }
+         break;
       default:
          _mesa_problem(NULL, "bad srcType in extract uint data");
          break;
@@ -3345,7 +3414,8 @@ _mesa_unpack_color_span_chan( struct gl_context *ctx,
           srcType == GL_UNSIGNED_INT_8_8_8_8 ||
           srcType == GL_UNSIGNED_INT_8_8_8_8_REV ||
           srcType == GL_UNSIGNED_INT_10_10_10_2 ||
-          srcType == GL_UNSIGNED_INT_2_10_10_10_REV);
+          srcType == GL_UNSIGNED_INT_2_10_10_10_REV ||
+          srcType == GL_UNSIGNED_INT_5_9_9_9_REV);
 
    /* Try simple cases first */
    if (transferOps == 0) {
@@ -3667,7 +3737,8 @@ _mesa_unpack_color_span_float( struct gl_context *ctx,
           srcType == GL_UNSIGNED_INT_8_8_8_8 ||
           srcType == GL_UNSIGNED_INT_8_8_8_8_REV ||
           srcType == GL_UNSIGNED_INT_10_10_10_2 ||
-          srcType == GL_UNSIGNED_INT_2_10_10_10_REV);
+          srcType == GL_UNSIGNED_INT_2_10_10_10_REV ||
+          srcType == GL_UNSIGNED_INT_5_9_9_9_REV);
 
    /* general solution, no special cases, yet */
    {
@@ -3873,7 +3944,8 @@ _mesa_unpack_color_span_uint(struct gl_context *ctx,
           srcType == GL_UNSIGNED_INT_8_8_8_8 ||
           srcType == GL_UNSIGNED_INT_8_8_8_8_REV ||
           srcType == GL_UNSIGNED_INT_10_10_10_2 ||
-          srcType == GL_UNSIGNED_INT_2_10_10_10_REV);
+          srcType == GL_UNSIGNED_INT_2_10_10_10_REV ||
+          srcType == GL_UNSIGNED_INT_5_9_9_9_REV);
 
 
    /* Extract image data as uint[4] pixels */
-- 
cgit v1.1