Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016 #include "LinearMath/btScalar.h"
00017 #include "PlatformDefinitions.h"
00018
00019 #ifdef USE_WIN32_THREADING //platform specific defines are defined in PlatformDefinitions.h
00020
00021 #ifndef BT_WIN32_THREAD_SUPPORT_H
00022 #define BT_WIN32_THREAD_SUPPORT_H
00023
00024 #include "LinearMath/btAlignedObjectArray.h"
00025
00026 #include "btThreadSupportInterface.h"
00027
00028
00029 typedef void (*Win32ThreadFunc)(void* userPtr,void* lsMemory);
00030 typedef void* (*Win32lsMemorySetupFunc)();
00031
00032
00034 class Win32ThreadSupport : public btThreadSupportInterface
00035 {
00036 public:
00038 struct btSpuStatus
00039 {
00040 uint32_t m_taskId;
00041 uint32_t m_commandId;
00042 uint32_t m_status;
00043
00044 Win32ThreadFunc m_userThreadFunc;
00045 void* m_userPtr;
00046 void* m_lsMemory;
00047
00048 void* m_threadHandle;
00049
00050 void* m_eventStartHandle;
00051 char m_eventStartHandleName[32];
00052
00053 void* m_eventCompletetHandle;
00054 char m_eventCompletetHandleName[32];
00055
00056
00057 };
00058 private:
00059
00060 btAlignedObjectArray<btSpuStatus> m_activeSpuStatus;
00061 btAlignedObjectArray<void*> m_completeHandles;
00062
00063 int m_maxNumTasks;
00064 public:
00066
00067 struct Win32ThreadConstructionInfo
00068 {
00069 Win32ThreadConstructionInfo(const char* uniqueName,
00070 Win32ThreadFunc userThreadFunc,
00071 Win32lsMemorySetupFunc lsMemoryFunc,
00072 int numThreads=1,
00073 int threadStackSize=65535
00074 )
00075 :m_uniqueName(uniqueName),
00076 m_userThreadFunc(userThreadFunc),
00077 m_lsMemoryFunc(lsMemoryFunc),
00078 m_numThreads(numThreads),
00079 m_threadStackSize(threadStackSize)
00080 {
00081
00082 }
00083
00084 const char* m_uniqueName;
00085 Win32ThreadFunc m_userThreadFunc;
00086 Win32lsMemorySetupFunc m_lsMemoryFunc;
00087 int m_numThreads;
00088 int m_threadStackSize;
00089
00090 };
00091
00092
00093
00094 Win32ThreadSupport(const Win32ThreadConstructionInfo& threadConstructionInfo);
00095
00097 virtual ~Win32ThreadSupport();
00098
00099 void startThreads(const Win32ThreadConstructionInfo& threadInfo);
00100
00101
00103 virtual void sendRequest(uint32_t uiCommand, ppu_address_t uiArgument0, uint32_t uiArgument1);
00104
00106 virtual void waitForResponse(unsigned int *puiArgument0, unsigned int *puiArgument1);
00107
00108 virtual bool isTaskCompleted(unsigned int *puiArgument0, unsigned int *puiArgument1, int timeOutInMilliseconds);
00109
00111 virtual void startSPU();
00112
00114 virtual void stopSPU();
00115
00116 virtual void setNumTasks(int numTasks)
00117 {
00118 m_maxNumTasks = numTasks;
00119 }
00120
00121 virtual int getNumTasks() const
00122 {
00123 return m_maxNumTasks;
00124 }
00125
00126 virtual void* getThreadLocalMemory(int taskId)
00127 {
00128 return m_activeSpuStatus[taskId].m_lsMemory;
00129 }
00130 virtual btBarrier* createBarrier();
00131
00132 virtual btCriticalSection* createCriticalSection();
00133
00134 virtual void deleteBarrier(btBarrier* barrier);
00135
00136 virtual void deleteCriticalSection(btCriticalSection* criticalSection);
00137 };
00138
00139 #endif //BT_WIN32_THREAD_SUPPORT_H
00140
00141 #endif //USE_WIN32_THREADING