Can someone help me? I call this function from my kernel function:
colorin traceray(ray ray, scene scene, __global triangle * pt, __global light * pl)
{
colorin background = makecolorin(0, 0, 0);
colorin defaultcolorin = makecolorin(0, 1, 0);
bool isnull = true;
inter i; i.isnull = true;
for (int j = 0; j < MAXNTRIANGLE; j++)
{
triangle obj = pt[j];
vec E1 = vminus(obj.v2,obj.v1);
vec E2 = vminus(obj.v3,obj.v1);
vec pt_int = makevec(0,0,0);
vec normal = vcross(E1,E2);
float dotprod = vdot(normal,ray.dir);
float dist = 0.0f;
if(dotprod < 0)
{
dist = -vdot(normal, inus(ray.start,obj.v1))/vdot(normal,ray.dir);
if(dist < 0) return background;
pt_int = vplus(ray.start, times(dist,ray.dir));
if ((vdot(vcross(vminus(obj.v2,obj.v1), vminus(pt_int,obj.v1)), normal) >= 0)
&& (vdot(vcross(vminus(obj.v3,obj.v2), vminus(pt_int,obj.v2)), normal) >= 0)
&& (vdot(vcross(vminus(obj.v1,obj.v3), vminus(pt_int,obj.v3)), normal) >= 0))
{isnull = false; i.isnull = false;}
}
}
i.isnull = isnull;
if (!(i.isnull)) return defaultcolorin;
return background;
}
After “i.isnull = false” I have access to “i.isnull” only inside block {isnull = false; i.isnull = false;}. But I have full access to bool variable “isnull” inside full function area.
What’s wrong with “struct inter i”? Why I can’t use it’s bool field “i.isnull” as real bool value “isnull”?
There is my struct:
typedef struct inter { bool isnull; triangle thing; ray ray; float dist; vec normal; } inter;
I attach my full kernel code
dataParallel.txt (8.9 KB)