summaryrefslogtreecommitdiffstats
path: root/src/mesa/main/texgetimage.c
diff options
context:
space:
mode:
authorDave Airlie <airlied@redhat.com>2015-08-25 14:36:01 +1000
committerDave Airlie <airlied@redhat.com>2015-09-02 09:16:43 +1000
commit0ad3a475ef81dad3baf607d749b91dfa1700ca23 (patch)
treea9232bc66a31900353ab3d0a1135333c8b6f9299 /src/mesa/main/texgetimage.c
parent60aea3011525de8bf6506e08c913cbe24cc17767 (diff)
downloadexternal_mesa3d-0ad3a475ef81dad3baf607d749b91dfa1700ca23.zip
external_mesa3d-0ad3a475ef81dad3baf607d749b91dfa1700ca23.tar.gz
external_mesa3d-0ad3a475ef81dad3baf607d749b91dfa1700ca23.tar.bz2
mesa: fix SwapBytes handling in numerous places
In a number of places the SwapBytes handling didn't handle cases with GL_(UN)PACK_ALIGNMENT set and 7 byte width cases aligned to 8 bytes. This adds a common routine to swap bytes a 2D image and uses this code in: texture storage texture get readpixels swrast drawpixels. [airlied: updated with Brian's nitpicks]. Cc: "11.0" <mesa-stable@lists.freedesktop.org> Reviewed-by: Brian Paul <brianp@vmware.com> Signed-off-by: Dave Airlie <airlied@redhat.com>
Diffstat (limited to 'src/mesa/main/texgetimage.c')
-rw-r--r--src/mesa/main/texgetimage.c14
1 files changed, 3 insertions, 11 deletions
diff --git a/src/mesa/main/texgetimage.c b/src/mesa/main/texgetimage.c
index f62553d..a1fd338 100644
--- a/src/mesa/main/texgetimage.c
+++ b/src/mesa/main/texgetimage.c
@@ -557,17 +557,9 @@ get_tex_rgba_uncompressed(struct gl_context *ctx, GLuint dimensions,
do_swap:
/* 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;
- assert(_mesa_bytes_per_pixel(format, type) % swapSize == 0);
- if (swapSize == 2)
- _mesa_swap2((GLushort *) dest, width * height * swapsPerPixel);
- else if (swapSize == 4)
- _mesa_swap4((GLuint *) dest, width * height * swapsPerPixel);
- }
- }
+ if (ctx->Pack.SwapBytes)
+ _mesa_swap_bytes_2d_image(format, type, &ctx->Pack,
+ width, height, dest, dest);
/* Unmap the src texture buffer */
ctx->Driver.UnmapTextureImage(ctx, texImage, zoffset + img);