Add posix thread backend to BulletMultiThreaded. Contributed by Enrico.

This commit is contained in:
john.mccutchan
2008-04-01 18:32:41 +00:00
parent 64df6edf39
commit ba27e0522b
13 changed files with 356 additions and 17 deletions

View File

@@ -43,6 +43,7 @@ ELSE (WIN32)
# SET(CMAKE_BUILD_TYPE Debug)
# SET(CMAKE_CXX_FLAGS_DEBUG "-g")
INCLUDE_DIRECTORIES(/usr/include /usr/local/include ${GLUT_INCLUDE_DIR})
LINK_LIBRARIES(MultiThreadedDemo pthread)
# TARGET_LINK_LIBRARIES(table ${GLUT_glut_LIBRARY} ${OPENGL_gl_LIBRARY} ${OPENGL_glU_LIBRARY})
# TARGET_LINK_LIBRARIES(checker ${GLUT_glut_LIBRARY} ${OPENGL_gl_LIBRARY} ${OPENGL_glU_LIBRARY})
ENDIF (WIN32)

View File

@@ -22,14 +22,19 @@ subject to the following restrictions:
#ifdef USE_PARALLEL_DISPATCHER
#include "../../Extras/BulletMultiThreaded/SpuGatheringCollisionDispatcher.h"
#ifdef WIN32
#endif //WIN32
#include "../../Extras/BulletMultiThreaded/PlatformDefinitions.h"
#ifdef USE_LIBSPE2
#include "../../Extras/BulletMultiThreaded/SpuLibspe2Support.h"
#elif defined (WIN32)
#include "../../Extras/BulletMultiThreaded/Win32ThreadSupport.h"
#include "../../Extras/BulletMultiThreaded/SpuNarrowPhaseCollisionTask/SpuGatheringCollisionTask.h"
#elif defined (USE_PTHREADS)
#include "../../Extras/BulletMultiThreaded/PosixThreadSupport.h"
#include "../../Extras/BulletMultiThreaded/SpuNarrowPhaseCollisionTask/SpuGatheringCollisionTask.h"
#else
//other platforms run the parallel code sequentially (until pthread support or other parallel implementation is added)
#include "../../Extras/BulletMultiThreaded/SequentialThreadSupport.h"
@@ -44,7 +49,6 @@ subject to the following restrictions:
#endif//USE_PARALLEL_DISPATCHER
#include "LinearMath/btQuickprof.h"
#include "LinearMath/btIDebugDraw.h"
@@ -222,10 +226,8 @@ void MultiThreadedDemo::displayCallback(void) {
void MultiThreadedDemo::initPhysics()
{
#ifdef USE_PARALLEL_DISPATCHER
#ifdef WIN32
m_threadSupportSolver = 0;
m_threadSupportCollision = 0;
#endif //
#endif
//#define USE_GROUND_PLANE 1
@@ -250,7 +252,7 @@ void MultiThreadedDemo::initPhysics()
m_collisionConfiguration = new btDefaultCollisionConfiguration();
#ifdef USE_PARALLEL_DISPATCHER
int maxNumOutstandingTasks = 4;
int maxNumOutstandingTasks = 4;
#ifdef USE_WIN32_THREADING
@@ -279,6 +281,12 @@ m_threadSupportCollision = new Win32ThreadSupport(Win32ThreadSupport::Win32Threa
program_handle = &spu_program;
#endif
SpuLibspe2Support* threadSupportCollision = new SpuLibspe2Support( program_handle, maxNumOutstandingTasks);
#elif defined (USE_PTHREADS)
PosixThreadSupport::ThreadConstructionInfo constructionInfo("collision",
processCollisionTask,
createCollisionLocalStoreMemory,
maxNumOutstandingTasks);
m_threadSupportCollision = new PosixThreadSupport(constructionInfo);
#else
SequentialThreadSupport::SequentialThreadConstructionInfo colCI("collision",processCollisionTask,createCollisionLocalStoreMemory);
@@ -315,7 +323,11 @@ m_threadSupportCollision = new Win32ThreadSupport(Win32ThreadSupport::Win32Threa
processSolverTask,
createSolverLocalStoreMemory,
maxNumOutstandingTasks));
#elif defined (USE_PTHREADS)
PosixThreadSupport::ThreadConstructionInfo solverConstructionInfo("solver", processSolverTask,
createSolverLocalStoreMemory, maxNumOutstandingTasks);
m_threadSupportSolver = new PosixThreadSupport(solverConstructionInfo);
#else
//for now use sequential version
SequentialThreadSupport::SequentialThreadConstructionInfo solverCI("solver",processSolverTask,createSolverLocalStoreMemory);
@@ -405,7 +417,6 @@ m_threadSupportCollision = new Win32ThreadSupport(Win32ThreadSupport::Win32Threa
void MultiThreadedDemo::exitPhysics()
{
//cleanup in the reverse order of creation/initialization
//remove the rigidbodies from the dynamics world and delete them
@@ -436,12 +447,10 @@ void MultiThreadedDemo::exitPhysics()
//delete solver
delete m_solver;
#ifdef USE_PARALLEL_DISPATCHER
#ifdef WIN32
if (m_threadSupportSolver)
{
delete m_threadSupportSolver;
}
#endif
#endif
//delete broadphase
@@ -451,12 +460,10 @@ void MultiThreadedDemo::exitPhysics()
delete m_dispatcher;
#ifdef USE_PARALLEL_DISPATCHER
#ifdef WIN32
if (m_threadSupportCollision)
{
delete m_threadSupportCollision;
}
#endif
#endif
delete m_collisionConfiguration;

View File

@@ -12,7 +12,7 @@ subject to the following restrictions:
2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution.
*/
#include <cstdio>
#include "MultiThreadedDemo.h"
#include "GlutStuff.h"
#include "GLDebugDrawer.h"
@@ -22,7 +22,6 @@ GLDebugDrawer gDebugDrawer;
int main(int argc,char** argv)
{
MultiThreadedDemo* demo = new MultiThreadedDemo();
demo->initPhysics();
@@ -33,4 +32,5 @@ int main(int argc,char** argv)
delete demo;
return EXIT_SUCCESS;
}