Mesa (master): Fix compressed texture loads for non-minimal pitches

Keith Whitwell keithw at kemper.freedesktop.org
Mon Jan 11 10:57:04 UTC 2010


Module: Mesa
Branch: master
Commit: eea6a7639f767b1d30b6ef1f91a9c49e3f3b78f0
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=eea6a7639f767b1d30b6ef1f91a9c49e3f3b78f0

Author: Luca Barbieri <luca at luca-barbieri.com>
Date:   Sun Jan 10 12:04:21 2010 -0800

Fix compressed texture loads for non-minimal pitches

The current glCompressedTexImage support in the state tracker assumes
that compressed textures have minimal pitch.

However, in some cases this is not true, such as for mipmaps of non-POT
compressed textures on nVidia hardware.

This patch adds a check and does a memcpy for each line instead of the
whole image in that case.

Signed-off-by: Keith Whitwell <keithw at vmware.com>

Tweaks for C90 compilation.

---

 src/mesa/state_tracker/st_cb_texture.c |   17 ++++++++++++++++-
 1 files changed, 16 insertions(+), 1 deletions(-)

diff --git a/src/mesa/state_tracker/st_cb_texture.c b/src/mesa/state_tracker/st_cb_texture.c
index 0cec23f..f01053c 100644
--- a/src/mesa/state_tracker/st_cb_texture.c
+++ b/src/mesa/state_tracker/st_cb_texture.c
@@ -680,7 +680,22 @@ st_TexImage(GLcontext * ctx,
     * conversion and copy:
     */
    if (compressed_src) {
-      memcpy(texImage->Data, pixels, imageSize);
+      const GLuint srcImageStride = _mesa_format_row_stride(texImage->TexFormat, width);
+      if(dstRowStride == srcImageStride)
+         memcpy(texImage->Data, pixels, imageSize);
+      else
+      {
+         char *dst = texImage->Data;
+         const char *src = pixels;
+         int i;
+
+         for(i = 0; i < height; ++i)
+         {
+            memcpy(dst, src, srcImageStride);
+            dst += dstRowStride;
+            src += srcImageStride;
+         }
+      }
    }
    else {
       const GLuint srcImageStride =




More information about the mesa-commit mailing list