softpipe: pass stream-out targets to draw-module early
authorErik Faye-Lund <erik.faye-lund@collabora.com>
Tue, 7 May 2019 10:13:43 +0000 (12:13 +0200)
committerErik Faye-Lund <erik.faye-lund@collabora.com>
Wed, 17 Jul 2019 10:43:06 +0000 (10:43 +0000)
This is essensially a port of ed53e61bec9 from LLVMpipe to softpipe,
as it makes things a bit simpler and more performant.

Signed-off-by: Erik Faye-Lund <erik.faye-lund@collabora.com>
Reviewed-By: Gert Wollny <gert.wollny@collabora.com>
src/gallium/drivers/softpipe/sp_draw_arrays.c
src/gallium/drivers/softpipe/sp_state_so.c

index 6363701cf92ae36fe9853bf9bc75cc6565683ee9..91427348a25732c26a0460d92ea8473b36c0e64a 100644 (file)
@@ -109,18 +109,6 @@ softpipe_draw_vbo(struct pipe_context *pipe,
                        info->index_size, available_space);
    }
 
-
-   for (i = 0; i < sp->num_so_targets; i++) {
-      void *buf = 0;
-      if (sp->so_targets[i]) {
-         buf = softpipe_resource(sp->so_targets[i]->target.buffer)->data;
-         sp->so_targets[i]->mapping = buf;
-      }
-   }
-
-   draw_set_mapped_so_targets(draw, sp->num_so_targets,
-                              sp->so_targets);
-
    if (softpipe_screen(sp->pipe.screen)->use_llvm) {
       softpipe_prepare_vertex_sampling(sp,
                                        sp->num_sampler_views[PIPE_SHADER_VERTEX],
@@ -151,8 +139,6 @@ softpipe_draw_vbo(struct pipe_context *pipe,
       draw_set_indexes(draw, NULL, 0, 0);
    }
 
-   draw_set_mapped_so_targets(draw, 0, NULL);
-
    if (softpipe_screen(sp->pipe.screen)->use_llvm) {
       softpipe_cleanup_vertex_sampling(sp);
       softpipe_cleanup_geometry_sampling(sp);
index 3878e4a53891b88ad63e9a7ffbffe8ebc7e29706..aa2f11880dd27d12f97e0d59dd5b9a865d539574 100644 (file)
@@ -70,6 +70,11 @@ softpipe_set_so_targets(struct pipe_context *pipe,
 
    for (i = 0; i < num_targets; i++) {
       pipe_so_target_reference((struct pipe_stream_output_target **)&softpipe->so_targets[i], targets[i]);
+
+      if (targets[i]) {
+         void *buf = softpipe_resource(targets[i]->buffer)->data;
+         softpipe->so_targets[i]->mapping = buf;
+      }
    }
 
    for (; i < softpipe->num_so_targets; i++) {
@@ -77,6 +82,9 @@ softpipe_set_so_targets(struct pipe_context *pipe,
    }
 
    softpipe->num_so_targets = num_targets;
+
+   draw_set_mapped_so_targets(softpipe->draw, softpipe->num_so_targets,
+                              softpipe->so_targets);
 }
 
 void
@@ -86,4 +94,3 @@ softpipe_init_streamout_funcs(struct pipe_context *pipe)
    pipe->stream_output_target_destroy = softpipe_so_target_destroy;
    pipe->set_stream_output_targets = softpipe_set_so_targets;
 }
-