diff --git a/va/va.c b/va/va.c index 6d6ed1810..09a3b16ec 100644 --- a/va/va.c +++ b/va/va.c @@ -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 */ @@ -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 diff --git a/va/va.h b/va/va.h index d349704e8..e7384a2db 100644 --- a/va/va.h +++ b/va/va.h @@ -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. + */ + +VAStatus vaEndPicture2( + VADisplay dpy, + VAContextID context, + int32_t *sync_fds, + 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. diff --git a/va/va_backend.h b/va/va_backend.h index d62e4ce75..85f4214ee 100644 --- a/va/va_backend.h +++ b/va/va_backend.h @@ -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]; }; diff --git a/va/va_trace.c b/va/va_trace.c index 365708cff..9459f2acc 100644 --- a/va/va_trace.c +++ b/va/va_trace.c @@ -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 ) { @@ -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); } diff --git a/va/va_trace.h b/va/va_trace.h index 05637afac..b91cd06cf 100644 --- a/va/va_trace.h +++ b/va/va_trace.h @@ -377,6 +377,8 @@ DLL_HIDDEN void va_TraceEndPicture( VADisplay dpy, VAContextID context, + int32_t *sync_fds, + int32_t sync_num, int endpic_done );