Vulkan: Discard scissored clears where scissor is null

If a clear becomes a no-op because the scissor has a width and height
of 0, return early and skip the draw.
This also works around a driver issue on some devices where it was
ignoring a null scissor and drawing the clear anyway. Found with deqp
test:
adb shell am start -n com.drawelements.deqp/android.app.NativeActivity \
    -e cmdLine '"deqp --deqp-case=dEQP-GLES2.functional.color_clear.* \
    --deqp-log-filename=/sdcard/dEQP-Log.qpa"'
run_angle_end2end_tests --gtest_filter=ClearTest.EmptyScissor/ES2_VULKAN

Bug: angleproject:3114
Change-Id: I6cf2716bd93bb332f74b44c7250e363c68cc614f
Reviewed-on: https://chromium-review.googlesource.com/c/1436841
Commit-Queue: Jamie Madill <jmadill@chromium.org>
Reviewed-by: Geoff Lang <geofflang@chromium.org>
diff --git a/src/libANGLE/renderer/vulkan/UtilsVk.cpp b/src/libANGLE/renderer/vulkan/UtilsVk.cpp
index 6d4bbee..e02f939 100644
--- a/src/libANGLE/renderer/vulkan/UtilsVk.cpp
+++ b/src/libANGLE/renderer/vulkan/UtilsVk.cpp
@@ -641,6 +641,11 @@
     VkRect2D scissor;
     const gl::State &glState = contextVk->getState();
     gl_vk::GetScissor(glState, invertViewport, renderArea, &scissor);
+    // TODO(courtneygo): workaround for scissor issue on some devices. http://anglebug.com/3114
+    if ((scissor.extent.width == 0) && (scissor.extent.height == 0))
+    {
+        return angle::Result::Continue;
+    }
     pipelineDesc.setScissor(scissor);
 
     vk::ShaderLibrary &shaderLibrary                    = renderer->getShaderLibrary();
diff --git a/src/tests/gl_tests/ClearTest.cpp b/src/tests/gl_tests/ClearTest.cpp
index ea777e3..2bc8920 100644
--- a/src/tests/gl_tests/ClearTest.cpp
+++ b/src/tests/gl_tests/ClearTest.cpp
@@ -187,6 +187,26 @@
     EXPECT_PIXEL_NEAR(0, 0, 64, 128, 128, 128, 1.0);
 }
 
+// Test clearing the default framebuffer with scissor and mask
+// This forces down path that uses draw to do clear
+TEST_P(ClearTest, EmptyScissor)
+{
+    // These configs have bug that fails this test.
+    // These configs are unmaintained so skipping.
+    ANGLE_SKIP_TEST_IF(IsIntel() && IsD3D9());
+    ANGLE_SKIP_TEST_IF(IsOSX());
+    glClearColor(0.25f, 0.5f, 0.5f, 1.0f);
+    glClear(GL_COLOR_BUFFER_BIT);
+    glEnable(GL_SCISSOR_TEST);
+    glScissor(-10, 0, 5, 5);
+    glClearColor(0.5f, 0.25f, 0.75f, 0.5f);
+    glColorMask(GL_TRUE, GL_FALSE, GL_TRUE, GL_TRUE);
+    glClear(GL_COLOR_BUFFER_BIT);
+    glDisable(GL_SCISSOR_TEST);
+    glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);
+    EXPECT_PIXEL_NEAR(0, 0, 64, 128, 128, 255, 1.0);
+}
+
 // Test clearing the RGB default framebuffer and verify that the alpha channel is not cleared
 TEST_P(ClearTestRGB, DefaultFramebufferRGB)
 {