[Mesa-dev] [PATCH 8/8] intel/blorp: Use ISL for emitting depth/stencil/hiz

Jason Ekstrand jason at jlekstrand.net
Tue Apr 4 22:56:37 UTC 2017


---
 src/intel/blorp/blorp_genX_exec.h | 120 +++++++++++---------------------------
 1 file changed, 35 insertions(+), 85 deletions(-)

diff --git a/src/intel/blorp/blorp_genX_exec.h b/src/intel/blorp/blorp_genX_exec.h
index 3791462..e1acb07 100644
--- a/src/intel/blorp/blorp_genX_exec.h
+++ b/src/intel/blorp/blorp_genX_exec.h
@@ -792,107 +792,57 @@ static void
 blorp_emit_depth_stencil_config(struct blorp_batch *batch,
                                 const struct blorp_params *params)
 {
-#if GEN_GEN >= 7
-   const uint32_t mocs = 1; /* GEN7_MOCS_L3 */
-#else
-   const uint32_t mocs = 0;
-#endif
-
-   blorp_emit(batch, GENX(3DSTATE_DEPTH_BUFFER), db) {
-#if GEN_GEN >= 7
-      db.DepthWriteEnable = params->depth.enabled;
-      db.StencilWriteEnable = params->stencil.enabled;
-#endif
+   const struct isl_device *isl_dev = batch->blorp->isl_dev;
 
-#if GEN_GEN <= 6
-      db.SeparateStencilBufferEnable = true;
-#endif
+   uint32_t *dw = blorp_emit_dwords(batch, isl_dev->ds.size / 4);
+   if (dw == NULL)
+      return;
 
-      if (params->depth.enabled) {
-         db.SurfaceFormat = params->depth_format;
-         db.SurfaceType = isl_to_gen_ds_surftype[params->depth.surf.dim];
+   struct isl_depth_stencil_hiz_emit_info info = {
+      .fb_extent = {
+         .width = params->dst.surf.logical_level0_px.width,
+         .height = params->dst.surf.logical_level0_px.height,
+      },
 
-#if GEN_GEN <= 6
-         db.TiledSurface = true;
-         db.TileWalk = TILEWALK_YMAJOR;
-         db.MIPMapLayoutMode = MIPLAYOUT_BELOW;
+#if GEN_GEN >= 7
+      .mocs = 1, /* GEN7_MOCS_L3 */
+#else
+      .mocs = 0,
 #endif
+   };
 
-         db.HierarchicalDepthBufferEnable =
-            params->depth.aux_usage == ISL_AUX_USAGE_HIZ;
-
-         db.Width = params->depth.surf.logical_level0_px.width - 1;
-         db.Height = params->depth.surf.logical_level0_px.height - 1;
-         db.RenderTargetViewExtent = db.Depth =
-            params->depth.view.array_len - 1;
-
-         db.LOD = params->depth.view.base_level;
-         db.MinimumArrayElement = params->depth.view.base_array_layer;
+   if (params->depth.enabled) {
+      info.view = &params->depth.view;
+   } else if (params->stencil.enabled) {
+      info.view = &params->stencil.view;
+   }
 
-         db.SurfacePitch = params->depth.surf.row_pitch - 1;
-#if GEN_GEN >= 8
-         db.SurfaceQPitch =
-            isl_surf_get_array_pitch_el_rows(&params->depth.surf) >> 2,
-#endif
+   if (params->depth.enabled) {
+      info.depth_surf = &params->depth.surf;
 
-         db.SurfaceBaseAddress = params->depth.addr;
-         db.DepthBufferMOCS = mocs;
-      } else if (params->stencil.enabled) {
-         db.SurfaceFormat = D32_FLOAT;
-         db.SurfaceType = isl_to_gen_ds_surftype[params->stencil.surf.dim];
+      blorp_emit_reloc(batch, dw + isl_dev->ds.depth_offset / 4,
+                       params->depth.addr, 0);
 
-         db.Width = params->stencil.surf.logical_level0_px.width - 1;
-         db.Height = params->stencil.surf.logical_level0_px.height - 1;
-         db.RenderTargetViewExtent = db.Depth =
-            params->stencil.view.array_len - 1;
+      info.hiz_usage = params->depth.aux_usage;
+      if (info.hiz_usage == ISL_AUX_USAGE_HIZ) {
+         info.hiz_surf = &params->depth.aux_surf;
+         info.hiz_usage = ISL_AUX_USAGE_HIZ;
 
-         db.LOD = params->stencil.view.base_level;
-         db.MinimumArrayElement = params->stencil.view.base_array_layer;
-      } else {
-         db.SurfaceType = SURFTYPE_NULL;
-         db.SurfaceFormat = D32_FLOAT;
-      }
-   }
+         blorp_emit_reloc(batch, dw + isl_dev->ds.hiz_offset / 4,
+                          params->depth.aux_addr, 0);
 
-   blorp_emit(batch, GENX(3DSTATE_HIER_DEPTH_BUFFER), hiz) {
-      if (params->depth.aux_usage == ISL_AUX_USAGE_HIZ) {
-         hiz.SurfacePitch = params->depth.aux_surf.row_pitch - 1;
-         hiz.SurfaceBaseAddress = params->depth.aux_addr;
-         hiz.HierarchicalDepthBufferMOCS = mocs;
-#if GEN_GEN >= 8
-         hiz.SurfaceQPitch =
-            isl_surf_get_array_pitch_sa_rows(&params->depth.aux_surf) >> 2;
-#endif
+         info.depth_clear_value = params->depth.clear_color.u32[0];
       }
    }
 
-   blorp_emit(batch, GENX(3DSTATE_STENCIL_BUFFER), sb) {
-      if (params->stencil.enabled) {
-#if GEN_GEN >= 8 || GEN_IS_HASWELL
-         sb.StencilBufferEnable = true;
-#endif
-
-         sb.SurfacePitch = params->stencil.surf.row_pitch - 1,
-#if GEN_GEN >= 8
-         sb.SurfaceQPitch =
-            isl_surf_get_array_pitch_el_rows(&params->stencil.surf) >> 2,
-#endif
+   if (params->stencil.enabled) {
+      info.stencil_surf = &params->stencil.surf;
 
-         sb.SurfaceBaseAddress = params->stencil.addr;
-         sb.StencilBufferMOCS = batch->blorp->mocs.tex;
-      }
+      blorp_emit_reloc(batch, dw + isl_dev->ds.stencil_offset / 4,
+                       params->stencil.addr, 0);
    }
 
-   /* 3DSTATE_CLEAR_PARAMS
-    *
-    * From the Sandybridge PRM, Volume 2, Part 1, Section 3DSTATE_CLEAR_PARAMS:
-    *   [DevSNB] 3DSTATE_CLEAR_PARAMS packet must follow the DEPTH_BUFFER_STATE
-    *   packet when HiZ is enabled and the DEPTH_BUFFER_STATE changes.
-    */
-   blorp_emit(batch, GENX(3DSTATE_CLEAR_PARAMS), clear) {
-      clear.DepthClearValueValid = true;
-      clear.DepthClearValue = params->depth.clear_color.u32[0];
-   }
+   isl_emit_depth_stencil_hiz_s(isl_dev, dw, &info);
 }
 
 static uint32_t
-- 
2.5.0.400.gff86faf



More information about the mesa-dev mailing list