Skip to content

Commit

Permalink
va: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 Oct 9, 2023
1 parent 8575b2b commit 15f6459
Show file tree
Hide file tree
Showing 5 changed files with 68 additions and 6 deletions.
35 changes: 32 additions & 3 deletions va/va.c
Original file line number Diff line number Diff line change
Expand Up @@ -1430,14 +1430,43 @@ VAStatus vaMapBuffer(
)
{
VADriverContextP ctx;
VAStatus va_status;
VAStatus va_status = VA_STATUS_SUCCESS;

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

if (ctx->vtable->vaMapBuffer2) {
va_status = ctx->vtable->vaMapBuffer2(ctx, buf_id, pbuf, VA_MAPBUFFER_FLAG_DEFAULT);
} else if (ctx->vtable->vaMapBuffer) {
va_status = ctx->vtable->vaMapBuffer(ctx, buf_id, pbuf);
}

VA_TRACE_ALL(va_TraceMapBuffer, dpy, buf_id, pbuf, VA_MAPBUFFER_FLAG_DEFAULT);
VA_TRACE_RET(dpy, va_status);

return va_status;
}

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

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

va_status = ctx->vtable->vaMapBuffer(ctx, 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_ALL(va_TraceMapBuffer, dpy, buf_id, pbuf, flags);
VA_TRACE_RET(dpy, va_status);

return va_status;
Expand Down
22 changes: 22 additions & 0 deletions va/va.h
Original file line number Diff line number Diff line change
Expand Up @@ -3880,6 +3880,28 @@ 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
*/

/** \brief VA_MAPBUFFER_FLAG_DEFAULT is used when there are no flag specified
* same as VA_MAPBUFFER_FLAG_READ | VA_MAPBUFFER_FLAG_WRITE.
*/
#define VA_MAPBUFFER_FLAG_DEFAULT 0
/** \brief application will read the surface after map */
#define VA_MAPBUFFER_FLAG_READ 1
/** \brief application will write the surface after map */
#define VA_MAPBUFFER_FLAG_WRITE 2

VAStatus vaMapBuffer2(
VADisplay dpy,
VABufferID buf_id, /* in */
void **pbuf, /* out */
uint32_t 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
10 changes: 9 additions & 1 deletion va/va_backend.h
Original file line number Diff line number Diff line change
Expand Up @@ -504,8 +504,16 @@ struct VADriverVTable {
VACopyObject *src, /* in */
VACopyOption option /* in */
);

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

};

struct VADriverContext {
Expand Down
4 changes: 3 additions & 1 deletion va/va_trace.c
Original file line number Diff line number Diff line change
Expand Up @@ -1740,7 +1740,8 @@ static void va_TraceCodedBufferIVFHeader(struct trace_context *trace_ctx, void *
void va_TraceMapBuffer(
VADisplay dpy,
VABufferID buf_id, /* in */
void **pbuf /* out */
void **pbuf, /* out */
uint32_t flags /* in */
)
{
VABufferType type;
Expand All @@ -1761,6 +1762,7 @@ void va_TraceMapBuffer(
TRACE_FUNCNAME(idx);
va_TraceMsg(trace_ctx, "\tbuf_id=0x%x\n", buf_id);
va_TraceMsg(trace_ctx, "\tbuf_type=%s\n", vaBufferTypeStr(type));
va_TraceMsg(trace_ctx, "\tflags = 0x%x\n", flags);
if ((pbuf == NULL) || (*pbuf == NULL))
return;

Expand Down
3 changes: 2 additions & 1 deletion va/va_trace.h
Original file line number Diff line number Diff line change
Expand Up @@ -353,7 +353,8 @@ DLL_HIDDEN
void va_TraceMapBuffer(
VADisplay dpy,
VABufferID buf_id, /* in */
void **pbuf /* out */
void **pbuf, /* out */
uint32_t flags /* in */
);


Expand Down

0 comments on commit 15f6459

Please sign in to comment.