i965: Port Gen8+ 3DSTATE_RASTER state to genxml.
authorRafael Antognolli <rafael.antognolli@intel.com>
Thu, 16 Mar 2017 18:39:31 +0000 (11:39 -0700)
committerKenneth Graunke <kenneth@whitecape.org>
Thu, 4 May 2017 01:57:51 +0000 (18:57 -0700)
Emits 3DSTATE_RASTER from genX_state_upload.c using pack structs from
genxml.

v3:
   - Style fixes (Ken)

Signed-off-by: Rafael Antognolli <rafael.antognolli@intel.com>
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
src/mesa/drivers/dri/i965/brw_state.h
src/mesa/drivers/dri/i965/gen8_sf_state.c
src/mesa/drivers/dri/i965/genX_state_upload.c

index c26be41aa2eb8b5cb72e0e14a2e0e39bab554245..3a10a8a43e0ec1b88e6f11b9b2884d7e49ae9ea8 100644 (file)
@@ -156,7 +156,6 @@ extern const struct brw_tracked_state gen8_ps_blend;
 extern const struct brw_tracked_state gen8_ps_extra;
 extern const struct brw_tracked_state gen8_ps_state;
 extern const struct brw_tracked_state gen8_wm_state;
-extern const struct brw_tracked_state gen8_raster_state;
 extern const struct brw_tracked_state gen8_sbe_state;
 extern const struct brw_tracked_state gen8_sf_state;
 extern const struct brw_tracked_state gen8_sf_clip_viewport;
index 41e94fb50408db41471f997b8bc368e13153fa79..d47adcdb3d028d827ec58ea4372d1c3091204139 100644 (file)
@@ -224,128 +224,3 @@ const struct brw_tracked_state gen8_sf_state = {
    },
    .emit = upload_sf,
 };
