llvmpipe: pass stream-out targets to draw-module early
authorErik Faye-Lund <erik.faye-lund@collabora.com>
Mon, 6 May 2019 13:35:04 +0000 (15:35 +0200)
committerErik Faye-Lund <erik.faye-lund@collabora.com>
Mon, 6 May 2019 20:42:37 +0000 (22:42 +0200)
We currently set this state in the draw-module twice on each draw, but
which trashes this state. So far that's not a problem, because we don't
really do much from that function.

But it turns out, we're going to have to do more; namely flush when the
state changes. This will incur a large performance penalty due to the
excessive setting.

Instead, let's rely on the CSO caching making sure that
llvmpipe_set_so_targets doesn't get called needlessly, and setup the
state directly there instead.

Signed-off-by: Erik Faye-Lund <erik.faye-lund@collabora.com>
Reviewed-by: Roland Scheidegger <sroland@vmware.com>
src/gallium/drivers/llvmpipe/lp_draw_arrays.c
src/gallium/drivers/llvmpipe/lp_state_so.c

index 2efe3ef5bb83f6ed72c5fe9de22fd19334ef56e8..3ce3d47829063e6006be38e0830d41d3abf8fe16 100644 (file)
@@ -99,16 +99,6 @@ llvmpipe_draw_vbo(struct pipe_context *pipe, const struct pipe_draw_info *info)
                        info->index_size, available_space);
    }
 
-   for (i = 0; i < lp->num_so_targets; i++) {
-      void *buf = 0;
-      if (lp->so_targets[i]) {
-         buf = llvmpipe_resource(lp->so_targets[i]->target.buffer)->data;
-         lp->so_targets[i]->mapping = buf;
-      }
-   }
-   draw_set_mapped_so_targets(draw, lp->num_so_targets,
-                              lp->so_targets);
-
    llvmpipe_prepare_vertex_sampling(lp,
                                     lp->num_sampler_views[PIPE_SHADER_VERTEX],
                                     lp->sampler_views[PIPE_SHADER_VERTEX]);
@@ -137,7 +127,6 @@ llvmpipe_draw_vbo(struct pipe_context *pipe, const struct pipe_draw_info *info)
    if (mapped_indices) {
       draw_set_indexes(draw, NULL, 0, 0);
    }
-   draw_set_mapped_so_targets(draw, 0, NULL);
 
    if (lp->gs && lp->gs->no_tokens) {
       /* we have attached stream output to the vs for rendering,
index b2afd6fbf702ba202b031cf0aed830af0654762c..0fd38c17e5073e42793c5cd29df648319ebbb6a3 100644 (file)
@@ -85,12 +85,20 @@ llvmpipe_set_so_targets(struct pipe_context *pipe,
       if (!append && llvmpipe->so_targets[i]) {
          llvmpipe->so_targets[i]->internal_offset = offsets[i];
       }
+
+      if (targets[i]) {
+         void *buf = llvmpipe_resource(targets[i]->buffer)->data;
+         llvmpipe->so_targets[i]->mapping = buf;
+      }
    }
 
    for (; i < llvmpipe->num_so_targets; i++) {
       pipe_so_target_reference((struct pipe_stream_output_target **)&llvmpipe->so_targets[i], NULL);
    }
    llvmpipe->num_so_targets = num_targets;
+
+   draw_set_mapped_so_targets(llvmpipe->draw, llvmpipe->num_so_targets,
+                              llvmpipe->so_targets);
 }
 
 void