[gegl/gsoc2011-opencl-2: 11/19] Changing OpenCL headers directory because of makefiles



commit 97d8a051ba9f7e416f439ebe3d303a1bd9f448e8
Author: Victor Oliveira <victormatheus gmail com>
Date:   Fri Nov 18 16:05:28 2011 -0200

    Changing OpenCL headers directory because of makefiles

 gegl/opencl/Makefile.am                      |   22 ++++++++++---
 gegl/opencl/{CL => }/cl.h                    |    2 +-
 gegl/opencl/{CL => }/cl_d3d10.h              |    4 +-
 gegl/opencl/{CL => }/cl_ext.h                |    2 +-
 gegl/opencl/{CL => }/cl_gl.h                 |    2 +-
 gegl/opencl/{CL => }/cl_gl_ext.h             |    2 +-
 gegl/opencl/{CL => }/cl_platform.h           |    0
 gegl/opencl/gegl-cl-types.h                  |    8 ++--
 gegl/opencl/{CL => }/opencl.h                |    0
 gegl/operation/gegl-operation-point-filter.c |   43 ++++++++++++++++---------
 gegl/operation/gegl-operation-point-filter.h |    2 +-
 operations/common/brightness-contrast.c      |    2 +-
 12 files changed, 56 insertions(+), 33 deletions(-)
---
diff --git a/gegl/opencl/Makefile.am b/gegl/opencl/Makefile.am
index 90df443..39891d0 100644
--- a/gegl/opencl/Makefile.am
+++ b/gegl/opencl/Makefile.am
@@ -13,16 +13,28 @@ AM_CFLAGS = $(DEP_CFLAGS) $(BABL_CFLAGS)
 
 LIBS = $(OPENCL_LIBS)
 
-noinst_LTLIBRARIES = libcl.la
+libcl_publicdir = $(includedir)/gegl-$(GEGL_API_VERSION)/opencl
 
-#libcl_publicdir = $(includedir)/gegl-$(GEGL_API_VERSION)/gegl/cl
-#libcl_public_HEADERS = gegl-cl-init.h
+libcl_public_HEADERS = \
+	gegl-cl.h \
+	gegl-cl-init.h \
+	gegl-cl-texture.h \
+	gegl-cl-types.h \
+	cl_d3d10.h \
+	cl_ext.h \
+	cl_gl_ext.h \
+	cl_gl.h \
+	cl.h \
+	cl_platform.h \
+	opencl.h
 
-libcl_la_SOURCES = \
+libcl_sources = \
 	gegl-cl-types.h \
 	gegl-cl-init.c \
 	gegl-cl-init.h \
 	gegl-cl-texture.c \
 	gegl-cl-texture.h
 
-#libcl_la_SOURCES = $(libcl_sources) $(libcl_public_HEADERS)
+noinst_LTLIBRARIES = libcl.la
+
+libcl_la_SOURCES = $(libcl_sources) $(libcl_public_HEADERS)
diff --git a/gegl/opencl/CL/cl.h b/gegl/opencl/cl.h
similarity index 99%
rename from gegl/opencl/CL/cl.h
rename to gegl/opencl/cl.h
index 6f85d09..c68f985 100644
--- a/gegl/opencl/CL/cl.h
+++ b/gegl/opencl/cl.h
@@ -29,7 +29,7 @@
 #ifdef __APPLE__
 #include <OpenCL/cl_platform.h>
 #else
-#include <CL/cl_platform.h>
+#include "cl_platform.h"
 #endif
 
 #ifdef __cplusplus
diff --git a/gegl/opencl/CL/cl_d3d10.h b/gegl/opencl/cl_d3d10.h
similarity index 99%
rename from gegl/opencl/CL/cl_d3d10.h
rename to gegl/opencl/cl_d3d10.h
index c6d9cf2..42ab25e 100644
--- a/gegl/opencl/CL/cl_d3d10.h
+++ b/gegl/opencl/cl_d3d10.h
@@ -27,8 +27,8 @@
 #define __OPENCL_CL_D3D10_H
 
 #include <d3d10.h>
