diff --git a/Extras/BulletMultiThreaded/PlatformDefinitions.h b/Extras/BulletMultiThreaded/PlatformDefinitions.h index 81566c567..88caa204d 100644 --- a/Extras/BulletMultiThreaded/PlatformDefinitions.h +++ b/Extras/BulletMultiThreaded/PlatformDefinitions.h @@ -25,16 +25,19 @@ #else #if defined (__CELLOS_LV2__) ///Playstation 3 Cell SDK + #include #else //non-windows systems #define USE_PTHREADS 1 + #endif //__CELLOS_LV2__ #include #include - + #include //for memcpy + #endif diff --git a/Extras/BulletMultiThreaded/SpuCollisionTaskProcess.cpp b/Extras/BulletMultiThreaded/SpuCollisionTaskProcess.cpp index adf348b37..3eb5c6b55 100644 --- a/Extras/BulletMultiThreaded/SpuCollisionTaskProcess.cpp +++ b/Extras/BulletMultiThreaded/SpuCollisionTaskProcess.cpp @@ -36,7 +36,6 @@ subject to the following restrictions: #include -//#ifdef __CELLOS_LV2__??? #ifdef USE_WIN32_THREADING Win32ThreadSupport gMidphaseSPU(Win32ThreadSupport::Win32ThreadConstructionInfo("collision", processCollisionTask, @@ -44,12 +43,9 @@ Win32ThreadSupport gMidphaseSPU(Win32ThreadSupport::Win32ThreadConstructionInfo( MIDPHASE_NUM_WORKUNIT_TASKS)); #elif defined(USE_LIBSPE2) SpuLibspe2Support gMidphaseSPU(SPU_ELF_COLLISION_DETECTION,MIDPHASE_NUM_WORKUNIT_TASKS); -#endif - -#ifdef __CELLOS_LV2__ - - - +#elif defined (__CELLOS_LV2__) +#include "CellSPURSSupport.ppu.h" +CellSPURSSupport gMidphaseSPU(SPU_ELF_MID_PHASE); #endif diff --git a/Extras/BulletMultiThreaded/SpuCollisionTaskProcess.h b/Extras/BulletMultiThreaded/SpuCollisionTaskProcess.h index e1fe040c2..e4f5e16fe 100644 --- a/Extras/BulletMultiThreaded/SpuCollisionTaskProcess.h +++ b/Extras/BulletMultiThreaded/SpuCollisionTaskProcess.h @@ -50,7 +50,7 @@ struct SpuGatherAndProcessPairsTaskDesc uint16_t numPages; uint16_t taskId; - struct CollisionTask_LocalStoreMemory* m_lsMemory; +// struct CollisionTask_LocalStoreMemory* m_lsMemory; } #ifdef __CELLOS_LV2__ __attribute__ ((aligned (16))) diff --git a/Extras/BulletMultiThreaded/SpuDoubleBuffer.h b/Extras/BulletMultiThreaded/SpuDoubleBuffer.h index 92f465cd4..027ad1b4b 100644 --- a/Extras/BulletMultiThreaded/SpuDoubleBuffer.h +++ b/Extras/BulletMultiThreaded/SpuDoubleBuffer.h @@ -1,14 +1,7 @@ #ifndef DOUBLE_BUFFER_H #define DOUBLE_BUFFER_H -#ifdef __CELLOS_LV2__ - -#include -#include - -#else #include "SpuFakeDma.h" -#endif // ///DoubleBuffer diff --git a/Extras/BulletMultiThreaded/SpuFakeDma.h b/Extras/BulletMultiThreaded/SpuFakeDma.h index 5bc73ce37..d891ee450 100644 --- a/Extras/BulletMultiThreaded/SpuFakeDma.h +++ b/Extras/BulletMultiThreaded/SpuFakeDma.h @@ -5,10 +5,23 @@ #include "PlatformDefinitions.h" + #include //for definition of uint64_t,uint32_t + +#ifdef __CELLOS_LV2__ + +#include +#include + +#define DMA_TAG(xfer) (xfer + 1) +#define DMA_MASK(xfer) (1 << DMA_TAG(xfer)) + +#elif defined (WIN32) + #define DMA_TAG(a) (a) #define DMA_MASK(a) (a) + /// cellDmaLargeGet Win32 replacements for Cell DMA to allow simulating most of the SPU code (just memcpy) int cellDmaLargeGet(void *ls, uint64_t ea, uint32_t size, uint32_t tag, uint32_t tid, uint32_t rid); int cellDmaGet(void *ls, uint64_t ea, uint32_t size, uint32_t tag, uint32_t tid, uint32_t rid); @@ -16,6 +29,7 @@ int cellDmaGet(void *ls, uint64_t ea, uint32_t size, uint32_t tag, uint32_t tid, int cellDmaLargePut(const void *ls, uint64_t ea, uint32_t size, uint32_t tag, uint32_t tid, uint32_t rid); /// cellDmaWaitTagStatusAll Win32 replacements for Cell DMA to allow simulating most of the SPU code (just memcpy) void cellDmaWaitTagStatusAll(int ignore); +#endif //WIN32 #endif //FAKE_DMA_H \ No newline at end of file diff --git a/Extras/BulletMultiThreaded/SpuNarrowPhaseCollisionTask/SpuContactResult.h b/Extras/BulletMultiThreaded/SpuNarrowPhaseCollisionTask/SpuContactResult.h index be8a8eef4..51f12b042 100644 --- a/Extras/BulletMultiThreaded/SpuNarrowPhaseCollisionTask/SpuContactResult.h +++ b/Extras/BulletMultiThreaded/SpuNarrowPhaseCollisionTask/SpuContactResult.h @@ -23,13 +23,7 @@ subject to the following restrictions: -#ifdef WIN32 -#include "SpuDoubleBuffer.h" -#else -#include "SPU_Common/SpuDefines.h" -#include "SPU_Common/SpuDoubleBuffer.h" -#include -#endif //WIN32 +#include "../SpuDoubleBuffer.h" #include "LinearMath/btTransform.h" diff --git a/Extras/BulletMultiThreaded/SpuNarrowPhaseCollisionTask/SpuGatheringCollisionTask.cpp b/Extras/BulletMultiThreaded/SpuNarrowPhaseCollisionTask/SpuGatheringCollisionTask.cpp index ef1ef550e..9241cd98a 100644 --- a/Extras/BulletMultiThreaded/SpuNarrowPhaseCollisionTask/SpuGatheringCollisionTask.cpp +++ b/Extras/BulletMultiThreaded/SpuNarrowPhaseCollisionTask/SpuGatheringCollisionTask.cpp @@ -1,13 +1,13 @@ #include "SpuGatheringCollisionTask.h" -#include "SpuDoubleBuffer.h" +#include "../SpuDoubleBuffer.h" #include "../SpuCollisionTaskProcess.h" #include "../SpuGatheringCollisionDispatcher.h" //for SPU_BATCHSIZE_BROADPHASE_PAIRS #include "BulletCollision/BroadphaseCollision/btBroadphaseProxy.h" -#include "SpuContactManifoldCollisionAlgorithm.h" +#include "../SpuContactManifoldCollisionAlgorithm.h" #include "BulletCollision/CollisionDispatch/btCollisionObject.h" #include "SpuContactResult.h" #include "BulletCollision/CollisionShapes/btOptimizedBvh.h" @@ -78,13 +78,23 @@ struct CollisionTask_LocalStoreMemory - +#ifdef WIN32 void* createCollisionLocalStoreMemory() { return new CollisionTask_LocalStoreMemory; }; +#elif defined(__CELLOS_LV2__) + +CollisionTask_LocalStoreMemory gLocalStoreMemory; +void* createCollisionLocalStoreMemory() +{ + return &gLocalStoreMemory; +} +#endif + + void ProcessSpuConvexConvexCollision(SpuCollisionPairInput* wuInput, CollisionTask_LocalStoreMemory* lsMemPtr, SpuContactResult& spuContacts); @@ -654,6 +664,8 @@ void processCollisionTask(void* userPtr, void* lsMemPtr) CollisionTask_LocalStoreMemory* colMemPtr = (CollisionTask_LocalStoreMemory*)lsMemPtr; CollisionTask_LocalStoreMemory& lsMem = *(colMemPtr); + spu_printf("taskDescPtr=%llx\n",taskDescPtr); + SpuContactResult spuContacts; uint64_t dmaInPtr = taskDesc.inPtr; @@ -667,6 +679,7 @@ void processCollisionTask(void* userPtr, void* lsMemPtr) for (unsigned int i = 0; i < numPages; i++) { + // wait for back buffer dma and swap buffers unsigned char *inputPtr = lsMem.g_workUnitTaskBuffers.swapBuffers(); @@ -688,6 +701,8 @@ void processCollisionTask(void* userPtr, void* lsMemPtr) for (j = 0; j < numOnPage; j++) { + spu_printf("numOnPage=%d\n",numOnPage); + #ifdef DEBUG_SPU_COLLISION_DETECTION printMidphaseInput(&wuInputs[j]); #endif //DEBUG_SPU_COLLISION_DETECTION diff --git a/Extras/BulletMultiThreaded/SpuNarrowPhaseCollisionTask/SpuGjkPairDetector.cpp b/Extras/BulletMultiThreaded/SpuNarrowPhaseCollisionTask/SpuGjkPairDetector.cpp index cf0022187..02aa69356 100644 --- a/Extras/BulletMultiThreaded/SpuNarrowPhaseCollisionTask/SpuGjkPairDetector.cpp +++ b/Extras/BulletMultiThreaded/SpuNarrowPhaseCollisionTask/SpuGjkPairDetector.cpp @@ -18,6 +18,7 @@ subject to the following restrictions: #include "SpuLocalSupport.h" + #if defined(DEBUG) || defined (_DEBUG) #include //for debug printf #ifdef __SPU__ diff --git a/Extras/BulletMultiThreaded/SpuSampleTaskProcess.cpp b/Extras/BulletMultiThreaded/SpuSampleTaskProcess.cpp index ca2fff17b..6e5c4039e 100644 --- a/Extras/BulletMultiThreaded/SpuSampleTaskProcess.cpp +++ b/Extras/BulletMultiThreaded/SpuSampleTaskProcess.cpp @@ -42,13 +42,19 @@ void* SamplelsMemoryFunc() return 0; } - +#ifdef USE_IBM_CELL_SDK //SpuLibspe2Support gSampleSPU(SPU_ELF_SAMPLE,SAMPLE_NUM_WORKUNIT_TASKS); +#elif defined(WIN32) Win32ThreadSupport gSampleSPU(Win32ThreadSupport::Win32ThreadConstructionInfo("sample", SampleThreadFunc, SamplelsMemoryFunc, SAMPLE_NUM_WORKUNIT_TASKS)); +#elif defined(__CELLOS_LV2__) +#include "CellSPURSSupport.ppu.h" +CellSPURSSupport gSampleSPU(SPU_ELF_SAMPLE); + +#endif extern "C" { extern char SPU_SAMPLE_ELF_SYMBOL[]; @@ -62,10 +68,10 @@ SpuSampleTaskDesc g_spuSampleTaskDesc[SAMPLE_NUM_WORKUNIT_TASKS]; -SpuSampleTaskProcess::SpuSampleTaskProcess(Win32ThreadSupport::Win32ThreadConstructionInfo& threadConstructionInfo) +SpuSampleTaskProcess::SpuSampleTaskProcess() { - for (int i = 0; i < threadConstructionInfo.m_numThreads; i++) + for (int i = 0; i < SAMPLE_NUM_WORKUNIT_TASKS; i++) { m_taskBusy[i] = false; } @@ -74,14 +80,20 @@ SpuSampleTaskProcess::SpuSampleTaskProcess(Win32ThreadSupport::Win32ThreadConstr m_initialized = false; - gSampleSPU.startSPUs(threadConstructionInfo); +#ifdef WIN32 + Win32ThreadSupport::Win32ThreadConstructionInfo threadConstructionInfo( + "sample",SampleThreadFunc,SamplelsMemoryFunc); + + gSampleSPU.startSPU(threadConstructionInfo); +#else + gSampleSPU.startSPU(); +#endif } SpuSampleTaskProcess::~SpuSampleTaskProcess() { - - gSampleSPU.stopSPUs(); + gSampleSPU.stopSPU(); } diff --git a/Extras/BulletMultiThreaded/SpuSampleTaskProcess.h b/Extras/BulletMultiThreaded/SpuSampleTaskProcess.h index 243eddc32..543fb7c59 100644 --- a/Extras/BulletMultiThreaded/SpuSampleTaskProcess.h +++ b/Extras/BulletMultiThreaded/SpuSampleTaskProcess.h @@ -65,7 +65,7 @@ class SpuSampleTaskProcess public: - SpuSampleTaskProcess(Win32ThreadSupport::Win32ThreadConstructionInfo& ci); + SpuSampleTaskProcess(); ~SpuSampleTaskProcess(); diff --git a/Extras/BulletMultiThreaded/Win32ThreadSupport.cpp b/Extras/BulletMultiThreaded/Win32ThreadSupport.cpp index b0e26aa6a..4b11df1ec 100644 --- a/Extras/BulletMultiThreaded/Win32ThreadSupport.cpp +++ b/Extras/BulletMultiThreaded/Win32ThreadSupport.cpp @@ -26,13 +26,13 @@ subject to the following restrictions: ///Setup and initialize SPU/CELL/Libspe2 Win32ThreadSupport::Win32ThreadSupport(Win32ThreadConstructionInfo& threadConstructionInfo) { - startSPUs(threadConstructionInfo); + startSPU(threadConstructionInfo); } ///cleanup/shutdown Libspe2 Win32ThreadSupport::~Win32ThreadSupport() { - stopSPUs(); + stopSPU(); } @@ -171,7 +171,7 @@ void Win32ThreadSupport::waitForResponse(unsigned int *puiArgument0, unsigned in ///start the spus group (can be called at the beginning of each frame, to make sure that the right SPU program is loaded) -void Win32ThreadSupport::startSPUs(Win32ThreadConstructionInfo& threadConstructionInfo) +void Win32ThreadSupport::startSPU(Win32ThreadConstructionInfo& threadConstructionInfo) { m_activeSpuStatus.resize(threadConstructionInfo.m_numThreads); @@ -215,7 +215,7 @@ void Win32ThreadSupport::startSPUs(Win32ThreadConstructionInfo& threadConstructi } ///tell the task scheduler we are done with the SPU tasks -void Win32ThreadSupport::stopSPUs() +void Win32ThreadSupport::stopSPU() { // m_activeSpuStatus.pop_back(); // WaitForSingleObject(spuStatus.bla, INFINITE); diff --git a/Extras/BulletMultiThreaded/Win32ThreadSupport.h b/Extras/BulletMultiThreaded/Win32ThreadSupport.h index 70d11d962..c339e6cf1 100644 --- a/Extras/BulletMultiThreaded/Win32ThreadSupport.h +++ b/Extras/BulletMultiThreaded/Win32ThreadSupport.h @@ -104,10 +104,10 @@ public: void waitForResponse(unsigned int *puiArgument0, unsigned int *puiArgument1); ///start the spus (can be called at the beginning of each frame, to make sure that the right SPU program is loaded) - void startSPUs(Win32ThreadConstructionInfo& threadConstructionInfo); + void startSPU(Win32ThreadConstructionInfo& threadConstructionInfo); ///tell the task scheduler we are done with the SPU tasks - void stopSPUs(); + void stopSPU(); };