return;
if (LIKELY(mem->bo != NULL))
cl_buffer_unreference(mem->bo);
+#ifdef HAS_EGL
+ if (UNLIKELY(mem->egl_image != NULL)) {
+ cl_mem_gl_delete(mem);
+ }
+#endif
/* Remove it from the list */
assert(mem->ctx);
uint64_t magic; /* To identify it as a memory object */
volatile int ref_n; /* This object is reference counted */
cl_buffer bo; /* Data in GPU memory */
+ void *egl_image; /* created from external egl image*/
size_t size; /* original request size, not alignment size, used in constant buffer */
cl_mem prev, next; /* We chain the memory buffers together */
cl_context ctx; /* Context it belongs to */
/* Unref the object and delete it if no more reference */
extern void cl_mem_delete(cl_mem);
+/* Destroy egl image. */
+extern void cl_mem_gl_delete(cl_mem);
+
/* Add one more reference to this object */
extern void cl_mem_add_ref(cl_mem);
err = CL_INVALID_GL_OBJECT;
goto error;
}
+ mem->egl_image = egl_image;
mem->bo = cl_buffer_alloc_from_eglimage(ctx, (void*)egl_image, &gl_format, &w, &h, &pitch, &tiling);
if (UNLIKELY(mem->bo == NULL)) {
err = CL_MEM_OBJECT_ALLOCATION_FAILURE;
goto exit;
}
+
+LOCAL void cl_mem_gl_delete(cl_mem mem)
+{
+ struct cl_gl_ext_deps *egl_funcs;
+ EGLDisplay egl_display = (EGLDisplay)mem->ctx->props.egl_display;
+ egl_funcs = CL_EXTENSION_GET_FUNCS(mem->ctx, khr_gl_sharing, gl_ext_deps);
+ egl_funcs->eglDestroyImageKHR_func(egl_display, mem->egl_image);
+}