-
-static void
-upload_raster(struct brw_context *brw)
-{
-   struct gl_context *ctx = &brw->ctx;
-   uint32_t dw1 = 0;
-
-   /* _NEW_BUFFERS */
-   bool render_to_fbo = _mesa_is_user_fbo(brw->ctx.DrawBuffer);
-
-   /* _NEW_POLYGON */
-   if (ctx->Polygon._FrontBit == render_to_fbo)
-      dw1 |= GEN8_RASTER_FRONT_WINDING_CCW;
-
-   if (ctx->Polygon.CullFlag) {
-      switch (ctx->Polygon.CullFaceMode) {
-      case GL_FRONT:
-         dw1 |= GEN8_RASTER_CULL_FRONT;
-         break;
-      case GL_BACK:
-         dw1 |= GEN8_RASTER_CULL_BACK;
-         break;
-      case GL_FRONT_AND_BACK:
-         dw1 |= GEN8_RASTER_CULL_BOTH;
-         break;
-      default:
-         unreachable("not reached");
-      }
-   } else {
-      dw1 |= GEN8_RASTER_CULL_NONE;
-   }
-
-   /* _NEW_POINT */
-   if (ctx->Point.SmoothFlag)
-      dw1 |= GEN8_RASTER_SMOOTH_POINT_ENABLE;
-
-   if (_mesa_is_multisample_enabled(ctx))
-      dw1 |= GEN8_RASTER_API_MULTISAMPLE_ENABLE;
-
-   if (ctx->Polygon.OffsetFill)
-      dw1 |= GEN6_SF_GLOBAL_DEPTH_OFFSET_SOLID;
-
-   if (ctx->Polygon.OffsetLine)
-      dw1 |= GEN6_SF_GLOBAL_DEPTH_OFFSET_WIREFRAME;
-
-   if (ctx->Polygon.OffsetPoint)
-      dw1 |= GEN6_SF_GLOBAL_DEPTH_OFFSET_POINT;
-
-   switch (ctx->Polygon.FrontMode) {
-   case GL_FILL:
-      dw1 |= GEN6_SF_FRONT_SOLID;
-      break;
-   case GL_LINE:
-      dw1 |= GEN6_SF_FRONT_WIREFRAME;
-      break;
-   case GL_POINT:
-      dw1 |= GEN6_SF_FRONT_POINT;
-      break;
-
-   default:
-      unreachable("not reached");
-   }
-
-   switch (ctx->Polygon.BackMode) {
-   case GL_FILL:
-      dw1 |= GEN6_SF_BACK_SOLID;
-      break;
-   case GL_LINE:
-      dw1 |= GEN6_SF_BACK_WIREFRAME;
-      break;
-   case GL_POINT:
-      dw1 |= GEN6_SF_BACK_POINT;
-      break;
-   default:
-      unreachable("not reached");
-   }
-
-   /* _NEW_LINE */
-   if (ctx->Line.SmoothFlag)
-      dw1 |= GEN8_RASTER_LINE_AA_ENABLE;
-
-   /* _NEW_SCISSOR */
-   if (ctx->Scissor.EnableFlags)
-      dw1 |= GEN8_RASTER_SCISSOR_ENABLE;
-
-   /* _NEW_TRANSFORM */
-   if (!ctx->Transform.DepthClamp) {
-      if (brw->gen >= 9) {
-         dw1 |= GEN9_RASTER_VIEWPORT_Z_NEAR_CLIP_TEST_ENABLE |
-                GEN9_RASTER_VIEWPORT_Z_FAR_CLIP_TEST_ENABLE;
-      } else {
-         dw1 |= GEN8_RASTER_VIEWPORT_Z_CLIP_TEST_ENABLE;
-      }
-   }
-
-   /* BRW_NEW_CONSERVATIVE_RASTERIZATION */
-   if (ctx->IntelConservativeRasterization) {
-      if (brw->gen >= 9)
-         dw1 |= GEN9_RASTER_CONSERVATIVE_RASTERIZATION_ENABLE;
-   }
-
-   BEGIN_BATCH(5);
-   OUT_BATCH(_3DSTATE_RASTER << 16 | (5 - 2));
-   OUT_BATCH(dw1);
-   OUT_BATCH_F(ctx->Polygon.OffsetUnits * 2); /* constant.  copied from gen4 */
-   OUT_BATCH_F(ctx->Polygon.OffsetFactor); /* scale */
-   OUT_BATCH_F(ctx->Polygon.OffsetClamp); /* global depth offset clamp */
-   ADVANCE_BATCH();
-}
-
-const struct brw_tracked_state gen8_raster_state = {
-   .dirty = {
-      .mesa  = _NEW_BUFFERS |
-               _NEW_LINE |
-               _NEW_MULTISAMPLE |
-               _NEW_POINT |
-               _NEW_POLYGON |
-               _NEW_SCISSOR |
-               _NEW_TRANSFORM,
-      .brw   = BRW_NEW_BLORP |
-               BRW_NEW_CONTEXT |
-               BRW_NEW_CONSERVATIVE_RASTERIZATION,
-   },
-   .emit = upload_raster,
-};
index 53c1498fe5f340c95cf4ea29206938df28e51ccd..ac467316183b8161ca120a77cff93eab755ca8fe 100644 (file)
@@ -338,10 +338,132 @@ static const struct brw_tracked_state genX(clip_state) = {
    .emit = genX(upload_clip_state),
 };
 
+#endif
+
 /* ---------------------------------------------------------------------- */
 
