Bullet Collision Detection & Physics Library
SequentialThreadSupport.cpp
Go to the documentation of this file.
1 /*
2 Bullet Continuous Collision Detection and Physics Library
3 Copyright (c) 2003-2007 Erwin Coumans http://bulletphysics.com
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 
17 
18 
21 
23 {
24  startThreads(threadConstructionInfo);
25 }
26 
29 {
30  stopSPU();
31 }
32 
33 #include <stdio.h>
34 
37 {
38  switch (uiCommand)
39  {
41  {
42  btSpuStatus& spuStatus = m_activeSpuStatus[0];
43  spuStatus.m_userPtr=(void*)uiArgument0;
44  spuStatus.m_userThreadFunc(spuStatus.m_userPtr,spuStatus.m_lsMemory);
45  }
46  break;
47  default:
48  {
50  btAssert(0 && "Not implemented");
51  }
52 
53  };
54 
55 
56 }
57 
59 void SequentialThreadSupport::waitForResponse(unsigned int *puiArgument0, unsigned int *puiArgument1)
60 {
62  btSpuStatus& spuStatus = m_activeSpuStatus[0];
63  *puiArgument0 = spuStatus.m_taskId;
64  *puiArgument1 = spuStatus.m_status;
65 }
66 
68 {
69  m_activeSpuStatus.resize(1);
70  printf("STS: Not starting any threads\n");
71  btSpuStatus& spuStatus = m_activeSpuStatus[0];
72  spuStatus.m_userPtr = 0;
73  spuStatus.m_taskId = 0;
74  spuStatus.m_commandId = 0;
75  spuStatus.m_status = 0;
76  spuStatus.m_lsMemory = threadConstructionInfo.m_lsMemoryFunc();
77  spuStatus.m_userThreadFunc = threadConstructionInfo.m_userThreadFunc;
78  printf("STS: Created local store at %p for task %s\n", spuStatus.m_lsMemory, threadConstructionInfo.m_uniqueName);
79 }
80 
82 {
83 }
84 
86 {
87  m_activeSpuStatus.clear();
88 }
89 
91 {
92  printf("SequentialThreadSupport::setNumTasks(%d) is not implemented and has no effect\n",numTasks);
93 }
94 
95 
96 
97 
98 class btDummyBarrier : public btBarrier
99 {
100 private:
101 
102 public:
104  {
105  }
106 
107  virtual ~btDummyBarrier()
108  {
109  }
110 
111  void sync()
112  {
113  }
114 
115  virtual void setMaxCount(int n) {}
116  virtual int getMaxCount() {return 1;}
117 };
118 
120 {
121 
122 public:
124  {
125  }
126 
128  {
129  }
130 
131  unsigned int getSharedParam(int i)
132  {
133  btAssert(i>=0&&i<31);
134  return mCommonBuff[i+1];
135  }
136 
137  void setSharedParam(int i,unsigned int p)
138  {
139  btAssert(i>=0&&i<31);
140  mCommonBuff[i+1] = p;
141  }
142 
143  void lock()
144  {
145  mCommonBuff[0] = 1;
146  }
147 
148  void unlock()
149  {
150  mCommonBuff[0] = 0;
151  }
152 };
153 
154 
155 
156 
158 {
159  return new btDummyBarrier();
160 }
161 
163 {
164  return new btDummyCriticalSection();
165 
166 }
167 
169 {
170  delete barrier;
171 }
172 
174 {
175  delete criticalSection;
176 }
177 
178 
179 
180 
181 
virtual void deleteCriticalSection(btCriticalSection *criticalSection)
unsigned int mCommonBuff[32]
uint32_t ppu_address_t
#define btAssert(x)
Definition: btScalar.h:101
unsigned int getSharedParam(int i)
virtual void sendRequest(uint32_t uiCommand, ppu_address_t uiArgument0, uint32_t uiArgument1)
send messages to SPUs
SequentialThreadSupport(SequentialThreadConstructionInfo &threadConstructionInfo)
virtual void startSPU()
start the spus (can be called at the beginning of each frame, to make sure that the right SPU program...
btAlignedObjectArray< btSpuStatus > m_activeSpuStatus
virtual void setNumTasks(int numTasks)
tell the task scheduler to use no more than numTasks tasks
void setSharedParam(int i, unsigned int p)
void startThreads(SequentialThreadConstructionInfo &threadInfo)
unsigned int uint32_t
virtual void stopSPU()
tell the task scheduler we are done with the SPU tasks
virtual void deleteBarrier(btBarrier *barrier)
virtual btCriticalSection * createCriticalSection()
virtual void waitForResponse(unsigned int *puiArgument0, unsigned int *puiArgument1)
check for messages from SPUs
virtual ~SequentialThreadSupport()
cleanup/shutdown Libspe2
static void barrier(unsigned int a)
virtual btBarrier * createBarrier()
#define CMD_GATHER_AND_PROCESS_PAIRLIST
virtual void setMaxCount(int n)