summaryrefslogtreecommitdiffstats
path: root/src/mesa/main/arrayobj.c
diff options
context:
space:
mode:
authorBrian Paul <[email protected]>2018-01-29 14:09:54 -0700
committerBrian Paul <[email protected]>2018-01-29 21:16:50 -0700
commitd5f42f96e16f4b1242e51fb9eec6f608b221a1c4 (patch)
tree09928889e4ae6e7bea279df1e0816caa57c9e349 /src/mesa/main/arrayobj.c
parent79cafa0df342f9fdc142ad2ed7d910044f5f4c4f (diff)
mesa: shrink size of gl_array_attributes (v2)
Inspired by Marek's earlier patch, but even smaller. Sort fields from largest to smallest. Use bitfields for more fields (sometimes with an extra bit for MSVC). Reduce Stride field to GLshort. Note that some fields cannot be bitfields because they're accessed via pointers (such as for glEnableClientState(GL_VERTEX_ARRAY) to set the Enabled field). Reduces size from 48 to 24 bytes. Also reduces size of gl_vertex_array_object from 3632 to 2864 bytes. And add some assertions in init_array(). v2: use s/GLuint/unsigned/, improve commit comments. Reviewed-by: Marek Olšák <[email protected]>
Diffstat (limited to 'src/mesa/main/arrayobj.c')
-rw-r--r--src/mesa/main/arrayobj.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/src/mesa/main/arrayobj.c b/src/mesa/main/arrayobj.c
index 2810647c7e7..9d3ddbfcbf0 100644
--- a/src/mesa/main/arrayobj.c
+++ b/src/mesa/main/arrayobj.c
@@ -233,7 +233,9 @@ init_array(struct gl_context *ctx,
struct gl_vertex_array_object *vao,
GLuint index, GLint size, GLint type)
{
+ assert(index < ARRAY_SIZE(vao->VertexAttrib));
struct gl_array_attributes *array = &vao->VertexAttrib[index];
+ assert(index < ARRAY_SIZE(vao->BufferBinding));
struct gl_vertex_buffer_binding *binding = &vao->BufferBinding[index];
array->Size = size;
@@ -247,6 +249,8 @@ init_array(struct gl_context *ctx,
array->Integer = GL_FALSE;
array->Doubles = GL_FALSE;
array->_ElementSize = size * _mesa_sizeof_type(type);
+ ASSERT_BITFIELD_SIZE(struct gl_array_attributes, BufferBindingIndex,
+ VERT_ATTRIB_MAX - 1);
array->BufferBindingIndex = index;
binding->Offset = 0;