diff options
author | David Phillips <david@sighup.nz> | 2017-02-18 00:48:16 +1300 |
---|---|---|
committer | David Phillips <david@sighup.nz> | 2017-02-18 00:48:16 +1300 |
commit | d356d2bea1a5c0012bf6ef746a90f86b2076d9c2 (patch) | |
tree | eee34f17d35394da91e0d15c5889540de7fec46e /cl | |
parent | ea11f0c71f1617bbfdb5a5ef6644e34cb0192e29 (diff) | |
download | fractal-gen-opencl-d356d2bea1a5c0012bf6ef746a90f86b2076d9c2.tar.xz |
Add macro to set CL kernel source directory
This will future-proof the software for installation to system roots,
where the executable isn't being run in the source tree.
Diffstat (limited to 'cl')
-rw-r--r-- | cl/mandelbrot.cl | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/cl/mandelbrot.cl b/cl/mandelbrot.cl new file mode 100644 index 0000000..2652108 --- /dev/null +++ b/cl/mandelbrot.cl @@ -0,0 +1,25 @@ +__kernel void fractal_gen( + __global unsigned char *buffer, + const unsigned int size, + const unsigned int iterations) +{ + unsigned int x = get_global_id(0); + unsigned int y = get_global_id(1); + unsigned int i = 0; + + float a = -2.5+(((float)x)/(float)size)*3.5; + float b = -1.75+(((float)y)/(float)size)*3.5; + + float2 z = (0.0, 0.0); + + for (i = 0; i < iterations; i++) { + // if abs(z) > 2 + if (z.x*z.x + z.y*z.y > 4) + break; + + float oldx = z.x; + z.x = z.x*z.x - z.y*z.y + a; + z.y = 2*oldx*z.y + b; + } + buffer[(size*y)+x] = (i*255)/iterations; +} |