Commit e4c38be0 by Luc Ferron Committed by Commit Bot

Vulkan: clearRegionWithScissor did not determine the region correctly

When the scissor region given was completely outside the renderArea, we were calling vkCmdClearAttachments with the unmodified rectangle. Instead, we just need to actually skip the clear call since there is nothing to clear if we have a scissor region outside the render area. Bug: angleproject:2484 Change-Id: If2c7c5b91e07081f1d2e4f4d8d13f8c8a842ea0b Reviewed-on: https://chromium-review.googlesource.com/1014958 Commit-Queue: Luc Ferron <lucferron@chromium.org> Reviewed-by: 's avatarCorentin Wallez <cwallez@chromium.org>
parent 01074436
...@@ -454,6 +454,26 @@ gl::Error FramebufferVk::clearAttachmentsWithScissorRegion(const gl::Context *co ...@@ -454,6 +454,26 @@ gl::Error FramebufferVk::clearAttachmentsWithScissorRegion(const gl::Context *co
ANGLE_TRY(node->beginInsideRenderPassRecording(renderer, &commandBuffer)); ANGLE_TRY(node->beginInsideRenderPassRecording(renderer, &commandBuffer));
} }
// TODO(jmadill): Cube map attachments. http://anglebug.com/2470
// We assume for now that we always need to clear only 1 layer starting at the
// baseArrayLayer 0, this might need to change depending how we'll implement
// cube maps, 3d textures and array textures.
VkClearRect clearRect;
clearRect.baseArrayLayer = 0;
clearRect.layerCount = 1;
// When clearing, the scissor region must be clipped to the renderArea per the validation rules
// in Vulkan.
gl::Rectangle intersection;
if (!ClipRectangle(contextVk->getGLState().getScissor(), node->getRenderPassRenderArea(),
&intersection))
{
// There is nothing to clear since the scissor is outside of the render area.
return gl::NoError();
}
clearRect.rect = gl_vk::GetRect(intersection);
gl::AttachmentArray<VkClearAttachment> clearAttachments; gl::AttachmentArray<VkClearAttachment> clearAttachments;
int clearAttachmentIndex = 0; int clearAttachmentIndex = 0;
...@@ -501,26 +521,6 @@ gl::Error FramebufferVk::clearAttachmentsWithScissorRegion(const gl::Context *co ...@@ -501,26 +521,6 @@ gl::Error FramebufferVk::clearAttachmentsWithScissorRegion(const gl::Context *co
} }
} }
// We assume for now that we always need to clear only 1 layer starting at the
// baseArrayLayer 0, this might need to change depending how we'll implement
// cube maps, 3d textures and array textures.
VkClearRect clearRect;
clearRect.baseArrayLayer = 0;
clearRect.layerCount = 1;
// When clearing, the scissor region must be clipped to the renderArea per the validation rules
// in Vulkan.
gl::Rectangle intersection;
if (ClipRectangle(contextVk->getGLState().getScissor(), node->getRenderPassRenderArea(),
&intersection))
{
clearRect.rect = gl_vk::GetRect(intersection);
}
else
{
clearRect.rect = gl_vk::GetRect(contextVk->getGLState().getScissor());
}
commandBuffer->clearAttachments(static_cast<uint32_t>(clearAttachmentIndex), commandBuffer->clearAttachments(static_cast<uint32_t>(clearAttachmentIndex),
clearAttachments.data(), 1, &clearRect); clearAttachments.data(), 1, &clearRect);
return gl::NoError(); return gl::NoError();
......
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