From d7354e53879e42604c4e55256f62801da9c5abf6 Mon Sep 17 00:00:00 2001 From: ejcoumans Date: Fri, 14 Dec 2007 06:21:51 +0000 Subject: [PATCH] get SequentialThreadSupport to compile on the Mac --- Demos/OpenGL/DemoApplication.cpp | 2 +- Demos/OpenGL/Jamfile | 2 +- Extras/BulletMultiThreaded/SpuFakeDma.cpp | 39 +++++++++++-------- Extras/BulletMultiThreaded/SpuFakeDma.h | 35 +++++++---------- .../SpuGatheringCollisionTask.cpp | 3 +- Extras/BulletMultiThreaded/SpuSync.h | 28 +++++++++++++ Extras/Jamfile | 2 +- src/LinearMath/btScalar.h | 2 + 8 files changed, 72 insertions(+), 41 deletions(-) diff --git a/Demos/OpenGL/DemoApplication.cpp b/Demos/OpenGL/DemoApplication.cpp index 0bfefad18..38003e355 100644 --- a/Demos/OpenGL/DemoApplication.cpp +++ b/Demos/OpenGL/DemoApplication.cpp @@ -260,7 +260,7 @@ void DemoApplication::keyboardCallback(unsigned char key, int x, int y) //return from glutMainLoop(), detect memory leaks etc. glutLeaveMainLoop(); #else - exit(); + exit(0); #endif break; diff --git a/Demos/OpenGL/Jamfile b/Demos/OpenGL/Jamfile index abcb63cd1..eec188c44 100644 --- a/Demos/OpenGL/Jamfile +++ b/Demos/OpenGL/Jamfile @@ -12,7 +12,7 @@ if $(GLUT.AVAILABLE) = "yes" CFlags bulletopenglsupport : ; -LibDepends bulletopenglsupport : bulletdynamics ; +LibDepends bulletopenglsupport : bulletdynamics ; ExternalLibs bulletopenglsupport : GLUT ; } diff --git a/Extras/BulletMultiThreaded/SpuFakeDma.cpp b/Extras/BulletMultiThreaded/SpuFakeDma.cpp index d578210b7..74f42f659 100644 --- a/Extras/BulletMultiThreaded/SpuFakeDma.cpp +++ b/Extras/BulletMultiThreaded/SpuFakeDma.cpp @@ -4,26 +4,31 @@ //Disabling memcpy sometimes helps debugging DMA #define USE_MEMCPY 1 +#ifdef USE_MEMCPY + +#endif + void* cellDmaLargeGetReadOnly(void *ls, uint64_t ea, uint32_t size, uint32_t tag, uint32_t tid, uint32_t rid) { -#if defined (WIN32) || defined (__PPU__) - return (void*)(uint32_t)ea; -#else + +#if defined (__CELLOS_LV2__) || defined (USE_LIBSPE2) cellDmaLargeGet(ls,ea,size,tag,tid,rid); return ls; -#endif //WIN32 +#else + return (void*)(uint32_t)ea; +#endif } void* cellDmaGetReadOnly(void *ls, uint64_t ea, uint32_t size, uint32_t tag, uint32_t tid, uint32_t rid) { -#if defined (WIN32) || defined (__PPU__) - return (void*)(uint32_t)ea; -#else +#if defined (__CELLOS_LV2__) || defined (USE_LIBSPE2) cellDmaGet(ls,ea,size,tag,tid,rid); return ls; -#endif //WIN32 +#else + return (void*)(uint32_t)ea; +#endif } @@ -43,8 +48,10 @@ int stallingUnalignedDmaSmallGet(void *ls, uint64_t ea, uint32_t size) ///make sure last 4 bits are the same, for cellDmaSmallGet uint32_t last4BitsOffset = ea & 0x0f; char* tmpTarget = tmpBuffer + last4BitsOffset; -#ifdef WIN32 - +#if defined (__CELLOS_LV2__) || defined (USE_LIBSPE2) + mfc_get(tmpTarget,ea,size,DMA_TAG(1),0,0); +#else + //copy into final destination #ifdef USE_MEMCPY memcpy(tmpTarget,mainMem,size); #else @@ -53,10 +60,8 @@ int stallingUnalignedDmaSmallGet(void *ls, uint64_t ea, uint32_t size) tmpTarget[i] = mainMem[i]; } #endif //USE_MEMCPY -#else - mfc_get(tmpTarget,ea,size,DMA_TAG(1),0,0); - //copy into final destination -#endif //WIN32 + +#endif cellDmaWaitTagStatusAll(DMA_MASK(1)); @@ -69,8 +74,8 @@ int stallingUnalignedDmaSmallGet(void *ls, uint64_t ea, uint32_t size) return 0; } - -#ifdef WIN32 +#if defined (__CELLOS_LV2__) || defined (USE_LIBSPE2) +#else int cellDmaLargeGet(void *ls, uint64_t ea, uint32_t size, uint32_t tag, uint32_t tid, uint32_t rid) { @@ -126,4 +131,4 @@ void cellDmaWaitTagStatusAll(int ignore) } -#endif //WIN32 +#endif diff --git a/Extras/BulletMultiThreaded/SpuFakeDma.h b/Extras/BulletMultiThreaded/SpuFakeDma.h index 2837e62a3..b6dc22c96 100644 --- a/Extras/BulletMultiThreaded/SpuFakeDma.h +++ b/Extras/BulletMultiThreaded/SpuFakeDma.h @@ -15,23 +15,6 @@ #define DMA_TAG(xfer) (xfer + 1) #define DMA_MASK(xfer) (1 << DMA_TAG(xfer)) - -#else -#ifdef 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); - /// cellDmaLargePut Win32 replacements for Cell DMA to allow simulating most of the SPU code (just memcpy) - 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); - - #elif defined(USE_LIBSPE2) #define DMA_TAG(xfer) (xfer + 1) @@ -109,9 +92,21 @@ - - -#endif // WIN32 +#else +//Simulate DMA using memcpy or direct access on non-CELL platforms that don't have DMAs and SPUs (Win32, Mac, Linux etc) +//Potential to add networked simulation using this interface + +#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); + /// cellDmaLargePut Win32 replacements for Cell DMA to allow simulating most of the SPU code (just memcpy) + 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 //__CELLOS_LV2__ diff --git a/Extras/BulletMultiThreaded/SpuNarrowPhaseCollisionTask/SpuGatheringCollisionTask.cpp b/Extras/BulletMultiThreaded/SpuNarrowPhaseCollisionTask/SpuGatheringCollisionTask.cpp index 94ef10226..98c8b22c0 100644 --- a/Extras/BulletMultiThreaded/SpuNarrowPhaseCollisionTask/SpuGatheringCollisionTask.cpp +++ b/Extras/BulletMultiThreaded/SpuNarrowPhaseCollisionTask/SpuGatheringCollisionTask.cpp @@ -85,7 +85,8 @@ int g_CacheHits=0; #include #endif //USE_SN_TUNER -#ifdef WIN32 +#if defined (__CELLOS_LV2__) || defined (USE_LIBSPE2) +#else #define IGNORE_ALIGNMENT 1 #define spu_printf printf #include diff --git a/Extras/BulletMultiThreaded/SpuSync.h b/Extras/BulletMultiThreaded/SpuSync.h index 4e0fc86ae..bb3a650b5 100644 --- a/Extras/BulletMultiThreaded/SpuSync.h +++ b/Extras/BulletMultiThreaded/SpuSync.h @@ -106,6 +106,34 @@ private: ATTRIBUTE_ALIGNED128(uint32_t atomic_buf[32]); }; +#else +//create a dummy implementation (without any locking) useful for serial processing +class btSpinlock +{ +public: + typedef int SpinVariable; + + btSpinlock (SpinVariable* var) + : spinVariable (var) + {} + + void Init () + { + } + + void Lock () + { + } + + void Unlock () + { + } + +private: + SpinVariable* spinVariable; +}; + + #endif diff --git a/Extras/Jamfile b/Extras/Jamfile index 0cd949b5c..e9bfe591d 100644 --- a/Extras/Jamfile +++ b/Extras/Jamfile @@ -5,7 +5,7 @@ SubInclude TOP Extras COLLADA_DOM ; SubInclude TOP Extras glui ; SubInclude TOP Extras LibXML ; SubInclude TOP Extras BulletColladaConverter ; -#SubInclude TOP Extras BulletMultiThreaded ; +SubInclude TOP Extras BulletMultiThreaded ; #SubInclude TOP Extras EPA ; #SubInclude TOP Extras ExtraSolid35 ; SubInclude TOP Extras quickstep ; diff --git a/src/LinearMath/btScalar.h b/src/LinearMath/btScalar.h index 09c4302f1..971c06802 100644 --- a/src/LinearMath/btScalar.h +++ b/src/LinearMath/btScalar.h @@ -111,6 +111,8 @@ inline int btGetVersion() #define btAssert assert //btFullAssert is optional, slows down a lot #define btFullAssert(x) + #define btLikely(_c) _c + #define btUnlikely(_c) _c #endif // LIBSPE2