Hi, everyone.
I’m writing a test program which uses structures in a kernel and as its arguments.
I wrote the below OpenCL C program and added to a Xcode’s project.
If I try to debug the project, several errors appears for the CL program.
//------------------------------------------------------------
//Structures
typedef float* Vertex;
typedef float* Normal;
typedef struct Face {
uint v[3];// error! : Type name requires a specifier or qualifier. + Expected: ';' at the end of declaration list.
uint n[3];// error! : Type name requires a specifier or qualifier. + Expected: ';' at the end of declaration list.
} Face;
typedef struct Matrix4 {
float4 c[4];// error! : Type name requires a specifier or qualifier. + Expected: ';' at the end of declaration list.
} Matrix4;
typedef struct PerspectiveCamera {
float aspect;
float fovY;
float lensRadius;
float focalDistance;
Matrix4 transform;
} PerspectiveCamera;
//------------------------------------------------------------
//Functions
//------------------------------------------------------------
__kernel void simpleRayTracing(__constant Vertex* vertices,
__constant Normal* normals,
__constant Face* faces,
PerspectiveCamera camera,
__global uchar* result) {
int x = get_global_id(0);
int y = get_global_id(1);
int idx = y * get_global_size(0) + x;
uchar3 value = (uchar3)(faces[x % 12].v[0], faces[x % 12].v[1], faces[x % 12].v[2]);
vstore3(value, idx, result);
}
If I replace an array with actual variables, the errors disappears.
What should I do to make it correct ?
Thanks in advance.
And I’m sorry for my poor English.
OS X 10.8.4
Xcode 4.6.2
iMac 27-inch Mid 2011
CPU : Core i7 2600 3.4GHz
MEM : 16GB
GPU : Radeon HD 6970M 2GB
MacBook Air 11-inch Late 2010
CPU : Core 2 Duo SU9400 1.4GHz
MEM : 4GB
GPU : Geforce 320M