Several changes to sync Bullet trunk with PlayStation 3 spubullet version

Still needs some cross-platform fixes
This commit is contained in:
erwin.coumans
2010-07-08 17:02:38 +00:00
parent 76a58e1f4e
commit fbc17731ec
63 changed files with 10363 additions and 522 deletions

View File

@@ -20,10 +20,11 @@ ${BULLET_PHYSICS_SOURCE_DIR}/src
${BULLET_PHYSICS_SOURCE_DIR}/Demos/OpenGL
${BULLET_PHYSICS_SOURCE_DIR}/Extras/Serialize/BulletFileLoader
${BULLET_PHYSICS_SOURCE_DIR}/Extras/Serialize/BulletWorldImporter
${VECTOR_MATH_INCLUDE}
)
LINK_LIBRARIES(
GLUI GIMPACTUtils ConvexDecomposition OpenGLSupport BulletWorldImporter BulletSoftBody BulletDynamics BulletCollision BulletFileLoader LinearMath ${GLUT_glut_LIBRARY} ${OPENGL_gl_LIBRARY} ${OPENGL_glu_LIBRARY}
GLUI GIMPACTUtils ConvexDecomposition BulletMultiThreaded OpenGLSupport BulletWorldImporter BulletSoftBody BulletDynamics BulletCollision BulletFileLoader LinearMath ${GLUT_glut_LIBRARY} ${OPENGL_gl_LIBRARY} ${OPENGL_glu_LIBRARY}
)
SET(AllBulletDemos_SRCS

View File

@@ -33,6 +33,11 @@ subject to the following restrictions:
#include "GlutStuff.h"
///btBulletDynamicsCommon.h is the main Bullet include file, contains most common include files.
#include "btBulletDynamicsCommon.h"
#include "BulletMultiThreaded/Win32ThreadSupport.h"
#include "BulletMultiThreaded/btParallelConstraintSolver.h"
#include "BulletCollision/CollisionDispatch/btSimulationIslandManager.h"
#ifdef TEST_SERIALIZATION
#include "LinearMath/btSerializer.h"
#endif //TEST_SERIALIZATION
@@ -50,7 +55,7 @@ void BasicDemo::clientMoveAndDisplay()
///step the simulation
if (m_dynamicsWorld)
{
m_dynamicsWorld->stepSimulation(ms / 1000000.f);
m_dynamicsWorld->stepSimulation(1./60.,0);//ms / 1000000.f,0);
//optional but useful: debug drawing
m_dynamicsWorld->debugDrawWorld();
}
@@ -79,7 +84,35 @@ void BasicDemo::displayCallback(void) {
swapBuffers();
}
btThreadSupportInterface* createSolverThreadSupport(int maxNumThreads)
{
//#define SEQUENTIAL
#ifdef SEQUENTIAL
SequentialThreadSupport::SequentialThreadConstructionInfo tci("solverThreads",SolverThreadFunc,SolverlsMemoryFunc);
SequentialThreadSupport* threadSupport = new SequentialThreadSupport(tci);
threadSupport->startSPU();
#else
#ifdef _WIN32
Win32ThreadSupport::Win32ThreadConstructionInfo threadConstructionInfo("solverThreads",SolverThreadFunc,SolverlsMemoryFunc,maxNumThreads);
Win32ThreadSupport* threadSupport = new Win32ThreadSupport(threadConstructionInfo);
threadSupport->startSPU();
#elif defined (USE_PTHREADS)
PosixThreadSupport::ThreadConstructionInfo solverConstructionInfo("solver", SolverThreadFunc,
SolverlsMemoryFunc, maxNumThreads);
PosixThreadSupport* threadSupport = new PosixThreadSupport(solverConstructionInfo);
#else
SequentialThreadSupport::SequentialThreadConstructionInfo tci("solverThreads",SolverThreadFunc,SolverlsMemoryFunc);
SequentialThreadSupport* threadSupport = new SequentialThreadSupport(tci);
threadSupport->startSPU();
#endif
#endif
return threadSupport;
}
@@ -100,10 +133,21 @@ void BasicDemo::initPhysics()
m_broadphase = new btDbvtBroadphase();
///the default constraint solver. For parallel processing you can use a different solver (see Extras/BulletMultiThreaded)
btSequentialImpulseConstraintSolver* sol = new btSequentialImpulseConstraintSolver;
//btSequentialImpulseConstraintSolver* sol = new btSequentialImpulseConstraintSolver;
//btSequentialImpulseConstraintSolver* sol = new btSequentialImpulseConstraintSolver;
btParallelConstraintSolver* sol = new btParallelConstraintSolver(createSolverThreadSupport(4));
m_solver = sol;
m_dynamicsWorld = new btDiscreteDynamicsWorld(m_dispatcher,m_broadphase,m_solver,m_collisionConfiguration);
btDiscreteDynamicsWorld* world = new btDiscreteDynamicsWorld(m_dispatcher,m_broadphase,m_solver,m_collisionConfiguration);
m_dynamicsWorld = world;
world->getSimulationIslandManager()->setSplitIslands(false);
m_dynamicsWorld->setGravity(btVector3(0,-10,0));

View File

@@ -13,13 +13,14 @@ SET(GLUT_ROOT ${BULLET_PHYSICS_SOURCE_DIR}/Glut)
INCLUDE_DIRECTORIES(
${BULLET_PHYSICS_SOURCE_DIR}/src ${BULLET_PHYSICS_SOURCE_DIR}/Demos/OpenGL
${VECTOR_MATH_INCLUDE}
)
IF (USE_GLUT)
LINK_LIBRARIES(
OpenGLSupport BulletDynamics BulletCollision LinearMath ${GLUT_glut_LIBRARY} ${OPENGL_gl_LIBRARY} ${OPENGL_glu_LIBRARY}
OpenGLSupport BulletMultiThreaded BulletDynamics BulletCollision LinearMath ${GLUT_glut_LIBRARY} ${OPENGL_gl_LIBRARY} ${OPENGL_glu_LIBRARY}
)
IF (WIN32)

View File

@@ -29,9 +29,12 @@ subject to the following restrictions:
#include "Taru.mdl"
#include "landscape.mdl"
#include "BulletCollision/BroadphaseCollision/btDbvtBroadphase.h"
#ifdef USE_PARALLEL_DISPATCHER_BENCHMARK
#include "BulletMultiThreaded/SpuGatheringCollisionDispatcher.h"
#include "BulletMultiThreaded/SequentialThreadSupport.h"
#include "BulletMultiThreaded/SpuNarrowPhaseCollisionTask/SpuGatheringCollisionTask.h"
#endif
#include "BulletCollision/CollisionDispatch/btSimulationIslandManager.h"

View File

@@ -11,11 +11,12 @@
IF (USE_GRAPHICAL_BENCHMARK)
IF (USE_GLUT)
INCLUDE_DIRECTORIES(
${BULLET_PHYSICS_SOURCE_DIR}/src
${BULLET_PHYSICS_SOURCE_DIR}/Demos/OpenGL
${BULLET_PHYSICS_SOURCE_DIR}/src
${BULLET_PHYSICS_SOURCE_DIR}/Demos/OpenGL
)
IF (USE_MULTITHREADED_BENCHMARK)
INCLUDE_DIRECTORIES( ${VECTOR_MATH_INCLUDE} )
LINK_LIBRARIES( OpenGLSupport BulletMultiThreaded BulletDynamics BulletCollision LinearMath ${GLUT_glut_LIBRARY} ${OPENGL_gl_LIBRARY} ${OPENGL_glu_LIBRARY})
ELSE()
LINK_LIBRARIES( OpenGLSupport BulletDynamics BulletCollision LinearMath ${GLUT_glut_LIBRARY} ${OPENGL_gl_LIBRARY} ${OPENGL_glu_LIBRARY})
@@ -65,6 +66,7 @@ ELSE (USE_GLUT)
)
IF (USE_MULTITHREADED_BENCHMARK)
INCLUDE_DIRECTORIES( ${VECTOR_MATH_INCLUDE} )
LINK_LIBRARIES(
OpenGLSupport BulletMultiThreaded BulletDynamics BulletCollision LinearMath ${OPENGL_gl_LIBRARY} ${OPENGL_glu_LIBRARY}
)

