VTK  9.7.20260913
vtkWebGPUProcLoader Class Reference

#include <vtkWebGPUProcLoader.h>

Detailed Description

vtkWebGPUProcLoader provides C++ integration for runtime WebGPU library loading.

It ensures the proc table is initialized and provides access to WebGPU functions.

This is a singleton: construction and loading are private so that GetInstance() owns the one and only instance.

if (auto* loader = vtkWebGPUProcLoader::GetInstance())
{
WGPUInstance instance = wgpuCreateInstance(nullptr);
// ...
}
static vtkWebGPUProcLoader * GetInstance()
Get the singleton instance (loads on first access).
#define wgpuCreateInstance
Note
The proc table is process wide. vtkWebGPUProcTableLoad() hands back the existing global table without taking a reference, so a second instance of this class would release a table still in use by the first when it is destroyed. Keeping the constructor private makes that unrepresentable.

Definition at line 30 of file vtkWebGPUProcLoader.h.

Public Types

enum  ImplementationType { Unknown = 0 , Dawn , WgpuNative }
 The implementation behind the loaded library. More...

Public Member Functions

ImplementationType GetImplementation () const
 Which implementation the loaded library is, as identified by the extension entry points only that implementation declares.
bool IsLoaded () const
 Check if a library has been successfully loaded.
const std::string & GetError () const
 Get the last error message if Load() failed.
 vtkWebGPUProcLoader (const vtkWebGPUProcLoader &)=delete
void operator= (const vtkWebGPUProcLoader &)=delete

Static Public Member Functions

static vtkWebGPUProcLoaderGetInstance ()
 Get the singleton instance (loads on first access).

Member Enumeration Documentation

◆ ImplementationType

The implementation behind the loaded library.

Implementations disagree on which entry points they actually implement. wgpu-native in particular exports the whole of webgpu.h but leaves a number of bodies as unimplemented!(), which panics and aborts the process rather than returning an error, so a missing symbol cannot be used to detect them.

Enumerator
Unknown 
Dawn 
WgpuNative 

Definition at line 41 of file vtkWebGPUProcLoader.h.

Constructor & Destructor Documentation

◆ vtkWebGPUProcLoader()

vtkWebGPUProcLoader::vtkWebGPUProcLoader ( const vtkWebGPUProcLoader & )
delete

Member Function Documentation

◆ GetImplementation()

ImplementationType vtkWebGPUProcLoader::GetImplementation ( ) const
inline

Which implementation the loaded library is, as identified by the extension entry points only that implementation declares.

Definition at line 52 of file vtkWebGPUProcLoader.h.

◆ IsLoaded()

bool vtkWebGPUProcLoader::IsLoaded ( ) const

Check if a library has been successfully loaded.

◆ GetError()

const std::string & vtkWebGPUProcLoader::GetError ( ) const
inline

Get the last error message if Load() failed.

Definition at line 62 of file vtkWebGPUProcLoader.h.

◆ GetInstance()

vtkWebGPUProcLoader * vtkWebGPUProcLoader::GetInstance ( )
static

Get the singleton instance (loads on first access).

Returns nullptr if load fails.

The library to load is taken from the VTK_WEBGPU_LIBRARY environment variable when it is set; otherwise the names implementations are commonly installed under are tried in turn.

◆ operator=()

void vtkWebGPUProcLoader::operator= ( const vtkWebGPUProcLoader & )
delete

The documentation for this class was generated from the following file: