Equalizer
1.2.1
|
00001 00002 /* Copyright (c) 2005-2012, Stefan Eilemann <eile@equalizergraphics.com> 00003 * 2010, Cedric Stalder<cedric.stalder@gmail.com> 00004 * 00005 * This library is free software; you can redistribute it and/or modify it under 00006 * the terms of the GNU Lesser General Public License version 2.1 as published 00007 * by the Free Software Foundation . 00008 * 00009 * This library is distributed in the hope that it will be useful, but WITHOUT 00010 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 00011 * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more 00012 * details. 00013 * 00014 * You should have received a copy of the GNU Lesser General Public License 00015 * along with this library; if not, write to the Free Software Foundation, Inc., 00016 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 00017 */ 00018 00019 #ifndef EQ_NODE_H 00020 #define EQ_NODE_H 00021 00022 #include <eq/client/api.h> 00023 #include <eq/client/types.h> 00024 #include <eq/client/visitorResult.h> // enum 00025 #include <eq/fabric/node.h> // base class 00026 00027 #include <co/types.h> 00028 #include <co/base/mtQueue.h> // member 00029 00030 namespace eq 00031 { 00047 class Node : public fabric::Node< Config, Node, Pipe, NodeVisitor > 00048 { 00049 public: 00051 EQ_API Node( Config* parent ); 00052 00054 EQ_API virtual ~Node(); 00055 00057 EQ_API ClientPtr getClient(); 00058 00060 EQ_API ServerPtr getServer(); 00061 00062 EQ_API co::CommandQueue* getMainThreadQueue(); 00063 EQ_API co::CommandQueue* getCommandThreadQueue(); 00064 00066 uint32_t getCurrentFrame() const { return _currentFrame.get(); } 00067 00075 co::Barrier* getBarrier( const co::ObjectVersion barrier ); 00076 00084 FrameData* getFrameData( const co::ObjectVersion& dataVersion ); 00085 00087 EQ_API void waitInitialized() const; 00088 00093 EQ_API bool isRunning() const; 00094 00099 EQ_API bool isStopped() const; 00100 00111 EQ_API void waitFrameStarted( const uint32_t frameNumber ) const; 00112 00114 uint32_t getFinishedFrame() const { return _finishedFrame; } 00115 00117 class TransmitThread : public co::base::Thread 00118 { 00119 public: 00120 TransmitThread( Node* parent ) : _node( parent ) {} 00121 virtual ~TransmitThread() {} 00122 00123 co::CommandQueue& getQueue() { return _queue; } 00124 00125 protected: 00126 virtual void run(); 00127 00128 private: 00129 co::CommandQueue _queue; 00130 Node* const _node; 00131 } transmitter; 00132 00134 EQ_API virtual void setDirty( const uint64_t bits ); 00135 00137 EQ_API void dirtyClientExit(); 00138 00139 protected: 00141 EQ_API virtual void attach( const UUID& id, const uint32_t instanceID ); 00142 00151 EQ_API void startFrame( const uint32_t frameNumber ); 00152 00159 EQ_API void releaseFrame( const uint32_t frameNumber ); 00160 00167 EQ_API void releaseFrameLocal( const uint32_t frameNumber ); 00169 00177 00184 EQ_API virtual bool configInit( const uint128_t& initID ); 00185 00187 EQ_API virtual bool configExit(); 00188 00202 EQ_API virtual void frameStart( const uint128_t& frameID, 00203 const uint32_t frameNumber ); 00204 00217 EQ_API virtual void frameFinish( const uint128_t& frameID, 00218 const uint32_t frameNumber ); 00219 00232 EQ_API virtual void frameDrawFinish( const uint128_t& frameID, 00233 const uint32_t frameNumber ); 00234 00250 EQ_API virtual void frameTasksFinish( const uint128_t& frameID, 00251 const uint32_t frameNumber ); 00253 00254 private: 00255 enum State 00256 { 00257 STATE_STOPPED, 00258 STATE_INITIALIZING, 00259 STATE_INIT_FAILED, 00260 STATE_RUNNING, 00261 STATE_FAILED 00262 }; 00264 co::base::Monitor< State > _state; 00265 00267 co::base::Monitor< uint32_t > _currentFrame; 00268 00270 uint32_t _finishedFrame; 00271 00273 uint32_t _unlockedFrame; 00274 00275 typedef stde::hash_map< uint128_t, co::Barrier* > BarrierHash; 00277 co::base::Lockable< BarrierHash > _barriers; 00278 00279 typedef stde::hash_map< uint128_t, FrameData* > FrameDataHash; 00281 co::base::Lockable< FrameDataHash > _frameDatas; 00282 00283 struct Private; 00284 Private* _private; // placeholder for binary-compatible changes 00285 00286 void _finishFrame( const uint32_t frameNumber ) const; 00287 void _frameFinish( const uint128_t& frameID, 00288 const uint32_t frameNumber ); 00289 00290 void _flushObjects(); 00291 00293 bool _cmdCreatePipe( co::Command& command ); 00294 bool _cmdDestroyPipe( co::Command& command ); 00295 bool _cmdConfigInit( co::Command& command ); 00296 bool _cmdConfigExit( co::Command& command ); 00297 bool _cmdFrameStart( co::Command& command ); 00298 bool _cmdFrameFinish( co::Command& command ); 00299 bool _cmdFrameDrawFinish( co::Command& command ); 00300 bool _cmdFrameTasksFinish( co::Command& command ); 00301 bool _cmdFrameDataTransmit( co::Command& command ); 00302 bool _cmdFrameDataReady( co::Command& command ); 00303 00304 EQ_TS_VAR( _nodeThread ); 00305 EQ_TS_VAR( _commandThread ); 00306 }; 00307 } 00308 00309 #endif // EQ_NODE_H 00310