View File

@@ -1,75 +1,75 @@
# This is basically the overall name of the project in Visual Studio this is the name of the Solution File
# For every executable you have with a main method you should have an add_executable line below.
# For every add executable line you should list every .cpp and .h file you have associated with that executable.
# This is the variable for Windows. I use this to define the root of my directory structure.
SET(GLUT_ROOT ${BULLET_PHYSICS_SOURCE_DIR}/Glut)
# You shouldn't have to modify anything below this line
########################################################
INCLUDE_DIRECTORIES(
${BULLET_PHYSICS_SOURCE_DIR}/src ${BULLET_PHYSICS_SOURCE_DIR}/Demos/OpenGL
)
IF (USE_GLUT)
LINK_LIBRARIES(
OpenGLSupport BulletDynamics BulletCollision LinearMath ${GLUT_glut_LIBRARY} ${OPENGL_gl_LIBRARY} ${OPENGL_glu_LIBRARY}
)
IF (WIN32)
ADD_EXECUTABLE(AppBox2dDemo
main.cpp
Box2dDemo.cpp
Box2dDemo.h
${BULLET_PHYSICS_SOURCE_DIR}/msvc/bullet.rc
)
ELSE()
ADD_EXECUTABLE(AppBox2dDemo
main.cpp
Box2dDemo.cpp
Box2dDemo.h
)
ENDIF()
IF (WIN32)
IF (NOT INTERNAL_CREATE_DISTRIBUTABLE_MSVC_PROJECTFILES)
IF (CMAKE_CL_64)
ADD_CUSTOM_COMMAND(
TARGET AppBox2dDemo
POST_BUILD
COMMAND ${CMAKE_COMMAND} ARGS -E copy_if_different ${BULLET_PHYSICS_SOURCE_DIR}/glut64.dll ${CMAKE_CURRENT_BINARY_DIR}
)
ELSE(CMAKE_CL_64)
ADD_CUSTOM_COMMAND(
TARGET AppBox2dDemo
POST_BUILD
COMMAND ${CMAKE_COMMAND} ARGS -E copy_if_different ${BULLET_PHYSICS_SOURCE_DIR}/GLUT32.DLL ${CMAKE_CURRENT_BINARY_DIR}
)
ENDIF(CMAKE_CL_64)
ENDIF (NOT INTERNAL_CREATE_DISTRIBUTABLE_MSVC_PROJECTFILES)
ENDIF(WIN32)
ELSE (USE_GLUT)
LINK_LIBRARIES(
OpenGLSupport BulletDynamics BulletCollision LinearMath ${OPENGL_gl_LIBRARY} ${OPENGL_glu_LIBRARY}
)
ADD_EXECUTABLE(AppBox2dDemo
WIN32
../OpenGL/Win32AppMain.cpp
Win32Box2dDemo.cpp
Box2dDemo.cpp
Box2dDemo.h
${BULLET_PHYSICS_SOURCE_DIR}/msvc/bullet.rc
)
ENDIF (USE_GLUT)
# This is basically the overall name of the project in Visual Studio this is the name of the Solution File
# For every executable you have with a main method you should have an add_executable line below.
# For every add executable line you should list every .cpp and .h file you have associated with that executable.
# This is the variable for Windows. I use this to define the root of my directory structure.
SET(GLUT_ROOT ${BULLET_PHYSICS_SOURCE_DIR}/Glut)
# You shouldn't have to modify anything below this line
########################################################
INCLUDE_DIRECTORIES(
${BULLET_PHYSICS_SOURCE_DIR}/src ${BULLET_PHYSICS_SOURCE_DIR}/Demos/OpenGL
)
IF (USE_GLUT)
LINK_LIBRARIES(
OpenGLSupport BulletDynamics BulletCollision LinearMath ${GLUT_glut_LIBRARY} ${OPENGL_gl_LIBRARY} ${OPENGL_glu_LIBRARY}
)
IF (WIN32)
ADD_EXECUTABLE(AppBox2dDemo
main.cpp
Box2dDemo.cpp
Box2dDemo.h
${BULLET_PHYSICS_SOURCE_DIR}/msvc/bullet.rc
)
ELSE()
ADD_EXECUTABLE(AppBox2dDemo
main.cpp
Box2dDemo.cpp
Box2dDemo.h
)
ENDIF()
IF (WIN32)
IF (NOT INTERNAL_CREATE_DISTRIBUTABLE_MSVC_PROJECTFILES)
IF (CMAKE_CL_64)
ADD_CUSTOM_COMMAND(
TARGET AppBox2dDemo
POST_BUILD
COMMAND ${CMAKE_COMMAND} ARGS -E copy_if_different ${BULLET_PHYSICS_SOURCE_DIR}/glut64.dll ${CMAKE_CURRENT_BINARY_DIR}
)
ELSE(CMAKE_CL_64)
ADD_CUSTOM_COMMAND(
TARGET AppBox2dDemo
POST_BUILD
COMMAND ${CMAKE_COMMAND} ARGS -E copy_if_different ${BULLET_PHYSICS_SOURCE_DIR}/GLUT32.DLL ${CMAKE_CURRENT_BINARY_DIR}
)
ENDIF(CMAKE_CL_64)
ENDIF (NOT INTERNAL_CREATE_DISTRIBUTABLE_MSVC_PROJECTFILES)
ENDIF(WIN32)
ELSE (USE_GLUT)
LINK_LIBRARIES(
OpenGLSupport BulletDynamics BulletCollision LinearMath ${OPENGL_gl_LIBRARY} ${OPENGL_glu_LIBRARY}
)
ADD_EXECUTABLE(AppBox2dDemo
WIN32
../OpenGL/Win32AppMain.cpp
Win32Box2dDemo.cpp
Box2dDemo.cpp
Box2dDemo.h
${BULLET_PHYSICS_SOURCE_DIR}/msvc/bullet.rc
)
ENDIF (USE_GLUT)
IF (INTERNAL_ADD_POSTFIX_EXECUTABLE_NAMES)
SET_TARGET_PROPERTIES(AppBox2dDemo PROPERTIES DEBUG_POSTFIX "_Debug")
SET_TARGET_PROPERTIES(AppBox2dDemo PROPERTIES MINSIZEREL_POSTFIX "_MinsizeRel")
SET_TARGET_PROPERTIES(AppBox2dDemo PROPERTIES RELWITHDEBINFO_POSTFIX "_RelWithDebugInfo")
ENDIF(INTERNAL_ADD_POSTFIX_EXECUTABLE_NAMES)
ENDIF(INTERNAL_ADD_POSTFIX_EXECUTABLE_NAMES)

