Module: Mesa
Branch: main
Commit: 1b09fbd9aa265bd1f969f9f85564b7ac4260a950
URL:    
http://cgit.freedesktop.org/mesa/mesa/commit/?id=1b09fbd9aa265bd1f969f9f85564b7ac4260a950

Author: Marek Olšák <[email protected]>
Date:   Sat Dec 31 13:41:49 2022 -0500

mesa: add a pipe_draw_indirect_info* parameter into the DrawGallium callback

We need this to enable GL_SELECT and GL_FEEDBACK modes for indirect draws.

Reviewed-by: Pierre-Eric Pelloux-Prayer <[email protected]>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/26786>

---

 src/mesa/main/dd.h                        |  5 +++--
 src/mesa/main/draw.c                      | 14 +++++++-------
 src/mesa/state_tracker/st_cb_rasterpos.c  |  2 +-
 src/mesa/state_tracker/st_draw.c          |  6 ++++--
 src/mesa/state_tracker/st_draw.h          |  1 +
 src/mesa/state_tracker/st_draw_feedback.c |  6 +++---
 src/mesa/vbo/vbo_save_draw.c              |  4 ++--
 7 files changed, 21 insertions(+), 17 deletions(-)

diff --git a/src/mesa/main/dd.h b/src/mesa/main/dd.h
index 972f515dba9..fea734db1e7 100644
--- a/src/mesa/main/dd.h
+++ b/src/mesa/main/dd.h
@@ -62,6 +62,7 @@ struct gl_vertex_array_object;
 struct ati_fragment_shader;
 struct util_queue_monitoring;
 struct pipe_draw_info;
+struct pipe_draw_indirect_info;
 struct pipe_draw_start_count_bias;
 struct pipe_vertex_state;
 struct pipe_draw_vertex_state_info;
