<p dir="ltr"></p>
<p dir="ltr">On Jul 30, 2016 2:01 AM, "Pohjolainen, Topi" <<a href="mailto:topi.pohjolainen@intel.com">topi.pohjolainen@intel.com</a>> wrote:<br>
><br>
> On Fri, Jul 29, 2016 at 06:59:44AM -0700, Jason Ekstrand wrote:<br>
> > On Jul 29, 2016 2:26 AM, "Pohjolainen, Topi"<br>
> > <[1]<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>
> > +++++++++++++++++++++++++++++-----<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<br>
> > 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<br>
> > *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>
> > > > +<br>
> > mt->level[lod].level_x,<br>
> > > > +<br>
> > mt->level[lod].level_y,<br>
> > > > + false);<br>
> > > > +<br>
> > > > + surf->logical_level0_px.width =<br>
> > minify(surf->logical_level0_px.width, lod);<br>
> > > > + surf->logical_level0_px.height =<br>
> > minify(surf->logical_level0_px.height, lod);<br>
> > > > + surf->phys_level0_sa.width = minify(surf->phys_level0_sa.width,<br>
> > lod);<br>
> > > > + surf->phys_level0_sa.height =<br>
> > minify(surf->phys_level0_sa.height, lod);<br>
> > > > + surf->levels = 1;<br>
> > > > + surf->array_pitch_el_rows =<br>
> > > > + ALIGN(surf->phys_level0_sa.height,<br>
> > 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<br>
> > *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<br>
> > 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<br>
> > auxiliary<br>
> > > > * surface. Without one, it does nothing.<br>
> > > > */<br>
> > > > info->clear_color = intel_miptree_get_isl_clear_color(brw,<br>
> > 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<br>
> > this<br>
> > > path now also for gen7?<br>
> ><br>
> > The only platform that needs this hack is Sandy Bridge which supports<br>
> > layered rendering but not multi-LOD HiZ.<br>
><br>
> Yes, that is my understanding also. It just looks to me that gen7 will take<br>
> this path also. The conditions above don't check for gen. Or am I missing<br>
> something else?</p>
<p dir="ltr">Gen7 will take it but only for single-LOD surfaces where it's pretty-much a no-op. That said, a gen check is probably in order since it really exists for gen6 only. I'll add one.</p>
<p dir="ltr">> ><br>
> > > > + /* gen6 requires the HiZ buffer to be manually<br>
> > offset to the<br>
> > > > + * right location. We could fixup the surf but it<br>
> > doesn't<br>
> > > > + * matter since most of those fields don't matter.<br>
> > > > + */<br>
> > > > + apply_gen6_stencil_hiz_offset(&info->aux_surf,<br>
> > 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<br>
> > == NULL));<br>
> > > ><br>
> > > > info->view = (struct isl_view) {<br>
> > > > .usage = is_render_target ? ISL_SURF_USAGE_RENDER_TARGET_BIT<br>
> > :<br>
> > > > diff --git a/src/mesa/drivers/dri/i965/brw_blorp.h<br>
> > 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<br>
> > 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<br>
> > brw_context *brw,<br>
> > > ><br>
> > > > /* 3DSTATE_HIER_DEPTH_BUFFER */<br>
> > > > {<br>
> > > > - struct intel_mipmap_tree *hiz_mt =<br>
> > 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>
> > > > -<br>
> > hiz_mt->level[lod].level_x,<br>
> > > > -<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<br>
> > *brw,<br>
> > > > OUT_BATCH(_3DSTATE_CLEAR_PARAMS << 16 |<br>
> > > > GEN5_DEPTH_CLEAR_VALID |<br>
> > > > (2 - 2));<br>
> > > > - OUT_BATCH(params->[2]<a href="http://depth.mt">depth.mt</a> ?<br>
> > 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<br>
> > 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<br>
> > brw_context *brw,<br>
> > > ><br>
> > > > /* 3DSTATE_HIER_DEPTH_BUFFER */<br>
> > > > {<br>
> > > > - struct intel_miptree_aux_buffer *hiz_buf =<br>
> > 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<br>
> > *brw,<br>
> > > > {<br>
> > > > BEGIN_BATCH(3);<br>
> > > > OUT_BATCH(GEN7_3DSTATE_CLEAR_PARAMS << 16 | (3 - 2));<br>
> > > > - OUT_BATCH(params->[3]<a href="http://depth.mt">depth.mt</a> ?<br>
> > 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>
> > > > [4]<a href="mailto:mesa-dev@lists.freedesktop.org">mesa-dev@lists.freedesktop.org</a><br>
> > > > [5]<a href="https://lists.freedesktop.org/mailman/listinfo/mesa-dev">https://lists.freedesktop.org/mailman/listinfo/mesa-dev</a><br>
> ><br>
> > References<br>
> ><br>
> > 1. mailto:<a href="mailto:topi.pohjolainen@intel.com">topi.pohjolainen@intel.com</a><br>
> > 2. <a href="http://depth.mt/">http://depth.mt/</a><br>
> > 3. <a href="http://depth.mt/">http://depth.mt/</a><br>
> > 4. mailto:<a href="mailto:mesa-dev@lists.freedesktop.org">mesa-dev@lists.freedesktop.org</a><br>
> > 5. <a href="https://lists.freedesktop.org/mailman/listinfo/mesa-dev">https://lists.freedesktop.org/mailman/listinfo/mesa-dev</a><br></p>