Allow depth/stencil attachment to be VK_ATTACHMENT_UNUSED in clear
Test: dEQP-VK.renderpass.suballocation.unused_clear_attachments.*depth*
Bug: b/144280552
Change-Id: I37072270105caf206ed3ab6cb2895d32ef22f653
Reviewed-on: https://swiftshader-review.googlesource.com/c/SwiftShader/+/38108
Tested-by: Chris Forbes <chrisforbes@google.com>
Presubmit-Ready: Chris Forbes <chrisforbes@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
Kokoro-Presubmit: kokoro <noreply+kokoro@google.com>
diff --git a/src/Vulkan/VkFramebuffer.cpp b/src/Vulkan/VkFramebuffer.cpp
index db29ba7..7c3617f 100644
--- a/src/Vulkan/VkFramebuffer.cpp
+++ b/src/Vulkan/VkFramebuffer.cpp
@@ -96,17 +96,22 @@
}
else if (attachment.aspectMask & (VK_IMAGE_ASPECT_DEPTH_BIT | VK_IMAGE_ASPECT_STENCIL_BIT))
{
- ASSERT(subpass.pDepthStencilAttachment->attachment < attachmentCount);
- ImageView *imageView = attachments[subpass.pDepthStencilAttachment->attachment];
+ uint32_t attachmentIndex = subpass.pDepthStencilAttachment->attachment;
- if (renderPass->isMultiView())
+ if (attachmentIndex != VK_ATTACHMENT_UNUSED)
{
- imageView->clearWithLayerMask(attachment.clearValue, attachment.aspectMask, rect.rect,
- renderPass->getViewMask(subpassIndex));
- }
- else
- {
- imageView->clear(attachment.clearValue, attachment.aspectMask, rect);
+ ASSERT(attachmentIndex < attachmentCount);
+ ImageView *imageView = attachments[attachmentIndex];
+
+ if (renderPass->isMultiView())
+ {
+ imageView->clearWithLayerMask(attachment.clearValue, attachment.aspectMask, rect.rect,
+ renderPass->getViewMask(subpassIndex));
+ }
+ else
+ {
+ imageView->clear(attachment.clearValue, attachment.aspectMask, rect);
+ }
}
}
}