I have the following struct in the kernel
err = clEnqueueReadBuffer(queue, fragments_buf_mem, CL_TRUE, 0, width * height*sizeof(Fragment), &fragments[0], 0, NULL, &kernel_event);
fragments_buf_mem = clCreateBuffer(context, CL_MEM_READ_WRITE, width * height*sizeof(Fragment), NULL, &err);
struct Fragment {
float pos[3];
float nor[3];
float col[3];
bool isCovered;
};
I'm trying to assing a global fragments buffer locally to a struct
Kernel definition
__kernel void fragment_shader(__global struct Fragment* fragments, __global struct Triangle_* triangles, int triCount)
Inside the kernel I'm trying to define a local structure and assign variables to it struct Fragment f;
f.pos[0] = (float)w0 * v0Raster.y;
/*
f.pos[1] = (float)w1 * v1Raster.y;
f.pos[2] = (float)w2 * v2Raster.z;
f.nor[0] = (float)w0 * v1Raster_n.x;
f.nor[1] = (float)w1 * v1Raster_n.y;
f.nor[2] = (float)w2 * v2Raster_n.z;
f.col[0] = (float)w0 * v1Raster_c.x;
f.col[1] = (float)w1 * v1Raster_c.y;
f.col[2] = (float)w2 * v2Raster_c.z;
*/
fragments[x + y * imageWidth] = f;
I can't enqueue the kernel and I get an exception. However when I remove the commented code, and just use f <-- struct alone, I can enqueue the kernel, only we setting data to the local structure fragment, I get a crash.