<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On Wed, Apr 12, 2017 at 2:54 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"><span class="">On Tue, Apr 11, 2017 at 07:54:23AM -0700, Jason Ekstrand wrote:<br>
> The Vulkan driver was originally written under the assumption that<br>
> VK_ATTACHMENT_UNUSED was basically just for depth-stencil attachments.<br>
> However, the way things fell together, VK_ATTACHMENT_UNUSED can be used<br>
> anywhere in the subpass description.  The blorp-based clear and resolve<br>
> code has a bunch of places where we walk lists of attachments and we<br>
> weren't handling VK_ATTACHMENT_UNUSED everywhere.  This commit should<br>
> fix all of them.<br>
><br>
> Cc: "13.0 17.0" <<a href="mailto:mesa-stable@lists.freedesktop.org">mesa-stable@lists.<wbr>freedesktop.org</a>><br>
<br>
</span>I think specifying the specific stable branch in quotes has been<br>
deprecated according to<br>
<a href="https://www.mesa3d.org/submittingpatches.html#nominations" rel="noreferrer" target="_blank">https://www.mesa3d.org/<wbr>submittingpatches.html#<wbr>nominations</a><br>
<div><div class="h5"><br>
> ---<br>
>  src/intel/vulkan/anv_blorp.c | 30 +++++++++++++++++++++++++-----<br>
>  1 file changed, 25 insertions(+), 5 deletions(-)<br>
><br>
> diff --git a/src/intel/vulkan/anv_blorp.c b/src/intel/vulkan/anv_blorp.c<br>
> index 72a468a..d27132a 100644<br>
> --- a/src/intel/vulkan/anv_blorp.c<br>
> +++ b/src/intel/vulkan/anv_blorp.c<br>
> @@ -1148,6 +1148,9 @@ anv_cmd_buffer_flush_<wbr>attachments(struct anv_cmd_buffer *cmd_buffer,<br>
><br>
>     for (uint32_t i = 0; i < subpass->color_count; ++i) {<br>
>        uint32_t att = subpass->color_attachments[i].<wbr>attachment;<br>
> +      if (att == VK_ATTACHMENT_UNUSED)<br>
> +         continue;<br>
> +<br>
>        assert(att < pass->attachment_count);<br>
>        if (attachment_needs_flush(cmd_<wbr>buffer, &pass->attachments[att], stage)) {<br>
>           cmd_buffer->state.pending_<wbr>pipe_bits |=<br>
> @@ -1175,14 +1178,19 @@ subpass_needs_clear(const struct anv_cmd_buffer *cmd_buffer)<br>
><br>
>     for (uint32_t i = 0; i < cmd_state->subpass->color_<wbr>count; ++i) {<br>
>        uint32_t a = cmd_state->subpass->color_<wbr>attachments[i].attachment;<br>
> +      if (a == VK_ATTACHMENT_UNUSED)<br>
> +         continue;<br>
> +<br>
> +      assert(a < cmd_state->pass->attachment_<wbr>count);<br>
>        if (cmd_state->attachments[a].<wbr>pending_clear_aspects) {<br>
>           return true;<br>
>        }<br>
>     }<br>
><br>
> -   if (ds != VK_ATTACHMENT_UNUSED &&<br>
> -       cmd_state->attachments[ds].<wbr>pending_clear_aspects) {<br>
> -      return true;<br>
> +   if (ds != VK_ATTACHMENT_UNUSED) {<br>
> +      assert(ds < cmd_state->pass->attachment_<wbr>count);<br>
> +      if (cmd_state->attachments[ds].<wbr>pending_clear_aspects)<br>
> +         return true;<br>
<br>
</div></div>I'll refer to this hunk below.<br>
<span class=""><br>
>     }<br>
><br>
>     return false;<br>
> @@ -1214,6 +1222,10 @@ anv_cmd_buffer_clear_subpass(<wbr>struct anv_cmd_buffer *cmd_buffer)<br>
>     struct anv_framebuffer *fb = cmd_buffer->state.framebuffer;<br>
>     for (uint32_t i = 0; i < cmd_state->subpass->color_<wbr>count; ++i) {<br>
>        const uint32_t a = cmd_state->subpass->color_<wbr>attachments[i].attachment;<br>
> +      if (a == VK_ATTACHMENT_UNUSED)<br>
> +         continue;<br>
> +<br>
> +      assert(a < cmd_state->pass->attachment_<wbr>count);<br>
>        struct anv_attachment_state *att_state = &cmd_state->attachments[a];<br>
><br>
>        if (!att_state->pending_clear_<wbr>aspects)<br>
> @@ -1273,6 +1285,7 @@ anv_cmd_buffer_clear_subpass(<wbr>struct anv_cmd_buffer *cmd_buffer)<br>
>     }<br>
><br>
>     const uint32_t ds = cmd_state->subpass->depth_<wbr>stencil_attachment.attachment;<br>
> +   assert(ds == VK_ATTACHMENT_UNUSED || ds < cmd_state->pass->attachment_<wbr>count);<br>
><br>
<br>
</span>I wonder why this assertion differs from the one two hunks up.<br></blockquote><div><br></div><div>Not a good reason, but I prefer the simpler assert above but trying to do that here would have meant an extra unneeded level of control-flow nesting.  The one above is just an "if (...) return true;" so adding nesting wasn't a big deal.<br></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Nevertheless, this series is<br>
Reviewed-by: Nanley Chery <<a href="mailto:nanley.g.chery@intel.com">nanley.g.chery@intel.com</a>><br>
<div><div class="h5"><br>
>     if (ds != VK_ATTACHMENT_UNUSED &&<br>
>         cmd_state->attachments[ds].<wbr>pending_clear_aspects) {<br>
> @@ -1578,8 +1591,12 @@ anv_cmd_buffer_resolve_<wbr>subpass(struct anv_cmd_buffer *cmd_buffer)<br>
>     blorp_batch_init(&cmd_buffer-><wbr>device->blorp, &batch, cmd_buffer, 0);<br>
><br>
>     for (uint32_t i = 0; i < subpass->color_count; ++i) {<br>
> -      ccs_resolve_attachment(cmd_<wbr>buffer, &batch,<br>
> -                             subpass->color_attachments[i].<wbr>attachment);<br>
> +      const uint32_t att = subpass->color_attachments[i].<wbr>attachment;<br>
> +      if (att == VK_ATTACHMENT_UNUSED)<br>
> +         continue;<br>
> +<br>
> +      assert(att < cmd_buffer->state.pass-><wbr>attachment_count);<br>
> +      ccs_resolve_attachment(cmd_<wbr>buffer, &batch, att);<br>
>     }<br>
><br>
>     anv_cmd_buffer_flush_<wbr>attachments(cmd_buffer, SUBPASS_STAGE_DRAW);<br>
> @@ -1592,6 +1609,9 @@ anv_cmd_buffer_resolve_<wbr>subpass(struct anv_cmd_buffer *cmd_buffer)<br>
>           if (dst_att == VK_ATTACHMENT_UNUSED)<br>
>              continue;<br>
><br>
> +         assert(src_att < cmd_buffer->state.pass-><wbr>attachment_count);<br>
> +         assert(dst_att < cmd_buffer->state.pass-><wbr>attachment_count);<br>
> +<br>
>           if (cmd_buffer->state.<wbr>attachments[dst_att].pending_<wbr>clear_aspects) {<br>
>              /* From the Vulkan 1.0 spec:<br>
>               *<br>
> --<br>
> 2.5.0.400.gff86faf<br>
><br>
</div></div>> ______________________________<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>
</blockquote></div><br></div></div>