Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

va:add synchornization fence for HW execution #810

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 27 additions & 1 deletion va/va.c
Original file line number Diff line number Diff line change
Expand Up @@ -1643,7 +1643,7 @@ VAStatus vaEndPicture(
ctx = CTX(dpy);

VA_TRACE_V(dpy, END_PICTURE, TRACE_BEGIN, context);
VA_TRACE_ALL(va_TraceEndPicture, dpy, context, 0);
VA_TRACE_ALL(va_TraceEndPicture, dpy, context, NULL, 0, 0);
va_status = ctx->vtable->vaEndPicture(ctx, context);
VA_TRACE_RET(dpy, va_status);
/* dump surface content */
Expand All @@ -1653,6 +1653,32 @@ VAStatus vaEndPicture(
return va_status;
}

VAStatus vaEndPicture2(
VADisplay dpy,
VAContextID context,
int32_t *sync_fds,
int32_t sync_num

)
{
VAStatus va_status = VA_STATUS_SUCCESS;
VADriverContextP ctx;

CHECK_DISPLAY(dpy);
ctx = CTX(dpy);

VA_TRACE_V(dpy, END_PICTURE, TRACE_BEGIN, context);
VA_TRACE_ALL(va_TraceEndPicture, dpy, context, sync_fds, sync_num, 0);
va_status = ctx->vtable->vaEndPicture2(ctx, context, sync_fds, sync_num);
VA_TRACE_RET(dpy, va_status);
/* dump surface content */
VA_TRACE_ALL(va_TraceEndPictureExt, dpy, context, 1);
VA_TRACE_V(dpy, END_PICTURE, TRACE_END, va_status);

return va_status;
}


VAStatus vaSyncSurface(
VADisplay dpy,
VASurfaceID render_target
Expand Down
18 changes: 18 additions & 0 deletions va/va.h
Original file line number Diff line number Diff line change
Expand Up @@ -4174,6 +4174,24 @@ VAStatus vaEndPicture(
VAContextID context
);

/**
* Same behavior as vaEndPicture except a sync fd list for synchronizations.
* if sync_num = 0 or sync_fds == NULL, the behavior should be same as vaEndPicture.
* if sync_num >= 1, the sync_fds[0] should be the fence out, this fd(or the fence
* behind this fd) will be overridden by this call, and will be signaled to indicate
* current frame finishing. sync_num = 1 means only fence out is needed.
* sync_fds[1] to sync_fds[1 ~ sync_num-1] is fence in, current HW execution
* will be blocked until all these fences are signaled.
* these fence fds is file descriptor of dma_fence.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it possible to call vaEndPicture2() with a fence-out but no fence-in(s)? If so it'd be good to specify it in this function comment (and maybe other expected example use patterns);

*/

VAStatus vaEndPicture2(
VADisplay dpy,
VAContextID context,
int32_t *sync_fds,

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there any advantage in bundling fences out and in vs e.g.

   int32_t *sync_fd_out,     // Out. Can be nullptr.
   int32_t* sync_fds_in,     // In. Can be nullptr.
   int32_t sync_fds_in_num,  // In. Can be 0.

Or something like that?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

both ok to me, but now , it is just a PoC, and the implementation is ready here:
intel/media-driver#1803

in the future:

  1. libva should support both linux and windows, so, we will have some other interfaces to hide the dma fence, unify the syn definition in future.
  2. decouple the fence in and out to too parameters as your mentioned.

int32_t sync_num
);

/**
* Make the end of rendering for a pictures in contexts passed with submission.
* The server should start processing all pending operations for contexts.
Expand Down
10 changes: 9 additions & 1 deletion va/va_backend.h
Original file line number Diff line number Diff line change
Expand Up @@ -511,8 +511,16 @@ struct VADriverVTable {
void **pbuf, /* out */
uint32_t flags /* in */
);

VAStatus(*vaEndPicture2)(
VADriverContextP ctx, /* in */
VAContextID context, /* in */
int32_t *sync_fds,
int32_t sync_num
);

/** \brief Reserved bytes for future use, must be zero */
unsigned long reserved[53];
unsigned long reserved[52];

};

Expand Down
8 changes: 8 additions & 0 deletions va/va_trace.c
Original file line number Diff line number Diff line change
Expand Up @@ -5943,6 +5943,8 @@ void va_TraceRenderPicture(
void va_TraceEndPicture(
VADisplay dpy,
VAContextID context,
int32_t *sync_fds,
int32_t sync_num,
int endpic_done
)
{
Expand All @@ -5952,6 +5954,12 @@ void va_TraceEndPicture(

va_TraceMsg(trace_ctx, "\tcontext = 0x%08x\n", context);
va_TraceMsg(trace_ctx, "\trender_targets = 0x%08x\n", trace_ctx->trace_rendertarget);
if (sync_num && sync_fds) {
va_TraceMsg(trace_ctx, "\t fence out = %d \n", sync_fds[0]);
for (int i = 1; i < sync_num && sync_num > 1; i ++) {
va_TraceMsg(trace_ctx, "\t fence_in index %d = %d \n", i - 1, sync_fds[i]);
}
}
va_TraceMsg(trace_ctx, NULL);
}

Expand Down
2 changes: 2 additions & 0 deletions va/va_trace.h
Original file line number Diff line number Diff line change
Expand Up @@ -377,6 +377,8 @@ DLL_HIDDEN
void va_TraceEndPicture(
VADisplay dpy,
VAContextID context,
int32_t *sync_fds,
int32_t sync_num,
int endpic_done
);

Expand Down