aboutsummaryrefslogtreecommitdiff
path: root/test.cl
diff options
context:
space:
mode:
authorDavid Phillips <david@sighup.nz>2017-02-12 00:08:10 +1300
committerDavid Phillips <david@sighup.nz>2017-02-12 00:08:10 +1300
commit11b1f27f9d27b3f497c20205a77f00272fe8f332 (patch)
tree4a5eee2cfd70885b18103f9349e2c70ac0dcab16 /test.cl
parente169d7aa8585ebb5f4fab3eccc8df92a43add4f5 (diff)
downloadfractal-gen-opencl-11b1f27f9d27b3f497c20205a77f00272fe8f332.tar.xz
Add rough, hard-coded mock-up to prove trampoline
This needs the hard-coded constants taken out of it asap to merge with master. The code is strictly temporary as a measure to prove that the CL trampoline works and we are actually able to get images from the device.
Diffstat (limited to 'test.cl')
-rw-r--r--test.cl24
1 files changed, 21 insertions, 3 deletions
diff --git a/test.cl b/test.cl
index cc587b4..5e081f5 100644
--- a/test.cl
+++ b/test.cl
@@ -1,5 +1,23 @@
-__kernel void test(__global float *a, __global float *b)
+__kernel void fractal_gen(__global unsigned int *buffer)
{
- unsigned int i = get_global_id(0);
- b[i] = a[i] * 2.f;
+ 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;
+
+ float2 z = (0.0, 0.0);
+
+
+ for (i = 0; i < 254; 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[x+1024*y] = i;
}