VTK  9.7.20260907
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 C API
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
51 vtkGetSmartPointerMacro(WGPUConfiguration, vtkWebGPUConfiguration);
52
57
61 const std::vector<vtkSmartPointer<vtkWebGPUComputePass>>& GetComputePasses() const;
62
67
75 void Update();
76
84
85protected:
88
89private:
93 friend class vtkWebGPURenderer;
94
96 void operator=(const vtkWebGPUComputePipeline&) = delete;
97
102 void RegisterBuffer(vtkSmartPointer<vtkWebGPUComputeBuffer> buffer, WGPUBuffer wgpuBuffer);
103
108 void RegisterTexture(vtkSmartPointer<vtkWebGPUComputeTexture> texture, WGPUTexture wgpuTexture);
109
111
118 bool GetRegisteredBuffer(vtkSmartPointer<vtkWebGPUComputeBuffer> buffer, WGPUBuffer& wgpuBuffer);
119
120 bool GetRegisteredTexture(
121 vtkSmartPointer<vtkWebGPUComputeTexture> texture, WGPUTexture& wgpuTexture);
123
128 void EnsureConfigured();
129
134 vtkSmartPointer<vtkWebGPUConfiguration> WGPUConfiguration = nullptr;
135
139 std::vector<vtkSmartPointer<vtkWebGPUComputePass>> ComputePasses;
140
152 std::unordered_map<vtkSmartPointer<vtkWebGPUComputeBuffer>, WGPUBuffer> RegisteredBuffers;
153 std::unordered_map<vtkSmartPointer<vtkWebGPUComputeTexture>, WGPUTexture> RegisteredTextures;
154
155 // Label used for debugging
156 std::string Label = "WebGPU Compute Pipeline";
157};
158
159VTK_ABI_NAMESPACE_END
160
161#endif
a simple class to control print indentation
Definition vtkIndent.h:108
Hold a reference to a vtkObjectBase instance.
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.
~vtkWebGPUComputePipeline() override
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.
void Update()
Executes WebGPU commands and callbacks.
Create a webgpu device for use in rendering and compute pipelines.
WebGPU rendering window.