Fix wrong caching of glBindBuffer

Fixes: 127884817

Previously, we incorrectly skipped setting the client state's
non-indexed bindings such as GL_ELEMENT_ARRAY_BUFFER_BINDING.

This resulted in the guest binding buffer 0 and not having that
reflected in GLClientState, which ended up segaulting in
index range calculation, as a nonzero index buffer object would be used
as the base, and indices argument to glDrawElements
incorrectly treated as an offset.

This CL makes it so that the client state in the guest
is properly updated.

Change-Id: I19eefe1106a59d86e618e9746b6b2bcd5539e7cd
diff --git a/system/GLESv2_enc/GL2Encoder.cpp b/system/GLESv2_enc/GL2Encoder.cpp
index 827efef..d8ea74e 100755
--- a/system/GLESv2_enc/GL2Encoder.cpp
+++ b/system/GLESv2_enc/GL2Encoder.cpp
@@ -545,7 +545,7 @@
     assert(ctx->m_state != NULL);
     SET_ERROR_IF(!GLESv2Validation::bufferTarget(ctx, target), GL_INVALID_ENUM);
 
-    bool nop = id == ctx->m_state->getLastEncodedBufferBind(target);
+    bool nop = ctx->m_state->isNonIndexedBindNoOp(target, id);
 
     if (nop) return;
 
@@ -4344,8 +4344,14 @@
     // caching previous results.
     if (ctx->m_state->currentIndexVbo() != 0) {
         buf = ctx->m_shared->getBufferData(ctx->m_state->currentIndexVbo());
+        ALOGV("%s: current index vbo: %p len %zu count %zu\n", __func__, buf, (size_t)buf->m_fixedBuffer.len(), (size_t)count);
         offset = (GLintptr)indices;
+        void* oldIndices = (void*)indices;
         indices = (void*)((GLintptr)buf->m_fixedBuffer.ptr() + (GLintptr)indices);
+        ALOGV("%s: indices arg: %p buffer start: %p indices: %p\n", __func__,
+                (void*)(uintptr_t)(oldIndices),
+                buf->m_fixedBuffer.ptr(),
+                indices);
         ctx->getBufferIndexRange(buf,
                                  indices,
                                  type,