Hi:
When I compile a optix function:
__device__ __forceinline__ bool isPointOnLight(const MixedLight& light, const float3& point) {
if (light.type() != MixedLight::AREA_LIGHT)
return false;
float3 Q1 = light.v1 - light.v3;
float3 Q2 = light.v2 - light.v3;
float3 R = point - light.v3;
......
// check whether R = a Q1 b Q2 with a > 0, b > 0 and a b < 1
float aboveTheLine = R.y - (R.x * Q1.y / Q1.x);
float underTheLine = Q2.y - (Q1.y * Q2.x / Q1.x);
float b = aboveTheLine / underTheLine;
float a = (R.x - b * Q2.x) / Q1.x;
float Rz = a * Q1.z + b * Q2.z;
//check if Rz == R.z
Rz -= R.z;
if (Rz > scene_epsilon*10.f || Rz < -scene_epsilon*10.f)
return false;
return true;
}
It can be compiled successfully.
But when I add the same code with line 20 before “return true”, i.e. the function become:
__device__ __forceinline__ bool isPointOnLight(const MixedLight& light, const float3& point) {
if (light.type() != MixedLight::AREA_LIGHT)
return false;
float3 Q1 = light.v1 - light.v3;
float3 Q2 = light.v2 - light.v3;
float3 R = point - light.v3;
......
// check whether R = a Q1 b Q2 with a > 0, b > 0 and a b < 1
float aboveTheLine = R.y - (R.x * Q1.y / Q1.x);
float underTheLine = Q2.y - (Q1.y * Q2.x / Q1.x);
float b = aboveTheLine / underTheLine;
float a = (R.x - b * Q2.x) / Q1.x;
float Rz = a * Q1.z + b * Q2.z;
//check if Rz == R.z
Rz -= R.z;
if (Rz > scene_epsilon*10.f || Rz < -scene_epsilon*10.f)
return false;
if (Rz > scene_epsilon*10.f || Rz < -scene_epsilon*10.f)
return false;
return true;
}
The compiler throws a exception:
Unknown error (Details: Function \"_rtProgramCreateFromPTXFile\" caught exception: Assertion failed: \"ref != vlm->m_variables.end() : Found call before load/move\", [5571733])"
Does any one can help me to sovle the problem ?
Thanks!