Equalizer  2.1.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/fabric/channel.h> // base class
25 #include <eq/types.h>
26 
27 namespace eq
28 {
29 namespace detail
30 {
31 class Channel;
32 struct RBStat;
33 }
34 
46 class Channel : public fabric::Channel<Window, Channel>
47 {
48 public:
50  EQ_API explicit Channel(Window* parent);
51 
53  EQ_API virtual ~Channel();
54 
57  EQ_API co::CommandQueue* getPipeThreadQueue();
58  EQ_API co::CommandQueue* getCommandThreadQueue();
59  EQ_API uint32_t getCurrentFrame() const;
60 
62  bool waitFrameFinished(uint32_t frame, uint32_t timeout) const;
63 
68  EQ_API bool isStopped() const;
69 
71  EQ_API Pipe* getPipe();
72 
74  EQ_API const Pipe* getPipe() const;
75 
77  EQ_API Node* getNode();
78 
80  EQ_API const Node* getNode() const;
81 
83  EQ_API Config* getConfig();
84 
86  EQ_API const Config* getConfig() const;
87 
89  EQ_API ServerPtr getServer();
90 
104  EQ_API const GLEWContext* glewGetContext() const;
105 
107  EQ_API util::ObjectManager& getObjectManager();
108 
110  EQ_API const DrawableConfig& getDrawableConfig() const;
111 
122  EQ_API View* getNativeView();
123 
125  EQ_API const View* getNativeView() const;
126 
128  EQ_API const Vector3ub& getUniqueColor() const;
129 
131  EQ_API void addStatistic(Statistic& event);
133 
148  EQ_API virtual Vector2f getJitter() const;
149 
162  EQ_API View* getView();
163 
165  EQ_API const View* getView() const;
166 
176  EQ_API Frustumf getScreenFrustum() const;
178 
192  EQ_API virtual void applyBuffer();
193 
199  EQ_API virtual void applyColorMask() const;
200 
206  EQ_API virtual void applyViewport() const;
207 
220  EQ_API virtual void applyFrustum() const;
221 
226  EQ_API virtual void applyPerspective() const;
227 
232  EQ_API virtual void applyOrtho() const;
233 
241  EQ_API void applyScreenFrustum() const;
242 
248  EQ_API virtual void applyHeadTransform() const;
249 
254  EQ_API virtual void applyPerspectiveTransform() const;
255 
260  EQ_API virtual void applyOrthoTransform() const;
261 
266  EQ_API void applyOverlayState();
267 
272  EQ_API void resetOverlayState();
273 
278  EQ_API void bindFrameBuffer();
279 
284  EQ_API void bindDrawFrameBuffer();
286 
296  EQ_API virtual void resetRegions();
297 
312  EQ_API virtual void declareRegion(const eq::PixelViewport& region);
313 
320  EQ_API void declareRegion(const eq::Viewport& vp);
321 
323  EQ_API PixelViewport getRegion() const;
324 
336  EQ_API const PixelViewports& getRegions() const;
338 
347  EQ_API EventOCommand sendError(const uint32_t error);
348 
360  EQ_API virtual bool processEvent(EventType type, SizeEvent& event);
361  EQ_API virtual bool processEvent(EventType type, PointerEvent& event);
362  EQ_API virtual bool processEvent(EventType type, KeyEvent& event);
363  EQ_API virtual bool processEvent(Statistic& event);
365 
367  EQ_API virtual void drawStatistics();
368 
370  EQ_API virtual void outlineViewport();
371 
378  void changeLatency(const uint32_t latency);
379 
390  EQ_API void addResultImageListener(ResultImageListener* listener);
391 
399  EQ_API void removeResultImageListener(ResultImageListener* listener);
400 
406  EQ_API virtual std::string getDumpImageFileName() const;
407 
408 protected:
410  EQ_API void attach(const uint128_t& id, const uint32_t instanceID);
411 
420  EQ_API void startFrame(const uint32_t frameNumber);
421 
428  EQ_API void releaseFrame(const uint32_t frameNumber);
429 
436  EQ_API void releaseFrameLocal(const uint32_t frameNumber);
437 
448  EQ_API virtual void setupAssemblyState();
449 
451  EQ_API virtual void resetAssemblyState();
453 
469  EQ_API virtual bool configInit(const uint128_t& initID);
470 
472  EQ_API virtual bool configExit();
473 
485  EQ_API virtual void frameStart(const uint128_t& frameID,
486  const uint32_t frameNumber);
487 
498  EQ_API virtual void frameFinish(const uint128_t& frameID,
499  const uint32_t frameNumber);
500 
511  EQ_API virtual void frameDrawFinish(const uint128_t& frameID,
512  const uint32_t frameNumber);
513 
522  EQ_API virtual void frameClear(const uint128_t& frameID);
523 
532  EQ_API virtual void frameDraw(const uint128_t& frameID);
533 
543  EQ_API virtual void frameAssemble(const uint128_t& frameID,
544  const Frames& frames);
545 
556  EQ_API virtual void frameReadback(const uint128_t& frameID,
557  const Frames& frames);
558 
570  EQ_API virtual void frameViewStart(const uint128_t& frameID);
571 
587  EQ_API virtual void frameViewFinish(const uint128_t& frameID);
588 
597  EQ_API virtual void frameDrawOverlay(const uint128_t& frameID);
599 
601  virtual void frameTilesStart(const uint128_t& /*frameID*/) {}
603  virtual void frameTilesFinish(const uint128_t& /*frameID*/) {}
605  EQ_API virtual void notifyViewportChanged();
606 
619  EQ_API virtual void notifyStopFrame(const uint32_t lastFrameNumber);
620 
621 private:
622  detail::Channel* const _impl;
623  friend class fabric::Window<Pipe, Window, Channel, WindowSettings>;
624 
625  //-------------------- Methods --------------------
627  void _overrideContext(RenderContext& context);
628 
630  void _initDrawableConfig();
631 
633  void _frameTiles(RenderContext& context, const bool isLocal,
634  const uint128_t& queueID, const uint32_t tasks,
635  const co::ObjectVersions& frames);
636 
638  void _refFrame(const uint32_t frameNumber);
639 
641  void _unrefFrame(const uint32_t frameNumber);
642 
644  void _transmitImage(const co::ObjectVersion& frameDataVersion,
645  const uint128_t& nodeID, const co::NodeID& netNodeID,
646  const uint64_t imageIndex, 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, const uint32_t frameNumber,
653  const uint32_t taskID,
654  const std::vector<uint128_t>& nodes,
655  const co::NodeIDs& netNodes);
656 
657  bool _asyncFinishReadback(const std::vector<size_t>& imagePos,
658  const Frames& frames);
659 
660  void _asyncTransmit(FrameDataPtr frame, const uint32_t frameNumber,
661  const uint64_t image,
662  const std::vector<uint128_t>& nodes,
663  const co::NodeIDs& netNodes, 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, const bool isOutput);
679 
680  void _createTransferWindow();
681  void _deleteTransferWindow();
682 
683  /* The command handler functions. */
684  bool _cmdConfigInit(co::ICommand& command);
685  bool _cmdConfigExit(co::ICommand& command);
686  bool _cmdFrameStart(co::ICommand& command);
687  bool _cmdFrameFinish(co::ICommand& command);
688  bool _cmdFrameClear(co::ICommand& command);
689  bool _cmdFrameDraw(co::ICommand& command);
690  bool _cmdFrameDrawFinish(co::ICommand& command);
691  bool _cmdFrameAssemble(co::ICommand& command);
692  bool _cmdFrameReadback(co::ICommand& command);
693  bool _cmdFinishReadback(co::ICommand& command);
694  bool _cmdFrameSetReady(co::ICommand& command);
695  bool _cmdFrameTransmitImage(co::ICommand& command);
696  bool _cmdFrameSetReadyNode(co::ICommand& command);
697  bool _cmdFrameViewStart(co::ICommand& command);
698  bool _cmdFrameViewFinish(co::ICommand& command);
699  bool _cmdStopFrame(co::ICommand& command);
700  bool _cmdFrameTiles(co::ICommand& command);
701  bool _cmdDeleteTransferWindow(co::ICommand& command);
702 
703  LB_TS_VAR(_pipeThread);
704 };
705 }
706 
707 #endif // EQ_CHANNEL_H
std::vector< PixelViewport > PixelViewports
A vector of eq::PixelViewport.
Definition: eq/types.h:175
lunchbox::RefPtr< Server > ServerPtr
A reference-counted pointer to an eq::Server.
Definition: eq/types.h:215
A channel represents a two-dimensional viewport within a Window.
Definition: channel.h:46
A configuration is a visualization session driven by an application.
Definition: config.h:58
virtual void frameTilesStart(const uint128_t &)
Start a batch of tile rendering operations.
Definition: channel.h:601
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:52
EQ_API Config * getConfig(const int argc, char **argv)
Convenience function to retrieve a configuration.
std::vector< Frame * > Frames
A vector of pointers to eq::Frame.
Definition: eq/types.h:161
A Window represents an on-screen or off-screen drawable.
Definition: window.h:62
The result image listener gets notified on new images produced by destination channels.
The Equalizer client library.
Definition: eq/agl/types.h:23
A View is a 2D area of a Layout.
Definition: view.h:46
lunchbox::RefPtr< FrameData > FrameDataPtr
A reference-counted pointer to an eq::FrameData.
Definition: eq/types.h:217
Base data transport class for windows.
virtual void frameTilesFinish(const uint128_t &)
Finish a batch of tile rendering operations.
Definition: channel.h:603
A facility class to manage OpenGL objects across shared contexts.
Definition: objectManager.h:56
Base data transport class for channels.