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: Corentin Wallez <cwallez@chromium.org>
diff --git a/src/libANGLE/renderer/vulkan/FramebufferVk.cpp b/src/libANGLE/renderer/vulkan/FramebufferVk.cpp
index f31923d..d447564 100644
--- a/src/libANGLE/renderer/vulkan/FramebufferVk.cpp
+++ b/src/libANGLE/renderer/vulkan/FramebufferVk.cpp
@@ -454,6 +454,26 @@
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;
int clearAttachmentIndex = 0;
@@ -501,26 +521,6 @@
}
}
- // 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),
clearAttachments.data(), 1, &clearRect);
return gl::NoError();