+#if GEN_GEN >= 8
+static void
+genX(upload_raster)(struct brw_context *brw)
+{
+   struct gl_context *ctx = &brw->ctx;
+
+   /* _NEW_BUFFERS */
+   bool render_to_fbo = _mesa_is_user_fbo(ctx->DrawBuffer);
+
+   /* _NEW_POLYGON */
+   struct gl_polygon_attrib *polygon = &ctx->Polygon;
+
+   /* _NEW_POINT */
+   struct gl_point_attrib *point = &ctx->Point;
+
+   brw_batch_emit(brw, GENX(3DSTATE_RASTER), raster) {
+      if (polygon->_FrontBit == render_to_fbo)
+         raster.FrontWinding = CounterClockwise;
+
+      if (polygon->CullFlag) {
+         switch (polygon->CullFaceMode) {
+         case GL_FRONT:
+            raster.CullMode = CULLMODE_FRONT;
+            break;
+         case GL_BACK:
+            raster.CullMode = CULLMODE_BACK;
+            break;
+         case GL_FRONT_AND_BACK:
+            raster.CullMode = CULLMODE_BOTH;
+            break;
+         default:
+            unreachable("not reached");
+         }
+      } else {
+         raster.CullMode = CULLMODE_NONE;
+      }
+
+      point->SmoothFlag = raster.SmoothPointEnable;
+
+      raster.DXMultisampleRasterizationEnable =
+         _mesa_is_multisample_enabled(ctx);
+
+      raster.GlobalDepthOffsetEnableSolid = polygon->OffsetFill;
+      raster.GlobalDepthOffsetEnableWireframe = polygon->OffsetLine;
+      raster.GlobalDepthOffsetEnablePoint = polygon->OffsetPoint;
+
+      switch (polygon->FrontMode) {
+      case GL_FILL:
+         raster.FrontFaceFillMode = FILL_MODE_SOLID;
+         break;
+      case GL_LINE:
+         raster.FrontFaceFillMode = FILL_MODE_WIREFRAME;
+         break;
+      case GL_POINT:
+         raster.FrontFaceFillMode = FILL_MODE_POINT;
+         break;
+      default:
+         unreachable("not reached");
+      }
+
+      switch (polygon->BackMode) {
+      case GL_FILL:
+         raster.BackFaceFillMode = FILL_MODE_SOLID;
+         break;
+      case GL_LINE:
+         raster.BackFaceFillMode = FILL_MODE_WIREFRAME;
+         break;
+      case GL_POINT:
+         raster.BackFaceFillMode = FILL_MODE_POINT;
+         break;
+      default:
+         unreachable("not reached");
+      }
+
+      /* _NEW_LINE */
+      raster.AntialiasingEnable = ctx->Line.SmoothFlag;
+
+      /* _NEW_SCISSOR */
+      raster.ScissorRectangleEnable = ctx->Scissor.EnableFlags;
+
+      /* _NEW_TRANSFORM */
+      if (!ctx->Transform.DepthClamp) {
+#if GEN_GEN >= 9
+         raster.ViewportZFarClipTestEnable = true;
+         raster.ViewportZNearClipTestEnable = true;
+#else
+         raster.ViewportZClipTestEnable = true;
+#endif
+      }
+
+      /* BRW_NEW_CONSERVATIVE_RASTERIZATION */
+#if GEN_GEN >= 9
+      raster.ConservativeRasterizationEnable =
+         ctx->IntelConservativeRasterization;
+#endif
+
+      raster.GlobalDepthOffsetClamp = polygon->OffsetClamp;
+      raster.GlobalDepthOffsetScale = polygon->OffsetFactor;
+
+      raster.GlobalDepthOffsetConstant = polygon->OffsetUnits * 2;
+   }
+}
+
+static const struct brw_tracked_state genX(raster_state) = {
+   .dirty = {
+      .mesa  = _NEW_BUFFERS |
+               _NEW_LINE |
+               _NEW_MULTISAMPLE |
+               _NEW_POINT |
+               _NEW_POLYGON |
+               _NEW_SCISSOR |
+               _NEW_TRANSFORM,
+      .brw   = BRW_NEW_BLORP |
+               BRW_NEW_CONTEXT |
+               BRW_NEW_CONSERVATIVE_RASTERIZATION,
+   },
+   .emit = genX(upload_raster),
+};
 #endif
 
+/* ---------------------------------------------------------------------- */
+
 void
 genX(init_atoms)(struct brw_context *brw)
 {
@@ -623,7 +745,7 @@ genX(init_atoms)(struct brw_context *brw)
       &gen8_gs_state,
       &gen7_sol_state,
       &genX(clip_state),
-      &gen8_raster_state,
+      &genX(raster_state),
       &gen8_sbe_state,
       &gen8_sf_state,
       &gen8_ps_blend,