[gegl/gsoc2011-opencl: 39/46] gegl_cl_texture_dup implemented



commit 924479522b9cfe70effc40f07c3fec140b86875b
Author: Victor Oliveira <victormatheus gmail com>
Date:   Mon Jun 13 15:29:22 2011 -0300

    gegl_cl_texture_dup implemented

 gegl/opencl/gegl-cl-init.h    |    2 ++
 gegl/opencl/gegl-cl-texture.c |   18 ++++++++++++++++--
 gegl/opencl/gegl-cl-texture.h |    9 +++++----
 gegl/opencl/gegl-cl-types.h   |    2 ++
 4 files changed, 25 insertions(+), 6 deletions(-)
---
diff --git a/gegl/opencl/gegl-cl-init.h b/gegl/opencl/gegl-cl-init.h
index 29af9bc..c817009 100644
--- a/gegl/opencl/gegl-cl-init.h
+++ b/gegl/opencl/gegl-cl-init.h
@@ -36,6 +36,7 @@ t_clGetKernelWorkGroupInfo  gegl_clGetKernelWorkGroupInfo  = NULL;
 t_clCreateBuffer            gegl_clCreateBuffer            = NULL;
 t_clEnqueueWriteBuffer      gegl_clEnqueueWriteBuffer      = NULL;
 t_clEnqueueReadBuffer       gegl_clEnqueueReadBuffer       = NULL;
+t_clEnqueueCopyBuffer       gegl_clEnqueueCopyBuffer       = NULL;
 t_clEnqueueNDRangeKernel    gegl_clEnqueueNDRangeKernel    = NULL;
 t_clFinish                  gegl_clFinish                  = NULL;
 
@@ -64,6 +65,7 @@ extern t_clGetKernelWorkGroupInfo  gegl_clGetKernelWorkGroupInfo;
 extern t_clCreateBuffer            gegl_clCreateBuffer;
 extern t_clEnqueueWriteBuffer      gegl_clEnqueueWriteBuffer;
 extern t_clEnqueueReadBuffer       gegl_clEnqueueReadBuffer;
+extern t_clEnqueueCopyBuffer       gegl_clEnqueueCopyBuffer;
 extern t_clEnqueueNDRangeKernel    gegl_clEnqueueNDRangeKernel;
 extern t_clFinish                  gegl_clFinish;
 
diff --git a/gegl/opencl/gegl-cl-texture.c b/gegl/opencl/gegl-cl-texture.c
index 7e56bbf..2fe6e4b 100644
--- a/gegl/opencl/gegl-cl-texture.c
+++ b/gegl/opencl/gegl-cl-texture.c
@@ -5,7 +5,7 @@
 #include "gegl-cl-texture.h"
 
 GeglClTexture *
-gegl_cl_texture_new (gint size)
+gegl_cl_texture_new (const gint size)
 {
   cl_int errcode;
 
@@ -31,7 +31,7 @@ gegl_cl_texture_free (GeglClTexture *texture)
 void
 gegl_cl_texture_get (const GeglClTexture *texture,
                      gpointer             dst,
-                     const gint           size);
+                     const gint           size)
 {
   gegl_clEnqueueReadBuffer(gegl_cl_get_command_queue(), 
                            texture->data, CL_TRUE, 0, size, dst,
@@ -49,3 +49,17 @@ gegl_cl_texture_set (GeglClTexture  *texture,
                             0, NULL, NULL);
   gegl_clFinish(gegl_cl_get_command_queue());
 }
+
+GeglClTexture *
+gegl_cl_texture_dup (const GeglClTexture *texture,
+                     const gint           size)
+{
+  GeglClTexture *new_texture = gegl_cl_texture_new (size);
+
+  gegl_clEnqueueCopyBuffer (gegl_cl_get_command_queue(),
+                            texture->data, new_texture->data,
+                            0, 0, size, 0, NULL, NULL);
+  gegl_clFinish(gegl_cl_get_command_queue());
+
+  return new_texture;
+}
diff --git a/gegl/opencl/gegl-cl-texture.h b/gegl/opencl/gegl-cl-texture.h
index ea05cbc..e9bcabb 100644
--- a/gegl/opencl/gegl-cl-texture.h
+++ b/gegl/opencl/gegl-cl-texture.h
@@ -16,19 +16,20 @@ typedef struct _GeglClTexture GeglClTexture;
 
 GType           gegl_cl_texture_get_type (void) G_GNUC_CONST;
 
-GeglClTexture  *gegl_cl_texture_new      (gint                 size);
+GeglClTexture  *gegl_cl_texture_new      (const gint           size);
 
 void            gegl_cl_texture_free     (GeglClTexture       *texture);
 
 void            gegl_cl_texture_get      (const GeglClTexture *texture,
                                           gpointer             dest,
-                                          gint                 size);
+                                          const gint           size);
 
 void            gegl_cl_texture_set      (GeglClTexture       *texture,
                                           const gpointer       src,
-                                          gint                 size);
+                                          const gint           size);
 
-GeglClTexture  *gegl_cl_texture_dup      (const GeglClTexture *texture);
+GeglClTexture  *gegl_cl_texture_dup      (const GeglClTexture *texture,
+                                          const gint           size);
 
 #define GEGL_TYPE_CL_TEXTURE   (gegl_cl_texture_get_type())
 
diff --git a/gegl/opencl/gegl-cl-types.h b/gegl/opencl/gegl-cl-types.h
index ad04f6e..8947858 100644
--- a/gegl/opencl/gegl-cl-types.h
+++ b/gegl/opencl/gegl-cl-types.h
@@ -25,6 +25,8 @@ typedef cl_int            (*t_clGetKernelWorkGroupInfo ) (cl_kernel, cl_device_i
 typedef cl_mem            (*t_clCreateBuffer           ) (cl_context, cl_mem_flags, size_t, void *, cl_int *);
 typedef cl_int            (*t_clEnqueueWriteBuffer     ) (cl_command_queue, cl_mem, cl_bool, size_t, size_t, const void *, cl_uint, const cl_event *, cl_event *);
 typedef cl_int            (*t_clEnqueueReadBuffer      ) (cl_command_queue, cl_mem, cl_bool, size_t, size_t, void *, cl_uint, const cl_event *, cl_event *);
+typedef cl_int            (*t_clEnqueueCopyBuffer      ) (cl_command_queue, cl_mem, cl_mem,  size_t, size_t, size_t, cl_uint, const cl_event *, cl_event *);
+
 typedef cl_int            (*t_clEnqueueNDRangeKernel   ) (cl_command_queue, cl_kernel, cl_uint, const size_t *, const size_t *, const size_t *, cl_uint, const cl_event *, cl_event *);
 typedef cl_int            (*t_clFinish                 ) (cl_command_queue);
 



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