VTK
vtkPSurfaceLICComposite.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: Visualization Toolkit
4  Module: vtkPSurfaceLICComposite.h
5 
6  Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
7  All rights reserved.
8  See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
9 
10  This software is distributed WITHOUT ANY WARRANTY; without even
11  the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
12  PURPOSE. See the above copyright notice for more information.
13 
14 =========================================================================*/
25 #ifndef vtkPSurfaceLICComposite_h
26 #define vtkPSurfaceLICComposite_h
27 
28 #include "vtkSurfaceLICComposite.h"
29 #include "vtkWeakPointer.h" // for ren context
30 #include "vtkOpenGLRenderWindow.h" // for context
31 #include "vtkRenderingParallelLICModule.h" // for export macro
32 #include "vtkPixelExtent.h" // for pixel extent
33 #include "vtkPPixelTransfer.h" // for pixel transfer
34 #include <deque> // for deque
35 #include <vector> // for vector
36 #include <list> // for list
37 
38 class vtkFloatArray;
39 class vtkRenderWindow;
40 class vtkTextureObject;
43 class vtkPPixelExtentOps;
44 
45 #ifdef VTK_OPENGL2
46 class vtkOpenGLHelper;
48 #else
49 class vtkShaderProgram2;
51 #endif
52 
53 class VTKRENDERINGPARALLELLIC_EXPORT vtkPSurfaceLICComposite : public vtkSurfaceLICComposite
54 {
55 public:
56  static vtkPSurfaceLICComposite *New();
58  virtual void PrintSelf(ostream &os, vtkIndent indent) VTK_OVERRIDE;
59 
65  virtual void SetContext(vtkOpenGLRenderWindow *rwin) VTK_OVERRIDE;
66  virtual vtkOpenGLRenderWindow *GetContext() VTK_OVERRIDE { return this->Context; }
67 
72  virtual void SetCommunicator(vtkPainterCommunicator *comm) VTK_OVERRIDE;
73 
78  virtual int BuildProgram(float *vectors) VTK_OVERRIDE;
79 
84  virtual int Gather(
85  void *pSendPBO,
86  int dataType,
87  int nComps,
88  vtkTextureObject *&newImage) VTK_OVERRIDE;
89 
94  virtual int Scatter(
95  void *pSendPBO,
96  int dataType,
97  int nComps,
98  vtkTextureObject *&newImage) VTK_OVERRIDE;
99 
100 protected:
103 
104 private:
108  int InitializeCompositeShader(vtkOpenGLRenderWindow *context);
109 
113  int ExecuteShader(const vtkPixelExtent &ext, vtkTextureObject *tex);
114 
120  double EstimateCommunicationCost(
121  const std::deque<std::deque<vtkPixelExtent> > &srcExts,
122  const std::deque<std::deque<vtkPixelExtent> > &destExts);
123 
129  double EstimateDecompEfficiency(
130  const std::deque< std::deque<vtkPixelExtent> > &exts,
131  const std::deque< std::deque<vtkPixelExtent> > &guardExts);
132 
137  int DecomposeScreenExtent(
138  std::deque< std::deque<vtkPixelExtent> >&newExts,
139  float *vectors);
140 
145  int DecomposeExtent(
146  vtkPixelExtent &in,
147  int nPieces,
148  std::list<vtkPixelExtent> &out);
149 
158  int MakeDecompDisjoint(
159  const std::deque< std::deque< vtkPixelExtent> > &in,
160  std::deque< std::deque< vtkPixelExtent> > &out,
161  float *vectors);
162 
163 
164  // decomp set of extents
165  int MakeDecompLocallyDisjoint(
166  const std::deque< std::deque< vtkPixelExtent> > &in,
167  std::deque< std::deque< vtkPixelExtent> > &out);
168 
170 
176  int AllGatherExtents(
177  const std::deque<vtkPixelExtent> &localExts,
178  std::deque<std::deque<vtkPixelExtent> > &remoteExts,
179  vtkPixelExtent &dataSetExt);
180 
184  int AllReduceVectorMax(
185  const std::deque<vtkPixelExtent> &originalExts,
186  const std::deque<std::deque<vtkPixelExtent> > &newExts,
187  float *vectors,
188  std::vector<std::vector<float> > &vectorMax);
189 
193  int AddGuardPixels(
194  const std::deque<std::deque<vtkPixelExtent> > &exts,
195  std::deque<std::deque<vtkPixelExtent> > &guardExts,
196  std::deque<std::deque<vtkPixelExtent> > &disjointGuardExts,
197  float *vectors);
198 
199 private:
200  vtkPPainterCommunicator *PainterComm; // mpi state
201  vtkPPixelExtentOps *PixelOps;
202  int CommRank;
203  int CommSize;
204 
205  vtkWeakPointer<vtkOpenGLRenderWindow> Context; // rendering context
206 
207 #ifdef VTK_OPENGL2
208  vtkOpenGLFramebufferObject *FBO; // Framebuffer object
209  vtkOpenGLHelper *CompositeShader;
210 #else
211  vtkFrameBufferObject2 *FBO; // buffer object
212  vtkShaderProgram2 *CompositeShader; // shader program for compositing
213 #endif
214 
215  std::deque<vtkPPixelTransfer> GatherProgram; // ordered steps required to move data to new decomp
216  std::deque<vtkPPixelTransfer> ScatterProgram; // ordered steps required to unmove data from new decomp
217 
218  friend VTKRENDERINGPARALLELLIC_EXPORT
219  ostream &operator<<(ostream &os, vtkPSurfaceLICComposite &ss);
220 
221  vtkPSurfaceLICComposite(const vtkPSurfaceLICComposite&) VTK_DELETE_FUNCTION;
222  void operator=(const vtkPSurfaceLICComposite&) VTK_DELETE_FUNCTION;
223 };
224 
225 VTKRENDERINGPARALLELLIC_EXPORT
226 ostream &operator<<(ostream &os, vtkPSurfaceLICComposite &ss);
227 
228 #endif
OpenGL rendering window.
static vtkSurfaceLICComposite * New()
VTKRENDERINGPARALLELLIC_EXPORT ostream & operator<<(ostream &os, vtkPSurfaceLICComposite &ss)
friend ostream & operator<<(ostream &os, vtkSurfaceLICComposite &ss)
dynamic, self-adjusting array of float
Definition: vtkFloatArray.h:35
virtual void SetCommunicator(vtkPainterCommunicator *)
Set the communicator for parallel communication.
virtual int Gather(void *, int, int, vtkTextureObject *&)
Move a single buffer from the geometry decomp to the LIC decomp.
GLSL Program.
a simple class to control print indentation
Definition: vtkIndent.h:33
virtual void SetContext(vtkOpenGLRenderWindow *)
Set the rendering context.
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
Internal class which encapsulates OpenGL FramebufferObject.
int AddGuardPixels(const std::deque< vtkPixelExtent > &exts, std::deque< vtkPixelExtent > &guardExts, std::deque< vtkPixelExtent > &disjointGuardExts, float *vectors)
Add guard pixels (Serial run)
static int MakeDecompDisjoint(std::deque< vtkPixelExtent > &in, std::deque< vtkPixelExtent > &out)
Make a decomposition disjoint with respect to itself.
abstracts an OpenGL texture object.
virtual vtkOpenGLRenderWindow * GetContext() override
create a window for renderers to draw into
Representation of a cartesian pixel plane and common operations on it.
This class decomposes the image space and shuffles image space data onto the new decomposition with t...
A communicator that can safely be used inside a painter.
virtual int Scatter(void *, int, int, vtkTextureObject *&)
Move a single buffer from the LIC decomp to the geometry decomp In parallel THIS IS A COLLECTIVE OPER...
virtual int BuildProgram(float *)
Build programs to move data to the new decomp In parallel THIS IS A COLLECTIVE OPERATION.
This class decomposes the image space and shuffles image space data onto the new decomposition with t...
Interface to OpenGL framebuffer object.