From c27fcb1d3bac4282978529d947f3a143ae4a311f Mon Sep 17 00:00:00 2001 From: Kenneth Graunke Date: Tue, 19 Oct 2021 14:16:38 -0700 Subject: [PATCH] isl: Fill in MOCS for NULL depth, stencil, and HiZ buffers. We'd like to add safeguards against accidental use of MOCS 0 (uncached), which can have large performance implications. One case where we use MOCS of 0 is SURFTYPE_NULL depth, stencil, and HiZ buffers, where MOCS really shouldn't matter, as there's no actual surface to be cached. That said, it should be harmless to set MOCS for these null surfaces. We now set the one provided in info->mocs regardless of whether any buffers actually exist or not. Reviewed-by: Jason Ekstrand Part-of: --- src/intel/isl/isl_emit_depth_stencil.c | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/src/intel/isl/isl_emit_depth_stencil.c b/src/intel/isl/isl_emit_depth_stencil.c index 370f98b811d..e6abc9ceb33 100644 --- a/src/intel/isl/isl_emit_depth_stencil.c +++ b/src/intel/isl/isl_emit_depth_stencil.c @@ -71,6 +71,9 @@ isl_genX(emit_depth_stencil_hiz_s)(const struct isl_device *dev, void *batch, { struct GENX(3DSTATE_DEPTH_BUFFER) db = { GENX(3DSTATE_DEPTH_BUFFER_header), +#if GFX_VER >= 6 + .MOCS = info->mocs, +#endif }; if (info->depth_surf) { @@ -118,9 +121,6 @@ isl_genX(emit_depth_stencil_hiz_s)(const struct isl_device *dev, void *batch, db.DepthWriteEnable = true; #endif db.SurfaceBaseAddress = info->depth_address; -#if GFX_VER >= 6 - db.MOCS = info->mocs; -#endif #if GFX_VERx10 >= 125 db.TiledMode = isl_encode_tiling[info->depth_surf->tiling]; @@ -160,6 +160,7 @@ isl_genX(emit_depth_stencil_hiz_s)(const struct isl_device *dev, void *batch, #if GFX_VER >= 6 struct GENX(3DSTATE_STENCIL_BUFFER) sb = { GENX(3DSTATE_STENCIL_BUFFER_header), + sb.MOCS = info->mocs, }; #else # define sb db @@ -193,9 +194,6 @@ isl_genX(emit_depth_stencil_hiz_s)(const struct isl_device *dev, void *batch, sb.StencilBufferEnable = true; #endif sb.SurfaceBaseAddress = info->stencil_address; -#if GFX_VER >= 6 - sb.MOCS = info->mocs; -#endif sb.SurfacePitch = info->stencil_surf->row_pitch_B - 1; #if GFX_VER >= 8 sb.SurfaceQPitch = @@ -219,6 +217,7 @@ isl_genX(emit_depth_stencil_hiz_s)(const struct isl_device *dev, void *batch, #if GFX_VER >= 6 struct GENX(3DSTATE_HIER_DEPTH_BUFFER) hiz = { GENX(3DSTATE_HIER_DEPTH_BUFFER_header), + .MOCS = info->mocs, }; struct GENX(3DSTATE_CLEAR_PARAMS) clear = { GENX(3DSTATE_CLEAR_PARAMS_header), @@ -231,7 +230,6 @@ isl_genX(emit_depth_stencil_hiz_s)(const struct isl_device *dev, void *batch, db.HierarchicalDepthBufferEnable = true; hiz.SurfaceBaseAddress = info->hiz_address; - hiz.MOCS = info->mocs; hiz.SurfacePitch = info->hiz_surf->row_pitch_B - 1; #if GFX_VERx10 >= 125