gallium: add pipe_context::multi_draw
Acked-by: Pierre-Eric Pelloux-Prayer <pierre-eric.pelloux-prayer@amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/7056>
diff --git a/src/gallium/include/pipe/p_context.h b/src/gallium/include/pipe/p_context.h
index d7fa315..b961c77 100644
--- a/src/gallium/include/pipe/p_context.h
+++ b/src/gallium/include/pipe/p_context.h
@@ -49,6 +49,7 @@
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 @@
/*@{*/
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 06f9565..0ae0297 100644
--- a/src/gallium/include/pipe/p_state.h
+++ b/src/gallium/include/pipe/p_state.h
@@ -720,6 +720,10 @@
struct pipe_resource *indirect_draw_count;
};
+struct pipe_draw_start_count {
+ unsigned start;
+ unsigned count;
+};
/**
* Information to describe a draw_vbo call.