[Mesa-dev] [PATCH v2] mesa/vbo: reduce prim array size

Bartosz Tomczyk bartosz.tomczyk86 at gmail.com
Tue May 2 11:19:34 UTC 2017


We always use only single element.

v2: Change signle element arrays to variables
---
 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 15382eaaae..0fcaefe30a 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.12.2



More information about the mesa-dev mailing list