Equalizer  1.6.1
include/eq/client/channel.h
1 
2 /* Copyright (c) 2005-2013, 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 
100  EQ_API const GLEWContext* glewGetContext() const;
101 
104 
106  EQ_API const DrawableConfig& getDrawableConfig() const;
107 
119  EQ_API View* getNativeView();
120 
122  EQ_API const View* getNativeView() const;
123 
126 
128  EQ_API const Vector3ub& getUniqueColor() const;
129 
131  EQ_API void addStatistic( Event& event );
133 
148  EQ_API virtual Vector2f getJitter() const;
149 
154  EQ_API const Frames& getInputFrames();
155 
160  EQ_API const Frames& getOutputFrames();
161 
175  EQ_API View* getView();
176 
178  EQ_API const View* getView() const;
179 
189  EQ_API Frustumf getScreenFrustum() const;
191 
205  EQ_API virtual void applyBuffer();
206 
212  EQ_API virtual void applyColorMask() const;
213 
219  EQ_API virtual void applyViewport() const;
220 
233  EQ_API virtual void applyFrustum() const;
234 
239  EQ_API virtual void applyPerspective() const;
240 
245  EQ_API virtual void applyOrtho() const;
246 
254  EQ_API void applyScreenFrustum() const;
255 
261  EQ_API virtual void applyHeadTransform() const;
262 
267  EQ_API virtual void applyPerspectiveTransform() const;
268 
273  EQ_API virtual void applyOrthoTransform() const;
274 
279  EQ_API virtual void applyFrameBufferObject();
280 
285  EQ_API void bindFrameBuffer();
287 
297  EQ_API virtual void resetRegions();
298 
313  EQ_API virtual void declareRegion( const eq::PixelViewport& region );
314 
321  EQ_API void declareRegion( const eq::Viewport& vp );
322 
324  EQ_API PixelViewport getRegion() const;
325 
337  EQ_API const PixelViewports& getRegions() const;
338 
340 
352  EQ_API virtual bool processEvent( const Event& event );
353 
355  EQ_API virtual void drawStatistics();
356 
358  EQ_API virtual void outlineViewport();
359 
366  void changeLatency( const uint32_t latency );
367 
368  protected:
370  EQ_API void attach( const UUID& id, const uint32_t instanceID );
371 
380  EQ_API void startFrame( const uint32_t frameNumber );
381 
388  EQ_API void releaseFrame( const uint32_t frameNumber );
389 
396  EQ_API void releaseFrameLocal( const uint32_t frameNumber );
397 
408  EQ_API virtual void setupAssemblyState();
409 
411  EQ_API virtual void resetAssemblyState();
413 
429  EQ_API virtual bool configInit( const uint128_t& initID );
430 
432  EQ_API virtual bool configExit();
433 
445  EQ_API virtual void frameStart( const uint128_t& frameID,
446  const uint32_t frameNumber );
447 
458  EQ_API virtual void frameFinish( const uint128_t& frameID,
459  const uint32_t frameNumber );
460 
471  EQ_API virtual void frameDrawFinish( const uint128_t& frameID,
472  const uint32_t frameNumber );
473 
482  EQ_API virtual void frameClear( const uint128_t& frameID );
483 
492  EQ_API virtual void frameDraw( const uint128_t& frameID );
493 
503  EQ_API virtual void frameAssemble( const uint128_t& frameID );
504 
514  EQ_API virtual void frameReadback( const uint128_t& frameID );
515 
526  EQ_API virtual void frameViewStart( const uint128_t& frameID );
527 
541  EQ_API virtual void frameViewFinish( const uint128_t& frameID );
543 
545  virtual void frameTilesStart( const uint128_t& /*frameID*/ ) {}
546 
548  virtual void frameTilesFinish( const uint128_t& /*frameID*/ ) {}
549 
551  EQ_API virtual void notifyViewportChanged();
552 
565  EQ_API virtual void notifyStopFrame( const uint32_t lastFrameNumber );
566 
567  private:
568  detail::Channel* const _impl;
569  friend class fabric::Window< Pipe, Window, Channel >;
570 
571  //-------------------- Methods --------------------
573  void _setRenderContext( RenderContext& context );
574 
576  bool _configInitFBO();
577 
579  void _initDrawableConfig();
580 
582  void _frameTiles( RenderContext& context, const bool isLocal,
583  const UUID& queueID, const uint32_t tasks,
584  const co::ObjectVersions& frames );
585 
587  void _refFrame( const uint32_t frameNumber );
588 
590  void _unrefFrame( const uint32_t frameNumber );
591 
593  void _transmitImage( const co::ObjectVersion& frameDataVersion,
594  const uint128_t& nodeID,
595  const uint128_t& netNodeID,
596  const uint64_t imageIndex,
597  const uint32_t frameNumber,
598  const uint32_t taskID );
599 
600  void _frameReadback( const uint128_t& frameID,
601  const co::ObjectVersions& frames );
602  void _finishReadback( const co::ObjectVersion& frameDataVersion,
603  const uint64_t imageIndex,
604  const uint32_t frameNumber,
605  const uint32_t taskID,
606  const std::vector< uint128_t >& nodes,
607  const std::vector< uint128_t >& netNodes );
608 
609  bool _asyncFinishReadback( const std::vector< size_t >& imagePos );
610 
611  void _asyncTransmit( FrameDataPtr frame, const uint32_t frameNumber,
612  const uint64_t image,
613  const std::vector<uint128_t>& nodes,
614  const std::vector< uint128_t >& netNodes,
615  const uint32_t taskID );
616 
617  void _setReady( const bool async, detail::RBStat* stat );
618  void _asyncSetReady( const FrameDataPtr frame, detail::RBStat* stat,
619  const std::vector< uint128_t >& nodes,
620  const std::vector< uint128_t >& netNodes );
621 
622  void _setReady( FrameDataPtr frame, detail::RBStat* stat,
623  const std::vector< uint128_t >& nodes,
624  const std::vector< uint128_t >& netNodes );
625 
627  co::QueueSlave* _getQueue( const UUID& queueID );
628 
629  void _setOutputFrames( const co::ObjectVersions& frames );
630  void _resetOutputFrames();
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
A configuration is a visualization session driven by an application.
Event structure to report window system and other events.
Definition: event.h:171
virtual ~Channel()
Destruct the channel.
virtual void applyOrthoTransform() const
Apply the transformation to position the orthographic view frustum.
Node * getNode()
virtual void applyColorMask() const
Apply the current color mask.
A C++ class to abstract OpenGL frame buffer objects.
Base data transport class for windows.
A channel represents a two-dimensional viewport within a Window.
virtual void setupAssemblyState()
Setup the OpenGL state for a readback or assemble operation.
virtual void frameClear(const uint128_t &frameID)
Clear the frame buffer.
virtual void applyPerspective() const
Apply the perspective frustum matrix for the current rendering task.
virtual void applyViewport() const
Apply the OpenGL viewport for the current rendering task.
virtual void frameStart(const uint128_t &frameID, const uint32_t frameNumber)
Start rendering a frame.
Base data transport class for channels.
virtual void drawStatistics()
Draw a statistics overlay.
A View is a 2D area of a Layout.
virtual void notifyStopFrame(const uint32_t lastFrameNumber)
Notify interruption of the rendering.
const PixelViewports & getRegions() const
Get the current regions of interest.
virtual void frameTilesFinish(const uint128_t &)
Finish a batch of tile rendering operations.
virtual void frameAssemble(const uint128_t &frameID)
Assemble all input frames.
A Window represents an on-screen or off-screen drawable.
virtual bool processEvent(const Event &event)
Process a received event.
virtual Vector2f getJitter() const
const GLEWContext * glewGetContext() const
Get the GLEW context for this channel.
virtual void applyPerspectiveTransform() const
Apply the transformation to position the perspective view frustum.
std::vector< PixelViewport > PixelViewports
A vector of eq::PixelViewport.
Frustumf getScreenFrustum() const
Returns an orthographic frustum for 2D operations on the view.
const Frames & getInputFrames()
void applyScreenFrustum() const
Apply an orthographic frustum for pixel-based 2D operations.
virtual void outlineViewport()
Outline the current pixel viewport.
virtual void resetRegions()
Reset the declared regions of interest.
Channel(Window *parent)
Construct a new channel.
virtual void frameFinish(const uint128_t &frameID, const uint32_t frameNumber)
Finish rendering a frame.
const Frames & getOutputFrames()
A Node represents a single computer in the cluster.
virtual void applyBuffer()
Apply the current rendering buffer, including the color mask.
virtual void applyFrameBufferObject()
Apply the current alternate frame buffer.
virtual bool configExit()
Exit this channel.
A facility class to manage OpenGL objects across shared contexts.
A Pipe represents a graphics card (GPU) on a Node.
PixelViewport getRegion() const
View * getView()
Get the channel&#39;s current View.
lunchbox::RefPtr< Server > ServerPtr
A reference-counted pointer to an eq::Server.
Pipe * getPipe()
virtual void applyHeadTransform() const
Apply the transformation to position the view frustum.
util::FrameBufferObject * getFrameBufferObject()
const Vector3ub & getUniqueColor() const
View * getNativeView()
Get the channel&#39;s native view.
void releaseFrameLocal(const uint32_t frameNumber)
Release the local synchronization of the parent for a frame.
void startFrame(const uint32_t frameNumber)
Start a frame by unlocking all child resources.
ServerPtr getServer()
virtual void applyFrustum() const
Apply the frustum matrix for the current rendering task.
const DrawableConfig & getDrawableConfig() const
void bindFrameBuffer()
Rebind the current alternate FBO of the channel or window.
std::vector< Frame * > Frames
A vector of pointers to eq::Frame.
virtual bool configInit(const uint128_t &initID)
Initialize this channel.
virtual void declareRegion(const eq::PixelViewport &region)
Declare a region covered by the current draw or assemble operation.
virtual void frameDraw(const uint128_t &frameID)
Draw the scene.
virtual void frameViewFinish(const uint128_t &frameID)
Finish updating a destination channel.
ObjectManager * getObjectManager()
Config * getConfig()
lunchbox::RefPtr< FrameData > FrameDataPtr
A reference-counted pointer to an eq::FrameData.
virtual void frameViewStart(const uint128_t &frameID)
Start updating a destination channel.
void releaseFrame(const uint32_t frameNumber)
Signal the completion of a frame to the parent.
virtual void frameReadback(const uint128_t &frameID)
Read back the rendered frame buffer into the output frames.
virtual void notifyViewportChanged()
Notification that parameters influencing the vp/pvp have changed.
virtual void applyOrtho() const
Apply the orthographic frustum matrix for the current rendering task.
bool isStopped() const
virtual void frameTilesStart(const uint128_t &)
Start a batch of tile rendering operations.
virtual void frameDrawFinish(const uint128_t &frameID, const uint32_t frameNumber)
Finish drawing.
virtual void resetAssemblyState()
Reset the OpenGL state after an assembly operation.