mesa: add Driver.DrawGallium* functions to be used by main/draw.c
authorMarek Olšák <marek.olsak@amd.com>
Tue, 3 Nov 2020 17:14:12 +0000 (12:14 -0500)
committerMarek Olšák <marek.olsak@amd.com>
Tue, 5 Jan 2021 00:22:33 +0000 (19:22 -0500)
This is a new Draw interface using the same parameters as draw_vbo.

Reviewed-by: Pierre-Eric Pelloux-Prayer <pierre-eric.pelloux-prayer@amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/7679>

src/mesa/drivers/common/driverfuncs.c
src/mesa/main/dd.h

index 21771d2..88ecb93 100644 (file)
@@ -121,6 +121,8 @@ _mesa_init_driver_functions(struct dd_function_table *driver)
 
    /* Draw functions */
    driver->Draw = NULL;
+   driver->DrawGallium = NULL;
+   driver->DrawGalliumComplex = NULL;
    driver->DrawIndirect = NULL;
    driver->DrawTransformFeedback = NULL;
 
index 4539448..3eaf20f 100644 (file)
@@ -56,6 +56,8 @@ struct ati_fragment_shader;
 struct util_queue_monitoring;
 struct _mesa_prim;
 struct _mesa_index_buffer;
+struct pipe_draw_info;
+struct pipe_draw_start_count;
 
 /* GL_ARB_vertex_buffer_object */
 /* Modifies GL_MAP_UNSYNCHRONIZED_BIT to allow driver to fail (return
@@ -554,6 +556,46 @@ struct dd_function_table {
                 unsigned min_index, unsigned max_index,
                 unsigned num_instances, unsigned base_instance);
 
+   /**
+    * Optimal Gallium version of Draw() that doesn't require translation
+    * of draw info in the state tracker.
+    *
+    * The interface is identical to pipe_context::draw_vbo
+    * with indirect == NULL.
+    *
+    * "info" is not const and the following fields can be changed by
+    * the callee, so callers should be aware:
+    * - info->index_bounds_valid (if false)
+    * - info->min_index (if index_bounds_valid is false)
+    * - info->max_index (if index_bounds_valid is false)
+    * - info->drawid (if increment_draw_id is true)
+    * - info->index.gl_bo (if index_size && !has_user_indices)
+    */
+   void (*DrawGallium)(struct gl_context *ctx,
+                       struct pipe_draw_info *info,
+                       const struct pipe_draw_start_count *draws,
+                       unsigned num_draws);
+
+   /**
+    * Same as DrawGallium, but base_vertex and mode can also change between draws.
+    *
+    * If index_bias != NULL, index_bias changes for each draw.
+    * If mode != NULL, mode changes for each draw.
+    * At least one of them must be non-NULL.
+    *
+    * "info" is not const and the following fields can be changed by
+    * the callee in addition to the fields listed by DrawGallium:
+    * - info->mode (if mode != NULL)
+    * - info->index_bias (if index_bias != NULL)
+    *
+    * This function exists to decrease complexity of DrawGallium.
+    */
+   void (*DrawGalliumComplex)(struct gl_context *ctx,
+                              struct pipe_draw_info *info,
+                              const struct pipe_draw_start_count *draws,
+                              const unsigned char *mode,
+                              const int *base_vertex,
+                              unsigned num_draws);
 
    /**
     * Draw a primitive, getting the vertex count, instance count, start