From: Brian Paul Date: Mon, 15 Jan 2018 21:37:04 +0000 (-0700) Subject: vbo: change vbo_context attribute map arrays to GLubyte X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=95dec9097fb0a5cf5438f04511a52724ea545302;p=mesa.git vbo: change vbo_context attribute map arrays to GLubyte The values will never be larger than VBO_ATTRIB_MAX (currently 44). v2: add STATIC_ASSERT to be sure VBO_ATTRIB_MAX can fit in ubyte, per Emil. Reviewed-by: Ian Romanick Reviewed-by: Roland Scheidegger Reviewed-by: Emil Velikov --- diff --git a/src/mesa/vbo/vbo_context.c b/src/mesa/vbo/vbo_context.c index a5f915d9bdb..2d4a973ebd6 100644 --- a/src/mesa/vbo/vbo_context.c +++ b/src/mesa/vbo/vbo_context.c @@ -200,6 +200,9 @@ GLboolean _vbo_CreateContext( struct gl_context *ctx ) { GLuint i; + /* make sure all VBO_ATTRIB_ values can fit in an unsigned byte */ + STATIC_ASSERT(VBO_ATTRIB_MAX <= 255); + /* identity mapping */ for (i = 0; i < ARRAY_SIZE(vbo->map_vp_none); i++) vbo->map_vp_none[i] = i; diff --git a/src/mesa/vbo/vbo_context.h b/src/mesa/vbo/vbo_context.h index 70757d0ea4d..04079b7d329 100644 --- a/src/mesa/vbo/vbo_context.h +++ b/src/mesa/vbo/vbo_context.h @@ -67,8 +67,8 @@ 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; diff --git a/src/mesa/vbo/vbo_exec_draw.c b/src/mesa/vbo/vbo_exec_draw.c index de173220fca..5d1e5880b6b 100644 --- a/src/mesa/vbo/vbo_exec_draw.c +++ b/src/mesa/vbo/vbo_exec_draw.c @@ -175,7 +175,7 @@ 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; GLbitfield varying_inputs = 0x0; bool swap_pos = false; diff --git a/src/mesa/vbo/vbo_save_draw.c b/src/mesa/vbo/vbo_save_draw.c index 41010225c3c..c1298f95a0c 100644 --- a/src/mesa/vbo/vbo_save_draw.c +++ b/src/mesa/vbo/vbo_save_draw.c @@ -137,7 +137,7 @@ bind_vertex_list(struct gl_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[] */ GLenum node_attrtype[VBO_ATTRIB_MAX]; /* copy of node->attrtype[] */ @@ -160,7 +160,7 @@ bind_vertex_list(struct gl_context *ctx, /* Install the default (ie Current) attributes first */ for (attr = 0; attr < VERT_ATTRIB_FF_MAX; attr++) { - save->inputs[attr] = &vbo->currval[VBO_ATTRIB_POS+attr]; + save->inputs[attr] = &vbo->currval[VBO_ATTRIB_POS + attr]; } /* Overlay other active attributes */