Bullet Collision Detection & Physics Library
SpuGatheringCollisionTask.h
Go to the documentation of this file.
1 /*
2 Bullet Continuous Collision Detection and Physics Library
3 Copyright (c) 2003-2006 Erwin Coumans http://continuousphysics.com/Bullet/
4 
5 This software is provided 'as-is', without any express or implied warranty.
6 In no event will the authors be held liable for any damages arising from the use of this software.
7 Permission is granted to anyone to use this software for any purpose,
8 including commercial applications, and to alter it and redistribute it freely,
9 subject to the following restrictions:
10 
11 1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
12 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
13 3. This notice may not be removed or altered from any source distribution.
14 */
15 
16 #ifndef SPU_GATHERING_COLLISION_TASK_H
17 #define SPU_GATHERING_COLLISION_TASK_H
18 
19 #include "../PlatformDefinitions.h"
20 //#define DEBUG_SPU_COLLISION_DETECTION 1
21 
22 
25 {
26  ppu_address_t m_inPairPtr;//m_pairArrayPtr;
27  //mutex variable
29 
31 
33 
36  bool m_useEpa;
37 
39 }
40 
41 #if defined(__CELLOS_LV2__) || defined(USE_LIBSPE2)
42 __attribute__ ((aligned (128)))
43 #endif
44 ;
45 
46 
47 void processCollisionTask(void* userPtr, void* lsMemory);
48 
51 
52 #if defined(USE_LIBSPE2) && defined(__SPU__)
53 #include "../SpuLibspe2Support.h"
54 #include <spu_intrinsics.h>
55 #include <spu_mfcio.h>
56 #include <SpuFakeDma.h>
57 
58 //#define DEBUG_LIBSPE2_SPU_TASK
59 
60 
61 
62 int main(unsigned long long speid, addr64 argp, addr64 envp)
63 {
64  printf("SPU: hello \n");
65 
66  ATTRIBUTE_ALIGNED128(btSpuStatus status);
68  unsigned int received_message = Spu_Mailbox_Event_Nothing;
69  bool shutdown = false;
70 
71  cellDmaGet(&status, argp.ull, sizeof(btSpuStatus), DMA_TAG(3), 0, 0);
73 
74  status.m_status = Spu_Status_Free;
75  status.m_lsMemory.p = createCollisionLocalStoreMemory();
76 
77  cellDmaLargePut(&status, argp.ull, sizeof(btSpuStatus), DMA_TAG(3), 0, 0);
79 
80 
81  while ( btLikely( !shutdown ) )
82  {
83 
84  received_message = spu_read_in_mbox();
85 
86  if( btLikely( received_message == Spu_Mailbox_Event_Task ))
87  {
88 #ifdef DEBUG_LIBSPE2_SPU_TASK
89  printf("SPU: received Spu_Mailbox_Event_Task\n");
90 #endif //DEBUG_LIBSPE2_SPU_TASK
91 
92  // refresh the status
93  cellDmaGet(&status, argp.ull, sizeof(btSpuStatus), DMA_TAG(3), 0, 0);
95 
96  btAssert(status.m_status==Spu_Status_Occupied);
97 
98  cellDmaGet(&taskDesc, status.m_taskDesc.p, sizeof(SpuGatherAndProcessPairsTaskDesc), DMA_TAG(3), 0, 0);
100 #ifdef DEBUG_LIBSPE2_SPU_TASK
101  printf("SPU:processCollisionTask\n");
102 #endif //DEBUG_LIBSPE2_SPU_TASK
103  processCollisionTask((void*)&taskDesc, taskDesc.m_lsMemory);
104 
105 #ifdef DEBUG_LIBSPE2_SPU_TASK
106  printf("SPU:finished processCollisionTask\n");
107 #endif //DEBUG_LIBSPE2_SPU_TASK
108  }
109  else
110  {
111 #ifdef DEBUG_LIBSPE2_SPU_TASK
112  printf("SPU: received ShutDown\n");
113 #endif //DEBUG_LIBSPE2_SPU_TASK
114  if( btLikely( received_message == Spu_Mailbox_Event_Shutdown ) )
115  {
116  shutdown = true;
117  }
118  else
119  {
120  //printf("SPU - Sth. recieved\n");
121  }
122  }
123 
124  // set to status free and wait for next task
125  status.m_status = Spu_Status_Free;
126  cellDmaLargePut(&status, argp.ull, sizeof(btSpuStatus), DMA_TAG(3), 0, 0);
128 
129 
130  }
131 
132  printf("SPU: shutdown\n");
133  return 0;
134 }
135 #endif // USE_LIBSPE2
136 
137 
138 #endif //SPU_GATHERING_COLLISION_TASK_H
139 
140 
struct CollisionTask_LocalStoreMemory * m_lsMemory
int cellDmaGet(void *ls, uint64_t ea, uint32_t size, uint32_t tag, uint32_t tid, uint32_t rid)
Definition: SpuFakeDma.cpp:173
enum @25 __attribute__
#define ATTRIBUTE_ALIGNED128(a)
Definition: btScalar.h:61
uint32_t ppu_address_t
Task Description for SPU collision detection.
#define DMA_MASK(a)
Definition: SpuFakeDma.h:113
#define btAssert(x)
Definition: btScalar.h:101
unsigned short uint16_t
void * createCollisionLocalStoreMemory()
#define DMA_TAG(a)
Definition: SpuFakeDma.h:112
int cellDmaLargePut(const 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...
Definition: SpuFakeDma.cpp:192
#define btLikely(_c)
Definition: btScalar.h:106
void deleteCollisionLocalStoreMemory()
void cellDmaWaitTagStatusAll(int ignore)
cellDmaWaitTagStatusAll Win32 replacements for Cell DMA to allow simulating most of the SPU code (jus...
Definition: SpuFakeDma.cpp:210
unsigned int uint32_t
#define ATTRIBUTE_ALIGNED16(a)
Definition: btScalar.h:59
Make sure no destructors are called on this memory.
This file provides some platform/compiler checks for common definitions.
void processCollisionTask(void *userPtr, void *lsMemory)