i965: Port CC_VIEWPORT to genxml.
[mesa.git] / src / mesa / drivers / dri / i965 / brw_cc.c
index 289f65b5a8a9834296066acef78f3ae61f22ff5b..78d3bc86d13998cc44a8fcfdaef62e6ac8a3bc9d 100644 (file)
 #include "main/stencil.h"
 #include "intel_batchbuffer.h"
 
-static void
-brw_upload_cc_vp(struct brw_context *brw)
-{
-   struct gl_context *ctx = &brw->ctx;
-   struct brw_cc_viewport *ccv;
-
-   ccv = brw_state_batch(brw, AUB_TRACE_CC_VP_STATE,
-                        sizeof(*ccv) * ctx->Const.MaxViewports, 32,
-                         &brw->cc.vp_offset);
-
-   /* _NEW_TRANSFORM */
-   for (unsigned i = 0; i < ctx->Const.MaxViewports; i++) {
-      if (ctx->Transform.DepthClamp) {
-         /* _NEW_VIEWPORT */
-         ccv[i].min_depth = MIN2(ctx->ViewportArray[i].Near,
-                                 ctx->ViewportArray[i].Far);
-         ccv[i].max_depth = MAX2(ctx->ViewportArray[i].Near,
-                                 ctx->ViewportArray[i].Far);
-      } else {
-         ccv[i].min_depth = 0.0;
-         ccv[i].max_depth = 1.0;
-      }
-   }
-
-   brw->state.dirty.cache |= CACHE_NEW_CC_VP;
-}
-
-const struct brw_tracked_state brw_cc_vp = {
-   .dirty = {
-      .mesa = _NEW_VIEWPORT | _NEW_TRANSFORM,
-      .brw = BRW_NEW_BATCH,
-      .cache = 0
-   },
-   .emit = brw_upload_cc_vp
-};
-
 /**
  * Modify blend function to force destination alpha to 1.0
  *
@@ -104,8 +68,7 @@ static void upload_cc_unit(struct brw_context *brw)
    struct gl_context *ctx = &brw->ctx;
    struct brw_cc_unit_state *cc;
 
-   cc = brw_state_batch(brw, AUB_TRACE_CC_STATE,
-                       sizeof(*cc), 64, &brw->cc.state_offset);
+   cc = brw_state_batch(brw, sizeof(*cc), 64, &brw->cc.state_offset);
    memset(cc, 0, sizeof(*cc));
 
    /* _NEW_STENCIL | _NEW_BUFFERS */
@@ -151,7 +114,7 @@ static void upload_cc_unit(struct brw_context *brw)
    if (ctx->Color.ColorLogicOpEnabled && ctx->Color.LogicOp != GL_COPY) {
       cc->cc2.logicop_enable = 1;
       cc->cc5.logicop_func = intel_translate_logic_op(ctx->Color.LogicOp);
-   } else if (ctx->Color.BlendEnabled) {
+   } else if (ctx->Color.BlendEnabled && !ctx->Color._AdvancedBlendMode) {
       GLenum eqRGB = ctx->Color.Blend[0].EquationRGB;
       GLenum eqA = ctx->Color.Blend[0].EquationA;
       GLenum srcRGB = ctx->Color.Blend[0].SrcRGB;
@@ -213,31 +176,36 @@ static void upload_cc_unit(struct brw_context *brw)
       cc->cc2.depth_test = 1;
       cc->cc2.depth_test_function =
         intel_translate_compare_func(ctx->Depth.Func);
-      cc->cc2.depth_write_enable = ctx->Depth.Mask;
+      cc->cc2.depth_write_enable = brw_depth_writes_enabled(brw);
    }
 
-   if (brw->stats_wm || unlikely(INTEL_DEBUG & DEBUG_STATS))
+   if (brw->stats_wm)
       cc->cc5.statistics_enable = 1;
 
-   /* CACHE_NEW_CC_VP */
+   /* BRW_NEW_CC_VP */
    cc->cc4.cc_viewport_state_offset = (brw->batch.bo->offset64 +
                                       brw->cc.vp_offset) >> 5; /* reloc */
 
-   brw->state.dirty.cache |= CACHE_NEW_CC_UNIT;
+   brw->ctx.NewDriverState |= BRW_NEW_GEN4_UNIT_STATE;
 
    /* Emit CC viewport relocation */
-   drm_intel_bo_emit_reloc(brw->batch.bo,
-                          (brw->cc.state_offset +
-                           offsetof(struct brw_cc_unit_state, cc4)),
-                          brw->batch.bo, brw->cc.vp_offset,
-                          I915_GEM_DOMAIN_INSTRUCTION, 0);
+   brw_emit_reloc(&brw->batch,
+                  (brw->cc.state_offset +
+                   offsetof(struct brw_cc_unit_state, cc4)),
+                  brw->batch.bo, brw->cc.vp_offset,
+                  I915_GEM_DOMAIN_INSTRUCTION, 0);
 }
 
 const struct brw_tracked_state brw_cc_unit = {
    .dirty = {
-      .mesa = _NEW_STENCIL | _NEW_COLOR | _NEW_DEPTH | _NEW_BUFFERS,
-      .brw = BRW_NEW_BATCH | BRW_NEW_STATS_WM,
-      .cache = CACHE_NEW_CC_VP
+      .mesa = _NEW_BUFFERS |
+              _NEW_COLOR |
+              _NEW_DEPTH |
+              _NEW_STENCIL,
+      .brw = BRW_NEW_BATCH |
+             BRW_NEW_BLORP |
+             BRW_NEW_CC_VP |
+             BRW_NEW_STATS_WM,
    },
    .emit = upload_cc_unit,
 };
@@ -258,8 +226,8 @@ static void upload_blend_constant_color(struct brw_context *brw)
 const struct brw_tracked_state brw_blend_constant_color = {
    .dirty = {
       .mesa = _NEW_COLOR,
-      .brw = BRW_NEW_CONTEXT,
-      .cache = 0
+      .brw = BRW_NEW_CONTEXT |
+             BRW_NEW_BLORP,
    },
    .emit = upload_blend_constant_color
 };