summaryrefslogtreecommitdiffstats
path: root/src/mesa/vbo
diff options
context:
space:
mode:
authorBrian Paul <[email protected]>2018-01-15 14:37:04 -0700
committerBrian Paul <[email protected]>2018-01-17 11:17:56 -0700
commit95dec9097fb0a5cf5438f04511a52724ea545302 (patch)
tree1081b7fd567e8aa8ea9916ed7d6518096d547fbd /src/mesa/vbo
parent5d78440d5830e5f38ac4b3094aadcd436db18365 (diff)
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 <[email protected]> Reviewed-by: Roland Scheidegger <[email protected]> Reviewed-by: Emil Velikov <[email protected]>
Diffstat (limited to 'src/mesa/vbo')
-rw-r--r--src/mesa/vbo/vbo_context.c3
-rw-r--r--src/mesa/vbo/vbo_context.h4
-rw-r--r--src/mesa/vbo/vbo_exec_draw.c2
-rw-r--r--src/mesa/vbo/vbo_save_draw.c4
4 files changed, 8 insertions, 5 deletions
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 */