Mesa (master): mesa: Walk the VAO in _mesa_print_arrays.

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


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

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

mesa: Walk the VAO in _mesa_print_arrays.

Only a debugging function, but move away from
gl_client_array and use the first order information
from the VAO. Also make use of gl_vert_attrib_name.

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

---

 src/mesa/main/varray.c | 52 +++++++++++++++++++-------------------------------
 1 file changed, 20 insertions(+), 32 deletions(-)

diff --git a/src/mesa/main/varray.c b/src/mesa/main/varray.c
index c2bf295..36aa33c 100644
--- a/src/mesa/main/varray.c
+++ b/src/mesa/main/varray.c
@@ -2360,44 +2360,32 @@ _mesa_copy_vertex_buffer_binding(struct gl_context *ctx,
 }
 
 /**
- * Print vertex array's fields.
- */
-static void
-print_array(const char *name, GLint index, const struct gl_client_array *array)
-{
-   if (index >= 0)
-      fprintf(stderr, "  %s[%d]: ", name, index);
-   else
-      fprintf(stderr, "  %s: ", name);
-   fprintf(stderr, "Ptr=%p, Type=%s, Size=%d, ElemSize=%u, Stride=%d, Buffer=%u(Size %lu)\n",
-           array->Ptr, _mesa_enum_to_string(array->Type), array->Size,
-           array->_ElementSize, array->StrideB, array->BufferObj->Name,
-           (unsigned long) array->BufferObj->Size);
-}
-
-
-/**
  * Print current vertex object/array info.  For debug.
  */
 void
 _mesa_print_arrays(struct gl_context *ctx)
 {
-   struct gl_vertex_array_object *vao = ctx->Array.VAO;
-   GLuint i;
+   const struct gl_vertex_array_object *vao = ctx->Array.VAO;
 
-   printf("Array Object %u\n", vao->Name);
-   if (vao->_VertexAttrib[VERT_ATTRIB_POS].Enabled)
-      print_array("Vertex", -1, &vao->_VertexAttrib[VERT_ATTRIB_POS]);
-   if (vao->_VertexAttrib[VERT_ATTRIB_NORMAL].Enabled)
-      print_array("Normal", -1, &vao->_VertexAttrib[VERT_ATTRIB_NORMAL]);
-   if (vao->_VertexAttrib[VERT_ATTRIB_COLOR0].Enabled)
-      print_array("Color", -1, &vao->_VertexAttrib[VERT_ATTRIB_COLOR0]);
-   for (i = 0; i < ctx->Const.MaxTextureCoordUnits; i++)
-      if (vao->_VertexAttrib[VERT_ATTRIB_TEX(i)].Enabled)
-         print_array("TexCoord", i, &vao->_VertexAttrib[VERT_ATTRIB_TEX(i)]);
-   for (i = 0; i < VERT_ATTRIB_GENERIC_MAX; i++)
-      if (vao->_VertexAttrib[VERT_ATTRIB_GENERIC(i)].Enabled)
-         print_array("Attrib", i, &vao->_VertexAttrib[VERT_ATTRIB_GENERIC(i)]);
+   fprintf(stderr, "Array Object %u\n", vao->Name);
+
+   unsigned i;
+   for (i = 0; i < VERT_ATTRIB_MAX; ++i) {
+      const struct gl_vertex_attrib_array *array = &vao->VertexAttrib[i];
+      if (!array->Enabled)
+         continue;
+
+      const struct gl_vertex_buffer_binding *binding =
+         &vao->VertexBinding[array->VertexBinding];
+      const struct gl_buffer_object *bo = binding->BufferObj;
+
+      fprintf(stderr, "  %s: Ptr=%p, Type=%s, Size=%d, ElemSize=%u, "
+              "Stride=%d, Buffer=%u(Size %lu)\n",
+              gl_vert_attrib_name((gl_vert_attrib)i),
+              array->Ptr, _mesa_enum_to_string(array->Type), array->Size,
+              array->_ElementSize, binding->Stride, bo->Name,
+              (unsigned long) bo->Size);
+   }
 }
 
 




More information about the mesa-commit mailing list