Module: Mesa
Branch: master
Commit: fca1550550793f0a1156ad795445e2242c1fea9b
URL:    
http://cgit.freedesktop.org/mesa/mesa/commit/?id=fca1550550793f0a1156ad795445e2242c1fea9b

Author: Mathias Fröhlich <mathias.froehl...@web.de>
Date:   Sun Mar 25 19:16:54 2018 +0200

gallium: Push down the gl_vertex_array inputs into gallium.

Let the gallium backend have its own gl_vertex_array array and basically
reimplement the way _vbo_draw works.

Reviewed-by: Brian Paul <bri...@vmware.com>
Signed-off-by: Mathias Fröhlich <mathias.froehl...@web.de>

---

 src/mesa/state_tracker/st_cb_feedback.c | 35 ++++++++++++++++++++++++++++++---
 src/mesa/state_tracker/st_context.c     |  9 ++++-----
 src/mesa/state_tracker/st_context.h     |  4 ++++
 src/mesa/state_tracker/st_draw.c        | 16 ++++++++++-----
 src/mesa/state_tracker/st_draw.h        |  2 +-
 5 files changed, 52 insertions(+), 14 deletions(-)

diff --git a/src/mesa/state_tracker/st_cb_feedback.c 
b/src/mesa/state_tracker/st_cb_feedback.c
index 436062b1f8..b7a082fca3 100644
--- a/src/mesa/state_tracker/st_cb_feedback.c
+++ b/src/mesa/state_tracker/st_cb_feedback.c
@@ -40,6 +40,7 @@
 #include "main/imports.h"
 #include "main/context.h"
 #include "main/feedback.h"
+#include "main/varray.h"
 
 #include "vbo/vbo.h"
 
@@ -272,6 +273,34 @@ draw_glselect_stage(struct gl_context *ctx, struct 
draw_context *draw)
 
 
 static void
