[16/22] radeonsi: add support for importing PIPE_FD_TYPE_SYNCOBJ semaphores

Submitted by Andres Rodriguez on Dec. 22, 2017, 12:41 a.m.

Details

Message ID 20171222004157.28106-17-andresx7@gmail.com
State New
Headers show
Series "Add support for GL_EXT_semaphore" ( rev: 2 ) in Mesa

Not browsing as part of any series.

Commit Message

Andres Rodriguez Dec. 22, 2017, 12:41 a.m.
Hook up importing semaphores of type PIPE_FD_TYPE_SYNCOBJ

Signed-off-by: Andres Rodriguez <andresx7@gmail.com>
---
 src/gallium/drivers/radeonsi/si_fence.c | 26 ++++++++++++++++++++------
 1 file changed, 20 insertions(+), 6 deletions(-)

Patch hide | download patch | download mbox

diff --git a/src/gallium/drivers/radeonsi/si_fence.c b/src/gallium/drivers/radeonsi/si_fence.c
index 3b30eb0..086d45c 100644
--- a/src/gallium/drivers/radeonsi/si_fence.c
+++ b/src/gallium/drivers/radeonsi/si_fence.c
@@ -305,18 +305,32 @@  static void si_create_semaphore_fd(struct pipe_context *ctx,
 	struct radeon_winsys *ws = sscreen->ws;
 	struct si_multi_fence *rfence;
 
-	assert(type == PIPE_FD_TYPE_NATIVE_SYNC);
-
 	*pfence = NULL;
 
-	if (!sscreen->info.has_sync_file)
-		return;
-
 	rfence = si_create_multi_fence();
 	if (!rfence)
 		return;
 
-	rfence->gfx = ws->fence_import_sync_file(ws, fd);
+	switch (type) {
+	case PIPE_FD_TYPE_NATIVE_SYNC:
+		if (!sscreen->info.has_sync_file)
+			goto finish;
+
+		rfence->gfx = ws->fence_import_sync_file(ws, fd);
+		break;
+
+	case PIPE_FD_TYPE_SYNCOBJ:
+		if (!sscreen->info.has_syncobj)
+			goto finish;
+
+		rfence->gfx = ws->fence_import_syncobj(ws, fd);
+		break;
+
+	default:
+		unreachable("bad semaphore type when importing");
+	}
+
+finish:
 	if (!rfence->gfx) {
 		FREE(rfence);
 		return;