Mesa (master): mesa: Implement _mesa_all_varyings_in_vbos.

Mathias Fröhlich frohlich at kemper.freedesktop.org
Sun Jul 31 19:54:46 UTC 2016


Module: Mesa
Branch: master
Commit: f8be969b1bfafc0e7ec6c066b56e53ec382464d0
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=f8be969b1bfafc0e7ec6c066b56e53ec382464d0

Author: Mathias Fröhlich <mathias.froehlich at web.de>
Date:   Fri Jun 17 08:09:04 2016 +0200

mesa: Implement _mesa_all_varyings_in_vbos.

Implement the equivalent of vbo_all_varyings_in_vbos for
vertex array objects.

v2: Update comment.

Signed-off-by: Mathias Fröhlich <Mathias.Froehlich at web.de>
Reviewed-by: Eric Anholt <eric at anholt.net>

---

 src/mesa/main/arrayobj.c | 35 +++++++++++++++++++++++++++++++++++
 src/mesa/main/arrayobj.h |  4 ++++
 2 files changed, 39 insertions(+)

diff --git a/src/mesa/main/arrayobj.c b/src/mesa/main/arrayobj.c
index 9c3451e..becf32f 100644
--- a/src/mesa/main/arrayobj.c
+++ b/src/mesa/main/arrayobj.c
@@ -359,6 +359,41 @@ _mesa_update_vao_client_arrays(struct gl_context *ctx,
 }
 
 
+bool
+_mesa_all_varyings_in_vbos(const struct gl_vertex_array_object *vao)
+{
+   /* Walk those enabled arrays that have the default vbo attached */
+   GLbitfield64 mask = vao->_Enabled & ~vao->VertexAttribBufferMask;
+
+   while (mask) {
+      /* Do not use u_bit_scan64 as we can walk multiple
+       * attrib arrays at once
+       */
+      const int i = ffsll(mask) - 1;
+      const struct gl_vertex_attrib_array *attrib_array =
+         &vao->VertexAttrib[i];
+      const struct gl_vertex_buffer_binding *buffer_binding =
+         &vao->VertexBinding[attrib_array->VertexBinding];
+
+      /* Only enabled arrays shall appear in the _Enabled bitmask */
+      assert(attrib_array->Enabled);
+      /* We have already masked out vao->VertexAttribBufferMask  */
+      assert(!_mesa_is_bufferobj(buffer_binding->BufferObj));
+
+      /* Bail out once we find the first non vbo with a non zero stride */
+      if (buffer_binding->Stride != 0)
+         return false;
+
+      /* Note that we cannot use the xor variant since the _BoundArray mask
+       * may contain array attributes that are bound but not enabled.
+       */
+      mask &= ~buffer_binding->_BoundArrays;
+   }
+
+   return true;
+}
+
+
 /**********************************************************************/
 /* API Functions                                                      */
 /**********************************************************************/
diff --git a/src/mesa/main/arrayobj.h b/src/mesa/main/arrayobj.h
index 6a4247f..d30c85c 100644
--- a/src/mesa/main/arrayobj.h
+++ b/src/mesa/main/arrayobj.h
@@ -81,6 +81,10 @@ extern void
 _mesa_update_vao_client_arrays(struct gl_context *ctx,
                                struct gl_vertex_array_object *vao);
 
+/* Returns true if all varying arrays reside in vbos */
+extern bool
+_mesa_all_varyings_in_vbos(const struct gl_vertex_array_object *vao);
+
 /*
  * API functions
  */




More information about the mesa-commit mailing list