Minor fixes in multi-threaded narrowphase Bullet version: allow to dynamically switch number of threads/SPUs
Disable USE_SEPDISTANCE_UTIL for now
This commit is contained in:
@@ -24,6 +24,28 @@ subject to the following restrictions:
|
||||
|
||||
|
||||
|
||||
void SpuCollisionTaskProcess::setNumTasks(int maxNumTasks)
|
||||
{
|
||||
m_maxNumOutstandingTasks = maxNumTasks;
|
||||
m_taskBusy.resize(m_maxNumOutstandingTasks);
|
||||
m_spuGatherTaskDesc.resize(m_maxNumOutstandingTasks);
|
||||
|
||||
for (int i = 0; i < m_taskBusy.size(); i++)
|
||||
{
|
||||
m_taskBusy[i] = false;
|
||||
}
|
||||
|
||||
///re-allocate task memory buffers
|
||||
if (m_workUnitTaskBuffers != 0)
|
||||
{
|
||||
btAlignedFree(m_workUnitTaskBuffers);
|
||||
}
|
||||
|
||||
m_workUnitTaskBuffers = (unsigned char *)btAlignedAlloc(MIDPHASE_WORKUNIT_TASK_SIZE*m_maxNumOutstandingTasks, 128);
|
||||
m_workUnitTaskBuffers = (unsigned char *)btAlignedAlloc(MIDPHASE_WORKUNIT_TASK_SIZE*6, 128);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
SpuCollisionTaskProcess::SpuCollisionTaskProcess(class btThreadSupportInterface* threadInterface, unsigned int maxNumOutstandingTasks)
|
||||
@@ -31,13 +53,7 @@ SpuCollisionTaskProcess::SpuCollisionTaskProcess(class btThreadSupportInterface*
|
||||
m_maxNumOutstandingTasks(maxNumOutstandingTasks)
|
||||
{
|
||||
m_workUnitTaskBuffers = (unsigned char *)0;
|
||||
m_taskBusy.resize(m_maxNumOutstandingTasks);
|
||||
m_spuGatherTaskDesc.resize(m_maxNumOutstandingTasks);
|
||||
|
||||
for (int i = 0; i < m_maxNumOutstandingTasks; i++)
|
||||
{
|
||||
m_taskBusy[i] = false;
|
||||
}
|
||||
setNumTasks(maxNumOutstandingTasks);
|
||||
m_numBusyTasks = 0;
|
||||
m_currentTask = 0;
|
||||
m_currentPage = 0;
|
||||
@@ -77,11 +93,6 @@ void SpuCollisionTaskProcess::initialize2(bool useEpa)
|
||||
#ifdef DEBUG_SPU_TASK_SCHEDULING
|
||||
printf("SpuCollisionTaskProcess::initialize()\n");
|
||||
#endif //DEBUG_SPU_TASK_SCHEDULING
|
||||
if (!m_workUnitTaskBuffers)
|
||||
{
|
||||
m_workUnitTaskBuffers = (unsigned char *)btAlignedAlloc(MIDPHASE_WORKUNIT_TASK_SIZE*m_maxNumOutstandingTasks, 128);
|
||||
}
|
||||
|
||||
|
||||
for (int i = 0; i < m_maxNumOutstandingTasks; i++)
|
||||
{
|
||||
|
||||
@@ -132,6 +132,14 @@ public:
|
||||
|
||||
///call flush to submit potential outstanding work to SPUs and wait for all involved SPUs to be finished
|
||||
void flush2();
|
||||
|
||||
/// set the maximum number of SPU tasks allocated
|
||||
void setNumTasks(int maxNumTasks);
|
||||
|
||||
int getNumTasks() const
|
||||
{
|
||||
return m_maxNumOutstandingTasks;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -24,7 +24,7 @@ subject to the following restrictions:
|
||||
|
||||
class btPersistentManifold;
|
||||
|
||||
#define USE_SEPDISTANCE_UTIL 1
|
||||
//#define USE_SEPDISTANCE_UTIL 1
|
||||
|
||||
/// SpuContactManifoldCollisionAlgorithm provides contact manifold and should be processed on SPU.
|
||||
ATTRIBUTE_ALIGNED16(class) SpuContactManifoldCollisionAlgorithm : public btCollisionAlgorithm
|
||||
|
||||
@@ -150,11 +150,17 @@ void SpuGatheringCollisionDispatcher::dispatchAllCollisionPairs(btOverlappingPai
|
||||
|
||||
if (dispatchInfo.m_enableSPU)
|
||||
{
|
||||
m_maxNumOutstandingTasks = m_threadInterface->getNumTasks();
|
||||
|
||||
if (!m_spuCollisionTaskProcess)
|
||||
m_spuCollisionTaskProcess = new SpuCollisionTaskProcess(m_threadInterface,m_maxNumOutstandingTasks);
|
||||
|
||||
m_spuCollisionTaskProcess->setNumTasks(m_maxNumOutstandingTasks);
|
||||
// printf("m_maxNumOutstandingTasks =%d\n",m_maxNumOutstandingTasks);
|
||||
|
||||
m_spuCollisionTaskProcess->initialize2(dispatchInfo.m_useEpa);
|
||||
|
||||
|
||||
///modified version of btCollisionDispatcher::dispatchAllCollisionPairs:
|
||||
{
|
||||
btSpuCollisionPairCallback collisionCallback(dispatchInfo,this);
|
||||
|
||||
@@ -64,6 +64,7 @@ private:
|
||||
btAlignedObjectArray<btSpuStatus> m_activeSpuStatus;
|
||||
btAlignedObjectArray<void*> m_completeHandles;
|
||||
|
||||
int m_maxNumTasks;
|
||||
public:
|
||||
///Setup and initialize SPU/CELL/Libspe2
|
||||
|
||||
@@ -116,6 +117,12 @@ public:
|
||||
|
||||
virtual void setNumTasks(int numTasks)
|
||||
{
|
||||
m_maxNumTasks = numTasks;
|
||||
}
|
||||
|
||||
virtual int getNumTasks() const
|
||||
{
|
||||
return m_maxNumTasks;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
@@ -42,6 +42,8 @@ public:
|
||||
///tell the task scheduler to use no more than numTasks tasks
|
||||
virtual void setNumTasks(int numTasks)=0;
|
||||
|
||||
virtual int getNumTasks() const = 0;
|
||||
|
||||
};
|
||||
|
||||
#endif //THREAD_SUPPORT_INTERFACE_H
|
||||
|
||||
Reference in New Issue
Block a user