<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Mon, Sep 11, 2017 at 2:15 AM, Pohjolainen, Topi <span dir="ltr"><<a href="mailto:topi.pohjolainen@gmail.com" target="_blank">topi.pohjolainen@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="HOEnZb"><div class="h5">On Mon, Sep 11, 2017 at 10:55:36AM +0200, Iago Toral wrote:<br>
> On Fri, 2017-09-08 at 11:44 +0300, Pohjolainen, Topi wrote:<br>
> > On Fri, Sep 08, 2017 at 09:41:11AM +0200, Iago Toral wrote:<br>
> > > On Fri, 2017-09-08 at 00:34 -0700, Kenneth Graunke wrote:<br>
> > > > On Thursday, September 7, 2017 11:44:04 PM PDT Iago Toral Quiroga<br>
> > > > wrote:<br>
> > > > > It is not supported by the hardware and the driver assumes<br>
> > > > > W-tiling for stencil and Y-tiling for depth everywhere anyway.<br>
> > > > ><br>
> > > > > This fixes a regression in a CTS test introduced with commit<br>
> > > > > 4ea63fab77f0 that started applying re-tiling for these surfaces<br>
> > > > > in certain scenarios.<br>
> > > > ><br>
> > > > > Fixes:<br>
> > > > > KHR-GL45.direct_state_access.<wbr>renderbuffers_storage<br>
> > > > > ---<br>
> > > > > src/mesa/drivers/dri/i965/<wbr>intel_mipmap_tree.c | 8 ++++++--<br>
> > > > > 1 file changed, 6 insertions(+), 2 deletions(-)<br>
> > > > ><br>
> > > > > diff --git a/src/mesa/drivers/dri/i965/<wbr>intel_mipmap_tree.c<br>
> > > > > b/src/mesa/drivers/dri/i965/<wbr>intel_mipmap_tree.c<br>
> > > > > index 79afdc5342..cfc1212353 100644<br>
> > > > > --- a/src/mesa/drivers/dri/i965/<wbr>intel_mipmap_tree.c<br>
> > > > > +++ b/src/mesa/drivers/dri/i965/<wbr>intel_mipmap_tree.c<br>
> > > > > @@ -572,9 +572,13 @@ make_surface(struct brw_context *brw,<br>
> > > > > GLenum<br>
> > > > > target, mesa_format format,<br>
> > > > > <br>
> > > > > /* In case caller doesn't specifically request Y-tiling<br>
> > > > > (needed<br>
> > > > > * unconditionally for depth), check for corner cases<br>
> > > > > needing<br>
> > > > > special<br>
> > > > > - * treatment.<br>
> > > > > + * treatment. Stencil and depth surfaces are always W and<br>
> > > > > Y<br>
> > > > > tiled<br>
> > > > > + * respectively, so we should not attempt to retile them to<br>
> > > > > different<br>
> > > > > + * layouts.<br>
> > > > > */<br>
> > > > > - if (tiling_flags & ~ISL_TILING_Y0_BIT) {<br>
> > > ><br>
> > > > Based on Topi's comment, it sounds like depth surfaces should be<br>
> > > > passing<br>
> > > > tiling_flags == ISL_TILING_Y0_BIT, so we shouldn't hit this for<br>
> > > > depth.<br>
> > > ><br>
> > > > Separate stencil passes ISL_TILING_W_BIT, so I think you're right<br>
> > > > that<br>
> > > > it'll incorrectly hit this case. Perhaps we need to just change<br>
> > > > it<br>
> > > > to:<br>
> > > ><br>
> > > > if (tiling_flags & ~(ISL_TILING_Y0_BIT | ISL_TILING_W_BIT))<br>
> > > ><br>
> > > > ...? Though, basing it on usage doesn't seem bad either...<br>
> > ><br>
> > > Yeah, I noticed that the test for depth usage wasn't actually<br>
> > > required<br>
> > > after sending the patch.<br>
> > ><br>
> > > Is there anything other than depth/stencil that can use Y/W tiling<br>
> > > and<br>
> > > could be retiled to linear or X? If that is the case then I think<br>
> > > we<br>
> > > want to check against usage, otherwise we could just check against<br>
> > > the<br>
> > > tiling flags.<br>
> ><br>
> > Color renderbuffers can be X or Y (latter preferred).<br>
><br>
> Mmm... the current implementation will attempt to retile things that<br>
> are not Y-tiled, but that restriction seems to come from depth surfaces<br>
> specifically... Topi: are Y-tiled color renderbuffers ever supposed to<br>
> be retiled to linear or X? If they are, then we need to modify the code<br>
> consider the usage flags instead of the tiling flags to decide if want<br>
> to try retiling strategies. What do you think?<br>
<br>
</div></div>In make_surface():<br>
<span class=""><br>
/* In case caller doesn't specifically request Y-tiling (needed<br>
* unconditionally for depth), check for corner cases needing special<br>
</span> * treatment.<br>
*/<br>
if (tiling_flags & ~ISL_TILING_Y0_BIT) {<br>
<span class=""> if (need_to_retile_as_linear(brw, mt->surf.row_pitch,<br>
mt->surf.tiling, mt->surf.samples)) {<br>
init_info.tiling_flags = 1u << ISL_TILING_LINEAR;<br>
</span> if (!isl_surf_init_s(&brw->isl_<wbr>dev, &mt->surf, &init_info))<br>
goto fail;<br>
} else if (need_to_retile_as_x(brw, mt->surf.size, mt->surf.tiling)) {<br>
init_info.tiling_flags = 1u << ISL_TILING_X;<br>
if (!isl_surf_init_s(&brw->isl_<wbr>dev, &mt->surf, &init_info))<br>
goto fail;<br>
}<br>
}<br>
<br>
<br>
Color buffers normally are created with ISL_TILING_ANY_MASK. If<br>
isl_surf_init_s() chose Y-tiling than the block above will consider both linear<br>
and X-tiled fallbacks. Same thing if isl_surf_init_s() chose X-tiling, the<br>
block is hit and linear considered.</blockquote><div><br></div><div>I think the fundamental problem here is that these decisions really need to be made in ISL in the long term. If we're going to support GL_EXT_external_objects then we can't have any per-driver heuristics because they'll break image compatibility between the two. It's going to depend on the need_to_retile_* condition whether it needs to be pulled into ISL or removed entirely. For instance, the "too big to blit" should probably be solved by using blorp_copy instead of the blitter in those cases rather than falling back to linear.<br></div><div><br></div><div>Sorry for not chipping in earlier. :-( I think v2 of Iago's patch is fine for now but we need to start moving in the direction where basically all i965 ever does is call into ISL and ISL makes the decisions.<br></div></div></div></div>