@@ -145,8 +146,7 @@ struct dd_function_table {
     * 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.
+    * The interface is identical to pipe_context::draw_vbo.
     *
     * "info" is not const and the following fields can be changed by
     * the callee, so callers should be aware:
@@ -158,6 +158,7 @@ struct dd_function_table {
    void (*DrawGallium)(struct gl_context *ctx,
                        struct pipe_draw_info *info,
                        unsigned drawid_offset,
+                       const struct pipe_draw_indirect_info *indirect,
                        const struct pipe_draw_start_count_bias *draws,
                        unsigned num_draws);
 
diff --git a/src/mesa/main/draw.c b/src/mesa/main/draw.c
index 884a6aaee05..a1c4df0bf93 100644
--- a/src/mesa/main/draw.c
+++ b/src/mesa/main/draw.c
@@ -1200,7 +1200,7 @@ _mesa_draw_arrays(struct gl_context *ctx, GLenum mode, 
GLint start,
 
    st_prepare_draw(ctx, ST_PIPELINE_RENDER_STATE_MASK);
 
-   ctx->Driver.DrawGallium(ctx, &info, ctx->DrawID, &draw, 1);
+   ctx->Driver.DrawGallium(ctx, &info, ctx->DrawID, NULL, &draw, 1);
 
    if (MESA_DEBUG_FLAGS & DEBUG_ALWAYS_FLUSH) {
       _mesa_flush(ctx);
@@ -1507,7 +1507,7 @@ _mesa_MultiDrawArrays(GLenum mode, const GLint *first,
 
    st_prepare_draw(ctx, ST_PIPELINE_RENDER_STATE_MASK);
 
-   ctx->Driver.DrawGallium(ctx, &info, 0, draw, primcount);
+   ctx->Driver.DrawGallium(ctx, &info, 0, NULL, draw, primcount);
 
    if (MESA_DEBUG_FLAGS & DEBUG_ALWAYS_FLUSH)
       _mesa_flush(ctx);
@@ -1679,7 +1679,7 @@ _mesa_validated_drawrangeelements(struct gl_context *ctx,
    if (!validate_index_bounds(ctx, &info, &draw, 1))
       return;
 
-   ctx->Driver.DrawGallium(ctx, &info, ctx->DrawID, &draw, 1);
+   ctx->Driver.DrawGallium(ctx, &info, ctx->DrawID, NULL, &draw, 1);
 
    if (MESA_DEBUG_FLAGS & DEBUG_ALWAYS_FLUSH) {
       _mesa_flush(ctx);
@@ -2063,7 +2063,7 @@ _mesa_validated_multidrawelements(struct gl_context *ctx,
       if (!validate_index_bounds(ctx, &info, draw, primcount))
          return;
 
-      ctx->Driver.DrawGallium(ctx, &info, 0, draw, primcount);
+      ctx->Driver.DrawGallium(ctx, &info, 0, NULL, draw, primcount);
    } else {
       /* draw[i].start would overflow. Draw one at a time. */
       assert(info.has_user_indices);
@@ -2087,7 +2087,7 @@ _mesa_validated_multidrawelements(struct gl_context *ctx,
          if (!draw.count || !validate_index_bounds(ctx, &info, &draw, 1))
             continue;
 
-         ctx->Driver.DrawGallium(ctx, &info, i, &draw, 1);
+         ctx->Driver.DrawGallium(ctx, &info, i, NULL, &draw, 1);
       }
    }
 
@@ -2416,7 +2416,7 @@ _mesa_MultiDrawArraysIndirect(GLenum mode, const GLvoid 
*indirect,
          if (!draw.count)
             continue;
 
-         ctx->Driver.DrawGallium(ctx, &info, i, &draw, 1);
+         ctx->Driver.DrawGallium(ctx, &info, i, NULL, &draw, 1);
          ptr += stride;
       }
 
@@ -2532,7 +2532,7 @@ _mesa_MultiDrawElementsIndirect(GLenum mode, GLenum type,
          if (!draw.count || !validate_index_bounds(ctx, &info, &draw, 1))
             continue;
 
-         ctx->Driver.DrawGallium(ctx, &info, i, &draw, 1);
+         ctx->Driver.DrawGallium(ctx, &info, i, NULL, &draw, 1);
          ptr += stride;
       }
 
diff --git a/src/mesa/state_tracker/st_cb_rasterpos.c 
b/src/mesa/state_tracker/st_cb_rasterpos.c
index c728ff92868..fe8ec093f8c 100644
--- a/src/mesa/state_tracker/st_cb_rasterpos.c
+++ b/src/mesa/state_tracker/st_cb_rasterpos.c
@@ -278,7 +278,7 @@ st_RasterPos(struct gl_context *ctx, const GLfloat v[4])
                                ctx->Array._DrawVAO->_EnabledWithMapMode);
 
    st_prepare_draw(ctx, ST_PIPELINE_RENDER_STATE_MASK);
-   st_feedback_draw_vbo(ctx, &rs->info, 0, &rs->draw, 1);
+   st_feedback_draw_vbo(ctx, &rs->info, 0, NULL, &rs->draw, 1);
 
    _mesa_restore_draw_vao(ctx, old_vao, old_vp_input_filter);
 
diff --git a/src/mesa/state_tracker/st_draw.c b/src/mesa/state_tracker/st_draw.c
index 582d853f6ab..58514404f26 100644
--- a/src/mesa/state_tracker/st_draw.c
+++ b/src/mesa/state_tracker/st_draw.c
@@ -115,12 +115,13 @@ static void
 st_draw_gallium(struct gl_context *ctx,
                 struct pipe_draw_info *info,
                 unsigned drawid_offset,
+                const struct pipe_draw_indirect_info *indirect,
                 const struct pipe_draw_start_count_bias *draws,
                 unsigned num_draws)
 {
    struct st_context *st = st_context(ctx);
 
-   cso_draw_vbo(st->cso_context, info, drawid_offset, NULL, draws, num_draws);
+   cso_draw_vbo(st->cso_context, info, drawid_offset, indirect, draws, 
num_draws);
 }
 
 static void
@@ -439,6 +440,7 @@ static void
 st_hw_select_draw_gallium(struct gl_context *ctx,
                           struct pipe_draw_info *info,
                           unsigned drawid_offset,
+                          const struct pipe_draw_indirect_info *indirect,
                           const struct pipe_draw_start_count_bias *draws,
                           unsigned num_draws)
 {
@@ -447,7 +449,7 @@ st_hw_select_draw_gallium(struct gl_context *ctx,
 
    if (st_draw_hw_select_prepare_common(ctx) &&
        st_draw_hw_select_prepare_mode(ctx, info)) {
-      cso_draw_vbo(st->cso_context, info, drawid_offset, NULL, draws,
+      cso_draw_vbo(st->cso_context, info, drawid_offset, indirect, draws,
                    num_draws);
    }
 
diff --git a/src/mesa/state_tracker/st_draw.h b/src/mesa/state_tracker/st_draw.h
index a52182e0451..121f0a561e2 100644
--- a/src/mesa/state_tracker/st_draw.h
+++ b/src/mesa/state_tracker/st_draw.h
@@ -50,6 +50,7 @@ void
 st_feedback_draw_vbo(struct gl_context *ctx,
                      struct pipe_draw_info *info,
                      unsigned drawid_offset,
+                     const struct pipe_draw_indirect_info *indirect,
                      const struct pipe_draw_start_count_bias *draws,
                      unsigned num_draws);
 
diff --git a/src/mesa/state_tracker/st_draw_feedback.c 
b/src/mesa/state_tracker/st_draw_feedback.c
index 4da566849c4..e667759b850 100644
--- a/src/mesa/state_tracker/st_draw_feedback.c
+++ b/src/mesa/state_tracker/st_draw_feedback.c
@@ -95,6 +95,7 @@ void
 st_feedback_draw_vbo(struct gl_context *ctx,
                      struct pipe_draw_info *info,
                      unsigned drawid_offset,
+                     const struct pipe_draw_indirect_info *indirect,
                      const struct pipe_draw_start_count_bias *draws,
                      unsigned num_draws)
 {
@@ -386,8 +387,7 @@ st_feedback_draw_vbo(struct gl_context *ctx,
 
    /* draw here */
    for (i = 0; i < num_draws; i++) {
-      /* TODO: indirect draws */
-      draw_vbo(draw, info, info->increment_draw_id ? i : 0, NULL,
+      draw_vbo(draw, info, info->increment_draw_id ? i : 0, indirect,
                &draws[i], 1, ctx->TessCtrlProgram.patch_vertices);
    }
 
@@ -469,6 +469,6 @@ st_feedback_draw_vbo_multi_mode(struct gl_context *ctx,
 {
    for (unsigned i = 0; i < num_draws; i++) {
       info->mode = mode[i];
-      st_feedback_draw_vbo(ctx, info, 0, &draws[i], 1);
+      st_feedback_draw_vbo(ctx, info, 0, NULL, &draws[i], 1);
    }
 }
diff --git a/src/mesa/vbo/vbo_save_draw.c b/src/mesa/vbo/vbo_save_draw.c
index 7d46341ebfe..0923db73514 100644
--- a/src/mesa/vbo/vbo_save_draw.c
+++ b/src/mesa/vbo/vbo_save_draw.c
@@ -359,9 +359,9 @@ vbo_save_playback_vertex_list(struct gl_context *ctx, void 
*data, bool copy_to_c
                                        node->modes,
                                        node->num_draws);
    } else if (node->num_draws == 1) {
-      ctx->Driver.DrawGallium(ctx, info, 0, &node->start_count, 1);
+      ctx->Driver.DrawGallium(ctx, info, 0, NULL, &node->start_count, 1);
    } else if (node->num_draws) {
-      ctx->Driver.DrawGallium(ctx, info, 0, node->start_counts,
+      ctx->Driver.DrawGallium(ctx, info, 0, NULL, node->start_counts,
                               node->num_draws);
    }
 

Reply via email to