VTK  9.4.20241112
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
189 std::string ReportCapabilities();
190 static std::string DeviceNotReadyMessage();
191
198 std::uint32_t GetAdapterVendorID();
199 std::uint32_t GetAdapterDeviceID();
200
202
220
221protected:
224
225 PowerPreferenceType PowerPreference = PowerPreferenceType::HighPerformance;
226 // Initialized in constructor at runtime based on the operating system.
228 // In milliseconds
229 double Timeout;
230
231 void AcquireAdapter(vtkObject* caller, unsigned long event, void* calldata);
232
233 void AcquireDevice(vtkObject* caller, unsigned long event, void* calldata);
234
235private:
237 void operator=(const vtkWebGPUConfiguration&) = delete;
238
240 std::unique_ptr<vtkWebGPUConfigurationInternals> Internals;
241};
242
243VTK_ABI_NAMESPACE_END
244
245#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.
bool IsMicrosoftGPUInUse()
Checks whether a particular vendor's GPU is in use.
wgpu::Device GetDevice()
Get handles of the WGPU adapter/device/instance.
bool IsBroadcomGPUInUse()
Checks whether a particular vendor's GPU is in use.
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.
std::uint32_t GetAdapterDeviceID()
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.
bool IsAppleGPUInUse()
Checks whether a particular vendor's GPU is in use.
void AcquireDevice(vtkObject *caller, unsigned long event, void *calldata)
vtkSetEnumMacro(Backend, BackendType)
Set/Get the graphics backend to use from the graphics adapter.
std::string ReportCapabilities()
Print information of webgpu adapter and device to the output string.
bool IsAMDGPUInUse()
Checks whether a particular vendor's GPU is in use.
void Finalize()
Finalizes the class.
bool IsNVIDIAGPUInUse()
Checks whether a particular vendor's GPU is in use.
vtkSetEnumMacro(PowerPreference, PowerPreferenceType)
Set/Get the power preference of the graphics adapter.
void ProcessEvents()
Process events on the WGPUInstance.
bool IsIntelGPUInUse()
Checks whether a particular vendor's GPU is in use.
bool IsARMGPUInUse()
Checks whether a particular vendor's GPU is in use.
std::uint32_t GetAdapterVendorID()
Get the PCI vendor ID of the adapter and the system PCI ID of the device.
bool IsMesaGPUInUse()
Checks whether a particular vendor's GPU is in use.
bool IsSamsungGPUInUse()
Checks whether a particular vendor's GPU is in use.
static std::string DeviceNotReadyMessage()
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.
WebGPU rendering window.