[gegl] operations: move checkerboard kernel source to opencl folder
- From: Øyvind Kolås <ok src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gegl] operations: move checkerboard kernel source to opencl folder
- Date: Sat, 23 May 2015 21:05:57 +0000 (UTC)
commit c9c1181bc28189a09da2c8017e4a8bdd277e376e
Author: Nanley Chery <nanleychery gmail com>
Date: Mon Dec 8 04:49:14 2014 -0500
operations: move checkerboard kernel source to opencl folder
opencl/checkerboard.cl | 28 ++++++++++++++++++++++++++++
opencl/checkerboard.cl.h | 30 ++++++++++++++++++++++++++++++
operations/common/checkerboard.c | 31 +------------------------------
3 files changed, 59 insertions(+), 30 deletions(-)
---
diff --git a/opencl/checkerboard.cl b/opencl/checkerboard.cl
new file mode 100644
index 0000000..0644811
--- /dev/null
+++ b/opencl/checkerboard.cl
@@ -0,0 +1,28 @@
+inline int tile_index (int coordinate, int stride)
+{
+ int a = (coordinate < 0);
+ return ((coordinate + a) / stride) - a;
+}
+
+__kernel void kernel_checkerboard (__global float4 *out,
+ float4 color1,
+ float4 color2,
+ int square_width,
+ int square_height,
+ int x_offset,
+ int y_offset)
+{
+ size_t roi_width = get_global_size(0);
+ size_t roi_x = get_global_offset(0);
+ size_t roi_y = get_global_offset(1);
+ size_t gidx = get_global_id(0) - roi_x;
+ size_t gidy = get_global_id(1) - roi_y;
+
+ int x = get_global_id(0) - x_offset;
+ int y = get_global_id(1) - y_offset;
+
+ int tilex = tile_index (x, square_width);
+ int tiley = tile_index (y, square_height);
+ out[gidx + gidy * roi_width] = (tilex + tiley) & 1 ?
+ color2 : color1;
+}
diff --git a/opencl/checkerboard.cl.h b/opencl/checkerboard.cl.h
new file mode 100644
index 0000000..cda511f
--- /dev/null
+++ b/opencl/checkerboard.cl.h
@@ -0,0 +1,30 @@
+static const char* checkerboard_cl_source =
+"inline int tile_index (int coordinate, int stride) \n"
+"{ \n"
+" int a = (coordinate < 0); \n"
+" return ((coordinate + a) / stride) - a; \n"
+"} \n"
+" \n"
+"__kernel void kernel_checkerboard (__global float4 *out, \n"
+" float4 color1, \n"
+" float4 color2, \n"
+" int square_width, \n"
+" int square_height, \n"
+" int x_offset, \n"
+" int y_offset) \n"
+"{ \n"
+" size_t roi_width = get_global_size(0); \n"
+" size_t roi_x = get_global_offset(0); \n"
+" size_t roi_y = get_global_offset(1); \n"
+" size_t gidx = get_global_id(0) - roi_x; \n"
+" size_t gidy = get_global_id(1) - roi_y; \n"
+" \n"
+" int x = get_global_id(0) - x_offset; \n"
+" int y = get_global_id(1) - y_offset; \n"
+" \n"
+" int tilex = tile_index (x, square_width); \n"
+" int tiley = tile_index (y, square_height); \n"
+" out[gidx + gidy * roi_width] = (tilex + tiley) & 1 ? \n"
+" color2 : color1; \n"
+"} \n"
+;
diff --git a/operations/common/checkerboard.c b/operations/common/checkerboard.c
index 319025c..f40eed4 100644
--- a/operations/common/checkerboard.c
+++ b/operations/common/checkerboard.c
@@ -87,42 +87,13 @@ get_bounding_box (GeglOperation *operation)
return gegl_rectangle_infinite_plane ();
}
-static const char* checkerboard_cl_source =
-"inline int tile_index (int coordinate, int stride) \n"
-"{ \n"
-" int a = (coordinate < 0); \n"
-" return ((coordinate + a) / stride) - a; \n"
-"} \n"
-" \n"
-"__kernel void kernel_checkerboard (__global float4 *out, \n"
-" float4 color1, \n"
-" float4 color2, \n"
-" int square_width, \n"
-" int square_height, \n"
-" int x_offset, \n"
-" int y_offset) \n"
-"{ \n"
-" size_t roi_width = get_global_size(0); \n"
-" size_t roi_x = get_global_offset(0); \n"
-" size_t roi_y = get_global_offset(1); \n"
-" size_t gidx = get_global_id(0) - roi_x; \n"
-" size_t gidy = get_global_id(1) - roi_y; \n"
-" \n"
-" int x = get_global_id(0) - x_offset; \n"
-" int y = get_global_id(1) - y_offset; \n"
-" \n"
-" int tilex = tile_index (x, square_width); \n"
-" int tiley = tile_index (y, square_height); \n"
-" out[gidx + gidy * roi_width] = (tilex + tiley) & 1 ? \n"
-" color2 : color1; \n"
-"} \n";
-
#define TILE_INDEX(coordinate,stride) \
(((coordinate) >= 0)?\
(coordinate) / (stride):\
((((coordinate) + 1) /(stride)) - 1))
+#include "opencl/checkerboard.cl.h"
static GeglClRunData *cl_data = NULL;
static gboolean
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]