Mesa (master): radeonsi: allocate filled_size for streamout targets in set_streamout_buffers

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Wed Feb 17 10:01:29 UTC 2021


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

Author: Marek Olšák <marek.olsak at amd.com>
Date:   Thu Feb 11 17:41:01 2021 -0500

radeonsi: allocate filled_size for streamout targets in set_streamout_buffers

so that create_stream_output_target doesn't use the context and can be
called from any thread. This is for u_threaded_context.

Reviewed-by: Zoltán Böszörményi <zboszor at gmail.com>
Reviewed-by: Pierre-Eric Pelloux-Prayer <pierre-eric.pelloux-prayer at amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/9028>

---

 src/gallium/drivers/radeonsi/si_state_streamout.c | 18 +++++++++---------
 1 file changed, 9 insertions(+), 9 deletions(-)

diff --git a/src/gallium/drivers/radeonsi/si_state_streamout.c b/src/gallium/drivers/radeonsi/si_state_streamout.c
index 2d8fb989106..5303ad5e83d 100644
--- a/src/gallium/drivers/radeonsi/si_state_streamout.c
+++ b/src/gallium/drivers/radeonsi/si_state_streamout.c
@@ -39,7 +39,6 @@ static struct pipe_stream_output_target *si_create_so_target(struct pipe_context
                                                              unsigned buffer_offset,
                                                              unsigned buffer_size)
 {
-   struct si_context *sctx = (struct si_context *)ctx;
    struct si_streamout_target *t;
    struct si_resource *buf = si_resource(buffer);
 
@@ -48,14 +47,6 @@ static struct pipe_stream_output_target *si_create_so_target(struct pipe_context
       return NULL;
    }
 
-   unsigned buf_filled_size_size = sctx->screen->use_ngg_streamout ? 8 : 4;
-   u_suballocator_alloc(&sctx->allocator_zeroed_memory, buf_filled_size_size, 4,
-                        &t->buf_filled_size_offset, (struct pipe_resource **)&t->buf_filled_size);
-   if (!t->buf_filled_size) {
-      FREE(t);
-      return NULL;
-   }
-
    t->b.reference.count = 1;
    t->b.context = ctx;
    pipe_resource_reference(&t->b.buffer, buffer);
@@ -166,6 +157,15 @@ static void si_set_streamout_targets(struct pipe_context *ctx, unsigned num_targ
 
       if (offsets[i] == ((unsigned)-1))
          append_bitmask |= 1 << i;
+
+      /* Allocate space for the filled buffer size. */
+      struct si_streamout_target *t = sctx->streamout.targets[i];
+      if (!t->buf_filled_size) {
+         unsigned buf_filled_size_size = sctx->screen->use_ngg_streamout ? 8 : 4;
+         u_suballocator_alloc(&sctx->allocator_zeroed_memory, buf_filled_size_size, 4,
+                              &t->buf_filled_size_offset,
+                              (struct pipe_resource **)&t->buf_filled_size);
+      }
    }
 
    for (; i < sctx->streamout.num_targets; i++)



More information about the mesa-commit mailing list