<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On Wed, Sep 7, 2016 at 9:50 AM, Jason Ekstrand <span dir="ltr"><<a target="_blank" href="mailto:jason@jlekstrand.net">jason@jlekstrand.net</a>></span> wrote:<br><blockquote style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex" class="gmail_quote"><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><div><div class="gmail-h5">On Wed, Sep 7, 2016 at 9:36 AM, Nanley Chery <span dir="ltr"><<a target="_blank" href="mailto:nanleychery@gmail.com">nanleychery@gmail.com</a>></span> wrote:<br><blockquote style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex" class="gmail_quote"><div><div>On Tue, Sep 06, 2016 at 05:02:55PM -0700, Jason Ekstrand wrote:<br>
> On Tue, Sep 6, 2016 at 4:12 PM, Nanley Chery <<a target="_blank" href="mailto:nanleychery@gmail.com">nanleychery@gmail.com</a>> wrote:<br>
><br>
> > On Wed, Aug 31, 2016 at 02:22:33PM -0700, Jason Ekstrand wrote:<br>
> > > ---<br>
> > > src/intel/blorp/blorp.h | 10 ++++<br>
> > > src/intel/blorp/blorp_blit.c | 133 ++++++++++++++++++++++++++++++<br>
> > +++++++++++++<br>
> > > 2 files changed, 143 insertions(+)<br>
> > ><br>
> > > diff --git a/src/intel/blorp/blorp.h b/src/intel/blorp/blorp.h<br>
> > > index c1e93fd..6574124 100644<br>
> > > --- a/src/intel/blorp/blorp.h<br>
> > > +++ b/src/intel/blorp/blorp.h<br>
> > > @@ -109,6 +109,16 @@ blorp_blit(struct blorp_batch *batch,<br>
> > > uint32_t filter, bool mirror_x, bool mirror_y);<br>
> > ><br>
> > > void<br>
> > > +blorp_copy(struct blorp_batch *batch,<br>
> > > + const struct blorp_surf *src_surf,<br>
> > > + unsigned src_level, unsigned src_layer,<br>
> > > + const struct blorp_surf *dst_surf,<br>
> > > + unsigned dst_level, unsigned dst_layer,<br>
> > > + uint32_t src_x, uint32_t src_y,<br>
> > > + uint32_t dst_x, uint32_t dst_y,<br>
> > > + uint32_t src_width, uint32_t src_height);<br>
> > > +<br>
> > > +void<br>
> > > blorp_fast_clear(struct blorp_batch *batch,<br>
> > > const struct blorp_surf *surf,<br>
> > > uint32_t level, uint32_t layer, enum isl_format format,<br>
> > > diff --git a/src/intel/blorp/blorp_blit.c b/src/intel/blorp/blorp_blit.c<br>
> > > index 3ab39a3..42a502c 100644<br>
> > > --- a/src/intel/blorp/blorp_blit.c<br>
> > > +++ b/src/intel/blorp/blorp_blit.c<br>
> > > @@ -1685,3 +1685,136 @@ blorp_blit(struct blorp_batch *batch,<br>
> > > dst_x0, dst_y0, dst_x1, dst_y1,<br>
> > > mirror_x, mirror_y);<br>
> > > }<br>
> > > +<br>
> > > +static enum isl_format<br>
> > > +get_copy_format_for_bpb(unsig<wbr>ned bpb)<br>
> > > +{<br>
> > > + /* The choice of UNORM and UINT formats is very intentional here.<br>
> > Most of<br>
> > > + * the time, we want to use a UINT format to avoid any rounding<br>
> > error in<br>
> > > + * the blit. For stencil blits, R8_UINT is required by the hardware.<br>
> > > + * (It's the only format allowed in conjunction with W-tiling.)<br>
> > Also we<br>
> > > + * intentionally use the 4-channel formats whenever we can. This is<br>
> > so<br>
> > > + * that, when we do a RGB <-> RGBX copy, the two formats will line<br>
> > up even<br>
> > > + * though one of them is 3/4 the size of the other. The choice of<br>
> > UNORM<br>
> > > + * vs. UINT is also very intentional because Haswell doesn't handle<br>
> > 8 or<br>
> > > + * 16-bit RGB UINT formats at all so we have to use UNORM there.<br>
> > > + * Fortunately, the only time we should ever use two different<br>
> > formats in<br>
> > > + * the table below is for RGB -> RGBA blits and so we will never<br>
> > have any<br>
> > > + * UNORM/UINT mismatch.<br>
> > > + */<br>
> > > + switch (bpb) {<br>
> > > + case 8: return ISL_FORMAT_R8_UINT;<br>
> > > + case 16: return ISL_FORMAT_R8G8_UINT;<br>
> > > + case 24: return ISL_FORMAT_R8G8B8_UNORM;<br>
> > > + case 32: return ISL_FORMAT_R8G8B8A8_UNORM;<br>
> > > + case 48: return ISL_FORMAT_R16G16B16_UNORM;<br>
> > > + case 64: return ISL_FORMAT_R16G16B16A16_UNORM;<br>
> > > + case 96: return ISL_FORMAT_R32G32B32_UINT;<br>
> > > + case 128:return ISL_FORMAT_R32G32B32A32_UINT;<br>
> > > + default:<br>
> > > + unreachable("Unknown format bpb");<br>
> > > + }<br>
> > > +}<br>
> > > +<br>
> > > +static void<br>
> > > +surf_convert_to_uncompressed(<wbr>const struct isl_device *isl_dev,<br>
> > > + struct brw_blorp_surface_info *info,<br>
> > > + uint32_t *x, uint32_t *y,<br>
> > > + uint32_t *width, uint32_t *height)<br>
> > > +{<br>
> > > + const struct isl_format_layout *fmtl =<br>
> > > + isl_format_get_layout(info->su<wbr>rf.format);<br>
> > > +<br>
> > > + assert(fmtl->bw > 1 || fmtl->bh > 1);<br>
> > > +<br>
> > > + /* This is a compressed surface. We need to convert it to a single<br>
> > > + * slice (becase compressed layouts don't perfectly match<br>
> > uncompressed<br>
> > > + * ones with the same bpb) and divide x, y, width, and height by the<br>
> > > + * block size.<br>
> > > + */<br>
> > > + surf_convert_to_single_slice(<wbr>isl_dev, info);<br>
> > > +<br>
> > > + if (width || height) {<br>
> > > + assert(*width % fmtl->bw == 0 ||<br>
> > > + *x + *width == info->surf.logical_level0_px.w<wbr>idth);<br>
> > > + assert(*height % fmtl->bh == 0 ||<br>
> > > + *y + *height == info->surf.logical_level0_px.h<wbr>eight);<br>
> > > + *width = DIV_ROUND_UP(*width, fmtl->bw);<br>
> > > + *height = DIV_ROUND_UP(*height, fmtl->bh);<br>
> > > + }<br>
> > > +<br>
> > > + assert(*x % fmtl->bw == 0);<br>
> > > + assert(*y % fmtl->bh == 0);<br>
> > > + *x /= fmtl->bw;<br>
> > > + *y /= fmtl->bh;<br>
> > > +<br>
> > > + info->surf.logical_level0_px.<wbr>width =<br>
> > > + DIV_ROUND_UP(info->surf.logica<wbr>l_level0_px.width, fmtl->bw);<br>
> > > + info->surf.logical_level0_px.<wbr>height =<br>
> > > + DIV_ROUND_UP(info->surf.logica<wbr>l_level0_px.height, fmtl->bh);<br>
> > > +<br>
> > > + assert(info->surf.phys_<wbr>level0_sa.width % fmtl->bw == 0);<br>
> > > + assert(info->surf.phys_<wbr>level0_sa.height % fmtl->bh == 0);<br>
> > > + info->surf.phys_level0_sa.wid<wbr>th /= fmtl->bw;<br>
> > > + info->surf.phys_level0_sa.hei<wbr>ght /= fmtl->bh;<br>
> > > +<br>
> > > + assert(info->tile_x_sa % fmtl->bw == 0);<br>
> > > + assert(info->tile_y_sa % fmtl->bh == 0);<br>
> > > + info->tile_x_sa /= fmtl->bw;<br>
> > > + info->tile_y_sa /= fmtl->bh;<br>
> > > +<br>
> > > + /* It's now an uncompressed surface so we need an uncompressed<br>
> > format */<br>
> > > + info->surf.format = get_copy_format_for_bpb(fmtl-><wbr>bpb);<br>
> > > +}<br>
> > > +<br>
> > > +void<br>
> > > +blorp_copy(struct blorp_batch *batch,<br>
> > > + const struct blorp_surf *src_surf,<br>
> > > + unsigned src_level, unsigned src_layer,<br>
> > > + const struct blorp_surf *dst_surf,<br>
> > > + unsigned dst_level, unsigned dst_layer,<br>
> > > + uint32_t src_x, uint32_t src_y,<br>
> > > + uint32_t dst_x, uint32_t dst_y,<br>
> > > + uint32_t src_width, uint32_t src_height)<br>
> > > +{<br>
> > > + struct blorp_params params;<br>
> > > + blorp_params_init(¶ms);<br>
> > > +<br>
> > > + brw_blorp_surface_info_init(b<wbr>atch->blorp, ¶ms.src, src_surf,<br>
> > src_level,<br>
> > > + src_layer, ISL_FORMAT_UNSUPPORTED,<br>
> > false);<br>
> > > + brw_blorp_surface_info_init(b<wbr>atch->blorp, ¶ms.dst, dst_surf,<br>
> > dst_level,<br>
> > > + dst_layer, ISL_FORMAT_UNSUPPORTED, true);<br>
> > > +<br>
> > > + struct brw_blorp_blit_prog_key wm_prog_key;<br>
> > > + memset(&wm_prog_key, 0, sizeof(wm_prog_key));<br>
> > > +<br>
> > > + const struct isl_format_layout *src_fmtl =<br>
> > > + isl_format_get_layout(params.s<wbr>rc.surf.format);<br>
> > > + const struct isl_format_layout *dst_fmtl =<br>
> > > + isl_format_get_layout(params.d<wbr>st.surf.format);<br>
> > > +<br>
> > > + params.src.view.format = get_copy_format_for_bpb(src_fm<wbr>tl->bpb);<br>
> > > + if (src_fmtl->bw > 1 || src_fmtl->bh > 1) {<br>
> > > + surf_convert_to_uncompressed(b<wbr>atch->blorp->isl_dev, ¶ms.src,<br>
> > > + &src_x, &src_y, &src_width,<br>
> > &src_height);<br>
> > > + wm_prog_key.need_dst_offset = true;<br>
> > > + }<br>
> > > +<br>
> > > + params.dst.view.format = get_copy_format_for_bpb(dst_fm<wbr>tl->bpb);<br>
> > > + if (dst_fmtl->bw > 1 || dst_fmtl->bh > 1) {<br>
> > > + surf_convert_to_uncompressed(b<wbr>atch->blorp->isl_dev, ¶ms.dst,<br>
> > > + &dst_x, &dst_y, NULL, NULL);<br>
> > > + wm_prog_key.need_dst_offset = true;<br>
> > > + }<br>
> ><br>
> > When this function is later used to replace meta in vkCopyImage and the<br>
> > like,<br>
> > I suspect that copying non-zero mip levels on D16 and S8 textures can fail.<br>
> > These textures have a non-4x4 alignment on SKL and, like compressed<br>
> > textures,<br>
> > need surf_convert_to_single_slice()<wbr>.<br>
> ><br>
><br>
> I don't think that's an issue. Depth and stencil are still valid multi-LOD<br>
> textures. You don't need 4x4, you just need an alignment that we can<br>
> validly express so 4x8 (stencil), for instance, is fine. The problem with<br>
> compressed is that, when you fake it as R32U32G32A32_UINT, you can end up<br>
> with halign/valign that can't actually be expressed. On SKL, I think we<br>
> can actually express them all so we may not need the stomp at all.<br>
><br>
><br>
<br>
</div></div>My suspicion was wrong. I was under the assumption that blorp behaved like<br>
meta in that it always created an image from the tile nearest to the copy region<br>
of the src/dst image - that is not the case. Sorry for not simply asking. This<br>
seems like a much better way to copy images.<br>
<br>
This series currently causes 6 crucbile tests to fail in<br>
<a href="http://func.miptree.r8g8b8a8-unorm.as">func.miptree.r8g8b8a8-unorm.as</a><wbr>pect-color.view-3d. Does your local copy fix<br>
these? If so, could you send it out?<span><br></span></blockquote><div><br></div></div></div><div>Drp... I didn't run crucible. No CTS failures but I'm seeing the same 6 crucible fails that you are. I'll look into them.<span class="gmail-HOEnZb"><font color="#888888"><br></font></span></div></div></div></div></blockquote><div><br></div><div>Looking at the crucible fail a bit. The R8G8B8A8 failures were do to sanitizing coordinates with the type from the wrong image. I also found a couple of other bugs.<br><br></div><div>There are still failures on 3-D stencil in those tests. I'll look into them.<br><br></div><div>The latest can always be found here:<br><br><a href="https://cgit.freedesktop.org/~jekstrand/mesa/log/?h=wip/anv-blorp">https://cgit.freedesktop.org/~jekstrand/mesa/log/?h=wip/anv-blorp</a><br></div><div> </div><blockquote style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex" class="gmail_quote"><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><div><span class="gmail-HOEnZb"><font color="#888888"></font></span></div><span class="gmail-HOEnZb"><font color="#888888"><div>--Jason<br></div></font></span><div><div class="gmail-h5"><div> </div><blockquote style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex" class="gmail_quote"><span>
> > One idea is to call surf_convert_to_single_slice() when ever a copy occurs<br>
> > with an image's subresource that isn't the 1st mip level on the 1st array<br>
> > layer<br>
> > /depth slice and the alignment differs from what would be used the copy<br>
> > format.<br>
> > Thoughts?<br>
> ><br>
><br>
> That seems a bit harsh.<br>
><br>
><br>
<br>
</span>I agree.<br>
<span><font color="#888888"><br>
- Nanley<br>
</font></span><div><div><br>
> > - Nanley<br>
> ><br>
> > > +<br>
> > > + /* Once both surfaces are stompped to uncompressed as needed, the<br>
> > > + * destination size is the same as the source size.<br>
> > > + */<br>
> > > + uint32_t dst_width = src_width;<br>
> > > + uint32_t dst_height = src_height;<br>
> > > +<br>
> > > + do_blorp_blit(batch, ¶ms, &wm_prog_key,<br>
> > > + src_x, src_y, src_x + src_width, src_y + src_height,<br>
> > > + dst_x, dst_y, dst_x + dst_width, dst_y + dst_height,<br>
> > > + false, false);<br>
> > > +}<br>
> > > --<br>
> > > 2.5.0.400.gff86faf<br>
> > ><br>
> > > ______________________________<wbr>_________________<br>
> > > mesa-dev mailing list<br>
> > > <a target="_blank" href="mailto:mesa-dev@lists.freedesktop.org">mesa-dev@lists.freedesktop.org</a><br>
> > > <a target="_blank" rel="noreferrer" href="https://lists.freedesktop.org/mailman/listinfo/mesa-dev">https://lists.freedesktop.org/<wbr>mailman/listinfo/mesa-dev</a><br>
> ><br>
</div></div></blockquote></div></div></div><br></div></div>
</blockquote></div><br></div></div>