fix OpenCL kernel: NVIDIA crashes in clBuildProgram and AMD reports an error 'irreducable flow detected" ?!?
ray-convex works on GPU
This commit is contained in:
@@ -171,11 +171,12 @@ bool rayConvex(float4 rayFromLocal, float4 rayToLocal, int numFaces, int faceOff
|
|||||||
{
|
{
|
||||||
rayFromLocal.w = 0.f;
|
rayFromLocal.w = 0.f;
|
||||||
rayToLocal.w = 0.f;
|
rayToLocal.w = 0.f;
|
||||||
|
bool result = true;
|
||||||
|
|
||||||
float exitFraction = *hitFraction;
|
float exitFraction = *hitFraction;
|
||||||
float enterFraction = -0.1f;
|
float enterFraction = -0.1f;
|
||||||
float4 curHitNormal = (float4)(0,0,0,0);
|
float4 curHitNormal = (float4)(0,0,0,0);
|
||||||
for (int i=0;i<numFaces;i++)
|
for (int i=0;i<numFaces && result;i++)
|
||||||
{
|
{
|
||||||
b3GpuFace face = faces[faceOffset+i];
|
b3GpuFace face = faces[faceOffset+i];
|
||||||
float fromPlaneDist = dot(rayFromLocal,face.m_plane)+face.m_plane.w;
|
float fromPlaneDist = dot(rayFromLocal,face.m_plane)+face.m_plane.w;
|
||||||
@@ -203,19 +204,21 @@ bool rayConvex(float4 rayFromLocal, float4 rayToLocal, int numFaces, int faceOff
|
|||||||
}
|
}
|
||||||
} else
|
} else
|
||||||
{
|
{
|
||||||
return false;
|
result = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (exitFraction <= enterFraction)
|
if (exitFraction <= enterFraction)
|
||||||
return false;
|
result = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (enterFraction < 0.f)
|
result = result && (enterFraction < 0.f);
|
||||||
return false;
|
|
||||||
|
|
||||||
*hitFraction = enterFraction;
|
if (result)
|
||||||
*hitNormal = curHitNormal;
|
{
|
||||||
return true;
|
*hitFraction = enterFraction;
|
||||||
|
*hitNormal = curHitNormal;
|
||||||
|
}
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -173,11 +173,12 @@ static const char* rayCastKernelCL= \
|
|||||||
"{\n"
|
"{\n"
|
||||||
" rayFromLocal.w = 0.f;\n"
|
" rayFromLocal.w = 0.f;\n"
|
||||||
" rayToLocal.w = 0.f;\n"
|
" rayToLocal.w = 0.f;\n"
|
||||||
"\n"
|
" bool result = true;\n"
|
||||||
|
" \n"
|
||||||
" float exitFraction = *hitFraction;\n"
|
" float exitFraction = *hitFraction;\n"
|
||||||
" float enterFraction = -0.1f;\n"
|
" float enterFraction = -0.1f;\n"
|
||||||
" float4 curHitNormal = (float4)(0,0,0,0);\n"
|
" float4 curHitNormal = (float4)(0,0,0,0);\n"
|
||||||
" for (int i=0;i<numFaces;i++)\n"
|
" for (int i=0;i<numFaces && result;i++)\n"
|
||||||
" {\n"
|
" {\n"
|
||||||
" b3GpuFace face = faces[faceOffset+i];\n"
|
" b3GpuFace face = faces[faceOffset+i];\n"
|
||||||
" float fromPlaneDist = dot(rayFromLocal,face.m_plane)+face.m_plane.w;\n"
|
" float fromPlaneDist = dot(rayFromLocal,face.m_plane)+face.m_plane.w;\n"
|
||||||
@@ -205,19 +206,21 @@ static const char* rayCastKernelCL= \
|
|||||||
" }\n"
|
" }\n"
|
||||||
" } else\n"
|
" } else\n"
|
||||||
" {\n"
|
" {\n"
|
||||||
" return false;\n"
|
" result = false;\n"
|
||||||
" }\n"
|
" }\n"
|
||||||
" }\n"
|
" }\n"
|
||||||
" if (exitFraction <= enterFraction)\n"
|
" if (exitFraction <= enterFraction)\n"
|
||||||
" return false;\n"
|
" result = false;\n"
|
||||||
" }\n"
|
" }\n"
|
||||||
"\n"
|
" \n"
|
||||||
" if (enterFraction < 0.f)\n"
|
" result = result && (enterFraction < 0.f);\n"
|
||||||
" return false;\n"
|
" \n"
|
||||||
"\n"
|
" if (result)\n"
|
||||||
" *hitFraction = enterFraction;\n"
|
" { \n"
|
||||||
" *hitNormal = curHitNormal;\n"
|
" *hitFraction = enterFraction;\n"
|
||||||
" return true;\n"
|
" *hitNormal = curHitNormal;\n"
|
||||||
|
" }\n"
|
||||||
|
" return result;\n"
|
||||||
"}\n"
|
"}\n"
|
||||||
"\n"
|
"\n"
|
||||||
"\n"
|
"\n"
|
||||||
|
|||||||
Reference in New Issue
Block a user