aboutsummaryrefslogtreecommitdiff
path: root/test.cl
diff options
context:
space:
mode:
authorDavid Phillips <david@sighup.nz>2017-02-12 19:53:03 +1300
committerDavid Phillips <david@sighup.nz>2017-02-12 19:53:03 +1300
commitc8dc778d855b05a057e8d340b06900ba738811df (patch)
tree99565a2eaeab3e57a32bc26670dce6e80c233d31 /test.cl
parent49de0b81e712bad40753ff648adad8d0bd28b6bd (diff)
downloadfractal-gen-opencl-c8dc778d855b05a057e8d340b06900ba738811df.tar.xz
Don't hardcode stuff
Diffstat (limited to 'test.cl')
-rw-r--r--test.cl13
1 files changed, 8 insertions, 5 deletions
diff --git a/test.cl b/test.cl
index 5e081f5..a2ecc67 100644
--- a/test.cl
+++ b/test.cl
@@ -1,16 +1,19 @@
-__kernel void fractal_gen(__global unsigned int *buffer)
+__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)1024)*3.5;
- float b = -1.75+(((float)y)/(float)1024)*3.5;
+ 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 < 254; i++) {
+ for (i = 0; i < iterations; i++) {
// if abs(z) > 2
if (z.x*z.x + z.y*z.y > 4)
break;
@@ -19,5 +22,5 @@ __kernel void fractal_gen(__global unsigned int *buffer)
z.x = z.x*z.x - z.y*z.y + a;
z.y = 2*oldx*z.y + b;
}
- buffer[x+1024*y] = i;
+ buffer[x+size*y] = (i*255)/iterations;
}