bt -> b3 and BT -> B3 rename for content and filenames

This commit is contained in:
erwin coumans
2013-04-28 23:11:10 -07:00
parent 6bcb5b9d5f
commit 7366e262fd
178 changed files with 5218 additions and 5218 deletions

View File

@@ -1,5 +1,5 @@
#ifndef BT_CONFIG_H
#define BT_CONFIG_H
#ifndef B3_CONFIG_H
#define B3_CONFIG_H
struct b3Config
{
@@ -36,5 +36,5 @@ struct b3Config
};
#endif//BT_CONFIG_H
#endif//B3_CONFIG_H

View File

@@ -1,11 +1,11 @@
#include "b3GpuBatchingPgsSolver.h"
#include "../../parallel_primitives/host/btRadixSort32CL.h"
#include "../../parallel_primitives/host/b3RadixSort32CL.h"
#include "Bullet3Common/b3Quickprof.h"
#include "../../parallel_primitives/host/btLauncherCL.h"
#include "../../parallel_primitives/host/btBoundSearchCL.h"
#include "../../parallel_primitives/host/btPrefixScanCL.h"
#include "../../parallel_primitives/host/b3LauncherCL.h"
#include "../../parallel_primitives/host/b3BoundSearchCL.h"
#include "../../parallel_primitives/host/b3PrefixScanCL.h"
#include <string.h>
#include "../../basic_initialize/b3OpenCLUtils.h"
#include "../host/b3Config.h"
@@ -30,10 +30,10 @@
enum
{
BT_SOLVER_N_SPLIT = 16,
BT_SOLVER_N_BATCHES = 4,
BT_SOLVER_N_OBJ_PER_SPLIT = 10,
BT_SOLVER_N_TASKS_PER_BATCH = BT_SOLVER_N_SPLIT*BT_SOLVER_N_SPLIT,
B3_SOLVER_N_SPLIT = 16,
B3_SOLVER_N_BATCHES = 4,
B3_SOLVER_N_OBJ_PER_SPLIT = 10,
B3_SOLVER_N_TASKS_PER_BATCH = B3_SOLVER_N_SPLIT*B3_SOLVER_N_SPLIT,
};
@@ -41,7 +41,7 @@ bool gpuBatchContacts = true;//true;
bool gpuSolveConstraint = true;//true;
struct btGpuBatchingPgsSolverInternalData
struct b3GpuBatchingPgsSolverInternalData
{
cl_context m_context;
cl_device_id m_device;
@@ -49,9 +49,9 @@ struct btGpuBatchingPgsSolverInternalData
int m_pairCapacity;
int m_nIterations;
btOpenCLArray<b3GpuConstraint4>* m_contactCGPU;
btOpenCLArray<unsigned int>* m_numConstraints;
btOpenCLArray<unsigned int>* m_offsets;
b3OpenCLArray<b3GpuConstraint4>* m_contactCGPU;
b3OpenCLArray<unsigned int>* m_numConstraints;
b3OpenCLArray<unsigned int>* m_offsets;
b3Solver* m_solverGPU;
@@ -64,20 +64,20 @@ struct btGpuBatchingPgsSolverInternalData
cl_kernel m_reorderContactKernel;
cl_kernel m_copyConstraintKernel;
class btRadixSort32CL* m_sort32;
class btBoundSearchCL* m_search;
class btPrefixScanCL* m_scan;
class b3RadixSort32CL* m_sort32;
class b3BoundSearchCL* m_search;
class b3PrefixScanCL* m_scan;
btOpenCLArray<btSortData>* m_sortDataBuffer;
btOpenCLArray<b3Contact4>* m_contactBuffer;
b3OpenCLArray<b3SortData>* m_sortDataBuffer;
b3OpenCLArray<b3Contact4>* m_contactBuffer;
btOpenCLArray<b3RigidBodyCL>* m_bodyBufferGPU;
btOpenCLArray<btInertiaCL>* m_inertiaBufferGPU;
btOpenCLArray<b3Contact4>* m_pBufContactOutGPU;
b3OpenCLArray<b3RigidBodyCL>* m_bodyBufferGPU;
b3OpenCLArray<b3InertiaCL>* m_inertiaBufferGPU;
b3OpenCLArray<b3Contact4>* m_pBufContactOutGPU;
b3AlignedObjectArray<unsigned int> m_idxBuffer;
b3AlignedObjectArray<btSortData> m_sortData;
b3AlignedObjectArray<b3SortData> m_sortData;
b3AlignedObjectArray<b3Contact4> m_old;
};
@@ -85,35 +85,35 @@ struct btGpuBatchingPgsSolverInternalData
b3GpuBatchingPgsSolver::b3GpuBatchingPgsSolver(cl_context ctx,cl_device_id device, cl_command_queue q,int pairCapacity)
{
m_data = new btGpuBatchingPgsSolverInternalData;
m_data = new b3GpuBatchingPgsSolverInternalData;
m_data->m_context = ctx;
m_data->m_device = device;
m_data->m_queue = q;
m_data->m_pairCapacity = pairCapacity;
m_data->m_nIterations = 4;
m_data->m_bodyBufferGPU = new btOpenCLArray<b3RigidBodyCL>(ctx,q);
m_data->m_inertiaBufferGPU = new btOpenCLArray<btInertiaCL>(ctx,q);
m_data->m_pBufContactOutGPU = new btOpenCLArray<b3Contact4>(ctx,q);
m_data->m_bodyBufferGPU = new b3OpenCLArray<b3RigidBodyCL>(ctx,q);
m_data->m_inertiaBufferGPU = new b3OpenCLArray<b3InertiaCL>(ctx,q);
m_data->m_pBufContactOutGPU = new b3OpenCLArray<b3Contact4>(ctx,q);
m_data->m_solverGPU = new b3Solver(ctx,device,q,512*1024);
m_data->m_sort32 = new btRadixSort32CL(ctx,device,m_data->m_queue);
m_data->m_scan = new btPrefixScanCL(ctx,device,m_data->m_queue,BT_SOLVER_N_SPLIT*BT_SOLVER_N_SPLIT);
m_data->m_search = new btBoundSearchCL(ctx,device,m_data->m_queue,BT_SOLVER_N_SPLIT*BT_SOLVER_N_SPLIT);
m_data->m_sort32 = new b3RadixSort32CL(ctx,device,m_data->m_queue);
m_data->m_scan = new b3PrefixScanCL(ctx,device,m_data->m_queue,B3_SOLVER_N_SPLIT*B3_SOLVER_N_SPLIT);
m_data->m_search = new b3BoundSearchCL(ctx,device,m_data->m_queue,B3_SOLVER_N_SPLIT*B3_SOLVER_N_SPLIT);
const int sortSize = BTNEXTMULTIPLEOF( pairCapacity, 512 );
const int sortSize = B3NEXTMULTIPLEOF( pairCapacity, 512 );
m_data->m_sortDataBuffer = new btOpenCLArray<btSortData>(ctx,m_data->m_queue,sortSize);
m_data->m_contactBuffer = new btOpenCLArray<b3Contact4>(ctx,m_data->m_queue);
m_data->m_sortDataBuffer = new b3OpenCLArray<b3SortData>(ctx,m_data->m_queue,sortSize);
m_data->m_contactBuffer = new b3OpenCLArray<b3Contact4>(ctx,m_data->m_queue);
m_data->m_numConstraints = new btOpenCLArray<unsigned int>(ctx,m_data->m_queue,BT_SOLVER_N_SPLIT*BT_SOLVER_N_SPLIT );
m_data->m_numConstraints->resize(BT_SOLVER_N_SPLIT*BT_SOLVER_N_SPLIT);
m_data->m_numConstraints = new b3OpenCLArray<unsigned int>(ctx,m_data->m_queue,B3_SOLVER_N_SPLIT*B3_SOLVER_N_SPLIT );
m_data->m_numConstraints->resize(B3_SOLVER_N_SPLIT*B3_SOLVER_N_SPLIT);
m_data->m_contactCGPU = new btOpenCLArray<b3GpuConstraint4>(ctx,q,pairCapacity);
m_data->m_contactCGPU = new b3OpenCLArray<b3GpuConstraint4>(ctx,q,pairCapacity);
m_data->m_offsets = new btOpenCLArray<unsigned int>( ctx,m_data->m_queue, BT_SOLVER_N_SPLIT*BT_SOLVER_N_SPLIT );
m_data->m_offsets->resize(BT_SOLVER_N_SPLIT*BT_SOLVER_N_SPLIT);
m_data->m_offsets = new b3OpenCLArray<unsigned int>( ctx,m_data->m_queue, B3_SOLVER_N_SPLIT*B3_SOLVER_N_SPLIT );
m_data->m_offsets->resize(B3_SOLVER_N_SPLIT*B3_SOLVER_N_SPLIT);
const char* additionalMacros = "";
const char* srcFileNameForCaching="";
@@ -132,54 +132,54 @@ b3GpuBatchingPgsSolver::b3GpuBatchingPgsSolver(cl_context ctx,cl_device_id devic
{
cl_program solveContactProg= b3OpenCLUtils::compileCLProgramFromString( ctx, device, solveContactSource, &pErrNum,additionalMacros, SOLVER_CONTACT_KERNEL_PATH);
btAssert(solveContactProg);
b3Assert(solveContactProg);
cl_program solveFrictionProg= b3OpenCLUtils::compileCLProgramFromString( ctx, device, solveFrictionSource, &pErrNum,additionalMacros, SOLVER_FRICTION_KERNEL_PATH);
btAssert(solveFrictionProg);
b3Assert(solveFrictionProg);
cl_program solverSetup2Prog= b3OpenCLUtils::compileCLProgramFromString( ctx, device, solverSetup2Source, &pErrNum,additionalMacros, SOLVER_SETUP2_KERNEL_PATH);
btAssert(solverSetup2Prog);
b3Assert(solverSetup2Prog);
cl_program solverSetupProg= b3OpenCLUtils::compileCLProgramFromString( ctx, device, solverSetupSource, &pErrNum,additionalMacros, SOLVER_SETUP_KERNEL_PATH);
btAssert(solverSetupProg);
b3Assert(solverSetupProg);
m_data->m_solveFrictionKernel= b3OpenCLUtils::compileCLKernelFromString( ctx, device, solveFrictionSource, "BatchSolveKernelFriction", &pErrNum, solveFrictionProg,additionalMacros );
btAssert(m_data->m_solveFrictionKernel);
b3Assert(m_data->m_solveFrictionKernel);
m_data->m_solveContactKernel= b3OpenCLUtils::compileCLKernelFromString( ctx, device, solveContactSource, "BatchSolveKernelContact", &pErrNum, solveContactProg,additionalMacros );
btAssert(m_data->m_solveContactKernel);
b3Assert(m_data->m_solveContactKernel);
m_data->m_contactToConstraintKernel = b3OpenCLUtils::compileCLKernelFromString( ctx, device, solverSetupSource, "ContactToConstraintKernel", &pErrNum, solverSetupProg,additionalMacros );
btAssert(m_data->m_contactToConstraintKernel);
b3Assert(m_data->m_contactToConstraintKernel);
m_data->m_setSortDataKernel = b3OpenCLUtils::compileCLKernelFromString( ctx, device, solverSetup2Source, "SetSortDataKernel", &pErrNum, solverSetup2Prog,additionalMacros );
btAssert(m_data->m_setSortDataKernel);
b3Assert(m_data->m_setSortDataKernel);
m_data->m_reorderContactKernel = b3OpenCLUtils::compileCLKernelFromString( ctx, device, solverSetup2Source, "ReorderContactKernel", &pErrNum, solverSetup2Prog,additionalMacros );
btAssert(m_data->m_reorderContactKernel);
b3Assert(m_data->m_reorderContactKernel);
m_data->m_copyConstraintKernel = b3OpenCLUtils::compileCLKernelFromString( ctx, device, solverSetup2Source, "CopyConstraintKernel", &pErrNum, solverSetup2Prog,additionalMacros );
btAssert(m_data->m_copyConstraintKernel);
b3Assert(m_data->m_copyConstraintKernel);
}
{
cl_program batchingProg = b3OpenCLUtils::compileCLProgramFromString( ctx, device, batchKernelSource, &pErrNum,additionalMacros, BATCHING_PATH);
btAssert(batchingProg);
b3Assert(batchingProg);
m_data->m_batchingKernel = b3OpenCLUtils::compileCLKernelFromString( ctx, device, batchKernelSource, "CreateBatches", &pErrNum, batchingProg,additionalMacros );
btAssert(m_data->m_batchingKernel);
b3Assert(m_data->m_batchingKernel);
}
{
cl_program batchingNewProg = b3OpenCLUtils::compileCLProgramFromString( ctx, device, batchKernelNewSource, &pErrNum,additionalMacros, BATCHING_NEW_PATH);
btAssert(batchingNewProg);
b3Assert(batchingNewProg);
m_data->m_batchingKernelNew = b3OpenCLUtils::compileCLKernelFromString( ctx, device, batchKernelNewSource, "CreateBatchesNew", &pErrNum, batchingNewProg,additionalMacros );
btAssert(m_data->m_batchingKernelNew);
b3Assert(m_data->m_batchingKernelNew);
}
@@ -216,9 +216,9 @@ b3GpuBatchingPgsSolver::~b3GpuBatchingPgsSolver()
struct btConstraintCfg
struct b3ConstraintCfg
{
btConstraintCfg( float dt = 0.f ): m_positionDrift( 0.005f ), m_positionConstraintCoeff( 0.2f ), m_dt(dt), m_staticIdx(0) {}
b3ConstraintCfg( float dt = 0.f ): m_positionDrift( 0.005f ), m_positionConstraintCoeff( 0.2f ), m_dt(dt), m_staticIdx(0) {}
float m_positionDrift;
float m_positionConstraintCoeff;
@@ -232,34 +232,34 @@ struct btConstraintCfg
void b3GpuBatchingPgsSolver::solveContactConstraint( const btOpenCLArray<b3RigidBodyCL>* bodyBuf, const btOpenCLArray<btInertiaCL>* shapeBuf,
btOpenCLArray<b3GpuConstraint4>* constraint, void* additionalData, int n ,int maxNumBatches,int numIterations)
void b3GpuBatchingPgsSolver::solveContactConstraint( const b3OpenCLArray<b3RigidBodyCL>* bodyBuf, const b3OpenCLArray<b3InertiaCL>* shapeBuf,
b3OpenCLArray<b3GpuConstraint4>* constraint, void* additionalData, int n ,int maxNumBatches,int numIterations)
{
btInt4 cdata = btMakeInt4( n, 0, 0, 0 );
b3Int4 cdata = b3MakeInt4( n, 0, 0, 0 );
{
const int nn = BT_SOLVER_N_SPLIT*BT_SOLVER_N_SPLIT;
const int nn = B3_SOLVER_N_SPLIT*B3_SOLVER_N_SPLIT;
cdata.x = 0;
cdata.y = maxNumBatches;//250;
int numWorkItems = 64*nn/BT_SOLVER_N_BATCHES;
int numWorkItems = 64*nn/B3_SOLVER_N_BATCHES;
#ifdef DEBUG_ME
SolverDebugInfo* debugInfo = new SolverDebugInfo[numWorkItems];
adl::btOpenCLArray<SolverDebugInfo> gpuDebugInfo(data->m_device,numWorkItems);
adl::b3OpenCLArray<SolverDebugInfo> gpuDebugInfo(data->m_device,numWorkItems);
#endif
{
BT_PROFILE("m_batchSolveKernel iterations");
B3_PROFILE("m_batchSolveKernel iterations");
for(int iter=0; iter<numIterations; iter++)
{
for(int ib=0; ib<BT_SOLVER_N_BATCHES; ib++)
for(int ib=0; ib<B3_SOLVER_N_BATCHES; ib++)
{
#ifdef DEBUG_ME
memset(debugInfo,0,sizeof(SolverDebugInfo)*numWorkItems);
@@ -268,26 +268,26 @@ void b3GpuBatchingPgsSolver::solveContactConstraint( const btOpenCLArray<b3Rigi
cdata.z = ib;
cdata.w = BT_SOLVER_N_SPLIT;
cdata.w = B3_SOLVER_N_SPLIT;
btLauncherCL launcher( m_data->m_queue, m_data->m_solveContactKernel );
b3LauncherCL launcher( m_data->m_queue, m_data->m_solveContactKernel );
#if 1
btBufferInfoCL bInfo[] = {
b3BufferInfoCL bInfo[] = {
btBufferInfoCL( bodyBuf->getBufferCL() ),
btBufferInfoCL( shapeBuf->getBufferCL() ),
btBufferInfoCL( constraint->getBufferCL() ),
btBufferInfoCL( m_data->m_numConstraints->getBufferCL() ),
btBufferInfoCL( m_data->m_offsets->getBufferCL() )
b3BufferInfoCL( bodyBuf->getBufferCL() ),
b3BufferInfoCL( shapeBuf->getBufferCL() ),
b3BufferInfoCL( constraint->getBufferCL() ),
b3BufferInfoCL( m_data->m_numConstraints->getBufferCL() ),
b3BufferInfoCL( m_data->m_offsets->getBufferCL() )
#ifdef DEBUG_ME
, btBufferInfoCL(&gpuDebugInfo)
, b3BufferInfoCL(&gpuDebugInfo)
#endif
};
launcher.setBuffers( bInfo, sizeof(bInfo)/sizeof(btBufferInfoCL) );
launcher.setBuffers( bInfo, sizeof(bInfo)/sizeof(b3BufferInfoCL) );
//launcher.setConst( cdata.x );
launcher.setConst( cdata.y );
launcher.setConst( cdata.z );
@@ -352,32 +352,32 @@ void b3GpuBatchingPgsSolver::solveContactConstraint( const btOpenCLArray<b3Rigi
bool applyFriction=true;
if (applyFriction)
{
BT_PROFILE("m_batchSolveKernel iterations2");
B3_PROFILE("m_batchSolveKernel iterations2");
for(int iter=0; iter<numIterations; iter++)
{
for(int ib=0; ib<BT_SOLVER_N_BATCHES; ib++)
for(int ib=0; ib<B3_SOLVER_N_BATCHES; ib++)
{
cdata.z = ib;
cdata.w = BT_SOLVER_N_SPLIT;
cdata.w = B3_SOLVER_N_SPLIT;
btBufferInfoCL bInfo[] = {
btBufferInfoCL( bodyBuf->getBufferCL() ),
btBufferInfoCL( shapeBuf->getBufferCL() ),
btBufferInfoCL( constraint->getBufferCL() ),
btBufferInfoCL( m_data->m_numConstraints->getBufferCL() ),
btBufferInfoCL( m_data->m_offsets->getBufferCL() )
b3BufferInfoCL bInfo[] = {
b3BufferInfoCL( bodyBuf->getBufferCL() ),
b3BufferInfoCL( shapeBuf->getBufferCL() ),
b3BufferInfoCL( constraint->getBufferCL() ),
b3BufferInfoCL( m_data->m_numConstraints->getBufferCL() ),
b3BufferInfoCL( m_data->m_offsets->getBufferCL() )
#ifdef DEBUG_ME
,btBufferInfoCL(&gpuDebugInfo)
,b3BufferInfoCL(&gpuDebugInfo)
#endif //DEBUG_ME
};
btLauncherCL launcher( m_data->m_queue, m_data->m_solveFrictionKernel );
launcher.setBuffers( bInfo, sizeof(bInfo)/sizeof(btBufferInfoCL) );
b3LauncherCL launcher( m_data->m_queue, m_data->m_solveFrictionKernel );
launcher.setBuffers( bInfo, sizeof(bInfo)/sizeof(b3BufferInfoCL) );
//launcher.setConst( cdata.x );
launcher.setConst( cdata.y );
launcher.setConst( cdata.z );
launcher.setConst( cdata.w );
launcher.launch1D( 64*nn/BT_SOLVER_N_BATCHES, 64 );
launcher.launch1D( 64*nn/B3_SOLVER_N_BATCHES, 64 );
}
}
clFinish(m_data->m_queue);
@@ -417,17 +417,17 @@ void b3GpuBatchingPgsSolver::solveContacts(int numBodies, cl_mem bodyBuf, cl_mem
if (useSolver)
{
float dt=1./60.;
btConstraintCfg csCfg( dt );
b3ConstraintCfg csCfg( dt );
csCfg.m_enableParallelSolve = true;
csCfg.m_averageExtent = .2f;//@TODO m_averageObjExtent;
csCfg.m_staticIdx = 0;//m_static0Index;//m_planeBodyIndex;
btOpenCLArray<b3RigidBodyCL>* bodyBuf = m_data->m_bodyBufferGPU;
b3OpenCLArray<b3RigidBodyCL>* bodyBuf = m_data->m_bodyBufferGPU;
void* additionalData = 0;//m_data->m_frictionCGPU;
const btOpenCLArray<btInertiaCL>* shapeBuf = m_data->m_inertiaBufferGPU;
btOpenCLArray<b3GpuConstraint4>* contactConstraintOut = m_data->m_contactCGPU;
const b3OpenCLArray<b3InertiaCL>* shapeBuf = m_data->m_inertiaBufferGPU;
b3OpenCLArray<b3GpuConstraint4>* contactConstraintOut = m_data->m_contactCGPU;
int nContacts = nContactOut;
@@ -442,7 +442,7 @@ void b3GpuBatchingPgsSolver::solveContacts(int numBodies, cl_mem bodyBuf, cl_mem
if( m_data->m_solverGPU->m_contactBuffer2 == 0 )
{
m_data->m_solverGPU->m_contactBuffer2 = new btOpenCLArray<b3Contact4>(m_data->m_context,m_data->m_queue, nContacts );
m_data->m_solverGPU->m_contactBuffer2 = new b3OpenCLArray<b3Contact4>(m_data->m_context,m_data->m_queue, nContacts );
m_data->m_solverGPU->m_contactBuffer2->resize(nContacts);
}
@@ -451,31 +451,31 @@ void b3GpuBatchingPgsSolver::solveContacts(int numBodies, cl_mem bodyBuf, cl_mem
{
BT_PROFILE("batching");
B3_PROFILE("batching");
//@todo: just reserve it, without copy of original contact (unless we use warmstarting)
const btOpenCLArray<b3RigidBodyCL>* bodyNative = bodyBuf;
const b3OpenCLArray<b3RigidBodyCL>* bodyNative = bodyBuf;
{
//btOpenCLArray<b3RigidBodyCL>* bodyNative = btOpenCLArrayUtils::map<adl::TYPE_CL, true>( data->m_device, bodyBuf );
//btOpenCLArray<b3Contact4>* contactNative = btOpenCLArrayUtils::map<adl::TYPE_CL, true>( data->m_device, contactsIn );
//b3OpenCLArray<b3RigidBodyCL>* bodyNative = b3OpenCLArrayUtils::map<adl::TYPE_CL, true>( data->m_device, bodyBuf );
//b3OpenCLArray<b3Contact4>* contactNative = b3OpenCLArrayUtils::map<adl::TYPE_CL, true>( data->m_device, contactsIn );
const int sortAlignment = 512; // todo. get this out of sort
if( csCfg.m_enableParallelSolve )
{
int sortSize = BTNEXTMULTIPLEOF( nContacts, sortAlignment );
int sortSize = B3NEXTMULTIPLEOF( nContacts, sortAlignment );
btOpenCLArray<unsigned int>* countsNative = m_data->m_solverGPU->m_numConstraints;
btOpenCLArray<unsigned int>* offsetsNative = m_data->m_solverGPU->m_offsets;
b3OpenCLArray<unsigned int>* countsNative = m_data->m_solverGPU->m_numConstraints;
b3OpenCLArray<unsigned int>* offsetsNative = m_data->m_solverGPU->m_offsets;
{ // 2. set cell idx
BT_PROFILE("GPU set cell idx");
B3_PROFILE("GPU set cell idx");
struct CB
{
int m_nContacts;
@@ -484,19 +484,19 @@ void b3GpuBatchingPgsSolver::solveContacts(int numBodies, cl_mem bodyBuf, cl_mem
int m_nSplit;
};
btAssert( sortSize%64 == 0 );
b3Assert( sortSize%64 == 0 );
CB cdata;
cdata.m_nContacts = nContacts;
cdata.m_staticIdx = csCfg.m_staticIdx;
cdata.m_scale = 1.f/(BT_SOLVER_N_OBJ_PER_SPLIT*csCfg.m_averageExtent);
cdata.m_nSplit = BT_SOLVER_N_SPLIT;
cdata.m_scale = 1.f/(B3_SOLVER_N_OBJ_PER_SPLIT*csCfg.m_averageExtent);
cdata.m_nSplit = B3_SOLVER_N_SPLIT;
m_data->m_solverGPU->m_sortDataBuffer->resize(nContacts);
btBufferInfoCL bInfo[] = { btBufferInfoCL( m_data->m_pBufContactOutGPU->getBufferCL() ), btBufferInfoCL( bodyBuf->getBufferCL()), btBufferInfoCL( m_data->m_solverGPU->m_sortDataBuffer->getBufferCL()) };
btLauncherCL launcher(m_data->m_queue, m_data->m_solverGPU->m_setSortDataKernel );
launcher.setBuffers( bInfo, sizeof(bInfo)/sizeof(btBufferInfoCL) );
b3BufferInfoCL bInfo[] = { b3BufferInfoCL( m_data->m_pBufContactOutGPU->getBufferCL() ), b3BufferInfoCL( bodyBuf->getBufferCL()), b3BufferInfoCL( m_data->m_solverGPU->m_sortDataBuffer->getBufferCL()) };
b3LauncherCL launcher(m_data->m_queue, m_data->m_solverGPU->m_setSortDataKernel );
launcher.setBuffers( bInfo, sizeof(bInfo)/sizeof(b3BufferInfoCL) );
launcher.setConst( cdata.m_nContacts );
launcher.setConst( cdata.m_scale );
launcher.setConst(cdata.m_nSplit);
@@ -509,17 +509,17 @@ void b3GpuBatchingPgsSolver::solveContacts(int numBodies, cl_mem bodyBuf, cl_mem
bool gpuRadixSort=true;
if (gpuRadixSort)
{ // 3. sort by cell idx
BT_PROFILE("gpuRadixSort");
int n = BT_SOLVER_N_SPLIT*BT_SOLVER_N_SPLIT;
B3_PROFILE("gpuRadixSort");
int n = B3_SOLVER_N_SPLIT*B3_SOLVER_N_SPLIT;
int sortBit = 32;
//if( n <= 0xffff ) sortBit = 16;
//if( n <= 0xff ) sortBit = 8;
//adl::RadixSort<adl::TYPE_CL>::execute( data->m_sort, *data->m_sortDataBuffer, sortSize );
//adl::RadixSort32<adl::TYPE_CL>::execute( data->m_sort32, *data->m_sortDataBuffer, sortSize );
btOpenCLArray<btSortData>& keyValuesInOut = *(m_data->m_solverGPU->m_sortDataBuffer);
b3OpenCLArray<b3SortData>& keyValuesInOut = *(m_data->m_solverGPU->m_sortDataBuffer);
this->m_data->m_solverGPU->m_sort32->execute(keyValuesInOut);
/*b3AlignedObjectArray<btSortData> hostValues;
/*b3AlignedObjectArray<b3SortData> hostValues;
keyValuesInOut.copyToHost(hostValues);
printf("hostValues.size=%d\n",hostValues.size());
*/
@@ -528,17 +528,17 @@ void b3GpuBatchingPgsSolver::solveContacts(int numBodies, cl_mem bodyBuf, cl_mem
{
// 4. find entries
BT_PROFILE("gpuBoundSearch");
B3_PROFILE("gpuBoundSearch");
m_data->m_solverGPU->m_search->execute(*m_data->m_solverGPU->m_sortDataBuffer,nContacts,*countsNative,
BT_SOLVER_N_SPLIT*BT_SOLVER_N_SPLIT,btBoundSearchCL::COUNT);
B3_SOLVER_N_SPLIT*B3_SOLVER_N_SPLIT,b3BoundSearchCL::COUNT);
//adl::BoundSearch<adl::TYPE_CL>::execute( data->m_search, *data->m_sortDataBuffer, nContacts, *countsNative,
// BT_SOLVER_N_SPLIT*BT_SOLVER_N_SPLIT, adl::BoundSearchBase::COUNT );
// B3_SOLVER_N_SPLIT*B3_SOLVER_N_SPLIT, adl::BoundSearchBase::COUNT );
//unsigned int sum;
m_data->m_solverGPU->m_scan->execute(*countsNative,*offsetsNative, BT_SOLVER_N_SPLIT*BT_SOLVER_N_SPLIT);//,&sum );
m_data->m_solverGPU->m_scan->execute(*countsNative,*offsetsNative, B3_SOLVER_N_SPLIT*B3_SOLVER_N_SPLIT);//,&sum );
//printf("sum = %d\n",sum);
}
@@ -548,15 +548,15 @@ void b3GpuBatchingPgsSolver::solveContacts(int numBodies, cl_mem bodyBuf, cl_mem
if (nContacts)
{ // 5. sort constraints by cellIdx
{
BT_PROFILE("gpu m_reorderContactKernel");
B3_PROFILE("gpu m_reorderContactKernel");
btInt4 cdata;
b3Int4 cdata;
cdata.x = nContacts;
btBufferInfoCL bInfo[] = { btBufferInfoCL( m_data->m_pBufContactOutGPU->getBufferCL() ), btBufferInfoCL( m_data->m_solverGPU->m_contactBuffer2->getBufferCL())
, btBufferInfoCL( m_data->m_solverGPU->m_sortDataBuffer->getBufferCL()) };
btLauncherCL launcher(m_data->m_queue,m_data->m_solverGPU->m_reorderContactKernel);
launcher.setBuffers( bInfo, sizeof(bInfo)/sizeof(btBufferInfoCL) );
b3BufferInfoCL bInfo[] = { b3BufferInfoCL( m_data->m_pBufContactOutGPU->getBufferCL() ), b3BufferInfoCL( m_data->m_solverGPU->m_contactBuffer2->getBufferCL())
, b3BufferInfoCL( m_data->m_solverGPU->m_sortDataBuffer->getBufferCL()) };
b3LauncherCL launcher(m_data->m_queue,m_data->m_solverGPU->m_reorderContactKernel);
launcher.setBuffers( bInfo, sizeof(bInfo)/sizeof(b3BufferInfoCL) );
launcher.setConst( cdata );
launcher.launch1D( nContacts, 64 );
}
@@ -574,11 +574,11 @@ void b3GpuBatchingPgsSolver::solveContacts(int numBodies, cl_mem bodyBuf, cl_mem
if (nContacts)
{
BT_PROFILE("gpu m_copyConstraintKernel");
btInt4 cdata; cdata.x = nContacts;
btBufferInfoCL bInfo[] = { btBufferInfoCL( m_data->m_solverGPU->m_contactBuffer2->getBufferCL() ), btBufferInfoCL( m_data->m_pBufContactOutGPU->getBufferCL() ) };
btLauncherCL launcher(m_data->m_queue, m_data->m_solverGPU->m_copyConstraintKernel );
launcher.setBuffers( bInfo, sizeof(bInfo)/sizeof(btBufferInfoCL) );
B3_PROFILE("gpu m_copyConstraintKernel");
b3Int4 cdata; cdata.x = nContacts;
b3BufferInfoCL bInfo[] = { b3BufferInfoCL( m_data->m_solverGPU->m_contactBuffer2->getBufferCL() ), b3BufferInfoCL( m_data->m_pBufContactOutGPU->getBufferCL() ) };
b3LauncherCL launcher(m_data->m_queue, m_data->m_solverGPU->m_copyConstraintKernel );
launcher.setBuffers( bInfo, sizeof(bInfo)/sizeof(b3BufferInfoCL) );
launcher.setConst( cdata );
launcher.launch1D( nContacts, 64 );
clFinish(m_data->m_queue);
@@ -590,24 +590,24 @@ void b3GpuBatchingPgsSolver::solveContacts(int numBodies, cl_mem bodyBuf, cl_mem
{
if (gpuBatchContacts)
{
BT_PROFILE("gpu batchContacts");
B3_PROFILE("gpu batchContacts");
maxNumBatches = 50;//250;
m_data->m_solverGPU->batchContacts( m_data->m_pBufContactOutGPU, nContacts, m_data->m_solverGPU->m_numConstraints, m_data->m_solverGPU->m_offsets, csCfg.m_staticIdx );
} else
{
BT_PROFILE("cpu batchContacts");
B3_PROFILE("cpu batchContacts");
b3AlignedObjectArray<b3Contact4> cpuContacts;
btOpenCLArray<b3Contact4>* contactsIn = m_data->m_solverGPU->m_contactBuffer2;
b3OpenCLArray<b3Contact4>* contactsIn = m_data->m_solverGPU->m_contactBuffer2;
contactsIn->copyToHost(cpuContacts);
btOpenCLArray<unsigned int>* countsNative = m_data->m_solverGPU->m_numConstraints;
btOpenCLArray<unsigned int>* offsetsNative = m_data->m_solverGPU->m_offsets;
b3OpenCLArray<unsigned int>* countsNative = m_data->m_solverGPU->m_numConstraints;
b3OpenCLArray<unsigned int>* offsetsNative = m_data->m_solverGPU->m_offsets;
b3AlignedObjectArray<unsigned int> nNativeHost;
b3AlignedObjectArray<unsigned int> offsetsNativeHost;
{
BT_PROFILE("countsNative/offsetsNative copyToHost");
B3_PROFILE("countsNative/offsetsNative copyToHost");
countsNative->copyToHost(nNativeHost);
offsetsNative->copyToHost(offsetsNativeHost);
}
@@ -616,8 +616,8 @@ void b3GpuBatchingPgsSolver::solveContacts(int numBodies, cl_mem bodyBuf, cl_mem
int numNonzeroGrid=0;
{
BT_PROFILE("batch grid");
for(int i=0; i<BT_SOLVER_N_SPLIT*BT_SOLVER_N_SPLIT; i++)
B3_PROFILE("batch grid");
for(int i=0; i<B3_SOLVER_N_SPLIT*B3_SOLVER_N_SPLIT; i++)
{
int n = (nNativeHost)[i];
int offset = (offsetsNativeHost)[i];
@@ -633,7 +633,7 @@ void b3GpuBatchingPgsSolver::solveContacts(int numBodies, cl_mem bodyBuf, cl_mem
int numBatches = sortConstraintByBatch3( &cpuContacts[0]+offset, n, simdWidth,csCfg.m_staticIdx ,numBodies); // on GPU
maxNumBatches = btMax(numBatches,maxNumBatches);
maxNumBatches = b3Max(numBatches,maxNumBatches);
static int globalMaxBatch = 0;
if (maxNumBatches>globalMaxBatch )
{
@@ -647,7 +647,7 @@ void b3GpuBatchingPgsSolver::solveContacts(int numBodies, cl_mem bodyBuf, cl_mem
}
}
{
BT_PROFILE("m_contactBuffer->copyFromHost");
B3_PROFILE("m_contactBuffer->copyFromHost");
m_data->m_solverGPU->m_contactBuffer2->copyFromHost((b3AlignedObjectArray<b3Contact4>&)cpuContacts);
}
@@ -660,7 +660,7 @@ void b3GpuBatchingPgsSolver::solveContacts(int numBodies, cl_mem bodyBuf, cl_mem
if (nContacts)
{
//BT_PROFILE("gpu convertToConstraints");
//B3_PROFILE("gpu convertToConstraints");
m_data->m_solverGPU->convertToConstraints( bodyBuf,
shapeBuf, m_data->m_solverGPU->m_contactBuffer2,
contactConstraintOut,
@@ -682,7 +682,7 @@ void b3GpuBatchingPgsSolver::solveContacts(int numBodies, cl_mem bodyBuf, cl_mem
m_data->m_solverGPU->m_nIterations = 4;//10
if (gpuSolveConstraint)
{
BT_PROFILE("GPU solveContactConstraint");
B3_PROFILE("GPU solveContactConstraint");
m_data->m_solverGPU->solveContactConstraint(
m_data->m_bodyBufferGPU,
@@ -693,7 +693,7 @@ void b3GpuBatchingPgsSolver::solveContacts(int numBodies, cl_mem bodyBuf, cl_mem
}
else
{
BT_PROFILE("Host solveContactConstraint");
B3_PROFILE("Host solveContactConstraint");
m_data->m_solverGPU->solveContactConstraintHost(m_data->m_bodyBufferGPU, m_data->m_inertiaBufferGPU, m_data->m_contactCGPU,0, nContactOut ,maxNumBatches);
}
@@ -705,7 +705,7 @@ void b3GpuBatchingPgsSolver::solveContacts(int numBodies, cl_mem bodyBuf, cl_mem
#if 0
if (0)
{
BT_PROFILE("read body velocities back to CPU");
B3_PROFILE("read body velocities back to CPU");
//read body updated linear/angular velocities back to CPU
m_data->m_bodyBufferGPU->read(
m_data->m_bodyBufferCPU->m_ptr,numOfConvexRBodies);
@@ -718,13 +718,13 @@ void b3GpuBatchingPgsSolver::solveContacts(int numBodies, cl_mem bodyBuf, cl_mem
}
void b3GpuBatchingPgsSolver::batchContacts( btOpenCLArray<b3Contact4>* contacts, int nContacts, btOpenCLArray<unsigned int>* n, btOpenCLArray<unsigned int>* offsets, int staticIdx )
void b3GpuBatchingPgsSolver::batchContacts( b3OpenCLArray<b3Contact4>* contacts, int nContacts, b3OpenCLArray<unsigned int>* n, b3OpenCLArray<unsigned int>* offsets, int staticIdx )
{
}
static bool sortfnc(const btSortData& a,const btSortData& b)
static bool sortfnc(const b3SortData& a,const b3SortData& b)
{
return (a.m_key<b.m_key);
}
@@ -737,14 +737,14 @@ static bool sortfnc(const btSortData& a,const btSortData& b)
b3AlignedObjectArray<unsigned int> idxBuffer;
b3AlignedObjectArray<btSortData> sortData;
b3AlignedObjectArray<b3SortData> sortData;
b3AlignedObjectArray<b3Contact4> old;
inline int b3GpuBatchingPgsSolver::sortConstraintByBatch( b3Contact4* cs, int n, int simdWidth , int staticIdx, int numBodies)
{
BT_PROFILE("sortConstraintByBatch");
B3_PROFILE("sortConstraintByBatch");
int numIter = 0;
sortData.resize(n);
@@ -769,7 +769,7 @@ inline int b3GpuBatchingPgsSolver::sortConstraintByBatch( b3Contact4* cs, int n,
int batchIdx = 0;
{
BT_PROFILE("cpu batch innerloop");
B3_PROFILE("cpu batch innerloop");
while( nIdxSrc )
{
numIter++;
@@ -782,7 +782,7 @@ inline int b3GpuBatchingPgsSolver::sortConstraintByBatch( b3Contact4* cs, int n,
for(int i=0; i<nIdxSrc; i++)
{
int idx = idxSrc[i];
btAssert( idx < n );
b3Assert( idx < n );
// check if it can go
int bodyAS = cs[idx].m_bodyAPtrAndSignBit;
int bodyBS = cs[idx].m_bodyBPtrAndSignBit;
@@ -830,19 +830,19 @@ inline int b3GpuBatchingPgsSolver::sortConstraintByBatch( b3Contact4* cs, int n,
idxDst[nIdxDst++] = idx;
}
}
btSwap( idxSrc, idxDst );
btSwap( nIdxSrc, nIdxDst );
b3Swap( idxSrc, idxDst );
b3Swap( nIdxSrc, nIdxDst );
batchIdx ++;
}
}
{
BT_PROFILE("quickSort");
B3_PROFILE("quickSort");
sortData.quickSort(sortfnc);
}
{
BT_PROFILE("reorder");
B3_PROFILE("reorder");
// reorder
memcpy( &old[0], cs, sizeof(b3Contact4)*n);
@@ -858,7 +858,7 @@ inline int b3GpuBatchingPgsSolver::sortConstraintByBatch( b3Contact4* cs, int n,
// debugPrintf( "nBatches: %d\n", batchIdx );
for(int i=0; i<n; i++)
{
btAssert( cs[i].getBatchIdx() != -1 );
b3Assert( cs[i].getBatchIdx() != -1 );
}
#endif
return batchIdx;
@@ -870,7 +870,7 @@ b3AlignedObjectArray<int> bodyUsed2;
inline int b3GpuBatchingPgsSolver::sortConstraintByBatch2( b3Contact4* cs, int numConstraints, int simdWidth , int staticIdx, int numBodies)
{
BT_PROFILE("sortConstraintByBatch2");
B3_PROFILE("sortConstraintByBatch2");
@@ -903,7 +903,7 @@ inline int b3GpuBatchingPgsSolver::sortConstraintByBatch2( b3Contact4* cs, int n
{
BT_PROFILE("cpu batch innerloop");
B3_PROFILE("cpu batch innerloop");
while( numValidConstraints < numConstraints)
{
@@ -917,7 +917,7 @@ inline int b3GpuBatchingPgsSolver::sortConstraintByBatch2( b3Contact4* cs, int n
for(int i=numValidConstraints; i<numConstraints; i++)
{
int idx = idxSrc[i];
btAssert( idx < numConstraints );
b3Assert( idx < numConstraints );
// check if it can go
int bodyAS = cs[idx].m_bodyAPtrAndSignBit;
int bodyBS = cs[idx].m_bodyBPtrAndSignBit;
@@ -968,7 +968,7 @@ inline int b3GpuBatchingPgsSolver::sortConstraintByBatch2( b3Contact4* cs, int n
if (i!=numValidConstraints)
{
btSwap(idxSrc[i], idxSrc[numValidConstraints]);
b3Swap(idxSrc[i], idxSrc[numValidConstraints]);
}
numValidConstraints++;
@@ -991,19 +991,19 @@ inline int b3GpuBatchingPgsSolver::sortConstraintByBatch2( b3Contact4* cs, int n
}
}
{
BT_PROFILE("quickSort");
B3_PROFILE("quickSort");
//m_data->m_sortData.quickSort(sortfnc);
}
{
BT_PROFILE("reorder");
B3_PROFILE("reorder");
// reorder
memcpy( &m_data->m_old[0], cs, sizeof(b3Contact4)*numConstraints);
for(int i=0; i<numConstraints; i++)
{
btAssert(m_data->m_sortData[idxSrc[i]].m_value == idxSrc[i]);
b3Assert(m_data->m_sortData[idxSrc[i]].m_value == idxSrc[i]);
int idx = m_data->m_sortData[idxSrc[i]].m_value;
cs[i] = m_data->m_old[idx];
}
@@ -1013,7 +1013,7 @@ inline int b3GpuBatchingPgsSolver::sortConstraintByBatch2( b3Contact4* cs, int n
// debugPrintf( "nBatches: %d\n", batchIdx );
for(int i=0; i<numConstraints; i++)
{
btAssert( cs[i].getBatchIdx() != -1 );
b3Assert( cs[i].getBatchIdx() != -1 );
}
#endif
@@ -1029,7 +1029,7 @@ b3AlignedObjectArray<int> curUsed;
inline int b3GpuBatchingPgsSolver::sortConstraintByBatch3( b3Contact4* cs, int numConstraints, int simdWidth , int staticIdx, int numBodies)
{
BT_PROFILE("sortConstraintByBatch3");
B3_PROFILE("sortConstraintByBatch3");
static int maxSwaps = 0;
int numSwaps = 0;
@@ -1071,7 +1071,7 @@ inline int b3GpuBatchingPgsSolver::sortConstraintByBatch3( b3Contact4* cs, int n
{
BT_PROFILE("cpu batch innerloop");
B3_PROFILE("cpu batch innerloop");
while( numValidConstraints < numConstraints)
{
@@ -1086,7 +1086,7 @@ inline int b3GpuBatchingPgsSolver::sortConstraintByBatch3( b3Contact4* cs, int n
for(int i=numValidConstraints; i<numConstraints; i++)
{
int idx = i;
btAssert( idx < numConstraints );
b3Assert( idx < numConstraints );
// check if it can go
int bodyAS = cs[idx].m_bodyAPtrAndSignBit;
int bodyBS = cs[idx].m_bodyBPtrAndSignBit;
@@ -1123,7 +1123,7 @@ inline int b3GpuBatchingPgsSolver::sortConstraintByBatch3( b3Contact4* cs, int n
if (i!=numValidConstraints)
{
btSwap(cs[i],cs[numValidConstraints]);
b3Swap(cs[i],cs[numValidConstraints]);
numSwaps++;
}
@@ -1148,7 +1148,7 @@ inline int b3GpuBatchingPgsSolver::sortConstraintByBatch3( b3Contact4* cs, int n
// debugPrintf( "nBatches: %d\n", batchIdx );
for(int i=0; i<numConstraints; i++)
{
btAssert( cs[i].getBatchIdx() != -1 );
b3Assert( cs[i].getBatchIdx() != -1 );
}
#endif

View File

@@ -1,9 +1,9 @@
#ifndef BT_GPU_BATCHING_PGS_SOLVER_H
#define BT_GPU_BATCHING_PGS_SOLVER_H
#ifndef B3_GPU_BATCHING_PGS_SOLVER_H
#define B3_GPU_BATCHING_PGS_SOLVER_H
#include "../../basic_initialize/b3OpenCLInclude.h"
#include "../../parallel_primitives/host/btOpenCLArray.h"
#include "../../parallel_primitives/host/b3OpenCLArray.h"
#include "Bullet3Collision/NarrowPhaseCollision/b3RigidBodyCL.h"
#include "Bullet3Collision/NarrowPhaseCollision/b3Contact4.h"
#include "b3GpuConstraint4.h"
@@ -14,9 +14,9 @@ protected:
struct btGpuBatchingPgsSolverInternalData* m_data;
struct b3GpuBatchingPgsSolverInternalData* m_data;
void batchContacts( btOpenCLArray<b3Contact4>* contacts, int nContacts, btOpenCLArray<unsigned int>* n, btOpenCLArray<unsigned int>* offsets, int staticIdx );
void batchContacts( b3OpenCLArray<b3Contact4>* contacts, int nContacts, b3OpenCLArray<unsigned int>* n, b3OpenCLArray<unsigned int>* offsets, int staticIdx );
inline int sortConstraintByBatch( b3Contact4* cs, int n, int simdWidth , int staticIdx, int numBodies);
inline int sortConstraintByBatch2( b3Contact4* cs, int n, int simdWidth , int staticIdx, int numBodies);
@@ -24,8 +24,8 @@ protected:
void solveContactConstraint( const btOpenCLArray<b3RigidBodyCL>* bodyBuf, const btOpenCLArray<btInertiaCL>* shapeBuf,
btOpenCLArray<b3GpuConstraint4>* constraint, void* additionalData, int n ,int maxNumBatches, int numIterations);
void solveContactConstraint( const b3OpenCLArray<b3RigidBodyCL>* bodyBuf, const b3OpenCLArray<b3InertiaCL>* shapeBuf,
b3OpenCLArray<b3GpuConstraint4>* constraint, void* additionalData, int n ,int maxNumBatches, int numIterations);
public:
@@ -36,5 +36,5 @@ public:
};
#endif //BT_GPU_BATCHING_PGS_SOLVER_H
#endif //B3_GPU_BATCHING_PGS_SOLVER_H

View File

@@ -1,11 +1,11 @@
#ifndef BT_CONSTRAINT4_h
#define BT_CONSTRAINT4_h
#ifndef B3_CONSTRAINT4_h
#define B3_CONSTRAINT4_h
#include "Bullet3Common/b3Vector3.h"
ATTRIBUTE_ALIGNED16(struct) b3GpuConstraint4
{
BT_DECLARE_ALIGNED_ALLOCATOR();
B3_DECLARE_ALIGNED_ALLOCATOR();
b3Vector3 m_linear;//normal?
b3Vector3 m_worldPos[4];
@@ -25,5 +25,5 @@ ATTRIBUTE_ALIGNED16(struct) b3GpuConstraint4
inline float getFrictionCoeff() const { return m_linear[3]; }
};
#endif //BT_CONSTRAINT4_h
#endif //B3_CONSTRAINT4_h

View File

@@ -1,7 +1,7 @@
#include "b3GpuNarrowPhase.h"
#include "parallel_primitives/host/btOpenCLArray.h"
#include "parallel_primitives/host/b3OpenCLArray.h"
#include "../../gpu_narrowphase/host/b3ConvexPolyhedronCL.h"
#include "../../gpu_narrowphase/host/b3ConvexHullContact.h"
#include "../../gpu_broadphase/host/b3SapAabb.h"
@@ -12,7 +12,7 @@
#include "Bullet3Geometry/b3AabbUtil.h"
#include "../../gpu_narrowphase/host/b3BvhInfo.h"
struct btGpuNarrowPhaseInternalData
struct b3GpuNarrowPhaseInternalData
{
b3AlignedObjectArray<b3ConvexUtility*>* m_convexData;
@@ -21,59 +21,59 @@ struct btGpuNarrowPhaseInternalData
b3AlignedObjectArray<b3Vector3> m_convexVertices;
b3AlignedObjectArray<int> m_convexIndices;
btOpenCLArray<b3ConvexPolyhedronCL>* m_convexPolyhedraGPU;
btOpenCLArray<b3Vector3>* m_uniqueEdgesGPU;
btOpenCLArray<b3Vector3>* m_convexVerticesGPU;
btOpenCLArray<int>* m_convexIndicesGPU;
b3OpenCLArray<b3ConvexPolyhedronCL>* m_convexPolyhedraGPU;
b3OpenCLArray<b3Vector3>* m_uniqueEdgesGPU;
b3OpenCLArray<b3Vector3>* m_convexVerticesGPU;
b3OpenCLArray<int>* m_convexIndicesGPU;
btOpenCLArray<b3Vector3>* m_worldVertsB1GPU;
btOpenCLArray<btInt4>* m_clippingFacesOutGPU;
btOpenCLArray<b3Vector3>* m_worldNormalsAGPU;
btOpenCLArray<b3Vector3>* m_worldVertsA1GPU;
btOpenCLArray<b3Vector3>* m_worldVertsB2GPU;
b3OpenCLArray<b3Vector3>* m_worldVertsB1GPU;
b3OpenCLArray<b3Int4>* m_clippingFacesOutGPU;
b3OpenCLArray<b3Vector3>* m_worldNormalsAGPU;
b3OpenCLArray<b3Vector3>* m_worldVertsA1GPU;
b3OpenCLArray<b3Vector3>* m_worldVertsB2GPU;
b3AlignedObjectArray<btGpuChildShape> m_cpuChildShapes;
btOpenCLArray<btGpuChildShape>* m_gpuChildShapes;
b3AlignedObjectArray<b3GpuChildShape> m_cpuChildShapes;
b3OpenCLArray<b3GpuChildShape>* m_gpuChildShapes;
b3AlignedObjectArray<btGpuFace> m_convexFaces;
btOpenCLArray<btGpuFace>* m_convexFacesGPU;
b3AlignedObjectArray<b3GpuFace> m_convexFaces;
b3OpenCLArray<b3GpuFace>* m_convexFacesGPU;
GpuSatCollision* m_gpuSatCollision;
b3AlignedObjectArray<btInt2>* m_pBufPairsCPU;
b3AlignedObjectArray<b3Int2>* m_pBufPairsCPU;
btOpenCLArray<btInt2>* m_convexPairsOutGPU;
btOpenCLArray<btInt2>* m_planePairs;
b3OpenCLArray<b3Int2>* m_convexPairsOutGPU;
b3OpenCLArray<b3Int2>* m_planePairs;
btOpenCLArray<b3Contact4>* m_pBufContactOutGPU;
b3OpenCLArray<b3Contact4>* m_pBufContactOutGPU;
b3AlignedObjectArray<b3Contact4>* m_pBufContactOutCPU;
b3AlignedObjectArray<b3RigidBodyCL>* m_bodyBufferCPU;
btOpenCLArray<b3RigidBodyCL>* m_bodyBufferGPU;
b3OpenCLArray<b3RigidBodyCL>* m_bodyBufferGPU;
b3AlignedObjectArray<btInertiaCL>* m_inertiaBufferCPU;
btOpenCLArray<btInertiaCL>* m_inertiaBufferGPU;
b3AlignedObjectArray<b3InertiaCL>* m_inertiaBufferCPU;
b3OpenCLArray<b3InertiaCL>* m_inertiaBufferGPU;
int m_numAcceleratedShapes;
int m_numAcceleratedRigidBodies;
b3AlignedObjectArray<b3Collidable> m_collidablesCPU;
btOpenCLArray<b3Collidable>* m_collidablesGPU;
b3OpenCLArray<b3Collidable>* m_collidablesGPU;
btOpenCLArray<b3SapAabb>* m_localShapeAABBGPU;
b3OpenCLArray<b3SapAabb>* m_localShapeAABBGPU;
b3AlignedObjectArray<b3SapAabb>* m_localShapeAABBCPU;
b3AlignedObjectArray<class b3OptimizedBvh*> m_bvhData;
b3AlignedObjectArray<btQuantizedBvhNode> m_treeNodesCPU;
b3AlignedObjectArray<btBvhSubtreeInfo> m_subTreesCPU;
b3AlignedObjectArray<b3QuantizedBvhNode> m_treeNodesCPU;
b3AlignedObjectArray<b3BvhSubtreeInfo> m_subTreesCPU;
b3AlignedObjectArray<b3BvhInfo> m_bvhInfoCPU;
btOpenCLArray<b3BvhInfo>* m_bvhInfoGPU;
b3OpenCLArray<b3BvhInfo>* m_bvhInfoGPU;
btOpenCLArray<btQuantizedBvhNode>* m_treeNodesGPU;
btOpenCLArray<btBvhSubtreeInfo>* m_subTreesGPU;
b3OpenCLArray<b3QuantizedBvhNode>* m_treeNodesGPU;
b3OpenCLArray<b3BvhSubtreeInfo>* m_subTreesGPU;
b3Config m_config;
@@ -91,52 +91,52 @@ m_device(device),
m_queue(queue)
{
m_data = new btGpuNarrowPhaseInternalData();
memset(m_data,0,sizeof(btGpuNarrowPhaseInternalData));
m_data = new b3GpuNarrowPhaseInternalData();
memset(m_data,0,sizeof(b3GpuNarrowPhaseInternalData));
m_data->m_config = config;
m_data->m_gpuSatCollision = new GpuSatCollision(ctx,device,queue);
m_data->m_pBufPairsCPU = new b3AlignedObjectArray<btInt2>;
m_data->m_pBufPairsCPU = new b3AlignedObjectArray<b3Int2>;
m_data->m_pBufPairsCPU->resize(config.m_maxBroadphasePairs);
m_data->m_convexPairsOutGPU = new btOpenCLArray<btInt2>(ctx,queue,config.m_maxBroadphasePairs,false);
m_data->m_planePairs = new btOpenCLArray<btInt2>(ctx,queue,config.m_maxBroadphasePairs,false);
m_data->m_convexPairsOutGPU = new b3OpenCLArray<b3Int2>(ctx,queue,config.m_maxBroadphasePairs,false);
m_data->m_planePairs = new b3OpenCLArray<b3Int2>(ctx,queue,config.m_maxBroadphasePairs,false);
m_data->m_pBufContactOutCPU = new b3AlignedObjectArray<b3Contact4>();
m_data->m_pBufContactOutCPU->resize(config.m_maxBroadphasePairs);
m_data->m_bodyBufferCPU = new b3AlignedObjectArray<b3RigidBodyCL>();
m_data->m_bodyBufferCPU->resize(config.m_maxConvexBodies);
m_data->m_inertiaBufferCPU = new b3AlignedObjectArray<btInertiaCL>();
m_data->m_inertiaBufferCPU = new b3AlignedObjectArray<b3InertiaCL>();
m_data->m_inertiaBufferCPU->resize(config.m_maxConvexBodies);
m_data->m_pBufContactOutGPU = new btOpenCLArray<b3Contact4>(ctx,queue, config.m_maxContactCapacity,true);
m_data->m_pBufContactOutGPU = new b3OpenCLArray<b3Contact4>(ctx,queue, config.m_maxContactCapacity,true);
m_data->m_inertiaBufferGPU = new btOpenCLArray<btInertiaCL>(ctx,queue,config.m_maxConvexBodies,false);
m_data->m_collidablesGPU = new btOpenCLArray<b3Collidable>(ctx,queue,config.m_maxConvexShapes);
m_data->m_inertiaBufferGPU = new b3OpenCLArray<b3InertiaCL>(ctx,queue,config.m_maxConvexBodies,false);
m_data->m_collidablesGPU = new b3OpenCLArray<b3Collidable>(ctx,queue,config.m_maxConvexShapes);
m_data->m_localShapeAABBCPU = new b3AlignedObjectArray<b3SapAabb>;
m_data->m_localShapeAABBGPU = new btOpenCLArray<b3SapAabb>(ctx,queue,config.m_maxConvexShapes);
m_data->m_localShapeAABBGPU = new b3OpenCLArray<b3SapAabb>(ctx,queue,config.m_maxConvexShapes);
//m_data->m_solverDataGPU = adl::Solver<adl::TYPE_CL>::allocate(ctx,queue, config.m_maxBroadphasePairs,false);
m_data->m_bodyBufferGPU = new btOpenCLArray<b3RigidBodyCL>(ctx,queue, config.m_maxConvexBodies,false);
m_data->m_bodyBufferGPU = new b3OpenCLArray<b3RigidBodyCL>(ctx,queue, config.m_maxConvexBodies,false);
m_data->m_convexFacesGPU = new btOpenCLArray<btGpuFace>(ctx,queue,config.m_maxConvexShapes*config.m_maxFacesPerShape,false);
m_data->m_gpuChildShapes = new btOpenCLArray<btGpuChildShape>(ctx,queue,config.m_maxCompoundChildShapes,false);
m_data->m_convexFacesGPU = new b3OpenCLArray<b3GpuFace>(ctx,queue,config.m_maxConvexShapes*config.m_maxFacesPerShape,false);
m_data->m_gpuChildShapes = new b3OpenCLArray<b3GpuChildShape>(ctx,queue,config.m_maxCompoundChildShapes,false);
m_data->m_convexPolyhedraGPU = new btOpenCLArray<b3ConvexPolyhedronCL>(ctx,queue,config.m_maxConvexShapes,false);
m_data->m_uniqueEdgesGPU = new btOpenCLArray<b3Vector3>(ctx,queue,config.m_maxConvexUniqueEdges,true);
m_data->m_convexVerticesGPU = new btOpenCLArray<b3Vector3>(ctx,queue,config.m_maxConvexVertices,true);
m_data->m_convexIndicesGPU = new btOpenCLArray<int>(ctx,queue,config.m_maxConvexIndices,true);
m_data->m_convexPolyhedraGPU = new b3OpenCLArray<b3ConvexPolyhedronCL>(ctx,queue,config.m_maxConvexShapes,false);
m_data->m_uniqueEdgesGPU = new b3OpenCLArray<b3Vector3>(ctx,queue,config.m_maxConvexUniqueEdges,true);
m_data->m_convexVerticesGPU = new b3OpenCLArray<b3Vector3>(ctx,queue,config.m_maxConvexVertices,true);
m_data->m_convexIndicesGPU = new b3OpenCLArray<int>(ctx,queue,config.m_maxConvexIndices,true);
m_data->m_worldVertsB1GPU = new btOpenCLArray<b3Vector3>(ctx,queue,config.m_maxConvexBodies*config.m_maxVerticesPerFace);
m_data->m_clippingFacesOutGPU = new btOpenCLArray<btInt4>(ctx,queue,config.m_maxConvexBodies);
m_data->m_worldNormalsAGPU = new btOpenCLArray<b3Vector3>(ctx,queue,config.m_maxConvexBodies);
m_data->m_worldVertsA1GPU = new btOpenCLArray<b3Vector3>(ctx,queue,config.m_maxConvexBodies*config.m_maxVerticesPerFace);
m_data->m_worldVertsB2GPU = new btOpenCLArray<b3Vector3>(ctx,queue,config.m_maxConvexBodies*config.m_maxVerticesPerFace);
m_data->m_worldVertsB1GPU = new b3OpenCLArray<b3Vector3>(ctx,queue,config.m_maxConvexBodies*config.m_maxVerticesPerFace);
m_data->m_clippingFacesOutGPU = new b3OpenCLArray<b3Int4>(ctx,queue,config.m_maxConvexBodies);
m_data->m_worldNormalsAGPU = new b3OpenCLArray<b3Vector3>(ctx,queue,config.m_maxConvexBodies);
m_data->m_worldVertsA1GPU = new b3OpenCLArray<b3Vector3>(ctx,queue,config.m_maxConvexBodies*config.m_maxVerticesPerFace);
m_data->m_worldVertsB2GPU = new b3OpenCLArray<b3Vector3>(ctx,queue,config.m_maxConvexBodies*config.m_maxVerticesPerFace);
@@ -150,12 +150,12 @@ m_queue(queue)
m_data->m_numAcceleratedRigidBodies = 0;
m_data->m_subTreesGPU = new btOpenCLArray<btBvhSubtreeInfo>(this->m_context,this->m_queue);
m_data->m_treeNodesGPU = new btOpenCLArray<btQuantizedBvhNode>(this->m_context,this->m_queue);
m_data->m_bvhInfoGPU = new btOpenCLArray<b3BvhInfo>(this->m_context,this->m_queue);
m_data->m_subTreesGPU = new b3OpenCLArray<b3BvhSubtreeInfo>(this->m_context,this->m_queue);
m_data->m_treeNodesGPU = new b3OpenCLArray<b3QuantizedBvhNode>(this->m_context,this->m_queue);
m_data->m_bvhInfoGPU = new b3OpenCLArray<b3BvhInfo>(this->m_context,this->m_queue);
//m_data->m_contactCGPU = new btOpenCLArray<Constraint4>(ctx,queue,config.m_maxBroadphasePairs,false);
//m_data->m_frictionCGPU = new btOpenCLArray<adl::Solver<adl::TYPE_CL>::allocateFrictionConstraint( m_data->m_deviceCL, config.m_maxBroadphasePairs);
//m_data->m_contactCGPU = new b3OpenCLArray<Constraint4>(ctx,queue,config.m_maxBroadphasePairs,false);
//m_data->m_frictionCGPU = new b3OpenCLArray<adl::Solver<adl::TYPE_CL>::allocateFrictionConstraint( m_data->m_deviceCL, config.m_maxBroadphasePairs);
}
@@ -246,7 +246,7 @@ int b3GpuNarrowPhase::registerSphereShape(float radius)
int b3GpuNarrowPhase::registerFace(const b3Vector3& faceNormal, float faceConstant)
{
int faceOffset = m_data->m_convexFaces.size();
btGpuFace& face = m_data->m_convexFaces.expand();
b3GpuFace& face = m_data->m_convexFaces.expand();
face.m_plane[0] = faceNormal.getX();
face.m_plane[1] = faceNormal.getY();
face.m_plane[2] = faceNormal.getZ();
@@ -426,7 +426,7 @@ int b3GpuNarrowPhase::registerConvexHullShape(b3ConvexUtility* utilPtr)
}
int b3GpuNarrowPhase::registerCompoundShape(b3AlignedObjectArray<btGpuChildShape>* childShapes)
int b3GpuNarrowPhase::registerCompoundShape(b3AlignedObjectArray<b3GpuChildShape>* childShapes)
{
int collidableIndex = allocateCollidable();
@@ -435,7 +435,7 @@ int b3GpuNarrowPhase::registerCompoundShape(b3AlignedObjectArray<btGpuChildShap
col.m_shapeIndex = m_data->m_cpuChildShapes.size();
{
btAssert(col.m_shapeIndex+childShapes->size()<m_data->m_config.m_maxCompoundChildShapes);
b3Assert(col.m_shapeIndex+childShapes->size()<m_data->m_config.m_maxCompoundChildShapes);
for (int i=0;i<childShapes->size();i++)
{
m_data->m_cpuChildShapes.push_back(childShapes->at(i));
@@ -474,7 +474,7 @@ int b3GpuNarrowPhase::registerCompoundShape(b3AlignedObjectArray<btGpuChildShap
childShapes->at(i).m_childOrientation[1],
childShapes->at(i).m_childOrientation[2],
childShapes->at(i).m_childOrientation[3]));
btTransformAabb(childLocalAabbMin,childLocalAabbMax,margin,childTr,aMin,aMax);
b3TransformAabb(childLocalAabbMin,childLocalAabbMax,margin,childTr,aMin,aMax);
myAabbMin.setMin(aMin);
myAabbMax.setMax(aMax);
}
@@ -539,7 +539,7 @@ int b3GpuNarrowPhase::registerConcaveMesh(b3AlignedObjectArray<b3Vector3>* vert
bool useQuantizedAabbCompression = true;
b3TriangleIndexVertexArray* meshInterface=new b3TriangleIndexVertexArray();
btIndexedMesh mesh;
b3IndexedMesh mesh;
mesh.m_numTriangles = indices->size()/3;
mesh.m_numVertices = vertices->size();
mesh.m_vertexBase = (const unsigned char *)&vertices->at(0).getX();
@@ -551,7 +551,7 @@ int b3GpuNarrowPhase::registerConcaveMesh(b3AlignedObjectArray<b3Vector3>* vert
bvh->build(meshInterface, useQuantizedAabbCompression, (b3Vector3&)aabb.m_min, (b3Vector3&)aabb.m_max);
m_data->m_bvhData.push_back(bvh);
int numNodes = bvh->getQuantizedNodeArray().size();
//btOpenCLArray<btQuantizedBvhNode>* treeNodesGPU = new btOpenCLArray<btQuantizedBvhNode>(this->m_context,this->m_queue,numNodes);
//b3OpenCLArray<b3QuantizedBvhNode>* treeNodesGPU = new b3OpenCLArray<b3QuantizedBvhNode>(this->m_context,this->m_queue,numNodes);
//treeNodesGPU->copyFromHost(bvh->getQuantizedNodeArray());
int numSubTrees = bvh->getSubtreeInfoArray().size();
@@ -582,7 +582,7 @@ int b3GpuNarrowPhase::registerConcaveMesh(b3AlignedObjectArray<b3Vector3>* vert
m_data->m_treeNodesCPU.push_back(bvh->getQuantizedNodeArray()[i]);
}
//btOpenCLArray<btBvhSubtreeInfo>* subTreesGPU = new btOpenCLArray<btBvhSubtreeInfo>(this->m_context,this->m_queue,numSubTrees);
//b3OpenCLArray<b3BvhSubtreeInfo>* subTreesGPU = new b3OpenCLArray<b3BvhSubtreeInfo>(this->m_context,this->m_queue,numSubTrees);
//subTreesGPU->copyFromHost(bvh->getSubtreeInfoArray());
m_data->m_treeNodesGPU->copyFromHost(m_data->m_treeNodesCPU);
@@ -741,12 +741,12 @@ void b3GpuNarrowPhase::computeContacts(cl_mem broadphasePairs, int numBroadphase
int nContactOut = 0;
int maxTriConvexPairCapacity = m_data->m_config.m_maxTriConvexPairCapacity;
btOpenCLArray<btInt4> triangleConvexPairs(m_context,m_queue, maxTriConvexPairCapacity);
b3OpenCLArray<b3Int4> triangleConvexPairs(m_context,m_queue, maxTriConvexPairCapacity);
int numTriConvexPairsOut=0;
btOpenCLArray<btInt2> broadphasePairsGPU(m_context,m_queue);
b3OpenCLArray<b3Int2> broadphasePairsGPU(m_context,m_queue);
broadphasePairsGPU.setFromOpenCLBuffer(broadphasePairs,numBroadphasePairs);
btOpenCLArray<btYetAnotherAabb> clAabbArray(this->m_context,this->m_queue);
b3OpenCLArray<b3YetAnotherAabb> clAabbArray(this->m_context,this->m_queue);
clAabbArray.setFromOpenCLBuffer(aabbsWS,numObjects);
m_data->m_gpuSatCollision->computeConvexConvexContactsGPUSAT(
@@ -794,7 +794,7 @@ int b3GpuNarrowPhase::registerRigidBody(int collidableIndex, float mass, const f
b3Vector3 aabbMin(aabbMinPtr[0],aabbMinPtr[1],aabbMinPtr[2]);
b3Vector3 aabbMax (aabbMaxPtr[0],aabbMaxPtr[1],aabbMaxPtr[2]);
btAssert(m_data->m_numAcceleratedRigidBodies< (m_data->m_config.m_maxConvexBodies-1));
b3Assert(m_data->m_numAcceleratedRigidBodies< (m_data->m_config.m_maxConvexBodies-1));
m_data->m_bodyBufferGPU->resize(m_data->m_numAcceleratedRigidBodies+1);
@@ -828,7 +828,7 @@ int b3GpuNarrowPhase::registerRigidBody(int collidableIndex, float mass, const f
m_data->m_bodyBufferGPU->copyFromHostPointer(&body,1,m_data->m_numAcceleratedRigidBodies);
}
btInertiaCL& shapeInfo = m_data->m_inertiaBufferCPU->at(m_data->m_numAcceleratedRigidBodies);
b3InertiaCL& shapeInfo = m_data->m_inertiaBufferCPU->at(m_data->m_numAcceleratedRigidBodies);
if (mass==0.f)
{

View File

@@ -1,5 +1,5 @@
#ifndef BT_GPU_NARROWPHASE_H
#define BT_GPU_NARROWPHASE_H
#ifndef B3_GPU_NARROWPHASE_H
#define B3_GPU_NARROWPHASE_H
#include "../../gpu_narrowphase/host/b3Collidable.h"
#include "basic_initialize/b3OpenCLInclude.h"
@@ -10,7 +10,7 @@ class b3GpuNarrowPhase
{
protected:
struct btGpuNarrowPhaseInternalData* m_data;
struct b3GpuNarrowPhaseInternalData* m_data;
int m_acceleratedCompanionShapeIndex;
int m_planeBodyIndex;
int m_static0Index;
@@ -34,7 +34,7 @@ public:
int registerSphereShape(float radius);
int registerPlaneShape(const b3Vector3& planeNormal, float planeConstant);
int registerCompoundShape(b3AlignedObjectArray<btGpuChildShape>* childShapes);
int registerCompoundShape(b3AlignedObjectArray<b3GpuChildShape>* childShapes);
int registerFace(const b3Vector3& faceNormal, float faceConstant);
int registerConcaveMesh(b3AlignedObjectArray<b3Vector3>* vertices, b3AlignedObjectArray<int>* indices,const float* scaling);
@@ -82,5 +82,5 @@ public:
const struct b3SapAabb& getLocalSpaceAabb(int collidableIndex) const;
};
#endif //BT_GPU_NARROWPHASE_H
#endif //B3_GPU_NARROWPHASE_H

View File

@@ -8,7 +8,7 @@
#include "Bullet3Geometry/b3AabbUtil.h"
#include "../../gpu_broadphase/host/b3SapAabb.h"
#include "../../gpu_broadphase/host/b3GpuSapBroadphase.h"
#include "parallel_primitives/host/btLauncherCL.h"
#include "parallel_primitives/host/b3LauncherCL.h"
#include "Bullet3Dynamics/ConstraintSolver/b3PgsJacobiSolver.h"
#include "Bullet3Collision/BroadPhaseCollision/b3DynamicBvhBroadphase.h"
@@ -20,7 +20,7 @@ bool useBullet2CpuSolver = true;//false;
bool dumpContactStats = false;
#ifdef TEST_OTHER_GPU_SOLVER
#include "btGpuJacobiSolver.h"
#include "b3GpuJacobiSolver.h"
#endif //TEST_OTHER_GPU_SOLVER
#include "Bullet3Collision/NarrowPhaseCollision/b3RigidBodyCL.h"
@@ -43,11 +43,11 @@ b3GpuRigidBodyPipeline::b3GpuRigidBodyPipeline(cl_context ctx,cl_device_id devic
m_data->m_solver = new b3PgsJacobiSolver();
b3Config config;
m_data->m_allAabbsGPU = new btOpenCLArray<b3SapAabb>(ctx,q,config.m_maxConvexBodies);
m_data->m_overlappingPairsGPU = new btOpenCLArray<btBroadphasePair>(ctx,q,config.m_maxBroadphasePairs);
m_data->m_allAabbsGPU = new b3OpenCLArray<b3SapAabb>(ctx,q,config.m_maxConvexBodies);
m_data->m_overlappingPairsGPU = new b3OpenCLArray<b3BroadphasePair>(ctx,q,config.m_maxBroadphasePairs);
#ifdef TEST_OTHER_GPU_SOLVER
m_data->m_solver3 = new btGpuJacobiSolver(ctx,device,q,config.m_maxBroadphasePairs);
m_data->m_solver3 = new b3GpuJacobiSolver(ctx,device,q,config.m_maxBroadphasePairs);
#endif // TEST_OTHER_GPU_SOLVER
m_data->m_solver2 = new b3GpuBatchingPgsSolver(ctx,device,q,config.m_maxBroadphasePairs);
@@ -61,16 +61,16 @@ b3GpuRigidBodyPipeline::b3GpuRigidBodyPipeline(cl_context ctx,cl_device_id devic
{
cl_program prog = b3OpenCLUtils::compileCLProgramFromString(m_data->m_context,m_data->m_device,integrateKernelCL,&errNum,"","opencl/gpu_rigidbody/kernels/integrateKernel.cl");
btAssert(errNum==CL_SUCCESS);
b3Assert(errNum==CL_SUCCESS);
m_data->m_integrateTransformsKernel = b3OpenCLUtils::compileCLKernelFromString(m_data->m_context, m_data->m_device,integrateKernelCL, "integrateTransformsKernel",&errNum,prog);
btAssert(errNum==CL_SUCCESS);
b3Assert(errNum==CL_SUCCESS);
clReleaseProgram(prog);
}
{
cl_program prog = b3OpenCLUtils::compileCLProgramFromString(m_data->m_context,m_data->m_device,updateAabbsKernelCL,&errNum,"","opencl/gpu_rigidbody/kernels/updateAabbsKernel.cl");
btAssert(errNum==CL_SUCCESS);
b3Assert(errNum==CL_SUCCESS);
m_data->m_updateAabbsKernel = b3OpenCLUtils::compileCLKernelFromString(m_data->m_context, m_data->m_device,updateAabbsKernelCL, "initializeGpuAabbsFull",&errNum,prog);
btAssert(errNum==CL_SUCCESS);
b3Assert(errNum==CL_SUCCESS);
clReleaseProgram(prog);
}
@@ -116,11 +116,11 @@ void b3GpuRigidBodyPipeline::stepSimulation(float deltaTime)
if (useDbvt)
{
{
BT_PROFILE("setAabb");
B3_PROFILE("setAabb");
m_data->m_allAabbsGPU->copyToHost(m_data->m_allAabbsCPU);
for (int i=0;i<m_data->m_allAabbsCPU.size();i++)
{
btBroadphaseProxy* proxy = &m_data->m_broadphaseDbvt->m_proxies[i];
b3BroadphaseProxy* proxy = &m_data->m_broadphaseDbvt->m_proxies[i];
b3Vector3 aabbMin(m_data->m_allAabbsCPU[i].m_min[0],m_data->m_allAabbsCPU[i].m_min[1],m_data->m_allAabbsCPU[i].m_min[2]);
b3Vector3 aabbMax(m_data->m_allAabbsCPU[i].m_max[0],m_data->m_allAabbsCPU[i].m_max[1],m_data->m_allAabbsCPU[i].m_max[2]);
m_data->m_broadphaseDbvt->setAabb(proxy,aabbMin,aabbMax,0);
@@ -128,7 +128,7 @@ void b3GpuRigidBodyPipeline::stepSimulation(float deltaTime)
}
{
BT_PROFILE("calculateOverlappingPairs");
B3_PROFILE("calculateOverlappingPairs");
m_data->m_broadphaseDbvt->calculateOverlappingPairs();
}
numPairs = m_data->m_broadphaseDbvt->getOverlappingPairCache()->getNumOverlappingPairs();
@@ -153,7 +153,7 @@ void b3GpuRigidBodyPipeline::stepSimulation(float deltaTime)
cl_mem aabbsWS =0;
if (useDbvt)
{
BT_PROFILE("m_overlappingPairsGPU->copyFromHost");
B3_PROFILE("m_overlappingPairsGPU->copyFromHost");
m_data->m_overlappingPairsGPU->copyFromHost(m_data->m_broadphaseDbvt->getOverlappingPairCache()->getOverlappingPairArray());
pairs = m_data->m_overlappingPairsGPU->getBufferCL();
aabbsWS = m_data->m_allAabbsGPU->getBufferCL();
@@ -190,11 +190,11 @@ void b3GpuRigidBodyPipeline::stepSimulation(float deltaTime)
//solve constraints
btOpenCLArray<b3RigidBodyCL> gpuBodies(m_data->m_context,m_data->m_queue,0,true);
b3OpenCLArray<b3RigidBodyCL> gpuBodies(m_data->m_context,m_data->m_queue,0,true);
gpuBodies.setFromOpenCLBuffer(m_data->m_narrowphase->getBodiesGpu(),m_data->m_narrowphase->getNumBodiesGpu());
btOpenCLArray<btInertiaCL> gpuInertias(m_data->m_context,m_data->m_queue,0,true);
b3OpenCLArray<b3InertiaCL> gpuInertias(m_data->m_context,m_data->m_queue,0,true);
gpuInertias.setFromOpenCLBuffer(m_data->m_narrowphase->getBodyInertiasGpu(),m_data->m_narrowphase->getNumBodiesGpu());
btOpenCLArray<b3Contact4> gpuContacts(m_data->m_context,m_data->m_queue,0,true);
b3OpenCLArray<b3Contact4> gpuContacts(m_data->m_context,m_data->m_queue,0,true);
gpuContacts.setFromOpenCLBuffer(m_data->m_narrowphase->getContactsGpu(),m_data->m_narrowphase->getNumContactsGpu());
if (useBullet2CpuSolver)
@@ -202,7 +202,7 @@ void b3GpuRigidBodyPipeline::stepSimulation(float deltaTime)
b3AlignedObjectArray<b3RigidBodyCL> hostBodies;
gpuBodies.copyToHost(hostBodies);
b3AlignedObjectArray<btInertiaCL> hostInertias;
b3AlignedObjectArray<b3InertiaCL> hostInertias;
gpuInertias.copyToHost(hostInertias);
b3AlignedObjectArray<b3Contact4> hostContacts;
gpuContacts.copyToHost(hostContacts);
@@ -230,36 +230,36 @@ void b3GpuRigidBodyPipeline::stepSimulation(float deltaTime)
if (forceHost)
{
b3AlignedObjectArray<b3RigidBodyCL> hostBodies;
b3AlignedObjectArray<btInertiaCL> hostInertias;
b3AlignedObjectArray<b3InertiaCL> hostInertias;
b3AlignedObjectArray<b3Contact4> hostContacts;
{
BT_PROFILE("copyToHost");
B3_PROFILE("copyToHost");
gpuBodies.copyToHost(hostBodies);
gpuInertias.copyToHost(hostInertias);
gpuContacts.copyToHost(hostContacts);
}
{
btJacobiSolverInfo solverInfo;
b3JacobiSolverInfo solverInfo;
m_data->m_solver3->solveGroupHost(&hostBodies[0], &hostInertias[0], hostBodies.size(),&hostContacts[0],hostContacts.size(),0,0,solverInfo);
}
{
BT_PROFILE("copyFromHost");
B3_PROFILE("copyFromHost");
gpuBodies.copyFromHost(hostBodies);
}
} else
{
btJacobiSolverInfo solverInfo;
b3JacobiSolverInfo solverInfo;
m_data->m_solver3->solveGroup(&gpuBodies, &gpuInertias, &gpuContacts,solverInfo);
}
} else
{
b3AlignedObjectArray<b3RigidBodyCL> hostBodies;
gpuBodies.copyToHost(hostBodies);
b3AlignedObjectArray<btInertiaCL> hostInertias;
b3AlignedObjectArray<b3InertiaCL> hostInertias;
gpuInertias.copyToHost(hostInertias);
b3AlignedObjectArray<b3Contact4> hostContacts;
gpuContacts.copyToHost(hostContacts);
@@ -279,9 +279,9 @@ void b3GpuRigidBodyPipeline::stepSimulation(float deltaTime)
/*m_data->m_solver3->solveContactConstraintHost(
(btOpenCLArray<RigidBodyBase::Body>*)&gpuBodies,
(btOpenCLArray<RigidBodyBase::Inertia>*)&gpuInertias,
(btOpenCLArray<Constraint4>*) &gpuContacts,
(b3OpenCLArray<RigidBodyBase::Body>*)&gpuBodies,
(b3OpenCLArray<RigidBodyBase::Inertia>*)&gpuInertias,
(b3OpenCLArray<Constraint4>*) &gpuContacts,
0,numContacts,256);
*/
}
@@ -295,7 +295,7 @@ void b3GpuRigidBodyPipeline::integrate(float timeStep)
{
//integrate
btLauncherCL launcher(m_data->m_queue,m_data->m_integrateTransformsKernel);
b3LauncherCL launcher(m_data->m_queue,m_data->m_integrateTransformsKernel);
launcher.setBuffer(m_data->m_narrowphase->getBodiesGpu());
int numBodies = m_data->m_narrowphase->getNumBodiesGpu();
launcher.setConst(numBodies);
@@ -319,8 +319,8 @@ void b3GpuRigidBodyPipeline::setupGpuAabbsFull()
if (!numBodies)
return;
//__kernel void initializeGpuAabbsFull( const int numNodes, __global Body* gBodies,__global Collidable* collidables, __global btAABBCL* plocalShapeAABB, __global btAABBCL* pAABB)
btLauncherCL launcher(m_data->m_queue,m_data->m_updateAabbsKernel);
//__kernel void initializeGpuAabbsFull( const int numNodes, __global Body* gBodies,__global Collidable* collidables, __global b3AABBCL* plocalShapeAABB, __global b3AABBCL* pAABB)
b3LauncherCL launcher(m_data->m_queue,m_data->m_updateAabbsKernel);
launcher.setConst(numBodies);
cl_mem bodies = m_data->m_narrowphase->getBodiesGpu();
launcher.setBuffer(bodies);
@@ -379,7 +379,7 @@ int b3GpuRigidBodyPipeline::registerPhysicsInstance(float mass, const float* po
t.setIdentity();
t.setOrigin(b3Vector3(position[0],position[1],position[2]));
t.setRotation(b3Quaternion(orientation[0],orientation[1],orientation[2],orientation[3]));
btTransformAabb(localAabbMin,localAabbMax, margin,t,aabbMin,aabbMax);
b3TransformAabb(localAabbMin,localAabbMax, margin,t,aabbMin,aabbMax);
if (useDbvt)
{
m_data->m_broadphaseDbvt->createProxy(aabbMin,aabbMax,bodyIndex,0,1,1);

View File

@@ -1,5 +1,5 @@
#ifndef BT_GPU_RIGIDBODY_PIPELINE_H
#define BT_GPU_RIGIDBODY_PIPELINE_H
#ifndef B3_GPU_RIGIDBODY_PIPELINE_H
#define B3_GPU_RIGIDBODY_PIPELINE_H
#include "../../basic_initialize/b3OpenCLInclude.h"
@@ -27,7 +27,7 @@ public:
//int registerPlaneShape(const b3Vector3& planeNormal, float planeConstant);
//int registerConcaveMesh(b3AlignedObjectArray<b3Vector3>* vertices, b3AlignedObjectArray<int>* indices, const float* scaling);
//int registerCompoundShape(b3AlignedObjectArray<btGpuChildShape>* childShapes);
//int registerCompoundShape(b3AlignedObjectArray<b3GpuChildShape>* childShapes);
int registerPhysicsInstance(float mass, const float* position, const float* orientation, int collisionShapeIndex, int userData, bool writeInstanceToGpu);
@@ -42,4 +42,4 @@ public:
};
#endif //BT_GPU_RIGIDBODY_PIPELINE_H
#endif //B3_GPU_RIGIDBODY_PIPELINE_H

View File

@@ -1,10 +1,10 @@
#ifndef BT_GPU_RIGIDBODY_PIPELINE_INTERNAL_DATA_H
#define BT_GPU_RIGIDBODY_PIPELINE_INTERNAL_DATA_H
#ifndef B3_GPU_RIGIDBODY_PIPELINE_INTERNAL_DATA_H
#define B3_GPU_RIGIDBODY_PIPELINE_INTERNAL_DATA_H
#include "../../basic_initialize/b3OpenCLInclude.h"
#include "Bullet3Common/b3AlignedObjectArray.h"
#include "../../parallel_primitives/host/btOpenCLArray.h"
#include "../../parallel_primitives/host/b3OpenCLArray.h"
#include "../../gpu_narrowphase/host/b3Collidable.h"
#include "gpu_broadphase/host/b3SapAabb.h"
@@ -26,19 +26,19 @@ struct b3GpuRigidBodyPipelineInternalData
class b3PgsJacobiSolver* m_solver;
class b3GpuBatchingPgsSolver* m_solver2;
class btGpuJacobiSolver* m_solver3;
class b3GpuJacobiSolver* m_solver3;
class b3GpuSapBroadphase* m_broadphaseSap;
class b3DynamicBvhBroadphase* m_broadphaseDbvt;
btOpenCLArray<b3SapAabb>* m_allAabbsGPU;
b3OpenCLArray<b3SapAabb>* m_allAabbsGPU;
b3AlignedObjectArray<b3SapAabb> m_allAabbsCPU;
btOpenCLArray<btBroadphasePair>* m_overlappingPairsGPU;
b3OpenCLArray<b3BroadphasePair>* m_overlappingPairsGPU;
b3AlignedObjectArray<b3TypedConstraint*> m_joints;
class b3GpuNarrowPhase* m_narrowphase;
};
#endif //BT_GPU_RIGIDBODY_PIPELINE_INTERNAL_DATA_H
#endif //B3_GPU_RIGIDBODY_PIPELINE_INTERNAL_DATA_H

View File

@@ -40,7 +40,7 @@ bool useNewBatchingKernel = true;
#include "Bullet3Common/b3Quickprof.h"
#include "../../parallel_primitives/host/btLauncherCL.h"
#include "../../parallel_primitives/host/b3LauncherCL.h"
#include "Bullet3Common/b3Vector3.h"
struct SolverDebugInfo
@@ -80,8 +80,8 @@ class SolverDeviceInl
public:
struct ParallelSolveData
{
btOpenCLArray<unsigned int>* m_numConstraints;
btOpenCLArray<unsigned int>* m_offsets;
b3OpenCLArray<unsigned int>* m_numConstraints;
b3OpenCLArray<unsigned int>* m_offsets;
};
};
@@ -93,19 +93,19 @@ b3Solver::b3Solver(cl_context ctx, cl_device_id device, cl_command_queue queue,
m_device(device),
m_queue(queue)
{
m_sort32 = new btRadixSort32CL(ctx,device,queue);
m_scan = new btPrefixScanCL(ctx,device,queue,N_SPLIT*N_SPLIT);
m_search = new btBoundSearchCL(ctx,device,queue,N_SPLIT*N_SPLIT);
m_sort32 = new b3RadixSort32CL(ctx,device,queue);
m_scan = new b3PrefixScanCL(ctx,device,queue,N_SPLIT*N_SPLIT);
m_search = new b3BoundSearchCL(ctx,device,queue,N_SPLIT*N_SPLIT);
const int sortSize = BTNEXTMULTIPLEOF( pairCapacity, 512 );
const int sortSize = B3NEXTMULTIPLEOF( pairCapacity, 512 );
m_sortDataBuffer = new btOpenCLArray<btSortData>(ctx,queue,sortSize);
m_contactBuffer2 = new btOpenCLArray<b3Contact4>(ctx,queue);
m_sortDataBuffer = new b3OpenCLArray<b3SortData>(ctx,queue,sortSize);
m_contactBuffer2 = new b3OpenCLArray<b3Contact4>(ctx,queue);
m_numConstraints = new btOpenCLArray<unsigned int>(ctx,queue,N_SPLIT*N_SPLIT );
m_numConstraints = new b3OpenCLArray<unsigned int>(ctx,queue,N_SPLIT*N_SPLIT );
m_numConstraints->resize(N_SPLIT*N_SPLIT);
m_offsets = new btOpenCLArray<unsigned int>( ctx,queue, N_SPLIT*N_SPLIT );
m_offsets = new b3OpenCLArray<unsigned int>( ctx,queue, N_SPLIT*N_SPLIT );
m_offsets->resize(N_SPLIT*N_SPLIT);
const char* additionalMacros = "";
const char* srcFileNameForCaching="";
@@ -126,54 +126,54 @@ b3Solver::b3Solver(cl_context ctx, cl_device_id device, cl_command_queue queue,
{
cl_program solveContactProg= b3OpenCLUtils::compileCLProgramFromString( ctx, device, solveContactSource, &pErrNum,additionalMacros, SOLVER_CONTACT_KERNEL_PATH);
btAssert(solveContactProg);
b3Assert(solveContactProg);
cl_program solveFrictionProg= b3OpenCLUtils::compileCLProgramFromString( ctx, device, solveFrictionSource, &pErrNum,additionalMacros, SOLVER_FRICTION_KERNEL_PATH);
btAssert(solveFrictionProg);
b3Assert(solveFrictionProg);
cl_program solverSetup2Prog= b3OpenCLUtils::compileCLProgramFromString( ctx, device, solverSetup2Source, &pErrNum,additionalMacros, SOLVER_SETUP2_KERNEL_PATH);
btAssert(solverSetup2Prog);
b3Assert(solverSetup2Prog);
cl_program solverSetupProg= b3OpenCLUtils::compileCLProgramFromString( ctx, device, solverSetupSource, &pErrNum,additionalMacros, SOLVER_SETUP_KERNEL_PATH);
btAssert(solverSetupProg);
b3Assert(solverSetupProg);
m_solveFrictionKernel= b3OpenCLUtils::compileCLKernelFromString( ctx, device, solveFrictionSource, "BatchSolveKernelFriction", &pErrNum, solveFrictionProg,additionalMacros );
btAssert(m_solveFrictionKernel);
b3Assert(m_solveFrictionKernel);
m_solveContactKernel= b3OpenCLUtils::compileCLKernelFromString( ctx, device, solveContactSource, "BatchSolveKernelContact", &pErrNum, solveContactProg,additionalMacros );
btAssert(m_solveContactKernel);
b3Assert(m_solveContactKernel);
m_contactToConstraintKernel = b3OpenCLUtils::compileCLKernelFromString( ctx, device, solverSetupSource, "ContactToConstraintKernel", &pErrNum, solverSetupProg,additionalMacros );
btAssert(m_contactToConstraintKernel);
b3Assert(m_contactToConstraintKernel);
m_setSortDataKernel = b3OpenCLUtils::compileCLKernelFromString( ctx, device, solverSetup2Source, "SetSortDataKernel", &pErrNum, solverSetup2Prog,additionalMacros );
btAssert(m_setSortDataKernel);
b3Assert(m_setSortDataKernel);
m_reorderContactKernel = b3OpenCLUtils::compileCLKernelFromString( ctx, device, solverSetup2Source, "ReorderContactKernel", &pErrNum, solverSetup2Prog,additionalMacros );
btAssert(m_reorderContactKernel);
b3Assert(m_reorderContactKernel);
m_copyConstraintKernel = b3OpenCLUtils::compileCLKernelFromString( ctx, device, solverSetup2Source, "CopyConstraintKernel", &pErrNum, solverSetup2Prog,additionalMacros );
btAssert(m_copyConstraintKernel);
b3Assert(m_copyConstraintKernel);
}
{
cl_program batchingProg = b3OpenCLUtils::compileCLProgramFromString( ctx, device, batchKernelSource, &pErrNum,additionalMacros, BATCHING_PATH);
btAssert(batchingProg);
b3Assert(batchingProg);
m_batchingKernel = b3OpenCLUtils::compileCLKernelFromString( ctx, device, batchKernelSource, "CreateBatches", &pErrNum, batchingProg,additionalMacros );
btAssert(m_batchingKernel);
b3Assert(m_batchingKernel);
}
{
cl_program batchingNewProg = b3OpenCLUtils::compileCLProgramFromString( ctx, device, batchKernelNewSource, &pErrNum,additionalMacros, BATCHING_NEW_PATH);
btAssert(batchingNewProg);
b3Assert(batchingNewProg);
m_batchingKernelNew = b3OpenCLUtils::compileCLKernelFromString( ctx, device, batchKernelNewSource, "CreateBatchesNew", &pErrNum, batchingNewProg,additionalMacros );
//m_batchingKernelNew = b3OpenCLUtils::compileCLKernelFromString( ctx, device, batchKernelNewSource, "CreateBatchesBruteForce", &pErrNum, batchingNewProg,additionalMacros );
btAssert(m_batchingKernelNew);
b3Assert(m_batchingKernelNew);
}
}
@@ -204,9 +204,9 @@ b3Solver::~b3Solver()
/*void b3Solver::reorderConvertToConstraints( const btOpenCLArray<b3RigidBodyCL>* bodyBuf,
const btOpenCLArray<btInertiaCL>* shapeBuf,
btOpenCLArray<b3Contact4>* contactsIn, btOpenCLArray<b3GpuConstraint4>* contactCOut, void* additionalData,
/*void b3Solver::reorderConvertToConstraints( const b3OpenCLArray<b3RigidBodyCL>* bodyBuf,
const b3OpenCLArray<b3InertiaCL>* shapeBuf,
b3OpenCLArray<b3Contact4>* contactsIn, b3OpenCLArray<b3GpuConstraint4>* contactCOut, void* additionalData,
int nContacts, const b3Solver::ConstraintCfg& cfg )
{
if( m_contactBuffer )
@@ -215,8 +215,8 @@ b3Solver::~b3Solver()
}
if( m_contactBuffer == 0 )
{
BT_PROFILE("new m_contactBuffer;");
m_contactBuffer = new btOpenCLArray<b3Contact4>(m_context,m_queue,nContacts );
B3_PROFILE("new m_contactBuffer;");
m_contactBuffer = new b3OpenCLArray<b3Contact4>(m_context,m_queue,nContacts );
m_contactBuffer->resize(nContacts);
}
@@ -233,47 +233,47 @@ b3Solver::~b3Solver()
// contactsIn -> m_contactBuffer
{
BT_PROFILE("sortContacts");
B3_PROFILE("sortContacts");
sortContacts( bodyBuf, contactsIn, additionalData, nContacts, cfg );
clFinish(m_queue);
}
{
BT_PROFILE("m_copyConstraintKernel");
B3_PROFILE("m_copyConstraintKernel");
btInt4 cdata; cdata.x = nContacts;
btBufferInfoCL bInfo[] = { btBufferInfoCL( m_contactBuffer->getBufferCL() ), btBufferInfoCL( contactsIn->getBufferCL() ) };
// btLauncherCL launcher( m_queue, data->m_device->getKernel( PATH, "CopyConstraintKernel", "-I ..\\..\\ -Wf,--c++", 0 ) );
btLauncherCL launcher( m_queue, m_copyConstraintKernel );
launcher.setBuffers( bInfo, sizeof(bInfo)/sizeof(btBufferInfoCL) );
b3Int4 cdata; cdata.x = nContacts;
b3BufferInfoCL bInfo[] = { b3BufferInfoCL( m_contactBuffer->getBufferCL() ), b3BufferInfoCL( contactsIn->getBufferCL() ) };
// b3LauncherCL launcher( m_queue, data->m_device->getKernel( PATH, "CopyConstraintKernel", "-I ..\\..\\ -Wf,--c++", 0 ) );
b3LauncherCL launcher( m_queue, m_copyConstraintKernel );
launcher.setBuffers( bInfo, sizeof(bInfo)/sizeof(b3BufferInfoCL) );
launcher.setConst( cdata );
launcher.launch1D( nContacts, 64 );
clFinish(m_queue);
}
{
BT_PROFILE("batchContacts");
B3_PROFILE("batchContacts");
b3Solver::batchContacts( contactsIn, nContacts, m_numConstraints, m_offsets, cfg.m_staticIdx );
}
}
{
BT_PROFILE("waitForCompletion (batchContacts)");
B3_PROFILE("waitForCompletion (batchContacts)");
clFinish(m_queue);
}
//================
{
BT_PROFILE("convertToConstraints");
B3_PROFILE("convertToConstraints");
b3Solver::convertToConstraints( bodyBuf, shapeBuf, contactsIn, contactCOut, additionalData, nContacts, cfg );
}
{
BT_PROFILE("convertToConstraints waitForCompletion");
B3_PROFILE("convertToConstraints waitForCompletion");
clFinish(m_queue);
}
@@ -285,7 +285,7 @@ b3Solver::~b3Solver()
float calcRelVel(const b3Vector3& l0, const b3Vector3& l1, const b3Vector3& a0, const b3Vector3& a1,
const b3Vector3& linVel0, const b3Vector3& angVel0, const b3Vector3& linVel1, const b3Vector3& angVel1)
{
return btDot(l0, linVel0) + btDot(a0, angVel0) + btDot(l1, linVel1) + btDot(a1, angVel1);
return b3Dot(l0, linVel0) + b3Dot(a0, angVel0) + b3Dot(l1, linVel1) + b3Dot(a1, angVel1);
}
@@ -295,8 +295,8 @@ b3Solver::~b3Solver()
b3Vector3& linear, b3Vector3& angular0, b3Vector3& angular1)
{
linear = -n;
angular0 = -btCross(r0, n);
angular1 = btCross(r1, n);
angular0 = -b3Cross(r0, n);
angular1 = b3Cross(r1, n);
}
@@ -333,8 +333,8 @@ void solveContact(b3GpuConstraint4& cs,
float prevSum = cs.m_appliedRambdaDt[ic];
float updated = prevSum;
updated += rambdaDt;
updated = btMax( updated, minRambdaDt[ic] );
updated = btMin( updated, maxRambdaDt[ic] );
updated = b3Max( updated, minRambdaDt[ic] );
updated = b3Min( updated, maxRambdaDt[ic] );
rambdaDt = updated - prevSum;
cs.m_appliedRambdaDt[ic] = updated;
}
@@ -344,8 +344,8 @@ void solveContact(b3GpuConstraint4& cs,
b3Vector3 angImp0 = (invInertiaA* angular0)*rambdaDt;
b3Vector3 angImp1 = (invInertiaB* angular1)*rambdaDt;
#ifdef _WIN32
btAssert(_finite(linImp0.getX()));
btAssert(_finite(linImp1.getX()));
b3Assert(_finite(linImp0.getX()));
b3Assert(_finite(linImp1.getX()));
#endif
if( JACOBI )
{
@@ -393,7 +393,7 @@ void solveContact(b3GpuConstraint4& cs,
b3Vector3 tangent[2];
#if 1
btPlaneSpace1 (n, tangent[0],tangent[1]);
b3PlaneSpace1 (n, tangent[0],tangent[1]);
#else
b3Vector3 r = cs.m_worldPos[0]-center;
tangent[0] = cross3( n, r );
@@ -416,8 +416,8 @@ void solveContact(b3GpuConstraint4& cs,
float prevSum = cs.m_fAppliedRambdaDt[i];
float updated = prevSum;
updated += rambdaDt;
updated = btMax( updated, minRambdaDt[i] );
updated = btMin( updated, maxRambdaDt[i] );
updated = b3Max( updated, minRambdaDt[i] );
updated = b3Min( updated, maxRambdaDt[i] );
rambdaDt = updated - prevSum;
cs.m_fAppliedRambdaDt[i] = updated;
}
@@ -427,8 +427,8 @@ void solveContact(b3GpuConstraint4& cs,
b3Vector3 angImp0 = (invInertiaA* angular0)*rambdaDt;
b3Vector3 angImp1 = (invInertiaB* angular1)*rambdaDt;
#ifdef _WIN32
btAssert(_finite(linImp0.getX()));
btAssert(_finite(linImp1.getX()));
b3Assert(_finite(linImp0.getX()));
b3Assert(_finite(linImp1.getX()));
#endif
linVelA += linImp0;
angVelA += angImp0;
@@ -439,10 +439,10 @@ void solveContact(b3GpuConstraint4& cs,
{ // angular damping for point constraint
b3Vector3 ab = ( posB - posA ).normalized();
b3Vector3 ac = ( center - posA ).normalized();
if( btDot( ab, ac ) > 0.95f || (invMassA == 0.f || invMassB == 0.f))
if( b3Dot( ab, ac ) > 0.95f || (invMassA == 0.f || invMassB == 0.f))
{
float angNA = btDot( n, angVelA );
float angNB = btDot( n, angVelB );
float angNA = b3Dot( n, angVelA );
float angNB = b3Dot( n, angVelB );
angVelA -= (angNA*0.1f)*n;
angVelB -= (angNB*0.1f)*n;
@@ -454,7 +454,7 @@ void solveContact(b3GpuConstraint4& cs,
struct SolveTask// : public ThreadPool::Task
{
SolveTask(b3AlignedObjectArray<b3RigidBodyCL>& bodies, b3AlignedObjectArray<btInertiaCL>& shapes, b3AlignedObjectArray<b3GpuConstraint4>& constraints,
SolveTask(b3AlignedObjectArray<b3RigidBodyCL>& bodies, b3AlignedObjectArray<b3InertiaCL>& shapes, b3AlignedObjectArray<b3GpuConstraint4>& constraints,
int start, int nConstraints)
: m_bodies( bodies ), m_shapes( shapes ), m_constraints( constraints ), m_start( start ), m_nConstraints( nConstraints ),
m_solveFriction( true ){}
@@ -513,7 +513,7 @@ struct SolveTask// : public ThreadPool::Task
}
b3AlignedObjectArray<b3RigidBodyCL>& m_bodies;
b3AlignedObjectArray<btInertiaCL>& m_shapes;
b3AlignedObjectArray<b3InertiaCL>& m_shapes;
b3AlignedObjectArray<b3GpuConstraint4>& m_constraints;
int m_start;
int m_nConstraints;
@@ -521,13 +521,13 @@ struct SolveTask// : public ThreadPool::Task
};
void b3Solver::solveContactConstraintHost( btOpenCLArray<b3RigidBodyCL>* bodyBuf, btOpenCLArray<btInertiaCL>* shapeBuf,
btOpenCLArray<b3GpuConstraint4>* constraint, void* additionalData, int n ,int maxNumBatches)
void b3Solver::solveContactConstraintHost( b3OpenCLArray<b3RigidBodyCL>* bodyBuf, b3OpenCLArray<b3InertiaCL>* shapeBuf,
b3OpenCLArray<b3GpuConstraint4>* constraint, void* additionalData, int n ,int maxNumBatches)
{
b3AlignedObjectArray<b3RigidBodyCL> bodyNative;
bodyBuf->copyToHost(bodyNative);
b3AlignedObjectArray<btInertiaCL> shapeNative;
b3AlignedObjectArray<b3InertiaCL> shapeNative;
shapeBuf->copyToHost(shapeNative);
b3AlignedObjectArray<b3GpuConstraint4> constraintNative;
constraint->copyToHost(constraintNative);
@@ -553,12 +553,12 @@ void b3Solver::solveContactConstraintHost( btOpenCLArray<b3RigidBodyCL>* bodyBu
}
void b3Solver::solveContactConstraint( const btOpenCLArray<b3RigidBodyCL>* bodyBuf, const btOpenCLArray<btInertiaCL>* shapeBuf,
btOpenCLArray<b3GpuConstraint4>* constraint, void* additionalData, int n ,int maxNumBatches)
void b3Solver::solveContactConstraint( const b3OpenCLArray<b3RigidBodyCL>* bodyBuf, const b3OpenCLArray<b3InertiaCL>* shapeBuf,
b3OpenCLArray<b3GpuConstraint4>* constraint, void* additionalData, int n ,int maxNumBatches)
{
btInt4 cdata = btMakeInt4( n, 0, 0, 0 );
b3Int4 cdata = b3MakeInt4( n, 0, 0, 0 );
{
const int nn = N_SPLIT*N_SPLIT;
@@ -570,14 +570,14 @@ void b3Solver::solveContactConstraint( const btOpenCLArray<b3RigidBodyCL>* body
int numWorkItems = 64*nn/N_BATCHES;
#ifdef DEBUG_ME
SolverDebugInfo* debugInfo = new SolverDebugInfo[numWorkItems];
adl::btOpenCLArray<SolverDebugInfo> gpuDebugInfo(data->m_device,numWorkItems);
adl::b3OpenCLArray<SolverDebugInfo> gpuDebugInfo(data->m_device,numWorkItems);
#endif
{
BT_PROFILE("m_batchSolveKernel iterations");
B3_PROFILE("m_batchSolveKernel iterations");
for(int iter=0; iter<m_nIterations; iter++)
{
for(int ib=0; ib<N_BATCHES; ib++)
@@ -591,24 +591,24 @@ void b3Solver::solveContactConstraint( const btOpenCLArray<b3RigidBodyCL>* body
cdata.z = ib;
cdata.w = N_SPLIT;
btLauncherCL launcher( m_queue, m_solveContactKernel );
b3LauncherCL launcher( m_queue, m_solveContactKernel );
#if 1
btBufferInfoCL bInfo[] = {
b3BufferInfoCL bInfo[] = {
btBufferInfoCL( bodyBuf->getBufferCL() ),
btBufferInfoCL( shapeBuf->getBufferCL() ),
btBufferInfoCL( constraint->getBufferCL() ),
btBufferInfoCL( m_numConstraints->getBufferCL() ),
btBufferInfoCL( m_offsets->getBufferCL() )
b3BufferInfoCL( bodyBuf->getBufferCL() ),
b3BufferInfoCL( shapeBuf->getBufferCL() ),
b3BufferInfoCL( constraint->getBufferCL() ),
b3BufferInfoCL( m_numConstraints->getBufferCL() ),
b3BufferInfoCL( m_offsets->getBufferCL() )
#ifdef DEBUG_ME
, btBufferInfoCL(&gpuDebugInfo)
, b3BufferInfoCL(&gpuDebugInfo)
#endif
};
launcher.setBuffers( bInfo, sizeof(bInfo)/sizeof(btBufferInfoCL) );
launcher.setBuffers( bInfo, sizeof(bInfo)/sizeof(b3BufferInfoCL) );
//launcher.setConst( cdata.x );
launcher.setConst( cdata.y );
launcher.setConst( cdata.z );
@@ -673,7 +673,7 @@ void b3Solver::solveContactConstraint( const btOpenCLArray<b3RigidBodyCL>* body
bool applyFriction=true;
if (applyFriction)
{
BT_PROFILE("m_batchSolveKernel iterations2");
B3_PROFILE("m_batchSolveKernel iterations2");
for(int iter=0; iter<m_nIterations; iter++)
{
for(int ib=0; ib<N_BATCHES; ib++)
@@ -681,18 +681,18 @@ void b3Solver::solveContactConstraint( const btOpenCLArray<b3RigidBodyCL>* body
cdata.z = ib;
cdata.w = N_SPLIT;
btBufferInfoCL bInfo[] = {
btBufferInfoCL( bodyBuf->getBufferCL() ),
btBufferInfoCL( shapeBuf->getBufferCL() ),
btBufferInfoCL( constraint->getBufferCL() ),
btBufferInfoCL( m_numConstraints->getBufferCL() ),
btBufferInfoCL( m_offsets->getBufferCL() )
b3BufferInfoCL bInfo[] = {
b3BufferInfoCL( bodyBuf->getBufferCL() ),
b3BufferInfoCL( shapeBuf->getBufferCL() ),
b3BufferInfoCL( constraint->getBufferCL() ),
b3BufferInfoCL( m_numConstraints->getBufferCL() ),
b3BufferInfoCL( m_offsets->getBufferCL() )
#ifdef DEBUG_ME
,btBufferInfoCL(&gpuDebugInfo)
,b3BufferInfoCL(&gpuDebugInfo)
#endif //DEBUG_ME
};
btLauncherCL launcher( m_queue, m_solveFrictionKernel );
launcher.setBuffers( bInfo, sizeof(bInfo)/sizeof(btBufferInfoCL) );
b3LauncherCL launcher( m_queue, m_solveFrictionKernel );
launcher.setBuffers( bInfo, sizeof(bInfo)/sizeof(b3BufferInfoCL) );
//launcher.setConst( cdata.x );
launcher.setConst( cdata.y );
launcher.setConst( cdata.z );
@@ -712,12 +712,12 @@ void b3Solver::solveContactConstraint( const btOpenCLArray<b3RigidBodyCL>* body
}
void b3Solver::convertToConstraints( const btOpenCLArray<b3RigidBodyCL>* bodyBuf,
const btOpenCLArray<btInertiaCL>* shapeBuf,
btOpenCLArray<b3Contact4>* contactsIn, btOpenCLArray<b3GpuConstraint4>* contactCOut, void* additionalData,
void b3Solver::convertToConstraints( const b3OpenCLArray<b3RigidBodyCL>* bodyBuf,
const b3OpenCLArray<b3InertiaCL>* shapeBuf,
b3OpenCLArray<b3Contact4>* contactsIn, b3OpenCLArray<b3GpuConstraint4>* contactCOut, void* additionalData,
int nContacts, const ConstraintCfg& cfg )
{
btOpenCLArray<b3GpuConstraint4>* constraintNative =0;
b3OpenCLArray<b3GpuConstraint4>* constraintNative =0;
struct CB
{
@@ -728,7 +728,7 @@ void b3Solver::convertToConstraints( const btOpenCLArray<b3RigidBodyCL>* bodyBuf
};
{
BT_PROFILE("m_contactToConstraintKernel");
B3_PROFILE("m_contactToConstraintKernel");
CB cdata;
cdata.m_nContacts = nContacts;
cdata.m_dt = cfg.m_dt;
@@ -736,10 +736,10 @@ void b3Solver::convertToConstraints( const btOpenCLArray<b3RigidBodyCL>* bodyBuf
cdata.m_positionConstraintCoeff = cfg.m_positionConstraintCoeff;
btBufferInfoCL bInfo[] = { btBufferInfoCL( contactsIn->getBufferCL() ), btBufferInfoCL( bodyBuf->getBufferCL() ), btBufferInfoCL( shapeBuf->getBufferCL()),
btBufferInfoCL( contactCOut->getBufferCL() )};
btLauncherCL launcher( m_queue, m_contactToConstraintKernel );
launcher.setBuffers( bInfo, sizeof(bInfo)/sizeof(btBufferInfoCL) );
b3BufferInfoCL bInfo[] = { b3BufferInfoCL( contactsIn->getBufferCL() ), b3BufferInfoCL( bodyBuf->getBufferCL() ), b3BufferInfoCL( shapeBuf->getBufferCL()),
b3BufferInfoCL( contactCOut->getBufferCL() )};
b3LauncherCL launcher( m_queue, m_contactToConstraintKernel );
launcher.setBuffers( bInfo, sizeof(bInfo)/sizeof(b3BufferInfoCL) );
//launcher.setConst( cdata );
launcher.setConst(cdata.m_nContacts);
@@ -756,8 +756,8 @@ void b3Solver::convertToConstraints( const btOpenCLArray<b3RigidBodyCL>* bodyBuf
}
/*
void b3Solver::sortContacts( const btOpenCLArray<b3RigidBodyCL>* bodyBuf,
btOpenCLArray<b3Contact4>* contactsIn, void* additionalData,
void b3Solver::sortContacts( const b3OpenCLArray<b3RigidBodyCL>* bodyBuf,
b3OpenCLArray<b3Contact4>* contactsIn, void* additionalData,
int nContacts, const b3Solver::ConstraintCfg& cfg )
{
@@ -770,8 +770,8 @@ void b3Solver::sortContacts( const btOpenCLArray<b3RigidBodyCL>* bodyBuf,
int sortSize = NEXTMULTIPLEOF( nContacts, sortAlignment );
btOpenCLArray<unsigned int>* countsNative = m_numConstraints;//BufferUtils::map<TYPE_CL, false>( data->m_device, &countsHost );
btOpenCLArray<unsigned int>* offsetsNative = m_offsets;//BufferUtils::map<TYPE_CL, false>( data->m_device, &offsetsHost );
b3OpenCLArray<unsigned int>* countsNative = m_numConstraints;//BufferUtils::map<TYPE_CL, false>( data->m_device, &countsHost );
b3OpenCLArray<unsigned int>* offsetsNative = m_offsets;//BufferUtils::map<TYPE_CL, false>( data->m_device, &offsetsHost );
{ // 2. set cell idx
struct CB
@@ -782,7 +782,7 @@ void b3Solver::sortContacts( const btOpenCLArray<b3RigidBodyCL>* bodyBuf,
int m_nSplit;
};
btAssert( sortSize%64 == 0 );
b3Assert( sortSize%64 == 0 );
CB cdata;
cdata.m_nContacts = nContacts;
cdata.m_staticIdx = cfg.m_staticIdx;
@@ -790,9 +790,9 @@ void b3Solver::sortContacts( const btOpenCLArray<b3RigidBodyCL>* bodyBuf,
cdata.m_nSplit = N_SPLIT;
btBufferInfoCL bInfo[] = { btBufferInfoCL( contactsIn->getBufferCL() ), btBufferInfoCL( bodyBuf->getBufferCL() ), btBufferInfoCL( m_sortDataBuffer->getBufferCL() ) };
btLauncherCL launcher( m_queue, m_setSortDataKernel );
launcher.setBuffers( bInfo, sizeof(bInfo)/sizeof(btBufferInfoCL) );
b3BufferInfoCL bInfo[] = { b3BufferInfoCL( contactsIn->getBufferCL() ), b3BufferInfoCL( bodyBuf->getBufferCL() ), b3BufferInfoCL( m_sortDataBuffer->getBufferCL() ) };
b3LauncherCL launcher( m_queue, m_setSortDataKernel );
launcher.setBuffers( bInfo, sizeof(bInfo)/sizeof(b3BufferInfoCL) );
launcher.setConst( cdata );
launcher.launch1D( sortSize, 64 );
}
@@ -805,23 +805,23 @@ void b3Solver::sortContacts( const btOpenCLArray<b3RigidBodyCL>* bodyBuf,
m_sort32->execute(*m_sortDataBuffer,sortSize);
}
{ // 4. find entries
m_search->execute( *m_sortDataBuffer, nContacts, *countsNative, N_SPLIT*N_SPLIT, btBoundSearchCL::COUNT);
m_search->execute( *m_sortDataBuffer, nContacts, *countsNative, N_SPLIT*N_SPLIT, b3BoundSearchCL::COUNT);
m_scan->execute( *countsNative, *offsetsNative, N_SPLIT*N_SPLIT );
}
{ // 5. sort constraints by cellIdx
// todo. preallocate this
// btAssert( contactsIn->getType() == TYPE_HOST );
// btOpenCLArray<b3Contact4>* out = BufferUtils::map<TYPE_CL, false>( data->m_device, contactsIn ); // copying contacts to this buffer
// b3Assert( contactsIn->getType() == TYPE_HOST );
// b3OpenCLArray<b3Contact4>* out = BufferUtils::map<TYPE_CL, false>( data->m_device, contactsIn ); // copying contacts to this buffer
{
btInt4 cdata; cdata.x = nContacts;
btBufferInfoCL bInfo[] = { btBufferInfoCL( contactsIn->getBufferCL() ), btBufferInfoCL( m_contactBuffer->getBufferCL() ), btBufferInfoCL( m_sortDataBuffer->getBufferCL() ) };
btLauncherCL launcher( m_queue, m_reorderContactKernel );
launcher.setBuffers( bInfo, sizeof(bInfo)/sizeof(btBufferInfoCL) );
b3Int4 cdata; cdata.x = nContacts;
b3BufferInfoCL bInfo[] = { b3BufferInfoCL( contactsIn->getBufferCL() ), b3BufferInfoCL( m_contactBuffer->getBufferCL() ), b3BufferInfoCL( m_sortDataBuffer->getBufferCL() ) };
b3LauncherCL launcher( m_queue, m_reorderContactKernel );
launcher.setBuffers( bInfo, sizeof(bInfo)/sizeof(b3BufferInfoCL) );
launcher.setConst( cdata );
launcher.launch1D( nContacts, 64 );
}
@@ -834,14 +834,14 @@ void b3Solver::sortContacts( const btOpenCLArray<b3RigidBodyCL>* bodyBuf,
*/
void b3Solver::batchContacts( btOpenCLArray<b3Contact4>* contacts, int nContacts, btOpenCLArray<unsigned int>* nNative, btOpenCLArray<unsigned int>* offsetsNative, int staticIdx )
void b3Solver::batchContacts( b3OpenCLArray<b3Contact4>* contacts, int nContacts, b3OpenCLArray<unsigned int>* nNative, b3OpenCLArray<unsigned int>* offsetsNative, int staticIdx )
{
int numWorkItems = 64*N_SPLIT*N_SPLIT;
{
BT_PROFILE("batch generation");
B3_PROFILE("batch generation");
btInt4 cdata;
b3Int4 cdata;
cdata.x = nContacts;
cdata.y = 0;
cdata.z = staticIdx;
@@ -849,7 +849,7 @@ void b3Solver::batchContacts( btOpenCLArray<b3Contact4>* contacts, int nContact
#ifdef BATCH_DEBUG
SolverDebugInfo* debugInfo = new SolverDebugInfo[numWorkItems];
adl::btOpenCLArray<SolverDebugInfo> gpuDebugInfo(data->m_device,numWorkItems);
adl::b3OpenCLArray<SolverDebugInfo> gpuDebugInfo(data->m_device,numWorkItems);
memset(debugInfo,0,sizeof(SolverDebugInfo)*numWorkItems);
gpuDebugInfo.write(debugInfo,numWorkItems);
#endif
@@ -857,13 +857,13 @@ void b3Solver::batchContacts( btOpenCLArray<b3Contact4>* contacts, int nContact
btBufferInfoCL bInfo[] = {
btBufferInfoCL( contacts->getBufferCL() ),
btBufferInfoCL( m_contactBuffer2->getBufferCL()),
btBufferInfoCL( nNative->getBufferCL() ),
btBufferInfoCL( offsetsNative->getBufferCL() ),
b3BufferInfoCL bInfo[] = {
b3BufferInfoCL( contacts->getBufferCL() ),
b3BufferInfoCL( m_contactBuffer2->getBufferCL()),
b3BufferInfoCL( nNative->getBufferCL() ),
b3BufferInfoCL( offsetsNative->getBufferCL() ),
#ifdef BATCH_DEBUG
, btBufferInfoCL(&gpuDebugInfo)
, b3BufferInfoCL(&gpuDebugInfo)
#endif
};
@@ -871,11 +871,11 @@ void b3Solver::batchContacts( btOpenCLArray<b3Contact4>* contacts, int nContact
{
BT_PROFILE("batchingKernel");
//btLauncherCL launcher( m_queue, m_batchingKernel);
B3_PROFILE("batchingKernel");
//b3LauncherCL launcher( m_queue, m_batchingKernel);
cl_kernel k = useNewBatchingKernel ? m_batchingKernelNew : m_batchingKernel;
btLauncherCL launcher( m_queue, k);
b3LauncherCL launcher( m_queue, k);
if (!useNewBatchingKernel )
{
launcher.setBuffer( contacts->getBufferCL() );
@@ -927,7 +927,7 @@ void b3Solver::batchContacts( btOpenCLArray<b3Contact4>* contacts, int nContact
}
// copy buffer to buffer
//btAssert(m_contactBuffer->size()==nContacts);
//b3Assert(m_contactBuffer->size()==nContacts);
//contacts->copyFromOpenCLArray( *m_contactBuffer);
//clFinish(m_queue);//needed?

View File

@@ -17,20 +17,20 @@ subject to the following restrictions:
#ifndef __ADL_SOLVER_H
#define __ADL_SOLVER_H
#include "../../parallel_primitives/host/btOpenCLArray.h"
#include "../../parallel_primitives/host/b3OpenCLArray.h"
#include "../host/b3GpuConstraint4.h"
#include "Bullet3Collision/NarrowPhaseCollision/b3RigidBodyCL.h"
#include "Bullet3Collision/NarrowPhaseCollision/b3Contact4.h"
#include "../host/b3GpuConstraint4.h"
#include "../../parallel_primitives/host/btPrefixScanCL.h"
#include "../../parallel_primitives/host/btRadixSort32CL.h"
#include "../../parallel_primitives/host/btBoundSearchCL.h"
#include "../../parallel_primitives/host/b3PrefixScanCL.h"
#include "../../parallel_primitives/host/b3RadixSort32CL.h"
#include "../../parallel_primitives/host/b3BoundSearchCL.h"
#include "../../basic_initialize/b3OpenCLUtils.h"
#define BTNEXTMULTIPLEOF(num, alignment) (((num)/(alignment) + (((num)%(alignment)==0)?0:1))*(alignment))
#define B3NEXTMULTIPLEOF(num, alignment) (((num)/(alignment) + (((num)%(alignment)==0)?0:1))*(alignment))
class b3SolverBase
{
@@ -69,8 +69,8 @@ class b3Solver : public b3SolverBase
cl_command_queue m_queue;
btOpenCLArray<unsigned int>* m_numConstraints;
btOpenCLArray<unsigned int>* m_offsets;
b3OpenCLArray<unsigned int>* m_numConstraints;
b3OpenCLArray<unsigned int>* m_offsets;
int m_nIterations;
@@ -83,12 +83,12 @@ class b3Solver : public b3SolverBase
cl_kernel m_reorderContactKernel;
cl_kernel m_copyConstraintKernel;
class btRadixSort32CL* m_sort32;
class btBoundSearchCL* m_search;
class btPrefixScanCL* m_scan;
class b3RadixSort32CL* m_sort32;
class b3BoundSearchCL* m_search;
class b3PrefixScanCL* m_scan;
btOpenCLArray<btSortData>* m_sortDataBuffer;
btOpenCLArray<b3Contact4>* m_contactBuffer2;
b3OpenCLArray<b3SortData>* m_sortDataBuffer;
b3OpenCLArray<b3Contact4>* m_contactBuffer2;
enum
{
@@ -102,19 +102,19 @@ class b3Solver : public b3SolverBase
virtual ~b3Solver();
void solveContactConstraint( const btOpenCLArray<b3RigidBodyCL>* bodyBuf, const btOpenCLArray<btInertiaCL>* inertiaBuf,
btOpenCLArray<b3GpuConstraint4>* constraint, void* additionalData, int n ,int maxNumBatches);
void solveContactConstraint( const b3OpenCLArray<b3RigidBodyCL>* bodyBuf, const b3OpenCLArray<b3InertiaCL>* inertiaBuf,
b3OpenCLArray<b3GpuConstraint4>* constraint, void* additionalData, int n ,int maxNumBatches);
void solveContactConstraintHost( btOpenCLArray<b3RigidBodyCL>* bodyBuf, btOpenCLArray<btInertiaCL>* shapeBuf,
btOpenCLArray<b3GpuConstraint4>* constraint, void* additionalData, int n ,int maxNumBatches);
void solveContactConstraintHost( b3OpenCLArray<b3RigidBodyCL>* bodyBuf, b3OpenCLArray<b3InertiaCL>* shapeBuf,
b3OpenCLArray<b3GpuConstraint4>* constraint, void* additionalData, int n ,int maxNumBatches);
void convertToConstraints( const btOpenCLArray<b3RigidBodyCL>* bodyBuf,
const btOpenCLArray<btInertiaCL>* shapeBuf,
btOpenCLArray<b3Contact4>* contactsIn, btOpenCLArray<b3GpuConstraint4>* contactCOut, void* additionalData,
void convertToConstraints( const b3OpenCLArray<b3RigidBodyCL>* bodyBuf,
const b3OpenCLArray<b3InertiaCL>* shapeBuf,
b3OpenCLArray<b3Contact4>* contactsIn, b3OpenCLArray<b3GpuConstraint4>* contactCOut, void* additionalData,
int nContacts, const ConstraintCfg& cfg );
void batchContacts( btOpenCLArray<b3Contact4>* contacts, int nContacts, btOpenCLArray<unsigned int>* n, btOpenCLArray<unsigned int>* offsets, int staticIdx );
void batchContacts( b3OpenCLArray<b3Contact4>* contacts, int nContacts, b3OpenCLArray<unsigned int>* n, b3OpenCLArray<unsigned int>* offsets, int staticIdx );
};