<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Thu, Jun 15, 2017 at 10:14 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"><span>On Thu, Jun 15, 2017 at 09:41:42AM -0700, Jason Ekstrand wrote:<br>
> On Thu, Jun 15, 2017 at 9:36 AM, Jason Ekstrand <<a href="mailto:jason@jlekstrand.net" target="_blank">jason@jlekstrand.net</a>><br>
> wrote:<br>
><br>
> > This patch makes the assumption that, if stencil_irb != NULL then<br>
> > depth_irb != NULL.  I did a bunch of digging and I am now convinced that<br>
> > this is a fine assumption.  Specifically, in intel_renderbuffer_format() in<br>
> > intel_fbo.c, we map all STENCIL_INDEX internal formats to Z24_UNORM_S8_UINT<br>
> > on gen4-5.<br>
> ><br>
<br>
</span>It shouldn't.<br>
<div><div class="m_-7605881083323770664h5"><br>
><br>
> Except that patch 1 only makes a difference if (stencil_irb && !depth_irb)<br>
> can be true.  Now I'm very confused...<br>
><br>
><br>
> > On Mon, May 22, 2017 at 12:12 PM, Topi Pohjolainen <<br>
> > <a href="mailto:topi.pohjolainen@gmail.com" target="_blank">topi.pohjolainen@gmail.com</a>> wrote:<br>
> ><br>
> >> In case of gen < 6 stencil (if present) is always combined with<br>
> >> depth. Both stencil and depth attachments point to the same<br>
> >> physical surface.<br>
> >> Alignment workaround starts by considering depth and updates<br>
> >> stencil accordingly. Current logic continues with stencil and<br>
> >> in vain considers the case where depth would refer to different<br>
> >> surface than stencil.<br>
> >><br>
> >> Signed-off-by: Topi Pohjolainen <<a href="mailto:topi.pohjolainen@intel.com" target="_blank">topi.pohjolainen@intel.com</a>><br>
> >> ---<br>
> >>  src/mesa/drivers/dri/i965/brw_<wbr>misc_state.c | 63<br>
> >> ++++++------------------------<br>
> >>  1 file changed, 12 insertions(+), 51 deletions(-)<br>
> >><br>
> >> diff --git a/src/mesa/drivers/dri/i965/br<wbr>w_misc_state.c<br>
> >> b/src/mesa/drivers/dri/i965/br<wbr>w_misc_state.c<br>
> >> index 6ea1fb0..9fe3655 100644<br>
> >> --- a/src/mesa/drivers/dri/i965/br<wbr>w_misc_state.c<br>
> >> +++ b/src/mesa/drivers/dri/i965/br<wbr>w_misc_state.c<br>
> >> @@ -295,28 +295,14 @@ brw_workaround_depthstencil_al<wbr>ignment(struct<br>
> >> brw_context *brw,<br>
> >>        }<br>
> >><br>
> >>        if (stencil_irb) {<br>
> >> -         stencil_mt = get_stencil_miptree(stencil_ir<wbr>b);<br>
> >> -         intel_miptree_get_image_offse<wbr>t(stencil_mt,<br>
> >> -                                        stencil_irb->mt_level,<br>
> >> -                                        stencil_irb->mt_layer,<br>
> >> -                                        &stencil_draw_x,<br>
> >> &stencil_draw_y);<br>
> >> -         int stencil_tile_x = stencil_draw_x & tile_mask_x;<br>
> >> -         int stencil_tile_y = stencil_draw_y & tile_mask_y;<br>
> >> -<br>
> >> -         /* If stencil doesn't match depth, then we'll need to rebase<br>
> >> stencil<br>
> >> -          * as well.  (if we hadn't decided to rebase stencil before, the<br>
> >> -          * post-stencil depth test will also rebase depth to try to<br>
> >> match it<br>
> >> -          * up).<br>
> >> -          */<br>
> >> -         if (tile_x != stencil_tile_x ||<br>
> >> -             tile_y != stencil_tile_y) {<br>
> >> -            rebase_stencil = true;<br>
> >> -         }<br>
> >> +         assert(stencil_irb->mt == depth_irb->mt);<br>
> >> +         assert(stencil_irb->mt_level == depth_irb->mt_level);<br>
> >> +         assert(stencil_irb->mt_layer == depth_irb->mt_layer);<br>
<br>
</div></div>This is inside a branch "if (depth_irb)" and therefore I'm simply asserting<br>
that in case stencil also exists, it must point to the same miptree.<span><br></span></blockquote><div><br></div><div>Sorry, I missed that.<br></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span>
> >>        }<br>
> >>     }<br>
> >><br>
> >>     /* If we have (just) stencil, check it for ignored low bits as well */<br>
> >> -   if (stencil_irb) {<br>
> >> +   if (!depth_irb && stencil_irb) {<br>
<br>
</span>Here we handle the case where there is stencil but no depth - a valid case<br>
and hit by a few piglits.<br><div class="m_-7605881083323770664HOEnZb"><div class="m_-7605881083323770664h5"></div></div></blockquote><div><br></div><div>Ok, that makes more sense.<br><br></div><div>Reviewed-by: Jason Ekstrand <<a href="mailto:jason@jlekstrand.net">jason@jlekstrand.net</a>><br><br></div><div>Carrying on...<br></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="m_-7605881083323770664HOEnZb"><div class="m_-7605881083323770664h5">
> >>        intel_miptree_get_image_offset<wbr>(stencil_mt,<br>
> >>                                       stencil_irb->mt_level,<br>
> >>                                       stencil_irb->mt_layer,<br>
> >> @@ -334,6 +320,14 @@ brw_workaround_depthstencil_al<wbr>ignment(struct<br>
> >> brw_context *brw,<br>
> >>     }<br>
> >><br>
> >>     if (rebase_stencil) {<br>
> >> +      /* If stencil needs rebase, there isn't a depth attachment and the<br>
> >> +       * combined depth-stencil is used for stencil only. Otherwise in<br>
> >> case<br>
> >> +       * depth attachment is present both stencil and depth point to the<br>
> >> same<br>
> >> +       * miptree. Rebase of depth is considered first updating stencil<br>
> >> +       * attachment accordingly - hence stencil is rebased only if there<br>
> >> is no<br>
> >> +       * depth attachment.<br>
> >> +       */<br>
> >> +      assert(!depth_irb);<br>
> >>        perf_debug("HW workaround: blitting stencil level %d to a<br>
> >> temporary "<br>
> >>                   "to fix alignment (stencil tile offset %d,%d)\n",<br>
> >>                   stencil_irb->mt_level, stencil_tile_x, stencil_tile_y);<br>
> >> @@ -347,39 +341,6 @@ brw_workaround_depthstencil_al<wbr>ignment(struct<br>
> >> brw_context *brw,<br>
> >>                                       &stencil_draw_x, &stencil_draw_y);<br>
> >>        stencil_tile_x = stencil_draw_x & tile_mask_x;<br>
> >>        stencil_tile_y = stencil_draw_y & tile_mask_y;<br>
> >> -<br>
> >> -      if (depth_irb && depth_irb->mt == stencil_irb->mt) {<br>
> >> -         intel_miptree_reference(&dept<wbr>h_irb->mt, stencil_irb->mt);<br>
> >> -         intel_renderbuffer_set_draw_o<wbr>ffset(depth_irb);<br>
> >> -      } else if (depth_irb && !rebase_depth) {<br>
> >> -         if (tile_x != stencil_tile_x ||<br>
> >> -             tile_y != stencil_tile_y) {<br>
> >> -            perf_debug("HW workaround: blitting depth level %d to a<br>
> >> temporary "<br>
> >> -                       "to match stencil level %d alignment (depth tile<br>
> >> offset "<br>
> >> -                       "%d,%d, stencil offset %d,%d)\n",<br>
> >> -                       depth_irb->mt_level,<br>
> >> -                       stencil_irb->mt_level,<br>
> >> -                       tile_x, tile_y,<br>
> >> -                       stencil_tile_x, stencil_tile_y);<br>
> >> -<br>
> >> -            intel_renderbuffer_move_to_tem<wbr>p(brw, depth_irb,<br>
> >> invalidate_depth);<br>
> >> -<br>
> >> -            tile_x = depth_irb->draw_x & tile_mask_x;<br>
> >> -            tile_y = depth_irb->draw_y & tile_mask_y;<br>
> >> -<br>
> >> -            if (stencil_irb && stencil_irb->mt == depth_mt) {<br>
> >> -               intel_miptree_reference(&sten<wbr>cil_irb->mt, depth_irb->mt);<br>
> >> -               intel_renderbuffer_set_draw_o<wbr>ffset(stencil_irb);<br>
> >> -            }<br>
> >> -<br>
> >> -            WARN_ONCE(stencil_tile_x != tile_x ||<br>
> >> -                      stencil_tile_y != tile_y,<br>
> >> -                      "Rebased stencil tile offset (%d,%d) doesn't match<br>
> >> depth "<br>
> >> -                      "tile offset (%d,%d).\n",<br>
> >> -                      stencil_tile_x, stencil_tile_y,<br>
> >> -                      tile_x, tile_y);<br>
> >> -         }<br>
> >> -      }<br>
> >>     }<br>
> >><br>
> >>     if (!depth_irb) {<br>
> >> --<br>
> >> 2.9.3<br>
> >><br>
> >> ______________________________<wbr>_________________<br>
> >> mesa-dev mailing list<br>
> >> <a href="mailto:mesa-dev@lists.freedesktop.org" target="_blank">mesa-dev@lists.freedesktop.org</a><br>
> >> <a href="https://lists.freedesktop.org/mailman/listinfo/mesa-dev" rel="noreferrer" target="_blank">https://lists.freedesktop.org/<wbr>mailman/listinfo/mesa-dev</a><br>
> >><br>
> ><br>
> ><br>
</div></div></blockquote></div><br></div></div>