[Mesa-dev] [PATCH 4/8] vbo: use software primitive restart in the VBO module

Marek Olšák maraeo at gmail.com
Fri May 11 09:48:46 PDT 2012


On Fri, May 11, 2012 at 5:15 PM, Jordan Justen
<jordan.l.justen at intel.com> wrote:
> When PrimitiveRestartInSoftware is set, the VBO module will handle
> primitive restart scenarios before calling the vbo_draw_func
> drawing function.
>
> Signed-off-by: Jordan Justen <jordan.l.justen at intel.com>
> ---
>  src/mesa/vbo/vbo_exec_array.c |   50 ++++++++++++++++++++++++++++++-----------
>  1 file changed, 37 insertions(+), 13 deletions(-)
>
> diff --git a/src/mesa/vbo/vbo_exec_array.c b/src/mesa/vbo/vbo_exec_array.c
> index cc94e76..e584cef 100644
> --- a/src/mesa/vbo/vbo_exec_array.c
> +++ b/src/mesa/vbo/vbo_exec_array.c
> @@ -542,6 +542,30 @@ vbo_bind_arrays(struct gl_context *ctx)
>  }
>
>
> +static void vbo_exec_array_draw_prims(struct gl_context *ctx,
> +                                      const struct _mesa_prim *prim,
> +                                      GLuint nr_prims,
> +                                      const struct _mesa_index_buffer *ib,
> +                                      GLboolean index_bounds_valid,
> +                                      GLuint min_index,
> +                                      GLuint max_index,
> +                                      struct gl_transform_feedback_object *tfb_vertcount)
> +{
> +   struct vbo_context *vbo = vbo_context(ctx);
> +
> +   if ((ib != NULL) &&
> +       ctx->Const.PrimitiveRestartInSoftware &&
> +       ctx->Array.PrimitiveRestart) {
> +      /* Handle primitive restart in software */
> +      vbo_sw_primitive_restart(ctx, prim, nr_prims, ib, tfb_vertcount);
> +   } else {
> +      /* Call driver directly for draw_prims */
> +      vbo->draw_prims(ctx, prim, nr_prims, ib,
> +                      index_bounds_valid, min_index, max_index, tfb_vertcount);
> +   }
> +}
> +
> +
>  /**
>  * Helper function called by the other DrawArrays() functions below.
>  * This is where we handle primitive restart for drawing non-indexed
> @@ -600,8 +624,8 @@ vbo_draw_arrays(struct gl_context *ctx, GLenum mode, GLint start,
>       if (primCount > 0) {
>          /* draw one or two prims */
>          check_buffers_are_unmapped(exec->array.inputs);
> -         vbo->draw_prims(ctx, prim, primCount, NULL,
> -                         GL_TRUE, start, start + count - 1, NULL);
> +         vbo_exec_array_draw_prims(ctx, prim, primCount, NULL,
> +                                   GL_TRUE, start, start + count - 1, NULL);
>       }
>    }
>    else {

The hunk above can be discarded (and I would prefer if it were), because the
draw call is non-indexed.

> @@ -610,9 +634,9 @@ vbo_draw_arrays(struct gl_context *ctx, GLenum mode, GLint start,
>       prim[0].count = count;
>
>       check_buffers_are_unmapped(exec->array.inputs);
> -      vbo->draw_prims(ctx, prim, 1, NULL,
> -                      GL_TRUE, start, start + count - 1,
> -                      NULL);
> +      vbo_exec_array_draw_prims(ctx, prim, 1, NULL,
> +                                GL_TRUE, start, start + count - 1,
> +                                NULL);
>    }
>  }
>

Same as above.

> @@ -801,8 +825,8 @@ vbo_validated_drawrangeelements(struct gl_context *ctx, GLenum mode,
>     */
>
>    check_buffers_are_unmapped(exec->array.inputs);
> -   vbo->draw_prims( ctx, prim, 1, &ib,
> -                   index_bounds_valid, start, end, NULL );
> +   vbo_exec_array_draw_prims(ctx, prim, 1, &ib,
> +                             index_bounds_valid, start, end, NULL );
>  }
>
>
> @@ -1096,8 +1120,8 @@ vbo_validated_multidrawelements(struct gl_context *ctx, GLenum mode,
>       }
>
>       check_buffers_are_unmapped(exec->array.inputs);
> -      vbo->draw_prims(ctx, prim, primcount, &ib,
> -                     GL_FALSE, ~0, ~0, NULL);
> +      vbo_exec_array_draw_prims(ctx, prim, primcount, &ib,
> +                                GL_FALSE, ~0, ~0, NULL);
>    } else {
>       /* render one prim at a time */
>       for (i = 0; i < primcount; i++) {
> @@ -1121,8 +1145,8 @@ vbo_validated_multidrawelements(struct gl_context *ctx, GLenum mode,
>            prim[0].basevertex = 0;
>
>          check_buffers_are_unmapped(exec->array.inputs);
> -         vbo->draw_prims(ctx, prim, 1, &ib,
> -                         GL_FALSE, ~0, ~0, NULL);
> +         vbo_exec_array_draw_prims(ctx, prim, 1, &ib,
> +                                   GL_FALSE, ~0, ~0, NULL);
>       }
>    }
>
> @@ -1199,8 +1223,8 @@ vbo_draw_transform_feedback(struct gl_context *ctx, GLenum mode,
>     * will be rendered. */
>
>    check_buffers_are_unmapped(exec->array.inputs);
> -   vbo->draw_prims(ctx, prim, 1, NULL,
> -                   GL_TRUE, 0, 0, obj);
> +   vbo_exec_array_draw_prims(ctx, prim, 1, NULL,
> +                             GL_TRUE, 0, 0, obj);
>  }

glDrawTransformFeedback is non-indexed too and obviously you can't do
any primitive splitting in it anyway, because the vertex count is
inaccessible to a CPU (and _mesa_prim::count is always 0).

Marek


More information about the mesa-dev mailing list