diff options
Diffstat (limited to 'src/gallium/auxiliary/util/u_threaded_context.c')
-rw-r--r-- | src/gallium/auxiliary/util/u_threaded_context.c | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/src/gallium/auxiliary/util/u_threaded_context.c b/src/gallium/auxiliary/util/u_threaded_context.c index 84fbb224533..ffa824744e5 100644 --- a/src/gallium/auxiliary/util/u_threaded_context.c +++ b/src/gallium/auxiliary/util/u_threaded_context.c @@ -231,13 +231,23 @@ _tc_sync(struct threaded_context *tc, MAYBE_UNUSED const char *info, MAYBE_UNUSE */ void threaded_context_flush(struct pipe_context *_pipe, - struct tc_unflushed_batch_token *token) + struct tc_unflushed_batch_token *token, + bool prefer_async) { struct threaded_context *tc = threaded_context(_pipe); /* This is called from the state-tracker / application thread. */ - if (token->tc && token->tc == tc) - tc_sync(token->tc); + if (token->tc && token->tc == tc) { + struct tc_batch *last = &tc->batch_slots[tc->last]; + + /* Prefer to do the flush in the driver thread if it is already + * running. That should be better for cache locality. + */ + if (prefer_async || !util_queue_fence_is_signalled(&last->fence)) + tc_batch_flush(tc); + else + tc_sync(token->tc); + } } static void |