ES31: Fix the issue for relink rendering/compute program.

When link or relink fails, if we try to install the unsuccessfully linked
program (via UseProgram) and start rendering or dispatch compute, We can
not always report INVALID_OPERATION for rendering/compute pipeline.
The result depends on the previous state: Whether a valid program has been
installed in pipeline before. If a valid program has been installed, it
should be OK to use the old executable residing in the GL state to start
rendering or dispatch compute. No error should be reported.

This change also add unit tests for unsuccessfully linked/relinked program
for rendering pipeline to avoid potential error.

If a program successfully relinks when it is in use, the program might
change from a rendering program to a compute program in theory,
or vice versa.

BUG=angleproject:2266

Change-Id: I4726112af2bc74f5beef25e35d2fcaa9f31e0768
Reviewed-on: https://chromium-review.googlesource.com/784273
Reviewed-by: Jamie Madill <jmadill@chromium.org>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
diff --git a/src/libANGLE/validationES.cpp b/src/libANGLE/validationES.cpp
index 3a29a33..e3d107f 100644
--- a/src/libANGLE/validationES.cpp
+++ b/src/libANGLE/validationES.cpp
@@ -2505,8 +2505,7 @@
     // vertex shader stage or fragment shader stage is a undefined behaviour.
     // But ANGLE should clearly generate an INVALID_OPERATION error instead of
     // produce undefined result.
-    if (program->isLinked() &&
-        (!program->hasLinkedVertexShader() || !program->hasLinkedFragmentShader()))
+    if (!program->hasLinkedVertexShader() || !program->hasLinkedFragmentShader())
     {
         context->handleError(InvalidOperation() << "It is a undefined behaviour to render without "
                                                    "vertex shader stage or fragment shader stage.");