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 "SequentialThreadSupport.h" |
---|
17 | |
---|
18 | |
---|
19 | #include "SpuCollisionTaskProcess.h" |
---|
20 | #include "SpuNarrowPhaseCollisionTask/SpuGatheringCollisionTask.h" |
---|
21 | |
---|
22 | SequentialThreadSupport::SequentialThreadSupport(SequentialThreadConstructionInfo& threadConstructionInfo) |
---|
23 | { |
---|
24 | startThreads(threadConstructionInfo); |
---|
25 | } |
---|
26 | |
---|
27 | ///cleanup/shutdown Libspe2 |
---|
28 | SequentialThreadSupport::~SequentialThreadSupport() |
---|
29 | { |
---|
30 | stopSPU(); |
---|
31 | } |
---|
32 | |
---|
33 | #include <stdio.h> |
---|
34 | |
---|
35 | ///send messages to SPUs |
---|
36 | void SequentialThreadSupport::sendRequest(uint32_t uiCommand, uint32_t uiArgument0, uint32_t taskId) |
---|
37 | { |
---|
38 | switch (uiCommand) |
---|
39 | { |
---|
40 | case CMD_GATHER_AND_PROCESS_PAIRLIST: |
---|
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 | { |
---|
49 | ///not implemented |
---|
50 | btAssert(0 && "Not implemented"); |
---|
51 | } |
---|
52 | |
---|
53 | }; |
---|
54 | |
---|
55 | |
---|
56 | } |
---|
57 | |
---|
58 | ///check for messages from SPUs |
---|
59 | void SequentialThreadSupport::waitForResponse(unsigned int *puiArgument0, unsigned int *puiArgument1) |
---|
60 | { |
---|
61 | btAssert(m_activeSpuStatus.size()); |
---|
62 | btSpuStatus& spuStatus = m_activeSpuStatus[0]; |
---|
63 | *puiArgument0 = spuStatus.m_taskId; |
---|
64 | *puiArgument1 = spuStatus.m_status; |
---|
65 | } |
---|
66 | |
---|
67 | void SequentialThreadSupport::startThreads(SequentialThreadConstructionInfo& threadConstructionInfo) |
---|
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 | |
---|
81 | void SequentialThreadSupport::startSPU() |
---|
82 | { |
---|
83 | } |
---|
84 | |
---|
85 | void SequentialThreadSupport::stopSPU() |
---|
86 | { |
---|
87 | m_activeSpuStatus.clear(); |
---|
88 | } |
---|
89 | |
---|
90 | void SequentialThreadSupport::setNumTasks(int numTasks) |
---|
91 | { |
---|
92 | printf("SequentialThreadSupport::setNumTasks(%d) is not implemented and has no effect\n",numTasks); |
---|
93 | } |
---|