Skip to content

Commit 45afd79

Browse files
XinfengZhangdvrogozh
authored andcommitted
va:add new interface vaMapBuffer2 for map operation optimization
add new vaMapBuffer2 backend driver need some usage hint to optimize the operation Signed-off-by: Carl Zhang <carl.zhang@intel.com>
1 parent 71ef7e0 commit 45afd79

File tree

5 files changed

+68
-6
lines changed

5 files changed

+68
-6
lines changed

va/va.c

Lines changed: 32 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1430,14 +1430,43 @@ VAStatus vaMapBuffer(
14301430
)
14311431
{
14321432
VADriverContextP ctx;
1433-
VAStatus va_status;
1433+
VAStatus va_status = VA_STATUS_SUCCESS;
1434+
1435+
CHECK_DISPLAY(dpy);
1436+
ctx = CTX(dpy);
1437+
1438+
if (ctx->vtable->vaMapBuffer2) {
1439+
va_status = ctx->vtable->vaMapBuffer2(ctx, buf_id, pbuf, VA_MAPBUFFER_FLAG_DEFAULT);
1440+
} else if (ctx->vtable->vaMapBuffer) {
1441+
va_status = ctx->vtable->vaMapBuffer(ctx, buf_id, pbuf);
1442+
}
1443+
1444+
VA_TRACE_ALL(va_TraceMapBuffer, dpy, buf_id, pbuf, VA_MAPBUFFER_FLAG_DEFAULT);
1445+
VA_TRACE_RET(dpy, va_status);
1446+
1447+
return va_status;
1448+
}
1449+
1450+
VAStatus vaMapBuffer2(
1451+
VADisplay dpy,
1452+
VABufferID buf_id, /* in */
1453+
void **pbuf, /* out */
1454+
uint32_t flags /*in */
1455+
)
1456+
{
1457+
VADriverContextP ctx;
1458+
VAStatus va_status = VA_STATUS_SUCCESS;
14341459

14351460
CHECK_DISPLAY(dpy);
14361461
ctx = CTX(dpy);
14371462

1438-
va_status = ctx->vtable->vaMapBuffer(ctx, buf_id, pbuf);
1463+
if (ctx->vtable->vaMapBuffer2) {
1464+
va_status = ctx->vtable->vaMapBuffer2(ctx, buf_id, pbuf, flags);
1465+
} else if (ctx->vtable->vaMapBuffer) {
1466+
va_status = ctx->vtable->vaMapBuffer(ctx, buf_id, pbuf);
1467+
}
14391468

1440-
VA_TRACE_ALL(va_TraceMapBuffer, dpy, buf_id, pbuf);
1469+
VA_TRACE_ALL(va_TraceMapBuffer, dpy, buf_id, pbuf, flags);
14411470
VA_TRACE_RET(dpy, va_status);
14421471

14431472
return va_status;

va/va.h

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3894,6 +3894,28 @@ VAStatus vaMapBuffer(
38943894
void **pbuf /* out */
38953895
);
38963896

3897+
/**
3898+
* Map data store of the buffer into the client's address space
3899+
* this interface could be used to convey the operation hint
3900+
* backend driver could use these hint to optimize the implementations
3901+
*/
3902+
3903+
/** \brief VA_MAPBUFFER_FLAG_DEFAULT is used when there are no flag specified
3904+
* same as VA_MAPBUFFER_FLAG_READ | VA_MAPBUFFER_FLAG_WRITE.
3905+
*/
3906+
#define VA_MAPBUFFER_FLAG_DEFAULT 0
3907+
/** \brief application will read the surface after map */
3908+
#define VA_MAPBUFFER_FLAG_READ 1
3909+
/** \brief application will write the surface after map */
3910+
#define VA_MAPBUFFER_FLAG_WRITE 2
3911+
3912+
VAStatus vaMapBuffer2(
3913+
VADisplay dpy,
3914+
VABufferID buf_id, /* in */
3915+
void **pbuf, /* out */
3916+
uint32_t flags /* in */
3917+
);
3918+
38973919
/**
38983920
* After client making changes to a mapped data store, it needs to
38993921
* "Unmap" it to let the server know that the data is ready to be

va/va_backend.h

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -504,8 +504,16 @@ struct VADriverVTable {
504504
VACopyObject *src, /* in */
505505
VACopyOption option /* in */
506506
);
507+
508+
VAStatus(*vaMapBuffer2)(
509+
VADriverContextP ctx,
510+
VABufferID buf_id, /* in */
511+
void **pbuf, /* out */
512+
uint32_t flags /* in */
513+
);
507514
/** \brief Reserved bytes for future use, must be zero */
508-
unsigned long reserved[54];
515+
unsigned long reserved[53];
516+
509517
};
510518

511519
struct VADriverContext {

va/va_trace.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1740,7 +1740,8 @@ static void va_TraceCodedBufferIVFHeader(struct trace_context *trace_ctx, void *
17401740
void va_TraceMapBuffer(
17411741
VADisplay dpy,
17421742
VABufferID buf_id, /* in */
1743-
void **pbuf /* out */
1743+
void **pbuf, /* out */
1744+
uint32_t flags /* in */
17441745
)
17451746
{
17461747
VABufferType type;
@@ -1761,6 +1762,7 @@ void va_TraceMapBuffer(
17611762
TRACE_FUNCNAME(idx);
17621763
va_TraceMsg(trace_ctx, "\tbuf_id=0x%x\n", buf_id);
17631764
va_TraceMsg(trace_ctx, "\tbuf_type=%s\n", vaBufferTypeStr(type));
1765+
va_TraceMsg(trace_ctx, "\tflags = 0x%x\n", flags);
17641766
if ((pbuf == NULL) || (*pbuf == NULL))
17651767
return;
17661768

va/va_trace.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -353,7 +353,8 @@ DLL_HIDDEN
353353
void va_TraceMapBuffer(
354354
VADisplay dpy,
355355
VABufferID buf_id, /* in */
356-
void **pbuf /* out */
356+
void **pbuf, /* out */
357+
uint32_t flags /* in */
357358
);
358359

359360

0 commit comments

Comments
 (0)