Equalizer  1.8.0
Parallel Rendering Framework
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Pages
include/eq/client/channel.h
1 
2 /* Copyright (c) 2005-2014, Stefan Eilemann <eile@equalizergraphics.com>
3  * 2010, Cedric Stalder <cedric.stalder@gmail.com>
4  * 2011, 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/client/api.h>
24 #include <eq/client/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 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  void waitFrameFinished( const uint32_t frame ) const;
58 
63  EQ_API bool isStopped() const;
64 
66  EQ_API Pipe* getPipe();
67 
69  EQ_API const Pipe* getPipe() const;
70 
72  EQ_API Node* getNode();
73 
75  EQ_API const Node* getNode() const;
76 
78  EQ_API Config* getConfig();
79 
81  EQ_API const Config* getConfig() const;
82 
84  EQ_API ServerPtr getServer();
85 
99  EQ_API const GLEWContext* glewGetContext() const;
100 
103 
105  EQ_API const DrawableConfig& getDrawableConfig() const;
106 
117  EQ_API View* getNativeView();
118 
120  EQ_API const View* getNativeView() const;
121 
124 
126  EQ_API const Vector3ub& getUniqueColor() const;
127 
129  EQ_API void addStatistic( Event& event );
131 
146  EQ_API virtual Vector2f getJitter() const;
147 
160  EQ_API View* getView();
161 
163  EQ_API const View* getView() const;
164 
174  EQ_API Frustumf getScreenFrustum() const;
176 
190  EQ_API virtual void applyBuffer();
191 
197  EQ_API virtual void applyColorMask() const;
198 
204  EQ_API virtual void applyViewport() const;
205 
218  EQ_API virtual void applyFrustum() const;
219 
224  EQ_API virtual void applyPerspective() const;
225 
230  EQ_API virtual void applyOrtho() const;
231 
239  EQ_API void applyScreenFrustum() const;
240 
246  EQ_API virtual void applyHeadTransform() const;
247 
252  EQ_API virtual void applyPerspectiveTransform() const;
253 
258  EQ_API virtual void applyOrthoTransform() const;
259 
264  EQ_API virtual void applyFrameBufferObject();
265 
270  EQ_API void bindFrameBuffer();
272 
282  EQ_API virtual void resetRegions();
283 
298  EQ_API virtual void declareRegion( const eq::PixelViewport& region );
299 
306  EQ_API void declareRegion( const eq::Viewport& vp );
307 
309  EQ_API PixelViewport getRegion() const;
310 
322  EQ_API const PixelViewports& getRegions() const;
324 
333  EQ_API EventOCommand sendError( const uint32_t error );
334 
346  EQ_API virtual bool processEvent( const Event& event );
348 
350  EQ_API virtual void drawStatistics();
351 
353  EQ_API virtual void outlineViewport();
354 
361  void changeLatency( const uint32_t latency );
362 
363 protected:
365  EQ_API void attach( const uint128_t& id, const uint32_t instanceID );
366 
375  EQ_API void startFrame( const uint32_t frameNumber );
376 
383  EQ_API void releaseFrame( const uint32_t frameNumber );
384 
391  EQ_API void releaseFrameLocal( const uint32_t frameNumber );
392 
403  EQ_API virtual void setupAssemblyState();
404 
406  EQ_API virtual void resetAssemblyState();
408 
424  EQ_API virtual bool configInit( const uint128_t& initID );
425 
427  EQ_API virtual bool configExit();
428 
440  EQ_API virtual void frameStart( const uint128_t& frameID,
441  const uint32_t frameNumber );
442 
453  EQ_API virtual void frameFinish( const uint128_t& frameID,
454  const uint32_t frameNumber );
455 
466  EQ_API virtual void frameDrawFinish( const uint128_t& frameID,
467  const uint32_t frameNumber );
468 
477  EQ_API virtual void frameClear( const uint128_t& frameID );
478 
487  EQ_API virtual void frameDraw( const uint128_t& frameID );
488 
498  EQ_API virtual void frameAssemble( const uint128_t& frameID,
499  const Frames& frames );
500 
511  EQ_API virtual void frameReadback( const uint128_t& frameID,
512  const Frames& frames );
513 
524  EQ_API virtual void frameViewStart( const uint128_t& frameID );
525 
539  EQ_API virtual void frameViewFinish( const uint128_t& frameID );
541 
543  virtual void frameTilesStart( const uint128_t& /*frameID*/ ) {}
544 
546  virtual void frameTilesFinish( const uint128_t& /*frameID*/ ) {}
547 
549  EQ_API virtual void notifyViewportChanged();
550 
563  EQ_API virtual void notifyStopFrame( const uint32_t lastFrameNumber );
564 
565 private:
566  detail::Channel* const _impl;
567  friend class fabric::Window< Pipe, Window, Channel, WindowSettings >;
568 
569  //-------------------- Methods --------------------
571  void _overrideContext( RenderContext& context );
572 
574  bool _configInitFBO();
575 
577  void _initDrawableConfig();
578 
580  void _frameTiles( RenderContext& context, const bool isLocal,
581  const uint128_t& queueID, const uint32_t tasks,
582  const co::ObjectVersions& frames );
583 
585  void _refFrame( const uint32_t frameNumber );
586 
588  void _unrefFrame( const uint32_t frameNumber );
589 
591  void _transmitImage( const co::ObjectVersion& frameDataVersion,
592  const uint128_t& nodeID,
593  const co::NodeID& netNodeID,
594  const uint64_t imageIndex,
595  const uint32_t frameNumber,
596  const uint32_t taskID );
597 
598  void _frameReadback( const uint128_t& frameID,
599  const co::ObjectVersions& frames );
600  void _finishReadback( const co::ObjectVersion& frameDataVersion,
601  const uint64_t imageIndex,
602  const uint32_t frameNumber,
603  const uint32_t taskID,
604  const std::vector< uint128_t >& nodes,
605  const co::NodeIDs& netNodes );
606 
607  bool _asyncFinishReadback( const std::vector< size_t >& imagePos,
608  const Frames& frames );
609 
610  void _asyncTransmit( FrameDataPtr frame, const uint32_t frameNumber,
611  const uint64_t image,
612  const std::vector< uint128_t >& nodes,
613  const co::NodeIDs& netNodes,
614  const uint32_t taskID );
615 
616  void _setReady( const bool async, detail::RBStat* stat,
617  const Frames& frames );
618  void _asyncSetReady( const FrameDataPtr frame, detail::RBStat* stat,
619  const std::vector< uint128_t >& nodes,
620  const co::NodeIDs& netNodes );
621 
622  void _setReady( FrameDataPtr frame, detail::RBStat* stat,
623  const std::vector< uint128_t >& nodes,
624  const co::NodeIDs& netNodes );
625 
627  co::QueueSlave* _getQueue( const uint128_t& queueID );
628 
629  Frames _getFrames( const co::ObjectVersions& frameIDs,
630  const bool isOutput );
631 
632  void _deleteTransferContext();
633 
634  /* The command handler functions. */
635  bool _cmdConfigInit( co::ICommand& command );
636  bool _cmdConfigExit( co::ICommand& command );
637  bool _cmdFrameStart( co::ICommand& command );
638  bool _cmdFrameFinish( co::ICommand& command );
639  bool _cmdFrameClear( co::ICommand& command );
640  bool _cmdFrameDraw( co::ICommand& command );
641  bool _cmdFrameDrawFinish( co::ICommand& command );
642  bool _cmdFrameAssemble( co::ICommand& command );
643  bool _cmdFrameReadback( co::ICommand& command );
644  bool _cmdFinishReadback( co::ICommand& command );
645  bool _cmdFrameSetReady( co::ICommand& command );
646  bool _cmdFrameTransmitImage( co::ICommand& command );
647  bool _cmdFrameSetReadyNode( co::ICommand& command );
648  bool _cmdFrameViewStart( co::ICommand& command );
649  bool _cmdFrameViewFinish( co::ICommand& command );
650  bool _cmdStopFrame( co::ICommand& command );
651  bool _cmdFrameTiles( co::ICommand& command );
652  bool _cmdDeleteTransferContext( co::ICommand& command );
653 
654  LB_TS_VAR( _pipeThread );
655 };
656 }
657 
658 #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.
A configuration is a visualization session driven by an application.
A C++ class to abstract OpenGL frame buffer objects.
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 void frameTilesStart(const uint128_t &)
Start a batch of tile rendering operations.
A Pipe represents a graphics card (GPU) on a Node.
EQ_API ServerPtr getServer()
A Node represents a single computer in the cluster.
EQ_API void bindFrameBuffer()
Rebind the current alternate FBO of the channel or window.
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.
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.
EQ_API util::ObjectManager & getObjectManager()
A Window represents an on-screen or off-screen drawable.
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.
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 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
virtual EQ_API bool configExit()
Exit this channel.
std::vector< Frame * > Frames
A vector of pointers to eq::Frame.
EQ_API util::FrameBufferObject * getFrameBufferObject()
A View is a 2D area of a Layout.
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.
EQ_API bool isStopped() const
virtual EQ_API void frameViewFinish(const uint128_t &frameID)
Finish updating a destination channel.
A facility class to manage OpenGL objects across shared contexts.
Definition: objectManager.h:51
Base data transport class for channels.
virtual EQ_API void setupAssemblyState()
Setup the OpenGL state for a readback or assemble operation.
virtual EQ_API void applyFrameBufferObject()
Apply the current alternate frame buffer.
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.
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.