[Mesa-dev] [PATCH 04/22] intel/blorp: Add support for binding an actual stencil buffer

Pohjolainen, Topi topi.pohjolainen at gmail.com
Tue Oct 11 18:40:23 UTC 2016


On Fri, Oct 07, 2016 at 09:41:02PM -0700, Jason Ekstrand wrote:
> While we're here, we also make depth without HiZ work.
> 
> Signed-off-by: Jason Ekstrand <jason at jlekstrand.net>
> ---
>  src/intel/blorp/blorp_genX_exec.h | 101 +++++++++++++++++++++++++-------------
>  src/intel/blorp/blorp_priv.h      |   1 +
>  2 files changed, 68 insertions(+), 34 deletions(-)
> 
> diff --git a/src/intel/blorp/blorp_genX_exec.h b/src/intel/blorp/blorp_genX_exec.h
> index 0469619..5326151 100644
> --- a/src/intel/blorp/blorp_genX_exec.h
> +++ b/src/intel/blorp/blorp_genX_exec.h
> @@ -716,6 +716,11 @@ blorp_emit_ps_config(struct blorp_batch *batch,
>  #endif /* GEN_GEN */
>  }
>  
> +static const uint32_t isl_to_gen_surf_dim[] = {
> +   [ISL_SURF_DIM_1D] = SURFTYPE_1D,
> +   [ISL_SURF_DIM_2D] = SURFTYPE_2D,
> +   [ISL_SURF_DIM_3D] = SURFTYPE_3D,
> +};
>  
>  static void
>  blorp_emit_depth_stencil_config(struct blorp_batch *batch,
> @@ -728,54 +733,82 @@ blorp_emit_depth_stencil_config(struct blorp_batch *batch,
>  #endif
>  
>     blorp_emit(batch, GENX(3DSTATE_DEPTH_BUFFER), db) {
> -      switch (params->depth.surf.dim) {
> -      case ISL_SURF_DIM_1D:
> -         db.SurfaceType = SURFTYPE_1D;
> -         break;
> -      case ISL_SURF_DIM_2D:
> -         db.SurfaceType = SURFTYPE_2D;
> -         break;
> -      case ISL_SURF_DIM_3D:
> -         db.SurfaceType = SURFTYPE_3D;
> -         break;
> -      }
> -
> -      db.SurfaceFormat = params->depth_format;
> -
>  #if GEN_GEN >= 7
> -      db.DepthWriteEnable = true;
> +      db.DepthWriteEnable = params->depth.addr.buffer != NULL;
> +      db.StencilWriteEnable = params->stencil.addr.buffer != NULL;
>  #endif
>  
>  #if GEN_GEN <= 6
> -      db.TiledSurface = true;
> -      db.TileWalk = TILEWALK_YMAJOR;
> -      db.MIPMapLayoutMode = MIPLAYOUT_BELOW;
>        db.SeparateStencilBufferEnable = true;
>  #endif
>  
> -      db.HierarchicalDepthBufferEnable = true;
> +      if (params->depth.addr.buffer) {
> +         db.SurfaceType = isl_to_gen_surf_dim[params->depth.surf.dim];
> +         db.SurfaceFormat = params->depth_format;
>  
> -      db.Width = params->depth.surf.logical_level0_px.width - 1;
> -      db.Height = params->depth.surf.logical_level0_px.height - 1;
> -      db.RenderTargetViewExtent = db.Depth =
> -         MAX2(params->depth.surf.logical_level0_px.depth,
> -              params->depth.surf.logical_level0_px.array_len) - 1;
> +#if GEN_GEN <= 6
> +         db.TiledSurface = true;
> +         db.TileWalk = TILEWALK_YMAJOR;
> +         db.MIPMapLayoutMode = MIPLAYOUT_BELOW;
> +#endif
> +
> +         db.HierarchicalDepthBufferEnable =
> +            params->depth.aux_usage == ISL_AUX_USAGE_HIZ;
>  
> -      db.LOD = params->depth.view.base_level;
> -      db.MinimumArrayElement = params->depth.view.base_array_layer;
> +         db.Width = params->depth.surf.logical_level0_px.width - 1;
> +         db.Height = params->depth.surf.logical_level0_px.height - 1;
> +         db.RenderTargetViewExtent = db.Depth =
> +            MAX2(params->depth.surf.logical_level0_px.depth,
> +                 params->depth.surf.logical_level0_px.array_len) - 1;

Looking the patches you are thinking of squashing in. Here you would write
instead:

          db.RenderTargetViewExtent = db.Depth =
             params->depth.view.array_len - 1;

>  
> -      db.SurfacePitch = params->depth.surf.row_pitch - 1;
> -      db.SurfaceBaseAddress = params->depth.addr;
> -      db.DepthBufferMOCS = mocs;
> +         db.LOD = params->depth.view.base_level;
> +         db.MinimumArrayElement = params->depth.view.base_array_layer;
> +
> +         db.SurfacePitch = params->depth.surf.row_pitch - 1;
> +         db.SurfaceBaseAddress = params->depth.addr;
> +         db.DepthBufferMOCS = mocs;
> +      } else {
> +         db.SurfaceFormat = D32_FLOAT;
> +
> +         /* If we don't have a depth buffer, pull dimensions from stencil */
> +         assert(params->stencil.addr.buffer != NULL);
> +
> +         db.SurfaceType = isl_to_gen_surf_dim[params->stencil.surf.dim];
> +         db.Width = params->stencil.surf.logical_level0_px.width - 1;
> +         db.Height = params->stencil.surf.logical_level0_px.height - 1;
> +         db.RenderTargetViewExtent = db.Depth =
> +            MAX2(params->stencil.surf.logical_level0_px.depth,
> +                 params->stencil.surf.logical_level0_px.array_len) - 1;

And here:

          db.RenderTargetViewExtent = db.Depth =
             params->stencil.view.array_len - 1;

This makes sense to me - it is the caller that tells how many layers are
involved.


> +
> +         db.LOD = params->stencil.view.base_level;
> +         db.MinimumArrayElement = params->stencil.view.base_array_layer;
> +      }
>     }
>  
>     blorp_emit(batch, GENX(3DSTATE_HIER_DEPTH_BUFFER), hiz) {
> -      hiz.SurfacePitch = params->depth.aux_surf.row_pitch - 1;
> -      hiz.SurfaceBaseAddress = params->depth.aux_addr;
> -      hiz.HierarchicalDepthBufferMOCS = mocs;
> +      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;
> +      }
>     }
>  
> -   blorp_emit(batch, GENX(3DSTATE_STENCIL_BUFFER), sb);
> +   blorp_emit(batch, GENX(3DSTATE_STENCIL_BUFFER), sb) {
> +      if (params->stencil.addr.buffer) {
> +#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
> +
> +         sb.SurfaceBaseAddress = params->stencil.addr;
> +         sb.StencilBufferMOCS = batch->blorp->mocs.tex;
> +      }
> +   }
>  
>     /* 3DSTATE_CLEAR_PARAMS
>      *
> @@ -1205,7 +1238,7 @@ blorp_exec(struct blorp_batch *batch, const struct blorp_params *params)
>  
>     blorp_emit_viewport_state(batch, params);
>  
> -   if (params->depth.addr.buffer) {
> +   if (params->depth.addr.buffer || params->stencil.addr.buffer) {
>        blorp_emit_depth_stencil_config(batch, params);
>     } else {
>        blorp_emit(batch, GENX(3DSTATE_DEPTH_BUFFER), db) {
> diff --git a/src/intel/blorp/blorp_priv.h b/src/intel/blorp/blorp_priv.h
> index a6ea0ff..82a7bef 100644
> --- a/src/intel/blorp/blorp_priv.h
> +++ b/src/intel/blorp/blorp_priv.h
> @@ -181,6 +181,7 @@ struct blorp_params
>     uint32_t y1;
>     float z;
>     struct brw_blorp_surface_info depth;
> +   struct brw_blorp_surface_info stencil;
>     uint32_t depth_format;
>     struct brw_blorp_surface_info src;
>     struct brw_blorp_surface_info dst;
> -- 
> 2.5.0.400.gff86faf
> 
> _______________________________________________
> mesa-dev mailing list
> mesa-dev at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/mesa-dev


More information about the mesa-dev mailing list