<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Mon, Jun 19, 2017 at 4:46 PM, Nanley Chery <span dir="ltr"><<a href="mailto:nanleychery@gmail.com" target="_blank">nanleychery@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, Jun 19, 2017 at 04:16:32PM -0700, Jason Ekstrand wrote:<br>
> On Tue, Jun 13, 2017 at 11:41 AM, Nanley Chery <<a href="mailto:nanleychery@gmail.com">nanleychery@gmail.com</a>><br>
> wrote:<br>
><br>
> > v2:<br>
> > - Check for aux levels in layer helper (Jason Ekstrand)<br>
> > - Don't assert aux is present, return 0 if it isn't.<br>
> > - Use the helpers.<br>
> ><br>
> > Signed-off-by: Nanley Chery <<a href="mailto:nanley.g.chery@intel.com">nanley.g.chery@intel.com</a>><br>
> > ---<br>
> > src/intel/vulkan/anv_blorp.c | 4 ++++<br>
> > src/intel/vulkan/anv_private.h | 39 ++++++++++++++++++++++++++++++<br>
> > +++++++++<br>
> > 2 files changed, 43 insertions(+)<br>
> ><br>
> > diff --git a/src/intel/vulkan/anv_blorp.c b/src/intel/vulkan/anv_blorp.c<br>
> > index a869eebc24..421f860428 100644<br>
> > --- a/src/intel/vulkan/anv_blorp.c<br>
> > +++ b/src/intel/vulkan/anv_blorp.c<br>
> > @@ -1436,6 +1436,7 @@ anv_image_ccs_clear(struct anv_cmd_buffer<br>
> > *cmd_buffer,<br>
> > const struct isl_view *view,<br>
> > const VkImageSubresourceRange *subresourceRange)<br>
> > {<br>
> > + assert(anv_image_has_color_<wbr>aux(image) && image->samples == 1);<br>
> > assert(image->type == VK_IMAGE_TYPE_3D || image->extent.depth == 1);<br>
> ><br>
> > struct blorp_batch batch;<br>
> > @@ -1488,6 +1489,9 @@ anv_image_ccs_clear(struct anv_cmd_buffer<br>
> > *cmd_buffer,<br>
> > blorp_layer_count = anv_get_layerCount(image, subresourceRange);<br>
> > }<br>
> ><br>
> > + assert(level < anv_color_aux_levels(image));<br>
> > + assert(blorp_base_layer + blorp_layer_count <=<br>
> > + anv_color_aux_layers(image, level));<br>
> > blorp_fast_clear(&batch, &surf, surf.surf->format,<br>
> > level, blorp_base_layer, blorp_layer_count,<br>
> > 0, 0, extent.width, extent.height);<br>
> > diff --git a/src/intel/vulkan/anv_<wbr>private.h b/src/intel/vulkan/anv_<br>
> > private.h<br>
> > index fe6ac3bc1b..32aec7782b 100644<br>
> > --- a/src/intel/vulkan/anv_<wbr>private.h<br>
> > +++ b/src/intel/vulkan/anv_<wbr>private.h<br>
> > @@ -2071,6 +2071,45 @@ struct anv_image {<br>
> > struct anv_surface aux_surface;<br>
> > };<br>
> ><br>
> > +/* Return whether or not the image has a color auxiliary buffer. */<br>
> > +static inline bool<br>
> > +anv_image_has_color_aux(const struct anv_image * const image)<br>
> > +{<br>
> > + assert(image);<br>
> > +<br>
> > + return image->aspects == VK_IMAGE_ASPECT_COLOR_BIT &&<br>
> > + image->aux_surface.isl.size > 0;<br>
> ><br>
><br>
> I'm not a big fan of conflating CCS and MCS. We do that in i965 today and<br>
> it's no end of pain. How about anv_image_has_ccs and restrict on sample<br>
> count as well? Same comment applies to the two below.<br>
><br>
><br>
<br>
</div></div>I'm not sure I understand your concern here, but I can create two<br>
functions instead. I think most of the callers of this function only<br>
care about whether or not there's a color buffer with CCS or MCS.<br>
(You can find more of the callers here:<br>
<a href="https://cgit.freedesktop.org/~nchery/mesa/log/?h=vk/perf/layout-ccsd-resolves-v3" rel="noreferrer" target="_blank">https://cgit.freedesktop.org/~<wbr>nchery/mesa/log/?h=vk/perf/<wbr>layout-ccsd-resolves-v3</a> )<span class=""><br></span></blockquote><div><br></div><div>My concern is that "color aux" isn't really a useful thing. You could call it anv_image_has_aux and make it apply to everything, or we can make it specific in which case it should be has_ccs. Separating it into depth and color without splitting out MSAA is deceptive.<br></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class="">
> > +}<br>
> > +<br>
> > +/* Returns the number of auxiliary buffer levels attached to a color<br>
> > image. */<br>
> > +static inline uint8_t<br>
> > +anv_color_aux_levels(const struct anv_image * const image)<br>
> > +{<br>
> > + assert(image && image->aspects == VK_IMAGE_ASPECT_COLOR_BIT);<br>
> > + return anv_image_has_color_aux(image) ? image->aux_surface.isl.levels<br>
> > : 0;<br>
> ><br>
><br>
> Is there some reason why we can't or shouldn't assert anv_image_has_ccs? I<br>
> haven't read all of the users of these helpers so maybe there's something<br>
> really useful about having them silently return 0.<br>
><br>
><br>
<br>
</span>We did previously. With your suggestion of returning 0 in the below<br>
function, I thought that it would make sense to give this function the<br>
same behavior.<span class=""><br></span></blockquote><div><br></div><div>If I've managed go suggest that we do it both ways, then I clearly don't care. Let's just go with what you have here. As stated above, making it anv_image_aux_levels instead of mentioning color would be good though.<br></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class="">
> > +}<br>
> > +<br>
> > +/* Returns the number of auxiliary buffer layers attached to a color<br>
> > image. */<br>
> > +static inline uint32_t<br>
> > +anv_color_aux_layers(const struct anv_image * const image,<br>
> > + const uint8_t miplevel)<br>
> > +{<br>
> > + assert(image && image->aspects == VK_IMAGE_ASPECT_COLOR_BIT);<br>
> > +<br>
> > + /* The miplevel must exist in the main buffer. */<br>
> > + assert(miplevel < image->levels);<br>
> ><br>
><br>
> Similarly can we or should we assert that miplevel < anv_color_aux_levels()?<br>
><br>
><br>
<br>
</span>I'm confused, you suggested that we return 0 in your previous review of<br>
this patch.<br>
<div class="HOEnZb"><div class="h5"><br>
> > +<br>
> > + if (miplevel >= anv_color_aux_levels(image)) {<br>
> > + /* There are no layers with auxiliary data because the miplevel has<br>
> > no<br>
> > + * auxiliary data.<br>
> > + */<br>
> > + return 0;<br>
> > + } else {<br>
> > + return MAX2(image->aux_surface.isl.<wbr>logical_level0_px.array_len,<br>
> > + image->aux_surface.isl.<wbr>logical_level0_px.depth >><br>
> > miplevel);<br>
> > + }<br>
> > +}<br>
> > +<br>
> > /* Returns true if a HiZ-enabled depth buffer can be sampled from. */<br>
> > static inline bool<br>
> > anv_can_sample_with_hiz(const struct gen_device_info * const devinfo,<br>
> > --<br>
> > 2.13.1<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>
</div></div></blockquote></div><br></div></div>