From 9a05ebac5202b6e4b59f43707b96b4acd4c00b7b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Konstantin=20K=C3=A4fer?= Date: Sun, 4 Jun 2017 02:47:20 +0200 Subject: [PATCH] [core] store vertex attribute binding to prevent duplicate binds We have an "oldBinding" value that we use for checking whether the vertex attribute was already bound to the current VAO, but we never set the state. Additionally, we're also checking whether the previous state was already any binding (optional is set), and don't re-enable the vertex attribute array. Additionally, we now only disable the vertex attribute array when the previous state was in fact an array attribute. We still don't deduplicate constant glVertexAttrib* calls, but that's a little trickier. --- src/mbgl/gl/attribute.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/mbgl/gl/attribute.cpp b/src/mbgl/gl/attribute.cpp index eacaa3745..8c52121f6 100644 --- a/src/mbgl/gl/attribute.cpp +++ b/src/mbgl/gl/attribute.cpp @@ -29,6 +29,7 @@ void VariableAttributeBinding::bind(Context& context, } context.vertexBuffer = vertexBuffer; MBGL_CHECK_ERROR(glEnableVertexAttribArray(location)); + oldBinding = *this; MBGL_CHECK_ERROR(glVertexAttribPointer( location, static_cast(attributeSize),