i915: Fix driver for the miptree x/y offset changes.
authorEric Anholt <eric@anholt.net>
Tue, 27 Oct 2009 17:26:09 +0000 (10:26 -0700)
committerBrian Paul <brianp@vmware.com>
Tue, 27 Oct 2009 23:00:30 +0000 (17:00 -0600)
Bug #24734.

src/mesa/drivers/dri/i915/i830_texstate.c
src/mesa/drivers/dri/i915/i915_texstate.c

index f270a1378126fb7fc405e93f702c9573a5d26577..20ff46b0b0cd1021a3c303b8181482829563beee 100644 (file)
@@ -160,10 +160,18 @@ i830_update_tex_unit(struct intel_context *intel, GLuint unit, GLuint ss3)
 
       pitch = intelObj->pitchOverride;
    } else {
+      GLuint dst_x, dst_y;
+
+      intel_miptree_get_image_offset(intelObj->mt, intelObj->firstLevel, 0, 0,
+                                    &dst_x, &dst_y);
+
       dri_bo_reference(intelObj->mt->region->buffer);
       i830->state.tex_buffer[unit] = intelObj->mt->region->buffer;
-      i830->state.tex_offset[unit] =
-         intel_miptree_image_offset(intelObj->mt, 0, intelObj->firstLevel, 0);
+      /* XXX: This calculation is probably broken for tiled images with
+       * a non-page-aligned offset.
+       */
+      i830->state.tex_offset[unit] = (dst_x + dst_y * intelObj->mt->pitch) *
+        intelObj->mt->cpp;
 
       format = translate_texture_format(firstImage->TexFormat->MesaFormat,
                                        firstImage->InternalFormat);
index b2f82f5655110cb55ce71d2faec5bfdbbc5fecad..998a04f7949f05011c4616ea6e623a508116513d 100644 (file)
@@ -171,10 +171,18 @@ i915_update_tex_unit(struct intel_context *intel, GLuint unit, GLuint ss3)
 
       pitch = intelObj->pitchOverride;
    } else {
+      GLuint dst_x, dst_y;
+
+      intel_miptree_get_image_offset(intelObj->mt, intelObj->firstLevel, 0, 0,
+                                    &dst_x, &dst_y);
+
       dri_bo_reference(intelObj->mt->region->buffer);
       i915->state.tex_buffer[unit] = intelObj->mt->region->buffer;
-      i915->state.tex_offset[unit] =
-         intel_miptree_image_offset(intelObj->mt, 0, intelObj->firstLevel, 0);
+      /* XXX: This calculation is probably broken for tiled images with
+       * a non-page-aligned offset.
+       */
+      i915->state.tex_offset[unit] = (dst_x + dst_y * intelObj->mt->pitch) *
+        intelObj->mt->cpp;
 
       format = translate_texture_format(firstImage->TexFormat->MesaFormat, 
                                        firstImage->InternalFormat,