Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/physics/src/bullet/BulletMultiThreaded/SequentialThreadSupport.h @ 1967

Last change on this file since 1967 was 1963, checked in by rgrieder, 16 years ago

Added Bullet physics engine.

  • Property svn:eol-style set to native
File size: 2.9 KB
Line 
1/*
2Bullet Continuous Collision Detection and Physics Library
3Copyright (c) 2003-2007 Erwin Coumans  http://bulletphysics.com
4
5This software is provided 'as-is', without any express or implied warranty.
6In no event will the authors be held liable for any damages arising from the use of this software.
7Permission is granted to anyone to use this software for any purpose,
8including commercial applications, and to alter it and redistribute it freely,
9subject to the following restrictions:
10
111. 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.
122. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
133. 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 SEQUENTIAL_THREAD_SUPPORT_H
21#define SEQUENTIAL_THREAD_SUPPORT_H
22
23#include "LinearMath/btAlignedObjectArray.h"
24
25#include "btThreadSupportInterface.h"
26
27typedef void (*SequentialThreadFunc)(void* userPtr,void* lsMemory);
28typedef void* (*SequentiallsMemorySetupFunc)();
29
30
31
32///SequentialThreadSupport is a portable non-parallel implementation of the btThreadSupportInterface
33class SequentialThreadSupport : public btThreadSupportInterface
34{
35public:
36        struct  btSpuStatus
37        {
38                uint32_t        m_taskId;
39                uint32_t        m_commandId;
40                uint32_t        m_status;
41
42                SequentialThreadFunc    m_userThreadFunc;
43
44                void*   m_userPtr; //for taskDesc etc
45                void*   m_lsMemory; //initialized using SequentiallsMemorySetupFunc
46        };
47private:
48        btAlignedObjectArray<btSpuStatus>       m_activeSpuStatus;
49        btAlignedObjectArray<void*>                     m_completeHandles;     
50public:
51        struct  SequentialThreadConstructionInfo
52        {
53                SequentialThreadConstructionInfo (char* uniqueName,
54                                                                        SequentialThreadFunc userThreadFunc,
55                                                                        SequentiallsMemorySetupFunc     lsMemoryFunc
56                                                                        )
57                                                                        :m_uniqueName(uniqueName),
58                                                                        m_userThreadFunc(userThreadFunc),
59                                                                        m_lsMemoryFunc(lsMemoryFunc)
60                {
61
62                }
63
64                char*                                           m_uniqueName;
65                SequentialThreadFunc            m_userThreadFunc;
66                SequentiallsMemorySetupFunc     m_lsMemoryFunc;
67        };
68
69        SequentialThreadSupport(SequentialThreadConstructionInfo& threadConstructionInfo);
70        virtual ~SequentialThreadSupport();
71        void    startThreads(SequentialThreadConstructionInfo&  threadInfo);
72///send messages to SPUs
73        virtual void sendRequest(uint32_t uiCommand, uint32_t uiArgument0, uint32_t uiArgument1);
74///check for messages from SPUs
75        virtual void waitForResponse(unsigned int *puiArgument0, unsigned int *puiArgument1);
76///start the spus (can be called at the beginning of each frame, to make sure that the right SPU program is loaded)
77        virtual void startSPU();
78///tell the task scheduler we are done with the SPU tasks
79        virtual void stopSPU();
80
81        virtual void setNumTasks(int numTasks);
82
83};
84
85#endif //SEQUENTIAL_THREAD_SUPPORT_H
86
Note: See TracBrowser for help on using the repository browser.