[Mesa-dev] [PATCH 4/6] mesa: handle SwapBytes in compressed texture get code.
Dave Airlie
airlied at gmail.com
Tue Aug 25 18:14:53 PDT 2015
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 <airlied at 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
More information about the mesa-dev
mailing list