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

Author: Eric Anholt <[email protected]>
Date:   Wed Jun  8 16:38:01 2011 -0700

intel: Fix 2x2 and 1x1 compressed teximages from _mesa_generate_mipmap()

Generally image uploads to a the region occur at TexImage time, but
that's not the case for fallback _mesa_generate_mipmap(), and in this
path we were forgetting to align the width when dividing height.  We
were just leaving out parts of the compressed block at 2x2 and 1x1
levels.

Fixes gen-compressed-teximage.

---

 src/mesa/drivers/dri/intel/intel_mipmap_tree.c |   17 ++++++++++++-----
 1 files changed, 12 insertions(+), 5 deletions(-)

diff --git a/src/mesa/drivers/dri/intel/intel_mipmap_tree.c 
b/src/mesa/drivers/dri/intel/intel_mipmap_tree.c
index e62905d..55eb9a1 100644
--- a/src/mesa/drivers/dri/intel/intel_mipmap_tree.c
+++ b/src/mesa/drivers/dri/intel/intel_mipmap_tree.c
@@ -389,26 +389,33 @@ intel_miptree_image_data(struct intel_context *intel,
    GLuint i;
 
    for (i = 0; i < depth; i++) {
-      GLuint dst_x, dst_y, height;
+      GLuint dst_x, dst_y, height, width;
 
       intel_miptree_get_image_offset(dst, level, face, i, &dst_x, &dst_y);
 
       height = dst->level[level].height;
-      if(dst->compressed)
-        height = (height + 3) / 4;
+      width = dst->level[level].width;
+      if (dst->compressed) {
+        unsigned int align_w, align_h;
+
+        intel_get_texture_alignment_unit(dst->internal_format,
+                                         &align_w, &align_h);
+        height = (height + align_h - 1) / align_h;
+        width = ALIGN(width, align_w);
+      }
 
       DBG("%s: %d/%d %p/%d -> (%d, %d)/%d (%d, %d)\n",
          __FUNCTION__, face, level,
          src, src_row_pitch * dst->cpp,
          dst_x, dst_y, dst->region->pitch * dst->cpp,
-         dst->level[level].width, height);
+         width, height);
 
       intel_region_data(intel,
                        dst->region, 0, dst_x, dst_y,
                        src,
                        src_row_pitch,
                        0, 0,                             /* source x, y */
-                       dst->level[level].width, height); /* width, height */
+                       width, height);
 
       src = (char *)src + src_image_pitch * dst->cpp;
    }

_______________________________________________
mesa-commit mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/mesa-commit

Reply via email to