From d7477ad0a38a178d1e03f8064ee8245b46e24f1e Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Fri, 7 Oct 2011 08:14:46 -0600 Subject: mesa: fix image unpacking when storing compressed textures This fixes failures found with the new piglit texsubimage test. Two things were broken: 1. The dxt code doesn't handle sources images where width != row stride. Check for that and take the _mesa_make_temp_ubyte_image() path to get an image where width = rowstride. 2. If we don't take the _mesa_make_temp_ubyte_image() path we need to take the source image unpacking parameters into account in order to get the proper starting memory address of the source texels. Note: This is a candidate for the 7.11 branch. --- src/mesa/main/texcompress_fxt1.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'src/mesa/main/texcompress_fxt1.c') diff --git a/src/mesa/main/texcompress_fxt1.c b/src/mesa/main/texcompress_fxt1.c index b6d8ae01655..41630a47c64 100644 --- a/src/mesa/main/texcompress_fxt1.c +++ b/src/mesa/main/texcompress_fxt1.c @@ -76,6 +76,7 @@ _mesa_texstore_rgb_fxt1(TEXSTORE_PARAMS) if (srcFormat != GL_RGB || srcType != GL_UNSIGNED_BYTE || ctx->_ImageTransferState || + srcPacking->RowLength != srcWidth || srcPacking->SwapBytes) { /* convert image to RGB/GLubyte */ tempImage = _mesa_make_temp_ubyte_image(ctx, dims, @@ -91,7 +92,9 @@ _mesa_texstore_rgb_fxt1(TEXSTORE_PARAMS) srcFormat = GL_RGB; } else { - pixels = (const GLubyte *) srcAddr; + pixels = _mesa_image_address2d(srcPacking, srcAddr, srcWidth, srcHeight, + srcFormat, srcType, 0, 0); + srcRowStride = _mesa_image_row_stride(srcPacking, srcWidth, srcFormat, srcType) / sizeof(GLubyte); } @@ -146,7 +149,9 @@ _mesa_texstore_rgba_fxt1(TEXSTORE_PARAMS) srcFormat = GL_RGBA; } else { - pixels = (const GLubyte *) srcAddr; + pixels = _mesa_image_address2d(srcPacking, srcAddr, srcWidth, srcHeight, + srcFormat, srcType, 0, 0); + srcRowStride = _mesa_image_row_stride(srcPacking, srcWidth, srcFormat, srcType) / sizeof(GLubyte); } -- cgit v1.2.3