[Mesa-dev] [PATCH 01/22] gallium: add type parameter to create_fence_fd
Andres Rodriguez
andresx7 at gmail.com
Fri Dec 22 00:41:36 UTC 2017
An fd can potentially have different types of objects backing it.
Specifying the type helps us make sure we treat the FD correctly.
This is in preparation to allow importing syncobj fence FDs in addition
to native sync FDs.
Signed-off-by: Andres Rodriguez <andresx7 at gmail.com>
---
src/gallium/auxiliary/util/u_tests.c | 7 ++++---
src/gallium/auxiliary/util/u_threaded_context.c | 5 +++--
src/gallium/drivers/etnaviv/etnaviv_fence.c | 4 +++-
src/gallium/drivers/etnaviv/etnaviv_fence.h | 3 ++-
src/gallium/drivers/freedreno/freedreno_fence.c | 4 +++-
src/gallium/drivers/freedreno/freedreno_fence.h | 3 ++-
src/gallium/drivers/radeonsi/si_fence.c | 5 ++++-
src/gallium/drivers/svga/svga_pipe_flush.c | 4 +++-
src/gallium/include/pipe/p_context.h | 8 +++++---
src/gallium/include/pipe/p_defines.h | 5 +++++
src/gallium/state_trackers/dri/dri_helpers.c | 2 +-
11 files changed, 35 insertions(+), 15 deletions(-)
diff --git a/src/gallium/auxiliary/util/u_tests.c b/src/gallium/auxiliary/util/u_tests.c
index 2548b46..6e0d84f 100644
--- a/src/gallium/auxiliary/util/u_tests.c
+++ b/src/gallium/auxiliary/util/u_tests.c
@@ -502,6 +502,7 @@ test_sync_file_fences(struct pipe_context *ctx)
{
struct pipe_screen *screen = ctx->screen;
bool pass = true;
+ enum pipe_fd_type fd_type = PIPE_FD_TYPE_NATIVE_SYNC;
if (!screen->get_param(screen, PIPE_CAP_NATIVE_FENCE_FD))
return;
@@ -536,9 +537,9 @@ test_sync_file_fences(struct pipe_context *ctx)
/* (Re)import all fences. */
struct pipe_fence_handle *re_buf_fence = NULL, *re_tex_fence = NULL;
struct pipe_fence_handle *merged_fence = NULL;
- ctx->create_fence_fd(ctx, &re_buf_fence, buf_fd);
- ctx->create_fence_fd(ctx, &re_tex_fence, tex_fd);
- ctx->create_fence_fd(ctx, &merged_fence, merged_fd);
+ ctx->create_fence_fd(ctx, &re_buf_fence, buf_fd, fd_type);
+ ctx->create_fence_fd(ctx, &re_tex_fence, tex_fd, fd_type);
+ ctx->create_fence_fd(ctx, &merged_fence, merged_fd, fd_type);
pass = pass && re_buf_fence && re_tex_fence && merged_fence;
/* Run another clear after waiting for everything. */
diff --git a/src/gallium/auxiliary/util/u_threaded_context.c b/src/gallium/auxiliary/util/u_threaded_context.c
index ffa8247..3ea1797 100644
--- a/src/gallium/auxiliary/util/u_threaded_context.c
+++ b/src/gallium/auxiliary/util/u_threaded_context.c
@@ -1835,13 +1835,14 @@ tc_set_log_context(struct pipe_context *_pipe, struct u_log_context *log)
static void
tc_create_fence_fd(struct pipe_context *_pipe,
- struct pipe_fence_handle **fence, int fd)
+ struct pipe_fence_handle **fence, int fd,
+ enum pipe_fd_type type)
{
struct threaded_context *tc = threaded_context(_pipe);
struct pipe_context *pipe = tc->pipe;
tc_sync(tc);
- pipe->create_fence_fd(pipe, fence, fd);
+ pipe->create_fence_fd(pipe, fence, fd, type);
}
static void
diff --git a/src/gallium/drivers/etnaviv/etnaviv_fence.c b/src/gallium/drivers/etnaviv/etnaviv_fence.c
index d82708e..22a964a 100644
--- a/src/gallium/drivers/etnaviv/etnaviv_fence.c
+++ b/src/gallium/drivers/etnaviv/etnaviv_fence.c
@@ -76,8 +76,10 @@ etna_screen_fence_finish(struct pipe_screen *pscreen, struct pipe_context *ctx,
void
etna_create_fence_fd(struct pipe_context *pctx,
- struct pipe_fence_handle **pfence, int fd)
+ struct pipe_fence_handle **pfence, int fd,
+ enum pipe_fd_type type)
{
+ assert(type == PIPE_FD_TYPE_NATIVE_SYNC);
*pfence = etna_fence_create(pctx, dup(fd));
}
diff --git a/src/gallium/drivers/etnaviv/etnaviv_fence.h b/src/gallium/drivers/etnaviv/etnaviv_fence.h
index cd68a42..8b8bb63 100644
--- a/src/gallium/drivers/etnaviv/etnaviv_fence.h
+++ b/src/gallium/drivers/etnaviv/etnaviv_fence.h
@@ -32,7 +32,8 @@
void
etna_create_fence_fd(struct pipe_context *pctx,
- struct pipe_fence_handle **pfence, int fd);
+ struct pipe_fence_handle **pfence, int fd,
+ enum pipe_fd_type type);
void
etna_fence_server_sync(struct pipe_context *pctx,
diff --git a/src/gallium/drivers/freedreno/freedreno_fence.c b/src/gallium/drivers/freedreno/freedreno_fence.c
index 9289720..1925f72 100644
--- a/src/gallium/drivers/freedreno/freedreno_fence.c
+++ b/src/gallium/drivers/freedreno/freedreno_fence.c
@@ -120,8 +120,10 @@ static struct pipe_fence_handle * fence_create(struct fd_context *ctx,
}
void fd_create_fence_fd(struct pipe_context *pctx,
- struct pipe_fence_handle **pfence, int fd)
+ struct pipe_fence_handle **pfence, int fd,
+ enum pipe_fd_type type)
{
+ assert(type == PIPE_FD_TYPE_NATIVE_SYNC);
*pfence = fence_create(fd_context(pctx), NULL, 0, dup(fd));
}
diff --git a/src/gallium/drivers/freedreno/freedreno_fence.h b/src/gallium/drivers/freedreno/freedreno_fence.h
index c1a9fd3..0842a1d 100644
--- a/src/gallium/drivers/freedreno/freedreno_fence.h
+++ b/src/gallium/drivers/freedreno/freedreno_fence.h
@@ -41,7 +41,8 @@ boolean fd_fence_finish(struct pipe_screen *screen,
struct pipe_fence_handle *pfence,
uint64_t timeout);
void fd_create_fence_fd(struct pipe_context *pctx,
- struct pipe_fence_handle **pfence, int fd);
+ struct pipe_fence_handle **pfence, int fd,
+ enum pipe_fd_type type);
void fd_fence_server_sync(struct pipe_context *pctx,
struct pipe_fence_handle *fence);
int fd_fence_get_fd(struct pipe_screen *pscreen,
diff --git a/src/gallium/drivers/radeonsi/si_fence.c b/src/gallium/drivers/radeonsi/si_fence.c
index 3c4d754..dbf4c51 100644
--- a/src/gallium/drivers/radeonsi/si_fence.c
+++ b/src/gallium/drivers/radeonsi/si_fence.c
@@ -298,12 +298,15 @@ static boolean si_fence_finish(struct pipe_screen *screen,
}
static void si_create_fence_fd(struct pipe_context *ctx,
- struct pipe_fence_handle **pfence, int fd)
+ struct pipe_fence_handle **pfence, int fd,
+ enum pipe_fd_type type)
{
struct si_screen *sscreen = (struct si_screen*)ctx->screen;
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)
diff --git a/src/gallium/drivers/svga/svga_pipe_flush.c b/src/gallium/drivers/svga/svga_pipe_flush.c
index 85ec34f..1f4eebc 100644
--- a/src/gallium/drivers/svga/svga_pipe_flush.c
+++ b/src/gallium/drivers/svga/svga_pipe_flush.c
@@ -85,10 +85,12 @@ static void svga_flush( struct pipe_context *pipe,
static void
svga_create_fence_fd(struct pipe_context *pipe,
struct pipe_fence_handle **fence,
- int fd)
+ int fd,
+ enum pipe_fd_type type)
{
struct svga_winsys_screen *sws = svga_winsys_screen(pipe->screen);
+ assert(type == PIPE_FD_TYPE_NATIVE_SYNC);
sws->fence_create_fd(sws, fence, fd);
}
diff --git a/src/gallium/include/pipe/p_context.h b/src/gallium/include/pipe/p_context.h
index b74e649..1c7f52c 100644
--- a/src/gallium/include/pipe/p_context.h
+++ b/src/gallium/include/pipe/p_context.h
@@ -505,17 +505,19 @@ struct pipe_context {
unsigned flags);
/**
- * Create a fence from a native sync fd.
+ * Create a fence from a fd.
*
* This is used for importing a foreign/external fence fd.
*
* \param fence if not NULL, an old fence to unref and transfer a
* new fence reference to
- * \param fd native fence fd
+ * \param fd fd representing the fence object
+ * \param type indicates which fence types backs fd
*/
void (*create_fence_fd)(struct pipe_context *pipe,
struct pipe_fence_handle **fence,
- int fd);
+ int fd,
+ enum pipe_fd_type type);
/**
* Insert commands to have GPU wait for fence to be signaled.
diff --git a/src/gallium/include/pipe/p_defines.h b/src/gallium/include/pipe/p_defines.h
index e4d0d63..3ae3e14 100644
--- a/src/gallium/include/pipe/p_defines.h
+++ b/src/gallium/include/pipe/p_defines.h
@@ -1066,6 +1066,11 @@ struct pipe_driver_query_group_info
unsigned num_queries;
};
+enum pipe_fd_type
+{
+ PIPE_FD_TYPE_NATIVE_SYNC,
+};
+
enum pipe_debug_type
{
PIPE_DEBUG_TYPE_OUT_OF_MEMORY = 1,
diff --git a/src/gallium/state_trackers/dri/dri_helpers.c b/src/gallium/state_trackers/dri/dri_helpers.c
index 37ab2c2..f1501bf 100644
--- a/src/gallium/state_trackers/dri/dri_helpers.c
+++ b/src/gallium/state_trackers/dri/dri_helpers.c
@@ -119,7 +119,7 @@ dri2_create_fence_fd(__DRIcontext *_ctx, int fd)
stapi->flush(stapi, ST_FLUSH_FENCE_FD, &fence->pipe_fence);
} else {
/* importing a foreign fence fd: */
- ctx->create_fence_fd(ctx, &fence->pipe_fence, fd);
+ ctx->create_fence_fd(ctx, &fence->pipe_fence, fd, PIPE_FD_TYPE_NATIVE_SYNC);
}
if (!fence->pipe_fence) {
FREE(fence);
--
2.9.3
More information about the mesa-dev
mailing list