i965/sf: Drop unnecessary push/pop in do_twoside_color.
[mesa.git] / src / mesa / drivers / dri / i965 / gen6_clip_state.c
index e4dc278e172986fa2f4c5acdc8b990a5b44f53fc..0ba190ea79230336f571c55d45012155c979caea 100644 (file)
@@ -49,9 +49,10 @@ upload_clip_state(struct brw_context *brw)
       dw2 |= GEN6_CLIP_NON_PERSPECTIVE_BARYCENTRIC_ENABLE;
    }
 
-   if (brw->gen >= 7) {
+   if (brw->gen >= 7)
       dw1 |= GEN7_CLIP_EARLY_CULL;
 
+   if (brw->gen == 7) {
       /* _NEW_POLYGON */
       if ((ctx->Polygon.FrontFace == GL_CCW) ^ _mesa_is_user_fbo(fb))
          dw1 |= GEN7_CLIP_WINDING_CCW;
@@ -76,7 +77,7 @@ upload_clip_state(struct brw_context *brw)
       }
    }
 
-   if (!ctx->Transform.DepthClamp)
+   if (brw->gen < 8 && !ctx->Transform.DepthClamp)
       dw2 |= GEN6_CLIP_Z_TEST;
 
    /* _NEW_LIGHT */
@@ -96,11 +97,19 @@ upload_clip_state(struct brw_context *brw)
    dw2 |= (ctx->Transform.ClipPlanesEnabled <<
            GEN6_USER_CLIP_CLIP_DISTANCES_SHIFT);
 
-   if (ctx->ViewportArray[0].X == 0 &&
-       ctx->ViewportArray[0].Y == 0 &&
-       ctx->ViewportArray[0].Width == (float) fb->Width &&
-       ctx->ViewportArray[0].Height == (float) fb->Height) {
-      dw2 |= GEN6_CLIP_GB_TEST;
+   dw2 |= GEN6_CLIP_GB_TEST;
+   for (unsigned i = 0; i < ctx->Const.MaxViewports; i++) {
+      if (ctx->ViewportArray[i].X != 0 ||
+          ctx->ViewportArray[i].Y != 0 ||
+          ctx->ViewportArray[i].Width != (float) fb->Width ||
+          ctx->ViewportArray[i].Height != (float) fb->Height) {
+         dw2 &= ~GEN6_CLIP_GB_TEST;
+         if (brw->gen >= 8) {
+            perf_debug("Disabling GB clipping due to lack of Gen8 viewport "
+                       "clipping setup code.  This should be fixed.");
+         }
+         break;
+      }
    }
 
    /* BRW_NEW_RASTERIZER_DISCARD */
@@ -121,7 +130,8 @@ upload_clip_state(struct brw_context *brw)
             dw2);
    OUT_BATCH(U_FIXED(0.125, 3) << GEN6_CLIP_MIN_POINT_WIDTH_SHIFT |
              U_FIXED(255.875, 3) << GEN6_CLIP_MAX_POINT_WIDTH_SHIFT |
-             (fb->MaxNumLayers > 0 ? 0 : GEN6_CLIP_FORCE_ZERO_RTAINDEX));
+             (fb->MaxNumLayers > 0 ? 0 : GEN6_CLIP_FORCE_ZERO_RTAINDEX) |
+             ((ctx->Const.MaxViewports - 1) & GEN6_CLIP_MAX_VP_INDEX_MASK));
    ADVANCE_BATCH();
 }