Equalizer  1.13.0
Parallel Rendering Framework
channel.h
1 
2 /* Copyright (c) 2005-2015, 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 
26 #include <eq/fabric/channel.h> // base class
27 
28 namespace eq
29 {
30 namespace detail { class Channel; struct RBStat; }
31 
43 class Channel : public fabric::Channel< Window, Channel >
44 {
45 public:
47  EQ_API explicit Channel( Window* parent );
48 
50  EQ_API virtual ~Channel();
51 
54  EQ_API co::CommandQueue* getPipeThreadQueue();
55  EQ_API co::CommandQueue* getCommandThreadQueue();
56  EQ_API uint32_t getCurrentFrame() const;
57 
59  bool waitFrameFinished( uint32_t frame, uint32_t timeout ) const;
60 
65  EQ_API bool isStopped() const;
66 
68  EQ_API Pipe* getPipe();
69 
71  EQ_API const Pipe* getPipe() const;
72 
74  EQ_API Node* getNode();
75 
77  EQ_API const Node* getNode() const;
78 
80  EQ_API Config* getConfig();
81 
83  EQ_API const Config* getConfig() const;
84 
86  EQ_API ServerPtr getServer();
87 
101  EQ_API const GLEWContext* glewGetContext() const;
102 
105 
107  EQ_API const DrawableConfig& getDrawableConfig() const;
108 
119  EQ_API View* getNativeView();
120 
122  EQ_API const View* getNativeView() const;
123 
125  EQ_API const Vector3ub& getUniqueColor() const;
126 
128  EQ_API void addStatistic( Event& event );
130 
145  EQ_API virtual Vector2f getJitter() const;
146 
159  EQ_API View* getView();
160 
162  EQ_API const View* getView() const;
163 
173  EQ_API Frustumf getScreenFrustum() const;
175 
189  EQ_API virtual void applyBuffer();
190 
196  EQ_API virtual void applyColorMask() const;
197 
203  EQ_API virtual void applyViewport() const;
204 
217  EQ_API virtual void applyFrustum() const;
218 
223  EQ_API virtual void applyPerspective() const;
224 
229  EQ_API virtual void applyOrtho() const;
230 
238  EQ_API void applyScreenFrustum() const;
239 
245  EQ_API virtual void applyHeadTransform() const;
246 
251  EQ_API virtual void applyPerspectiveTransform() const;
252 
257  EQ_API virtual void applyOrthoTransform() const;
258 
263  EQ_API void applyOverlayState();
264 
269  EQ_API void resetOverlayState();
270 
275  EQ_API void bindFrameBuffer();
276 
281  EQ_API void bindDrawFrameBuffer();
283 
293  EQ_API virtual void resetRegions();
294 
309  EQ_API virtual void declareRegion( const eq::PixelViewport& region );
310 
317  EQ_API void declareRegion( const eq::Viewport& vp );
318 
320  EQ_API PixelViewport getRegion() const;
321 
333  EQ_API const PixelViewports& getRegions() const;
335 
344  EQ_API EventOCommand sendError( const uint32_t error );
345 
357  EQ_API virtual bool processEvent( const Event& event );
359 
361  EQ_API virtual void drawStatistics();
362 
364  EQ_API virtual void outlineViewport();
365 
372  void changeLatency( const uint32_t latency );
373 
384  EQ_API void addResultImageListener( ResultImageListener* listener );
385 
393  EQ_API void removeResultImageListener( ResultImageListener* listener );
394 
400  EQ_API virtual std::string getDumpImageFileName() const;
401 
402 protected:
404  EQ_API void attach( const uint128_t& id, const uint32_t instanceID );
405 
414  EQ_API void startFrame( const uint32_t frameNumber );
415 
422  EQ_API void releaseFrame( const uint32_t frameNumber );
423 
430  EQ_API void releaseFrameLocal( const uint32_t frameNumber );
431 
442  EQ_API virtual void setupAssemblyState();
443 
445  EQ_API virtual void resetAssemblyState();
447 
463  EQ_API virtual bool configInit( const uint128_t& initID );
464 
466  EQ_API virtual bool configExit();
467 
479  EQ_API virtual void frameStart( const uint128_t& frameID,
480  const uint32_t frameNumber );
481 
492  EQ_API virtual void frameFinish( const uint128_t& frameID,
493  const uint32_t frameNumber );
494 
505  EQ_API virtual void frameDrawFinish( const uint128_t& frameID,
506  const uint32_t frameNumber );
507 
516  EQ_API virtual void frameClear( const uint128_t& frameID );
517 
526  EQ_API virtual void frameDraw( const uint128_t& frameID );
527 
537  EQ_API virtual void frameAssemble( const uint128_t& frameID,
538  const Frames& frames );
539 
550  EQ_API virtual void frameReadback( const uint128_t& frameID,
551  const Frames& frames );
552 
564  EQ_API virtual void frameViewStart( const uint128_t& frameID );
565 
581  EQ_API virtual void frameViewFinish( const uint128_t& frameID );
582 
591  EQ_API virtual void frameDrawOverlay( const uint128_t& frameID );
593 
595  virtual void frameTilesStart( const uint128_t& /*frameID*/ ) {}
596 
598  virtual void frameTilesFinish( const uint128_t& /*frameID*/ ) {}
599 
601  EQ_API virtual void notifyViewportChanged();
602 
615  EQ_API virtual void notifyStopFrame( const uint32_t lastFrameNumber );
616 
617 private:
618  detail::Channel* const _impl;
619  friend class fabric::Window< Pipe, Window, Channel, WindowSettings >;
620 
621  //-------------------- Methods --------------------
623  void _overrideContext( RenderContext& context );
624 
626  void _initDrawableConfig();
627 
629  void _frameTiles( RenderContext& context, const bool isLocal,
630  const uint128_t& queueID, const uint32_t tasks,
631  const co::ObjectVersions& frames );
632 
634  void _refFrame( const uint32_t frameNumber );
635 
637  void _unrefFrame( const uint32_t frameNumber );
638 
640  void _transmitImage( const co::ObjectVersion& frameDataVersion,
641  const uint128_t& nodeID,
642  const co::NodeID& netNodeID,
643  const uint64_t imageIndex,
644  const uint32_t frameNumber,
645  const uint32_t taskID );
646 
647  void _frameReadback( const uint128_t& frameID,
648  const co::ObjectVersions& frames );
649  void _finishReadback( const co::ObjectVersion& frameDataVersion,
650  const uint64_t imageIndex,
651  const uint32_t frameNumber,
652  const uint32_t taskID,
653  const std::vector< uint128_t >& nodes,
654  const co::NodeIDs& netNodes );
655 
656  bool _asyncFinishReadback( const std::vector< size_t >& imagePos,
657  const Frames& frames );
658 
659  void _asyncTransmit( FrameDataPtr frame, const uint32_t frameNumber,
660  const uint64_t image,
661  const std::vector< uint128_t >& nodes,
662  const co::NodeIDs& netNodes,
663  const uint32_t taskID );
664 
665  void _setReady( const bool async, detail::RBStat* stat,
666  const Frames& frames );
667  void _asyncSetReady( const FrameDataPtr frame, detail::RBStat* stat,
668  const std::vector< uint128_t >& nodes,
669  const co::NodeIDs& netNodes );
670 
671  void _setReady( FrameDataPtr frame, detail::RBStat* stat,
672  const std::vector< uint128_t >& nodes,
673  const co::NodeIDs& netNodes );
674 
676  co::QueueSlave* _getQueue( const uint128_t& queueID );
677 
678  Frames _getFrames( const co::ObjectVersions& frameIDs,
679  const bool isOutput );
680 
681  void _createTransferWindow();
682  void _deleteTransferWindow();
683 
684  /* The command handler functions. */
685  bool _cmdConfigInit( co::ICommand& command );
686  bool _cmdConfigExit( co::ICommand& command );
687  bool _cmdFrameStart( co::ICommand& command );
688  bool _cmdFrameFinish( co::ICommand& command );
689  bool _cmdFrameClear( co::ICommand& command );
690  bool _cmdFrameDraw( co::ICommand& command );
691  bool _cmdFrameDrawFinish( co::ICommand& command );
692  bool _cmdFrameAssemble( co::ICommand& command );
693  bool _cmdFrameReadback( co::ICommand& command );
694  bool _cmdFinishReadback( co::ICommand& command );
695  bool _cmdFrameSetReady( co::ICommand& command );
696  bool _cmdFrameTransmitImage( co::ICommand& command );
697  bool _cmdFrameSetReadyNode( co::ICommand& command );
698  bool _cmdFrameViewStart( co::ICommand& command );
699  bool _cmdFrameViewFinish( co::ICommand& command );
700  bool _cmdStopFrame( co::ICommand& command );
701  bool _cmdFrameTiles( co::ICommand& command );
702  bool _cmdDeleteTransferWindow( co::ICommand& command );
703 
704  LB_TS_VAR( _pipeThread );
705 };
706 }
707 
708 #endif // EQ_CHANNEL_H
virtual EQ_API void frameFinish(const uint128_t &frameID, const uint32_t frameNumber)
Finish rendering a frame.
virtual EQ_API Vector2f getJitter() const
virtual EQ_API void applyColorMask() const
Apply the current color mask.
EQ_API EventOCommand sendError(const uint32_t error)
Send a channel error event to the application node.
virtual EQ_API void frameReadback(const uint128_t &frameID, const Frames &frames)
Read back the rendered frame buffer into the output frames.
virtual EQ_API void outlineViewport()
Outline the current pixel viewport.
A channel represents a two-dimensional viewport within a Window.
Definition: channel.h:43
A configuration is a visualization session driven by an application.
Definition: config.h:55
virtual EQ_API void frameStart(const uint128_t &frameID, const uint32_t frameNumber)
Start rendering a frame.
virtual EQ_API void applyOrthoTransform() const
Apply the transformation to position the orthographic view frustum.
EQ_API void applyScreenFrustum() const
Apply an orthographic frustum for pixel-based 2D operations.
virtual EQ_API bool configInit(const uint128_t &initID)
Initialize this channel.
virtual EQ_API void frameDrawFinish(const uint128_t &frameID, const uint32_t frameNumber)
Finish drawing.
virtual EQ_API void frameDraw(const uint128_t &frameID)
Draw the scene.
virtual EQ_API void frameDrawOverlay(const uint128_t &frameID)
Draw 2D overlay content on a destination channel.
virtual void frameTilesStart(const uint128_t &)
Start a batch of tile rendering operations.
Definition: channel.h:595
A Pipe represents a graphics card (GPU) on a Node.
Definition: pipe.h:50
EQ_API ServerPtr getServer()
A Node represents a single computer in the cluster.
Definition: node.h:48
virtual EQ_API std::string getDumpImageFileName() const
EQ_API void bindFrameBuffer()
Rebind the window frame buffer.
A set of settings to setup an eq::SystemWindow.
virtual EQ_API void applyOrtho() const
Apply the orthographic frustum matrix for the current rendering task.
std::vector< PixelViewport > PixelViewports
A vector of eq::PixelViewport.
Definition: eq/types.h:172
virtual EQ_API void applyViewport() const
Apply the OpenGL viewport for the current rendering task.
virtual EQ_API void applyFrustum() const
Apply the frustum matrix for the current rendering task.
EQ_API void releaseFrameLocal(const uint32_t frameNumber)
Release the local synchronization of the parent for a frame.
EQ_API Frustumf getScreenFrustum() const
Returns an orthographic frustum for 2D operations on the view.
EQ_API void startFrame(const uint32_t frameNumber)
Start a frame by unlocking all child resources.
lunchbox::RefPtr< Server > ServerPtr
A reference-counted pointer to an eq::Server.
Definition: eq/types.h:212
EQ_API void bindDrawFrameBuffer()
Rebind the window draw buffer.
EQ_API util::ObjectManager & getObjectManager()
A Window represents an on-screen or off-screen drawable.
Definition: window.h:64
EQ_API Config * getConfig()
EQ_API const GLEWContext * glewGetContext() const
Get the GLEW context for this channel.
virtual EQ_API void frameViewStart(const uint128_t &frameID)
Start updating a destination channel.
EQ_API Channel(Window *parent)
Construct a new channel.
virtual EQ_API void notifyStopFrame(const uint32_t lastFrameNumber)
Notify interruption of the rendering.
virtual EQ_API void applyPerspectiveTransform() const
Apply the transformation to position the perspective view frustum.
The result image listener gets notified on new images produced by destination channels.
EQ_API Node * getNode()
EQ_API const Vector3ub & getUniqueColor() const
virtual EQ_API void applyHeadTransform() const
Apply the transformation to position the view frustum.
EQ_API void resetOverlayState()
Reset the overlay state setup by applyOverlayState()
EQ_API View * getNativeView()
Get the channel's native view.
virtual EQ_API void frameClear(const uint128_t &frameID)
Clear the frame buffer.
virtual EQ_API void drawStatistics()
Draw a statistics overlay.
EQ_API Pipe * getPipe()
EQ_API const DrawableConfig & getDrawableConfig() const
The Equalizer client library.
Definition: eq/agl/types.h:23
virtual EQ_API bool configExit()
Exit this channel.
std::vector< Frame * > Frames
A vector of pointers to eq::Frame.
Definition: eq/types.h:158
EQ_API void addResultImageListener(ResultImageListener *listener)
Add a listener that gets notified everytime a new frame was rendered for a destination channel...
A View is a 2D area of a Layout.
Definition: view.h:42
virtual EQ_API void notifyViewportChanged()
Notification that parameters influencing the vp/pvp have changed.
virtual EQ_API void resetRegions()
Reset the declared regions of interest.
Base data transport class for windows.
EQ_API View * getView()
Get the channel's current View.
virtual EQ_API bool processEvent(const Event &event)
Process a received event.
virtual void frameTilesFinish(const uint128_t &)
Finish a batch of tile rendering operations.
Definition: channel.h:598
EQ_API bool isStopped() const
virtual EQ_API void frameViewFinish(const uint128_t &frameID)
Finish updating a destination channel.
EQ_API void removeResultImageListener(ResultImageListener *listener)
Remove a result image listener to stop receival of notifications on new images.
A facility class to manage OpenGL objects across shared contexts.
Definition: objectManager.h:52
Base data transport class for channels.
EQ_API void applyOverlayState()
Apply the state for pixel-based 2D overlay rendering operations.
virtual EQ_API void setupAssemblyState()
Setup the OpenGL state for a readback or assemble operation.
virtual EQ_API void applyPerspective() const
Apply the perspective frustum matrix for the current rendering task.
virtual EQ_API void applyBuffer()
Apply the current rendering buffer, including the color mask.
EQ_API PixelViewport getRegion() const
lunchbox::RefPtr< FrameData > FrameDataPtr
A reference-counted pointer to an eq::FrameData.
Definition: eq/types.h:214
virtual EQ_API void frameAssemble(const uint128_t &frameID, const Frames &frames)
Assemble all input frames.
virtual EQ_API void resetAssemblyState()
Reset the OpenGL state after an assembly operation.
EQ_API const PixelViewports & getRegions() const
Get the current regions of interest.
virtual EQ_API ~Channel()
Destruct the channel.
EQ_API void releaseFrame(const uint32_t frameNumber)
Signal the completion of a frame to the parent.
virtual EQ_API void declareRegion(const eq::PixelViewport &region)
Declare a region covered by the current draw or assemble operation.