add gjk/epa (host only), possibly improve convex-convex with many edge-edge tests

more preparation towards persistent/incremental contact cache
This commit is contained in:
erwincoumans
2013-07-31 23:22:43 -07:00
parent 7992ff816b
commit 34de49d8a4
24 changed files with 3020 additions and 118 deletions

View File

@@ -13,6 +13,7 @@ subject to the following restrictions:
*/
//Originally written by Erwin Coumans
#define NEW_PAIR_MARKER -1
typedef struct
{
@@ -87,6 +88,9 @@ __kernel void computePairsKernelTwoArrays( __global const btAabbCL* unsortedAa
myPair.x = xIndex;
myPair.y = yIndex;
myPair.z = NEW_PAIR_MARKER;
myPair.w = NEW_PAIR_MARKER;
int curPair = atomic_inc (pairCount);
if (curPair<maxPairs)
@@ -112,7 +116,9 @@ __kernel void computePairsKernelOriginal( __global const btAabbCL* aabbs, vola
int4 myPair;
myPair.x = aabbs[i].m_minIndices[3];
myPair.y = aabbs[j].m_minIndices[3];
myPair.z = NEW_PAIR_MARKER;
myPair.w = NEW_PAIR_MARKER;
int curPair = atomic_inc (pairCount);
if (curPair<maxPairs)
{
@@ -176,6 +182,9 @@ __kernel void computePairsKernelBarrier( __global const btAabbCL* aabbs, volat
int4 myPair;
myPair.x = aabbs[i].m_minIndices[3];
myPair.y = aabbs[j].m_minIndices[3];
myPair.z = NEW_PAIR_MARKER;
myPair.w = NEW_PAIR_MARKER;
int curPair = atomic_inc (pairCount);
if (curPair<maxPairs)
{
@@ -251,6 +260,9 @@ __kernel void computePairsKernelLocalSharedMemory( __global const btAabbCL* aa
int4 myPair;
myPair.x = myAabb.m_minIndices[3];
myPair.y = localAabbs[localCount+localId+1].m_minIndices[3];
myPair.z = NEW_PAIR_MARKER;
myPair.w = NEW_PAIR_MARKER;
int curPair = atomic_inc (pairCount);
if (curPair<maxPairs)
{

View File

@@ -13,6 +13,8 @@ subject to the following restrictions:
*/
//Originally written by Erwin Coumans
#define NEW_PAIR_MARKER -1
#define REMOVED_PAIR_MARKER -2
typedef struct
{
@@ -177,9 +179,11 @@ __kernel void computePairsIncremental3dSapKernel( __global const uint2* object
int curPair = atomic_inc(addedHostPairsCount);
if (curPair<maxCapacity)
{
addedHostPairsGPU[curPair].x = newPair.x;
addedHostPairsGPU[curPair].y = newPair.y;
addedHostPairsGPU[curPair].z = NEW_PAIR_MARKER;
addedHostPairsGPU[curPair].w = NEW_PAIR_MARKER;
}
}
@@ -208,6 +212,8 @@ __kernel void computePairsIncremental3dSapKernel( __global const uint2* object
removedHostPairsGPU[curPair].x = removedPair.x;
removedHostPairsGPU[curPair].y = removedPair.y;
removedHostPairsGPU[curPair].z = REMOVED_PAIR_MARKER;
removedHostPairsGPU[curPair].w = REMOVED_PAIR_MARKER;
}
}
@@ -273,6 +279,9 @@ __kernel void computePairsIncremental3dSapKernel( __global const uint2* object
addedHostPairsGPU[curPair].x = newPair.x;
addedHostPairsGPU[curPair].y = newPair.y;
addedHostPairsGPU[curPair].z = NEW_PAIR_MARKER;
addedHostPairsGPU[curPair].w = NEW_PAIR_MARKER;
}
}
@@ -301,6 +310,8 @@ __kernel void computePairsIncremental3dSapKernel( __global const uint2* object
removedHostPairsGPU[curPair].x = removedPair.x;
removedHostPairsGPU[curPair].y = removedPair.y;
removedHostPairsGPU[curPair].z = REMOVED_PAIR_MARKER;
removedHostPairsGPU[curPair].w = REMOVED_PAIR_MARKER;
}
}
@@ -396,7 +407,9 @@ __kernel void computePairsKernel( __global const btAabbCL* aabbs, volatile __g
int4 tmpPair;
tmpPair.x = myPairs[p].x;
tmpPair.y = myPairs[p].y;
tmpPair.z = NEW_PAIR_MARKER;
tmpPair.w = NEW_PAIR_MARKER;
pairsOut[curPair+p] = tmpPair; //flush to main memory
}
}
@@ -430,7 +443,8 @@ __kernel void computePairsKernel( __global const btAabbCL* aabbs, volatile __g
int4 tmpPair;
tmpPair.x = myPairs[p].x;
tmpPair.y = myPairs[p].y;
tmpPair.z = NEW_PAIR_MARKER;
tmpPair.w = NEW_PAIR_MARKER;
pairsOut[curPair+p] = tmpPair; //flush to main memory
}
}

View File

@@ -15,6 +15,8 @@ static const char* sapFastCL= \
"*/\n"
"//Originally written by Erwin Coumans\n"
"\n"
"#define NEW_PAIR_MARKER -1\n"
"#define REMOVED_PAIR_MARKER -2\n"
"\n"
"typedef struct \n"
"{\n"
@@ -179,9 +181,11 @@ static const char* sapFastCL= \
" int curPair = atomic_inc(addedHostPairsCount);\n"
" if (curPair<maxCapacity)\n"
" {\n"
" \n"
" addedHostPairsGPU[curPair].x = newPair.x;\n"
" addedHostPairsGPU[curPair].y = newPair.y;\n"
" addedHostPairsGPU[curPair].z = NEW_PAIR_MARKER;\n"
" addedHostPairsGPU[curPair].w = NEW_PAIR_MARKER;\n"
"\n"
" }\n"
" }\n"
"\n"
@@ -210,6 +214,8 @@ static const char* sapFastCL= \
" \n"
" removedHostPairsGPU[curPair].x = removedPair.x;\n"
" removedHostPairsGPU[curPair].y = removedPair.y;\n"
" removedHostPairsGPU[curPair].z = REMOVED_PAIR_MARKER;\n"
" removedHostPairsGPU[curPair].w = REMOVED_PAIR_MARKER;\n"
"\n"
" }\n"
" }\n"
@@ -275,6 +281,9 @@ static const char* sapFastCL= \
" \n"
" addedHostPairsGPU[curPair].x = newPair.x;\n"
" addedHostPairsGPU[curPair].y = newPair.y;\n"
" addedHostPairsGPU[curPair].z = NEW_PAIR_MARKER;\n"
" addedHostPairsGPU[curPair].w = NEW_PAIR_MARKER;\n"
"\n"
" }\n"
" }\n"
" \n"
@@ -303,6 +312,8 @@ static const char* sapFastCL= \
" \n"
" removedHostPairsGPU[curPair].x = removedPair.x;\n"
" removedHostPairsGPU[curPair].y = removedPair.y;\n"
" removedHostPairsGPU[curPair].z = REMOVED_PAIR_MARKER;\n"
" removedHostPairsGPU[curPair].w = REMOVED_PAIR_MARKER;\n"
" }\n"
" }\n"
" \n"
@@ -398,7 +409,9 @@ static const char* sapFastCL= \
" int4 tmpPair;\n"
" tmpPair.x = myPairs[p].x;\n"
" tmpPair.y = myPairs[p].y;\n"
" \n"
" tmpPair.z = NEW_PAIR_MARKER;\n"
" tmpPair.w = NEW_PAIR_MARKER;\n"
"\n"
" pairsOut[curPair+p] = tmpPair; //flush to main memory\n"
" }\n"
" }\n"
@@ -432,7 +445,8 @@ static const char* sapFastCL= \
" int4 tmpPair;\n"
" tmpPair.x = myPairs[p].x;\n"
" tmpPair.y = myPairs[p].y;\n"
" \n"
" tmpPair.z = NEW_PAIR_MARKER;\n"
" tmpPair.w = NEW_PAIR_MARKER;\n"
" pairsOut[curPair+p] = tmpPair; //flush to main memory\n"
" }\n"
" }\n"

View File

@@ -15,6 +15,7 @@ static const char* sapCL= \
"*/\n"
"//Originally written by Erwin Coumans\n"
"\n"
"#define NEW_PAIR_MARKER -1\n"
"\n"
"typedef struct \n"
"{\n"
@@ -89,6 +90,9 @@ static const char* sapCL= \
" \n"
" myPair.x = xIndex;\n"
" myPair.y = yIndex;\n"
" myPair.z = NEW_PAIR_MARKER;\n"
" myPair.w = NEW_PAIR_MARKER;\n"
"\n"
"\n"
" int curPair = atomic_inc (pairCount);\n"
" if (curPair<maxPairs)\n"
@@ -114,7 +118,9 @@ static const char* sapCL= \
" int4 myPair;\n"
" myPair.x = aabbs[i].m_minIndices[3];\n"
" myPair.y = aabbs[j].m_minIndices[3];\n"
" \n"
" myPair.z = NEW_PAIR_MARKER;\n"
" myPair.w = NEW_PAIR_MARKER;\n"
"\n"
" int curPair = atomic_inc (pairCount);\n"
" if (curPair<maxPairs)\n"
" {\n"
@@ -178,6 +184,9 @@ static const char* sapCL= \
" int4 myPair;\n"
" myPair.x = aabbs[i].m_minIndices[3];\n"
" myPair.y = aabbs[j].m_minIndices[3];\n"
" myPair.z = NEW_PAIR_MARKER;\n"
" myPair.w = NEW_PAIR_MARKER;\n"
"\n"
" int curPair = atomic_inc (pairCount);\n"
" if (curPair<maxPairs)\n"
" {\n"
@@ -253,6 +262,9 @@ static const char* sapCL= \
" int4 myPair;\n"
" myPair.x = myAabb.m_minIndices[3];\n"
" myPair.y = localAabbs[localCount+localId+1].m_minIndices[3];\n"
" myPair.z = NEW_PAIR_MARKER;\n"
" myPair.w = NEW_PAIR_MARKER;\n"
"\n"
" int curPair = atomic_inc (pairCount);\n"
" if (curPair<maxPairs)\n"
" {\n"