[gegl] Add gegl_cl_set_kernel_args helper



commit f525fc7d59e44ae2a7f7ef94e6ca9b8b2b418ebb
Author: Daniel Sabo <DanielSabo gmail com>
Date:   Sat Oct 19 16:28:56 2013 -0700

    Add gegl_cl_set_kernel_args helper

 gegl/opencl/Makefile.am |    1 +
 gegl/opencl/gegl-cl.c   |   27 +++++++++++++++++++++++++++
 gegl/opencl/gegl-cl.h   |    2 ++
 3 files changed, 30 insertions(+), 0 deletions(-)
---
diff --git a/gegl/opencl/Makefile.am b/gegl/opencl/Makefile.am
index 089ec5b..4f8e467 100644
--- a/gegl/opencl/Makefile.am
+++ b/gegl/opencl/Makefile.am
@@ -27,6 +27,7 @@ libcl_public_HEADERS = \
        opencl.h
 
 libcl_sources = \
+       gegl-cl.c \
        gegl-cl-types.h \
        gegl-cl-init.c \
        gegl-cl-init.h \
diff --git a/gegl/opencl/gegl-cl.c b/gegl/opencl/gegl-cl.c
new file mode 100644
index 0000000..2d97168
--- /dev/null
+++ b/gegl/opencl/gegl-cl.c
@@ -0,0 +1,27 @@
+#include "gegl-cl.h"
+
+cl_int
+gegl_cl_set_kernel_args (cl_kernel kernel, ...)
+{
+  cl_int error = 0;
+  int i = 0;
+  va_list var_args;
+
+  va_start (var_args, kernel);
+  while (1)
+    {
+      size_t  size;
+      void   *value;
+      size  = va_arg (var_args, size_t);
+      if (!size)
+        break;
+      value = va_arg (var_args, void *);
+
+      error = gegl_clSetKernelArg (kernel, i++, size, value);
+      if (error)
+        break;
+    }
+  va_end (var_args);
+
+  return error;
+}
\ No newline at end of file
diff --git a/gegl/opencl/gegl-cl.h b/gegl/opencl/gegl-cl.h
index 2137567..0ff978a 100644
--- a/gegl/opencl/gegl-cl.h
+++ b/gegl/opencl/gegl-cl.h
@@ -23,6 +23,8 @@
 #include "gegl-cl-init.h"
 #include "gegl-cl-color.h"
 
+cl_int gegl_cl_set_kernel_args (cl_kernel kernel, ...) G_GNUC_NULL_TERMINATED;
+
 #ifdef __GEGL_DEBUG_H__
 
 #define CL_ERROR {GEGL_NOTE (GEGL_DEBUG_OPENCL, "Error in %s:%d %s - %s\n", __FILE__, __LINE__, __func__, 
gegl_cl_errstring(cl_err)); goto error;}


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