From 8f9ec28cead739d752e501a55048f5f5f5f6a542 Mon Sep 17 00:00:00 2001 From: Carl Zhang Date: Mon, 24 Feb 2020 10:56:22 -0500 Subject: [PATCH] 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 --- va/va.c | 35 ++++++++++++++++++++++++++++++++--- va/va.h | 22 ++++++++++++++++++++++ va/va_backend.h | 10 +++++++++- va/va_trace.c | 4 +++- va/va_trace.h | 3 ++- 5 files changed, 68 insertions(+), 6 deletions(-) diff --git a/va/va.c b/va/va.c index 920b76c50..6d6ed1810 100644 --- a/va/va.c +++ b/va/va.c @@ -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; diff --git a/va/va.h b/va/va.h index e0df2b56d..d3a88616e 100644 --- a/va/va.h +++ b/va/va.h @@ -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 +/** \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 diff --git a/va/va_backend.h b/va/va_backend.h index 51e80d058..d62e4ce75 100644 --- a/va/va_backend.h +++ b/va/va_backend.h @@ -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 { diff --git a/va/va_trace.c b/va/va_trace.c index 7d281db18..a273bf051 100644 --- a/va/va_trace.c +++ b/va/va_trace.c @@ -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; @@ -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; diff --git a/va/va_trace.h b/va/va_trace.h index aeb1884a9..8b0b5a4cd 100644 --- a/va/va_trace.h +++ b/va/va_trace.h @@ -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 */ );