intel: Implement attachment clears
- Add a test demonstrating a mid-renderpass attachment clear
- Implement in the intel ICD in terms of image clears
(not *quite* right -- doesn't support clearing a rect within
the surface, but far better than nothing).
Signed-off-by: Chris Forbes <chrisf@ijw.co.nz>
diff --git a/tests/render_tests.cpp b/tests/render_tests.cpp
index b456ace..70d53eb 100644
--- a/tests/render_tests.cpp
+++ b/tests/render_tests.cpp
@@ -4168,6 +4168,48 @@
RecordImages(m_renderTargets);
}
+TEST_F(VkRenderTest, RenderPassAttachmentClear)
+{
+ ASSERT_NO_FATAL_FAILURE(InitState());
+ ASSERT_NO_FATAL_FAILURE(InitViewport());
+
+ /* clear via load op to full red */
+ m_clear_via_load_op = true;
+ m_clear_color.useRawValue = false;
+ m_clear_color.color.floatColor[0] = 1;
+ m_clear_color.color.floatColor[1] = 0;
+ m_clear_color.color.floatColor[2] = 0;
+ m_clear_color.color.floatColor[3] = 0;
+ ASSERT_NO_FATAL_FAILURE(InitRenderTarget());
+
+ VkCommandBufferObj cmdBuffer(m_device);
+ cmdBuffer.AddRenderTarget(m_renderTargets[0]);
+ ASSERT_VK_SUCCESS(BeginCommandBuffer(cmdBuffer));
+
+ /* Load op has cleared to red */
+
+ /* Draw, draw, draw... */
+
+ /* Now, partway through this renderpass we want to clear the color
+ * attachment again, this time to green.
+ */
+ VkClearColor clear_color;
+ clear_color.useRawValue = false;
+ clear_color.color.floatColor[0] = 0;
+ clear_color.color.floatColor[1] = 1;
+ clear_color.color.floatColor[2] = 0;
+ clear_color.color.floatColor[3] = 0;
+ VkRect3D clear_rect = { { 0, 0, 0 }, { (int)m_width, (int)m_height, 1 } };
+ vkCmdClearColorAttachment(cmdBuffer.obj(), 0,
+ VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL,
+ &clear_color, 1, &clear_rect);
+
+ EndCommandBuffer(cmdBuffer);
+ cmdBuffer.QueueCommandBuffer();
+
+ RecordImages(m_renderTargets);
+}
+
int main(int argc, char **argv) {
int result;