i965: Port CC_VIEWPORT to genxml.
authorKenneth Graunke <kenneth@whitecape.org>
Thu, 11 May 2017 03:39:26 +0000 (20:39 -0700)
committerKenneth Graunke <kenneth@whitecape.org>
Tue, 30 May 2017 04:46:30 +0000 (21:46 -0700)
Reviewed-by: Topi Pohjolainen <topi.pohjolainen@intel.com>
src/mesa/drivers/dri/i965/brw_cc.c
src/mesa/drivers/dri/i965/brw_state.h
src/mesa/drivers/dri/i965/genX_state_upload.c

index 62e81253cc9b9e9818ff251391fb1da60a7d2319..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;
-
-   /* BRW_NEW_VIEWPORT_COUNT */
-   const unsigned viewport_count = brw->clip.viewport_count;
-
-   ccv = brw_state_batch(brw, sizeof(*ccv) * viewport_count, 32,
-                         &brw->cc.vp_offset);
-
-   /* _NEW_TRANSFORM */
-   for (unsigned i = 0; i < viewport_count; 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;
-      }
-   }
-
-   if (brw->gen >= 7) {
-      BEGIN_BATCH(2);
-      OUT_BATCH(_3DSTATE_VIEWPORT_STATE_POINTERS_CC << 16 | (2 - 2));
-      OUT_BATCH(brw->cc.vp_offset);
-      ADVANCE_BATCH();
-   } else {
-      brw->ctx.NewDriverState |= BRW_NEW_CC_VP;
-   }
-}
-
-const struct brw_tracked_state brw_cc_vp = {
-   .dirty = {
-      .mesa = _NEW_TRANSFORM |
-              _NEW_VIEWPORT,
-      .brw = BRW_NEW_BATCH |
-             BRW_NEW_BLORP |
-             BRW_NEW_VIEWPORT_COUNT,
-   },
-   .emit = brw_upload_cc_vp
-};
-
 /**
  * Modify blend function to force destination alpha to 1.0
  *
index 954969c4bf89ea39b079e8c173ab4b8bf82be4de..bec7b03c42fcb235d5a028bb2402e45610e86d5b 100644 (file)
@@ -42,7 +42,6 @@ extern "C" {
 enum intel_msaa_layout;
 
 extern const struct brw_tracked_state brw_blend_constant_color;
-extern const struct brw_tracked_state brw_cc_vp;
 extern const struct brw_tracked_state brw_cc_unit;
 extern const struct brw_tracked_state brw_clip_unit;
 extern const struct brw_tracked_state brw_vs_pull_constants;
index 0d02b3fb88473ab9998ead45ed554000cf4e0128..d13043f64d439c22659ff95b41ee712c883e5254 100644 (file)
@@ -1896,6 +1896,57 @@ static const struct brw_tracked_state genX(vs_state) = {
 
 /* ---------------------------------------------------------------------- */
 
+static void
+genX(upload_cc_viewport)(struct brw_context *brw)
+{
+   struct gl_context *ctx = &brw->ctx;
+
+   /* BRW_NEW_VIEWPORT_COUNT */
+   const unsigned viewport_count = brw->clip.viewport_count;
+
+   struct GENX(CC_VIEWPORT) ccv;
+   uint32_t cc_vp_offset;
+   uint32_t *cc_map =
+      brw_state_batch(brw, 4 * GENX(CC_VIEWPORT_length) * viewport_count,
+                      32, &cc_vp_offset);
+
+   for (unsigned i = 0; i < viewport_count; i++) {
+      /* _NEW_VIEWPORT | _NEW_TRANSFORM */
+      const struct gl_viewport_attrib *vp = &ctx->ViewportArray[i];
+      if (ctx->Transform.DepthClamp) {
+         ccv.MinimumDepth = MIN2(vp->Near, vp->Far);
+         ccv.MaximumDepth = MAX2(vp->Near, vp->Far);
+      } else {
+         ccv.MinimumDepth = 0.0;
+         ccv.MaximumDepth = 1.0;
+      }
+      GENX(CC_VIEWPORT_pack)(NULL, cc_map, &ccv);
+      cc_map += GENX(CC_VIEWPORT_length);
+   }
+
+#if GEN_GEN >= 7
+   brw_batch_emit(brw, GENX(3DSTATE_VIEWPORT_STATE_POINTERS_CC), ptr) {
+      ptr.CCViewportPointer = cc_vp_offset;
+   }
+#else
+   brw->cc.vp_offset = cc_vp_offset;
+   ctx->NewDriverState |= BRW_NEW_CC_VP;
+#endif
+}
+
+const struct brw_tracked_state genX(cc_vp) = {
+   .dirty = {
+      .mesa = _NEW_TRANSFORM |
+              _NEW_VIEWPORT,
+      .brw = BRW_NEW_BATCH |
+             BRW_NEW_BLORP |
+             BRW_NEW_VIEWPORT_COUNT,
+   },
+   .emit = genX(upload_cc_viewport)
+};
+
+/* ---------------------------------------------------------------------- */
+
 #if GEN_GEN >= 6
 static void
 brw_calculate_guardband_size(const struct gen_device_info *devinfo,
@@ -4113,7 +4164,7 @@ genX(init_atoms)(struct brw_context *brw)
       &brw_curbe_offsets,
       &brw_recalculate_urb_fence,
 
-      &brw_cc_vp,
+      &genX(cc_vp),
       &brw_cc_unit,
 
       /* Surface state setup.  Must come before the VS/WM unit.  The binding
@@ -4168,7 +4219,7 @@ genX(init_atoms)(struct brw_context *brw)
 
       /* Command packets: */
 
-      &brw_cc_vp,
+      &genX(cc_vp),
       &genX(viewport_state),   /* must do after *_vp stages */
 
       &gen6_urb,
@@ -4231,7 +4282,7 @@ genX(init_atoms)(struct brw_context *brw)
    {
       /* Command packets: */
 
-      &brw_cc_vp,
+      &genX(cc_vp),
       &genX(sf_clip_viewport),
 
       &gen7_l3_state,
@@ -4321,7 +4372,7 @@ genX(init_atoms)(struct brw_context *brw)
 #elif GEN_GEN >= 8
    static const struct brw_tracked_state *render_atoms[] =
    {
-      &brw_cc_vp,
+      &genX(cc_vp),
       &genX(sf_clip_viewport),
 
       &gen7_l3_state,