Add PPU fallback for btCompoundShape that have more child shapes than MAX_SPU_COMPOUND_SUBSHAPES (default 16, see SpuNarrowPhaseCollisionTask/SpuCollisionShapes.h)
This commit is contained in:
@@ -23,6 +23,8 @@ subject to the following restrictions:
|
|||||||
#include "BulletCollision/CollisionDispatch/btCollisionObject.h"
|
#include "BulletCollision/CollisionDispatch/btCollisionObject.h"
|
||||||
#include "BulletCollision/CollisionShapes/btCollisionShape.h"
|
#include "BulletCollision/CollisionShapes/btCollisionShape.h"
|
||||||
#include "LinearMath/btQuickprof.h"
|
#include "LinearMath/btQuickprof.h"
|
||||||
|
#include "BulletMultiThreaded/SpuNarrowPhaseCollisionTask/SpuCollisionShapes.h"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -127,11 +129,33 @@ public:
|
|||||||
{
|
{
|
||||||
int proxyType0 = colObj0->getCollisionShape()->getShapeType();
|
int proxyType0 = colObj0->getCollisionShape()->getShapeType();
|
||||||
int proxyType1 = colObj1->getCollisionShape()->getShapeType();
|
int proxyType1 = colObj1->getCollisionShape()->getShapeType();
|
||||||
if (m_dispatcher->supportsDispatchPairOnSpu(proxyType0,proxyType1)
|
bool supportsSpuDispatch = m_dispatcher->supportsDispatchPairOnSpu(proxyType0,proxyType1)
|
||||||
&& (colObj0->getCollisionFlags() != btCollisionObject::CF_DISABLE_SPU_COLLISION_PROCESSING)
|
&& (colObj0->getCollisionFlags() != btCollisionObject::CF_DISABLE_SPU_COLLISION_PROCESSING)
|
||||||
&& (colObj1->getCollisionFlags() != btCollisionObject::CF_DISABLE_SPU_COLLISION_PROCESSING)
|
&& (colObj1->getCollisionFlags() != btCollisionObject::CF_DISABLE_SPU_COLLISION_PROCESSING);
|
||||||
)
|
|
||||||
|
if (proxyType0 == COMPOUND_SHAPE_PROXYTYPE)
|
||||||
{
|
{
|
||||||
|
btCompoundShape* compound = (btCompoundShape*)colObj0->getCollisionShape();
|
||||||
|
if (compound->getNumChildShapes()>MAX_SPU_COMPOUND_SUBSHAPES)
|
||||||
|
{
|
||||||
|
//printf("PPU fallback, compound->getNumChildShapes(%d)>%d\n",compound->getNumChildShapes(),MAX_SPU_COMPOUND_SUBSHAPES);
|
||||||
|
supportsSpuDispatch = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (proxyType1 == COMPOUND_SHAPE_PROXYTYPE)
|
||||||
|
{
|
||||||
|
btCompoundShape* compound = (btCompoundShape*)colObj1->getCollisionShape();
|
||||||
|
if (compound->getNumChildShapes()>MAX_SPU_COMPOUND_SUBSHAPES)
|
||||||
|
{
|
||||||
|
//printf("PPU fallback, compound->getNumChildShapes(%d)>%d\n",compound->getNumChildShapes(),MAX_SPU_COMPOUND_SUBSHAPES);
|
||||||
|
supportsSpuDispatch = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (supportsSpuDispatch)
|
||||||
|
{
|
||||||
|
|
||||||
int so = sizeof(SpuContactManifoldCollisionAlgorithm);
|
int so = sizeof(SpuContactManifoldCollisionAlgorithm);
|
||||||
#ifdef ALLOCATE_SEPARATELY
|
#ifdef ALLOCATE_SEPARATELY
|
||||||
void* mem = btAlignedAlloc(so,16);//m_dispatcher->allocateCollisionAlgorithm(so);
|
void* mem = btAlignedAlloc(so,16);//m_dispatcher->allocateCollisionAlgorithm(so);
|
||||||
|
|||||||
@@ -33,7 +33,9 @@ subject to the following restrictions:
|
|||||||
#include "BulletCollision/CollisionShapes/btConvexHullShape.h"
|
#include "BulletCollision/CollisionShapes/btConvexHullShape.h"
|
||||||
#include "BulletCollision/CollisionShapes/btCompoundShape.h"
|
#include "BulletCollision/CollisionShapes/btCompoundShape.h"
|
||||||
|
|
||||||
#define MAX_NUM_SPU_CONVEX_POINTS 128
|
#define MAX_NUM_SPU_CONVEX_POINTS 128 //@fallback to PPU if a btConvexHullShape has more than MAX_NUM_SPU_CONVEX_POINTS points
|
||||||
|
#define MAX_SPU_COMPOUND_SUBSHAPES 16 //@fallback on PPU if compound has more than MAX_SPU_COMPOUND_SUBSHAPES child shapes
|
||||||
|
#define MAX_SHAPE_SIZE 256 //@todo: assert on this
|
||||||
|
|
||||||
ATTRIBUTE_ALIGNED16(struct) SpuConvexPolyhedronVertexData
|
ATTRIBUTE_ALIGNED16(struct) SpuConvexPolyhedronVertexData
|
||||||
{
|
{
|
||||||
@@ -44,7 +46,7 @@ ATTRIBUTE_ALIGNED16(struct) SpuConvexPolyhedronVertexData
|
|||||||
ATTRIBUTE_ALIGNED16(btVector3 g_convexPointBuffer[MAX_NUM_SPU_CONVEX_POINTS]);
|
ATTRIBUTE_ALIGNED16(btVector3 g_convexPointBuffer[MAX_NUM_SPU_CONVEX_POINTS]);
|
||||||
};
|
};
|
||||||
|
|
||||||
#define MAX_SHAPE_SIZE 256
|
|
||||||
|
|
||||||
ATTRIBUTE_ALIGNED16(struct) CollisionShape_LocalStoreMemory
|
ATTRIBUTE_ALIGNED16(struct) CollisionShape_LocalStoreMemory
|
||||||
{
|
{
|
||||||
@@ -54,7 +56,7 @@ ATTRIBUTE_ALIGNED16(struct) CollisionShape_LocalStoreMemory
|
|||||||
ATTRIBUTE_ALIGNED16(struct) CompoundShape_LocalStoreMemory
|
ATTRIBUTE_ALIGNED16(struct) CompoundShape_LocalStoreMemory
|
||||||
{
|
{
|
||||||
// Compound data
|
// Compound data
|
||||||
#define MAX_SPU_COMPOUND_SUBSHAPES 16
|
|
||||||
ATTRIBUTE_ALIGNED16(btCompoundShapeChild gSubshapes[MAX_SPU_COMPOUND_SUBSHAPES]);
|
ATTRIBUTE_ALIGNED16(btCompoundShapeChild gSubshapes[MAX_SPU_COMPOUND_SUBSHAPES]);
|
||||||
ATTRIBUTE_ALIGNED16(char gSubshapeShape[MAX_SPU_COMPOUND_SUBSHAPES][MAX_SHAPE_SIZE]);
|
ATTRIBUTE_ALIGNED16(char gSubshapeShape[MAX_SPU_COMPOUND_SUBSHAPES][MAX_SHAPE_SIZE]);
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -864,7 +864,9 @@ void handleCollisionPair(SpuCollisionPairInput& collisionPairInput, CollisionTas
|
|||||||
cellDmaWaitTagStatusAll(DMA_MASK(1));
|
cellDmaWaitTagStatusAll(DMA_MASK(1));
|
||||||
|
|
||||||
int childShapeCount0 = spuCompoundShape0->getNumChildShapes();
|
int childShapeCount0 = spuCompoundShape0->getNumChildShapes();
|
||||||
|
btAssert(childShapeCount0< MAX_SPU_COMPOUND_SUBSHAPES);
|
||||||
int childShapeCount1 = spuCompoundShape1->getNumChildShapes();
|
int childShapeCount1 = spuCompoundShape1->getNumChildShapes();
|
||||||
|
btAssert(childShapeCount1< MAX_SPU_COMPOUND_SUBSHAPES);
|
||||||
|
|
||||||
// Start the N^2
|
// Start the N^2
|
||||||
for (int i = 0; i < childShapeCount0; ++i)
|
for (int i = 0; i < childShapeCount0; ++i)
|
||||||
@@ -910,6 +912,7 @@ void handleCollisionPair(SpuCollisionPairInput& collisionPairInput, CollisionTas
|
|||||||
cellDmaWaitTagStatusAll(DMA_MASK(1));
|
cellDmaWaitTagStatusAll(DMA_MASK(1));
|
||||||
|
|
||||||
int childShapeCount = spuCompoundShape->getNumChildShapes();
|
int childShapeCount = spuCompoundShape->getNumChildShapes();
|
||||||
|
btAssert(childShapeCount< MAX_SPU_COMPOUND_SUBSHAPES);
|
||||||
|
|
||||||
for (int i = 0; i < childShapeCount; ++i)
|
for (int i = 0; i < childShapeCount; ++i)
|
||||||
{
|
{
|
||||||
@@ -942,6 +945,8 @@ void handleCollisionPair(SpuCollisionPairInput& collisionPairInput, CollisionTas
|
|||||||
cellDmaWaitTagStatusAll(DMA_MASK(1));
|
cellDmaWaitTagStatusAll(DMA_MASK(1));
|
||||||
|
|
||||||
int childShapeCount = spuCompoundShape->getNumChildShapes();
|
int childShapeCount = spuCompoundShape->getNumChildShapes();
|
||||||
|
btAssert(childShapeCount< MAX_SPU_COMPOUND_SUBSHAPES);
|
||||||
|
|
||||||
|
|
||||||
for (int i = 0; i < childShapeCount; ++i)
|
for (int i = 0; i < childShapeCount; ++i)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user