Mesa (main): util/tc: make clear calls async

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Sat Jul 17 00:46:07 UTC 2021


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

Author: Mike Blumenkrantz <michael.blumenkrantz at gmail.com>
Date:   Tue Jul 13 19:52:47 2021 -0400

util/tc: make clear calls async

Reviewed-by: Marek Olšák <marek.olsak at amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/11864>

---

 src/gallium/auxiliary/util/u_threaded_context.c    | 78 +++++++++++++++++++---
 .../auxiliary/util/u_threaded_context_calls.h      |  2 +
 2 files changed, 70 insertions(+), 10 deletions(-)

diff --git a/src/gallium/auxiliary/util/u_threaded_context.c b/src/gallium/auxiliary/util/u_threaded_context.c
index 847e7057859..543662f0429 100644
--- a/src/gallium/auxiliary/util/u_threaded_context.c
+++ b/src/gallium/auxiliary/util/u_threaded_context.c
@@ -3532,6 +3532,28 @@ tc_clear(struct pipe_context *_pipe, unsigned buffers, const struct pipe_scissor
    p->stencil = stencil;
 }
 
+struct tc_clear_render_target {
+   struct tc_call_base base;
+   bool render_condition_enabled;
+   unsigned dstx;
+   unsigned dsty;
+   unsigned width;
+   unsigned height;
+   union pipe_color_union color;
+   struct pipe_surface *dst;
+};
+
+static uint16_t
+tc_call_clear_render_target(struct pipe_context *pipe, void *call, uint64_t *last)
+{
+   struct tc_clear_render_target *p = to_call(call, tc_clear_render_target);
+
+   pipe->clear_render_target(pipe, p->dst, &p->color, p->dstx, p->dsty, p->width, p->height,
+                             p->render_condition_enabled);
+   tc_drop_surface_reference(p->dst);
+   return call_size(tc_clear_render_target);
+}
+
 static void
 tc_clear_render_target(struct pipe_context *_pipe,
                        struct pipe_surface *dst,
@@ -3541,11 +3563,42 @@ tc_clear_render_target(struct pipe_context *_pipe,
                        bool render_condition_enabled)
 {
    struct threaded_context *tc = threaded_context(_pipe);
-   struct pipe_context *pipe = tc->pipe;
+   struct tc_clear_render_target *p = tc_add_call(tc, TC_CALL_clear_render_target, tc_clear_render_target);
+   p->dst = NULL;
+   pipe_surface_reference(&p->dst, dst);
+   p->color = *color;
+   p->dstx = dstx;
+   p->dsty = dsty;
+   p->width = width;
+   p->height = height;
+   p->render_condition_enabled = render_condition_enabled;
+}
 
-   tc_sync(tc);
-   pipe->clear_render_target(pipe, dst, color, dstx, dsty, width, height,
-                             render_condition_enabled);
+
+struct tc_clear_depth_stencil {
+   struct tc_call_base base;
+   bool render_condition_enabled;
+   float depth;
+   unsigned clear_flags;
+   unsigned stencil;
+   unsigned dstx;
+   unsigned dsty;
+   unsigned width;
+   unsigned height;
+   struct pipe_surface *dst;
+};
+
+
+static uint16_t
+tc_call_clear_depth_stencil(struct pipe_context *pipe, void *call, uint64_t *last)
+{
+   struct tc_clear_depth_stencil *p = to_call(call, tc_clear_depth_stencil);
+
+   pipe->clear_depth_stencil(pipe, p->dst, p->clear_flags, p->depth, p->stencil,
+                             p->dstx, p->dsty, p->width, p->height,
+                             p->render_condition_enabled);
+   tc_drop_surface_reference(p->dst);
+   return call_size(tc_clear_depth_stencil);
 }
 
 static void
@@ -3556,12 +3609,17 @@ tc_clear_depth_stencil(struct pipe_context *_pipe,
                        bool render_condition_enabled)
 {
    struct threaded_context *tc = threaded_context(_pipe);
-   struct pipe_context *pipe = tc->pipe;
-
-   tc_sync(tc);
-   pipe->clear_depth_stencil(pipe, dst, clear_flags, depth, stencil,
-                             dstx, dsty, width, height,
-                             render_condition_enabled);
+   struct tc_clear_depth_stencil *p = tc_add_call(tc, TC_CALL_clear_depth_stencil, tc_clear_depth_stencil);
+   p->dst = NULL;
+   pipe_surface_reference(&p->dst, dst);
+   p->clear_flags = clear_flags;
+   p->depth = depth;
+   p->stencil = stencil;
+   p->dstx = dstx;
+   p->dsty = dsty;
+   p->width = width;
+   p->height = height;
+   p->render_condition_enabled = render_condition_enabled;
 }
 
 struct tc_clear_buffer {
diff --git a/src/gallium/auxiliary/util/u_threaded_context_calls.h b/src/gallium/auxiliary/util/u_threaded_context_calls.h
index 7aae54f16e3..7174d3ab941 100644
--- a/src/gallium/auxiliary/util/u_threaded_context_calls.h
+++ b/src/gallium/auxiliary/util/u_threaded_context_calls.h
@@ -39,6 +39,8 @@ CALL(generate_mipmap)
 CALL(flush_resource)
 CALL(invalidate_resource)
 CALL(clear)
+CALL(clear_render_target)
+CALL(clear_depth_stencil)
 CALL(clear_buffer)
 CALL(clear_texture)
 CALL(resource_commit)



More information about the mesa-commit mailing list