hello,
i am very new to CUDA, so my apologies if my problem is obvious. i’ve been just getting familiar with cuda, and life was good until i started getting this “'unspecified launch error”. i’ve narrowed the problem down to 2 sections of code…if i uncomment either section it errors out and (sometimes) requires a hard reboot.
i’ve marked the problem sections with a ‘// <-------------’
// performs ray-sphere intersection
__device__ float getSphereIntersection(float3 *rayPos, float3 *rayDir, float3 *sPos, float sRadius) {
float retVal = NO_INTERSECTION;
float a, b, c, root, omega1, omega2;
normalizeRay(rayPos, rayDir);
float x = rayPos->x;
float y = rayPos->y;
float z = rayPos->z;
float sphereX = sPos->x;
float sphereY = sPos->y;
float sphereZ = sPos->z;
float dx = rayDir->x;
float dy = rayDir->y;
float dz = rayDir->z;
a = (dx * dx) + (dy * dy) + (dz * dz);
b = 2 * (dx * (x - sphereX) + dy * (y - sphereY) + dz * (z - sphereZ));
c = (x - sphereX) * (x - sphereX) + (y - sphereY) * (y - sphereY) + (z - sphereZ) * (z - sphereZ) -
sRadius * sRadius;
root = b*b - 4*c;
// no intersection
if (root < 0) {
retVal = NO_INTERSECTION;
}
if (root == 0) {
//retVal = -b + sqrtf(root)/2;
//return -b; // <-------------
}
if (root > 0) {
root = sqrtf(root);
omega1 = (-b + root)/(2);
omega2 = (-b - root)/(2);
// .01 to allow for error
/*if ((omega1 < 0.01) && (omega2 < 0.01) ){ // <-------------
retVal = NO_INTERSECTION;
}else if( (omega2 < .01 || omega1 <= omega2) && (omega1 > 0.01)){
retVal = omega1;
}else if( (omega1 < .01 || omega2 <= omega1) && (omega2 > 0.01)){
retVal = omega2;
}
*/
}
return retVal;
}
let me know if more code is required. any help would be greatly appreciated!