VTK  9.7.1
vtkWebGPUComputePipeline.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 vtkWebGPUComputePipeline_h
5 #define vtkWebGPUComputePipeline_h
6 
7 #include "vtkObject.h"
8 #include "vtkWebGPUComputePass.h" // for the list of compute passes held by this pipeline
9 #include "vtkWebGPUConfiguration.h" // for requesting device / adapter
10 #include "vtk_wgpu.h" // for webgpu
11 
12 #include <unordered_map> // for the registered buffers / textures
13 
14 VTK_ABI_NAMESPACE_BEGIN
15 
17 class vtkWebGPURenderer;
18 
32 class VTKRENDERINGWEBGPU_EXPORT vtkWebGPUComputePipeline : public vtkObject
33 {
34 public:
36  static vtkWebGPUComputePipeline* New();
37 
38  void PrintSelf(ostream& os, vtkIndent indent) override;
39 
41 
46  vtkGetMacro(Label, std::string&);
47  vtkSetMacro(Label, std::string);
49 
50  void SetWGPUConfiguration(vtkWebGPUConfiguration* config);
51  vtkGetSmartPointerMacro(WGPUConfiguration, vtkWebGPUConfiguration);
52 
56  vtkSmartPointer<vtkWebGPUComputePass> CreateComputePass();
57 
61  const std::vector<vtkSmartPointer<vtkWebGPUComputePass>>& GetComputePasses() const;
62 
66  void DispatchAllPasses();
67 
75  void Update();
76 
83  void ReleaseResources();
84 
85 protected:
87  ~vtkWebGPUComputePipeline() override;
88 
89 private:
92  friend class vtkWebGPURenderWindow;
93  friend class vtkWebGPURenderer;
94 
96  void operator=(const vtkWebGPUComputePipeline&) = delete;
97 
102  void RegisterBuffer(vtkSmartPointer<vtkWebGPUComputeBuffer> buffer, wgpu::Buffer wgpuBuffer);
103 
108  void RegisterTexture(vtkSmartPointer<vtkWebGPUComputeTexture> texture, wgpu::Texture wgpuTexture);
109 
111 
118  bool GetRegisteredBuffer(
119  vtkSmartPointer<vtkWebGPUComputeBuffer> buffer, wgpu::Buffer& wgpuBuffer);
120 
121  bool GetRegisteredTexture(
122  vtkSmartPointer<vtkWebGPUComputeTexture> texture, wgpu::Texture& wgpuTexture);
124 
129  void EnsureConfigured();
130 
135  vtkSmartPointer<vtkWebGPUConfiguration> WGPUConfiguration = nullptr;
136 
140  std::vector<vtkSmartPointer<vtkWebGPUComputePass>> ComputePasses;
141 
153  std::unordered_map<vtkSmartPointer<vtkWebGPUComputeBuffer>, wgpu::Buffer> RegisteredBuffers;
154  std::unordered_map<vtkSmartPointer<vtkWebGPUComputeTexture>, wgpu::Texture> RegisteredTextures;
155 
156  // Label used for debugging
157  std::string Label = "WebGPU Compute Pipeline";
158 };
159 
160 VTK_ABI_NAMESPACE_END
161 
162 #endif
Internals of the vtkWebGPUComputePass.
Converts VTK cell connectivity arrays into webgpu primitives using compute shaders.
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.
a simple class to control print indentation
Definition: vtkIndent.h:28
Create a webgpu device for use in rendering and compute pipelines.
A compute pipeline is the orchestrator of a collection of compute passes.
WebGPU rendering window.
static vtkObject * New()
Create an object with Debug turned off, modified time initialized to zero, and reference counting on...