Vulkan: Implement masked color clear with depth.

This fixes an edge case when the app clears both color and depth at the
same time when a color mask is set. It also handles stencil clear, but
does not handle stencil masks.

Includes test suppressions for a few platforms that may have driver
bugs.

Bug: angleproject:2455
Bug: angleproject:2547
Bug: angleproject:2548
Change-Id: I5ac0a461a075328e5fc4e5e262c4d21f68f93434
Reviewed-on: https://chromium-review.googlesource.com/1052072
Reviewed-by: Geoff Lang <geofflang@chromium.org>
Reviewed-by: Luc Ferron <lucferron@chromium.org>
Commit-Queue: Jamie Madill <jmadill@chromium.org>
diff --git a/src/libANGLE/renderer/vulkan/FramebufferVk.cpp b/src/libANGLE/renderer/vulkan/FramebufferVk.cpp
index d69b64d..3144ef5 100644
--- a/src/libANGLE/renderer/vulkan/FramebufferVk.cpp
+++ b/src/libANGLE/renderer/vulkan/FramebufferVk.cpp
@@ -139,7 +139,21 @@
     VkColorComponentFlags colorMaskFlags = contextVk->getClearColorMask();
     if (clearColor && (mActiveColorComponents & colorMaskFlags) != mActiveColorComponents)
     {
-        return clearWithDraw(contextVk, colorMaskFlags);
+        ANGLE_TRY(clearWithDraw(contextVk, colorMaskFlags));
+
+        // Stencil clears must be handled separately. The only way to write out a stencil value from
+        // a fragment shader in Vulkan is with VK_EXT_shader_stencil_export. Support for this
+        // extension is sparse. Hence, we call into the RenderPass clear path. We similarly clear
+        // depth to keep the code simple, but depth clears could be combined with the masked color
+        // clears as an optimization.
+
+        if (clearDepth || clearStencil)
+        {
+            // Masked stencil clears are currently not implemented.
+            // TODO(jmadill): Masked stencil clear. http://anglebug.com/2540
+            ANGLE_TRY(clearWithClearAttachments(contextVk, false, clearDepth, clearStencil));
+        }
+        return gl::NoError();
     }
 
     // If we clear the depth OR the stencil but not both, and we have a packed depth stencil
@@ -152,6 +166,9 @@
         // With scissor test enabled, we clear very differently and we don't need to access
         // the image inside each attachment we can just use clearCmdAttachments with our
         // scissor region instead.
+
+        // Masked stencil clears are currently not implemented.
+        // TODO(jmadill): Masked stencil clear. http://anglebug.com/2540
         ANGLE_TRY(clearWithClearAttachments(contextVk, clearColor, clearDepth, clearStencil));
         return gl::NoError();
     }