Skip to content

anv,radv: Fix handling of VK_ATTACHMENT_UNUSED in CmdClearAttachments

From the Vulkan 1.0.98 spec for vkCmdClearAttachments:

"If any attachment to be cleared in the current subpass is VK_ATTACHMENT_UNUSED, then the clear has no effect on that attachment."

"If the aspectMask member of any element of pAttachments contains VK_IMAGE_ASPECT_COLOR_BIT, then the colorAttachment member of that element must either refer to a color attachment which is VK_ATTACHMENT_UNUSED, or must be a valid color attachment."

"If the aspectMask member of any element of pAttachments contains VK_IMAGE_ASPECT_DEPTH_BIT, then the current subpass' depth/stencil attachment must either be VK_ATTACHMENT_UNUSED, or must have a depth component"

"If the aspectMask member of any element of pAttachments contains VK_IMAGE_ASPECT_STENCIL_BIT, then the current subpass' depth/stencil attachment must either be VK_ATTACHMENT_UNUSED, or must have a stencil component"

So:

  • For color attachment this means that pAttachments[i]->colorAttachment could be VK_ATTACHMENT_UNUSED and in such case should be skipped.
  • For color/depth/stencil attachment this means that subpass' attachment could be VK_ATTACHMENT_UNUSED and in such case should be skipped.

Where this happens in the wild? It happens in RenderDoc vk_overlay.cpp#L1597

Merge request reports