allow PairBenchmark to select broadphase type, with cpu brute-force, gpu brute-force etc

fix issue in PairBench, related to index offset
allow to add a large AABB in PairBench, to see the effect on the broadphase pair search performance
This commit is contained in:
erwin coumans
2014-01-28 17:11:56 -08:00
parent 71f0537c6e
commit 33ebebd1c9
10 changed files with 413 additions and 114 deletions

View File

@@ -13,14 +13,14 @@ static const char* pairsKernelsCL= \
" __global float4* colors = &posOrnColors[numObjects*2];\n"
" colors[iGID] = (float4)(0,0,1,1);\n"
"}\n"
"__kernel void colorPairsKernel(__global float4* posOrnColors, int numObjects, __global const int4* pairs, int numPairs)\n"
"__kernel void colorPairsKernel2(__global float4* posOrnColors, int numObjects, __global const int4* pairs, int indexOffset, int numPairs)\n"
"{\n"
" int iPairId = get_global_id(0);\n"
" if (iPairId>=numPairs)\n"
" return;\n"
" __global float4* colors = &posOrnColors[numObjects*2];\n"
" int iObjectA = pairs[iPairId].x;\n"
" int iObjectB = pairs[iPairId].y;\n"
" int iObjectA = pairs[iPairId].x-indexOffset;\n"
" int iObjectB = pairs[iPairId].y-indexOffset;\n"
" colors[iObjectA] = (float4)(1,0,0,1);\n"
" colors[iObjectB] = (float4)(1,0,0,1);\n"
"}\n"
@@ -53,16 +53,25 @@ static const char* pairsKernelsCL= \
" int nodeId = get_global_id(0);\n"
" if( nodeId < numNodes )\n"
" {\n"
" \n"
" b3AABBCL orgAabbMin = pAABB[nodeId*2];\n"
" b3AABBCL orgAabbMax = pAABB[nodeId*2+1];\n"
" int orgNodeId = orgAabbMin.uw;\n"
" int orgBroadphaseIndex = orgAabbMax.uw;\n"
" \n"
" float4 position = posOrnColors[nodeId];\n"
" float4 halfExtents = (float4)(1.01f,1.01f,1.01f,0.f);\n"
" float4 argAabbMinVec = (float4)(orgAabbMin.fx,orgAabbMin.fy,orgAabbMin.fz,0.f);\n"
" float4 argAabbMaxVec = (float4)(orgAabbMax.fx,orgAabbMax.fy,orgAabbMax.fz,0.f);\n"
" float4 halfExtents = 0.5f*(argAabbMaxVec-argAabbMinVec);\n"
" \n"
" pAABB[nodeId*2].fx = position.x-halfExtents.x;\n"
" pAABB[nodeId*2].fy = position.y-halfExtents.y;\n"
" pAABB[nodeId*2].fz = position.z-halfExtents.z;\n"
" pAABB[nodeId*2].uw = nodeId;\n"
" pAABB[nodeId*2].uw = orgNodeId;\n"
" pAABB[nodeId*2+1].fx = position.x+halfExtents.x;\n"
" pAABB[nodeId*2+1].fy = position.y+halfExtents.y;\n"
" pAABB[nodeId*2+1].fz = position.z+halfExtents.z;\n"
" pAABB[nodeId*2+1].uw = nodeId; \n"
" pAABB[nodeId*2+1].uw = orgBroadphaseIndex; \n"
" }\n"
"}\n"
;