From 288d109ff3b5dc81705046d5e46ac11781d2e63e Mon Sep 17 00:00:00 2001 From: Mike Blumenkrantz Date: Fri, 14 Oct 2022 11:45:39 -0400 Subject: [PATCH] util/tc: split out flush and deferred flush calls MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit it's useful to be able to separate these, and deferred flushes can also consume slightly less memory Acked-by: Pierre-Eric Pelloux-Prayer Reviewed-by: Marek Olšák Part-of: --- src/gallium/auxiliary/util/u_threaded_context.c | 33 ++++++++++++++++++---- .../auxiliary/util/u_threaded_context_calls.h | 1 + 2 files changed, 29 insertions(+), 5 deletions(-) diff --git a/src/gallium/auxiliary/util/u_threaded_context.c b/src/gallium/auxiliary/util/u_threaded_context.c index 5cb8f78..6882079 100644 --- a/src/gallium/auxiliary/util/u_threaded_context.c +++ b/src/gallium/auxiliary/util/u_threaded_context.c @@ -3116,11 +3116,17 @@ tc_set_context_param(struct pipe_context *_pipe, * draw, launch, clear, blit, copy, flush */ +struct tc_flush_deferred_call { + struct tc_call_base base; + unsigned flags; + struct pipe_fence_handle *fence; +}; + struct tc_flush_call { struct tc_call_base base; unsigned flags; - struct threaded_context *tc; struct pipe_fence_handle *fence; + struct threaded_context *tc; }; static void @@ -3139,6 +3145,18 @@ tc_flush_queries(struct threaded_context *tc) } static uint16_t +tc_call_flush_deferred(struct pipe_context *pipe, void *call, uint64_t *last) +{ + struct tc_flush_deferred_call *p = to_call(call, tc_flush_deferred_call); + struct pipe_screen *screen = pipe->screen; + + pipe->flush(pipe, p->fence ? &p->fence : NULL, p->flags); + screen->fence_reference(screen, &p->fence, NULL); + + return call_size(tc_flush_deferred_call); +} + +static uint16_t tc_call_flush(struct pipe_context *pipe, void *call, uint64_t *last) { struct tc_flush_call *p = to_call(call, tc_flush_call); @@ -3147,8 +3165,7 @@ tc_call_flush(struct pipe_context *pipe, void *call, uint64_t *last) pipe->flush(pipe, p->fence ? &p->fence : NULL, p->flags); screen->fence_reference(screen, &p->fence, NULL); - if (!(p->flags & PIPE_FLUSH_DEFERRED)) - tc_flush_queries(p->tc); + tc_flush_queries(p->tc); return call_size(tc_flush_call); } @@ -3181,8 +3198,14 @@ tc_flush(struct pipe_context *_pipe, struct pipe_fence_handle **fence, goto out_of_memory; } - struct tc_flush_call *p = tc_add_call(tc, TC_CALL_flush, tc_flush_call); - p->tc = tc; + struct tc_flush_call *p; + if (flags & PIPE_FLUSH_DEFERRED) { + /* these have identical fields */ + p = (struct tc_flush_call *)tc_add_call(tc, TC_CALL_flush_deferred, tc_flush_deferred_call); + } else { + p = tc_add_call(tc, TC_CALL_flush, tc_flush_call); + p->tc = tc; + } p->fence = fence ? *fence : NULL; p->flags = flags | TC_FLUSH_ASYNC; diff --git a/src/gallium/auxiliary/util/u_threaded_context_calls.h b/src/gallium/auxiliary/util/u_threaded_context_calls.h index 2dbdd88..c3ba53f 100644 --- a/src/gallium/auxiliary/util/u_threaded_context_calls.h +++ b/src/gallium/auxiliary/util/u_threaded_context_calls.h @@ -1,4 +1,5 @@ CALL(flush) +CALL(flush_deferred) CALL(callback) CALL(fence_server_sync) CALL(destroy_query) -- 2.7.4