Equalizer  1.11.0
Parallel Rendering Framework
pipe.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_PIPE_H
21 #define EQ_PIPE_H
22 
23 #include <eq/api.h>
24 #include <eq/eye.h> // Eye enum
25 #include <eq/types.h>
26 #include <eq/visitorResult.h> // enum
27 
28 #include <eq/fabric/pipe.h> // base class
29 #include <co/objectVersion.h>
30 
31 namespace eq
32 {
33 namespace detail
34 {
35 class Pipe;
36 class RenderThread;
37 class ThreadAffinityVisitor;
38 }
39 
50 class Pipe : public fabric::Pipe< Node, Pipe, eq::Window, PipeVisitor >
51 {
52 public:
54  EQ_API explicit Pipe( Node* parent );
55 
57  EQ_API virtual ~Pipe();
58 
61  EQ_API co::CommandQueue* getPipeThreadQueue();
62  co::CommandQueue* getMainThreadQueue();
63  co::CommandQueue* getCommandThreadQueue();
64  co::CommandQueue* getTransferThreadQueue();
65 
67  EQ_API Config* getConfig();
69  EQ_API const Config* getConfig() const;
70 
72  EQ_API ClientPtr getClient();
73 
75  EQ_API ServerPtr getServer();
76 
81  bool isRunning() const;
82 
87  EQ_API bool isStopped() const;
88 
96  EQ_API uint32_t getCurrentFrame() const;
97  EQ_API uint32_t getFinishedFrame() const;
98 
109  EQ_API WindowSystem getWindowSystem() const;
111 
124  Frame* getFrame( const co::ObjectVersion& frameVersion,
125  const Eye eye, const bool output );
126 
128  co::QueueSlave* getQueue( const uint128_t& queueID );
129 
131  void flushFrames( util::ObjectManager& om );
132 
134  const View* getView( const co::ObjectVersion& viewVersion ) const;
135 
137  View* getView( const co::ObjectVersion& viewVersion );
139 
140  void waitExited() const;
141  void notifyMapped();
142 
150  EQ_API void waitFrameFinished( const uint32_t frameNumber );
151 
158  EQ_API EventOCommand sendError( const uint32_t error );
159 
167  EQ_API void waitFrameLocal( const uint32_t frameNumber ) const;
168 
180  EQ_API virtual bool processEvent( const Event& event );
181 
183  void startThread();
184 
186  void exitThread();
187 
188  void cancelThread();
189 
191  bool startTransferThread();
192 
194  QThread* getTransferQThread();
195 
197  bool hasTransferThread() const;
198 
211  EQ_API void setSystemPipe( SystemPipe* pipe );
212 
214  EQ_API SystemPipe* getSystemPipe();
215 
217  EQ_API const SystemPipe* getSystemPipe() const;
219 
226  EQ_API void setComputeContext( ComputeContext* ctx );
227 
229  EQ_API const ComputeContext* getComputeContext() const;
230 
234 
249  EQ_API virtual MessagePump* createMessagePump();
250 
254 
256  EQ_API virtual void setDirty( const uint64_t bits );
257 
258 protected:
266  EQ_API bool isWindowSystemAvailable( const std::string& name ) const;
268 
277  EQ_API void startFrame( const uint32_t frameNumber );
278 
285  EQ_API void releaseFrame( const uint32_t frameNumber );
286 
293  EQ_API void releaseFrameLocal( const uint32_t frameNumber );
295 
312  EQ_API virtual WindowSystem selectWindowSystem() const;
313 
320  EQ_API virtual bool configInit( const uint128_t& initID );
321 
328  EQ_API virtual bool configInitSystemPipe( const uint128_t& initID );
329 
334  EQ_API virtual bool configExit();
335 
352  EQ_API virtual void frameStart( const uint128_t& frameID,
353  const uint32_t frameNumber );
354 
369  EQ_API virtual void frameFinish( const uint128_t& frameID,
370  const uint32_t frameNumber );
371 
382  EQ_API virtual void frameDrawFinish( const uint128_t& frameID,
383  const uint32_t frameNumber );
384 
386  EQ_API virtual void attach( const uint128_t& id, const uint32_t instanceID );
387 
388 private:
389  detail::Pipe* const _impl;
390  friend class detail::RenderThread;
391 
392  //-------------------- Methods --------------------
393  void _setupCommandQueue();
394  void _setupAffinity();
395  void _exitCommandQueue();
396 
398  EQ_API int32_t _getAutoAffinity() const;
399  friend class detail::ThreadAffinityVisitor;
400 
401  //friend class Window;
402 
403  void _stopTransferThread();
404 
406  void _releaseViews();
407 
409  void _flushViews();
410 
412  void _flushQueues();
413 
414  /* The command functions. */
415  bool _cmdCreateWindow( co::ICommand& command );
416  bool _cmdDestroyWindow( co::ICommand& command );
417  bool _cmdConfigInit( co::ICommand& command );
418  bool _cmdConfigExit( co::ICommand& command );
419  bool _cmdFrameStartClock( co::ICommand& command );
420  bool _cmdFrameStart( co::ICommand& command );
421  bool _cmdFrameFinish( co::ICommand& command );
422  bool _cmdFrameDrawFinish( co::ICommand& command );
423  bool _cmdExitThread( co::ICommand& command );
424  bool _cmdDetachView( co::ICommand& command );
425  bool _cmdExitTransferThread( co::ICommand& command );
426 
427  LB_TS_VAR( _pipeThread );
428 };
429 }
430 
431 #endif // EQ_PIPE_H
virtual EQ_API WindowSystem selectWindowSystem() const
Choose the window system to be used by this pipe.
MessagePump * getMessagePump()
EQ_API ServerPtr getServer()
EQ_API void releaseFrameLocal(const uint32_t frameNumber)
Release the local synchronization of the parent for a frame.
A configuration is a visualization session driven by an application.
Definition: config.h:55
EQ_API uint32_t getCurrentFrame() const
Return the current frame number.
virtual EQ_API bool processEvent(const Event &event)
Process a received event.
EQ_API EventOCommand sendError(const uint32_t error)
Send a pipe error event to the application node.
virtual EQ_API bool configInit(const uint128_t &initID)
Initialize this pipe.
EQ_API bool isStopped() const
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:48
virtual EQ_API bool configInitSystemPipe(const uint128_t &initID)
Initialize the OS-specific pipe.
virtual EQ_API bool configExit()
De-initialize this pipe.
lunchbox::RefPtr< Server > ServerPtr
A reference-counted pointer to an eq::Server.
Definition: eq/types.h:213
EQ_API void setComputeContext(ComputeContext *ctx)
Set the compute-specific context.
EQ_API Config * getConfig()
Base data transport class for pipes.
Definition: fabric/pipe.h:31
EQ_API void releaseFrame(const uint32_t frameNumber)
Signal the completion of a frame to the parent.
An interface to process system messages or events.
Definition: messagePump.h:27
The interface definition for system-specific GPU handling.
Definition: systemPipe.h:38
EQ_API void setSystemPipe(SystemPipe *pipe)
Set the system-specific pipe implementation.
EQ_API const ComputeContext * getComputeContext() const
virtual EQ_API void frameDrawFinish(const uint128_t &frameID, const uint32_t frameNumber)
Finish drawing.
EQ_API ClientPtr getClient()
lunchbox::RefPtr< Client > ClientPtr
A reference-counted pointer to an eq::Client.
Definition: eq/types.h:209
virtual EQ_API MessagePump * createMessagePump()
Create a new MessagePump for this pipe.
The Equalizer client library.
Definition: eq/agl/types.h:23
A View is a 2D area of a Layout.
Definition: view.h:42
virtual EQ_API void frameFinish(const uint128_t &frameID, const uint32_t frameNumber)
Finish rendering a frame.
A facility class to manage OpenGL objects across shared contexts.
Definition: objectManager.h:52
bool isRunning() const
virtual EQ_API void frameStart(const uint128_t &frameID, const uint32_t frameNumber)
Start rendering a frame.
The interface definition for API-specific GPGPU handling.
EQ_API WindowSystem getWindowSystem() const
Return the window system used by this pipe.
virtual EQ_API ~Pipe()
Destruct the pipe.
EQ_API void startFrame(const uint32_t frameNumber)
Start a frame by unlocking all child resources.
A holder for a frame data and related parameters.
Definition: frame.h:43
EQ_API SystemPipe * getSystemPipe()
EQ_API bool isWindowSystemAvailable(const std::string &name) const
EQ_API Pipe(Node *parent)
Construct a new pipe.