VTK  9.7.1
vtkWebGPUPointCloudMapperInternals.h
Go to the documentation of this file.
1 // SPDX-FileCopyrightText: Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
2 // SPDX-License-Identifier: BSD-3-Clause
3 
4 #ifndef vtkWebGPUPointCloudMapperInternals_h
5 #define vtkWebGPUPointCloudMapperInternals_h
6 
7 #include "vtkObject.h"
8 #include "vtkRenderingWebGPUModule.h"
9 #include "vtkSmartPointer.h"
11 #include "vtk_wgpu.h"
12 
13 class vtkPolyData;
14 class vtkRenderer;
20 
21 VTK_ABI_NAMESPACE_BEGIN
22 
26 class VTKRENDERINGWEBGPU_NO_EXPORT vtkWebGPUPointCloudMapperInternals : public vtkObject
27 {
28 public:
31 
32  void PrintSelf(ostream& os, vtkIndent indent) override;
33 
34  void SetMapper(vtkWebGPUComputePointCloudMapper* mapper);
35 
43  {
44  wgpu::BindGroup BindGroup = nullptr;
45  wgpu::RenderPipeline Pipeline = nullptr;
46  wgpu::Buffer FramebufferWidthUniformBuffer = nullptr;
47  };
48 
49 protected:
52 
53 private:
55  void operator=(const vtkWebGPUPointCloudMapperInternals&) = delete;
56 
58 
62  vtkWebGPURenderWindow* GetRendererRenderWindow(vtkRenderer* renderer);
63 
67  void Initialize(vtkRenderer* renderer);
68 
78  void UpdateRenderWindowDepthBuffer(vtkRenderer* renderer);
79 
84  void CreateCopyDepthBufferRenderPipeline(vtkWebGPURenderWindow* wgpuRenderWindow);
85 
90  void CopyDepthBufferToRenderWindow(vtkWebGPURenderWindow* wgpuRenderWindow);
91 
99  void Update(vtkRenderer* renderer);
100 
104  void UseRenderWindowDevice(vtkRenderer* renderer);
105 
109  void ResizeToRenderWindow(vtkRenderer* renderer);
110 
114  void InitializeDepthCopyPass(vtkRenderer* renderer);
115 
119  void InitializePointRenderPass(vtkRenderer* renderer);
120 
127  void UploadPointsToGPU();
128 
136  void UploadColorsToGPU();
137 
142  void UploadCameraVPMatrix(vtkRenderer* renderer);
143 
144  // Whether or not the compute pipeline has been initialized
145  bool Initialized = false;
146 
147  // Compute pipeline for the point cloud rendering
149 
150  // Compute pass that copies the depth buffer of the render window into the custom depth
151  // buffer for rendering the points
153  // Compute pass that renders the points to the framebuffer of the render window of the
154  // WebGPURenderer
155  vtkSmartPointer<vtkWebGPUComputePass> RenderPointsPass;
156 
157  // Custom depth buffer for the render of the points
159  // Index of the buffer that contains the point data in the render point pass
160  int PointBufferIndex = -1;
161  // Index of the buffer that holds the colors of the points in float format in the point render
162  // pass
163  int PointColorBufferIndex = -1;
164 
165  // Custom depth buffer that contains the depth of the points after they've been rendered
166  int PointDepthBufferIndex = -1;
167  // Index of the view-projection matrix buffer in the render point pass
168  int CameraVPBufferIndex = -1;
169  // Index of the framebuffer in the render point pass
170  int FrameBufferRenderTextureIndex = -1;
171 
172  // The renderer culling pass always calls GetBounds() on the mappers. We use this opportunity to
173  // cache the polyData input so that we can reuse it later without having to call on the expensive
174  // GetInput() function
175  vtkPolyData* CachedInput = nullptr;
176  // MTime of the last points we uploaded to the GPU
177  vtkMTimeType LastPointsMTime = 0;
178  // MTime of the last point data (for point colors) we uploaded to the GPU
179  vtkMTimeType LastPointDataMTime = 0;
180 
181  // Contains the wgpu objects for refereing to the render pipeline that copies the point depth
182  // buffer to the depth buffer of the render window
183  CopyDepthBufferRenderPipeline CopyDepthBufferPipeline;
184 
185  // vtkWebGPUComputePointCloudMapper whose internals this instance is
186  vtkWebGPUComputePointCloudMapper* ParentMapper = nullptr;
187 };
188 VTK_ABI_NAMESPACE_END
189 
190 #endif
191 // VTK-HeaderTest-Exclude: vtkWebGPUBindGroupInternals.h
abstract base class for most VTK objects
Definition: vtkObject.h:52
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
vtkTypeUInt32 vtkMTimeType
Definition: vtkType.h:318
The point cloud renderer uses WebGPU compute shaders to render the point cells of a polydata onto the...
abstract specification for renderers
Definition: vtkRenderer.h:63
Represents the set of parameters that will be used to create a compute shader buffer on the device wh...
concrete dataset represents vertices, lines, polygons, and triangle strips
Definition: vtkPolyData.h:71
Internal implementation details of vtkWebGPUPointCloudMapper.
bool Update() override
Bring this algorithm's outputs up-to-date.
a simple class to control print indentation
Definition: vtkIndent.h:28
A compute pipeline is the orchestrator of a collection of compute passes.
WebGPU rendering window.
Structure that contains the wgpu objects necessary for the use of the render pipeline that copies the...
static vtkObject * New()
Create an object with Debug turned off, modified time initialized to zero, and reference counting on...
A compute pass is an abstraction for offloading computation from the CPU onto the GPU using WebGPU co...