summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMarek Olšák <[email protected]>2019-10-17 20:07:32 -0400
committerMarek Olšák <[email protected]>2019-10-25 19:59:04 -0400
commitc1c574fdf18f2aeb1c03f9670bf00e1dcd22d99d (patch)
tree35bc1412bf4df9247b16f6e8660d8aea2d1e751e /src
parent34b1aa957a3f44ea9587ec43311e8434d3782cc1 (diff)
egl: implement new functions from EGL_EXT_image_flush_external
Reviewed-by: Kristian H. Kristensen <[email protected]> Reviewed-By: Tapani Pälli <[email protected]>
Diffstat (limited to 'src')
-rw-r--r--src/egl/drivers/dri2/egl_dri2.c34
-rw-r--r--src/egl/generate/egl.xml12
-rw-r--r--src/egl/generate/eglFunctionList.py2
-rw-r--r--src/egl/main/eglapi.c50
-rw-r--r--src/egl/main/eglapi.h5
-rw-r--r--src/egl/main/egldisplay.h1
-rw-r--r--src/egl/main/eglentrypoint.h2
7 files changed, 106 insertions, 0 deletions
diff --git a/src/egl/drivers/dri2/egl_dri2.c b/src/egl/drivers/dri2/egl_dri2.c
index e9468dcf991..3015ad5ae14 100644
--- a/src/egl/drivers/dri2/egl_dri2.c
+++ b/src/egl/drivers/dri2/egl_dri2.c
@@ -801,6 +801,7 @@ dri2_setup_screen(_EGLDisplay *disp)
}
disp->Extensions.KHR_image_base = EGL_TRUE;
+ disp->Extensions.EXT_image_flush_external = EGL_TRUE;
disp->Extensions.KHR_gl_renderbuffer_image = EGL_TRUE;
if (dri2_dpy->image->base.version >= 5 &&
dri2_dpy->image->createImageFromTexture) {
@@ -3475,6 +3476,37 @@ dri2_interop_export_object(_EGLDisplay *disp, _EGLContext *ctx,
return dri2_dpy->interop->export_object(dri2_ctx->dri_context, in, out);
}
+static void
+dri2_image_flush_external(_EGLDisplay *disp, _EGLContext *ctx,
+ _EGLImage *image)
+{
+ struct dri2_egl_display *dri2_dpy = dri2_egl_display(disp);
+ struct dri2_egl_context *dri2_ctx = dri2_egl_context(ctx);
+ struct dri2_egl_image *dri2_img = dri2_egl_image(image);
+
+ if (dri2_dpy->image->base.version < 18)
+ return;
+
+ dri2_dpy->image->imageFlushExternal(dri2_ctx->dri_context,
+ dri2_img->dri_image, 0);
+}
+
+static void
+dri2_image_invalidate_external(_EGLDisplay *disp, _EGLContext *ctx,
+ _EGLImage *image)
+{
+ struct dri2_egl_display *dri2_dpy = dri2_egl_display(disp);
+ struct dri2_egl_context *dri2_ctx = dri2_egl_context(ctx);
+ struct dri2_egl_image *dri2_img = dri2_egl_image(image);
+
+ if (dri2_dpy->image->base.version < 18)
+ return;
+
+ dri2_dpy->image->imageInvalidateExternal(dri2_ctx->dri_context,
+ dri2_img->dri_image, 0);
+}
+
+
/**
* This is the main entrypoint into the driver, called by libEGL.
* Gets an _EGLDriver object and init its dispatch table.
@@ -3533,4 +3565,6 @@ _eglInitDriver(_EGLDriver *dri2_drv)
dri2_drv->API.GLInteropExportObject = dri2_interop_export_object;
dri2_drv->API.DupNativeFenceFDANDROID = dri2_dup_native_fence_fd;
dri2_drv->API.SetBlobCacheFuncsANDROID = dri2_set_blob_cache_funcs;
+ dri2_drv->API.ImageFlushExternal = dri2_image_flush_external;
+ dri2_drv->API.ImageInvalidateExternal = dri2_image_invalidate_external;
}
diff --git a/src/egl/generate/egl.xml b/src/egl/generate/egl.xml
index 10e34242089..8194c7316c8 100644
--- a/src/egl/generate/egl.xml
+++ b/src/egl/generate/egl.xml
@@ -1795,6 +1795,18 @@
<param><ptype>EGLint</ptype> <name>external_win_id</name></param>
<param><ptype>EGLint</ptype> <name>policy</name></param>
</command>
+ <command>
+ <proto><ptype>EGLBoolean</ptype> <name>eglImageFlushExternalEXT</name></proto>
+ <param><ptype>EGLDisplay</ptype> <name>dpy</name></param>
+ <param><ptype>EGLImageKHR</ptype> <name>image</name></param>
+ <param>const <ptype>EGLAttrib</ptype> *<name>attrib_list</name></param>
+ </command>
+ <command>
+ <proto><ptype>EGLBoolean</ptype> <name>eglImageInvalidateExternalEXT</name></proto>
+ <param><ptype>EGLDisplay</ptype> <name>dpy</name></param>
+ <param><ptype>EGLImageKHR</ptype> <name>image</name></param>
+ <param>const <ptype>EGLAttrib</ptype> *<name>attrib_list</name></param>
+ </command>
</commands>
<!-- SECTION: EGL API interface definitions. -->
diff --git a/src/egl/generate/eglFunctionList.py b/src/egl/generate/eglFunctionList.py
index 192280f58f0..2f533493037 100644
--- a/src/egl/generate/eglFunctionList.py
+++ b/src/egl/generate/eglFunctionList.py
@@ -213,5 +213,7 @@ EGL_FUNCTIONS = (
_eglFunc("eglGetDisplayDriverName", "display"),
_eglFunc("eglGetDisplayDriverConfig", "display"),
+ _eglFunc("eglImageFlushExternalEXT", "display"),
+ _eglFunc("eglImageInvalidateExternalEXT", "display"),
)
diff --git a/src/egl/main/eglapi.c b/src/egl/main/eglapi.c
index 51557be0864..68db0bd4cb9 100644
--- a/src/egl/main/eglapi.c
+++ b/src/egl/main/eglapi.c
@@ -499,6 +499,7 @@ _eglCreateExtensionsString(_EGLDisplay *disp)
_EGL_CHECK_EXTENSION(EXT_create_context_robustness);
_EGL_CHECK_EXTENSION(EXT_image_dma_buf_import);
_EGL_CHECK_EXTENSION(EXT_image_dma_buf_import_modifiers);
+ _EGL_CHECK_EXTENSION(EXT_image_flush_external);
_EGL_CHECK_EXTENSION(EXT_surface_CTA861_3_metadata);
_EGL_CHECK_EXTENSION(EXT_surface_SMPTE2086_metadata);
_EGL_CHECK_EXTENSION(EXT_swap_buffers_with_damage);
@@ -2747,6 +2748,55 @@ eglGetDisplayDriverName(EGLDisplay dpy)
RETURN_EGL_EVAL(disp, ret);
}
+static EGLBoolean EGLAPIENTRY
+eglImageFlushExternalEXT(EGLDisplay dpy, EGLImageKHR image,
+ const EGLAttrib *attrib_list)
+{
+ _EGLDisplay *disp = _eglLockDisplay(dpy);
+ _EGLContext *ctx = _eglGetCurrentContext();
+ _EGLImage *img = _eglLookupImage(image, disp);
+ _EGLDriver *drv;
+
+ _EGL_FUNC_START(disp, EGL_OBJECT_IMAGE_KHR, img, EGL_FALSE);
+ _EGL_CHECK_DISPLAY(disp, EGL_FALSE, drv);
+
+ if (attrib_list && attrib_list[0] != EGL_NONE)
+ RETURN_EGL_ERROR(disp, EGL_BAD_PARAMETER, EGL_FALSE);
+
+ if (!ctx || !disp->Extensions.EXT_image_flush_external)
+ RETURN_EGL_EVAL(disp, EGL_FALSE);
+ if (!img)
+ RETURN_EGL_ERROR(disp, EGL_BAD_PARAMETER, EGL_FALSE);
+
+
+ drv->API.ImageFlushExternal(disp, ctx, img);
+ RETURN_EGL_EVAL(disp, EGL_TRUE);
+}
+
+static EGLBoolean EGLAPIENTRY
+eglImageInvalidateExternalEXT(EGLDisplay dpy, EGLImageKHR image,
+ const EGLAttrib *attrib_list)
+{
+ _EGLDisplay *disp = _eglLockDisplay(dpy);
+ _EGLContext *ctx = _eglGetCurrentContext();
+ _EGLImage *img = _eglLookupImage(image, disp);
+ _EGLDriver *drv;
+
+ _EGL_FUNC_START(disp, EGL_OBJECT_IMAGE_KHR, img, EGL_FALSE);
+ _EGL_CHECK_DISPLAY(disp, EGL_FALSE, drv);
+
+ if (attrib_list && attrib_list[0] != EGL_NONE)
+ RETURN_EGL_ERROR(disp, EGL_BAD_PARAMETER, EGL_FALSE);
+
+ if (!ctx || !disp->Extensions.EXT_image_flush_external)
+ RETURN_EGL_EVAL(disp, EGL_FALSE);
+ if (!img)
+ RETURN_EGL_ERROR(disp, EGL_BAD_PARAMETER, EGL_FALSE);
+
+ drv->API.ImageInvalidateExternal(disp, ctx, img);
+ RETURN_EGL_EVAL(disp, EGL_TRUE);
+}
+
__eglMustCastToProperFunctionPointerType EGLAPIENTRY
eglGetProcAddress(const char *procname)
{
diff --git a/src/egl/main/eglapi.h b/src/egl/main/eglapi.h
index 968f4b27725..76891dcd25b 100644
--- a/src/egl/main/eglapi.h
+++ b/src/egl/main/eglapi.h
@@ -189,6 +189,11 @@ struct _egl_api
void (*SetBlobCacheFuncsANDROID) (_EGLDriver *drv, _EGLDisplay *disp,
EGLSetBlobFuncANDROID set,
EGLGetBlobFuncANDROID get);
+
+ void (*ImageFlushExternal)(_EGLDisplay *disp, _EGLContext *ctx,
+ _EGLImage *image);
+ void (*ImageInvalidateExternal)(_EGLDisplay *disp, _EGLContext *ctx,
+ _EGLImage *image);
};
#ifdef __cplusplus
diff --git a/src/egl/main/egldisplay.h b/src/egl/main/egldisplay.h
index 02ac4fb9a9d..940b71e318e 100644
--- a/src/egl/main/egldisplay.h
+++ b/src/egl/main/egldisplay.h
@@ -105,6 +105,7 @@ struct _egl_extensions
EGLBoolean EXT_create_context_robustness;
EGLBoolean EXT_image_dma_buf_import;
EGLBoolean EXT_image_dma_buf_import_modifiers;
+ EGLBoolean EXT_image_flush_external;
EGLBoolean EXT_pixel_format_float;
EGLBoolean EXT_surface_CTA861_3_metadata;
EGLBoolean EXT_surface_SMPTE2086_metadata;
diff --git a/src/egl/main/eglentrypoint.h b/src/egl/main/eglentrypoint.h
index 44e971e023a..b708078f550 100644
--- a/src/egl/main/eglentrypoint.h
+++ b/src/egl/main/eglentrypoint.h
@@ -51,6 +51,8 @@ EGL_ENTRYPOINT(eglGetProcAddress)
EGL_ENTRYPOINT(eglGetSyncAttrib)
EGL_ENTRYPOINT(eglGetSyncAttribKHR)
EGL_ENTRYPOINT(eglGetSyncValuesCHROMIUM)
+EGL_ENTRYPOINT(eglImageFlushExternalEXT)
+EGL_ENTRYPOINT(eglImageInvalidateExternalEXT)
EGL_ENTRYPOINT(eglInitialize)
EGL_ENTRYPOINT(eglLabelObjectKHR)
EGL_ENTRYPOINT(eglMakeCurrent)