[Mesa-dev] [PATCH 1/2] i965: Check actual tile offsets in Gen4 miptree workaround.

Kenneth Graunke kenneth at whitecape.org
Mon Jul 25 21:13:42 PDT 2011


The apitrace dump in bug #34009 managed to fool the draw_offset check
into thinking that we were tile aligned when we weren't.  This led to an
assertion failure in brw_update_renderbuffer_surface with tile_y != 0.

Simply compute tile_x and tile_y and check those, as that way both
places are checking the same thing.

NOTE: This is a candidate for stable release branches.

Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=34009
Signed-off-by: Kenneth Graunke <kenneth at whitecape.org>
---
 src/mesa/drivers/dri/intel/intel_fbo.c |   53 +++++++++++++++++---------------
 1 files changed, 28 insertions(+), 25 deletions(-)

For reviewers: Most of this patch is simply reindenting the code, as I added
pushed it inside a new if-statement.

diff --git a/src/mesa/drivers/dri/intel/intel_fbo.c b/src/mesa/drivers/dri/intel/intel_fbo.c
index 35be325..6f65e2c 100644
--- a/src/mesa/drivers/dri/intel/intel_fbo.c
+++ b/src/mesa/drivers/dri/intel/intel_fbo.c
@@ -700,8 +700,7 @@ intel_render_texture(struct gl_context * ctx,
    intel_image->used_as_render_target = GL_TRUE;
 
 #ifndef I915
-   if (!brw_context(ctx)->has_surface_tile_offset &&
-       (irb->draw_offset & 4095) != 0) {
+   if (!brw_context(ctx)->has_surface_tile_offset) {
       /* Original gen4 hardware couldn't draw to a non-tile-aligned
        * destination in a miptree unless you actually setup your
        * renderbuffer as a miptree and used the fragile
@@ -709,30 +708,34 @@ intel_render_texture(struct gl_context * ctx,
        * instead, we just make a new single-level miptree and render
        * into that.
        */
-      struct intel_context *intel = intel_context(ctx);
-      struct intel_mipmap_tree *old_mt = intel_image->mt;
-      struct intel_mipmap_tree *new_mt;
-
-      new_mt = intel_miptree_create(intel, image->TexObject->Target,
-				    intel_image->base.TexFormat,
-				    intel_image->level,
-				    intel_image->level,
-				    intel_image->base.Width,
-				    intel_image->base.Height,
-				    intel_image->base.Depth,
-				    GL_TRUE);
-
-      intel_miptree_image_copy(intel,
-                               new_mt,
-                               intel_image->face,
-			       intel_image->level,
-			       old_mt);
-
-      intel_miptree_release(intel, &intel_image->mt);
-      intel_image->mt = new_mt;
-      intel_renderbuffer_set_draw_offset(irb, intel_image, att->Zoffset);
+      uint32_t tile_x, tile_y;
+      intel_renderbuffer_tile_offsets(irb, &tile_x, &tile_y);
+      if (tile_x != 0 || tile_y != 0) {
+	 struct intel_context *intel = intel_context(ctx);
+	 struct intel_mipmap_tree *old_mt = intel_image->mt;
+	 struct intel_mipmap_tree *new_mt;
+
+	 new_mt = intel_miptree_create(intel, image->TexObject->Target,
+				       intel_image->base.TexFormat,
+				       intel_image->level,
+				       intel_image->level,
+				       intel_image->base.Width,
+				       intel_image->base.Height,
+				       intel_image->base.Depth,
+				       GL_TRUE);
 
-      intel_region_reference(&irb->region, intel_image->mt->region);
+	 intel_miptree_image_copy(intel,
+				  new_mt,
+				  intel_image->face,
+				  intel_image->level,
+				  old_mt);
+
+	 intel_miptree_release(intel, &intel_image->mt);
+	 intel_image->mt = new_mt;
+	 intel_renderbuffer_set_draw_offset(irb, intel_image, att->Zoffset);
+
+	 intel_region_reference(&irb->region, intel_image->mt->region);
+      }
    }
 #endif
    /* update drawing region, etc */
-- 
1.7.6



More information about the mesa-dev mailing list