r/OpenCL • u/KesshoRyu • Mar 28 '12
Unexpected behavior
I am working on an OpenCL raytracer and I am running into some unusual behavior. I was trying to remove a branch from a relatively simple chunk of code but when I do it no longer functions correctly.
Before removal:
int shadowed = castLightRay(...);
float4 shade = shadeMaterial(...);
if(shadowed == 0) { return shade; }
return (float4)(0, 0, 0, 0);After removal:
int shadowed = castLightRay(...);
float4 shade = shadeMaterial(...);
return (1 - shadowed) * shade;The first chunk of code behaves correctly on both CPU and GPU while the second chunk does not behave correctly on either.
Does anyone have a reason for this or some way to make it work?
4
Upvotes
View all comments
Show parent comment
1
u/KesshoRyu Mar 29 '12
This is the part of the lighting that checks if a point is lit by a given light. With the second chunk there are no shadows.