summaryrefslogtreecommitdiff
path: root/va
diff options
context:
space:
mode:
authorXiang, Haihao <haihao.xiang@intel.com>2011-12-01 15:29:18 +0800
committerXiang, Haihao <haihao.xiang@intel.com>2011-12-14 08:27:03 +0800
commit7b663dcd2558d98153c50e734bafe9fee46e509e (patch)
treeedb1dd4e1d61c87fe215b30c48c77316a63c8877 /va
parente8dc39b5e36ff7f936c8f564d03fed531fd75eba (diff)
Update the VA/EGL implementation in VAAPI
Signed-off-by: Xiang, Haihao <haihao.xiang@intel.com>
Diffstat (limited to 'va')
-rw-r--r--va/egl/va_backend_egl.h27
-rw-r--r--va/egl/va_egl.c80
-rw-r--r--va/egl/va_egl_impl.c347
-rw-r--r--va/egl/va_egl_private.h35
4 files changed, 268 insertions, 221 deletions
diff --git a/va/egl/va_backend_egl.h b/va/egl/va_backend_egl.h
index 9dae84f..7307b2e 100644
--- a/va/egl/va_backend_egl.h
+++ b/va/egl/va_backend_egl.h
@@ -35,15 +35,23 @@ struct VADriverVTableEGL {
VASurfaceID surface,
void **buffer
);
+
/* TBD: more APIs for EGL */
- /* Optional: create a surface used for display to OpenGL */
+ int max_egl_surface_targets;
+ int max_egl_surface_attributes;
+
+ VAStatus (*vaQuerySurfaceTargetsEGL)(
+ VADriverContextP ctx,
+ EGLenum *target_list, /* out */
+ int *num_targets /* out */
+ );
+
VAStatus (*vaCreateSurfaceEGL)(
VADriverContextP ctx,
- GLenum target,
- GLuint texture,
+ EGLenum target,
unsigned int width,
unsigned int height,
- VASurfaceEGL *egl_surface
+ VASurfaceEGL *gl_surface
);
/* Optional: destroy a VA/EGL surface */
@@ -59,11 +67,20 @@ struct VADriverVTableEGL {
unsigned int flags
);
- VAStatus (*vaUpdateAssociatedSurfaceEGL)(
+ VAStatus (*vaSyncSurfaceEGL)(
VADriverContextP ctx,
VASurfaceEGL egl_surface
);
+ VAStatus (*vaGetSurfaceInfoEGL)(
+ VADisplay dpy,
+ VASurfaceEGL egl_surface,
+ EGLenum *target,
+ EGLClientBuffer *buffer,
+ EGLint *attrib_list,
+ int *num_attribs
+ );
+
VAStatus (*vaDeassociateSurfaceEGL)(
VADriverContextP ctx,
VASurfaceEGL egl_surface
diff --git a/va/egl/va_egl.c b/va/egl/va_egl.c
index 6caf4f8..2c6c2b4 100644
--- a/va/egl/va_egl.c
+++ b/va/egl/va_egl.c
@@ -169,11 +169,58 @@ error:
return NULL;
}
-// Create a surface used for display to OpenGL
+int vaMaxNumSurfaceTargetsEGL(
+ VADisplay dpy
+)
+{
+ VADriverContextP ctx;
+ struct VADriverVTableEGL *va_egl;
+ CHECK_DISPLAY(dpy);
+ ctx = CTX(dpy);
+
+ va_egl = (struct VADriverVTableEGL *)ctx->vtable_egl;
+
+ if (va_egl)
+ return va_egl->max_egl_surface_targets;
+ else
+ return 2;
+}
+
+int vaMaxNumSurfaceAttributesEGL(
+ VADisplay dpy
+)
+{
+ VADriverContextP ctx;
+ struct VADriverVTableEGL *va_egl;
+ CHECK_DISPLAY(dpy);
+ ctx = CTX(dpy);
+
+ va_egl = (struct VADriverVTableEGL *)ctx->vtable_egl;
+
+ if (va_egl)
+ return va_egl->max_egl_surface_attributes;
+ else
+ return 2;
+}
+
+VAStatus vaQuerySurfaceTargetsEGL(
+ VADisplay dpy,
+ EGLenum *target_list, /* out */
+ int *num_targets /* out */
+)
+{
+ VADriverContextP ctx;
+ VAStatus status;
+
+ INIT_CONTEXT(ctx, dpy);
+
+ INVOKE(ctx, QuerySurfaceTargets, (dpy, target_list, num_targets));
+ return status;
+}
+
VAStatus vaCreateSurfaceEGL(
VADisplay dpy,
- GLenum target,
- GLuint texture,
+ EGLenum target,
unsigned int width,
unsigned int height,
VASurfaceEGL *gl_surface
@@ -182,12 +229,9 @@ VAStatus vaCreateSurfaceEGL(
VADriverContextP ctx;
VAStatus status;
- if (target != GL_TEXTURE_2D)
- return VA_STATUS_ERROR_INVALID_PARAMETER;
-
INIT_CONTEXT(ctx, dpy);
- INVOKE(ctx, CreateSurface, (dpy, target, texture, width, height, gl_surface));
+ INVOKE(ctx, CreateSurface, (dpy, target, width, height, gl_surface));
return status;
}
@@ -222,7 +266,7 @@ VAStatus vaAssociateSurfaceEGL(
return status;
}
-VAStatus vaUpdateAssociatedSurfaceEGL(
+VAStatus vaSyncSurfaceEGL(
VADisplay dpy,
VASurfaceEGL egl_surface
)
@@ -232,7 +276,25 @@ VAStatus vaUpdateAssociatedSurfaceEGL(
INIT_CONTEXT(ctx, dpy);
- INVOKE(ctx, UpdateAssociatedSurface, (dpy, egl_surface));
+ INVOKE(ctx, SyncSurface, (dpy, egl_surface));
+ return status;
+}
+
+VAStatus vaGetSurfaceInfoEGL(
+ VADisplay dpy,
+ VASurfaceEGL egl_surface,
+ EGLenum *target, /* out, the type of <buffer> */
+ EGLClientBuffer *buffer, /* out */
+ EGLint *attrib_list, /* out, the last attribute must be EGL_NONE */
+ int *num_attribs /* in/out */
+)
+{
+ VADriverContextP ctx;
+ VAStatus status;
+
+ INIT_CONTEXT(ctx, dpy);
+
+ INVOKE(ctx, GetSurfaceInfo, (dpy, egl_surface, target, buffer, attrib_list, num_attribs));
return status;
}
diff --git a/va/egl/va_egl_impl.c b/va/egl/va_egl_impl.c
index b47d266..2aa2bbe 100644
--- a/va/egl/va_egl_impl.c
+++ b/va/egl/va_egl_impl.c
@@ -9,49 +9,6 @@
#include "va_egl_private.h"
#include "va_egl_impl.h"
-// Returns the OpenGL ES VTable
-static inline VAOpenGLESVTableP
-gles_get_vtable(VADriverContextP ctx)
-{
- return &VA_DRIVER_CONTEXT_EGL(ctx)->gles_vtable;
-}
-
-// Lookup for a EGL function
-typedef void (*EGLFuncPtr)(void);
-typedef EGLFuncPtr (*EGLGetProcAddressProc)(const char *);
-
-static EGLFuncPtr
-get_proc_address_default(const char *name)
-{
- return NULL;
-}
-
-static EGLGetProcAddressProc
-get_proc_address_func(void)
-{
- EGLGetProcAddressProc get_proc_func;
-
- dlerror();
- get_proc_func = (EGLGetProcAddressProc)
- dlsym(RTLD_DEFAULT, "eglGetProcAddress");
-
- if (!dlerror())
- return get_proc_func;
-
- return get_proc_address_default;
-}
-
-static inline EGLFuncPtr
-get_proc_address(const char *name)
-{
- static EGLGetProcAddressProc get_proc_func = NULL;
-
- get_proc_func = get_proc_address_func();
-
- return get_proc_func(name);
-}
-
-// Check for GLES extensions (TFP, FBO)
static int
check_extension(const char *name, const char *exts)
{
@@ -77,7 +34,7 @@ check_extension(const char *name, const char *exts)
}
static int
-check_extensions(VADriverContextP ctx, EGLDisplay egl_display)
+check_pixmap_extensions(VADriverContextP ctx, EGLDisplay egl_display)
{
const char *exts;
@@ -86,34 +43,6 @@ check_extensions(VADriverContextP ctx, EGLDisplay egl_display)
if (!check_extension("EGL_KHR_image_pixmap", exts))
return 0;
- exts = (const char *)glGetString(GL_EXTENSIONS);
-
- if (!check_extension("GL_OES_EGL_image", exts))
- return 0;
-
-#if 0
- if (!check_extension("GL_OES_texture_npot", exts))
- return 0;
-#endif
-
- return 1;
-}
-
-static int
-init_extensions(VADriverContextP ctx)
-{
- VAOpenGLESVTableP pOpenGLESVTable = gles_get_vtable(ctx);
-
- /* EGL_KHR_image_pixmap */
- pOpenGLESVTable->egl_create_image_khr =
- (PFNEGLCREATEIMAGEKHRPROC)get_proc_address("eglCreateImageKHR");
- pOpenGLESVTable->egl_destroy_image_khr =
- (PFNEGLDESTROYIMAGEKHRPROC)get_proc_address("eglDestroyImageKHR");
-
- /* GL_OES_EGL_image */
- pOpenGLESVTable->gles_egl_image_target_texture_2d =
- (PFNGLEGLIMAGETARGETTEXTURE2DOESPROC)get_proc_address("glEGLImageTargetTexture2DOES");
-
return 1;
}
@@ -134,16 +63,30 @@ init_extensions(VADriverContextP ctx)
return status; \
} while (0)
+
static VAStatus
+vaQuerySurfaceTargetsEGL_impl_driver(VADisplay dpy,
+ EGLenum *target_list,
+ int *num_targets)
+{
+ VADriverContextP ctx = ((VADisplayContextP)(dpy))->pDriverContext;
+
+ INVOKE(ctx, QuerySurfaceTargets, (ctx, target_list, num_targets));
+
+ return VA_STATUS_SUCCESS;
+}
+
+static VAStatus
vaCreateSurfaceEGL_impl_driver(VADisplay dpy,
- GLenum target,
- GLuint texture,
+ EGLenum target,
unsigned int width,
unsigned int height,
- VASurfaceEGL *egl_surface)
+ VASurfaceEGL *gl_surface)
{
VADriverContextP ctx = ((VADisplayContextP)(dpy))->pDriverContext;
- INVOKE(ctx, CreateSurface, (ctx, target, texture, width, height, egl_surface));
+
+ INVOKE(ctx, CreateSurface, (ctx, target, width, height, gl_surface));
+
return VA_STATUS_SUCCESS;
}
@@ -151,7 +94,9 @@ static VAStatus
vaDestroySurfaceEGL_impl_driver(VADisplay dpy, VASurfaceEGL egl_surface)
{
VADriverContextP ctx = ((VADisplayContextP)(dpy))->pDriverContext;
+
INVOKE(ctx, DestroySurface, (ctx, egl_surface));
+
return VA_STATUS_SUCCESS;
}
@@ -162,17 +107,34 @@ vaAssociateSurfaceEGL_impl_driver(VADisplay dpy,
unsigned int flags)
{
VADriverContextP ctx = ((VADisplayContextP)(dpy))->pDriverContext;
+
INVOKE(ctx, AssociateSurface, (ctx, egl_surface, surface, flags));
return VA_STATUS_SUCCESS;
}
static VAStatus
-vaUpdateAssociatedSurfaceEGL_impl_driver(VADisplay dpy,
- VASurfaceEGL egl_surface)
+vaSyncSurfaceEGL_impl_driver(VADisplay dpy,
+ VASurfaceEGL egl_surface)
+{
+ VADriverContextP ctx = ((VADisplayContextP)(dpy))->pDriverContext;
+
+ INVOKE(ctx, SyncSurface, (ctx, egl_surface));
+
+ return VA_STATUS_SUCCESS;
+}
+
+static VAStatus
+vaGetSurfaceInfoEGL_impl_driver(VADisplay dpy,
+ VASurfaceEGL egl_surface,
+ EGLenum *target,
+ EGLClientBuffer *buffer,
+ EGLint *attrib_list,
+ int *num_attribs)
{
VADriverContextP ctx = ((VADisplayContextP)(dpy))->pDriverContext;
- INVOKE(ctx, UpdateAssociatedSurface, (ctx, egl_surface));
+
+ INVOKE(ctx, GetSurfaceInfo, (ctx, egl_surface, target, buffer, attrib_list, num_attribs));
return VA_STATUS_SUCCESS;
}
@@ -182,6 +144,7 @@ vaDeassociateSurfaceEGL_impl_driver(VADisplay dpy,
VASurfaceEGL egl_surface)
{
VADriverContextP ctx = ((VADisplayContextP)(dpy))->pDriverContext;
+
INVOKE(ctx, DeassociateSurface, (ctx, egl_surface));
return VA_STATUS_SUCCESS;
@@ -193,17 +156,15 @@ vaDeassociateSurfaceEGL_impl_driver(VADisplay dpy,
/* === VA/EGL helpers === */
/* ========================================================================= */
/** Unique VASurfaceImplEGL identifier */
-#define VA_SURFACE_IMPL_EGL_MAGIC VA_FOURCC('V','I','E','L')
+#define VA_SURFACE_IMPL_EGL_MAGIC VA_FOURCC('V','E','G','L')
struct VASurfaceImplEGL {
uint32_t magic; ///< Magic number identifying a VASurfaceImplEGL
VASurfaceID surface; ///< Associated VA surface
- GLenum target; ///< GL target to which the texture is bound
- GLuint texture; ///< GL texture
+ EGLenum target; ///< EGL target
+ EGLClientBuffer buffer;
unsigned int width;
unsigned int height;
- void *pixmap;
- EGLImageKHR img_khr;
unsigned int flags;
};
@@ -230,82 +191,6 @@ destroy_native_pixmap(VADisplay dpy, void *native_pixmap)
pDisplayContext->vaFreeNativePixmap(pDisplayContext, native_pixmap);
}
-// Destroy VA/EGL surface
-static void
-destroy_surface(VADisplay dpy, VASurfaceImplEGLP pSurfaceImplEGL)
-{
- VADriverContextP ctx = ((VADisplayContextP)(dpy))->pDriverContext;
- VADriverContextEGLP egl_ctx = VA_DRIVER_CONTEXT_EGL(ctx);
- VAOpenGLESVTableP const pOpenGLESVTable = gles_get_vtable(ctx);
-
- if (pSurfaceImplEGL->img_khr) {
- pOpenGLESVTable->egl_destroy_image_khr(egl_ctx->egl_display,
- pSurfaceImplEGL->img_khr);
- pSurfaceImplEGL->img_khr = EGL_NO_IMAGE_KHR;
- }
-
- if (pSurfaceImplEGL->pixmap) {
- destroy_native_pixmap(dpy, pSurfaceImplEGL->pixmap);
- pSurfaceImplEGL->pixmap = 0;
- }
-
- free(pSurfaceImplEGL);
-}
-
-// Create VA/EGL surface
-static VASurfaceImplEGLP
-create_surface(VADisplay dpy,
- GLenum target,
- GLuint texture,
- unsigned int width,
- unsigned int height)
-{
- VADriverContextP ctx = ((VADisplayContextP)(dpy))->pDriverContext;
- VADriverContextEGLP egl_ctx = VA_DRIVER_CONTEXT_EGL(ctx);
- VAOpenGLESVTableP const pOpenGLESVTable = gles_get_vtable(ctx);
- VASurfaceImplEGLP pSurfaceImplEGL = NULL;
- int is_error = 1;
- const EGLint img_attribs[] = {
- EGL_IMAGE_PRESERVED_KHR, EGL_TRUE,
- EGL_NONE
- };
-
- pSurfaceImplEGL = calloc(1, sizeof(*pSurfaceImplEGL));
-
- if (!pSurfaceImplEGL)
- goto end;
-
- pSurfaceImplEGL->magic = VA_SURFACE_IMPL_EGL_MAGIC;
- pSurfaceImplEGL->surface = VA_INVALID_SURFACE;
- pSurfaceImplEGL->target = target;
- pSurfaceImplEGL->texture = texture;
- pSurfaceImplEGL->width = width;
- pSurfaceImplEGL->height = height;
- pSurfaceImplEGL->pixmap = create_native_pixmap(dpy, width, height);
-
- if (!pSurfaceImplEGL->pixmap)
- goto end;
-
- pSurfaceImplEGL->img_khr = pOpenGLESVTable->egl_create_image_khr(egl_ctx->egl_display,
- EGL_NO_CONTEXT,
- EGL_NATIVE_PIXMAP_KHR,
- (EGLClientBuffer)pSurfaceImplEGL->pixmap,
- img_attribs);
-
- if (!pSurfaceImplEGL->img_khr)
- goto end;
-
- is_error = 0;
-
-end:
- if (is_error && pSurfaceImplEGL) {
- destroy_surface(dpy, pSurfaceImplEGL);
- pSurfaceImplEGL = NULL;
- }
-
- return pSurfaceImplEGL;
-}
-
// Check VASurfaceImplEGL is valid
static inline int check_surface(VASurfaceImplEGLP pSurfaceImplEGL)
{
@@ -327,7 +212,6 @@ associate_surface(VADriverContextP ctx,
unsigned int flags)
{
VAStatus status;
-
status = deassociate_surface(ctx, pSurfaceImplEGL);
if (status != VA_STATUS_SUCCESS)
@@ -349,9 +233,8 @@ sync_surface(VADriverContextP ctx, VASurfaceImplEGLP pSurfaceImplEGL)
}
static VAStatus
-update_accociated_surface(VADriverContextP ctx, VASurfaceImplEGLP pSurfaceImplEGL)
+sync_associated_surface(VADriverContextP ctx, VASurfaceImplEGLP pSurfaceImplEGL)
{
- VAOpenGLESVTableP pOpenGLESVTable = gles_get_vtable(ctx);
VAStatus status;
status = sync_surface(ctx, pSurfaceImplEGL);
@@ -359,20 +242,21 @@ update_accociated_surface(VADriverContextP ctx, VASurfaceImplEGLP pSurfaceImplEG
if (status != VA_STATUS_SUCCESS)
return status;
+ if (pSurfaceImplEGL->target != EGL_NATIVE_PIXMAP_KHR)
+ return VA_STATUS_ERROR_UNIMPLEMENTED;
+
status = ctx->vtable->vaPutSurface(
ctx,
pSurfaceImplEGL->surface,
- (void *)pSurfaceImplEGL->pixmap,
+ (void *)pSurfaceImplEGL->buffer,
0, 0, pSurfaceImplEGL->width, pSurfaceImplEGL->height,
0, 0, pSurfaceImplEGL->width, pSurfaceImplEGL->height,
NULL, 0,
pSurfaceImplEGL->flags
- );
+ );
if (status == VA_STATUS_SUCCESS) {
eglWaitNative(EGL_CORE_NATIVE_ENGINE);
- pOpenGLESVTable->gles_egl_image_target_texture_2d(pSurfaceImplEGL->target,
- (GLeglImageOES)pSurfaceImplEGL->img_khr);
}
return status;
@@ -392,21 +276,41 @@ update_accociated_surface(VADriverContextP ctx, VASurfaceImplEGLP pSurfaceImplEG
} while (0)
static VAStatus
+vaQuerySurfaceTargetsEGL_impl_libva(VADisplay dpy,
+ EGLenum *target_list,
+ int *num_targets)
+{
+ int i = 0;
+
+ target_list[i++] = EGL_NATIVE_PIXMAP_KHR;
+ *num_targets = i;
+
+ return VA_STATUS_SUCCESS;
+}
+
+static VAStatus
vaCreateSurfaceEGL_impl_libva(VADisplay dpy,
- GLenum target,
- GLuint texture,
+ EGLenum target,
unsigned int width,
unsigned int height,
VASurfaceEGL *egl_surface)
{
- VASurfaceEGL pSurfaceEGL;
+ VASurfaceImplEGLP pSurfaceImplEGL = NULL;
- pSurfaceEGL = create_surface(dpy, target, texture, width, height);
+ pSurfaceImplEGL = calloc(1, sizeof(*pSurfaceImplEGL));
- if (!pSurfaceEGL)
+ if (!pSurfaceImplEGL) {
+ *egl_surface = 0;
return VA_STATUS_ERROR_ALLOCATION_FAILED;
+ }
- *egl_surface = pSurfaceEGL;
+ pSurfaceImplEGL->magic = VA_SURFACE_IMPL_EGL_MAGIC;
+ pSurfaceImplEGL->surface = VA_INVALID_SURFACE;
+ pSurfaceImplEGL->target = target == 0 ? EGL_NATIVE_PIXMAP_KHR : target;
+ pSurfaceImplEGL->buffer = 0;
+ pSurfaceImplEGL->width = width;
+ pSurfaceImplEGL->height = height;
+ *egl_surface = (VASurfaceEGL)pSurfaceImplEGL;
return VA_STATUS_SUCCESS;
}
@@ -418,7 +322,14 @@ vaDestroySurfaceEGL_impl_libva(VADisplay dpy, VASurfaceEGL egl_surface)
INIT_SURFACE(pSurfaceImplEGL, egl_surface);
- destroy_surface(dpy, pSurfaceImplEGL);
+ if (pSurfaceImplEGL->target == EGL_NATIVE_PIXMAP_KHR) {
+ if (pSurfaceImplEGL->buffer) {
+ destroy_native_pixmap(dpy, pSurfaceImplEGL->buffer);
+ pSurfaceImplEGL->buffer = 0;
+ }
+ }
+
+ free(pSurfaceImplEGL);
return VA_STATUS_SUCCESS;
}
@@ -429,7 +340,7 @@ vaAssociateSurfaceEGL_impl_libva(
VASurfaceEGL egl_surface,
VASurfaceID surface,
unsigned int flags
-)
+ )
{
VADriverContextP ctx = ((VADisplayContextP)(dpy))->pDriverContext;
VASurfaceImplEGLP pSurfaceImplEGL;
@@ -437,16 +348,28 @@ vaAssociateSurfaceEGL_impl_libva(
INIT_SURFACE(pSurfaceImplEGL, egl_surface);
- status = associate_surface(ctx, egl_surface, surface, flags);
+ if (surface == VA_INVALID_SURFACE)
+ return VA_STATUS_ERROR_INVALID_SURFACE;
+
+ if (pSurfaceImplEGL->target == EGL_NATIVE_PIXMAP_KHR) {
+ if (pSurfaceImplEGL->buffer)
+ destroy_native_pixmap(dpy, pSurfaceImplEGL->buffer);
- return status;
+ pSurfaceImplEGL->buffer = create_native_pixmap(dpy, pSurfaceImplEGL->width, pSurfaceImplEGL->height);
+ }
+
+ pSurfaceImplEGL->surface = surface;
+ pSurfaceImplEGL->flags = flags;
+
+ if (pSurfaceImplEGL->buffer)
+ return VA_STATUS_SUCCESS;
+
+ return VA_STATUS_ERROR_UNKNOWN;
}
static VAStatus
-vaUpdateAssociatedSurfaceEGL_impl_libva(
- VADisplay dpy,
- VASurfaceEGL egl_surface
-)
+vaSyncSurfaceEGL_impl_libva(VADisplay dpy,
+ VASurfaceEGL egl_surface)
{
VADriverContextP ctx = ((VADisplayContextP)(dpy))->pDriverContext;
VASurfaceImplEGLP pSurfaceImplEGL;
@@ -454,16 +377,49 @@ vaUpdateAssociatedSurfaceEGL_impl_libva(
INIT_SURFACE(pSurfaceImplEGL, egl_surface);
- status = update_accociated_surface(ctx, egl_surface);
+ status = sync_associated_surface(ctx, pSurfaceImplEGL);
return status;
}
static VAStatus
+vaGetSurfaceInfoEGL_impl_libva(VADisplay dpy,
+ VASurfaceEGL egl_surface,
+ EGLenum *target,
+ EGLClientBuffer *buffer,
+ EGLint *attrib_list,
+ int *num_attribs)
+{
+ VADriverContextP ctx = ((VADisplayContextP)(dpy))->pDriverContext;
+ VASurfaceImplEGLP pSurfaceImplEGL;
+ VAStatus status;
+ int i = 0;
+
+ INIT_SURFACE(pSurfaceImplEGL, egl_surface);
+
+ if (pSurfaceImplEGL->surface == VA_INVALID_SURFACE)
+ return VA_STATUS_ERROR_INVALID_SURFACE;
+
+ *target = pSurfaceImplEGL->target;
+ *buffer = pSurfaceImplEGL->buffer;
+
+ if (pSurfaceImplEGL->target == EGL_NATIVE_PIXMAP_KHR) {
+ attrib_list[i++] = EGL_IMAGE_PRESERVED_KHR;
+ attrib_list[i++] = EGL_TRUE;
+ attrib_list[i++] = EGL_NONE;
+ } else {
+ /* FIXME later */
+ attrib_list[i++] = EGL_NONE;
+ }
+
+ return VA_STATUS_SUCCESS;
+}
+
+static VAStatus
vaDeassociateSurfaceEGL_impl_libva(
VADisplay dpy,
VASurfaceEGL egl_surface
-)
+ )
{
VADriverContextP ctx = ((VADisplayContextP)(dpy))->pDriverContext;
VASurfaceImplEGLP pSurfaceImplEGL;
@@ -471,9 +427,16 @@ vaDeassociateSurfaceEGL_impl_libva(
INIT_SURFACE(pSurfaceImplEGL, egl_surface);
- status = deassociate_surface(ctx, egl_surface);
+ if (pSurfaceImplEGL->target == EGL_NATIVE_PIXMAP_KHR) {
+ if (pSurfaceImplEGL->buffer)
+ destroy_native_pixmap(dpy, pSurfaceImplEGL->buffer);
- return status;
+ pSurfaceImplEGL->buffer = 0;
+ }
+
+ pSurfaceImplEGL->surface = VA_INVALID_SURFACE;
+
+ return VA_STATUS_SUCCESS;
}
#undef INIT_SURFACE
@@ -494,10 +457,12 @@ VAStatus va_egl_init_context(VADisplay dpy)
return VA_STATUS_SUCCESS;
if (ctx->vtable_egl && ctx->vtable_egl->vaCreateSurfaceEGL) {
+ vtable->vaQuerySurfaceTargetsEGL = vaQuerySurfaceTargetsEGL_impl_driver;
vtable->vaCreateSurfaceEGL = vaCreateSurfaceEGL_impl_driver;
vtable->vaDestroySurfaceEGL = vaDestroySurfaceEGL_impl_driver;
vtable->vaAssociateSurfaceEGL = vaAssociateSurfaceEGL_impl_driver;
- vtable->vaUpdateAssociatedSurfaceEGL = vaUpdateAssociatedSurfaceEGL_impl_driver;
+ vtable->vaSyncSurfaceEGL = vaSyncSurfaceEGL_impl_driver;
+ vtable->vaGetSurfaceInfoEGL = vaGetSurfaceInfoEGL_impl_driver;
vtable->vaDeassociateSurfaceEGL = vaDeassociateSurfaceEGL_impl_driver;
}
else {
@@ -505,14 +470,16 @@ VAStatus va_egl_init_context(VADisplay dpy)
pDisplayContext->vaFreeNativePixmap == NULL)
return VA_STATUS_ERROR_UNIMPLEMENTED;
+ if (!check_pixmap_extensions(ctx, egl_ctx->egl_display))
+ return VA_STATUS_ERROR_UNIMPLEMENTED;
+
+ vtable->vaQuerySurfaceTargetsEGL = vaQuerySurfaceTargetsEGL_impl_libva;
vtable->vaCreateSurfaceEGL = vaCreateSurfaceEGL_impl_libva;
vtable->vaDestroySurfaceEGL = vaDestroySurfaceEGL_impl_libva;
vtable->vaAssociateSurfaceEGL = vaAssociateSurfaceEGL_impl_libva;
- vtable->vaUpdateAssociatedSurfaceEGL = vaUpdateAssociatedSurfaceEGL_impl_libva;
+ vtable->vaSyncSurfaceEGL = vaSyncSurfaceEGL_impl_libva;
+ vtable->vaGetSurfaceInfoEGL = vaGetSurfaceInfoEGL_impl_libva;
vtable->vaDeassociateSurfaceEGL = vaDeassociateSurfaceEGL_impl_libva;
-
- if (!check_extensions(ctx, egl_ctx->egl_display) || !init_extensions(ctx))
- return VA_STATUS_ERROR_UNIMPLEMENTED;
}
egl_ctx->is_initialized = 1;
diff --git a/va/egl/va_egl_private.h b/va/egl/va_egl_private.h
index d0d92fd..5934e36 100644
--- a/va/egl/va_egl_private.h
+++ b/va/egl/va_egl_private.h
@@ -1,23 +1,11 @@
#ifndef _VA_EGL_PRIVATE_H_
#define _VA_EGL_PRIVATE_H_
-#include "sysdeps.h"
#include "va.h"
#include "va_backend.h"
#include "va_egl.h"
#include "va_backend_egl.h"
-typedef struct VAOpenGLESVTable *VAOpenGLESVTableP;
-
-struct VAOpenGLESVTable {
- /* EGL_KHR_image_pixmap */
- PFNEGLCREATEIMAGEKHRPROC egl_create_image_khr;
- PFNEGLDESTROYIMAGEKHRPROC egl_destroy_image_khr;
-
- /* GL_OES_EGL_image */
- PFNGLEGLIMAGETARGETTEXTURE2DOESPROC gles_egl_image_target_texture_2d;
-};
-
typedef struct VADisplayContextEGL *VADisplayContextEGLP;
typedef struct VADriverContextEGL *VADriverContextEGLP;
typedef struct VASurfaceImplEGL *VASurfaceImplEGLP;
@@ -32,13 +20,18 @@ struct VADisplayContextEGL {
#define VA_DRIVER_CONTEXT_EGL(ctx) ((VADriverContextEGLP)((ctx)->egl))
struct VADriverVTablePrivEGL {
+ VAStatus (*vaQuerySurfaceTargetsEGL)(
+ VADisplay dpy,
+ EGLenum *target_list, /* out */
+ int *num_targets /* out */
+ );
+
VAStatus (*vaCreateSurfaceEGL)(
VADisplay dpy,
- GLenum target,
- GLuint texture,
+ EGLenum target,
unsigned int width,
unsigned int height,
- VASurfaceEGL *egl_surface
+ VASurfaceEGL *gl_surface
);
VAStatus (*vaDestroySurfaceEGL)(
@@ -53,11 +46,20 @@ struct VADriverVTablePrivEGL {
unsigned int flags
);
- VAStatus (*vaUpdateAssociatedSurfaceEGL)(
+ VAStatus (*vaSyncSurfaceEGL)(
VADisplay dpy,
VASurfaceEGL egl_surface
);
+ VAStatus (*vaGetSurfaceInfoEGL)(
+ VADisplay dpy,
+ VASurfaceEGL egl_surface,
+ EGLenum *target,
+ EGLClientBuffer *buffer,
+ EGLint *attrib_list,
+ int *num_attribs
+ );
+
VAStatus (*vaDeassociateSurfaceEGL)(
VADisplay dpy,
VASurfaceEGL egl_surface
@@ -66,7 +68,6 @@ struct VADriverVTablePrivEGL {
struct VADriverContextEGL {
struct VADriverVTablePrivEGL vtable;
- struct VAOpenGLESVTable gles_vtable;
unsigned int is_initialized : 1;
EGLDisplay egl_display;
};