Equalizer  1.6.1
include/eq/client/node.h
1 
2 /* Copyright (c) 2005-2013, Stefan Eilemann <eile@equalizergraphics.com>
3  * 2010, Cedric Stalder<cedric.stalder@gmail.com>
4  *
5  * This library is free software; you can redistribute it and/or modify it under
6  * the terms of the GNU Lesser General Public License version 2.1 as published
7  * by the Free Software Foundation .
8  *
9  * This library is distributed in the hope that it will be useful, but WITHOUT
10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11  * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
12  * details.
13  *
14  * You should have received a copy of the GNU Lesser General Public License
15  * along with this library; if not, write to the Free Software Foundation, Inc.,
16  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
17  */
18 
19 #ifndef EQ_NODE_H
20 #define EQ_NODE_H
21 
22 #include <eq/client/api.h>
23 #include <eq/client/types.h>
24 #include <eq/client/visitorResult.h> // enum
25 #include <eq/fabric/node.h> // base class
26 
27 #include <co/commandQueue.h>
28 #include <co/types.h>
29 #include <lunchbox/monitor.h> // member
30 #include <lunchbox/mtQueue.h> // member
31 
32 namespace eq
33 {
49  class Node : public fabric::Node< Config, Node, Pipe, NodeVisitor >
50  {
51  public:
53  EQ_API Node( Config* parent );
54 
56  EQ_API virtual ~Node();
57 
59  EQ_API ClientPtr getClient();
60 
62  EQ_API ServerPtr getServer();
63 
64  EQ_API co::CommandQueue* getMainThreadQueue();
65  EQ_API co::CommandQueue* getCommandThreadQueue();
66 
68  uint32_t getCurrentFrame() const { return _currentFrame.get(); }
69 
77  co::Barrier* getBarrier( const co::ObjectVersion barrier );
78 
86  FrameDataPtr getFrameData( const co::ObjectVersion& frameDataVersion );
87 
89  void releaseFrameData( FrameDataPtr data );
90 
92  EQ_API void waitInitialized() const;
93 
98  EQ_API bool isRunning() const;
99 
104  EQ_API bool isStopped() const;
105 
116  EQ_API void waitFrameStarted( const uint32_t frameNumber ) const;
117 
119  uint32_t getFinishedFrame() const { return _finishedFrame; }
120 
132  EQ_API virtual bool processEvent( const Event& event );
133 
135  class TransmitThread : public lunchbox::Thread
136  {
137  public:
138  TransmitThread( Node* parent ) : _node( parent ) {}
139  virtual ~TransmitThread() {}
140 
141  co::CommandQueue& getQueue() { return _queue; }
142 
143  protected:
144  virtual void run();
145 
146  private:
147  co::CommandQueue _queue;
148  Node* const _node;
149  } transmitter;
150 
152  EQ_API virtual void setDirty( const uint64_t bits );
153 
155  EQ_API void dirtyClientExit();
156 
157  protected:
159  EQ_API virtual void attach( const UUID& id, const uint32_t instanceID );
160 
169  EQ_API void startFrame( const uint32_t frameNumber );
170 
177  EQ_API void releaseFrame( const uint32_t frameNumber );
178 
185  EQ_API void releaseFrameLocal( const uint32_t frameNumber );
187 
195 
202  EQ_API virtual bool configInit( const uint128_t& initID );
203 
205  EQ_API virtual bool configExit();
206 
220  EQ_API virtual void frameStart( const uint128_t& frameID,
221  const uint32_t frameNumber );
222 
235  EQ_API virtual void frameFinish( const uint128_t& frameID,
236  const uint32_t frameNumber );
237 
250  EQ_API virtual void frameDrawFinish( const uint128_t& frameID,
251  const uint32_t frameNumber );
252 
268  EQ_API virtual void frameTasksFinish( const uint128_t& frameID,
269  const uint32_t frameNumber );
271 
272  private:
273  enum State
274  {
275  STATE_STOPPED,
276  STATE_INITIALIZING,
277  STATE_INIT_FAILED,
278  STATE_RUNNING,
279  STATE_FAILED
280  };
282  lunchbox::Monitor< State > _state;
283 
285  lunchbox::Monitor< uint32_t > _currentFrame;
286 
288  uint32_t _finishedFrame;
289 
291  uint32_t _unlockedFrame;
292 
293  typedef stde::hash_map< uint128_t, co::Barrier* > BarrierHash;
295  lunchbox::Lockable< BarrierHash > _barriers;
296 
297  typedef stde::hash_map< uint128_t, FrameDataPtr > FrameDataHash;
298  typedef FrameDataHash::const_iterator FrameDataHashCIter;
299  typedef FrameDataHash::iterator FrameDataHashIter;
301  lunchbox::Lockable< FrameDataHash > _frameDatas;
302 
303  struct Private;
304  Private* _private; // placeholder for binary-compatible changes
305 
306  void _setAffinity();
307 
308  void _finishFrame( const uint32_t frameNumber ) const;
309  void _frameFinish( const uint128_t& frameID,
310  const uint32_t frameNumber );
311 
312  void _flushObjects();
313 
315  bool _cmdCreatePipe( co::ICommand& command );
316  bool _cmdDestroyPipe( co::ICommand& command );
317  bool _cmdConfigInit( co::ICommand& command );
318  bool _cmdConfigExit( co::ICommand& command );
319  bool _cmdFrameStart( co::ICommand& command );
320  bool _cmdFrameFinish( co::ICommand& command );
321  bool _cmdFrameDrawFinish( co::ICommand& command );
322  bool _cmdFrameTasksFinish( co::ICommand& command );
323  bool _cmdFrameDataTransmit( co::ICommand& command );
324  bool _cmdFrameDataReady( co::ICommand& command );
325  bool _cmdSetAffinity( co::ICommand& command );
326 
327  LB_TS_VAR( _nodeThread );
328  LB_TS_VAR( _commandThread );
329  };
330 }
331 
332 #endif // EQ_NODE_H
virtual bool processEvent(const Event &event)
Process a received event.
A configuration is a visualization session driven by an application.
Event structure to report window system and other events.
Definition: event.h:171
bool isRunning() const
virtual void setDirty(const uint64_t bits)
virtual void frameDrawFinish(const uint128_t &frameID, const uint32_t frameNumber)
Finish drawing.
void waitFrameStarted(const uint32_t frameNumber) const
Wait for a frame to be started.
void releaseFrameLocal(const uint32_t frameNumber)
Release the local synchronization of the parent for a frame.
virtual ~Node()
Destruct the node.
A Node represents a single computer in the cluster.
lunchbox::RefPtr< Server > ServerPtr
A reference-counted pointer to an eq::Server.
void startFrame(const uint32_t frameNumber)
Start a frame by unlocking all child resources.
virtual bool configInit(const uint128_t &initID)
Initialize this node.
ClientPtr getClient()
lunchbox::RefPtr< Client > ClientPtr
A reference-counted pointer to an eq::Client.
bool isStopped() const
virtual void frameFinish(const uint128_t &frameID, const uint32_t frameNumber)
Finish rendering a frame.
virtual bool configExit()
Exit this node.
void releaseFrame(const uint32_t frameNumber)
Signal the completion of a frame to the parent.
lunchbox::RefPtr< FrameData > FrameDataPtr
A reference-counted pointer to an eq::FrameData.
virtual void frameTasksFinish(const uint128_t &frameID, const uint32_t frameNumber)
Finish all rendering tasks.
virtual void frameStart(const uint128_t &frameID, const uint32_t frameNumber)
Start rendering a frame.
Base data transport class for nodes.
ServerPtr getServer()
Node(Config *parent)
Construct a new node.