Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add new interface vaMapBuffer2 for map operation optimization #377

Merged
merged 1 commit into from
Oct 10, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -3894,6 +3894,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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@dvrogozh , @XinfengZhang , can we do drop VA_MAPBUFFER_FLAG_DEFAULT because VA_MAPBUFFER_FLAG_DEFAULT in fact == VA_MAPBUFFER_FLAG_READ | VA_MAPBUFFER_FLAG_WRITE

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that having explicitly said what's the behavior in case of naive default value (=0) is good. I would leave DEFAULT declared.

/** \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