+/**
+ * Binds a buffer object to an atomic buffer binding point.
+ *
+ * Unlike set_atomic_binding(), this function also flushes vertices
+ * and updates NewDriverState. It also checks if the binding
+ * has actually changed before updating it.
+ */
+static void
+bind_atomic_buffer(struct gl_context *ctx, unsigned index,
+ struct gl_buffer_object *bufObj, GLintptr offset,
+ GLsizeiptr size, GLboolean autoSize)
+{
+ struct gl_atomic_buffer_binding *binding =
+ &ctx->AtomicBufferBindings[index];
+
+ if (binding->BufferObject == bufObj &&
+ binding->Offset == offset &&
+ binding->Size == size &&
+ binding->AutomaticSize == autoSize) {
+ return;
+ }
+
+ FLUSH_VERTICES(ctx, 0);
+ ctx->NewDriverState |= ctx->DriverFlags.NewAtomicBuffer;
+
+ set_atomic_buffer_binding(ctx, binding, bufObj, offset, size, autoSize);
+}
+