Hi Kristian, The OpenCL spec has one extension to support interoperation between OpenGL and OpenCL. The key requirement for this extension is to export an OpenGL resource (texture/buffer object/render buffer)'s internal attributes to the OpenCL's driver side.
IMHO, to support that cl extension we may need to add a new extension to the EGL/DRI layer which let the OpenCL driver could use this interface to query the low level attributes of the resource from the mesa dri driver side. Thus I propose this extension as below: EGLAPI EGLBoolean EGLAPIENTRY eglAcquireResourceMESA(EGLDisplay dpy, EGLContext ctx, const EGLenum target, const EGLint *attrib_list, void * user_data); EGLAPI EGLBoolean EGLAPIENTRY eglReleaseResourceMESA(EGLDisplay dpy, EGLContext ctx, const EGLenum target, const EGLint *attrib_list); The first API is to acquire the specified resource and get the low level attribute back in the driver specified user_data structure. The OpenCL side could use this structure to create a correct buffer object in OpenCL domain. The eglAcquireResourceMESA will also implicitly increase the resoruce's reference counter. The second API is to be called when the resource is no longer be shared with Open CL domain. It will decrease the resource's reference counter. The following patchset is to implement this extension, and I also implemented the OpenCL side on Beignet's runtime library. The texture sharing part works fine. Any comments are welcome and if this new extension is not the right way to solve the original problem, please feel free to point it out and kindly guide which is the right way to implement the cl-gl interoperations. Thanks. Zhigang Gong (3): EGL: introduce a new extension to share resource with external library. DRI: implement helper functions for dri resource sharing extension. i965: implement driResourceSharing extension. include/EGL/eglext.h | 19 ++ include/GL/internal/dri_interface.h | 19 ++ src/egl/drivers/dri2/egl_dri2.c | 167 +++++++++++++++++ src/egl/drivers/dri2/egl_dri2.h | 2 + src/egl/main/Makefile.am | 4 +- src/egl/main/eglapi.c | 33 ++++ src/egl/main/eglapi.h | 9 + src/egl/main/eglresshare.c | 139 ++++++++++++++ src/egl/main/eglresshare.h | 47 +++++ src/mesa/drivers/dri/common/dri_util.c | 48 +++++ src/mesa/drivers/dri/common/dri_util.h | 10 + src/mesa/drivers/dri/i965/Makefile.am | 2 + src/mesa/drivers/dri/i965/Makefile.sources | 1 + .../drivers/dri/i965/intel_dri_resource_share.c | 192 ++++++++++++++++++++ .../drivers/dri/i965/intel_dri_resource_share.h | 36 ++++ src/mesa/drivers/dri/i965/intel_screen.c | 9 +- src/mesa/drivers/dri/i965/intel_screen.h | 10 + 17 files changed, 745 insertions(+), 2 deletions(-) create mode 100644 src/egl/main/eglresshare.c create mode 100644 src/egl/main/eglresshare.h create mode 100644 src/mesa/drivers/dri/i965/intel_dri_resource_share.c create mode 100644 src/mesa/drivers/dri/i965/intel_dri_resource_share.h -- 1.7.9.5 _______________________________________________ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev