Make sure ProgramGL stays usable after failed glProgramBinary

glProgramBinary may fail if the driver is incompatible with the binary
that is being loaded. After this ANGLE falls back to recompiling the
GLSL program from source, but this requires that the ProgramGL object
used is still valid after a failed glProgramBinary call.

Don't delete the GL program after a failed glProgramBinary call so
that the fallback works as intended.

BUG=angleproject:2751

Change-Id: I55c19d71414163b1cd9f898f304e4aa7052f6b16
Reviewed-on: https://chromium-review.googlesource.com/1160540
Reviewed-by: Geoff Lang <geofflang@chromium.org>
Commit-Queue: Olli Etuaho <oetuaho@nvidia.com>
diff --git a/src/libANGLE/renderer/gl/ProgramGL.cpp b/src/libANGLE/renderer/gl/ProgramGL.cpp
index 89cd454..4e35b89 100644
--- a/src/libANGLE/renderer/gl/ProgramGL.cpp
+++ b/src/libANGLE/renderer/gl/ProgramGL.cpp
@@ -710,7 +710,7 @@
     mFunctions->getProgramiv(mProgramID, GL_LINK_STATUS, &linkStatus);
     if (linkStatus == GL_FALSE)
     {
-        // Linking failed, put the error into the info log
+        // Linking or program binary loading failed, put the error into the info log.
         GLint infoLogLength = 0;
         mFunctions->getProgramiv(mProgramID, GL_INFO_LOG_LENGTH, &infoLogLength);
 
@@ -721,19 +721,18 @@
             std::vector<char> buf(infoLogLength);
             mFunctions->getProgramInfoLog(mProgramID, infoLogLength, nullptr, &buf[0]);
 
-            mFunctions->deleteProgram(mProgramID);
-            mProgramID = 0;
-
             infoLog << buf.data();
 
-            WARN() << "Program link failed unexpectedly: " << buf.data();
+            WARN() << "Program link or binary loading failed: " << buf.data();
         }
         else
         {
-            WARN() << "Program link failed unexpectedly with no info log.";
+            WARN() << "Program link or binary loading failed with no info log.";
         }
 
-        // TODO, return GL_OUT_OF_MEMORY or just fail the link? This is an unexpected case
+        // This may happen under normal circumstances if we're loading program binaries and the
+        // driver or hardware has changed.
+        ASSERT(mProgramID != 0);
         return false;
     }