VTK  9.4.2
vtkWebGPUConfiguration.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
18#ifndef vtkWebGPUConfiguration_h
19#define vtkWebGPUConfiguration_h
20
21#include "vtkObject.h"
22
23#include "vtkCommand.h" // for vtkCommand
24#include "vtkRenderingWebGPUModule.h" // for export macro
25#include "vtk_wgpu.h" // for wgpu
26
27#include <memory> // for unique_ptr
28
29VTK_ABI_NAMESPACE_BEGIN
30
34
35class VTKRENDERINGWEBGPU_EXPORT vtkWebGPUConfiguration : public vtkObject
36{
37public:
40 void PrintSelf(ostream& os, vtkIndent indent) override;
41
47 {
48 Undefined,
49 LowPower,
50 HighPerformance
51 };
52
53 enum class BackendType
54 {
55 Undefined,
56 Null,
57 WebGPU,
58 D3D11,
59 D3D12,
60 Metal,
61 Vulkan,
62 OpenGL,
63 OpenGLES
64 };
65
67
78
80
97
99
107 vtkSetMacro(Timeout, double);
108 vtkGetMacro(Timeout, double);
110
114 static void SetDefaultTimeout(double);
115
123
128
130
133 wgpu::Adapter GetAdapter();
134 wgpu::Device GetDevice();
135 wgpu::Instance GetInstance();
137
155
161 void Finalize();
162
171
178 static std::size_t Align(std::size_t value, std::size_t alignment);
179
180 enum
181 {
182 AdapterRequestCompletedEvent = vtkCommand::UserEvent,
184 };
185
186protected:
189
190 PowerPreferenceType PowerPreference = PowerPreferenceType::HighPerformance;
191 // Initialized in constructor at runtime based on the operating system.
193 // In milliseconds
194 double Timeout;
195
196 void AcquireAdapter(vtkObject* caller, unsigned long event, void* calldata);
197
198 void AcquireDevice(vtkObject* caller, unsigned long event, void* calldata);
199
200private:
202 void operator=(const vtkWebGPUConfiguration&) = delete;
203
205 std::unique_ptr<vtkWebGPUConfigurationInternals> Internals;
206};
207
208VTK_ABI_NAMESPACE_END
209
210#endif
a simple class to control print indentation
Definition vtkIndent.h:108
abstract base class for most VTK objects
Definition vtkObject.h:162
A compute pipeline is the orchestrator of a collection of compute passes.
Create a webgpu device for use in rendering and compute pipelines.
vtkGetEnumMacro(PowerPreference, PowerPreferenceType)
Set/Get the power preference of the graphics adapter.
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
wgpu::Device GetDevice()
Get handles of the WGPU adapter/device/instance.
PowerPreferenceType
These enums have a one-one correspondence with the webgpu enums.
BackendType GetBackendInUse()
Get the backend in use.
vtkGetEnumMacro(Backend, BackendType)
Set/Get the graphics backend to use from the graphics adapter.
static std::size_t Align(std::size_t value, std::size_t alignment)
Adjusts a given value to the nearest multiple of the specified alignment.
void AcquireAdapter(vtkObject *caller, unsigned long event, void *calldata)
~vtkWebGPUConfiguration() override
static vtkWebGPUConfiguration * New()
static void SetDefaultTimeout(double)
Use this method to customize the default value for Timeout.
void AcquireDevice(vtkObject *caller, unsigned long event, void *calldata)
vtkSetEnumMacro(Backend, BackendType)
Set/Get the graphics backend to use from the graphics adapter.
void Finalize()
Finalizes the class.
vtkSetEnumMacro(PowerPreference, PowerPreferenceType)
Set/Get the power preference of the graphics adapter.
void ProcessEvents()
Process events on the WGPUInstance.
std::string GetBackendInUseAsString()
Convenient function returns a string representation of the currently used backend.
wgpu::Instance GetInstance()
Get handles of the WGPU adapter/device/instance.
bool Initialize()
Initializes the class.
wgpu::Adapter GetAdapter()
Get handles of the WGPU adapter/device/instance.