Notify the VertexArrayImpl when a buffer is detached.

Update VertexArrayGL to clear it's cached buffer binding when a buffer is
detached to prevent name aliasing.

Fixes:
 * DEQP standalone crashes.
 * WebGL Conformance DEQP tests.

Change-Id: If21a617629e15873ddeae0368b5399616f2ca68b
Reviewed-on: https://chromium-review.googlesource.com/278050
Reviewed-by: Jamie Madill <jmadill@chromium.org>
Tested-by: Geoff Lang <geofflang@chromium.org>
diff --git a/src/libANGLE/VertexArray.cpp b/src/libANGLE/VertexArray.cpp
index a920a77..4ffb6dd 100644
--- a/src/libANGLE/VertexArray.cpp
+++ b/src/libANGLE/VertexArray.cpp
@@ -44,13 +44,15 @@
     {
         if (mVertexAttributes[attribute].buffer.id() == bufferName)
         {
-            mVertexAttributes[attribute].buffer.set(NULL);
+            mVertexAttributes[attribute].buffer.set(nullptr);
+            mVertexArray->setAttribute(attribute, mVertexAttributes[attribute]);
         }
     }
 
     if (mElementArrayBuffer.id() == bufferName)
     {
-        mElementArrayBuffer.set(NULL);
+        mElementArrayBuffer.set(nullptr);
+        mVertexArray->setElementArrayBuffer(nullptr);
     }
 }
 
diff --git a/src/libANGLE/renderer/gl/VertexArrayGL.cpp b/src/libANGLE/renderer/gl/VertexArrayGL.cpp
index 93a352e..ba5521c 100644
--- a/src/libANGLE/renderer/gl/VertexArrayGL.cpp
+++ b/src/libANGLE/renderer/gl/VertexArrayGL.cpp
@@ -74,6 +74,13 @@
 void VertexArrayGL::setElementArrayBuffer(const gl::Buffer *buffer)
 {
     mElementArrayBuffer.set(buffer);
+
+    // If the buffer is being unbound/deleted, reset the currently applied buffer ID
+    // so that even if a new buffer is generated with the same ID, it will be re-bound.
+    if (buffer == nullptr && mAppliedElementArrayBuffer != mStreamingElementArrayBuffer)
+    {
+        mAppliedElementArrayBuffer = 0;
+    }
 }
 
 void VertexArrayGL::setAttribute(size_t idx, const gl::VertexAttribute &attr)