-#include <CL/cl.h>
-#include <CL/cl_platform.h>
+#include "cl.h"
+#include "cl_platform.h"
 
 #ifdef __cplusplus
 extern "C" {
diff --git a/gegl/opencl/CL/cl_ext.h b/gegl/opencl/cl_ext.h
similarity index 99%
rename from gegl/opencl/CL/cl_ext.h
rename to gegl/opencl/cl_ext.h
index 9f200d9..be80e74 100644
--- a/gegl/opencl/CL/cl_ext.h
+++ b/gegl/opencl/cl_ext.h
@@ -37,7 +37,7 @@ extern "C" {
 	#include <OpenCL/cl.h>
     #include <AvailabilityMacros.h>
 #else
-	#include <CL/cl.h>
+	#include "cl.h"
 #endif
 
 /* cl_khr_fp64 extension - no extension #define since it has no functions  */
diff --git a/gegl/opencl/CL/cl_gl.h b/gegl/opencl/cl_gl.h
similarity index 99%
rename from gegl/opencl/CL/cl_gl.h
rename to gegl/opencl/cl_gl.h
index ca3e80a..ae87c4e 100644
--- a/gegl/opencl/CL/cl_gl.h
+++ b/gegl/opencl/cl_gl.h
@@ -36,7 +36,7 @@
 #include <OpenCL/cl.h>
 #include <OpenGL/CGLDevice.h>
 #else
-#include <CL/cl.h>
+#include "cl.h"
 #endif
 
 #ifdef __cplusplus
diff --git a/gegl/opencl/CL/cl_gl_ext.h b/gegl/opencl/cl_gl_ext.h
similarity index 99%
rename from gegl/opencl/CL/cl_gl_ext.h
rename to gegl/opencl/cl_gl_ext.h
index 6b05e2e..e62be7b 100644
--- a/gegl/opencl/CL/cl_gl_ext.h
+++ b/gegl/opencl/cl_gl_ext.h
@@ -36,7 +36,7 @@ extern "C" {
 #ifdef __APPLE__
     #include <OpenCL/cl_gl.h>
 #else
-    #include <CL/cl_gl.h>
+    #include "cl_gl.h"
 #endif
 
 /*
diff --git a/gegl/opencl/CL/cl_platform.h b/gegl/opencl/cl_platform.h
similarity index 100%
rename from gegl/opencl/CL/cl_platform.h
rename to gegl/opencl/cl_platform.h
diff --git a/gegl/opencl/gegl-cl-types.h b/gegl/opencl/gegl-cl-types.h
index 78f65a9..a88957f 100644
--- a/gegl/opencl/gegl-cl-types.h
+++ b/gegl/opencl/gegl-cl-types.h
@@ -3,10 +3,10 @@
 
 #include <glib-object.h>
 
-#include <CL/cl.h>
-#include <CL/cl_gl.h>
-#include <CL/cl_gl_ext.h>
-#include <CL/cl_ext.h>
+#include "cl.h"
+#include "cl_gl.h"
+#include "cl_gl_ext.h"
+#include "cl_ext.h"
 
 typedef cl_int (*t_clGetPlatformIDs)  (cl_uint, cl_platform_id *, cl_uint *);
 typedef cl_int (*t_clGetPlatformInfo) (cl_platform_id, cl_platform_info, size_t, void *, size_t *);
diff --git a/gegl/opencl/CL/opencl.h b/gegl/opencl/opencl.h
similarity index 100%
rename from gegl/opencl/CL/opencl.h
rename to gegl/opencl/opencl.h
diff --git a/gegl/operation/gegl-operation-point-filter.c b/gegl/operation/gegl-operation-point-filter.c
index 4e436a1..438c098 100644
--- a/gegl/operation/gegl-operation-point-filter.c
+++ b/gegl/operation/gegl-operation-point-filter.c
@@ -32,7 +32,7 @@
 #include "gegl-buffer-private.h"
 #include "gegl-tile-storage.h"
 
-#include "gegl-cl.h"
+#include "opencl/gegl-cl.h"
 
 static gboolean gegl_operation_point_filter_process
                               (GeglOperation       *operation,
@@ -72,6 +72,7 @@ gegl_operation_point_filter_init (GeglOperationPointFilter *self)
 {
 }
 
+#include <stdio.h>
 
 static gboolean
 gegl_operation_point_filter_cl_process (GeglOperation       *operation,
@@ -81,7 +82,6 @@ gegl_operation_point_filter_cl_process (GeglOperation       *operation,
 {
   GeglOperationPointFilterClass *point_filter_class = GEGL_OPERATION_POINT_FILTER_GET_CLASS (operation);
 
-  const GeglRectangle *ext = gegl_buffer_get_extent (input);
   const gint bpp = babl_format_get_bytes_per_pixel (babl_format ("RGBA float"));
 
   int y, x;
@@ -121,35 +121,45 @@ gegl_operation_point_filter_cl_process (GeglOperation       *operation,
   for (y=0; y < result->height; y += cl_state.max_image_height)
     for (x=0; x < result->width;  x += cl_state.max_image_width)
       {
-        const size_t offset = y * (4 * ext->width) + (4 * x);
+        const size_t offset = y * (4 * result->width) + (4 * x);
         const size_t origin[3] = {0, 0, 0};
         const size_t region[3] = {MIN(cl_state.max_image_width,  result->width -x),
                                   MIN(cl_state.max_image_height, result->height-y),
                                   1};
         const size_t global_worksize[2] = {region[0], region[1]};
 
-        gegl_clEnqueueWriteImage(gegl_cl_get_command_queue(), in_tex, CL_FALSE,
-                                 origin, region, ext->width, 0, &in_data[offset],
-                                 0, NULL, NULL);
+        GeglRectangle roi = {x, y, region[0], region[1]};
 
-        gegl_clEnqueueBarrier (gegl_cl_get_command_queue());
+        /* CPU -> GPU */
+        errcode = gegl_clEnqueueWriteImage(gegl_cl_get_command_queue(), in_tex, CL_FALSE,
+                                           origin, region, result->width * 4 * sizeof(gfloat), 0, &in_data[offset],
+                                           0, NULL, NULL);
+        if (errcode != CL_SUCCESS) goto error;
 
-        errcode = point_filter_class->cl_process(operation, in_tex, out_tex, global_worksize, result);
+        /* Wait */
+        errcode = gegl_clEnqueueBarrier(gegl_cl_get_command_queue());
+        if (errcode != CL_SUCCESS) goto error;
 
-        if (errcode > 0) goto error;
+        /* Process */
+        errcode = point_filter_class->cl_process(operation, in_tex, out_tex, global_worksize, &roi);
+        if (errcode != CL_SUCCESS) goto error;
 
-        gegl_clEnqueueBarrier (gegl_cl_get_command_queue());
+        /* Wait */
+        errcode = gegl_clEnqueueBarrier(gegl_cl_get_command_queue());
+        if (errcode != CL_SUCCESS) goto error;
 
-        gegl_clEnqueueReadImage(gegl_cl_get_command_queue(), out_tex, CL_FALSE,
-                                origin, region, ext->width, 0, &out_data[offset],
-                                0, NULL, NULL);
-
-        gegl_clEnqueueBarrier (gegl_cl_get_command_queue());
+        /* GPU -> CPU */
+        errcode = gegl_clEnqueueReadImage(gegl_cl_get_command_queue(), out_tex, CL_FALSE,
+                                           origin, region, result->width * 4 * sizeof(gfloat), 0, &out_data[offset],
+                                           0, NULL, NULL);
+        if (errcode != CL_SUCCESS) goto error;
 
+        /* Wait */
+        errcode = gegl_clEnqueueBarrier(gegl_cl_get_command_queue());
+        if (errcode != CL_SUCCESS) goto error;
       }
 
   errcode = gegl_clFinish(gegl_cl_get_command_queue());
-
   if (errcode != CL_SUCCESS) goto error;
 
   /* tile-ize */
@@ -164,6 +174,7 @@ gegl_operation_point_filter_cl_process (GeglOperation       *operation,
   return TRUE;
 
 error:
+  g_log(G_LOG_DOMAIN, G_LOG_LEVEL_INFO, "[OpenCL] Error: %s", gegl_cl_errstring(errcode));
   if (in_tex)   gegl_clReleaseMemObject (in_tex);
   if (out_tex)  gegl_clReleaseMemObject (out_tex);
   if (in_data)  free (in_data);
diff --git a/gegl/operation/gegl-operation-point-filter.h b/gegl/operation/gegl-operation-point-filter.h
index 01115bf..dbcbd90 100644
--- a/gegl/operation/gegl-operation-point-filter.h
+++ b/gegl/operation/gegl-operation-point-filter.h
@@ -28,7 +28,7 @@
 
 #include "gegl-operation-filter.h"
 
-#include "gegl-cl.h"
+#include "opencl/gegl-cl.h"
 
 G_BEGIN_DECLS
 
diff --git a/operations/common/brightness-contrast.c b/operations/common/brightness-contrast.c
index 488f515..a11ec42 100644
--- a/operations/common/brightness-contrast.c
+++ b/operations/common/brightness-contrast.c
@@ -104,7 +104,7 @@ process (GeglOperation       *op,
   return TRUE;
 }
 
-#include "gegl-cl.h"
+#include "opencl/gegl-cl.h"
 
 static const char* kernel_source =
 "sampler_t sampler = CLK_NORMALIZED_COORDS_FALSE |              \n"



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