change lcpp Lua preprocessor, to keep #defines and comments, remove empty lines

remove duplicate data in b3Contact4 (now in btContact4Data shared between CPU/C++ and OpenCL)
OpenCL kernels use #include "Bullet3Collision/NarrowPhaseCollision/shared/b3Contact4Data.h"
Increase number of batches back to 250 (from 50), need to fix this hard coded number (see https://github.com/erwincoumans/bullet3/issues/12)
Work towards GJK/EPA, in addition to SAT/clipping (early on)
This commit is contained in:
erwincoumans
2013-08-08 12:24:09 -07:00
parent 46a08e3282
commit 3bf003ace1
50 changed files with 920 additions and 2731 deletions

View File

@@ -2,22 +2,18 @@
static const char* sapFastCL= \
"/*\n"
"Copyright (c) 2012 Advanced Micro Devices, Inc. \n"
"\n"
"This software is provided 'as-is', without any express or implied warranty.\n"
"In no event will the authors be held liable for any damages arising from the use of this software.\n"
"Permission is granted to anyone to use this software for any purpose, \n"
"including commercial applications, and to alter it and redistribute it freely, \n"
"subject to the following restrictions:\n"
"\n"
"1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.\n"
"2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.\n"
"3. This notice may not be removed or altered from any source distribution.\n"
"*/\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"
" union\n"
@@ -33,7 +29,6 @@ static const char* sapFastCL= \
" int m_maxIndices[4];\n"
" };\n"
"} btAabbCL;\n"
"\n"
"typedef struct \n"
"{\n"
" union\n"
@@ -41,7 +36,6 @@ static const char* sapFastCL= \
" unsigned int m_key;\n"
" unsigned int x;\n"
" };\n"
"\n"
" union\n"
" {\n"
" unsigned int m_value;\n"
@@ -49,8 +43,6 @@ static const char* sapFastCL= \
" \n"
" };\n"
"}b3SortData;\n"
"\n"
"\n"
"/// conservative test for overlap between two aabbs\n"
"bool TestAabbAgainstAabb2(const btAabbCL* aabb1, __local const btAabbCL* aabb2);\n"
"bool TestAabbAgainstAabb2(const btAabbCL* aabb1, __local const btAabbCL* aabb2)\n"
@@ -65,7 +57,6 @@ static const char* sapFastCL= \
" overlap = (aabb1->m_min.y > aabb2->m_max.y || aabb1->m_max.y < aabb2->m_min.y) ? false : overlap;\n"
" return overlap;\n"
"}\n"
"\n"
"__kernel void computePairsIncremental3dSapKernel( __global const uint2* objectMinMaxIndexGPUaxis0,\n"
" __global const uint2* objectMinMaxIndexGPUaxis1,\n"
" __global const uint2* objectMinMaxIndexGPUaxis2,\n"
@@ -88,7 +79,6 @@ static const char* sapFastCL= \
" int i = get_global_id(0);\n"
" if (i>=numObjects)\n"
" return;\n"
"\n"
" __global const uint2* objectMinMaxIndexGPU[3][2];\n"
" objectMinMaxIndexGPU[0][0]=objectMinMaxIndexGPUaxis0;\n"
" objectMinMaxIndexGPU[1][0]=objectMinMaxIndexGPUaxis1;\n"
@@ -96,7 +86,6 @@ static const char* sapFastCL= \
" objectMinMaxIndexGPU[0][1]=objectMinMaxIndexGPUaxis0prev;\n"
" objectMinMaxIndexGPU[1][1]=objectMinMaxIndexGPUaxis1prev;\n"
" objectMinMaxIndexGPU[2][1]=objectMinMaxIndexGPUaxis2prev;\n"
"\n"
" __global const b3SortData* sortedAxisGPU[3][2];\n"
" sortedAxisGPU[0][0] = sortedAxisGPU0;\n"
" sortedAxisGPU[1][0] = sortedAxisGPU1;\n"
@@ -104,20 +93,16 @@ static const char* sapFastCL= \
" sortedAxisGPU[0][1] = sortedAxisGPU0prev;\n"
" sortedAxisGPU[1][1] = sortedAxisGPU1prev;\n"
" sortedAxisGPU[2][1] = sortedAxisGPU2prev;\n"
"\n"
" int m_currentBuffer = 0;\n"
"\n"
" for (int axis=0;axis<3;axis++)\n"
" {\n"
" //int i = checkObjects[a];\n"
"\n"
" unsigned int curMinIndex = objectMinMaxIndexGPU[axis][m_currentBuffer][i].x;\n"
" unsigned int curMaxIndex = objectMinMaxIndexGPU[axis][m_currentBuffer][i].y;\n"
" unsigned int prevMinIndex = objectMinMaxIndexGPU[axis][1-m_currentBuffer][i].x;\n"
" int dmin = curMinIndex - prevMinIndex;\n"
" \n"
" unsigned int prevMaxIndex = objectMinMaxIndexGPU[axis][1-m_currentBuffer][i].y;\n"
"\n"
" int dmax = curMaxIndex - prevMaxIndex;\n"
" \n"
" for (int otherbuffer = 0;otherbuffer<2;otherbuffer++)\n"
@@ -132,23 +117,18 @@ static const char* sapFastCL= \
" if (otherIndex!=i)\n"
" {\n"
" bool otherIsMax = ((otherIndex2&1)!=0);\n"
"\n"
" if (otherIsMax)\n"
" {\n"
" \n"
" bool overlap = true;\n"
"\n"
" for (int ax=0;ax<3;ax++)\n"
" {\n"
" if ((objectMinMaxIndexGPU[ax][m_currentBuffer][i].x > objectMinMaxIndexGPU[ax][m_currentBuffer][otherIndex].y) ||\n"
" (objectMinMaxIndexGPU[ax][m_currentBuffer][i].y < objectMinMaxIndexGPU[ax][m_currentBuffer][otherIndex].x))\n"
" overlap=false;\n"
" }\n"
"\n"
" // b3Assert(overlap2==overlap);\n"
"\n"
" bool prevOverlap = true;\n"
"\n"
" for (int ax=0;ax<3;ax++)\n"
" {\n"
" if ((objectMinMaxIndexGPU[ax][1-m_currentBuffer][i].x > objectMinMaxIndexGPU[ax][1-m_currentBuffer][otherIndex].y) ||\n"
@@ -156,11 +136,8 @@ static const char* sapFastCL= \
" prevOverlap=false;\n"
" }\n"
" \n"
"\n"
" //b3Assert(overlap==overlap2);\n"
" \n"
"\n"
"\n"
" if (dmin<0)\n"
" {\n"
" if (overlap && !prevOverlap)\n"
@@ -185,10 +162,8 @@ static const char* sapFastCL= \
" addedHostPairsGPU[curPair].y = newPair.y;\n"
" addedHostPairsGPU[curPair].z = NEW_PAIR_MARKER;\n"
" addedHostPairsGPU[curPair].w = NEW_PAIR_MARKER;\n"
"\n"
" }\n"
" }\n"
"\n"
" }\n"
" } \n"
" else\n"
@@ -216,7 +191,6 @@ static const char* sapFastCL= \
" removedHostPairsGPU[curPair].y = removedPair.y;\n"
" removedHostPairsGPU[curPair].z = REMOVED_PAIR_MARKER;\n"
" removedHostPairsGPU[curPair].w = REMOVED_PAIR_MARKER;\n"
"\n"
" }\n"
" }\n"
" }\n"
@@ -240,7 +214,6 @@ static const char* sapFastCL= \
" {\n"
" \n"
" bool overlap = true;\n"
"\n"
" for (int ax=0;ax<3;ax++)\n"
" {\n"
" if ((objectMinMaxIndexGPU[ax][m_currentBuffer][i].x > objectMinMaxIndexGPU[ax][m_currentBuffer][otherIndex].y) ||\n"
@@ -248,9 +221,7 @@ static const char* sapFastCL= \
" overlap=false;\n"
" }\n"
" //b3Assert(overlap2==overlap);\n"
"\n"
" bool prevOverlap = true;\n"
"\n"
" for (int ax=0;ax<3;ax++)\n"
" {\n"
" if ((objectMinMaxIndexGPU[ax][1-m_currentBuffer][i].x > objectMinMaxIndexGPU[ax][1-m_currentBuffer][otherIndex].y) ||\n"
@@ -258,7 +229,6 @@ static const char* sapFastCL= \
" prevOverlap=false;\n"
" }\n"
" \n"
"\n"
" if (dmax>0)\n"
" {\n"
" if (overlap && !prevOverlap)\n"
@@ -283,7 +253,6 @@ static const char* sapFastCL= \
" addedHostPairsGPU[curPair].y = newPair.y;\n"
" addedHostPairsGPU[curPair].z = NEW_PAIR_MARKER;\n"
" addedHostPairsGPU[curPair].w = NEW_PAIR_MARKER;\n"
"\n"
" }\n"
" }\n"
" \n"
@@ -326,16 +295,12 @@ static const char* sapFastCL= \
" }\n"
" }//for (int otherbuffer\n"
" }//for (int axis=0;\n"
"\n"
"\n"
"}\n"
"\n"
"//computePairsKernelBatchWrite\n"
"__kernel void computePairsKernel( __global const btAabbCL* aabbs, volatile __global int4* pairsOut,volatile __global int* pairCount, int numObjects, int axis, int maxPairs)\n"
"{\n"
" int i = get_global_id(0);\n"
" int localId = get_local_id(0);\n"
"\n"
" __local int numActiveWgItems[1];\n"
" __local int breakRequest[1];\n"
" __local btAabbCL localAabbs[128];// = aabbs[i];\n"
@@ -411,7 +376,6 @@ static const char* sapFastCL= \
" tmpPair.y = myPairs[p].y;\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"