[Mesa-dev] [PATCH v2] egl: add support for EGL_ANDROID_blob_cache
Tapani Pälli
tapani.palli at intel.com
Fri Jan 19 07:10:45 UTC 2018
v2: cleanup, move callbacks to _egl_display struct (Emil Velikov)
Signed-off-by: Tapani Pälli <tapani.palli at intel.com>
---
src/egl/drivers/dri2/egl_dri2.c | 39 +++++++++++++++++++++++++++++++++++++++
src/egl/drivers/dri2/egl_dri2.h | 1 +
src/egl/main/eglapi.c | 30 ++++++++++++++++++++++++++++++
src/egl/main/eglapi.h | 4 ++++
src/egl/main/egldisplay.h | 4 ++++
src/egl/main/eglentrypoint.h | 1 +
6 files changed, 79 insertions(+)
diff --git a/src/egl/drivers/dri2/egl_dri2.c b/src/egl/drivers/dri2/egl_dri2.c
index d5a4f72e86..c323a4989d 100644
--- a/src/egl/drivers/dri2/egl_dri2.c
+++ b/src/egl/drivers/dri2/egl_dri2.c
@@ -458,6 +458,7 @@ static const struct dri2_extension_match optional_core_extensions[] = {
{ __DRI2_INTEROP, 1, offsetof(struct dri2_egl_display, interop) },
{ __DRI_IMAGE, 1, offsetof(struct dri2_egl_display, image) },
{ __DRI2_FLUSH_CONTROL, 1, offsetof(struct dri2_egl_display, flush_control) },
+ { __DRI2_BLOB, 1, offsetof(struct dri2_egl_display, blob) },
{ NULL, 0, 0 }
};
@@ -727,6 +728,9 @@ dri2_setup_screen(_EGLDisplay *disp)
}
}
+ if (dri2_dpy->blob)
+ disp->Extensions.ANDROID_blob_cache = EGL_TRUE;
+
disp->Extensions.KHR_reusable_sync = EGL_TRUE;
if (dri2_dpy->image) {
@@ -1470,6 +1474,28 @@ dri2_surf_update_fence_fd(_EGLContext *ctx,
dri2_surface_set_out_fence_fd(surf, fence_fd);
}
+static void
+update_blob_cache_functions( _EGLDisplay *disp, _EGLContext *ctx)
+{
+ struct dri2_egl_display *dri2_dpy = dri2_egl_display(disp);
+ struct dri2_egl_context *dri2_ctx = dri2_egl_context(ctx);
+
+ if (!ctx)
+ return;
+
+ /* No blob support. */
+ if (!dri2_dpy->blob)
+ return;
+
+ /* No functions to set. */
+ if (!disp->BlobCacheSet)
+ return;
+
+ dri2_dpy->blob->set_cache_funcs(dri2_ctx->dri_context,
+ disp->BlobCacheSet,
+ disp->BlobCacheGet);
+}
+
/**
* Called via eglMakeCurrent(), drv->API.MakeCurrent().
*/
@@ -1499,6 +1525,9 @@ dri2_make_current(_EGLDriver *drv, _EGLDisplay *disp, _EGLSurface *dsurf,
if (old_ctx)
dri2_gl_flush();
+ /* Make sure cache functions are set for new context. */
+ update_blob_cache_functions(disp, ctx);
+
ddraw = (dsurf) ? dri2_dpy->vtbl->get_dri_drawable(dsurf) : NULL;
rdraw = (rsurf) ? dri2_dpy->vtbl->get_dri_drawable(rsurf) : NULL;
cctx = (dri2_ctx) ? dri2_ctx->dri_context : NULL;
@@ -3016,6 +3045,15 @@ dri2_dup_native_fence_fd(_EGLDriver *drv, _EGLDisplay *dpy, _EGLSync *sync)
return dup(sync->SyncFd);
}
+static void
+dri2_set_blob_cache_funcs(_EGLDriver *drv, _EGLDisplay *dpy,
+ EGLSetBlobFuncANDROID set,
+ EGLGetBlobFuncANDROID get)
+{
+ _EGLContext *ctx = _eglGetCurrentContext();
+ update_blob_cache_functions(dpy, ctx);
+}
+
static EGLint
dri2_client_wait_sync(_EGLDriver *drv, _EGLDisplay *dpy, _EGLSync *sync,
EGLint flags, EGLTime timeout)
@@ -3234,6 +3272,7 @@ _eglBuiltInDriver(void)
dri2_drv->API.GLInteropQueryDeviceInfo = dri2_interop_query_device_info;
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->Name = "DRI2";
diff --git a/src/egl/drivers/dri2/egl_dri2.h b/src/egl/drivers/dri2/egl_dri2.h
index cc76c73eab..c49156fbb6 100644
--- a/src/egl/drivers/dri2/egl_dri2.h
+++ b/src/egl/drivers/dri2/egl_dri2.h
@@ -171,6 +171,7 @@ struct dri2_egl_display
const __DRInoErrorExtension *no_error;
const __DRI2configQueryExtension *config;
const __DRI2fenceExtension *fence;
+ const __DRI2blobExtension *blob;
const __DRI2rendererQueryExtension *rendererQuery;
const __DRI2interopExtension *interop;
int fd;
diff --git a/src/egl/main/eglapi.c b/src/egl/main/eglapi.c
index 5110688f2d..f2ba260060 100644
--- a/src/egl/main/eglapi.c
+++ b/src/egl/main/eglapi.c
@@ -476,6 +476,7 @@ _eglCreateExtensionsString(_EGLDisplay *dpy)
char *exts = dpy->ExtensionsString;
/* Please keep these sorted alphabetically. */
+ _EGL_CHECK_EXTENSION(ANDROID_blob_cache);
_EGL_CHECK_EXTENSION(ANDROID_framebuffer_target);
_EGL_CHECK_EXTENSION(ANDROID_image_native_buffer);
_EGL_CHECK_EXTENSION(ANDROID_native_fence_sync);
@@ -2522,6 +2523,35 @@ eglQueryDmaBufModifiersEXT(EGLDisplay dpy, EGLint format, EGLint max_modifiers,
RETURN_EGL_EVAL(disp, ret);
}
+static void EGLAPIENTRY
+eglSetBlobCacheFuncsANDROID(EGLDisplay *dpy, EGLSetBlobFuncANDROID set,
+ EGLGetBlobFuncANDROID get)
+{
+ _EGLDisplay *disp = _eglLockDisplay(dpy);
+ _EGLDriver *drv = _eglCheckDisplay(disp, __func__);
+
+ if (!set || !get) {
+ _eglError(EGL_BAD_PARAMETER,
+ "eglSetBlobCacheFuncsANDROID: NULL handler given");
+ _eglUnlockDisplay(disp);
+ return;
+ }
+
+ if (disp->BlobCacheSet) {
+ _eglError(EGL_BAD_PARAMETER,
+ "eglSetBlobCacheFuncsANDROID: functions already set");
+ _eglUnlockDisplay(disp);
+ return;
+ }
+
+ disp->BlobCacheSet = set;
+ disp->BlobCacheGet = get;
+
+ drv->API.SetBlobCacheFuncsANDROID(drv, disp, set, get);
+
+ _eglUnlockDisplay(disp);
+}
+
__eglMustCastToProperFunctionPointerType EGLAPIENTRY
eglGetProcAddress(const char *procname)
{
diff --git a/src/egl/main/eglapi.h b/src/egl/main/eglapi.h
index 852a34584e..3f70377cd7 100644
--- a/src/egl/main/eglapi.h
+++ b/src/egl/main/eglapi.h
@@ -209,6 +209,10 @@ struct _egl_api
EGLuint64KHR *modifiers,
EGLBoolean *external_only,
EGLint *num_modifiers);
+
+ void (*SetBlobCacheFuncsANDROID) (_EGLDriver *drv, _EGLDisplay *dpy,
+ EGLSetBlobFuncANDROID set,
+ EGLGetBlobFuncANDROID get);
};
#ifdef __cplusplus
diff --git a/src/egl/main/egldisplay.h b/src/egl/main/egldisplay.h
index addf430ffe..71400b9568 100644
--- a/src/egl/main/egldisplay.h
+++ b/src/egl/main/egldisplay.h
@@ -92,6 +92,7 @@ struct _egl_resource
struct _egl_extensions
{
/* Please keep these sorted alphabetically. */
+ EGLBoolean ANDROID_blob_cache;
EGLBoolean ANDROID_framebuffer_target;
EGLBoolean ANDROID_image_native_buffer;
EGLBoolean ANDROID_native_fence_sync;
@@ -181,6 +182,9 @@ struct _egl_display
_EGLResource *ResourceLists[_EGL_NUM_RESOURCES];
EGLLabelKHR Label;
+
+ EGLSetBlobFuncANDROID BlobCacheSet;
+ EGLGetBlobFuncANDROID BlobCacheGet;
};
diff --git a/src/egl/main/eglentrypoint.h b/src/egl/main/eglentrypoint.h
index f7fe77410d..06749f6353 100644
--- a/src/egl/main/eglentrypoint.h
+++ b/src/egl/main/eglentrypoint.h
@@ -63,6 +63,7 @@ EGL_ENTRYPOINT(eglQuerySurface)
EGL_ENTRYPOINT(eglQueryWaylandBufferWL)
EGL_ENTRYPOINT(eglReleaseTexImage)
EGL_ENTRYPOINT(eglReleaseThread)
+EGL_ENTRYPOINT(eglSetBlobCacheFuncsANDROID)
EGL_ENTRYPOINT(eglSetDamageRegionKHR)
EGL_ENTRYPOINT(eglSignalSyncKHR)
EGL_ENTRYPOINT(eglSurfaceAttrib)
--
2.14.3
More information about the mesa-dev
mailing list