Equalizer  2.0.0
Parallel Rendering Framework
channel.h
1 
2 /* Copyright (c) 2005-2016, Stefan Eilemann <eile@equalizergraphics.com>
3  * Cedric Stalder <cedric.stalder@gmail.com>
4  * Daniel Nachbaur <danielnachbaur@gmail.com>
5  *
6  * This library is free software; you can redistribute it and/or modify it under
7  * the terms of the GNU Lesser General Public License version 2.1 as published
8  * by the Free Software Foundation.
9  *
10  * This library is distributed in the hope that it will be useful, but WITHOUT
11  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
12  * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
13  * details.
14  *
15  * You should have received a copy of the GNU Lesser General Public License
16  * along with this library; if not, write to the Free Software Foundation, Inc.,
17  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
18  */
19 
20 #ifndef EQ_CHANNEL_H
21 #define EQ_CHANNEL_H
22 
23 #include <eq/api.h>
24 #include <eq/types.h>
25 #include <eq/fabric/channel.h> // base class
26 
27 namespace eq
28 {
29 namespace detail { class Channel; struct RBStat; }
30 
42 class Channel : public fabric::Channel< Window, Channel >
43 {
44 public:
46  EQ_API explicit Channel( Window* parent );
47 
49  EQ_API virtual ~Channel();
50 
53  EQ_API co::CommandQueue* getPipeThreadQueue();
54  EQ_API co::CommandQueue* getCommandThreadQueue();
55  EQ_API uint32_t getCurrentFrame() const;
56 
58  bool waitFrameFinished( uint32_t frame, uint32_t timeout ) const;
59 
64  EQ_API bool isStopped() const;
65 
67  EQ_API Pipe* getPipe();
68 
70  EQ_API const Pipe* getPipe() const;
71 
73  EQ_API Node* getNode();
74 
76  EQ_API const Node* getNode() const;
77 
79  EQ_API Config* getConfig();
80 
82  EQ_API const Config* getConfig() const;
83 
85  EQ_API ServerPtr getServer();
86 
100  EQ_API const GLEWContext* glewGetContext() const;
101 
103  EQ_API util::ObjectManager& getObjectManager();
104 
106  EQ_API const DrawableConfig& getDrawableConfig() const;
107 
118  EQ_API View* getNativeView();
119 
121  EQ_API const View* getNativeView() const;
122 
124  EQ_API const Vector3ub& getUniqueColor() const;
125 
127  EQ_API void addStatistic( Statistic& event );
129 
144  EQ_API virtual Vector2f getJitter() const;
145 
158  EQ_API View* getView();
159 
161  EQ_API const View* getView() const;
162 
172  EQ_API Frustumf getScreenFrustum() const;
174 
188  EQ_API virtual void applyBuffer();
189 
195  EQ_API virtual void applyColorMask() const;
196 
202  EQ_API virtual void applyViewport() const;
203 
216  EQ_API virtual void applyFrustum() const;
217 
222  EQ_API virtual void applyPerspective() const;
223 
228  EQ_API virtual void applyOrtho() const;
229 
237  EQ_API void applyScreenFrustum() const;
238 
244  EQ_API virtual void applyHeadTransform() const;
245 
250  EQ_API virtual void applyPerspectiveTransform() const;
251 
256  EQ_API virtual void applyOrthoTransform() const;
257 
262  EQ_API void applyOverlayState();
263 
268  EQ_API void resetOverlayState();
269 
274  EQ_API void bindFrameBuffer();
275 
280  EQ_API void bindDrawFrameBuffer();
282 
292  EQ_API virtual void resetRegions();
293 
308  EQ_API virtual void declareRegion( const eq::PixelViewport& region );
309 
316  EQ_API void declareRegion( const eq::Viewport& vp );
317 
319  EQ_API PixelViewport getRegion() const;
320 
332  EQ_API const PixelViewports& getRegions() const;
334 
343  EQ_API EventOCommand sendError( const uint32_t error );
344 
356  EQ_API virtual bool processEvent( EventType type, SizeEvent& event );
357  EQ_API virtual bool processEvent( EventType type, PointerEvent& event );
358  EQ_API virtual bool processEvent( EventType type, KeyEvent& event );
359  EQ_API virtual bool processEvent( Statistic& event );
361 
363  EQ_API virtual void drawStatistics();
364 
366  EQ_API virtual void outlineViewport();
367 
374  void changeLatency( const uint32_t latency );
375 
386  EQ_API void addResultImageListener( ResultImageListener* listener );
387 
395  EQ_API void removeResultImageListener( ResultImageListener* listener );
396 
402  EQ_API virtual std::string getDumpImageFileName() const;
403 
404 protected:
406  EQ_API void attach( const uint128_t& id, const uint32_t instanceID );
407 
416  EQ_API void startFrame( const uint32_t frameNumber );
417 
424  EQ_API void releaseFrame( const uint32_t frameNumber );
425 
432  EQ_API void releaseFrameLocal( const uint32_t frameNumber );
433 
444  EQ_API virtual void setupAssemblyState();
445 
447  EQ_API virtual void resetAssemblyState();
449 
465  EQ_API virtual bool configInit( const uint128_t& initID );
466 
468  EQ_API virtual bool configExit();
469 
481  EQ_API virtual void frameStart( const uint128_t& frameID,
482  const uint32_t frameNumber );
483 
494  EQ_API virtual void frameFinish( const uint128_t& frameID,
495  const uint32_t frameNumber );
496 
507  EQ_API virtual void frameDrawFinish( const uint128_t& frameID,
508  const uint32_t frameNumber );
509 
518  EQ_API virtual void frameClear( const uint128_t& frameID );
519 
528  EQ_API virtual void frameDraw( const uint128_t& frameID );
529 
539  EQ_API virtual void frameAssemble( const uint128_t& frameID,
540  const Frames& frames );
541 
552  EQ_API virtual void frameReadback( const uint128_t& frameID,
553  const Frames& frames );
554 
566  EQ_API virtual void frameViewStart( const uint128_t& frameID );
567 
583  EQ_API virtual void frameViewFinish( const uint128_t& frameID );
584 
593  EQ_API virtual void frameDrawOverlay( const uint128_t& frameID );
595 
597  virtual void frameTilesStart( const uint128_t& /*frameID*/ ) {}
598 
600  virtual void frameTilesFinish( const uint128_t& /*frameID*/ ) {}
601 
603  EQ_API virtual void notifyViewportChanged();
604 
617  EQ_API virtual void notifyStopFrame( const uint32_t lastFrameNumber );
618 
619 private:
620  detail::Channel* const _impl;
621  friend class fabric::Window< Pipe, Window, Channel, WindowSettings >;
622 
623  //-------------------- Methods --------------------
625  void _overrideContext( RenderContext& context );
626 
628  void _initDrawableConfig();
629 
631  void _frameTiles( RenderContext& context, const bool isLocal,
632  const uint128_t& queueID, const uint32_t tasks,
633  const co::ObjectVersions& frames );
634 
636  void _refFrame( const uint32_t frameNumber );
637 
639  void _unrefFrame( const uint32_t frameNumber );
640 
642  void _transmitImage( const co::ObjectVersion& frameDataVersion,
643  const uint128_t& nodeID,
644  const co::NodeID& netNodeID,
645  const uint64_t imageIndex,
646  const uint32_t frameNumber,
647  const uint32_t taskID );
648 
649  void _frameReadback( const uint128_t& frameID,
650  const co::ObjectVersions& frames );
651  void _finishReadback( const co::ObjectVersion& frameDataVersion,
652  const uint64_t imageIndex,
653  const uint32_t frameNumber,
654  const uint32_t taskID,
655  const std::vector< uint128_t >& nodes,
656  const co::NodeIDs& netNodes );
657 
658  bool _asyncFinishReadback( const std::vector< size_t >& imagePos,
659  const Frames& frames );
660 
661  void _asyncTransmit( FrameDataPtr frame, const uint32_t frameNumber,
662  const uint64_t image,
663  const std::vector< uint128_t >& nodes,
664  const co::NodeIDs& netNodes,
665  const uint32_t taskID );
666 
667  void _setReady( const bool async, detail::RBStat* stat,
668  const Frames& frames );
669  void _asyncSetReady( const FrameDataPtr frame, detail::RBStat* stat,
670  const std::vector< uint128_t >& nodes,
671  const co::NodeIDs& netNodes );
672 
673  void _setReady( FrameDataPtr frame, detail::RBStat* stat,
674  const std::vector< uint128_t >& nodes,
675  const co::NodeIDs& netNodes );
676 
678  co::QueueSlave* _getQueue( const uint128_t& queueID );
679 
680  Frames _getFrames( const co::ObjectVersions& frameIDs,
681  const bool isOutput );
682 
683  void _createTransferWindow();
684  void _deleteTransferWindow();
685 
686  /* The command handler functions. */
687  bool _cmdConfigInit( co::ICommand& command );
688  bool _cmdConfigExit( co::ICommand& command );
689  bool _cmdFrameStart( co::ICommand& command );
690  bool _cmdFrameFinish( co::ICommand& command );
691  bool _cmdFrameClear( co::ICommand& command );
692  bool _cmdFrameDraw( co::ICommand& command );
693  bool _cmdFrameDrawFinish( co::ICommand& command );
694  bool _cmdFrameAssemble( co::ICommand& command );
695  bool _cmdFrameReadback( co::ICommand& command );
696  bool _cmdFinishReadback( co::ICommand& command );
697  bool _cmdFrameSetReady( co::ICommand& command );
698  bool _cmdFrameTransmitImage( co::ICommand& command );
699  bool _cmdFrameSetReadyNode( co::ICommand& command );
700  bool _cmdFrameViewStart( co::ICommand& command );
701  bool _cmdFrameViewFinish( co::ICommand& command );
702  bool _cmdStopFrame( co::ICommand& command );
703  bool _cmdFrameTiles( co::ICommand& command );
704  bool _cmdDeleteTransferWindow( co::ICommand& command );
705 
706  LB_TS_VAR( _pipeThread );
707 };
708 }
709 
710 #endif // EQ_CHANNEL_H
A channel represents a two-dimensional viewport within a Window.
Definition: channel.h:42
A configuration is a visualization session driven by an application.
Definition: config.h:55
virtual void frameTilesStart(const uint128_t &)
Start a batch of tile rendering operations.
Definition: channel.h:597
A Pipe represents a graphics card (GPU) on a Node.
Definition: pipe.h:50
A Node represents a single computer in the cluster.
Definition: node.h:49
std::vector< PixelViewport > PixelViewports
A vector of eq::PixelViewport.
Definition: eq/types.h:175
EQ_API Config * getConfig(const int argc, char **argv)
Convenience function to retrieve a configuration.
lunchbox::RefPtr< Server > ServerPtr
A reference-counted pointer to an eq::Server.
Definition: eq/types.h:215
A Window represents an on-screen or off-screen drawable.
Definition: window.h:63
The result image listener gets notified on new images produced by destination channels.
The Equalizer client library.
Definition: eq/agl/types.h:23
std::vector< Frame * > Frames
A vector of pointers to eq::Frame.
Definition: eq/types.h:161
A View is a 2D area of a Layout.
Definition: view.h:42
Base data transport class for windows.
virtual void frameTilesFinish(const uint128_t &)
Finish a batch of tile rendering operations.
Definition: channel.h:600
A facility class to manage OpenGL objects across shared contexts.
Definition: objectManager.h:53
Base data transport class for channels.
lunchbox::RefPtr< FrameData > FrameDataPtr
A reference-counted pointer to an eq::FrameData.
Definition: eq/types.h:217