aboutsummaryrefslogtreecommitdiffstats
path: root/src/mesa/main/texstore.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/mesa/main/texstore.c')
-rw-r--r--src/mesa/main/texstore.c28
1 files changed, 17 insertions, 11 deletions
diff --git a/src/mesa/main/texstore.c b/src/mesa/main/texstore.c
index 539402668c4..e50964e79e4 100644
--- a/src/mesa/main/texstore.c
+++ b/src/mesa/main/texstore.c
@@ -727,19 +727,25 @@ texstore_rgba(TEXSTORE_PARAMS)
*/
GLint swapSize = _mesa_sizeof_packed_type(srcType);
if (swapSize == 2 || swapSize == 4) {
- int bytesPerPixel = _mesa_bytes_per_pixel(srcFormat, srcType);
- int swapsPerPixel = bytesPerPixel / swapSize;
- int elementCount = srcWidth * srcHeight * srcDepth;
- assert(bytesPerPixel % swapSize == 0);
- tempImage = malloc(elementCount * bytesPerPixel);
+ int imageStride = _mesa_image_image_stride(srcPacking, srcWidth, srcHeight, srcFormat, srcType);
+ int bufferSize = imageStride * srcDepth;
+ int layer;
+ const uint8_t *src;
+ uint8_t *dst;
+
+ tempImage = malloc(bufferSize);
if (!tempImage)
return GL_FALSE;
- if (swapSize == 2)
- _mesa_swap2_copy(tempImage, (GLushort *) srcAddr,
- elementCount * swapsPerPixel);
- else
- _mesa_swap4_copy(tempImage, (GLuint *) srcAddr,
- elementCount * swapsPerPixel);
+ src = srcAddr;
+ dst = tempImage;
+ for (layer = 0; layer < srcDepth; layer++) {
+ _mesa_swap_bytes_2d_image(srcFormat, srcType,
+ srcPacking,
+ srcWidth, srcHeight,
+ dst, src);
+ src += imageStride;
+ dst += imageStride;
+ }
srcAddr = tempImage;
}
}