mesa: Only update enabled VAO gl_vertex_array entries.
authorMathias Fröhlich <mathias.froehlich@web.de>
Sun, 4 Feb 2018 16:13:06 +0000 (17:13 +0100)
committerMathias Fröhlich <mathias.froehlich@web.de>
Fri, 9 Feb 2018 03:26:23 +0000 (04:26 +0100)
Instead of updating all modified gl_vertex_array_object::_VertexArray
entries just update those that are modified and enabled.
Also release buffer object from the _VertexArray that belong
to disabled attributes.

v2: Also set Ptr and Size to zero.

Signed-off-by: Mathias Fröhlich <Mathias.Froehlich@web.de>
Reviewed-by: Brian Paul <brianp@vmware.com>
src/mesa/main/varray.c
src/mesa/main/varray.h

index 4dfc3546a8c7afec1446ed19a39ba3595d910008..d55f74e968fa050c6dfc54a367084d38e3045ffe 100644 (file)
@@ -178,7 +178,7 @@ vertex_attrib_binding(struct gl_context *ctx,
 
       array->BufferBindingIndex = bindingIndex;
 
-      vao->NewArrays |= array_bit;
+      vao->NewArrays |= vao->_Enabled & array_bit;
    }
 }
 
@@ -213,7 +213,7 @@ _mesa_bind_vertex_buffer(struct gl_context *ctx,
       else
          vao->VertexAttribBufferMask |= binding->_BoundArrays;
 
-      vao->NewArrays |= binding->_BoundArrays;
+      vao->NewArrays |= vao->_Enabled & binding->_BoundArrays;
    }
 }
 
@@ -234,7 +234,7 @@ vertex_binding_divisor(struct gl_context *ctx,
    if (binding->InstanceDivisor != divisor) {
       FLUSH_VERTICES(ctx, _NEW_ARRAY);
       binding->InstanceDivisor = divisor;
-      vao->NewArrays |= binding->_BoundArrays;
+      vao->NewArrays |= vao->_Enabled & binding->_BoundArrays;
    }
 }
 
@@ -344,7 +344,7 @@ _mesa_update_array_format(struct gl_context *ctx,
    array->RelativeOffset = relativeOffset;
    array->_ElementSize = elementSize;
 
-   vao->NewArrays |= VERT_BIT(attrib);
+   vao->NewArrays |= vao->_Enabled & VERT_BIT(attrib);
    ctx->NewState |= _NEW_ARRAY;
 }
 
index ddabd0bc585c6458fe9232d8b87b825422de67d0..46f83b22008b2f95266f8a89e46e11c2bf87fa7c 100644 (file)
@@ -58,17 +58,24 @@ _mesa_update_vertex_array(struct gl_context *ctx,
                           const struct gl_array_attributes *attribs,
                           const struct gl_vertex_buffer_binding *binding)
 {
-   dst->Size = attribs->Size;
-   dst->Type = attribs->Type;
-   dst->Format = attribs->Format;
-   dst->StrideB = binding->Stride;
-   dst->Ptr = _mesa_vertex_attrib_address(attribs, binding);
-   dst->Normalized = attribs->Normalized;
-   dst->Integer = attribs->Integer;
-   dst->Doubles = attribs->Doubles;
-   dst->InstanceDivisor = binding->InstanceDivisor;
-   dst->_ElementSize = attribs->_ElementSize;
-   _mesa_reference_buffer_object(ctx, &dst->BufferObj, binding->BufferObj);
+   if (attribs->Enabled) {
+      dst->Size = attribs->Size;
+      dst->Type = attribs->Type;
+      dst->Format = attribs->Format;
+      dst->StrideB = binding->Stride;
+      dst->Ptr = _mesa_vertex_attrib_address(attribs, binding);
+      dst->Normalized = attribs->Normalized;
+      dst->Integer = attribs->Integer;
+      dst->Doubles = attribs->Doubles;
+      dst->InstanceDivisor = binding->InstanceDivisor;
+      dst->_ElementSize = attribs->_ElementSize;
+      _mesa_reference_buffer_object(ctx, &dst->BufferObj, binding->BufferObj);
+   } else {
+      /* Disabled arrays shall not be consumed */
+      dst->Size = 0;
+      dst->Ptr = NULL;
+      _mesa_reference_buffer_object(ctx, &dst->BufferObj, NULL);
+   }
 }