Another roadblock. After one iteration the neighbor count gets corrupted and starts spitting out random negative values.

This commit is contained in:
2016-01-10 16:48:26 -08:00
parent 1b379e095e
commit ed04d13d7b
3 changed files with 41 additions and 28 deletions

View File

@@ -1,8 +1,8 @@
__kernel void conway_compute(__write_only image2d_t front_image, __global char* back_image, __global int* num_workers, __global int* grid_width, __global int *grid_height)
{
float4 black = (float4)(.49, .68, .81, 1);
float4 white = (float4)(.49, .68, .71, .3);
float4 black = (float4)(0.49, 0.68, 0.81, 1.0);
float4 white = (float4)(1.0, 1.00, 1.0, 0.5);
// Caclulate the start and end range that this worker will be calculating
int data_length = *grid_width * *grid_height;
@@ -26,10 +26,10 @@ __kernel void conway_compute(__write_only image2d_t front_image, __global char*
// Top right
neighbors += back_image[i - *grid_width + 1];
// Right
/// Right
neighbors += back_image[i + 1];
// Bottom Right
/// Bottom Right
neighbors += back_image[i + *grid_width + 1];
// Bottom
@@ -47,13 +47,14 @@ __kernel void conway_compute(__write_only image2d_t front_image, __global char*
// push living status to the padded second char
write_imagef(front_image, pixelcoord, black);
if (neighbors == 3 || (neighbors == 2 && back_image[i])){
//write_imagef(front_image, pixelcoord, black);
if (neighbors == 3 || (neighbors == 2 && back_image[i] == 1) || back_image[i] < 0){
write_imagef(front_image, pixelcoord, white);
}
//else
//write_imagei(front_image, pixelcoord, white);
else{
write_imagef(front_image, pixelcoord, black);
}
}
}