+feedback_draw_vbo(struct gl_context *ctx,
+                  const struct _mesa_prim *prims,
+                  GLuint nr_prims,
+                  const struct _mesa_index_buffer *ib,
+                  GLboolean index_bounds_valid,
+                  GLuint min_index,
+                  GLuint max_index,
+                  struct gl_transform_feedback_object *tfb_vertcount,
+                  unsigned stream,
+                  struct gl_buffer_object *indirect)
+{
+   struct st_context *st = st_context(ctx);
+
+   /* The initial pushdown of the inputs array into the drivers */
+   _mesa_set_drawing_arrays(ctx, st->draw_arrays.inputs);
+   _vbo_update_inputs(ctx, &st->draw_arrays);
+
+   /* The above needs to happen outside of st_feedback_draw_vbo,
+    * since st_RasterPossets _DrawArrays and does not want that to be
+    * overwritten by _mesa_set_drawing_arrays.
+    */
+   st_feedback_draw_vbo(ctx, prims, nr_prims, ib, index_bounds_valid,
+                        min_index, max_index, tfb_vertcount,
+                        stream, indirect);
+}
+
+
+static void
 st_RenderMode(struct gl_context *ctx, GLenum newMode )
 {
    struct st_context *st = st_context(ctx);
@@ -282,14 +311,14 @@ st_RenderMode(struct gl_context *ctx, GLenum newMode )
 
    if (newMode == GL_RENDER) {
       /* restore normal VBO draw function */
-      st_init_draw(st);
+      st_init_draw_functions(&ctx->Driver);
    }
    else if (newMode == GL_SELECT) {
       if (!st->selection_stage)
          st->selection_stage = draw_glselect_stage(ctx, draw);
       draw_set_rasterize_stage(draw, st->selection_stage);
       /* Plug in new vbo draw function */
-      vbo_set_draw_func(ctx, st_feedback_draw_vbo);
+      ctx->Driver.Draw = feedback_draw_vbo;
    }
    else {
       struct gl_program *vp = st->ctx->VertexProgram._Current;
@@ -298,7 +327,7 @@ st_RenderMode(struct gl_context *ctx, GLenum newMode )
          st->feedback_stage = draw_glfeedback_stage(ctx, draw);
       draw_set_rasterize_stage(draw, st->feedback_stage);
       /* Plug in new vbo draw function */
-      vbo_set_draw_func(ctx, st_feedback_draw_vbo);
+      ctx->Driver.Draw = feedback_draw_vbo;
       /* need to generate/use a vertex program that emits pos/color/tex */
       if (vp)
          st->dirty |= ST_NEW_VERTEX_PROGRAM(st, st_vertex_program(vp));
diff --git a/src/mesa/state_tracker/st_context.c 
b/src/mesa/state_tracker/st_context.c
index 90b7f9359a..a3da0f8f1f 100644
--- a/src/mesa/state_tracker/st_context.c
+++ b/src/mesa/state_tracker/st_context.c
@@ -382,7 +382,6 @@ st_create_context_priv(struct gl_context *ctx, struct 
pipe_context *pipe,
 
    st_init_atoms(st);
    st_init_clear(st);
-   st_init_draw(st);
    st_init_pbo_helpers(st);
 
    /* Choose texture target for glDrawPixels, glBitmap, renderbuffers */
@@ -551,6 +550,9 @@ st_create_context_priv(struct gl_context *ctx, struct 
pipe_context *pipe,
    /* Initialize context's winsys buffers list */
    LIST_INITHEAD(&st->winsys_buffers);
 
+   /* Keep our list of gl_vertex_array inputs */
+   _vbo_init_inputs(&st->draw_arrays);
+
    return st;
 }
 
@@ -715,6 +717,7 @@ st_init_driver_functions(struct pipe_screen *screen,
    _mesa_init_shader_object_functions(functions);
    _mesa_init_sampler_object_functions(functions);
 
+   st_init_draw_functions(functions);
    st_init_blit_functions(functions);
    st_init_bufferobject_functions(screen, functions);
    st_init_clear_functions(functions);
@@ -752,10 +755,6 @@ st_init_driver_functions(struct pipe_screen *screen,
    if (screen->get_param(screen, PIPE_CAP_STRING_MARKER))
       functions->EmitStringMarker = st_emit_string_marker;
 
-   /* For now call through these into the vbo_set_draw_func... */
-   functions->Draw = _vbo_draw;
-   functions->DrawIndirect = _vbo_draw_indirect;
-
    functions->Enable = st_Enable;
    functions->UpdateState = st_invalidate_state;
    functions->QueryMemoryInfo = st_query_memory_info;
diff --git a/src/mesa/state_tracker/st_context.h 
b/src/mesa/state_tracker/st_context.h
index 9f2480e5da..5125fc5839 100644
--- a/src/mesa/state_tracker/st_context.h
+++ b/src/mesa/state_tracker/st_context.h
@@ -34,6 +34,7 @@
 #include "state_tracker/st_atom.h"
 #include "util/u_inlines.h"
 #include "util/list.h"
+#include "vbo/vbo.h"
 
 
 #ifdef __cplusplus
@@ -294,6 +295,9 @@ struct st_context
 
    /* Winsys buffers */
    struct list_head winsys_buffers;
+
+   /* For the initial pushdown, keep the list of vbo inputs. */
+   struct vbo_inputs draw_arrays;
 };
 
 
diff --git a/src/mesa/state_tracker/st_draw.c b/src/mesa/state_tracker/st_draw.c
index b95a2522b2..e9ffc18d91 100644
--- a/src/mesa/state_tracker/st_draw.c
+++ b/src/mesa/state_tracker/st_draw.c
@@ -145,6 +145,10 @@ st_draw_vbo(struct gl_context *ctx,
    unsigned i;
    unsigned start = 0;
 
+   /* The initial pushdown of the inputs array into the drivers */
+   _mesa_set_drawing_arrays(ctx, st->draw_arrays.inputs);
+   _vbo_update_inputs(ctx, &st->draw_arrays);
+
    prepare_draw(st, ctx);
 
    if (st->vertex_array_out_of_memory)
@@ -243,6 +247,10 @@ st_indirect_draw_vbo(struct gl_context *ctx,
    struct pipe_draw_info info;
    struct pipe_draw_indirect_info indirect;
 
+   /* The initial pushdown of the inputs array into the drivers */
+   _mesa_set_drawing_arrays(ctx, st->draw_arrays.inputs);
+   _vbo_update_inputs(ctx, &st->draw_arrays);
+
    assert(stride);
    prepare_draw(st, ctx);
 
@@ -304,12 +312,10 @@ st_indirect_draw_vbo(struct gl_context *ctx,
 
 
 void
-st_init_draw(struct st_context *st)
+st_init_draw_functions(struct dd_function_table *functions)
 {
-   struct gl_context *ctx = st->ctx;
-
-   vbo_set_draw_func(ctx, st_draw_vbo);
-   vbo_set_indirect_draw_func(ctx, st_indirect_draw_vbo);
+   functions->Draw = st_draw_vbo;
+   functions->DrawIndirect = st_indirect_draw_vbo;
 }
 
 
diff --git a/src/mesa/state_tracker/st_draw.h b/src/mesa/state_tracker/st_draw.h
index c4c2dc44ee..c1ebcd9f74 100644
--- a/src/mesa/state_tracker/st_draw.h
+++ b/src/mesa/state_tracker/st_draw.h
@@ -42,7 +42,7 @@ struct gl_vertex_array;
 struct gl_context;
 struct st_context;
 
-void st_init_draw( struct st_context *st );
+void st_init_draw_functions(struct dd_function_table *functions);
 
 void st_destroy_draw( struct st_context *st );
 

_______________________________________________
mesa-commit mailing list
mesa-commit@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-commit

Reply via email to