VTK  9.3.20240919
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
14VTK_ABI_NAMESPACE_BEGIN
15
18
32class VTKRENDERINGWEBGPU_EXPORT vtkWebGPUComputePipeline : public vtkObject
33{
34public:
37
38 void PrintSelf(ostream& os, vtkIndent indent) override;
39
41
46 vtkGetMacro(Label, std::string&);
47 vtkSetMacro(Label, std::string);
49
52
57
61 const std::vector<vtkSmartPointer<vtkWebGPUComputePass>>& GetComputePasses() const;
62
67
75 void Update();
76
84
85private:
88 friend class vtkWebGPURenderer;
89
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
160VTK_ABI_NAMESPACE_END
161
162#endif
a simple class to control print indentation
Definition vtkIndent.h:108
abstract base class for most VTK objects
Definition vtkObject.h:162
Hold a reference to a vtkObjectBase instance.
Internals of the vtkWebGPUComputePass.
A compute pipeline is the orchestrator of a collection of compute passes.
void SetWGPUConfiguration(vtkWebGPUConfiguration *config)
static vtkWebGPUComputePipeline * New()
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
void DispatchAllPasses()
Dispatch all the compute passes of this compute pipeline in the order they were added.
const std::vector< vtkSmartPointer< vtkWebGPUComputePass > > & GetComputePasses() const
Returns the list of the compute passes that have been added to this compute pipeline.
vtkSmartPointer< vtkWebGPUComputePass > CreateComputePass()
Adds a compute pass to this pipeline.
void ReleaseResources()
Releases the resources used by this pipeline: all compute passes & registered buffers/textures.
vtkGetSmartPointerMacro(WGPUConfiguration, vtkWebGPUConfiguration)
void Update()
Executes WebGPU commands and callbacks.
Create a webgpu device for use in rendering and compute pipelines.