[Mesa-dev] [PATCH 4/4] st/mesa: add support for new mesa indirect draw interface
Marek Olšák
maraeo at gmail.com
Fri Jan 1 04:13:37 PST 2016
On Thu, Dec 31, 2015 at 8:55 PM, Ilia Mirkin <imirkin at alum.mit.edu> wrote:
> This shifts all indirect draws to go through the new function. If the
> driver doesn't have support for multi draws, we break those up and
> perform N draws. Otherwise, we pass everything through for just a single
> draw call.
>
> Signed-off-by: Ilia Mirkin <imirkin at alum.mit.edu>
> ---
> src/mesa/state_tracker/st_context.c | 2 +
> src/mesa/state_tracker/st_context.h | 1 +
> src/mesa/state_tracker/st_draw.c | 100 ++++++++++++++++++++++++++++++++----
> 3 files changed, 94 insertions(+), 9 deletions(-)
>
> diff --git a/src/mesa/state_tracker/st_context.c b/src/mesa/state_tracker/st_context.c
> index 1459f25..d59f8a3 100644
> --- a/src/mesa/state_tracker/st_context.c
> +++ b/src/mesa/state_tracker/st_context.c
> @@ -249,6 +249,8 @@ st_create_context_priv( struct gl_context *ctx, struct pipe_context *pipe,
> PIPE_QUIRK_TEXTURE_BORDER_COLOR_SWIZZLE_R600));
> st->has_time_elapsed =
> screen->get_param(screen, PIPE_CAP_QUERY_TIME_ELAPSED);
> + st->has_multi_draw_indirect =
> + screen->get_param(screen, PIPE_CAP_MULTI_DRAW_INDIRECT);
>
> /* GL limits and extensions */
> st_init_limits(st->pipe->screen, &ctx->Const, &ctx->Extensions);
> diff --git a/src/mesa/state_tracker/st_context.h b/src/mesa/state_tracker/st_context.h
> index 60a9a4b..ccebdd9 100644
> --- a/src/mesa/state_tracker/st_context.h
> +++ b/src/mesa/state_tracker/st_context.h
> @@ -101,6 +101,7 @@ struct st_context
> boolean prefer_blit_based_texture_transfer;
> boolean force_persample_in_shader;
> boolean has_shareable_shaders;
> + boolean has_multi_draw_indirect;
>
> /**
> * If a shader can be created when we get its source.
> diff --git a/src/mesa/state_tracker/st_draw.c b/src/mesa/state_tracker/st_draw.c
> index 635a012..a041866 100644
> --- a/src/mesa/state_tracker/st_draw.c
> +++ b/src/mesa/state_tracker/st_draw.c
> @@ -249,13 +249,7 @@ st_draw_vbo(struct gl_context *ctx,
> }
> }
>
> - if (indirect) {
> - info.indirect = st_buffer_object(indirect)->buffer;
> -
> - /* Primitive restart is not handled by the VBO module in this case. */
> - info.primitive_restart = ctx->Array._PrimitiveRestart;
> - info.restart_index = ctx->Array.RestartIndex;
> - }
> + assert(!indirect);
>
> /* do actual drawing */
> for (i = 0; i < nr_prims; i++) {
> @@ -271,7 +265,6 @@ st_draw_vbo(struct gl_context *ctx,
> info.min_index = info.start;
> info.max_index = info.start + info.count - 1;
> }
> - info.indirect_offset = prims[i].indirect_offset;
>
> if (ST_DEBUG & DEBUG_DRAW) {
> debug_printf("st/draw: mode %s start %u count %u indexed %d\n",
> @@ -281,7 +274,7 @@ st_draw_vbo(struct gl_context *ctx,
> info.indexed);
> }
>
> - if (info.count_from_stream_output || info.indirect) {
> + if (info.count_from_stream_output) {
> cso_draw_vbo(st->cso_context, &info);
> }
> else if (info.primitive_restart) {
> @@ -298,6 +291,94 @@ st_draw_vbo(struct gl_context *ctx,
> }
> }
>
> +static void
> +st_indirect_draw_vbo(struct gl_context *ctx,
> + GLuint mode,
> + struct gl_buffer_object *indirect_data,
> + GLsizeiptr indirect_offset,
> + unsigned draw_count,
> + unsigned stride,
> + struct gl_buffer_object *indirect_params,
> + GLsizeiptr indirect_params_offset,
> + const struct _mesa_index_buffer *ib)
> +{
> + struct st_context *st = st_context(ctx);
> + struct pipe_index_buffer ibuffer = {0};
> + struct pipe_draw_info info;
> +
> + /* Mesa core state should have been validated already */
> + assert(ctx->NewState == 0x0);
> +
> + /* Validate state. */
> + if (st->dirty.st || ctx->NewDriverState) {
> + st_validate_state(st);
> +
> +#if 0
> + if (MESA_VERBOSE & VERBOSE_GLSL) {
> + check_uniforms(ctx);
> + }
> +#else
> + (void) check_uniforms;
> +#endif
Please, no #if 0. Other than that:
Reviewed-by: Marek Olšák <marek.olsak at amd.com>
Marek
More information about the mesa-dev
mailing list