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;
41 class vtkTextureObject;
44 class vtkPPixelExtentOps;
45 
46 #ifdef VTK_OPENGL2
47 class vtkOpenGLHelper;
48 #else
49 class vtkShaderProgram2;
50 #endif
51 
52 class VTKRENDERINGPARALLELLIC_EXPORT vtkPSurfaceLICComposite : public vtkSurfaceLICComposite
53 {
54 public:
55  static vtkPSurfaceLICComposite *New();
57  virtual void PrintSelf(ostream &os, vtkIndent indent);
58 
64  virtual void SetContext(vtkOpenGLRenderWindow *rwin);
65  virtual vtkOpenGLRenderWindow *GetContext(){ return this->Context; }
66 
71  virtual void SetCommunicator(vtkPainterCommunicator *comm);
72 
77  virtual int BuildProgram(float *vectors);
78 
83  virtual int Gather(
84  void *pSendPBO,
85  int dataType,
86  int nComps,
87  vtkTextureObject *&newImage);
88 
93  virtual int Scatter(
94  void *pSendPBO,
95  int dataType,
96  int nComps,
97  vtkTextureObject *&newImage);
98 
99 protected:
102 
103 private:
107  int InitializeCompositeShader(vtkOpenGLRenderWindow *context);
108 
112  int ExecuteShader(const vtkPixelExtent &ext, vtkTextureObject *tex);
113 
119  double EstimateCommunicationCost(
120  const std::deque<std::deque<vtkPixelExtent> > &srcExts,
121  const std::deque<std::deque<vtkPixelExtent> > &destExts);
122 
128  double EstimateDecompEfficiency(
129  const std::deque< std::deque<vtkPixelExtent> > &exts,
130  const std::deque< std::deque<vtkPixelExtent> > &guardExts);
131 
136  int DecomposeScreenExtent(
137  std::deque< std::deque<vtkPixelExtent> >&newExts,
138  float *vectors);
139 
144  int DecomposeExtent(
145  vtkPixelExtent &in,
146  int nPieces,
147  std::list<vtkPixelExtent> &out);
148 
157  int MakeDecompDisjoint(
158  const std::deque< std::deque< vtkPixelExtent> > &in,
159  std::deque< std::deque< vtkPixelExtent> > &out,
160  float *vectors);
161 
162 
163  // decomp set of extents
164  int MakeDecompLocallyDisjoint(
165  const std::deque< std::deque< vtkPixelExtent> > &in,
166  std::deque< std::deque< vtkPixelExtent> > &out);
167 
169 
175  int AllGatherExtents(
176  const std::deque<vtkPixelExtent> &localExts,
177  std::deque<std::deque<vtkPixelExtent> > &remoteExts,
178  vtkPixelExtent &dataSetExt);
179 
183  int AllReduceVectorMax(
184  const std::deque<vtkPixelExtent> &originalExts,
185  const std::deque<std::deque<vtkPixelExtent> > &newExts,
186  float *vectors,
187  std::vector<std::vector<float> > &vectorMax);
188 
192  int AddGuardPixels(
193  const std::deque<std::deque<vtkPixelExtent> > &exts,
194  std::deque<std::deque<vtkPixelExtent> > &guardExts,
195  std::deque<std::deque<vtkPixelExtent> > &disjointGuardExts,
196  float *vectors);
197 
198 private:
199  vtkPPainterCommunicator *PainterComm; // mpi state
200  vtkPPixelExtentOps *PixelOps;
201  int CommRank;
202  int CommSize;
203 
204  vtkWeakPointer<vtkOpenGLRenderWindow> Context; // rendering context
205  vtkFrameBufferObject2 *FBO; // buffer object
206 
207 #ifdef VTK_OPENGL2
208  vtkOpenGLHelper *CompositeShader;
209 #else
210  vtkShaderProgram2 *CompositeShader; // shader program for compositing
211 #endif
212 
213  std::deque<vtkPPixelTransfer> GatherProgram; // ordered steps required to move data to new decomp
214  std::deque<vtkPPixelTransfer> ScatterProgram; // ordered steps required to unmove data from new decomp
215 
216  friend VTKRENDERINGPARALLELLIC_EXPORT
217  ostream &operator<<(ostream &os, vtkPSurfaceLICComposite &ss);
218 
219  vtkPSurfaceLICComposite(const vtkPSurfaceLICComposite&) VTK_DELETE_FUNCTION;
220  void operator=(const vtkPSurfaceLICComposite&) VTK_DELETE_FUNCTION;
221 };
222 
223 VTKRENDERINGPARALLELLIC_EXPORT
224 ostream &operator<<(ostream &os, vtkPSurfaceLICComposite &ss);
225 
226 #endif
OpenGL rendering window.
static vtkSurfaceLICComposite * New()
friend ostream & operator<<(ostream &os, vtkSurfaceLICComposite &ss)
dynamic, self-adjusting array of float
Definition: vtkFloatArray.h:41
virtual vtkOpenGLRenderWindow * GetContext()
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.
virtual void PrintSelf(ostream &os, vtkIndent indent)
Methods invoked by print to print information about the object including superclasses.
GLSL Program.
a simple class to control print indentation
Definition: vtkIndent.h:39
virtual void SetContext(vtkOpenGLRenderWindow *)
Set the rendering context.
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.
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.