Skip to content

Commit f580a1d

Browse files
committed
va:add synchornization fence for HW execution
add fence in and fence out for vaEndPicture which is using to submit command buffer fence out will be signaled after HW execution, fence in is the dependencies Signed-off-by: Carl Zhang <carl.zhang@intel.com>
1 parent 1b7d71f commit f580a1d

File tree

5 files changed

+64
-2
lines changed

5 files changed

+64
-2
lines changed

va/va.c

+27-1
Original file line numberDiff line numberDiff line change
@@ -1643,7 +1643,7 @@ VAStatus vaEndPicture(
16431643
ctx = CTX(dpy);
16441644

16451645
VA_TRACE_V(dpy, END_PICTURE, TRACE_BEGIN, context);
1646-
VA_TRACE_ALL(va_TraceEndPicture, dpy, context, 0);
1646+
VA_TRACE_ALL(va_TraceEndPicture, dpy, context, NULL, 0, 0);
16471647
va_status = ctx->vtable->vaEndPicture(ctx, context);
16481648
VA_TRACE_RET(dpy, va_status);
16491649
/* dump surface content */
@@ -1653,6 +1653,32 @@ VAStatus vaEndPicture(
16531653
return va_status;
16541654
}
16551655

1656+
VAStatus vaEndPicture2(
1657+
VADisplay dpy,
1658+
VAContextID context,
1659+
int32_t *sync_fds,
1660+
int32_t sync_num
1661+
1662+
)
1663+
{
1664+
VAStatus va_status = VA_STATUS_SUCCESS;
1665+
VADriverContextP ctx;
1666+
1667+
CHECK_DISPLAY(dpy);
1668+
ctx = CTX(dpy);
1669+
1670+
VA_TRACE_V(dpy, END_PICTURE, TRACE_BEGIN, context);
1671+
VA_TRACE_ALL(va_TraceEndPicture, dpy, context, sync_fds, sync_num, 0);
1672+
va_status = ctx->vtable->vaEndPicture2(ctx, context, sync_fds, sync_num);
1673+
VA_TRACE_RET(dpy, va_status);
1674+
/* dump surface content */
1675+
VA_TRACE_ALL(va_TraceEndPictureExt, dpy, context, 1);
1676+
VA_TRACE_V(dpy, END_PICTURE, TRACE_END, va_status);
1677+
1678+
return va_status;
1679+
}
1680+
1681+
16561682
VAStatus vaSyncSurface(
16571683
VADisplay dpy,
16581684
VASurfaceID render_target

va/va.h

+18
Original file line numberDiff line numberDiff line change
@@ -4174,6 +4174,24 @@ VAStatus vaEndPicture(
41744174
VAContextID context
41754175
);
41764176

4177+
/**
4178+
* Same behavior with vaEndPicture except a sync fd list for synchronizations.
4179+
* if sync_num = 0 or sync_fds == NULL, the behavior should be same with vaEndPicture.
4180+
* if sync_num >= 1, the sync_fds[0] should be the fence out, this fd(or the fence
4181+
* behind this fd) will be overridden by this call, and will be signaled to indicate
4182+
* current frame finishing.
4183+
* sync_fds[1] to sync_fds[1 ~ sync_num-1] is fence in, current HW execution
4184+
* will be blocked until all these fences are signaled.
4185+
* these fence fds is file descriptor of dma_fence.
4186+
*/
4187+
4188+
VAStatus vaEndPicture2(
4189+
VADisplay dpy,
4190+
VAContextID context,
4191+
int32_t *sync_fds,
4192+
int32_t sync_num
4193+
);
4194+
41774195
/**
41784196
* Make the end of rendering for a pictures in contexts passed with submission.
41794197
* The server should start processing all pending operations for contexts.

va/va_backend.h

+9-1
Original file line numberDiff line numberDiff line change
@@ -511,8 +511,16 @@ struct VADriverVTable {
511511
void **pbuf, /* out */
512512
uint32_t flags /* in */
513513
);
514+
515+
VAStatus(*vaEndPicture2)(
516+
VADriverContextP ctx, /* in */
517+
VAContextID context, /* in */
518+
int32_t *sync_fds,
519+
int32_t sync_num
520+
);
521+
514522
/** \brief Reserved bytes for future use, must be zero */
515-
unsigned long reserved[53];
523+
unsigned long reserved[52];
516524

517525
};
518526

va/va_trace.c

+8
Original file line numberDiff line numberDiff line change
@@ -5943,6 +5943,8 @@ void va_TraceRenderPicture(
59435943
void va_TraceEndPicture(
59445944
VADisplay dpy,
59455945
VAContextID context,
5946+
int32_t *sync_fds,
5947+
int32_t sync_num,
59465948
int endpic_done
59475949
)
59485950
{
@@ -5952,6 +5954,12 @@ void va_TraceEndPicture(
59525954

59535955
va_TraceMsg(trace_ctx, "\tcontext = 0x%08x\n", context);
59545956
va_TraceMsg(trace_ctx, "\trender_targets = 0x%08x\n", trace_ctx->trace_rendertarget);
5957+
if (sync_num && sync_fds) {
5958+
va_TraceMsg(trace_ctx, "\t fence out = %d \n", sync_fds[0]);
5959+
for (int i = 1; i < sync_num && sync_num > 1; i ++) {
5960+
va_TraceMsg(trace_ctx, "\t fence_in index %d = %d \n", i - 1, sync_fds[i]);
5961+
}
5962+
}
59555963
va_TraceMsg(trace_ctx, NULL);
59565964
}
59575965

va/va_trace.h

+2
Original file line numberDiff line numberDiff line change
@@ -377,6 +377,8 @@ DLL_HIDDEN
377377
void va_TraceEndPicture(
378378
VADisplay dpy,
379379
VAContextID context,
380+
int32_t *sync_fds,
381+
int32_t sync_num,
380382
int endpic_done
381383
);
382384

0 commit comments

Comments
 (0)