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@gmail.com>
Reviewed-by: Marek Olšák <marek.olsak@amd.com>
{
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;
/* (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. */
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
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));
}
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,
}
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));
}
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,
}
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_fence_to_handle)
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);
}
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.
unsigned num_queries;
};
+enum pipe_fd_type
+{
+ PIPE_FD_TYPE_NATIVE_SYNC,
+};
+
enum pipe_debug_type
{
PIPE_DEBUG_TYPE_OUT_OF_MEMORY = 1,
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);