From 73f2d3c291f83fba2c94ab71ae4288ba71955814 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20Ol=C5=A1=C3=A1k?= Date: Wed, 7 Oct 2020 18:49:33 -0400 Subject: [PATCH] gallium: add pipe_context::multi_draw Acked-by: Pierre-Eric Pelloux-Prayer Part-of: --- src/gallium/include/pipe/p_context.h | 36 ++++++++++++++++++++++++++++ src/gallium/include/pipe/p_state.h | 4 ++++ 2 files changed, 40 insertions(+) diff --git a/src/gallium/include/pipe/p_context.h b/src/gallium/include/pipe/p_context.h index d7fa3156b6c..b961c7780b5 100644 --- a/src/gallium/include/pipe/p_context.h +++ b/src/gallium/include/pipe/p_context.h @@ -49,6 +49,7 @@ struct pipe_debug_callback; struct pipe_depth_stencil_alpha_state; struct pipe_device_reset_callback; struct pipe_draw_info; +struct pipe_draw_start_count; struct pipe_grid_info; struct pipe_fence_handle; struct pipe_framebuffer_state; @@ -108,6 +109,41 @@ struct pipe_context { /*@{*/ void (*draw_vbo)( struct pipe_context *pipe, const struct pipe_draw_info *info ); + + /** + * Direct multi draw specifying "start" and "count" for each draw. + * + * For indirect multi draws, use draw_vbo, which supports them through + * "info->indirect". + * + * Differences against draw_vbo: + * - "start" and "count" are taken from "draws", not "info" + * - "info->has_user_indices" is always false + * - "info->indirect" and "info->count_from_stream_output" are always NULL + * + * Differences against glMultiDraw: + * - "info->draw_id" is 0 and should be 0 for every draw + * (we could make this configurable) + * - "info->index_bias" is always constant due to hardware performance + * concerns (this is very important) and the lack of apps using + * glMultiDrawElementsBaseVertex. + * + * The main use case is to optimize applications that submit many + * back-to-back draws or when mesa/main or st/mesa eliminates redundant + * state changes, resulting in back-to-back draws in the driver. It requires + * DrawID = 0 for every draw. u_threaded_context is the module that converts + * back-to-back draws into a multi draw. It's done trivially by looking + * ahead within a gallium command buffer and collapsing draws. + * + * \param pipe context + * \param info draw info + * \param draws array of (start, count) pairs + * \param num_draws number of draws + */ + void (*multi_draw)(struct pipe_context *pipe, + const struct pipe_draw_info *info, + const struct pipe_draw_start_count *draws, + unsigned num_draws); /*@}*/ /** diff --git a/src/gallium/include/pipe/p_state.h b/src/gallium/include/pipe/p_state.h index 06f9565cfaf..0ae0297e30b 100644 --- a/src/gallium/include/pipe/p_state.h +++ b/src/gallium/include/pipe/p_state.h @@ -720,6 +720,10 @@ struct pipe_draw_indirect_info struct pipe_resource *indirect_draw_count; }; +struct pipe_draw_start_count { + unsigned start; + unsigned count; +}; /** * Information to describe a draw_vbo call.