[Mesa-dev] [PATCH 5/5] mesa: Replace gl_client_array usage in _mesa_print_arrays()

Fredrik Höglund fredrik at kde.org
Fri Sep 19 11:04:26 PDT 2014


On Friday 19 September 2014, Kenneth Graunke wrote:
> For now, this prints out the same information as before - just using the
> newer/non-derived structures.  Printing out each structure's fields
> separately might be more useful, but I've never used this code, so I'm
> not sure.
> 
> Signed-off-by: Kenneth Graunke <kenneth at whitecape.org>
> ---
>  src/mesa/main/varray.c | 47 +++++++++++++++++++++++++++++++----------------
>  1 file changed, 31 insertions(+), 16 deletions(-)
> 
> diff --git a/src/mesa/main/varray.c b/src/mesa/main/varray.c
> index 09bf52c..380a32e 100644
> --- a/src/mesa/main/varray.c
> +++ b/src/mesa/main/varray.c
> @@ -1904,16 +1904,19 @@ _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)
> +print_array(const char *name, GLint index,
> +            const struct gl_vertex_attrib_array *attrib,
> +            const struct gl_vertex_buffer_binding *binding)
>  {
>     if (index >= 0)
>        printf("  %s[%d]: ", name, index);
>     else
>        printf("  %s: ", name);
>     printf("Ptr=%p, Type=0x%x, Size=%d, ElemSize=%u, Stride=%d, Buffer=%u(Size %lu)\n",
> -	  array->Ptr, array->Type, array->Size,
> -	  array->_ElementSize, array->StrideB,
> -	  array->BufferObj->Name, (unsigned long) array->BufferObj->Size);
> +	  _mesa_vertex_attrib_address(attrib, binding),
> +          attrib->Type, attrib->Size,
> +	  attrib->_ElementSize, binding->Stride,
> +	  binding->BufferObj->Name, (unsigned long) binding->BufferObj->Size);
>  }
>  
>  
> @@ -1927,18 +1930,30 @@ _mesa_print_arrays(struct gl_context *ctx)
>     GLuint i;
>  
>     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)]);
> +   if (vao->VertexAttrib[VERT_ATTRIB_POS].Enabled) {
> +      print_array("Vertex", -1, &vao->VertexAttrib[VERT_ATTRIB_POS],
> +                                &vao->VertexBinding[VERT_ATTRIB_POS]);
> +   }
> +   if (vao->VertexAttrib[VERT_ATTRIB_NORMAL].Enabled) {
> +      print_array("Normal", -1, &vao->VertexAttrib[VERT_ATTRIB_NORMAL],
> +                                &vao->VertexBinding[VERT_ATTRIB_NORMAL]);
> +   }
> +   if (vao->VertexAttrib[VERT_ATTRIB_COLOR0].Enabled) {
> +      print_array("Color", -1, &vao->VertexAttrib[VERT_ATTRIB_COLOR0],
> +                               &vao->VertexBinding[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)],
> +                                    &vao->VertexBinding[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)],
> +                                  &vao->VertexBinding[VERT_ATTRIB_GENERIC(i)]);

The generic attributes are not always associated with the vertex
binding of the same index.  The VertexBinding array should be indexed
by gl_vertex_attrib_array::VertexBinding.

I think it would be easier to just pass the vao pointer and the index
to print_array() and let it figure out which attrib array and binding
it should use.

> +      }
> +   }
>  }
>  
>  
> 



More information about the mesa-dev mailing list