This case just wasn't handled, so add support for row by
row swapping when we've decompressed the texture.

Signed-off-by: Dave Airlie <airl...@redhat.com>
---
 src/mesa/main/texgetimage.c | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)

diff --git a/src/mesa/main/texgetimage.c b/src/mesa/main/texgetimage.c
index 872274e..25fa84c 100644
--- a/src/mesa/main/texgetimage.c
+++ b/src/mesa/main/texgetimage.c
@@ -361,6 +361,25 @@ get_tex_rgba_compressed(struct gl_context *ctx, GLuint 
dimensions,
                            tempSlice, RGBA32_FLOAT, srcStride,
                            width, height,
                            needsRebase ? rebaseSwizzle : NULL);
+      /* Handle byte swapping if required */
+      if (ctx->Pack.SwapBytes) {
+         GLint swapSize = _mesa_sizeof_packed_type(type);
+         if (swapSize == 2 || swapSize == 4) {
+            int swapsPerPixel = _mesa_bytes_per_pixel(format, type) / swapSize;
+            int stride = _mesa_image_row_stride(&ctx->Pack, width, format, 
type);
+            int row;
+            const uint8_t *dstrow;
+            assert(_mesa_bytes_per_pixel(format, type) % swapSize == 0);
+            dstrow = dest;
+            for (row = 0; row < height; row++) {
+               if (swapSize == 2)
+                  _mesa_swap2((GLushort *) dstrow, width * swapsPerPixel);
+               else if (swapSize == 4)
+                  _mesa_swap4((GLuint *) dstrow, width * swapsPerPixel);
+               dstrow += stride;
+            }
+         }
+      }
       tempSlice += 4 * width * height;
    }
 
-- 
2.4.3

_______________________________________________
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev

Reply via email to