[PATCH 1/2] opencl: Load cl_gl extension functions only if the extension is supported.

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

 



These are not available on mesa.

Signed-off-by: Jan Vesely <jan.vesely@xxxxxxxxxxx>
---
 gegl/opencl/gegl-cl-init.c | 23 +++++++++++++++++++++++
 1 file changed, 23 insertions(+)

diff --git a/gegl/opencl/gegl-cl-init.c b/gegl/opencl/gegl-cl-init.c
index 8a52ff5..da5f97d 100644
--- a/gegl/opencl/gegl-cl-init.c
+++ b/gegl/opencl/gegl-cl-init.c
@@ -501,6 +501,25 @@ gegl_cl_init_load_functions (GError **error)
   CL_LOAD_FUNCTION (clReleaseContext)
   CL_LOAD_FUNCTION (clReleaseMemObject)
 
+  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)
@@ -691,6 +710,10 @@ gegl_cl_init_common (cl_device_type          requested_device_type,
               return FALSE;
             }
 
+          /* Load extension functions */
+          if (!gegl_cl_gl_init_load_functions (error))
+            return FALSE;
+
           /* Create context */
           ctx = gegl_clCreateContext (gl_contex_props, 1, &cl_state.device, NULL, NULL, &err);
 
-- 
1.9.3

_______________________________________________
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