i915: Use x,y drawing offsets instead of changing buffer offsets.
authorEric Anholt <eric@anholt.net>
Wed, 3 Mar 2010 02:06:24 +0000 (18:06 -0800)
committerEric Anholt <eric@anholt.net>
Wed, 3 Mar 2010 19:33:37 +0000 (11:33 -0800)
This should fix rendering into mipmaps of tiled textures.

src/mesa/drivers/dri/i915/i915_context.h
src/mesa/drivers/dri/i915/i915_vtbl.c
src/mesa/drivers/dri/i915/intel_tris.c

index 60b357ec28d9f696700828fd731c8e0bde9a5a64..b5169280f6b14cd585cb71288f63e5895a09a67f 100644 (file)
@@ -40,6 +40,7 @@
 #define I915_FALLBACK_POLYGON_SMOOTH    0x40000
 #define I915_FALLBACK_POINT_SMOOTH      0x80000
 #define I915_FALLBACK_POINT_SPRITE_COORD_ORIGIN         0x100000
+#define I915_FALLBACK_DRAW_OFFSET       0x200000
 
 #define I915_UPLOAD_CTX              0x1
 #define I915_UPLOAD_BUFFERS          0x2
index 30aaab78c8f735befa39b26f0b4009299d6efb72..0a93e64b1fa315f2dbb9ee2c74772b71f3dfc7d1 100644 (file)
@@ -378,15 +378,13 @@ i915_emit_state(struct intel_context *intel)
       OUT_BATCH(state->Buffer[I915_DESTREG_CBUFADDR0]);
       OUT_BATCH(state->Buffer[I915_DESTREG_CBUFADDR1]);
       OUT_RELOC(state->draw_region->buffer,
-               I915_GEM_DOMAIN_RENDER, I915_GEM_DOMAIN_RENDER,
-                state->draw_region->draw_offset);
+               I915_GEM_DOMAIN_RENDER, I915_GEM_DOMAIN_RENDER, 0);
 
       if (state->depth_region) {
          OUT_BATCH(state->Buffer[I915_DESTREG_DBUFADDR0]);
          OUT_BATCH(state->Buffer[I915_DESTREG_DBUFADDR1]);
          OUT_RELOC(state->depth_region->buffer,
-                  I915_GEM_DOMAIN_RENDER, I915_GEM_DOMAIN_RENDER,
-                   state->depth_region->draw_offset);
+                  I915_GEM_DOMAIN_RENDER, I915_GEM_DOMAIN_RENDER, 0);
       }
 
       OUT_BATCH(state->Buffer[I915_DESTREG_DV0]);
@@ -534,6 +532,7 @@ i915_set_draw_region(struct intel_context *intel,
    struct intel_renderbuffer *irb = intel_renderbuffer(rb);
    GLuint value;
    struct i915_hw_state *state = &i915->state;
+   uint32_t draw_x, draw_y;
 
    if (state->draw_region != color_regions[0]) {
       intel_region_release(&state->draw_region);
@@ -596,14 +595,41 @@ i915_set_draw_region(struct intel_context *intel,
    }
    state->Buffer[I915_DESTREG_DV1] = value;
 
-   state->Buffer[I915_DESTREG_DRAWRECT0] = _3DSTATE_DRAWRECT_INFO;
-   state->Buffer[I915_DESTREG_DRAWRECT1] = 0;
-   state->Buffer[I915_DESTREG_DRAWRECT2] = 0; /* xmin, ymin */
-   state->Buffer[I915_DESTREG_DRAWRECT3] =
-      (ctx->DrawBuffer->Width & 0xffff) |
-      (ctx->DrawBuffer->Height << 16);
-   state->Buffer[I915_DESTREG_DRAWRECT4] = 0; /* xoff, yoff */
-   state->Buffer[I915_DESTREG_DRAWRECT5] = 0;
+   /* We set up the drawing rectangle to be offset into the color
+    * region's location in the miptree.  If it doesn't match with
+    * depth's offsets, we can't render to it.
+    *
+    * (Well, not actually true -- the hw grew a bit to let depth's
+    * offset get forced to 0,0.  We may want to use that if people are
+    * hitting that case.  Also, some configurations may be supportable
+    * by tweaking the start offset of the buffers around, which we
+    * can't do in general due to tiling)
+    */
+   FALLBACK(intel, I915_FALLBACK_DRAW_OFFSET,
+           (depth_region && color_regions[0]) &&
+           (depth_region->draw_x != color_regions[0]->draw_x ||
+            depth_region->draw_y != color_regions[0]->draw_y));
+
+   if (color_regions[0]) {
+      draw_x = color_regions[0]->draw_x;
+      draw_y = color_regions[0]->draw_y;
+   } else if (depth_region) {
+      draw_x = depth_region->draw_x;
+      draw_y = depth_region->draw_y;
+   } else {
+      draw_x = 0;
+      draw_y = 0;
+   }
+
+   /* When changing drawing rectangle offset, an MI_FLUSH is first required. */
+   state->Buffer[I915_DESTREG_DRAWRECT0] = MI_FLUSH;
+   state->Buffer[I915_DESTREG_DRAWRECT1] = _3DSTATE_DRAWRECT_INFO;
+   state->Buffer[I915_DESTREG_DRAWRECT2] = 0;
+   state->Buffer[I915_DESTREG_DRAWRECT3] = (draw_y << 16) | draw_x;
+   state->Buffer[I915_DESTREG_DRAWRECT4] =
+      ((ctx->DrawBuffer->Width + draw_x) & 0xffff) |
+      ((ctx->DrawBuffer->Height + draw_y) << 16);
+   state->Buffer[I915_DESTREG_DRAWRECT5] = (draw_y << 16) | draw_x;
 
    I915_STATECHANGE(i915, I915_UPLOAD_BUFFERS);
 }
index 0afbda2436b6a15e131efaab454a6dfad9ffe331..e63cd97db6f7b6f913c4b0b1bc30748d6625844d 100644 (file)
@@ -1177,6 +1177,8 @@ static char *fallbackStrings[] = {
    [17] = "Logic op",
    [18] = "Smooth polygon",
    [19] = "Smooth point",
+   [20] = "point sprite coord origin",
+   [21] = "depth/color drawing offset",
 };