Bullet Collision Detection & Physics Library
SequentialThreadSupport.h
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 
16 #include "LinearMath/btScalar.h"
17 #include "PlatformDefinitions.h"
18 
19 
20 #ifndef BT_SEQUENTIAL_THREAD_SUPPORT_H
21 #define BT_SEQUENTIAL_THREAD_SUPPORT_H
22 
24 
26 
27 typedef void (*SequentialThreadFunc)(void* userPtr,void* lsMemory);
28 typedef void* (*SequentiallsMemorySetupFunc)();
29 
30 
31 
35 {
36 public:
37  struct btSpuStatus
38  {
42 
44 
45  void* m_userPtr; //for taskDesc etc
46  void* m_lsMemory; //initialized using SequentiallsMemorySetupFunc
47  };
48 private:
51 public:
53  {
54  SequentialThreadConstructionInfo (const char* uniqueName,
55  SequentialThreadFunc userThreadFunc,
56  SequentiallsMemorySetupFunc lsMemoryFunc
57  )
58  :m_uniqueName(uniqueName),
59  m_userThreadFunc(userThreadFunc),
60  m_lsMemoryFunc(lsMemoryFunc)
61  {
62 
63  }
64 
65  const char* m_uniqueName;
68  };
69 
71  virtual ~SequentialThreadSupport();
74  virtual void sendRequest(uint32_t uiCommand, ppu_address_t uiArgument0, uint32_t uiArgument1);
76  virtual void waitForResponse(unsigned int *puiArgument0, unsigned int *puiArgument1);
78  virtual void startSPU();
80  virtual void stopSPU();
81 
82  virtual void setNumTasks(int numTasks);
83 
84  virtual int getNumTasks() const
85  {
86  return 1;
87  }
88  virtual btBarrier* createBarrier();
89 
91 
92  virtual void deleteBarrier(btBarrier* barrier);
93 
94  virtual void deleteCriticalSection(btCriticalSection* criticalSection);
95 
96 
97 };
98 
99 #endif //BT_SEQUENTIAL_THREAD_SUPPORT_H
100 
The SequentialThreadSupport is a portable non-parallel implementation of the btThreadSupportInterface...
The btAlignedObjectArray template class uses a subset of the stl::vector interface for its methods It...
virtual void deleteCriticalSection(btCriticalSection *criticalSection)
void *(* SequentiallsMemorySetupFunc)()
uint32_t ppu_address_t
btAlignedObjectArray< void * > m_completeHandles
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(* SequentialThreadFunc)(void *userPtr, void *lsMemory)
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()
SequentialThreadConstructionInfo(const char *uniqueName, SequentialThreadFunc userThreadFunc, SequentiallsMemorySetupFunc lsMemoryFunc)
virtual int getNumTasks() const
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()