Fix compressed texture loads for non-minimal pitches again
authorLuca Barbieri <luca@luca-barbieri.com>
Wed, 20 Jan 2010 01:39:27 +0000 (17:39 -0800)
committerBrian Paul <brianp@vmware.com>
Mon, 25 Jan 2010 15:11:49 +0000 (08:11 -0700)
My commit eea6a7639f767b1d30b6ef1f91a9c49e3f3b78f0 does a memcpy of height
lines, but that's wrong because the texture has a block layout and we
must thus use the number of vertical blocks instead of the height.

Signed-off-by: Brian Paul <brianp@vmware.com>
src/mesa/state_tracker/st_cb_texture.c

index b94bfc853880556a4a8c3d30fc60a835523063c7..cee2452eafee47e5164b610b5f34d00eae05dd76 100644 (file)
@@ -686,9 +686,11 @@ st_TexImage(GLcontext * ctx,
       {
          char *dst = texImage->Data;
          const char *src = pixels;
-         int i;
+         GLuint i, bw, bh, lines;
+         _mesa_get_format_block_size(texImage->TexFormat, &bw, &bh);
+         lines = (height + bh - 1) / bh;
 
-         for(i = 0; i < height; ++i)
+         for(i = 0; i < lines; ++i)
          {
             memcpy(dst, src, srcImageStride);
             dst += dstRowStride;