gallium: add type parameter to create_fence_fd

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>
This commit is contained in:
Andres Rodriguez 2017-12-04 15:27:08 -05:00
parent 16dd0eb517
commit 585daa2378
11 changed files with 35 additions and 15 deletions

View File

@ -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. */

View File

@ -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

View File

@ -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));
}

View File

@ -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,

View File

@ -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));
}

View File

@ -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,

View File

@ -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_fence_to_handle)

View File

@ -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);
}

View File

@ -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.

View File

@ -1084,6 +1084,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,

View File

@ -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);