Equalizer  2.1.0
Parallel Rendering Framework
fabric/channel.h
1 
2 /* Copyright (c) 2010-2016, Stefan Eilemann <eile@equalizergraphics.com>
3  * Cedric Stalder <cedric.stalder@gmail.com>
4  * Julio Delgado Mangas <julio.delgadomangas@epfl.ch>
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 EQFABRIC_CHANNEL_H
21 #define EQFABRIC_CHANNEL_H
22 
23 #include <eq/fabric/object.h> // base class
24 #include <eq/fabric/paths.h>
25 #include <eq/fabric/renderContext.h> // member
26 #include <eq/fabric/types.h>
27 
28 namespace eq
29 {
30 namespace fabric
31 {
33 template <class W, class C>
34 class Channel : public Object
35 {
36 public:
38  typedef W Parent;
39 
43  void init();
44 
46  W* getWindow() { return _window; }
48  const W* getWindow() const { return _window; }
50  bool isDestination() const
51  {
52  return _data.nativeContext.view.identifier != 0;
53  }
54 
56  void setViewVersion(const co::ObjectVersion& view);
57 
59  const co::ObjectVersion& getViewVersion() const
60  {
61  return _data.nativeContext.view;
62  }
63 
65  void setPixelViewport(const PixelViewport& pvp);
66 
68  EQFABRIC_INL void setViewport(const Viewport& vp);
69 
71  virtual void notifyViewportChanged();
72 
75  {
76  return _data.nativeContext.pvp;
77  }
78 
80  bool hasFixedViewport() const { return _data.fixedVP; }
92  EQFABRIC_INL void setNearFar(const float nearPlane, const float farPlane);
93 
101  EQFABRIC_INL VisitorResult accept(Visitor& visitor);
102 
104  EQFABRIC_INL VisitorResult accept(Visitor& visitor) const;
105 
114  EQFABRIC_INL void setCapabilities(const uint64_t bitmask);
115 
117  EQFABRIC_INL uint64_t getCapabilities() const;
118 
119  void setOverdraw(const Vector4i& overdraw);
120 
122  EQFABRIC_INL ChannelPath getPath() const;
123 
124  EQFABRIC_INL virtual void backup();
125  EQFABRIC_INL virtual void restore();
126 
127 
139  uint32_t getDrawBuffer() const { return _context->buffer; }
141  uint32_t getReadBuffer() const { return _context->buffer; }
143  const ColorMask& getDrawBufferMask() const { return _context->bufferMask; }
148  const PixelViewport& getPixelViewport() const { return _context->pvp; }
157  virtual bool useOrtho() const { return false; }
162  const Frustumf& getFrustum() const
163  {
164  return useOrtho() ? getOrtho() : getPerspective();
165  }
166 
171  const Frustumf& getPerspective() const { return _context->frustum; }
176  const Frustumf& getOrtho() const { return _context->ortho; }
186  const Matrix4f& getHeadTransform() const
187  {
189  }
190 
200  const Matrix4f& getPerspectiveTransform() const
201  {
202  return _context->headTransform;
203  }
204 
214  const Matrix4f& getOrthoTransform() const
215  {
216  return _context->orthoTransform;
217  }
218 
223  const Viewport& getViewport() const { return _context->vp; }
228  const Range& getRange() const { return _context->range; }
233  const Pixel& getPixel() const { return _context->pixel; }
238  const SubPixel& getSubPixel() const { return _context->subPixel; }
243  const Zoom& getZoom() const { return _context->zoom; }
248  uint32_t getPeriod() const { return _context->period; }
253  uint32_t getPhase() const { return _context->phase; }
264  const Vector2i& getPixelOffset() const { return _context->offset; }
266  Eye getEye() const { return _context->eye; }
268  const Vector4i& getOverdraw() const { return _context->overdraw; }
270  uint32_t getTaskID() const { return _context->taskID; }
272  const RenderContext& getContext() const { return *_context; }
274 
277  // Note: also update string array initialization in channel.cpp
280  {
285  IATTR_LAST,
286  IATTR_ALL = IATTR_LAST + 5
287  };
288 
291  {
292  SATTR_DUMP_IMAGE,
293  SATTR_LAST,
294  SATTR_ALL = SATTR_LAST + 5
295  };
296 
298  EQFABRIC_INL int32_t getIAttribute(const IAttribute attr) const;
299 
301  EQFABRIC_INL
302  const std::string& getSAttribute(const SAttribute attr) const;
303 
305  EQFABRIC_INL static const std::string& getIAttributeString(
306  const IAttribute attr);
307 
309  EQFABRIC_INL static const std::string& getSAttributeString(
310  const SAttribute attr);
312 
313  virtual bool omitOutput() const { return false; }
314  virtual void output(std::ostream&) const {}
315 protected:
317  EQFABRIC_INL explicit Channel(W* parent);
318 
320  Channel(const Channel& from);
321 
323  EQFABRIC_INL virtual ~Channel();
324 
326  EQFABRIC_INL virtual void serialize(co::DataOStream& os,
327  const uint64_t dirtyBits);
329  EQFABRIC_INL virtual void deserialize(co::DataIStream& is,
330  const uint64_t dirtyBits);
331 
333  EQFABRIC_INL virtual void setDirty(const uint64_t bits);
334 
338  void overrideContext(const RenderContext& context)
339  {
340  _overrideContext = context;
341  _context = &_overrideContext;
342  }
343 
345  void resetContext() { _context = &_data.nativeContext; }
347  const RenderContext& getNativeContext() const
348  {
349  return _data.nativeContext;
350  }
352 
354  void setIAttribute(const IAttribute attr, const int32_t value)
355  {
356  _iAttributes[attr] = value;
357  setDirty(DIRTY_ATTRIBUTES);
358  }
359 
361  void setSAttribute(const SAttribute attr, const std::string& value)
362  {
363  _sAttributes[attr] = value;
364  setDirty(DIRTY_ATTRIBUTES);
365  }
366 
368  virtual ChangeType getChangeType() const { return UNBUFFERED; }
369  enum DirtyBits
370  {
371  DIRTY_ATTRIBUTES = Object::DIRTY_CUSTOM << 0,
372  DIRTY_VIEWPORT = Object::DIRTY_CUSTOM << 1,
373  DIRTY_PIXELVIEWPORT = Object::DIRTY_CUSTOM << 2,
374  DIRTY_MEMBER = Object::DIRTY_CUSTOM << 3,
375  DIRTY_FRUSTUM = Object::DIRTY_CUSTOM << 4,
376  DIRTY_CAPABILITIES = Object::DIRTY_CUSTOM << 5,
377  DIRTY_CHANNEL_BITS = DIRTY_ATTRIBUTES | DIRTY_VIEWPORT |
378  DIRTY_PIXELVIEWPORT | DIRTY_MEMBER |
379  DIRTY_FRUSTUM | DIRTY_OBJECT_BITS
380  };
381 
383  virtual uint64_t getRedistributableBits() const
384  {
385  return DIRTY_CHANNEL_BITS;
386  }
387 
388  virtual void updateCapabilities() {}
389 private:
391  W* const _window;
392 
393  struct BackupData
394  {
395  BackupData()
396  : capabilities(LB_BIT_ALL_64)
397  , fixedVP(true)
398  {
399  }
400 
402  RenderContext nativeContext;
403 
405  uint64_t capabilities;
406 
408  bool fixedVP;
409  } _data, _backup;
410 
412  RenderContext _overrideContext;
413 
415  RenderContext* _context;
416 
418  int32_t _iAttributes[IATTR_ALL];
419 
421  std::string _sAttributes[SATTR_ALL];
422 };
423 
424 template <class W, class C>
425 EQFABRIC_INL std::ostream& operator<<(std::ostream&, const Channel<W, C>&);
426 }
427 }
428 
429 #endif // EQFABRIC_CHANNEL_H
uint32_t buffer
buffer as passed to glDrawBuffer()
Definition: renderContext.h:61
const PixelViewport & getPixelViewport() const
A zoom specification with methods for manipulation.
Definition: zoom.h:35
EQFABRIC_INL uint64_t getCapabilities() const
Zoom zoom
up/downsampling wrt to dest
Definition: renderContext.h:59
const Frustumf & getPerspective() const
uint32_t getPhase() const
static EQFABRIC_INL const std::string & getSAttributeString(const SAttribute attr)
A fractional viewport with methods for manipulation.
Definition: viewport.h:34
Holds a subpixel decomposition specification along with some methods for manipulation.
Definition: subPixel.h:42
Defines which parts of the color buffer are to be written.
Definition: colorMask.h:34
const PixelViewport & getNativePixelViewport() const
Range range
database-range wrt to dest channel
Definition: renderContext.h:57
LeafVisitor< C > Visitor
The channel visitor type.
uint32_t getReadBuffer() const
bool hasFixedViewport() const
Viewport vp
fractional viewport wrt dest view
Definition: renderContext.h:54
static EQFABRIC_INL const std::string & getIAttributeString(const IAttribute attr)
IAttribute
Integer attributes for a channel.
A visitor to traverse leaf nodes of a graph.
Definition: leafVisitor.h:29
const ColorMask & getDrawBufferMask() const
Pixel pixel
pixel decomposition wrt to dest
Definition: renderContext.h:52
EQFABRIC_INL const std::string & getSAttribute(const SAttribute attr) const
W Parent
The parent window type.
uint32_t period
DPlex period.
Definition: renderContext.h:63
uint32_t getTaskID() const
EQFABRIC_INL void setNearFar(const float nearPlane, const float farPlane)
Set the near and far planes for this channel.
const SubPixel & getSubPixel() const
const Vector2i & getPixelOffset() const
Get the channel&#39;s current position wrt the destination channel.
DirtyBits
The changed parts of the object since the last pack().
Definition: object.h:107
Eye
Eye pass bit mask for which rendering is enabled.
Definition: fabric/eye.h:31
ColorMask bufferMask
color mask for anaglyph stereo
Definition: renderContext.h:68
uint32_t phase
DPlex phase.
Definition: renderContext.h:64
const RenderContext & getContext() const
virtual bool useOrtho() const
Select perspective or orthographic rendering.
Use a send token for output frames (OFF, ON)
EQFABRIC_INL int32_t getIAttribute(const IAttribute attr) const
uint32_t getPeriod() const
Matrix4f orthoTransform
orthographic frustum transform
Definition: renderContext.h:47
SubPixel subPixel
subpixel decomposition wrt to dest
Definition: renderContext.h:58
const Viewport & getViewport() const
Holds a pixel decomposition specification with methods for manipulation.
Definition: pixel.h:40
const W * getWindow() const
The Equalizer client library.
Definition: eq/agl/types.h:23
const Vector4i & getOverdraw() const
Matrix4f headTransform
frustum transform for modelview
Definition: renderContext.h:46
const Matrix4f & getOrthoTransform() const
Return the orthographic view matrix.
EQFABRIC_INL Channel(W *parent)
Construct a new channel.
const Zoom & getZoom() const
Eye eye
current eye pass
Definition: renderContext.h:65
Vector2i offset
absolute position wrt dest channel
Definition: renderContext.h:56
Frustumf ortho
ortho frustum for projection matrix
Definition: renderContext.h:44
const Range & getRange() const
const Matrix4f & getHeadTransform() const
Return the view matrix.
const Frustumf & getFrustum() const
Base data transport class for channels.
uint32_t getDrawBuffer() const
PixelViewport pvp
pixel viewport of channel wrt window
Definition: renderContext.h:51
const Pixel & getPixel() const
Statistics gathering mode (OFF, FASTEST [ON], NICEST)
virtual EQFABRIC_INL ~Channel()
Destruct the channel.
Internal base class for all distributed, inheritable Equalizer objects.
Definition: object.h:44
EQFABRIC_INL void setCapabilities(const uint64_t bitmask)
Set the capabilities supported by the channel.
The context applied to a channel during rendering operations.
Definition: renderContext.h:37
Holds a 2D pixel viewport with methods for manipulation.
Definition: pixelViewport.h:34
A fractional database range with methods for manipulation.
Definition: range.h:31
const Frustumf & getOrtho() const
const Matrix4f & getPerspectiveTransform() const
Return the perspective view matrix.
Frustumf frustum
frustum for projection matrix
Definition: renderContext.h:43
EQFABRIC_INL VisitorResult accept(Visitor &visitor)
Perform a depth-first traversal of this channel.