Skip to content

Commit

Permalink
add new interface vaMapBuffer2 for map operation optimization
Browse files Browse the repository at this point in the history
add new vaMapBuffer2
backend driver need some usage hint to optimize the operation

Signed-off-by: Carl Zhang <[email protected]>
  • Loading branch information
XinfengZhang committed Feb 24, 2020
1 parent 8e467a6 commit 353d451
Show file tree
Hide file tree
Showing 3 changed files with 62 additions and 3 deletions.
38 changes: 36 additions & 2 deletions va/va.c
Original file line number Diff line number Diff line change
Expand Up @@ -1432,14 +1432,48 @@ VAStatus vaMapBuffer (
)
{
VADriverContextP ctx;
VAStatus va_status;
VAStatus va_status = VA_STATUS_SUCCESS;

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

VA_FOOL_FUNC(va_FoolMapBuffer, dpy, buf_id, pbuf);
if (ctx->vtable->vaMapBuffer)
{
va_status = ctx->vtable->vaMapBuffer( ctx, buf_id, pbuf );
}
else if (ctx->vtable->vaMapBuffer2)
{
va_status = ctx->vtable->vaMapBuffer2( ctx, buf_id, pbuf,VAMapBufferFlagDefault );
}
VA_TRACE_ALL(va_TraceMapBuffer, dpy, buf_id, pbuf);
VA_TRACE_RET(dpy, va_status);

return va_status;
}

VAStatus vaMapBuffer2 (
VADisplay dpy,
VABufferID buf_id, /* in */
void **pbuf, /* out */
VAMapBufferFlags flags /*in */
)
{
VADriverContextP ctx;
VAStatus va_status = VA_STATUS_SUCCESS;

va_status = ctx->vtable->vaMapBuffer( ctx, buf_id, pbuf );
CHECK_DISPLAY(dpy);
ctx = CTX(dpy);

VA_FOOL_FUNC(va_FoolMapBuffer, dpy, buf_id, pbuf);
if(ctx->vtable->vaMapBuffer2)
{
va_status = ctx->vtable->vaMapBuffer2(ctx, buf_id, pbuf, flags);
}
else if(ctx->vtable->vaMapBuffer)
{
va_status = ctx->vtable->vaMapBuffer(ctx, buf_id, pbuf);
}

VA_TRACE_ALL(va_TraceMapBuffer, dpy, buf_id, pbuf);
VA_TRACE_RET(dpy, va_status);
Expand Down
19 changes: 19 additions & 0 deletions va/va.h
Original file line number Diff line number Diff line change
Expand Up @@ -3437,6 +3437,25 @@ VAStatus vaMapBuffer (
void **pbuf /* out */
);

/**
* Map data store of the buffer into the client's address space
* this interface could be used to convey the operation hint
* backend driver could use these hint to optimize the implementations
*/
typedef enum
{
VAMapBufferFlagDefault = 0,
VAMapBufferFlagRead = 1,
VAMapBufferFlagWrite = 2
} VAMapBufferFlags;

VAStatus vaMapBuffer2 (
VADisplay dpy,
VABufferID buf_id, /* in */
void **pbuf, /* out */
VAMapBufferFlags flags /* in */
);

/**
* After client making changes to a mapped data store, it needs to
* "Unmap" it to let the server know that the data is ready to be
Expand Down
8 changes: 7 additions & 1 deletion va/va_backend.h
Original file line number Diff line number Diff line change
Expand Up @@ -485,8 +485,14 @@ struct VADriverVTable
void *descriptor /* out */
);

VAStatus (*vaMapBuffer2) (
VADriverContextP ctx,
VABufferID buf_id, /* in */
void **pbuf, /* out */
VAMapBufferFlags flags /* in */
);
/** \brief Reserved bytes for future use, must be zero */
unsigned long reserved[57];
unsigned long reserved[56];
};

struct VADriverContext
Expand Down

0 comments on commit 353d451

Please sign in to comment.