u_threaded_gallium: remove synchronization in fence_server_sync
authorNicolai Hähnle <nicolai.haehnle@amd.com>
Mon, 6 Nov 2017 10:56:54 +0000 (11:56 +0100)
committerNicolai Hähnle <nicolai.haehnle@amd.com>
Mon, 20 Nov 2017 17:15:06 +0000 (18:15 +0100)
The whole point of fence_server_sync is that it can be used to
avoid waiting in the application thread.

Reviewed-by: Andres Rodriguez <andresx7@gmail.com>
Reviewed-by: Marek Olšák <marek.olsak@amd.com>
src/gallium/auxiliary/util/u_threaded_context.c
src/gallium/auxiliary/util/u_threaded_context.h
src/gallium/auxiliary/util/u_threaded_context_calls.h

index b212393a5ba3fea3cc43599da35ea2faf28f666e..d0a8ffbd11af90d1f3f9b47e457aac636d507a1a 100644 (file)
@@ -1834,15 +1834,23 @@ tc_create_fence_fd(struct pipe_context *_pipe,
    pipe->create_fence_fd(pipe, fence, fd);
 }
 
+static void
+tc_call_fence_server_sync(struct pipe_context *pipe, union tc_payload *payload)
+{
+   pipe->fence_server_sync(pipe, payload->fence);
+   pipe->screen->fence_reference(pipe->screen, &payload->fence, NULL);
+}
+
 static void
 tc_fence_server_sync(struct pipe_context *_pipe,
                      struct pipe_fence_handle *fence)
 {
    struct threaded_context *tc = threaded_context(_pipe);
-   struct pipe_context *pipe = tc->pipe;
+   struct pipe_screen *screen = tc->pipe->screen;
+   union tc_payload *payload = tc_add_small_call(tc, TC_CALL_fence_server_sync);
 
-   tc_sync(tc);
-   pipe->fence_server_sync(pipe, fence);
+   payload->fence = NULL;
+   screen->fence_reference(screen, &payload->fence, fence);
 }
 
 static struct pipe_video_codec *
index ea815ed5e03fcf01b9f6bbccc886bd12173d31b4..b2d904569e1cb54a73a330b69728cc94b46007f6 100644 (file)
@@ -309,6 +309,7 @@ union tc_payload {
    struct pipe_query *query;
    struct pipe_resource *resource;
    struct pipe_transfer *transfer;
+   struct pipe_fence_handle *fence;
    uint64_t handle;
 };
 
index 0d2fd183680a4677e1f89007647c7cd965a95f17..675deaabd92530407debe7ede9e110101a5e0623 100644 (file)
@@ -1,5 +1,6 @@
 CALL(flush)
 CALL(callback)
+CALL(fence_server_sync)
 CALL(destroy_query)
 CALL(begin_query)
 CALL(end_query)