1) Initialize CL (I copied over the demo files and just call their InitCL() function in clstuff.cpp)
2) Provide the soft body solver as the 5th argument to the soft/rigid dynamics world:
Code: Select all
btSoftBodySolver* softBodySolver = new btCPUSoftBodySolver;
btSoftRigidDynamicsWorld* dynamicsWorld = new btSoftRigidDynamicsWorld(dispatcher, broadphase, solver, collisionConfiguration, softBodySolver);
Code: Select all
softBodySolver->optimize(dynamicsWorld->getSoftBodyArray();
I already had a soft dynamics world working before; all I did was add the above. I have everything compiled and linked correctly, and the simulation runs, but my soft body does not seem to be updated properly. The bounding box is actually falling (gravity) correctly (I render the aabb separately and monitor its position), but the mesh vertices (as retrieved via softBody->m_nodes.m_x) remain stationary, and then after 5-10 seconds they just disappear (but output indicates they are still stationary at their original location). My knowledge of OpenCL (and bullet's use of it) is very limited, and I could well be missing something. The only other thing that caught my eye in the demo was use of a (btSoftBodySolverOutput*) member, but from what I could tell this is just used for demo rendering purposes, so I didn't include it in my own. My rendering is done through btOgre, which updates vertex positions from the soft body's m_nodes array, but like I said the vertices don't seem to change.
Just trying to hack together a working test at the moment, without any real knowledge of OpenCL or how bullet is using it. For all I know it wouldn't even work on my system. I am running Mac OS X 10.6 on an Intel Core i5 iMac, with ATI Radeon HD 4850 graphics. I have not specifically installed any drivers or CL frameworks myself; just using what is provided in the bullet source code. However, I can run both the AppVectorAdd_Mini and AppVectorAdd_Apple with success (as noted in the output), which suggests to me that I have the appropriate setup for using OpenCL. I get varying results with the other CL demos:
1) AppOpenCLClothDemo_Mini: Doesn't compile for me (linker error, can't find _clGetProgramInfo symbol)
2) AppOpenCLClothDemo_Apple: Compiles but throws a runtime error (the btAssert(0) at line 1488 of btSoftBodySolver_CPU.cpp) with an error log:
Error in clBuildProgram, Line 1485 in file /Users/Dave/Documents/Bullet Physics/bullet-2.78/src/BulletMultiThreaded/GpuSoftBodySolvers/OpenCL/btSoftBodySolver_OpenCL.cpp, Log:
cvmsErrorCompilerFailure: LLVM compiler has failed to compile a function.
3) AppParticlesOCL_Mini: Compiles and runs, even with correct-looking particle dynamics. However the performance is rather slow (~250ms/step)
4) AppParticlesOCL_Apple: Compiles, but gives runtime error:
OpenCL compiles ParticlesOCL.cl ...
cvmsErrorCompilerFailure: LLVM compiler has failed to compile a function.
Any tips are much appreciated.