View File

@@ -18,17 +18,12 @@ ELSE()
)
ENDIF()
if (CMAKE_SIZEOF_VOID_P MATCHES "8")
SUBDIRS( ${SharedDemoSubdirs}
)
else (CMAKE_SIZEOF_VOID_P MATCHES "8")
SUBDIRS( ${SharedDemoSubdirs}
ThreadingDemo
MultiThreadedDemo
VectorAdd_OpenCL
ParticlesOpenCL
)
endif (CMAKE_SIZEOF_VOID_P MATCHES "8")
ELSE (USE_GLUT)

View File

@@ -25,7 +25,7 @@ subject to the following restrictions:
#ifdef BATCH_RAYCASTER
#include "BulletMultiThreaded/SpuBatchRaycaster.h"
static SpuBatchRaycaster* gBatchRaycaster = NULL;
#endif
#ifdef USE_LIBSPE2
#include "BulletMultiThreaded/SpuLibspe2Support.h"
@@ -35,6 +35,7 @@ static SpuBatchRaycaster* gBatchRaycaster = NULL;
//other platforms run the parallel code sequentially (until pthread support or other parallel implementation is added)
#include "BulletMultiThreaded/SequentialThreadSupport.h"
#endif //USE_LIBSPE2
#endif //BATCH_RAYCASTER
static btVector3* gVertices=0;
static int* gIndices=0;

View File

@@ -1,33 +1,53 @@
# This is basically the overall name of the project in Visual Studio this is the name of the Solution File
# For every executable you have with a main method you should have an add_executable line below.
# For every add executable line you should list every .cpp and .h file you have associated with that executable.
# You shouldn't have to modify anything below this line
########################################################
INCLUDE_DIRECTORIES(
${BULLET_PHYSICS_SOURCE_DIR}/src ${BULLET_PHYSICS_SOURCE_DIR}/Demos/OpenGL
)
LINK_LIBRARIES(
OpenGLSupport BulletMultiThreaded BulletDynamics BulletCollision LinearMath ${GLUT_glut_LIBRARY} ${OPENGL_gl_LIBRARY} ${OPENGL_glu_LIBRARY}
)
ADD_EXECUTABLE(AppMultiThreadedDemo
main.cpp
MultiThreadedDemo.cpp
MultiThreadedDemo.h
)
IF (UNIX)
TARGET_LINK_LIBRARIES(AppMultiThreadedDemo pthread)
ENDIF(UNIX)
# This is basically the overall name of the project in Visual Studio this is the name of the Solution File
# For every executable you have with a main method you should have an add_executable line below.
# For every add executable line you should list every .cpp and .h file you have associated with that executable.
# You shouldn't have to modify anything below this line
########################################################
INCLUDE_DIRECTORIES(
${BULLET_PHYSICS_SOURCE_DIR}/src
${BULLET_PHYSICS_SOURCE_DIR}/Demos/OpenGL
${VECTOR_MATH_INCLUDE}
)
LINK_LIBRARIES(
OpenGLSupport BulletMultiThreaded BulletDynamics BulletCollision LinearMath ${GLUT_glut_LIBRARY} ${OPENGL_gl_LIBRARY} ${OPENGL_glu_LIBRARY}
)
ADD_EXECUTABLE(AppMultiThreadedDemo
main.cpp
MultiThreadedDemo.cpp
MultiThreadedDemo.h
)
IF (UNIX)
TARGET_LINK_LIBRARIES(AppMultiThreadedDemo pthread)
ENDIF(UNIX)
IF(WIN32)
IF (CMAKE_CL_64)
IF (NOT INTERNAL_CREATE_DISTRIBUTABLE_MSVC_PROJECTFILES)
ADD_CUSTOM_COMMAND( TARGET AppMultiThreadedDemo POST_BUILD
COMMAND ${CMAKE_COMMAND} ARGS -E copy_if_different ${BULLET_PHYSICS_SOURCE_DIR}/glut64.dll ${CMAKE_CURRENT_BINARY_DIR} )
ADD_CUSTOM_COMMAND( TARGET AppMultiThreadedDemo POST_BUILD
COMMAND ${CMAKE_COMMAND} ARGS -E copy_if_different ${BULLET_PHYSICS_SOURCE_DIR}/GLEW64.DLL ${CMAKE_CURRENT_BINARY_DIR})
ENDIF()
ELSE(CMAKE_CL_64)
IF (NOT INTERNAL_CREATE_DISTRIBUTABLE_MSVC_PROJECTFILES)
ADD_CUSTOM_COMMAND( TARGET AppMultiThreadedDemo POST_BUILD
COMMAND ${CMAKE_COMMAND} ARGS -E copy_if_different ${BULLET_PHYSICS_SOURCE_DIR}/GLUT32.DLL ${CMAKE_CURRENT_BINARY_DIR})
ADD_CUSTOM_COMMAND( TARGET AppMultiThreadedDemo POST_BUILD
COMMAND ${CMAKE_COMMAND} ARGS -E copy_if_different ${BULLET_PHYSICS_SOURCE_DIR}/GLEW32.DLL ${CMAKE_CURRENT_BINARY_DIR})
ENDIF()
ENDIF(CMAKE_CL_64)
ENDIF(WIN32)
IF (INTERNAL_ADD_POSTFIX_EXECUTABLE_NAMES)
SET_TARGET_PROPERTIES(AppMultiThreadedDemo PROPERTIES DEBUG_POSTFIX "_Debug")
SET_TARGET_PROPERTIES(AppMultiThreadedDemo PROPERTIES MINSIZEREL_POSTFIX "_MinsizeRel")

View File

