Can't for the life of me get this to work. It's real darn good at crashing my computer though. Probably all those waits...
This commit is contained in:
@@ -301,7 +301,7 @@ int main(int argc, char* argv[])
|
||||
|
||||
int err = 0;
|
||||
|
||||
cl_mem frontBuffer = clCreateFromGLTexture(context , CL_MEM_READ_WRITE, GL_TEXTURE_2D, 0, texture, &err);
|
||||
cl_mem frontBuffer = clCreateFromGLTexture(context , CL_MEM_WRITE_ONLY, GL_TEXTURE_2D, 0, texture, &err);
|
||||
|
||||
cl_mem workerCountBuffer = clCreateBuffer(context, CL_MEM_READ_ONLY | CL_MEM_COPY_HOST_PTR, sizeof(int), &WORKER_SIZE, &err);
|
||||
cl_mem gridWidthBuffer = clCreateBuffer(context, CL_MEM_READ_ONLY | CL_MEM_COPY_HOST_PTR, sizeof(int), &GRID_WIDTH, &err);
|
||||
@@ -335,13 +335,13 @@ int main(int argc, char* argv[])
|
||||
size_t global_work_size[1] = { 10 };
|
||||
|
||||
status = clEnqueueAcquireGLObjects(commandQueue, 1, &frontBuffer, 0, 0, 0);
|
||||
|
||||
glFinish();
|
||||
status = clEnqueueNDRangeKernel(commandQueue, compute_kernel, 1, NULL, global_work_size, NULL, 0, NULL, NULL);
|
||||
|
||||
glFinish();
|
||||
//status = clEnqueueReadBuffer(commandQueue, frontBuffer, CL_TRUE, 0, GRID_WIDTH * GRID_HEIGHT * 4 * sizeof(unsigned char), (void*)pixel_array, 0, NULL, NULL);
|
||||
|
||||
status = clEnqueueReleaseGLObjects(commandQueue, 1, &frontBuffer, 0, NULL, NULL);
|
||||
|
||||
glFinish();
|
||||
|
||||
// ======================================= Rendering Shtuff =================================================
|
||||
|
||||
|
||||
@@ -1,21 +1,25 @@
|
||||
__kernel void conway_compute(__global unsigned char* front_grid, __global int* num_workers, __global int* grid_width, __global int* grid_height)
|
||||
__kernel void conway_compute(__write_only image2d_t front_grid, __global int* num_workers, __global int* grid_width, __global int *grid_height)
|
||||
{
|
||||
|
||||
//int width = *grid_width;
|
||||
//int height = grid_height;
|
||||
|
||||
int2 pixelcoord = (int2) (get_global_id(0), get_global_id(1));
|
||||
//if (pixelcoord.x < width && pixelcoord.y < height)
|
||||
//{
|
||||
//float4 pixel = read_imagef(image1, sampler, (int2)(pixelcoord.x, pixelcoord.y));
|
||||
float4 black = (float4)(0,0,0,0);
|
||||
|
||||
|
||||
// write_imagef(front_grid, pixelcoord, black);
|
||||
|
||||
|
||||
int num = *grid_width * *grid_height * 4;
|
||||
|
||||
for (int i = 0; i < num ; i += 4){
|
||||
|
||||
front_grid[i] = 0;
|
||||
front_grid[i + 1] = 0;
|
||||
front_grid[i + 2] = 0;
|
||||
front_grid[i + 3] = 0;
|
||||
|
||||
write_imagef(front_grid, pixelcoord, black);
|
||||
//
|
||||
}
|
||||
|
||||
front_grid[90000] = 0;
|
||||
front_grid[90001] = 0;
|
||||
front_grid[90002] = 0;
|
||||
front_grid[90003] = 0;
|
||||
front_grid[90004] = 0;
|
||||
front_grid[90005] = 0;
|
||||
front_grid[90006] = 0;
|
||||
//}
|
||||
}
|
||||
Reference in New Issue
Block a user