Vulkan: Clean up robust and emulated image clears.

This change consolidates image clears in multiple places into a single
site in ImageHelper initialization. It adds support for appending clear
image commands as well as prepend (the default). We prepend clears
because image initialization happens after data upload.

The Vulkan robust clear path now works like the other back-ends. The
change flushed out a bug where partially uninitialized CopyTexImage was
not correctly initializing a texture before triggering a full resource
clear. Texture::copyImage now uses a workaround where we first init the
image before clearing it. After the init we upload the new data.

We'll use the appending clears path when implementing deferred clears.

Bug: angleproject:4517
Change-Id: If9212f3b8cdd0fc8b7e729d364530801a644e164
Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2130627
Commit-Queue: Jamie Madill <jmadill@chromium.org>
Reviewed-by: Cody Northrop <cnorthrop@google.com>
diff --git a/src/tests/gl_tests/FramebufferTest.cpp b/src/tests/gl_tests/FramebufferTest.cpp
index 97c7874..0bd1cbf 100644
--- a/src/tests/gl_tests/FramebufferTest.cpp
+++ b/src/tests/gl_tests/FramebufferTest.cpp
@@ -1486,6 +1486,26 @@
     eglDestroyContext(display, context2);
 }
 
+// Ensure cube-incomplete attachments cause incomplete Framebuffers.
+TEST_P(FramebufferTest, IncompleteCubeMap)
+{
+    constexpr GLuint kSize = 2;
+
+    GLTexture srcTex;
+    glBindTexture(GL_TEXTURE_CUBE_MAP, srcTex);
+    glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X, 0, GL_RGBA, kSize, kSize, 0, GL_RGBA,
+                 GL_UNSIGNED_BYTE, nullptr);
+
+    GLFramebuffer fbo;
+    glBindFramebuffer(GL_FRAMEBUFFER, fbo);
+    glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_CUBE_MAP_POSITIVE_X,
+                           srcTex, 0);
+
+    ASSERT_GL_NO_ERROR();
+    ASSERT_GLENUM_EQ(glCheckFramebufferStatus(GL_FRAMEBUFFER),
+                     GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT);
+}
+
 ANGLE_INSTANTIATE_TEST_ES2(AddDummyTextureNoRenderTargetTest);
 ANGLE_INSTANTIATE_TEST_ES2(FramebufferTest);
 ANGLE_INSTANTIATE_TEST_ES2_AND_ES3(FramebufferFormatsTest);