@@ -13,12 +13,13 @@ subject to the following restrictions:
3. This notice may not be removed or altered from any source distribution.
*/
//#define USE_PARALLEL_SOLVER 1 //experimental parallel solver
#define USE_PARALLEL_SOLVER 1 //experimental parallel solver
#define USE_PARALLEL_DISPATCHER 1
#include "btBulletDynamicsCommon.h"
#include "BulletCollision/CollisionDispatch/btSphereSphereCollisionAlgorithm.h"
#include "BulletCollision/CollisionDispatch/btSphereTriangleCollisionAlgorithm.h"
#include "BulletCollision/CollisionDispatch/btSimulationIslandManager.h"
#ifdef USE_PARALLEL_DISPATCHER
#include "BulletMultiThreaded/SpuGatheringCollisionDispatcher.h"
@@ -37,18 +38,52 @@ subject to the following restrictions:
#else
//other platforms run the parallel code sequentially (until pthread support or other parallel implementation is added)
#include "BulletMultiThreaded/SequentialThreadSupport.h"
#include "BulletMultiThreaded/SpuNarrowPhaseCollisionTask/SpuGatheringCollisionTask.h"
#endif //USE_LIBSPE2
#ifdef USE_PARALLEL_SOLVER
#include "BulletMultiThreaded/SpuParallelSolver.h"
#include "BulletMultiThreaded/SpuSolverTask/SpuParallellSolverTask.h"
#include "BulletMultiThreaded/btParallelConstraintSolver.h"
#include "BulletMultiThreaded/SequentialThreadSupport.h"
btThreadSupportInterface* createSolverThreadSupport(int maxNumThreads)
{
//#define SEQUENTIAL
#ifdef SEQUENTIAL
SequentialThreadSupport::SequentialThreadConstructionInfo tci("solverThreads",SolverThreadFunc,SolverlsMemoryFunc);
SequentialThreadSupport* threadSupport = new SequentialThreadSupport(tci);
threadSupport->startSPU();
#else
#ifdef _WIN32
Win32ThreadSupport::Win32ThreadConstructionInfo threadConstructionInfo("solverThreads",SolverThreadFunc,SolverlsMemoryFunc,maxNumThreads);
Win32ThreadSupport* threadSupport = new Win32ThreadSupport(threadConstructionInfo);
threadSupport->startSPU();
#elif defined (USE_PTHREADS)
PosixThreadSupport::ThreadConstructionInfo solverConstructionInfo("solver", SolverThreadFunc,
SolverlsMemoryFunc, maxNumThreads);
PosixThreadSupport* threadSupport = new PosixThreadSupport(solverConstructionInfo);
#else
SequentialThreadSupport::SequentialThreadConstructionInfo tci("solverThreads",SolverThreadFunc,SolverlsMemoryFunc);
SequentialThreadSupport* threadSupport = new SequentialThreadSupport(tci);
threadSupport->startSPU();
#endif
#endif
return threadSupport;
}
#endif //USE_PARALLEL_SOLVER
#endif//USE_PARALLEL_DISPATCHER
#include "LinearMath/btQuickprof.h"
#include "LinearMath/btIDebugDraw.h"
@@ -162,8 +197,6 @@ void MultiThreadedDemo::clientMoveAndDisplay()
int numSimSteps = 0;
numSimSteps = m_dynamicsWorld->stepSimulation(dt,maxSimSubSteps);
//optional but useful: debug drawing
m_dynamicsWorld->debugDrawWorld();
#ifdef VERBOSE_TIMESTEPPING_CONSOLEOUTPUT
if (!numSimSteps)
@@ -182,6 +215,9 @@ void MultiThreadedDemo::clientMoveAndDisplay()
#endif //VERBOSE_TIMESTEPPING_CONSOLEOUTPUT
#endif
//optional but useful: debug drawing
m_dynamicsWorld->debugDrawWorld();
}
#ifdef USE_QUICKPROF
@@ -321,41 +357,23 @@ m_threadSupportCollision = new Win32ThreadSupport(Win32ThreadSupport::Win32Threa
#ifdef USE_PARALLEL_SOLVER
#ifdef USE_WIN32_THREADING
m_threadSupportSolver = new Win32ThreadSupport(Win32ThreadSupport::Win32ThreadConstructionInfo(
"solver",
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);
m_threadSupportSolver = new SequentialThreadSupport(solverCI);
#endif //USE_WIN32_THREADING
m_solver = new btParallelSequentialImpulseSolver(m_threadSupportSolver,maxNumOutstandingTasks);
m_threadSupportSolver = createSolverThreadSupport(maxNumOutstandingTasks);
m_solver = new btParallelConstraintSolver(m_threadSupportSolver);
#else
btSequentialImpulseConstraintSolver* solver = new btSequentialImpulseConstraintSolver();
m_solver = solver;
//default solverMode is SOLVER_RANDMIZE_ORDER. Warmstarting seems not to improve convergence, see
//solver->setSolverMode(0);//btSequentialImpulseConstraintSolver::SOLVER_USE_WARMSTARTING | btSequentialImpulseConstraintSolver::SOLVER_RANDMIZE_ORDER);
#endif //USE_PARALLEL_SOLVER
btDiscreteDynamicsWorld* world = new btDiscreteDynamicsWorld(m_dispatcher,m_broadphase,m_solver,m_collisionConfiguration);
m_dynamicsWorld = world;
world->getSimulationIslandManager()->setSplitIslands(false);
world->getSolverInfo().m_numIterations = 4;
world->getSolverInfo().m_solverMode = SOLVER_SIMD+SOLVER_USE_WARMSTARTING;
world->getSolverInfo().m_solverMode = SOLVER_SIMD+SOLVER_USE_WARMSTARTING;//+SOLVER_RANDMIZE_ORDER;
m_dynamicsWorld->getDispatchInfo().m_enableSPU = true;
m_dynamicsWorld->setGravity(btVector3(0,-10,0));

View File

@@ -954,8 +954,8 @@ void DemoApplication::mouseMotionFunc(int x,int y)
{
btVector3 hor = getRayTo(0,0)-getRayTo(1,0);
btVector3 vert = getRayTo(0,0)-getRayTo(0,1);
btScalar multiplierX = btScalar(0.01);
btScalar multiplierY = btScalar(0.01);
btScalar multiplierX = btScalar(0.001);
btScalar multiplierY = btScalar(0.001);
if (m_ortho)
{
multiplierX = 1;
@@ -979,7 +979,7 @@ void DemoApplication::mouseMotionFunc(int x,int y)
}
else if(m_mouseButtons & 4)
{
m_cameraDistance -= dy * btScalar(0.2f);
m_cameraDistance -= dy * btScalar(0.02f);
if (m_cameraDistance<btScalar(0.1))
m_cameraDistance = btScalar(0.1);
@@ -1324,8 +1324,10 @@ void DemoApplication::renderme()
updateCamera();
}
#include "BulletCollision/BroadphaseCollision/btAxisSweep3.h"
void DemoApplication::clientResetScene()
{
#ifdef SHOW_NUM_DEEP_PENETRATIONS
@@ -1365,7 +1367,8 @@ void DemoApplication::clientResetScene()
//colObj->setActivationState(WANTS_DEACTIVATION);
}
//removed cached contact points (this is not necessary if all objects have been removed from the dynamics world)
//m_dynamicsWorld->getBroadphase()->getOverlappingPairCache()->cleanProxyFromPairs(colObj->getBroadphaseHandle(),getDynamicsWorld()->getDispatcher());
if (m_dynamicsWorld->getBroadphase()->getOverlappingPairCache())
m_dynamicsWorld->getBroadphase()->getOverlappingPairCache()->cleanProxyFromPairs(colObj->getBroadphaseHandle(),getDynamicsWorld()->getDispatcher());
btRigidBody* body = btRigidBody::upcast(colObj);
if (body && !body->isStaticObject())

View File

@@ -10,14 +10,14 @@ ${BULLET_PHYSICS_SOURCE_DIR}/Demos/OpenGL
IF(INTERNAL_CREATE_DISTRIBUTABLE_MSVC_PROJECTFILES)
INCLUDE_DIRECTORIES( $ENV{==NVSDKCOMPUTE_ROOT=}/OpenCL/common/inc )
IF (CMAKE_CL_64)
SET(CMAK_NVSDKCOMPUTE_LIBPATH )
SET(CMAK_NVSDKCOMPUTE_LIBPATH $ENV{==NVSDKCOMPUTE_ROOT=}/OpenCL/common/lib/x64 )
ELSE(CMAKE_CL_64)
SET(CMAK_NVSDKCOMPUTE_LIBPATH $ENV{==NVSDKCOMPUTE_ROOT=}/OpenCL/common/lib/x64 )
SET(CMAK_NVSDKCOMPUTE_LIBPATH $ENV{==NVSDKCOMPUTE_ROOT=}/OpenCL/common/lib/Win32 )
ENDIF(CMAKE_CL_64)
ELSE()
INCLUDE_DIRECTORIES( $ENV{NVSDKCOMPUTE_ROOT}/OpenCL/common/inc )
IF (CMAKE_CL_64)
SET(CMAK_NVSDKCOMPUTE_LIBPATH )
SET(CMAK_NVSDKCOMPUTE_LIBPATH $ENV{NVSDKCOMPUTE_ROOT}/OpenCL/common/lib/x64 )
ELSE(CMAKE_CL_64)
SET(CMAK_NVSDKCOMPUTE_LIBPATH $ENV{NVSDKCOMPUTE_ROOT}/OpenCL/common/lib/Win32 )
ENDIF(CMAKE_CL_64)
@@ -35,7 +35,6 @@ IF (USE_GLUT)
OpenGLSupport
BulletDynamics
BulletCollision
BulletMultiThreaded
LinearMath
${GLUT_glut_LIBRARY}
${OPENGL_gl_LIBRARY}
@@ -74,8 +73,6 @@ IF (CMAKE_CL_64)
COMMAND ${CMAKE_COMMAND} ARGS -E copy_if_different ${BULLET_PHYSICS_SOURCE_DIR}/glut64.dll ${CMAKE_CURRENT_BINARY_DIR} )
ADD_CUSTOM_COMMAND( TARGET AppParticlesOCL_Nv POST_BUILD
COMMAND ${CMAKE_COMMAND} ARGS -E copy_if_different ${BULLET_PHYSICS_SOURCE_DIR}/GLEW64.DLL ${CMAKE_CURRENT_BINARY_DIR})
ADD_CUSTOM_COMMAND( TARGET AppParticlesOCL_Nv POST_BUILD
COMMAND ${CMAKE_COMMAND} ARGS -E copy_if_different ${BULLET_PHYSICS_SOURCE_DIR}/Demos/ParticlesOpenCL/ParticlesOCL.cl ${CMAKE_CURRENT_BINARY_DIR})
ENDIF()
ELSE(CMAKE_CL_64)
IF (NOT INTERNAL_CREATE_DISTRIBUTABLE_MSVC_PROJECTFILES)
@@ -83,10 +80,13 @@ ELSE(CMAKE_CL_64)
COMMAND ${CMAKE_COMMAND} ARGS -E copy_if_different ${BULLET_PHYSICS_SOURCE_DIR}/GLUT32.DLL ${CMAKE_CURRENT_BINARY_DIR})
ADD_CUSTOM_COMMAND( TARGET AppParticlesOCL_Nv POST_BUILD
COMMAND ${CMAKE_COMMAND} ARGS -E copy_if_different ${BULLET_PHYSICS_SOURCE_DIR}/GLEW32.DLL ${CMAKE_CURRENT_BINARY_DIR})
ENDIF()
ENDIF(CMAKE_CL_64)
IF (NOT INTERNAL_CREATE_DISTRIBUTABLE_MSVC_PROJECTFILES)
ADD_CUSTOM_COMMAND( TARGET AppParticlesOCL_Nv POST_BUILD
COMMAND ${CMAKE_COMMAND} ARGS -E copy_if_different ${BULLET_PHYSICS_SOURCE_DIR}/Demos/ParticlesOpenCL/ParticlesOCL.cl ${CMAKE_CURRENT_BINARY_DIR})
ENDIF()
ENDIF(CMAKE_CL_64)
ENDIF(WIN32)
IF (UNIX)

View File

@@ -22,8 +22,9 @@ subject to the following restrictions:
//#define START_POS_Z btScalar(0.4f)
#define ARRAY_SIZE_X 32
#define ARRAY_SIZE_Y 32
//#define ARRAY_SIZE_Y 5
//#define ARRAY_SIZE_Y 16
#define ARRAY_SIZE_Z 16
//16
//#define ARRAY_SIZE_Z 1
//#define DIST btScalar(2.f)
#define DIST (DEF_PARTICLE_RADIUS * 2.f)
@@ -65,7 +66,7 @@ subject to the following restrictions:
btScalar gTimeStep = btScalar(1./60.);
btScalar gTimeStep = 0.5f;//btScalar(1./60.);
#define SCALING btScalar(1.f)
@@ -254,6 +255,7 @@ void ParticlesDemo::initPhysics()
{
// btCollisionShape* colShape = new btSphereShape(btScalar(1.0f));
/*
btCollisionShape* colShape = new btSphereShape(DEF_PARTICLE_RADIUS);
m_collisionShapes.push_back(colShape);
btTransform startTransform;
@@ -269,37 +271,53 @@ void ParticlesDemo::initPhysics()
rbInfo.m_startWorldTransform = startTransform;
btRigidBody* body = new btRigidBody(rbInfo);
m_pWorld->addRigidBody(body);
*/
init_scene_directly();
}
clientResetScene();
m_pWorld->initDeviceData();
}
static float frand(void) { return 2.0f * (float)rand()/(float)RAND_MAX - 1.0f; }
inline float frand(void){
return (float)rand() / (float)RAND_MAX;
}
void ParticlesDemo::init_scene_directly()
{
float start_x = START_POS_X - ARRAY_SIZE_X * DIST * btScalar(0.5f);
float start_y = START_POS_Y - ARRAY_SIZE_Y * DIST * btScalar(0.5f);
float start_z = START_POS_Z - ARRAY_SIZE_Z * DIST * btScalar(0.5f);
int total = ARRAY_SIZE_X * ARRAY_SIZE_Y * ARRAY_SIZE_Z;
m_pWorld->m_hPos.resize(total);
m_pWorld->m_hVel.resize(total);
total = 0;
for (int k=0;k<ARRAY_SIZE_Y;k++)
{
for (int i=0;i<ARRAY_SIZE_X;i++)
{
for(int j = 0;j<ARRAY_SIZE_Z;j++)
{
m_pWorld->m_hVel[total] = btVector3(0., 0., 0.);
btVector3 jitter = 0.01f * 0.03f * btVector3(frand(), frand(), frand());
m_pWorld->m_hPos[total] = btVector3(DIST*i + start_x, DIST*k + start_y, DIST*j + start_z) + jitter;
total++;
}
}
}
m_pWorld->m_numParticles = total;
srand(1969);
float start_x = -1+DEF_PARTICLE_RADIUS;//START_POS_X - ARRAY_SIZE_X * DIST * btScalar(0.5f);
float start_y = -1+DEF_PARTICLE_RADIUS;//START_POS_Y - ARRAY_SIZE_Y * DIST * btScalar(0.5f);
float start_z = -1+DEF_PARTICLE_RADIUS;//START_POS_Z - ARRAY_SIZE_Z * DIST * btScalar(0.5f);
int numParticles = ARRAY_SIZE_X * ARRAY_SIZE_Y * ARRAY_SIZE_Z;
m_pWorld->m_hPos.resize(numParticles);
m_pWorld->m_hVel.resize(numParticles);
btScalar spacing = 2 * DEF_PARTICLE_RADIUS;
for(int z=0; z<ARRAY_SIZE_Z; z++)
{
for(int y=0; y<ARRAY_SIZE_Y; y++)
{
for(int x=0; x<ARRAY_SIZE_X; x++)
{
int i = (z * ARRAY_SIZE_Y * ARRAY_SIZE_X) + (y * ARRAY_SIZE_X) + x;
if (i < numParticles)
{
btVector3 jitter = 0.01f * 0.03f * btVector3(frand(), frand(), frand());
m_pWorld->m_hVel[i]= btVector3(0,0,0);
m_pWorld->m_hPos[i].setX((spacing * x) + DEF_PARTICLE_RADIUS -WORLD_SIZE+jitter.getX());
m_pWorld->m_hPos[i].setY((spacing * y) + DEF_PARTICLE_RADIUS -WORLD_SIZE+jitter.getY());
m_pWorld->m_hPos[i].setZ((spacing * z) + DEF_PARTICLE_RADIUS -WORLD_SIZE+jitter.getZ());
}
}
}
}
m_pWorld->m_numParticles = numParticles;
}
@@ -314,6 +332,7 @@ void ParticlesDemo::clientResetScene()
}
else
{
m_pWorld->grabSimulationData();
}
}
@@ -392,7 +411,7 @@ void ParticlesDemo::renderme()
{
glColor3f(1.0, 1.0, 1.0);
glutWireCube(2.0);
glutWireCube(2*WORLD_SIZE);
glPointSize(5.0f);
glEnable(GL_POINT_SPRITE_ARB);

View File

@@ -81,7 +81,7 @@ __kernel void kFindCellStart( int numParticles,
__global float4* pSortedVel GUID_ARG)
{
int index = get_global_id(0);
__local int sharedHash[513];
__local int sharedHash[1025];//maximum workgroup size 1024
int2 sortedData;
if(index < numParticles)
@@ -142,6 +142,8 @@ __kernel void kIntegrateMotion( int numParticles,
// collide with world boundaries
float4 worldMin = *((__global float4*)(pParams + 1));
float4 worldMax = *((__global float4*)(pParams + 2));
if(pos.x < (worldMin.x + particleRad))
{
pos.x = worldMin.x + particleRad;
@@ -216,7 +218,6 @@ float4 collideTwoParticles(
}
__kernel void kCollideParticles(int numParticles,
__global float4* pVel, //output: new velocity
__global const float4* pSortedPos, //input: reordered positions
@@ -264,8 +265,10 @@ __kernel void kCollideParticles(int numParticles,
continue;
}
//Iterate over particles in this cell
int endI = startI + 8;
if(endI >= numParticles) endI = numParticles - 1;
int endI = startI + 32;
if(endI >= numParticles)
endI = numParticles ;
for(int j = startI; j < endI; j++)
{
uint hashC = pPosHash[j].x;

View File

@@ -74,6 +74,7 @@ int btParticlesDynamicsWorld::stepSimulation( btScalar timeStep, int maxSubSteps
}
{
BT_PROFILE("CollideParticles");
// printf("\ncollide particles\n\n");
runCollideParticlesKernel();
}
gStepNum++;
@@ -212,8 +213,8 @@ void btParticlesDynamicsWorld::adjustGrid()
m_worldMin -= wsize;
m_worldMax += wsize;
*/
m_worldMin.setValue(-1.f, -1.f, -1.f);
m_worldMax.setValue( 1.f, 1.f, 1.f);
m_worldMin.setValue(-WORLD_SIZE, -WORLD_SIZE, -WORLD_SIZE);
m_worldMax.setValue( WORLD_SIZE, WORLD_SIZE, WORLD_SIZE);
wsize = m_worldMax - m_worldMin;
m_cellSize[0] = m_cellSize[1] = m_cellSize[2] = m_particleRad * btScalar(2.f);
@@ -246,7 +247,12 @@ void btParticlesDynamicsWorld::adjustGrid()
void btParticlesDynamicsWorld::grabSimulationData()
{
// const btVector3& gravity = getGravity();
btVector3 gravity(0., -0.06, 0.);
//btVector3 gravity(0., -0.06, 0.);
//btVector3 gravity(0., -0.0003f, 0.);
btVector3 gravity(0,-0.0003,0);
m_simParams.m_gravity[0] = gravity[0];
m_simParams.m_gravity[1] = gravity[1];
m_simParams.m_gravity[2] = gravity[2];
@@ -258,7 +264,7 @@ void btParticlesDynamicsWorld::grabSimulationData()
// m_simParams.m_spring = 0.5f;
// m_simParams.m_shear = 0.1f;
// m_simParams.m_attraction = 0.0f;
m_simParams.m_collisionDamping = 0.02f;
m_simParams.m_collisionDamping = 0.025f;//0.02f;
m_simParams.m_spring = 0.5f;
m_simParams.m_shear = 0.1f;
m_simParams.m_attraction = 0.0f;
@@ -427,6 +433,7 @@ void btParticlesDynamicsWorld::initCLKernels(int argc, char** argv)
ciErrNum |= clSetKernelArg(m_kernels[PARTICLES_KERNEL_CLEAR_CELL_START].m_kernel, 1, sizeof(cl_mem), (void*) &m_dCellStart);
initKernel(PARTICLES_KERNEL_FIND_CELL_START, "kFindCellStart");
// ciErrNum |= clSetKernelArg(m_kernels[PARTICLES_KERNEL_FIND_CELL_START].m_kernel, 0, sizeof(int), (void*) &m_numParticles);
ciErrNum |= clSetKernelArg(m_kernels[PARTICLES_KERNEL_FIND_CELL_START].m_kernel, 1, sizeof(cl_mem), (void*) &m_dPosHash);
ciErrNum |= clSetKernelArg(m_kernels[PARTICLES_KERNEL_FIND_CELL_START].m_kernel, 2, sizeof(cl_mem), (void*) &m_dCellStart);
ciErrNum |= clSetKernelArg(m_kernels[PARTICLES_KERNEL_FIND_CELL_START].m_kernel, 3, sizeof(cl_mem), (void*) &m_dPos);
@@ -560,15 +567,28 @@ static btVector3 cpu_collideTwoParticles(
float relVelDotNorm = relVel.dot(norm);
btVector3 tanVel = relVel - relVelDotNorm * norm;
//Spring force (potential)
float springFactor = -spring * (collideDist - dist);
force = springFactor * norm + damping * relVel + shear * tanVel + attraction * relPos;
//float springFactor = -spring * (collideDist - dist);
float springFactor = -0.4 * (collideDist - dist);
force = springFactor * norm + damping * relVel;// + shear * tanVel + attraction * relPos;
}
return force;
}
struct btPair
{
union
{
int value;
short v0[2];
};
};
void btParticlesDynamicsWorld::runCollideParticlesKernel()
{
btAlignedObjectArray<int> pairs;
float particleRad = m_simParams.m_particleRad;
float collideDist2 = (particleRad + particleRad)*(particleRad + particleRad);
cl_int ciErrNum;
if(m_useCpuControls[SIMSTAGE_COLLIDE_PARTICLES]->m_active)
{ // CPU version
@@ -585,6 +605,7 @@ void btParticlesDynamicsWorld::runCollideParticlesKernel()
ciErrNum = clEnqueueReadBuffer(m_cqCommandQue, m_dCellStart, CL_TRUE, 0, memSize, &(m_hCellStart[0]), 0, NULL, NULL);
oclCHECKERROR(ciErrNum, CL_SUCCESS);
}
for(int index = 0; index < m_numParticles; index++)
{
btVector3 posA = m_hSortedPos[index];
@@ -618,7 +639,10 @@ void btParticlesDynamicsWorld::runCollideParticlesKernel()
continue;
}
//Iterate over particles in this cell
int endI = startI + 8;
int endI = startI + 32;
if(endI > m_numParticles)
endI = m_numParticles;
for(int j = startI; j < endI; j++)
{
unsigned int hashC = m_hPosHash[j].x;
@@ -630,6 +654,14 @@ void btParticlesDynamicsWorld::runCollideParticlesKernel()
{
continue;
}
btPair pair;
pair.v0[0] = index;
pair.v0[1] = j;
pairs.push_back(pair.value);
// printf("index=%d, j=%d\n",index,j);
// printf("(index=%d, j=%d) ",index,j);
btVector3 posB = m_hSortedPos[j];
btVector3 velB = m_hSortedVel[j];
//Collide two spheres
@@ -642,6 +674,56 @@ void btParticlesDynamicsWorld::runCollideParticlesKernel()
//Write new velocity back to original unsorted location
m_hVel[unsortedIndex] = velA + force;
}
//#define BRUTE_FORCE_CHECK 1
#ifdef BRUTE_FORCE_CHECK
for(int index = 0; index < m_numParticles; index++)
{
btVector3 posA = m_hSortedPos[index];
btVector3 velA = m_hSortedVel[index];
btVector3 force = btVector3(0, 0, 0);
int unsortedIndex = m_hPosHash[index].y;
float collisionDamping = m_simParams.m_collisionDamping;
float spring = m_simParams.m_spring;
float shear = m_simParams.m_shear;
float attraction = m_simParams.m_attraction;
for(int j = 0 ; j < m_numParticles; j++)
{
if (index!=j)
{
btVector3 posB = m_hSortedPos[j];
btVector3 velB = m_hSortedVel[j];
btVector3 relPos = posB - posA; relPos[3] = 0.f;
float dist2 = (relPos[0] * relPos[0] + relPos[1] * relPos[1] + relPos[2] * relPos[2]);
if(dist2 < collideDist2)
{
//Collide two spheres
// force += cpu_collideTwoParticles( posA, posB, velA, velB, particleRad, particleRad,
// spring, collisionDamping, shear, attraction);
btPair pair;
pair.v0[0] = index;
pair.v0[1] = j;
if (pairs.findLinearSearch(pair.value)==pairs.size())
{
printf("not found index=%d, j=%d\n",index,j);
}
}
}
}
//Write new velocity back to original unsorted location
//m_hVel[unsortedIndex] = velA + force;
}
#endif //BRUTE_FORCE_CHECK
memSize = sizeof(btVector3) * m_numParticles;
ciErrNum = clEnqueueWriteBuffer(m_cqCommandQue, m_dVel, CL_TRUE, 0, memSize, &(m_hVel[0]), 0, NULL, NULL);
oclCHECKERROR(ciErrNum, CL_SUCCESS);
@@ -675,7 +757,11 @@ void btParticlesDynamicsWorld::runIntegrateMotionKernel()
pos[3] = 1.0f;
vel[3] = 0.0f;
// apply gravity
btVector3 gravity = *((btVector3*)(m_simParams.m_gravity));
btVector3 gravity;
gravity[0] = m_simParams.m_gravity[0];
gravity[1] = m_simParams.m_gravity[1];
gravity[2] = m_simParams.m_gravity[2];
float particleRad = m_simParams.m_particleRad;
float globalDamping = m_simParams.m_globalDamping;
float boundaryDamping = m_simParams.m_boundaryDamping;
@@ -684,8 +770,16 @@ void btParticlesDynamicsWorld::runIntegrateMotionKernel()
// integrate position
pos += vel * m_timeStep;
// collide with world boundaries
btVector3 worldMin = *((btVector3*)(m_simParams.m_worldMin));
btVector3 worldMax = *((btVector3*)(m_simParams.m_worldMax));
btVector3 worldMin;
worldMin[0] = m_simParams.m_worldMin[0];
worldMin[1] = m_simParams.m_worldMin[1];
worldMin[2] = m_simParams.m_worldMin[2];
btVector3 worldMax;
worldMax[0] = m_simParams.m_worldMax[0];
worldMax[1] = m_simParams.m_worldMax[1];
worldMax[2] = m_simParams.m_worldMax[2];
for(int j = 0; j < 3; j++)
{
if(pos[j] < (worldMin[j] + particleRad))
@@ -800,7 +894,7 @@ void btParticlesDynamicsWorld::runSortHashKernel()
}
};
btHashPosKey* pHash = (btHashPosKey*)(&m_hPosHash[0]);
pHash->quickSort(pHash, 0, m_numParticles - 1);
pHash->quickSort(pHash, 0, m_numParticles );
// pHash->bitonicSort(pHash, 0, m_hashSize, true);
// write back to GPU
ciErrNum = clEnqueueWriteBuffer(m_cqCommandQue, m_dPosHash, CL_TRUE, 0, memSize, &(m_hPosHash[0]), 0, NULL, NULL);
@@ -899,8 +993,19 @@ void btParticlesDynamicsWorld::initKernel(int kernelId, char* pName)
size_t wgSize;
ciErrNum = clGetKernelWorkGroupInfo(kernel, m_cdDevice, CL_KERNEL_WORK_GROUP_SIZE, sizeof(size_t), &wgSize, NULL);
oclCHECKERROR(ciErrNum, CL_SUCCESS);
// if (wgSize > 64)
// wgSize = 64;
// if (wgSize > 256)
// wgSize = 256;
if (wgSize > 512)
wgSize = 512;
// if (wgSize > 1024)
// wgSize = 1024;
m_kernels[kernelId].m_Id = kernelId;
m_kernels[kernelId].m_kernel = kernel;
m_kernels[kernelId].m_name = pName;

View File

@@ -45,6 +45,7 @@ subject to the following restrictions:
#define PARTICLES_MAX_PARTICLES (65536)
#define PARTICLES_MAX_NEIGHBORS (32)
#define DEF_PARTICLE_RADIUS (0.023f)
#define WORLD_SIZE 1.9f
enum
{

View File

@@ -1,5 +1,6 @@
#define STRINGIFY(A) #A
#ifdef USE_AMD_OPENCL
// vertex shader
const char *vertexShader = STRINGIFY(
uniform float pointRadius; // point size in world space
@@ -17,16 +18,40 @@ void main()
//hack around latest AMD graphics cards having troubles with point sprite rendering
//the problem is still unresolved on the 5870 card, and results in a black screen
//see also http://forums.amd.com/devforum/messageview.cfm?catid=392&threadid=129431
#ifdef USE_AMD_OPENCL
gl_TexCoord = gl_MultiTexCoord0;
#else
gl_TexCoord[0] = gl_MultiTexCoord0;
#endif
gl_Position = gl_ModelViewProjectionMatrix * vec4(gl_Vertex.xyz, 1.0);
gl_Position = gl_ModelViewProjectionMatrix * vec4(gl_Vertex.xyz, 1.0);
gl_FrontColor = gl_Color;
}
);
#else
// vertex shader
const char *vertexShader = STRINGIFY(
uniform float pointRadius; // point size in world space
uniform float pointScale; // scale to calculate size in pixels
uniform float densityScale;
uniform float densityOffset;
varying vec3 posEye;
void main()
{
// calculate window-space point size
posEye = vec3(gl_ModelViewMatrix * vec4(gl_Vertex.xyz, 1.0));
float dist = length(posEye);
gl_PointSize = pointRadius * (pointScale / dist);
// gl_PointSize = 4.0;
//hack around latest AMD graphics cards having troubles with point sprite rendering
//the problem is still unresolved on the 5870 card, and results in a black screen
//see also http://forums.amd.com/devforum/messageview.cfm?catid=392&threadid=129431
gl_TexCoord[0] = gl_MultiTexCoord0;
gl_Position = gl_ModelViewProjectionMatrix * vec4(gl_Vertex.xyz, 1.0);
gl_FrontColor = gl_Color;
}
);
#endif
// pixel shader for rendering points as shaded spheres
const char *spherePixelShader = STRINGIFY(

View File

@@ -9,6 +9,7 @@
//////////////////////////////////////////////////////////////////////////////
//! Gets the id of the nth device from the context
//!

View File

@@ -23,6 +23,8 @@ subject to the following restrictions:
void SampleThreadFunc(void* userPtr,void* lsMemory);
void* SamplelsMemoryFunc();
#include <stdio.h>
#ifdef __APPLE__
#include "BulletMultiThreaded/PosixThreadSupport.h"
@@ -148,7 +150,7 @@ int main(int argc,char** argv)
int numActiveThreads = numThreads;
while (numActiveThreads)
{
if (threadSupport->isTaskCompleted(&arg0,&arg1,0))
if (((Win32ThreadSupport*)threadSupport)->isTaskCompleted(&arg0,&arg1,0))
{
numActiveThreads--;
printf("numActiveThreads = %d\n",numActiveThreads);

View File

@@ -192,7 +192,7 @@ int main(int argc, char **argv)
};
// Create OpenCL context & context
cxGPUContext = clCreateContextFromType(cps, CL_DEVICE_TYPE_CPU, NULL, NULL, &ciErr1); //could also be CL_DEVICE_TYPE_GPU
cxGPUContext = clCreateContextFromType(cps, CL_DEVICE_TYPE_ALL, NULL, NULL, &ciErr1); //could also be CL_DEVICE_TYPE_GPU
// Query all devices available to the context
ciErr1 |= clGetContextInfo(cxGPUContext, CL_CONTEXT_DEVICES, 0, NULL, &szParmDataBytes);

View File

@@ -4,16 +4,16 @@
IF(INTERNAL_CREATE_DISTRIBUTABLE_MSVC_PROJECTFILES)
INCLUDE_DIRECTORIES( $ENV{==NVSDKCOMPUTE_ROOT=}/OpenCL/common/inc )
IF (CMAKE_CL_64)
SET(CMAKE_NVSDKCOMPUTE_LIBPATH )
SET(CMAK_NVSDKCOMPUTE_LIBPATH $ENV{==NVSDKCOMPUTE_ROOT=}/OpenCL/common/lib/x64 )
ELSE(CMAKE_CL_64)
SET(CMAKE_NVSDKCOMPUTE_LIBPATH $ENV{==NVSDKCOMPUTE_ROOT=}/OpenCL/common/lib/x64 )
SET(CMAK_NVSDKCOMPUTE_LIBPATH $ENV{==NVSDKCOMPUTE_ROOT=}/OpenCL/common/lib/Win32 )
ENDIF(CMAKE_CL_64)
ELSE()
INCLUDE_DIRECTORIES( $ENV{NVSDKCOMPUTE_ROOT}/OpenCL/common/inc )
IF (CMAKE_CL_64)
SET(CMAKE_NVSDKCOMPUTE_LIBPATH )
SET(CMAK_NVSDKCOMPUTE_LIBPATH $ENV{NVSDKCOMPUTE_ROOT}/OpenCL/common/lib/x64 )
ELSE(CMAKE_CL_64)
SET(CMAKE_NVSDKCOMPUTE_LIBPATH $ENV{NVSDKCOMPUTE_ROOT}/OpenCL/common/lib/Win32 )
SET(CMAK_NVSDKCOMPUTE_LIBPATH $ENV{NVSDKCOMPUTE_ROOT}/OpenCL/common/lib/Win32 )
ENDIF(CMAKE_CL_64)
ENDIF()
@@ -22,8 +22,8 @@ ${BULLET_PHYSICS_SOURCE_DIR}/src
)
LINK_LIBRARIES(
BulletMultiThreaded LinearMath
${CMAKE_NVSDKCOMPUTE_LIBPATH}/OpenCL.lib
LinearMath
${CMAK_NVSDKCOMPUTE_LIBPATH}/OpenCL.lib
)
ADD_EXECUTABLE(AppVectorAdd_NVidia