From fcf941068e67ca0483dc453dd27992e2cd27ea21 Mon Sep 17 00:00:00 2001 From: Bartosz Tomczyk Date: Tue, 2 May 2017 13:19:34 +0200 Subject: [PATCH] mesa/vbo: reduce prim array size MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit We always use only single element. v2: Change single element arrays to variables Reviewed-by: Brian Paul Reviewed-by: Nicolai Hähnle --- src/mesa/vbo/vbo_exec_array.c | 74 +++++++++++++++++------------------ 1 file changed, 37 insertions(+), 37 deletions(-) diff --git a/src/mesa/vbo/vbo_exec_array.c b/src/mesa/vbo/vbo_exec_array.c index 15382eaaae0..0fcaefe30a8 100644 --- a/src/mesa/vbo/vbo_exec_array.c +++ b/src/mesa/vbo/vbo_exec_array.c @@ -462,7 +462,7 @@ vbo_draw_arrays(struct gl_context *ctx, GLenum mode, GLint start, GLuint drawID) { struct vbo_context *vbo = vbo_context(ctx); - struct _mesa_prim prim[2]; + struct _mesa_prim prim; if (skip_validated_draw(ctx)) return; @@ -472,18 +472,18 @@ vbo_draw_arrays(struct gl_context *ctx, GLenum mode, GLint start, /* OpenGL 4.5 says that primitive restart is ignored with non-indexed * draws. */ - memset(prim, 0, sizeof(prim)); - prim[0].begin = 1; - prim[0].end = 1; - prim[0].mode = mode; - prim[0].num_instances = numInstances; - prim[0].base_instance = baseInstance; - prim[0].draw_id = drawID; - prim[0].is_indirect = 0; - prim[0].start = start; - prim[0].count = count; - - vbo->draw_prims(ctx, prim, 1, NULL, + memset(&prim, 0, sizeof(prim)); + prim.begin = 1; + prim.end = 1; + prim.mode = mode; + prim.num_instances = numInstances; + prim.base_instance = baseInstance; + prim.draw_id = drawID; + prim.is_indirect = 0; + prim.start = start; + prim.count = count; + + vbo->draw_prims(ctx, &prim, 1, NULL, GL_TRUE, start, start + count - 1, NULL, 0, NULL); if (MESA_DEBUG_FLAGS & DEBUG_ALWAYS_FLUSH) { @@ -853,7 +853,7 @@ vbo_validated_drawrangeelements(struct gl_context *ctx, GLenum mode, { struct vbo_context *vbo = vbo_context(ctx); struct _mesa_index_buffer ib; - struct _mesa_prim prim[1]; + struct _mesa_prim prim; if (skip_draw_elements(ctx, count, indices)) return; @@ -865,19 +865,19 @@ vbo_validated_drawrangeelements(struct gl_context *ctx, GLenum mode, ib.obj = ctx->Array.VAO->IndexBufferObj; ib.ptr = indices; - prim[0].begin = 1; - prim[0].end = 1; - prim[0].weak = 0; - prim[0].pad = 0; - prim[0].mode = mode; - prim[0].start = 0; - prim[0].count = count; - prim[0].indexed = 1; - prim[0].is_indirect = 0; - prim[0].basevertex = basevertex; - prim[0].num_instances = numInstances; - prim[0].base_instance = baseInstance; - prim[0].draw_id = 0; + prim.begin = 1; + prim.end = 1; + prim.weak = 0; + prim.pad = 0; + prim.mode = mode; + prim.start = 0; + prim.count = count; + prim.indexed = 1; + prim.is_indirect = 0; + prim.basevertex = basevertex; + prim.num_instances = numInstances; + prim.base_instance = baseInstance; + prim.draw_id = 0; /* Need to give special consideration to rendering a range of * indices starting somewhere above zero. Typically the @@ -910,7 +910,7 @@ vbo_validated_drawrangeelements(struct gl_context *ctx, GLenum mode, * for the latter case elsewhere. */ - vbo->draw_prims(ctx, prim, 1, &ib, + vbo->draw_prims(ctx, &prim, 1, &ib, index_bounds_valid, start, end, NULL, 0, NULL); if (MESA_DEBUG_FLAGS & DEBUG_ALWAYS_FLUSH) { @@ -1409,7 +1409,7 @@ vbo_draw_transform_feedback(struct gl_context *ctx, GLenum mode, GLuint stream, GLuint numInstances) { struct vbo_context *vbo = vbo_context(ctx); - struct _mesa_prim prim[2]; + struct _mesa_prim prim; if (!_mesa_validate_DrawTransformFeedback(ctx, mode, obj, stream, numInstances)) { @@ -1431,19 +1431,19 @@ vbo_draw_transform_feedback(struct gl_context *ctx, GLenum mode, vbo_bind_arrays(ctx); /* init most fields to zero */ - memset(prim, 0, sizeof(prim)); - prim[0].begin = 1; - prim[0].end = 1; - prim[0].mode = mode; - prim[0].num_instances = numInstances; - prim[0].base_instance = 0; - prim[0].is_indirect = 0; + memset(&prim, 0, sizeof(prim)); + prim.begin = 1; + prim.end = 1; + prim.mode = mode; + prim.num_instances = numInstances; + prim.base_instance = 0; + prim.is_indirect = 0; /* Maybe we should do some primitive splitting for primitive restart * (like in DrawArrays), but we have no way to know how many vertices * will be rendered. */ - vbo->draw_prims(ctx, prim, 1, NULL, GL_FALSE, 0, ~0, obj, stream, NULL); + vbo->draw_prims(ctx, &prim, 1, NULL, GL_FALSE, 0, ~0, obj, stream, NULL); if (MESA_DEBUG_FLAGS & DEBUG_ALWAYS_FLUSH) { _mesa_flush(ctx); -- 2.30.2