Mesa (mesa_7_7_branch): radeon: fix glCompressedTexSubImage

Maciej Cencora osiris at kemper.freedesktop.org
Sat Nov 21 07:49:52 PST 2009


Module: Mesa
Branch: mesa_7_7_branch
Commit: 1d1f81af93058541992bd0795b86500509edea56
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=1d1f81af93058541992bd0795b86500509edea56

Author: Maciej Cencora <m.cencora at gmail.com>
Date:   Sat Nov 21 15:56:02 2009 +0100

radeon: fix glCompressedTexSubImage

---

 src/mesa/drivers/dri/radeon/radeon_texture.c |   22 ++++++++++++----------
 1 files changed, 12 insertions(+), 10 deletions(-)

diff --git a/src/mesa/drivers/dri/radeon/radeon_texture.c b/src/mesa/drivers/dri/radeon/radeon_texture.c
index 6f11f1f..1ee9e27 100644
--- a/src/mesa/drivers/dri/radeon/radeon_texture.c
+++ b/src/mesa/drivers/dri/radeon/radeon_texture.c
@@ -582,12 +582,12 @@ static void radeon_store_teximage(GLcontext* ctx, int dims,
 		/* TODO */
 		assert(0);
 	} else {
-		dstRowStride = _mesa_format_row_stride(texImage->TexFormat, width);
+		dstRowStride = _mesa_format_row_stride(texImage->TexFormat, texImage->Width);
 	}
 
 	if (dims == 3) {
 		unsigned alignedWidth = dstRowStride/_mesa_get_format_bytes(texImage->TexFormat);
-		dstImageOffsets = allocate_image_offsets(ctx, alignedWidth, height, depth);
+		dstImageOffsets = allocate_image_offsets(ctx, alignedWidth, texImage->Height, texImage->Depth);
 		if (!dstImageOffsets) {
 			return;
 		}
@@ -598,8 +598,11 @@ static void radeon_store_teximage(GLcontext* ctx, int dims,
 	radeon_teximage_map(image, GL_TRUE);
 
 	if (compressed) {
-		uint32_t srcRowStride, bytesPerRow, rows;
+		uint32_t srcRowStride, bytesPerRow, rows, block_width, block_height;
 		GLubyte *img_start;
+
+		_mesa_get_format_block_size(texImage->TexFormat, &block_width, &block_height);
+
 		if (!image->mt) {
 			dstRowStride = _mesa_format_row_stride(texImage->TexFormat, texImage->Width);
 			img_start = _mesa_compressed_image_address(xoffset, yoffset, 0,
@@ -607,17 +610,16 @@ static void radeon_store_teximage(GLcontext* ctx, int dims,
 									texImage->Width, texImage->Data);
 		}
 		else {
-			uint32_t blocks_x, block_width, block_height;
-			_mesa_get_format_block_size(image->mt->mesaFormat, &block_width, &block_height);
-			blocks_x = dstRowStride / block_width;
-			img_start = texImage->Data + _mesa_get_format_bytes(image->mt->mesaFormat) * 4 * (blocks_x * (yoffset / 4) + xoffset / 4);
+			uint32_t offset;
+			offset = dstRowStride / _mesa_get_format_bytes(texImage->TexFormat) * yoffset / block_height + xoffset / block_width;
+			offset *= _mesa_get_format_bytes(texImage->TexFormat);
+			img_start = texImage->Data + offset;
 		}
 		srcRowStride = _mesa_format_row_stride(texImage->TexFormat, width);
 		bytesPerRow = srcRowStride;
-		rows = (height + 3) / 4;
-
-		copy_rows(img_start, dstRowStride,  pixels, srcRowStride, rows,  bytesPerRow);
+		rows = (height + block_height - 1) / block_height;
 
+		copy_rows(img_start, dstRowStride, pixels, srcRowStride, rows, bytesPerRow);
 	}
 	else {
 		if (!_mesa_texstore(ctx, dims, texImage->_BaseFormat,



More information about the mesa-commit mailing list