anv: Unify 3DSTATE_CLIP code across generations.
authorKenneth Graunke <kenneth@whitecape.org>
Mon, 18 Jul 2016 21:27:35 +0000 (14:27 -0700)
committerKenneth Graunke <kenneth@whitecape.org>
Wed, 20 Jul 2016 17:59:44 +0000 (10:59 -0700)
The bulk of this is the same.  There are just a couple fields that only
exist on one generation or another, and we can easily handle those with
an #ifdef.

Cc: "12.0" <mesa-stable@lists.freedesktop.org>
Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Jason Ekstrand <jason@jlekstrand.net>
src/intel/vulkan/gen7_pipeline.c
src/intel/vulkan/gen8_pipeline.c
src/intel/vulkan/genX_pipeline_util.h

index a9f5e0b51e5a7d35f9341d100f51e1803ea90466..8ce50be7717f0eaaba0660e3bacd2d288224e30c 100644 (file)
@@ -117,27 +117,8 @@ genX(graphics_pipeline_create)(
 
    emit_urb_setup(pipeline);
 
-   const VkPipelineRasterizationStateCreateInfo *rs_info =
-      pCreateInfo->pRasterizationState;
-
-   anv_batch_emit(&pipeline->batch, GENX(3DSTATE_CLIP), clip) {
-      clip.FrontWinding             = vk_to_gen_front_face[rs_info->frontFace],
-      clip.EarlyCullEnable          = true,
-      clip.CullMode                 = vk_to_gen_cullmode[rs_info->cullMode],
-      clip.ClipEnable               = !(extra && extra->use_rectlist),
-      clip.APIMode                  = APIMODE_D3D,
-      clip.ViewportXYClipTestEnable = true,
-      clip.ViewportZClipTestEnable  = !pipeline->depth_clamp_enable,
-      clip.ClipMode                 = CLIPMODE_NORMAL,
-
-      clip.TriangleStripListProvokingVertexSelect   = 0,
-      clip.LineStripListProvokingVertexSelect       = 0,
-      clip.TriangleFanProvokingVertexSelect         = 1,
-
-      clip.MinimumPointWidth        = 0.125,
-      clip.MaximumPointWidth        = 255.875,
-      clip.MaximumVPIndex = pCreateInfo->pViewportState->viewportCount - 1;
-   }
+   emit_3dstate_clip(pipeline, pCreateInfo->pViewportState,
+                     pCreateInfo->pRasterizationState, extra);
 
    if (pCreateInfo->pMultisampleState &&
        pCreateInfo->pMultisampleState->rasterizationSamples > 1)
index 52792a9ad17fce4db09b7cbc6065170083fe555b..cc10d3a085a190a27b3d73c16522d334bc51f172 100644 (file)
@@ -186,29 +186,10 @@ genX(graphics_pipeline_create)(
 
    emit_urb_setup(pipeline);
 
-   const struct brw_wm_prog_data *wm_prog_data = get_wm_prog_data(pipeline);
-   anv_batch_emit(&pipeline->batch, GENX(3DSTATE_CLIP), clip) {
-      clip.ClipEnable               = !(extra && extra->use_rectlist);
-      clip.EarlyCullEnable          = true;
-      clip.APIMode                  = APIMODE_D3D;
-      clip.ViewportXYClipTestEnable = true;
-
-      clip.ClipMode =
-         pCreateInfo->pRasterizationState->rasterizerDiscardEnable ?
-         CLIPMODE_REJECT_ALL : CLIPMODE_NORMAL;
-
-      clip.NonPerspectiveBarycentricEnable = wm_prog_data ?
-         (wm_prog_data->barycentric_interp_modes & 0x38) != 0 : 0;
-
-      clip.TriangleStripListProvokingVertexSelect  = 0;
-      clip.LineStripListProvokingVertexSelect      = 0;
-      clip.TriangleFanProvokingVertexSelect        = 1;
-
-      clip.MinimumPointWidth  = 0.125;
-      clip.MaximumPointWidth  = 255.875;
-      clip.MaximumVPIndex     = pCreateInfo->pViewportState->viewportCount - 1;
-   }
+   emit_3dstate_clip(pipeline, pCreateInfo->pViewportState,
+                     pCreateInfo->pRasterizationState, extra);
 
+   const struct brw_wm_prog_data *wm_prog_data = get_wm_prog_data(pipeline);
    anv_batch_emit(&pipeline->batch, GENX(3DSTATE_WM), wm) {
       wm.StatisticsEnable                    = true;
       wm.LineEndCapAntialiasingRegionWidth   = _05pixels;
index 4385112b4213c938fa8a853191eaf0bcfaa99771..52263dfd70c50f902013161be26d7f71f78835ae 100644 (file)
@@ -646,3 +646,39 @@ emit_cb_state(struct anv_pipeline *pipeline,
 #endif
    }
 }
+
+static void
+emit_3dstate_clip(struct anv_pipeline *pipeline,
+                  const VkPipelineViewportStateCreateInfo *vp_info,
+                  const VkPipelineRasterizationStateCreateInfo *rs_info,
+                  const struct anv_graphics_pipeline_create_info *extra)
+{
+   const struct brw_wm_prog_data *wm_prog_data = get_wm_prog_data(pipeline);
+   (void) wm_prog_data;
+   anv_batch_emit(&pipeline->batch, GENX(3DSTATE_CLIP), clip) {
+      clip.ClipEnable               = !(extra && extra->use_rectlist);
+      clip.EarlyCullEnable          = true;
+      clip.APIMode                  = APIMODE_D3D,
+      clip.ViewportXYClipTestEnable = true;
+
+      clip.ClipMode = rs_info->rasterizerDiscardEnable ?
+         CLIPMODE_REJECT_ALL : CLIPMODE_NORMAL;
+
+      clip.TriangleStripListProvokingVertexSelect = 0;
+      clip.LineStripListProvokingVertexSelect     = 0;
+      clip.TriangleFanProvokingVertexSelect       = 1;
+
+      clip.MinimumPointWidth = 0.125;
+      clip.MaximumPointWidth = 255.875;
+      clip.MaximumVPIndex    = vp_info->viewportCount - 1;
+
+#if GEN_GEN == 7
+      clip.FrontWinding            = vk_to_gen_front_face[rs_info->frontFace];
+      clip.CullMode                = vk_to_gen_cullmode[rs_info->cullMode];
+      clip.ViewportZClipTestEnable = !pipeline->depth_clamp_enable;
+#else
+      clip.NonPerspectiveBarycentricEnable = wm_prog_data ?
+         (wm_prog_data->barycentric_interp_modes & 0x38) != 0 : 0;
+#endif
+   }
+}