<p dir="ltr"></p>
<p dir="ltr">On Jul 27, 2016 1:53 PM, "Pohjolainen, Topi" <<a href="mailto:topi.pohjolainen@intel.com">topi.pohjolainen@intel.com</a>> wrote:<br>
><br>
> On Tue, Jul 26, 2016 at 03:02:09PM -0700, Jason Ekstrand wrote:<br>
> > For the moment, we still call the old miptree function; we just assert that<br>
> > the two are equal.<br>
> > ---<br>
> > src/mesa/drivers/dri/i965/brw_blorp.c | 94 +++++++++++++++++++++++++++++++++--<br>
> > 1 file changed, 91 insertions(+), 3 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 ef256a7..c8cb41a 100644<br>
> > --- a/src/mesa/drivers/dri/i965/brw_blorp.c<br>
> > +++ b/src/mesa/drivers/dri/i965/brw_blorp.c<br>
> > @@ -32,6 +32,88 @@<br>
> ><br>
> > #define FILE_DEBUG_FLAG DEBUG_BLORP<br>
> ><br>
> > +/**<br>
> > + * A variant of isl_surf_get_image_offset_sa() specific to gen6 stencil and<br>
> > + * HiZ surfaces.<br>
> > + */<br>
> > +static void<br>
> > +get_image_offset_sa_gen6_stencil(const struct isl_surf *surf,<br>
> > + uint32_t level, uint32_t logical_array_layer,<br>
> > + uint32_t *x_offset_sa,<br>
> > + uint32_t *y_offset_sa)<br>
> > +{<br>
> > + assert(surf->tiling == ISL_TILING_W || surf->format == ISL_FORMAT_HIZ);<br>
> > + assert(level < surf->levels);<br>
> > + assert(logical_array_layer < surf->logical_level0_px.array_len);<br>
> > +<br>
> > + const struct isl_extent3d image_align_sa =<br>
> > + isl_surf_get_image_alignment_sa(surf);<br>
> > +<br>
> > + const uint32_t W0 = surf->phys_level0_sa.width;<br>
> > + const uint32_t H0 = surf->phys_level0_sa.height;<br>
> > +<br>
> > + uint32_t x = 0, y = 0;<br>
> > + for (uint32_t l = 0; l < level; ++l) {<br>
> > + if (l == 1) {<br>
> > + uint32_t W = minify(W0, l);<br>
> > +<br>
> > + if (surf->samples > 1) {<br>
> > + assert(surf->msaa_layout == ISL_MSAA_LAYOUT_INTERLEAVED);<br>
> > + assert(surf->samples == 4);<br>
> > + W = ALIGN(W, 2) * 2;<br>
> > + }<br>
> > +<br>
> > + x += ALIGN(W, image_align_sa.w);<br>
> > + } else {<br>
> > + uint32_t H = minify(H0, l);<br>
> > +<br>
> > + if (surf->samples > 1) {<br>
> > + assert(surf->msaa_layout == ISL_MSAA_LAYOUT_INTERLEAVED);<br>
> > + assert(surf->samples == 4);<br>
> > + H = ALIGN(H, 2) * 2;<br>
> > + }<br>
> > +<br>
> > + y += ALIGN(H, image_align_sa.h) * surf->logical_level0_px.array_len;<br>
> > + }<br>
> > + }<br>
> > +<br>
> > + /* Now account for our location within the given LOD */<br>
> > + uint32_t Hl = minify(H0, level);<br>
> > + if (surf->samples > 1) {<br>
> > + assert(surf->msaa_layout == ISL_MSAA_LAYOUT_INTERLEAVED);<br>
> > + assert(surf->samples == 4);<br>
> > + Hl = ALIGN(Hl, 2) * 2;<br>
> > + }<br>
> > + y += ALIGN(Hl, image_align_sa.h) * logical_array_layer;<br>
> > +<br>
> > + *x_offset_sa = x;<br>
> > + *y_offset_sa = y;<br>
> > +}<br>
> > +<br>
> > +static void<br>
> > +blorp_get_image_offset_sa(struct isl_device *dev, const struct isl_surf *surf,<br>
> > + uint32_t level, uint32_t layer,<br>
> > + uint32_t *x_offset_sa,<br>
> > + uint32_t *y_offset_sa)<br>
> > +{<br>
> > + if (ISL_DEV_GEN(dev) == 6 && surf->tiling == ISL_TILING_W) {<br>
> > + get_image_offset_sa_gen6_stencil(surf, level, layer,<br>
> > + x_offset_sa, y_offset_sa);<br>
> > + } else {<br>
> > + /* Using base_array_layer for Z in 3-D surfaces is a bit abusive, but it<br>
> > + * will go away soon enough.<br>
> > + */<br>
> > + uint32_t z = 0;<br>
> > + if (surf->dim == ISL_SURF_DIM_3D) {<br>
> > + z = layer;<br>
> > + layer = 0;<br>
> > + }<br>
><br>
> This bit looks a little alarming I have to admit but looking at<br>
> isl_surf_get_image_offset_sa() tells that 'layer' is omitted and 'z'<br>
> becomes effective for 3D.<br>
><br>
> > +<br>
> > + isl_surf_get_image_offset_sa(surf, level, layer, z,<br>
> > + x_offset_sa, y_offset_sa);<br>
> > + }<br>
> > +}<br>
> > +<br>
> > void<br>
> > brw_blorp_surface_info_init(struct brw_context *brw,<br>
> > struct brw_blorp_surface_info *info,<br>
> > @@ -125,10 +207,16 @@ brw_blorp_surface_info_init(struct brw_context *brw,<br>
> > }<br>
> ><br>
> > uint32_t x_offset, y_offset;<br>
> > - intel_miptree_get_image_offset(mt, level, layer, &x_offset, &y_offset);<br>
> > + blorp_get_image_offset_sa(&brw->isl_dev, &info->surf,<br>
> > + level, layer / layer_multiplier,<br>
> > + &x_offset, &y_offset);<br>
> > +<br>
> > + uint32_t mt_x, mt_y;<br>
> > + intel_miptree_get_image_offset(mt, level, layer, &mt_x, &mt_y);<br>
> > + assert(mt_x == x_offset && mt_y == y_offset);<br>
><br>
> This is nice, makes me quite confident of the change:</p>
<p dir="ltr">Yeah, it scared me quite a bit too. Originally, I tried to do it without the assert but I got tired of annoying debugging so I did this and went no further until it passed Jenkins. :-)</p>
<p dir="ltr">> Reviewed-by: Topi Pohjolainen <<a href="mailto:topi.pohjolainen@intel.com">topi.pohjolainen@intel.com</a>><br>
><br>
> ><br>
> > - uint8_t bs = isl_format_get_layout(info->view.format)->bpb / 8;<br>
> > - isl_tiling_get_intratile_offset_el(&brw->isl_dev, info->surf.tiling, bs,<br>
> > + isl_tiling_get_intratile_offset_sa(&brw->isl_dev, info->surf.tiling,<br>
> > + info->view.format,<br>
> > info->surf.row_pitch, x_offset, y_offset,<br>
> > &info->bo_offset,<br>
> > &info->tile_x_sa, &info->tile_y_sa);<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>