cancel
Showing results for 
Search instead for 
Did you mean: 

Archives Discussions

twiig
Journeyman III

opencl function problems

So, I have a chunk of code that generates a ray for ray tracing purposes, but when I move the ray creation to its own function, it no longer works.  Literally, I can move the exact same chunk of code to a function that returns the created ray, and it no longer works.

Any ideas?

ie, //works fine <create ray code>; <use ray code>; //doesnt work Ray CreateRay() { <create ray code>; return ray; } ... Ray ray = CreateRay(); <use ray code>

0 Likes
6 Replies
nou
Exemplar

IIRC there was some issue if function return struct.

0 Likes

We should not have any trouble with structs. If you can't post your code publicly, please send a test case to streamdeveloper@amd.com Re: Micah Villmow and i'll see what is wrong with your kernel.
0 Likes

no problem posting the code ... nothing too new here.  Thanks for the help!

ps. I left out some code, because if you were going to run the whole project it would be very difficult as I use a custom 3D API to setup the project.

typedef struct { float length; float4 origin; float4 direction; } clRay; float4 GenerateRay(float width, float height, float near, float far, float rx, float ry, float rz, float16 mat) { rx = rx * 2.0f / width - 1.0f; ry = ry * 2.0f / height - 1.0f; rz = rz * 2.0f - 1.0f; float rw = mat.sc*rx + mat.sd*ry + mat.se*rz + mat.sf; rw = (rw == 0.0f ? 1.0f : rw); float4 v; v.x = (mat.s0*rx + mat.s1*ry + mat.s2*rz + mat.s3) / rw; v.y = (mat.s4*rx + mat.s5*ry + mat.s6*rz + mat.s7) / rw; v.z = (mat.s8*rx + mat.s9*ry + mat.sa*rz + mat.sb) / rw; v.w = 1.0f; return v; } clRay GenerateReverseOrthographicRay(const float width, const float height, const float near, const float far, const float4 eye_or_dir, const float16 inverseViewProjection, float x, float y, float depth) { float rz = (depth - near) / (far - near); float4 point = GenerateRay(width, height, near, far, x, y, rz, inverseViewProjection); clRay ray; ray.origin = point; ray.direction = eye_or_dir; ray.length = depth - near; return ray; } //this works __kernel void TraceRay0(const int width, const int height, const float near, const float far, const float4 eye_or_dir, const float16 inverseViewProjection, , const float4 nvoxels, const float vsize, const __global float *depths, __global clVoxel *voxels) { ... float rz = (depth - near) / (far - near); float4 point = GenerateRay(width, height, near, far, x, y, rz, inverseViewProjection); clRay ray; ray.origin = point; ray.direction = eye_or_dir; ray.length = depth - near; ... } //this does not work __kernel void TraceRay1(const int width, const int height, const float near, const float far, const float4 eye_or_dir, const float16 inverseViewProjection, , const float4 nvoxels, const float vsize, const __global float *depths, __global clVoxel *voxels) { ... clRay ray = GenerateReverseOrthographicRay(width, height, near, far, eye_or_dir, inverseViewProjection, x, y, depth); ... }

0 Likes

twiig,
Can you make a CL kernel that is all inclusive and compiles? That way I don't have to guess about your intentions and can more accurately reproduce your issue.

Thanks,
Micah
0 Likes

sure, but it relies on a fair amount of setup from the outside ... I should keep it off the message board though, so I will email.  Thanks!

0 Likes

looks like I missed check-point #3 in the 'don't be a stupid developer' handbook and didn't have the latest sdk.

thanks for the help!

0 Likes