anv/blorp: Handle VK_ATTACHMENT_UNUSED in CmdClearAttachments
authorJason Ekstrand <jason.ekstrand@intel.com>
Sat, 22 Oct 2016 06:19:44 +0000 (23:19 -0700)
committerJason Ekstrand <jason.ekstrand@intel.com>
Wed, 16 Nov 2016 18:32:20 +0000 (10:32 -0800)
From the Vulkan 1.0.29 spec for vkCmdClearAttachments:

   "If the subpass’s depth/stencil attachment is VK_ATTACHMENT_UNUSED,
   then the clear has no effect."

and

   "If colorAttachment is VK_ATTACHMENT_UNUSED then the clear has no
   effect."

I have no idea why it's spec'd this way; it seems very anti-Vulkan to me,
but that's what it says and it's really not much work to support.

Signed-off-by: Jason Ekstrand <jason@jlekstrand.net>
Reviewed-by: Nanley Chery <nanley.g.chery@intel.com>
src/intel/vulkan/anv_blorp.c

index ae746ed9b2d250a85e9fd1995b8e0a9d7df1c650..2429a964f3e209a1be49ddc86b81f02311ff901a 100644 (file)
@@ -932,6 +932,10 @@ clear_color_attachment(struct anv_cmd_buffer *cmd_buffer,
    const struct anv_subpass *subpass = cmd_buffer->state.subpass;
    const uint32_t color_att = attachment->colorAttachment;
    const uint32_t att_idx = subpass->color_attachments[color_att];
+
+   if (att_idx == VK_ATTACHMENT_UNUSED)
+      return;
+
    struct anv_render_pass_attachment *pass_att =
       &cmd_buffer->state.pass->attachments[att_idx];
    struct anv_attachment_state *att_state =
@@ -966,6 +970,10 @@ clear_depth_stencil_attachment(struct anv_cmd_buffer *cmd_buffer,
    static const union isl_color_value color_value = { .u32 = { 0, } };
    const struct anv_subpass *subpass = cmd_buffer->state.subpass;
    const uint32_t att_idx = subpass->depth_stencil_attachment;
+
+   if (att_idx == VK_ATTACHMENT_UNUSED)
+      return;
+
    struct anv_render_pass_attachment *pass_att =
       &cmd_buffer->state.pass->attachments[att_idx];