[Mesa-dev] [PATCH 06/20] vbo: decrease the size of vbo_context slightly

Ian Romanick idr at freedesktop.org
Wed Nov 22 21:53:22 UTC 2017


On 11/21/2017 10:01 AM, Marek Olšák wrote:
> From: Marek Olšák <marek.olsak at amd.com>
> 
> vbo_context: 21520 -> 20344 bytes
> ---
>  src/mesa/main/mtypes.h       | 8 ++++----
>  src/mesa/vbo/vbo_context.h   | 4 ++--
>  src/mesa/vbo/vbo_exec_draw.c | 2 +-
>  src/mesa/vbo/vbo_save_draw.c | 2 +-
>  4 files changed, 8 insertions(+), 8 deletions(-)
> 
> diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h
> index 67711d8..660b1a5 100644
> --- a/src/mesa/main/mtypes.h
> +++ b/src/mesa/main/mtypes.h
> @@ -1452,31 +1452,31 @@ struct gl_pixelstore_attrib
>  };
>  
>  
>  /**
>   * Vertex array information which is derived from gl_array_attributes
>   * and gl_vertex_buffer_binding information.  Used by the VBO module and
>   * device drivers.
>   */
>  struct gl_vertex_array
>  {
> -   GLint Size;                  /**< components per element (1,2,3,4) */
>     GLenum16 Type;               /**< datatype: GL_FLOAT, GL_INT, etc */
>     GLenum16 Format;             /**< default: GL_RGBA, but may be GL_BGRA */
> -   GLsizei StrideB;		/**< actual stride in bytes */
> -   GLuint _ElementSize;         /**< size of each element in bytes */
> -   const GLubyte *Ptr;          /**< Points to array data */
> +   GLshort StrideB;		/**< actual stride in bytes */

It looks like the largest value anyone currently advertises for
MaxVertexAttribStride is 2048.  We should probably have a check
somewhere that someone doesn't try to use 65537.

> +   GLubyte Size;                /**< components per element (1,2,3,4) */
> +   GLubyte _ElementSize;        /**< size of each element in bytes */
>     GLboolean Normalized;        /**< GL_ARB_vertex_program */
>     GLboolean Integer;           /**< Integer-valued? */
>     GLboolean Doubles;       /**< double precision values are not converted to floats */
>     GLuint InstanceDivisor;      /**< GL_ARB_instanced_arrays */
>  
> +   const GLubyte *Ptr;          /**< Points to array data */
>     struct gl_buffer_object *BufferObj;/**< GL_ARB_vertex_buffer_object */
>  };
>  
>  
>  /**
>   * Attributes to describe a vertex array.
>   *
>   * Contains the size, type, format and normalization flag,
>   * along with the index of a vertex buffer binding point.
>   *
> diff --git a/src/mesa/vbo/vbo_context.h b/src/mesa/vbo/vbo_context.h
> index 70757d0..04079b7 100644
> --- a/src/mesa/vbo/vbo_context.h
> +++ b/src/mesa/vbo/vbo_context.h
> @@ -60,22 +60,22 @@
>  #include "main/macros.h"
>  
>  #ifdef __cplusplus
>  extern "C" {
>  #endif
>  
>  struct vbo_context {
>     struct gl_vertex_array currval[VBO_ATTRIB_MAX];
>     
>     /** Map VERT_ATTRIB_x to VBO_ATTRIB_y */
> -   GLuint map_vp_none[VERT_ATTRIB_MAX];
> -   GLuint map_vp_arb[VERT_ATTRIB_MAX];
> +   GLubyte map_vp_none[VERT_ATTRIB_MAX];
> +   GLubyte map_vp_arb[VERT_ATTRIB_MAX];
>  
>     struct vbo_exec_context exec;
>     struct vbo_save_context save;
>  
>     /* Callback into the driver.  This must always succeed, the driver
>      * is responsible for initiating any fallback actions required:
>      */
>     vbo_draw_func draw_prims;
>  
>     /* Optional callback for indirect draws. This allows multidraws to not be
> diff --git a/src/mesa/vbo/vbo_exec_draw.c b/src/mesa/vbo/vbo_exec_draw.c
> index df34f05..f34b591 100644
> --- a/src/mesa/vbo/vbo_exec_draw.c
> +++ b/src/mesa/vbo/vbo_exec_draw.c
> @@ -168,21 +168,21 @@ vbo_copy_vertices( struct vbo_exec_context *exec )
>  
>  
>  /* TODO: populate these as the vertex is defined:
>   */
>  static void
>  vbo_exec_bind_arrays( struct gl_context *ctx )
>  {
>     struct vbo_context *vbo = vbo_context(ctx);
>     struct vbo_exec_context *exec = &vbo->exec;
>     struct gl_vertex_array *arrays = exec->vtx.arrays;
> -   const GLuint *map;
> +   const GLubyte *map;
>     GLuint attr;
>     GLbitfield64 varying_inputs = 0x0;
>     bool swap_pos = false;
>  
>     /* Install the default (ie Current) attributes first, then overlay
>      * all active ones.
>      */
>     switch (get_program_mode(exec->ctx)) {
>     case VP_NONE:
>        for (attr = 0; attr < VERT_ATTRIB_FF_MAX; attr++) {
> diff --git a/src/mesa/vbo/vbo_save_draw.c b/src/mesa/vbo/vbo_save_draw.c
> index 3fad4c7..02920c9 100644
> --- a/src/mesa/vbo/vbo_save_draw.c
> +++ b/src/mesa/vbo/vbo_save_draw.c
> @@ -130,21 +130,21 @@ _playback_copy_to_current(struct gl_context *ctx,
>   * Treat the vertex storage as a VBO, define vertex arrays pointing
>   * into it:
>   */
>  static void vbo_bind_vertex_list(struct gl_context *ctx,
>                                   const struct vbo_save_vertex_list *node)
>  {
>     struct vbo_context *vbo = vbo_context(ctx);
>     struct vbo_save_context *save = &vbo->save;
>     struct gl_vertex_array *arrays = save->arrays;
>     GLuint buffer_offset = node->buffer_offset;
> -   const GLuint *map;
> +   const GLubyte *map;
>     GLuint attr;
>     GLubyte node_attrsz[VBO_ATTRIB_MAX];  /* copy of node->attrsz[] */
>     GLenum16 node_attrtype[VBO_ATTRIB_MAX];  /* copy of node->attrtype[] */
>     GLbitfield64 varying_inputs = 0x0;
>  
>     memcpy(node_attrsz, node->attrsz, sizeof(node->attrsz));
>     memcpy(node_attrtype, node->attrtype, sizeof(node->attrtype));
>  
>     /* Install the default (ie Current) attributes first, then overlay
>      * all active ones.
> 



More information about the mesa-dev mailing list