mesa/pack: don't apply transfer operations to integer format buffers. (v3)
authorDave Airlie <airlied@redhat.com>
Mon, 12 Sep 2011 13:44:25 +0000 (14:44 +0100)
committerDave Airlie <airlied@redhat.com>
Tue, 13 Sep 2011 08:43:23 +0000 (09:43 +0100)
The EXT_texture_integer issues says:

Should pixel transfer operations be defined for the integer pixel
path?

RESOLVED: No.  Fragment shaders can achieve similar results
with more flexibility.  There is no need to aggrandize this
legacy mechanism.

v2: fix comments, fix unpack paths, use same comment/code
v3: fix last comment

Signed-off-by: Dave Airlie <airlied@redhat.com>
Reviewed-by: Brian Paul <brianp@vmware.com>
src/mesa/main/pack.c

index fd3f89d..8388708 100644 (file)
@@ -506,6 +506,13 @@ _mesa_pack_rgba_span_float(struct gl_context *ctx, GLuint n, GLfloat rgba[][4],
       luminance = NULL;
    }
 
+   /* EXT_texture_integer specifies no transfer ops on integer
+    * types in the resolved issues section. Just set them to 0
+    * for integer surfaces.
+    */
+   if (intDstFormat)
+      transferOps = 0;
+
    if (transferOps) {
       _mesa_apply_rgba_transfer_ops(ctx, transferOps, n, rgba);
    }
@@ -3452,6 +3459,7 @@ _mesa_unpack_color_span_chan( struct gl_context *ctx,
                               const struct gl_pixelstore_attrib *srcPacking,
                               GLbitfield transferOps )
 {
+   GLboolean intFormat = _mesa_is_integer_format(srcFormat);
    ASSERT(dstFormat == GL_ALPHA ||
           dstFormat == GL_LUMINANCE ||
           dstFormat == GL_LUMINANCE_ALPHA ||
@@ -3500,6 +3508,13 @@ _mesa_unpack_color_span_chan( struct gl_context *ctx,
           srcType == GL_UNSIGNED_INT_5_9_9_9_REV ||
           srcType == GL_UNSIGNED_INT_10F_11F_11F_REV);
 
+   /* EXT_texture_integer specifies no transfer ops on integer
+    * types in the resolved issues section. Just set them to 0
+    * for integer surfaces.
+    */
+   if (intFormat)
+      transferOps = 0;
+
    /* Try simple cases first */
    if (transferOps == 0) {
       if (srcType == CHAN_TYPE) {
@@ -3815,6 +3830,7 @@ _mesa_unpack_color_span_float( struct gl_context *ctx,
       GLint dstComponents;
       GLint rDst, gDst, bDst, aDst, lDst, iDst;
       GLfloat (*rgba)[4] = (GLfloat (*)[4]) malloc(4 * n * sizeof(GLfloat));
+      GLboolean intFormat = _mesa_is_integer_format(srcFormat);
 
       if (!rgba) {
          _mesa_error(ctx, GL_OUT_OF_MEMORY, "pixel unpacking");
@@ -3825,6 +3841,13 @@ _mesa_unpack_color_span_float( struct gl_context *ctx,
       /* source & dest image formats should have been error checked by now */
       assert(dstComponents > 0);
 
+      /* EXT_texture_integer specifies no transfer ops on integer
+       * types in the resolved issues section. Just set them to 0
+       * for integer surfaces.
+       */
+      if (intFormat)
+         transferOps = 0;
+
       /*
        * Extract image data and convert to RGBA floats
        */