Re: [PATCH 2/2] opencl: Load extension function in a portable way.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



ping, any takers?

Jan

On Mon, 2014-07-28 at 11:32 -0400, Jan Vesely wrote:
> Signed-off-by: Jan Vesely <jan.vesely@xxxxxxxxxxx>
> ---
>  gegl/opencl/gegl-cl-init.c  | 31 +++++++++++++++----------------
>  gegl/opencl/gegl-cl-init.h  |  4 ++++
>  gegl/opencl/gegl-cl-types.h |  2 ++
>  3 files changed, 21 insertions(+), 16 deletions(-)
> 
> diff --git a/gegl/opencl/gegl-cl-init.c b/gegl/opencl/gegl-cl-init.c
> index da5f97d..f4ba3ce 100644
> --- a/gegl/opencl/gegl-cl-init.c
> +++ b/gegl/opencl/gegl-cl-init.c
> @@ -324,6 +324,16 @@ if (gegl_##func == NULL)
>  
>  #endif
>  
> +#define CL_LOAD_EXTENSION_FUNCTION(func)                                          \
> +g_assert(gegl_clGetExtensionFunctionAddress);                                     \
> +gegl_##func = gegl_clGetExtensionFunctionAddress(#func);                          \
> +if (gegl_##func == NULL)                                                          \
> +  {                                                                               \
> +    GEGL_NOTE (GEGL_DEBUG_OPENCL, "symbol gegl_##func is NULL");                  \
> +    g_set_error (error, GEGL_OPENCL_ERROR, 0, "symbol gegl_##func is NULL");      \
> +    return FALSE;                                                                 \
> +  }
> +
>  #if defined(__APPLE__)
>  typedef struct _CGLContextObject *CGLContextObj;
>  typedef struct CGLShareGroupRec  *CGLShareGroupObj;
> @@ -501,28 +511,17 @@ gegl_cl_init_load_functions (GError **error)
>    CL_LOAD_FUNCTION (clReleaseContext)
>    CL_LOAD_FUNCTION (clReleaseMemObject)
>  
> +  CL_LOAD_FUNCTION (clGetExtensionFunctionAddress);
> +
>    return TRUE;
>  }
>  
>  static gboolean
>  gegl_cl_gl_init_load_functions (GError **error)
>  {
> -#ifdef G_OS_WIN32
> -  HINSTANCE module = LoadLibrary ("OpenCL.dll");
> -#else
> -  GModule *module = g_module_open (CL_LIBRARY_NAME, G_MODULE_BIND_LAZY);
> -#endif
> -
> -  if (!module)
> -    {
> -      GEGL_NOTE (GEGL_DEBUG_OPENCL, "Unable to load OpenCL library");
> -      g_set_error (error, GEGL_OPENCL_ERROR, 0, "Unable to load OpenCL library");
> -      return FALSE;
> -    }
> -
> -  CL_LOAD_FUNCTION (clCreateFromGLTexture2D)
> -  CL_LOAD_FUNCTION (clEnqueueAcquireGLObjects)
> -  CL_LOAD_FUNCTION (clEnqueueReleaseGLObjects)
> +  CL_LOAD_EXTENSION_FUNCTION (clCreateFromGLTexture2D)
> +  CL_LOAD_EXTENSION_FUNCTION (clEnqueueAcquireGLObjects)
> +  CL_LOAD_EXTENSION_FUNCTION (clEnqueueReleaseGLObjects)
>  
>    return TRUE;
>  }
> diff --git a/gegl/opencl/gegl-cl-init.h b/gegl/opencl/gegl-cl-init.h
> index 92ddd3b..9d1c983 100644
> --- a/gegl/opencl/gegl-cl-init.h
> +++ b/gegl/opencl/gegl-cl-init.h
> @@ -119,6 +119,8 @@ t_clReleaseCommandQueue gegl_clReleaseCommandQueue = NULL;
>  t_clReleaseContext      gegl_clReleaseContext      = NULL;
>  t_clReleaseMemObject    gegl_clReleaseMemObject    = NULL;
>  
> +t_clGetExtensionFunctionAddress gegl_clGetExtensionFunctionAddress = NULL;
> +
>  t_clCreateFromGLTexture2D    gegl_clCreateFromGLTexture2D = NULL;
>  t_clEnqueueAcquireGLObjects  gegl_clEnqueueAcquireGLObjects = NULL;
>  t_clEnqueueReleaseGLObjects  gegl_clEnqueueReleaseGLObjects = NULL;
> @@ -169,6 +171,8 @@ extern t_clReleaseCommandQueue gegl_clReleaseCommandQueue;
>  extern t_clReleaseContext      gegl_clReleaseContext;
>  extern t_clReleaseMemObject    gegl_clReleaseMemObject;
>  
> +extern t_clGetExtensionFunctionAddress gegl_clGetExtensionFunctionAddress;
> +
>  extern t_clCreateFromGLTexture2D gegl_clCreateFromGLTexture2D;
>  extern t_clEnqueueAcquireGLObjects gegl_clEnqueueAcquireGLObjects;
>  extern t_clEnqueueReleaseGLObjects gegl_clEnqueueReleaseGLObjects;
> diff --git a/gegl/opencl/gegl-cl-types.h b/gegl/opencl/gegl-cl-types.h
> index 73c9b3b..eb0ea38 100644
> --- a/gegl/opencl/gegl-cl-types.h
> +++ b/gegl/opencl/gegl-cl-types.h
> @@ -103,4 +103,6 @@ typedef CL_API_ENTRY cl_int            (CL_API_CALL *t_clEnqueueReleaseGLObjects
>     const cl_event *event_wait_list,
>     cl_event *event);
>  
> +typedef CL_API_ENTRY void *            (CL_API_CALL *t_clGetExtensionFunctionAddress)  (const char *);
> +
>  #endif /* __GEGL_CL_TYPES_H__ */

-- 
Jan Vesely <jan.vesely@xxxxxxxxxxx>

Attachment: signature.asc
Description: This is a digitally signed message part

_______________________________________________
gegl-developer-list mailing list
List address:    gegl-developer-list@xxxxxxxxx
List membership: https://mail.gnome.org/mailman/listinfo/gegl-developer-list


[Index of Archives]     [Yosemite News]     [Yosemite Photos]     [gtk]     [GIMP Users]     [KDE]     [Gimp's Home]     [Gimp on Windows]     [Steve's Art]

  Powered by Linux