Commit 605f8631 by Chris Forbes

Refactor framebuffer clear to be less redundant

Bug: b/119621736 Change-Id: I8a25e6a5dba7e05649c35dc65160f69300bf5791 Reviewed-on: https://swiftshader-review.googlesource.com/c/SwiftShader/+/35508Tested-by: 's avatarChris Forbes <chrisforbes@google.com> Presubmit-Ready: Chris Forbes <chrisforbes@google.com> Kokoro-Presubmit: kokoro <noreply+kokoro@google.com> Reviewed-by: 's avatarNicolas Capens <nicolascapens@google.com>
parent 2e5042a3
...@@ -41,47 +41,29 @@ void Framebuffer::clear(const RenderPass* renderPass, uint32_t clearValueCount, ...@@ -41,47 +41,29 @@ void Framebuffer::clear(const RenderPass* renderPass, uint32_t clearValueCount,
ASSERT(attachmentCount == renderPass->getAttachmentCount()); ASSERT(attachmentCount == renderPass->getAttachmentCount());
const uint32_t count = std::min(clearValueCount, attachmentCount); const uint32_t count = std::min(clearValueCount, attachmentCount);
for(uint32_t i = 0; i < count; i++) for (uint32_t i = 0; i < count; i++)
{ {
if (!renderPass->isAttachmentUsed(i)) const VkAttachmentDescription attachment = renderPass->getAttachment(i);
VkImageAspectFlags aspectMask = Format(attachment.format).getAspects();
if (attachment.loadOp != VK_ATTACHMENT_LOAD_OP_CLEAR)
aspectMask &= VK_IMAGE_ASPECT_STENCIL_BIT;
if (attachment.stencilLoadOp != VK_ATTACHMENT_LOAD_OP_CLEAR)
aspectMask &= ~VK_IMAGE_ASPECT_STENCIL_BIT;
if (!aspectMask || !renderPass->isAttachmentUsed(i))
{ {
continue; continue;
} }
const VkAttachmentDescription attachment = renderPass->getAttachment(i); if (renderPass->isMultiView())
const Format format(attachment.format);
bool isDepth = format.isDepth();
bool isStencil = format.isStencil();
if(isDepth || isStencil)
{ {
bool clearDepth = (isDepth && (attachment.loadOp == VK_ATTACHMENT_LOAD_OP_CLEAR)); attachments[i]->clearWithLayerMask(pClearValues[i], aspectMask, renderArea,
bool clearStencil = (isStencil && (attachment.stencilLoadOp == VK_ATTACHMENT_LOAD_OP_CLEAR)); renderPass->getAttachmentViewMask(i));
if(clearDepth || clearStencil)
{
auto aspectMask = (clearDepth ? VK_IMAGE_ASPECT_DEPTH_BIT : 0) |
(clearStencil ? VK_IMAGE_ASPECT_STENCIL_BIT : 0);
if (renderPass->isMultiView())
{
attachments[i]->clearWithLayerMask(pClearValues[i], aspectMask, renderArea, renderPass->getAttachmentViewMask(i));
}
else
{
attachments[i]->clear(pClearValues[i], aspectMask, renderArea);
}
}
} }
else if(attachment.loadOp == VK_ATTACHMENT_LOAD_OP_CLEAR) else
{ {
if (renderPass->isMultiView()) attachments[i]->clear(pClearValues[i], aspectMask, renderArea);
{
attachments[i]->clearWithLayerMask(pClearValues[i], VK_IMAGE_ASPECT_COLOR_BIT, renderArea, renderPass->getAttachmentViewMask(i));
}
else
{
attachments[i]->clear(pClearValues[i], VK_IMAGE_ASPECT_COLOR_BIT, renderArea);
}
} }
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment