i965: Implement guardband clipping on Ivybridge.
authorKenneth Graunke <kenneth@whitecape.org>
Sat, 5 May 2012 00:06:39 +0000 (17:06 -0700)
committerKenneth Graunke <kenneth@whitecape.org>
Tue, 15 May 2012 21:52:24 +0000 (14:52 -0700)
Improves performance in Citybench:
- 320x240: 9.19589% +/- 0.557621%
- 1280x480: 3.90797% +/- 0.774429%

No apparent difference in OpenArena.

Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Eric Anholt <eric@anholt.net>
src/mesa/drivers/dri/i965/gen7_clip_state.c
src/mesa/drivers/dri/i965/gen7_viewport_state.c

index 5fede36a20d20016e20218286040c1db0fea82ff..8ff31a8b42e9dc2eaeadf28b905f7c6d66a90b67 100644 (file)
@@ -101,6 +101,7 @@ upload_clip_state(struct brw_context *brw)
             GEN6_CLIP_MODE_NORMAL |
              nonperspective_barycentric_enable_flag |
             GEN6_CLIP_XY_TEST |
+            GEN6_CLIP_GB_TEST |
             userclip << GEN6_USER_CLIP_CLIP_DISTANCES_SHIFT |
             depth_clamp |
             provoking);
index 2bcf338b85d65da63567a2770bf72c674f3001bb..7036ef6e161cd46c2f44d4e2e4a27cba3f87d140 100644 (file)
@@ -43,11 +43,20 @@ gen7_upload_sf_clip_viewport(struct brw_context *brw)
    /* Also assign to clip.vp_offset in case something uses it. */
    brw->clip.vp_offset = brw->sf.vp_offset;
 
-   /* Disable guardband clipping (see gen6_viewport_state.c for rationale). */
-   vp->guardband.xmin = -1.0;
-   vp->guardband.xmax = 1.0;
-   vp->guardband.ymin = -1.0;
-   vp->guardband.ymax = 1.0;
+   /* According to the "Vertex X,Y Clamping and Quantization" section of the
+    * Strips and Fans documentation, Ivybridge and later don't have a maximum
+    * post-clamp delta.  However, the guardband extent must fit in [-32K, 32K)
+    * which gives us a maximum size of 64K.  Use 65000 rather than 65536 to be
+    * somewhat cautious---make the guardband slightly smaller than the maximum.
+    */
+   const float maximum_guardband_extent = 65000;
+   float gbx = maximum_guardband_extent / (float) ctx->Viewport.Width;
+   float gby = maximum_guardband_extent / (float) ctx->Viewport.Height;
+
+   vp->guardband.xmin = -gbx;
+   vp->guardband.xmax = gbx;
+   vp->guardband.ymin = -gby;
+   vp->guardband.ymax = gby;
 
    /* _NEW_BUFFERS */
    if (render_to_fbo) {