[Mesa-dev] [PATCH 3/6] mesa: handle SwapBytes in uncompressed get texture paths properly
Dave Airlie
airlied at gmail.com
Tue Aug 25 18:14:52 PDT 2015
This code wasn't handling the 7-width/GL_RED/GL_BYTE case where
GL_PACK_ALIGNMENT was set to 4. This fixes it to iterate
on a row by row basis over the image instead, and avoids
accessing uninitialised memory.
Signed-off-by: Dave Airlie <airlied at redhat.com>
---
src/mesa/main/texgetimage.c | 15 +++++++++++----
1 file changed, 11 insertions(+), 4 deletions(-)
diff --git a/src/mesa/main/texgetimage.c b/src/mesa/main/texgetimage.c
index f62553d..872274e 100644
--- a/src/mesa/main/texgetimage.c
+++ b/src/mesa/main/texgetimage.c
@@ -561,11 +561,18 @@ get_tex_rgba_uncompressed(struct gl_context *ctx, GLuint dimensions,
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);
- if (swapSize == 2)
- _mesa_swap2((GLushort *) dest, width * height * swapsPerPixel);
- else if (swapSize == 4)
- _mesa_swap4((GLuint *) dest, width * height * swapsPerPixel);
+ 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;
+ }
}
}
--
2.4.3
More information about the mesa-dev
mailing list