undo btQuadWord changes, added integration in parallel SpuSampleTask

This commit is contained in:
erwin.coumans
2008-06-04 02:01:41 +00:00
parent 5e3777ddd2
commit 8827d5dbfb
4 changed files with 72 additions and 38 deletions

View File

@@ -19,16 +19,24 @@ subject to the following restrictions:
#include "../PlatformDefinitions.h"
#include "../SpuFakeDma.h"
#include "LinearMath/btMinMax.h"
#include <stdio.h>
#ifdef __SPU__
#include <spu_printf.h>
#else
#include <stdio.h>
#define spu_printf printf
#endif
struct SampleTask_LocalStoreMemory
{
ATTRIBUTE_ALIGNED16(char gLocalRigidBody [sizeof(btRigidBody)+16]);
ATTRIBUTE_ALIGNED16(void* gPointerArray[1024]); //at max upload 1024 pointers
};
//-- MAIN METHOD
void processSampleTask(void* userPtr, void* lsMemory)
{
@@ -43,11 +51,70 @@ void processSampleTask(void* userPtr, void* lsMemory)
{
case CMD_SAMPLE_INTEGRATE_BODIES:
{
btTransform predictedTrans;
btCollisionObject** eaPtr = (btCollisionObject**)taskDesc.m_mainMemoryPtr;
int batchSize = taskDesc.m_sampleValue;
int dmaArraySize = batchSize*sizeof(void*);
uint64_t ppuArrayAddress = reinterpret_cast<uint64_t>(eaPtr);
// spu_printf("array location is at %llx, batchSize = %d, DMA size = %d\n",ppuArrayAddress,batchSize,dmaArraySize);
if (dmaArraySize>=16)
{
cellDmaLargeGet((void*)&localMemory->gPointerArray[0], ppuArrayAddress , dmaArraySize, DMA_TAG(1), 0, 0);
cellDmaWaitTagStatusAll(DMA_MASK(1));
} else
{
stallingUnalignedDmaSmallGet((void*)&localMemory->gPointerArray[0], ppuArrayAddress , dmaArraySize);
}
for ( int i=0;i<batchSize;i++)
{
///DMA rigid body
void* localPtr = &localMemory->gLocalRigidBody[0];
void* shortAdd = localMemory->gPointerArray[i];
uint64_t ppuRigidBodyAddress = reinterpret_cast<uint64_t>(shortAdd);
// spu_printf("cellDmaGet at CMD_SAMPLE_INTEGRATE_BODIES from %llx to %llx\n",ppuRigidBodyAddress,localPtr);
int dmaBodySize = sizeof(btRigidBody);
cellDmaGet((void*)localPtr, ppuRigidBodyAddress , dmaBodySize, DMA_TAG(1), 0, 0);
cellDmaWaitTagStatusAll(DMA_MASK(1));
float timeStep = 1.f/60.f;
btRigidBody* body = (btRigidBody*) localPtr;//btRigidBody::upcast(colObj);
if (body)
{
if (body->isActive() && (!body->isStaticOrKinematicObject()))
{
body->predictIntegratedTransform(timeStep, predictedTrans);
body->proceedToTransform( predictedTrans);
void* ptr = (void*)localPtr;
// spu_printf("cellDmaLargePut from %llx to LS %llx\n",ptr,ppuRigidBodyAddress);
cellDmaLargePut(ptr, ppuRigidBodyAddress , dmaBodySize, DMA_TAG(1), 0, 0);
cellDmaWaitTagStatusAll(DMA_MASK(1));
}
}
}
/*
#ifdef __SPU__
spu_printf("hello SPU world\n");
#else
printf("hello world\n");
#endif
*/
break;
}
default:

View File

@@ -38,9 +38,9 @@ ATTRIBUTE_ALIGNED16(struct) SpuSampleTaskDesc
uint32_t m_sampleCommand;
uint32_t m_taskId;
uint64_t m_mainMemoryPtr;
int m_sampleValue;
uint64_t m_mainMemoryPtr;
int m_sampleValue;
};

View File

@@ -19,13 +19,7 @@ subject to the following restrictions:
#include "btScalar.h"
#include "btMinMax.h"
#include <math.h>
#ifdef __PPU__
#include <altivec.h>
#endif
#ifdef __SPU__
#include <spu_intrinsics.h>
#endif
//ATTRIBUTE_ALIGNED16(class) btQuadWordStorage
//some issues under PS3 Linux with IBM 2.1 SDK, gcc compiler prevent from using aligned quadword. todo: look into this
@@ -33,34 +27,13 @@ subject to the following restrictions:
class btQuadWordStorage
{
protected:
#if defined __PPU__ || defined __SPU__
union {
vec_float4 m_Vec128;
struct
{
#endif
btScalar m_x;
btScalar m_y;
btScalar m_z;
btScalar m_unusedW;
#if defined __PPU__ || defined __SPU__
};
};
#endif
public:
#if defined __PPU__ || defined __SPU__
inline const vec_float4 get128( ) const
{
return m_Vec128;
}
inline vec_float4 get128( )
{
return m_Vec128;
}
#endif //
};

View File

@@ -48,13 +48,7 @@ public:
SIMD_FORCE_INLINE btVector3& operator+=(const btVector3& v)
{
#ifdef __PPU__
m_Vec128 = vec_add( m_Vec128, v.get128() );
#elif defined __SPU__
m_Vec128 = spu_add( m_Vec128, v.get128() );
#else
m_x += v.x(); m_y += v.y(); m_z += v.z();
#endif
return *this;
}