<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Thu, Apr 26, 2018 at 11:19 AM, Rafael Antognolli <span dir="ltr"><<a href="mailto:rafael.antognolli@intel.com" target="_blank">rafael.antognolli@intel.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 Thu, Apr 26, 2018 at 10:41:37AM -0700, Nanley Chery wrote:<br>
> On Wed, Apr 25, 2018 at 08:53:36PM -0400, Jason Ekstrand wrote:<br>
> > <br>
> > <br>
> > On April 25, 2018 20:25:16 Nanley Chery <<a href="mailto:nanleychery@gmail.com">nanleychery@gmail.com</a>> wrote:<br>
> > <br>
> > On Wed, Apr 25, 2018 at 04:50:11PM -0700, Jason Ekstrand wrote:<br>
> > On Tue, Apr 24, 2018 at 5:48 PM, Nanley Chery <<a href="mailto:nanleychery@gmail.com">nanleychery@gmail.com</a>> wrote:<br>
> > <br>
> <br>
> Your email client dropped the quotes :/ Thankfully, gmail can pick out<br>
> the diff.<br>
> <br>
> > Determine the predicate for updating the indirect depth value in the<br>
> > loop which inspects whether or not we need to resolve any slices.<br>
> > ---<br>
> > src/mesa/drivers/dri/i965/brw_<wbr>clear.c | 43 +++++++++++++-----------------<br>
> > -----<br>
> > 1 file changed, 16 insertions(+), 27 deletions(-)<br>
> > <br>
> > diff --git a/src/mesa/drivers/dri/i965/<wbr>brw_clear.c<br>
> > b/src/mesa/drivers/dri/i965/<wbr>brw_clear.c<br>
> > index 6521141d7f6..e372d28926e 100644<br>
> > --- a/src/mesa/drivers/dri/i965/<wbr>brw_clear.c<br>
> > +++ b/src/mesa/drivers/dri/i965/<wbr>brw_clear.c<br>
> > @@ -108,7 +108,6 @@ brw_fast_clear_depth(struct gl_context *ctx)<br>
> > struct intel_mipmap_tree *mt = depth_irb->mt;<br>
> > struct gl_renderbuffer_attachment *depth_att =<br>
> > &fb->Attachment[BUFFER_DEPTH];<br>
> > const struct gen_device_info *devinfo = &brw->screen->devinfo;<br>
> > - bool same_clear_value = true;<br>
> > <br>
> > if (devinfo->gen < 6)<br>
> > return false;<br>
> > @@ -174,9 +173,16 @@ brw_fast_clear_depth(struct gl_context *ctx)<br>
> > const uint32_t num_layers = depth_att->Layered ?<br>
> > depth_irb->layer_count : 1;<br>
> > <br>
> > /* If we're clearing to a new clear value, then we need to resolve any<br>
> > clear<br>
> > - * flags out of the HiZ buffer into the real depth buffer.<br>
> > + * flags out of the HiZ buffer into the real depth buffer and update<br>
> > the<br>
> > + * miptree's clear value.<br>
> > */<br>
> > if (mt->fast_clear_color.f32[0] != clear_value) {<br>
> > + /* BLORP updates the indirect clear color buffer when we do fast<br>
> > clears.<br>
> > + * If we won't do a fast clear, we'll have to update it ourselves.<br>
> > Start<br>
> > + * off assuming we won't perform a fast clear.<br>
> > + */<br>
> > + bool blorp_will_update_indirect_<wbr>color = false;<br>
> > <br>
> > This boolean is rather awkward.<br>
> > <br>
> > Why's that?<br>
> > <br>
> > It does have a clear meaning and it does what it says it does. However,<br>
> > it's not that obvious of a thing to work with compared to "did we do a<br>
> > clear?"<br>
> > <br>
> > <br>
> > +<br>
> > for (uint32_t level = mt->first_level; level <= mt->last_level;<br>
> > level++) {<br>
> > if (!intel_miptree_level_has_hiz(<wbr>mt, level))<br>
> > continue;<br>
> > @@ -184,16 +190,20 @@ brw_fast_clear_depth(struct gl_context *ctx)<br>
> > const unsigned level_layers = brw_get_num_logical_layers(mt,<br>
> > level);<br>
> > <br>
> > for (uint32_t layer = 0; layer < level_layers; layer++) {<br>
> > + const enum isl_aux_state aux_state =<br>
> > + intel_miptree_get_aux_state(<wbr>mt, level, layer);<br>
> > +<br>
> > if (level == depth_irb->mt_level &&<br>
> > layer >= depth_irb->mt_layer &&<br>
> > layer < depth_irb->mt_layer + num_layers) {<br>
> > +<br>
> > + if (aux_state != ISL_AUX_STATE_CLEAR)<br>
> > + blorp_will_update_indirect_<wbr>color = true;<br>
> > <br>
> > Putting this here separates the detection of whether or not we are doing a<br>
> > fast clear (and therefore don't need to set the clear color) even further<br>
> > from where we do the clear and use this value than it was previously.<br>
> > <br>
> > <br>
> <br>
> Sure.<br>
> <br>
> > +<br>
> > /* We're going to clear this layer anyway. Leave it<br>
> > alone. */<br>
> > continue;<br>
> > }<br>
> > <br>
> > - enum isl_aux_state aux_state =<br>
> > - intel_miptree_get_aux_state(<wbr>mt, level, layer);<br>
> > -<br>
> > if (aux_state != ISL_AUX_STATE_CLEAR &&<br>
> > aux_state != ISL_AUX_STATE_COMPRESSED_<wbr>CLEAR) {<br>
> > /* This slice doesn't have any fast-cleared bits. */<br>
> > @@ -214,29 +224,8 @@ brw_fast_clear_depth(struct gl_context *ctx)<br>
> > }<br>
> > <br>
> > intel_miptree_set_depth_clear_<wbr>value(brw, mt, clear_value);<br>
> > - same_clear_value = false;<br>
> > - }<br>
> > -<br>
> > - bool need_clear = false;<br>
> > - for (unsigned a = 0; a < num_layers; a++) {<br>
> > - enum isl_aux_state aux_state =<br>
> > - intel_miptree_get_aux_state(<wbr>mt, depth_irb->mt_level,<br>
> > - depth_irb->mt_layer + a);<br>
> > -<br>
> > - if (aux_state != ISL_AUX_STATE_CLEAR) {<br>
> > - need_clear = true;<br>
> > - break;<br>
> > - }<br>
> > - }<br>
> > -<br>
> > - if (!need_clear) {<br>
> > - if (!same_clear_value) {<br>
> > - /* BLORP updates the indirect clear color buffer when performing<br>
> > a<br>
> > - * fast clear. Since we are skipping the fast clear here, we<br>
> > need to<br>
> > - * do the update ourselves.<br>
> > - */<br>
> > + if (!blorp_will_update_indirect_<wbr>color)<br>
> > intel_miptree_update_indirect_<wbr>color(brw, mt);<br>
> > - }<br>
> > <br>
> > I think we can do this even better. We could do<br>
> > <br>
> > bool blorp_updated_indirect_clear_<wbr>color = false;<br>
> > <br>
> > and then set it to true if we call intel_hiz_exec below. Then, after the<br>
> > loop below we would do<br>
> > <br>
> > if (!blorp_updated_indirect_<wbr>clear_color)<br>
> > intel_miptree_update_indirect_<wbr>color(brw, mt);<br>
> > <br>
> > after we've done the clears.<br>
> > <br>
> > I had something like that originally and I think that solution would<br>
> > have marginally better performance. I went with doing it this way<br>
> > because it allows us to:<br>
> > <br>
> > * Do all the clear color updates in one place.<br>
> > <br>
> > That's sort-of true. It puts all the clear color updated that happen in<br>
> > this function together. But there is another update that BLORP is doing<br>
> > that, I would argue, it separates even further.<br>
> > <br>
> > <br>
> <br>
> I don't see how it's being separated further. This is the flow of the<br>
> current patch:<br>
> <br>
> * Update the inline miptree color<br>
> * Update the indirect miptree color ourselves<br>
> * Update the indirect miptree color through BLORP<br>
> * Do the fast-clear operation through BLORP<br>
> <br>
> This is the flow of the suggested patch:<br>
> <br>
> * Update the inline miptree color<br>
> * Update the indirect miptree color through BLORP<br>
> * Do the fast-clear operation through BLORP<br>
> * Update the indirect miptree color ourselves<br></div></div></blockquote><div><br></div><div>Ok, I guess I see how that looks closer in some way.<br></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="HOEnZb"><div class="h5">
> As we're discussing this, I'm starting to wonder if we should make it<br>
> possible to opt-out of BLORP's update of the indirect color. In GL, we<br>
> clear slice-by-slice to avoid fast-clearing something that's already<br>
> cleared. Since we aren't clearing the whole range at once, BLORP will<br>
> write the indirect clear color multiple times. We could avoid these<br>
> duplicate writes by just having intel_miptree_set_depth_clear_<wbr>value()<br>
> and the like update the indirect color if the clear value has changed.<br>
> That would also solve the issues we're discussing here. Thoughts?<br>
<br>
</div></div>If you want to opt out of BLORP's update of the indirect clear color,<br>
you can just not set the clear color address during a fast clear. This<br>
way, blorp will just stomp the clear state in the aux buffer, but not<br>
update the color.<br></blockquote><div><br></div><div>Yeah, that's starting to sound like a good idea. We could easily add a blorp_batch_flag for "don't auto-update the clear color" and use it from GL. Or we can just move the clear color updating back into Vulkan.<br></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
We still need to set the clear color address during a resolve, so BLORP<br>
can use it, but it won't update the clear color state buffer.<br>
<div class="HOEnZb"><div class="h5"><br>
> > * Place blorp_will_update_indirect_<wbr>color in a scope smaller<br>
> > than the function.<br>
> > <br>
> > True, but it's declaration, update, and use are much further apart in terms<br>
> > of logic and lines of code. Also, it's much further away from it's real<br>
> > meaning which is determined by the loop below. I dislike tightly coupled<br>
> > lots that look almost nothing some and have to agree on a value. Before<br>
> > this patch, we had two such loops but they were small and structured the<br>
> > same so it was ready to verify that the generated value was correct. Now,<br>
> > we're generating it in a very different looking loop so that's much harder<br>
> > to verify.<br>
> > <br>
> > <br>
> <br>
> Okay, I can see the difficulty in that.<br>
> <br>
> > * Delete more code.<br>
> > <br>
> > I think what I suggested below is actually less code.<br>
> > <br>
> > <br>
> <br>
> Right. If also I modify how we set same_clear_value, I think it'll<br>
> result in one less line.<br>
> <br>
> -Nanley<br>
> <br>
> > If we wait until the loop below to assign<br>
> > blorp_updated_indirect_clear_<wbr>color, we have to keep the same_clear_value<br>
> > variable around and then do:<br>
> > <br>
> > Yes, we would. However, that's a very straightforward and obvious value to<br>
> > keep around.<br>
> > <br>
> > --Jason<br>
> > <br>
> > <br>
> > if (!blorp_updated_indirect_<wbr>clear_color && !same_clear_value)<br>
> > intel_miptree_update_indirect_<wbr>color(brw, mt);<br>
> > <br>
> > -Nanley<br>
> > <br>
> > }<br>
> > <br>
> > for (unsigned a = 0; a < num_layers; a++) {<br>
> > --<br>
> > 2.16.2<br>
> > <br>
> > ______________________________<wbr>_________________<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" rel="noreferrer" target="_blank">https://lists.freedesktop.org/<wbr>mailman/listinfo/mesa-dev</a><br>
> > <br>
> > <br>
> > <br>
> ______________________________<wbr>_________________<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" rel="noreferrer" target="_blank">https://lists.freedesktop.org/<wbr>mailman/listinfo/mesa-dev</a><br>
</div></div></blockquote></div><br></div></div>