<p dir="ltr"></p>
<p dir="ltr">On Jul 29, 2016 2:26 AM, "Pohjolainen, Topi" <<a href="mailto:topi.pohjolainen@intel.com">topi.pohjolainen@intel.com</a>> wrote:<br>
><br>
> On Tue, Jul 26, 2016 at 03:11:14PM -0700, Jason Ekstrand wrote:<br>
> > ---<br>
> > src/mesa/drivers/dri/i965/brw_blorp.c | 59 +++++++++++++++++++++++++++++-----<br>
> > src/mesa/drivers/dri/i965/brw_blorp.h | 2 --<br>
> > src/mesa/drivers/dri/i965/gen6_blorp.c | 19 +++--------<br>
> > src/mesa/drivers/dri/i965/gen7_blorp.c | 10 +++---<br>
> > 4 files changed, 59 insertions(+), 31 deletions(-)<br>
> ><br>
> > diff --git a/src/mesa/drivers/dri/i965/brw_blorp.c b/src/mesa/drivers/dri/i965/brw_blorp.c<br>
> > index 97eddf9..47801f0 100644<br>
> > --- a/src/mesa/drivers/dri/i965/brw_blorp.c<br>
> > +++ b/src/mesa/drivers/dri/i965/brw_blorp.c<br>
> > @@ -105,6 +105,28 @@ blorp_get_image_offset_sa(struct isl_device *dev, const struct isl_surf *surf,<br>
> > }<br>
> > }<br>
> ><br>
> > +static void<br>
> > +apply_gen6_stencil_hiz_offset(struct isl_surf *surf,<br>
> > + struct intel_mipmap_tree *mt,<br>
> > + uint32_t lod,<br>
> > + uint32_t *offset)<br>
> > +{<br>
> > + assert(mt->array_layout == ALL_SLICES_AT_EACH_LOD);<br>
> > +<br>
> > + *offset = intel_miptree_get_aligned_offset(mt,<br>
> > + mt->level[lod].level_x,<br>
> > + mt->level[lod].level_y,<br>
> > + false);<br>
> > +<br>
> > + surf->logical_level0_px.width = minify(surf->logical_level0_px.width, lod);<br>
> > + surf->logical_level0_px.height = minify(surf->logical_level0_px.height, lod);<br>
> > + surf->phys_level0_sa.width = minify(surf->phys_level0_sa.width, lod);<br>
> > + surf->phys_level0_sa.height = minify(surf->phys_level0_sa.height, lod);<br>
> > + surf->levels = 1;<br>
> > + surf->array_pitch_el_rows =<br>
> > + ALIGN(surf->phys_level0_sa.height, surf->image_alignment_el.height);<br>
> > +}<br>
> > +<br>
> > void<br>
> > brw_blorp_surface_info_init(struct brw_context *brw,<br>
> > struct brw_blorp_surface_info *info,<br>
> > @@ -125,7 +147,6 @@ brw_blorp_surface_info_init(struct brw_context *brw,<br>
> ><br>
> > intel_miptree_check_level_layer(mt, level, layer);<br>
> ><br>
> > - info->mt = mt;<br>
> > if (is_render_target)<br>
> > intel_miptree_used_for_rendering(mt);<br>
> ><br>
> > @@ -133,21 +154,43 @@ brw_blorp_surface_info_init(struct brw_context *brw,<br>
> > info->bo = mt->bo;<br>
> > info->offset = mt->offset;<br>
> ><br>
> > - if (mt->mcs_mt) {<br>
> > - intel_miptree_get_aux_isl_surf(brw, mt, &info->aux_surf,<br>
> > - &info->aux_usage);<br>
> > - info->aux_bo = mt->mcs_mt->bo;<br>
> > - info->aux_offset = mt->mcs_mt->offset;<br>
> > -<br>
> > + intel_miptree_get_aux_isl_surf(brw, mt, &info->aux_surf,<br>
> > + &info->aux_usage);<br>
> > + if (info->aux_usage != ISL_AUX_USAGE_NONE) {<br>
> > /* We only really need a clear color if we also have an auxiliary<br>
> > * surface. Without one, it does nothing.<br>
> > */<br>
> > info->clear_color = intel_miptree_get_isl_clear_color(brw, mt);<br>
> > +<br>
> > + if (mt->mcs_mt) {<br>
> > + info->aux_bo = mt->mcs_mt->bo;<br>
> > + info->aux_offset = mt->mcs_mt->offset;<br>
> > + } else {<br>
> > + assert(info->aux_usage == ISL_AUX_USAGE_HIZ);<br>
> > + struct intel_mipmap_tree *hiz_mt = mt->hiz_buf->mt;<br>
> > + if (hiz_mt) {<br>
> > + info->aux_bo = hiz_mt->bo;<br>
> > + if (hiz_mt->array_layout == ALL_SLICES_AT_EACH_LOD) {<br>
><br>
> Otherwise the patch looks good, I'm only wondering aren't we taking this<br>
> path now also for gen7?</p>
<p dir="ltr">The only platform that needs this hack is Sandy Bridge which supports layered rendering but not multi-LOD HiZ.</p>
<p dir="ltr">> > + /* gen6 requires the HiZ buffer to be manually offset to the<br>
> > + * right location. We could fixup the surf but it doesn't<br>
> > + * matter since most of those fields don't matter.<br>
> > + */<br>
> > + apply_gen6_stencil_hiz_offset(&info->aux_surf, hiz_mt, level,<br>
> > + &info->aux_offset);<br>
> > + } else {<br>
> > + info->aux_offset = 0;<br>
> > + }<br>
> > + assert(hiz_mt->pitch == info->aux_surf.row_pitch);<br>
> > + } else {<br>
> > + info->aux_bo = mt->hiz_buf->bo;<br>
> > + info->aux_offset = 0;<br>
> > + }<br>
> > + }<br>
> > } else {<br>
> > - info->aux_usage = ISL_AUX_USAGE_NONE;<br>
> > info->aux_bo = NULL;<br>
> > info->aux_offset = 0;<br>
> > }<br>
> > + assert((info->aux_usage == ISL_AUX_USAGE_NONE) == (info->aux_bo == NULL));<br>
> ><br>
> > info->view = (struct isl_view) {<br>
> > .usage = is_render_target ? ISL_SURF_USAGE_RENDER_TARGET_BIT :<br>
> > diff --git a/src/mesa/drivers/dri/i965/brw_blorp.h b/src/mesa/drivers/dri/i965/brw_blorp.h<br>
> > index d747880..95a6257 100644<br>
> > --- a/src/mesa/drivers/dri/i965/brw_blorp.h<br>
> > +++ b/src/mesa/drivers/dri/i965/brw_blorp.h<br>
> > @@ -69,8 +69,6 @@ enum {<br>
> ><br>
> > struct brw_blorp_surface_info<br>
> > {<br>
> > - struct intel_mipmap_tree *mt;<br>
> > -<br>
> > struct isl_surf surf;<br>
> > drm_intel_bo *bo;<br>
> > uint32_t offset;<br>
> > diff --git a/src/mesa/drivers/dri/i965/gen6_blorp.c b/src/mesa/drivers/dri/i965/gen6_blorp.c<br>
> > index 6f3073b..8aeaf61 100644<br>
> > --- a/src/mesa/drivers/dri/i965/gen6_blorp.c<br>
> > +++ b/src/mesa/drivers/dri/i965/gen6_blorp.c<br>
> > @@ -759,23 +759,12 @@ gen6_blorp_emit_depth_stencil_config(struct brw_context *brw,<br>
> ><br>
> > /* 3DSTATE_HIER_DEPTH_BUFFER */<br>
> > {<br>
> > - struct intel_mipmap_tree *hiz_mt = params->depth.mt->hiz_buf->mt;<br>
> > - uint32_t offset = 0;<br>
> > -<br>
> > - if (hiz_mt->array_layout == ALL_SLICES_AT_EACH_LOD) {<br>
> > - const unsigned lod = params->depth.view.base_level;<br>
> > - offset = intel_miptree_get_aligned_offset(hiz_mt,<br>
> > - hiz_mt->level[lod].level_x,<br>
> > - hiz_mt->level[lod].level_y,<br>
> > - false);<br>
> > - }<br>
> > -<br>
> > BEGIN_BATCH(3);<br>
> > OUT_BATCH((_3DSTATE_HIER_DEPTH_BUFFER << 16) | (3 - 2));<br>
> > - OUT_BATCH(hiz_mt->pitch - 1);<br>
> > - OUT_RELOC(hiz_mt->bo,<br>
> > + OUT_BATCH(params->depth.aux_surf.row_pitch - 1);<br>
> > + OUT_RELOC(params->depth.aux_bo,<br>
> > I915_GEM_DOMAIN_RENDER, I915_GEM_DOMAIN_RENDER,<br>
> > - offset);<br>
> > + params->depth.aux_offset);<br>
> > ADVANCE_BATCH();<br>
> > }<br>
> ><br>
> > @@ -835,7 +824,7 @@ gen6_blorp_emit_clear_params(struct brw_context *brw,<br>
> > OUT_BATCH(_3DSTATE_CLEAR_PARAMS << 16 |<br>
> > GEN5_DEPTH_CLEAR_VALID |<br>
> > (2 - 2));<br>
> > - OUT_BATCH(params-><a href="http://depth.mt">depth.mt</a> ? params->depth.mt->depth_clear_value : 0);<br>
> > + OUT_BATCH(params->depth.clear_color.u32[0]);<br>
> > ADVANCE_BATCH();<br>
> > }<br>
> ><br>
> > diff --git a/src/mesa/drivers/dri/i965/gen7_blorp.c b/src/mesa/drivers/dri/i965/gen7_blorp.c<br>
> > index 0ca1a7b..43dea3e 100644<br>
> > --- a/src/mesa/drivers/dri/i965/gen7_blorp.c<br>
> > +++ b/src/mesa/drivers/dri/i965/gen7_blorp.c<br>
> > @@ -529,15 +529,13 @@ gen7_blorp_emit_depth_stencil_config(struct brw_context *brw,<br>
> ><br>
> > /* 3DSTATE_HIER_DEPTH_BUFFER */<br>
> > {<br>
> > - struct intel_miptree_aux_buffer *hiz_buf = params->depth.mt->hiz_buf;<br>
> > -<br>
> > BEGIN_BATCH(3);<br>
> > OUT_BATCH((GEN7_3DSTATE_HIER_DEPTH_BUFFER << 16) | (3 - 2));<br>
> > OUT_BATCH((mocs << 25) |<br>
> > - (hiz_buf->pitch - 1));<br>
> > - OUT_RELOC(hiz_buf->bo,<br>
> > + (params->depth.aux_surf.row_pitch - 1));<br>
> > + OUT_RELOC(params->depth.aux_bo,<br>
> > I915_GEM_DOMAIN_RENDER, I915_GEM_DOMAIN_RENDER,<br>
> > - 0);<br>
> > + params->depth.aux_offset);<br>
> > ADVANCE_BATCH();<br>
> > }<br>
> ><br>
> > @@ -595,7 +593,7 @@ gen7_blorp_emit_clear_params(struct brw_context *brw,<br>
> > {<br>
> > BEGIN_BATCH(3);<br>
> > OUT_BATCH(GEN7_3DSTATE_CLEAR_PARAMS << 16 | (3 - 2));<br>
> > - OUT_BATCH(params-><a href="http://depth.mt">depth.mt</a> ? params->depth.mt->depth_clear_value : 0);<br>
> > + OUT_BATCH(params->depth.clear_color.u32[0]);<br>
> > OUT_BATCH(GEN7_DEPTH_CLEAR_VALID);<br>
> > ADVANCE_BATCH();<br>
> > }<br>
> > --<br>
> > 2.5.0.400.gff86faf<br>
> ><br>
> > _______________________________________________<br>
> > mesa-dev mailing list<br>
> > <a href="mailto:mesa-dev@lists.freedesktop.org">mesa-dev@lists.freedesktop.org</a><br>
> > <a href="https://lists.freedesktop.org/mailman/listinfo/mesa-dev">https://lists.freedesktop.org/mailman/listinfo/mesa-dev</a><br></p>