diff --git a/Extras/BulletMultiThreaded/SpuSampleTask/SpuSampleTask.cpp b/Extras/BulletMultiThreaded/SpuSampleTask/SpuSampleTask.cpp index 2ea1280ce..32909f9dc 100644 --- a/Extras/BulletMultiThreaded/SpuSampleTask/SpuSampleTask.cpp +++ b/Extras/BulletMultiThreaded/SpuSampleTask/SpuSampleTask.cpp @@ -19,16 +19,24 @@ subject to the following restrictions: #include "../PlatformDefinitions.h" #include "../SpuFakeDma.h" #include "LinearMath/btMinMax.h" -#include +#ifdef __SPU__ +#include +#else +#include +#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(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;igLocalRigidBody[0]; + void* shortAdd = localMemory->gPointerArray[i]; + uint64_t ppuRigidBodyAddress = reinterpret_cast(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: diff --git a/Extras/BulletMultiThreaded/SpuSampleTask/SpuSampleTask.h b/Extras/BulletMultiThreaded/SpuSampleTask/SpuSampleTask.h index 9c02401e5..e3ca4d2bc 100644 --- a/Extras/BulletMultiThreaded/SpuSampleTask/SpuSampleTask.h +++ b/Extras/BulletMultiThreaded/SpuSampleTask/SpuSampleTask.h @@ -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; + }; diff --git a/src/LinearMath/btQuadWord.h b/src/LinearMath/btQuadWord.h index c14481928..647b9eeeb 100644 --- a/src/LinearMath/btQuadWord.h +++ b/src/LinearMath/btQuadWord.h @@ -19,13 +19,7 @@ subject to the following restrictions: #include "btScalar.h" #include "btMinMax.h" #include -#ifdef __PPU__ -#include -#endif -#ifdef __SPU__ -#include -#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 // }; diff --git a/src/LinearMath/btVector3.h b/src/LinearMath/btVector3.h index d68e0279f..96548c6ba 100644 --- a/src/LinearMath/btVector3.h +++ b/src/LinearMath/btVector3.h @@ -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; }