Library struct

The core implementation of the executable.

This class implements the main WebGPU initialization logic, abstracting the process of creating a WebGPU instance, requesting an adapter and device, and retrieving adapter info.

Constructors, destructors, conversion operators

Library()
Constructs the Library and initializes the name.

Public functions

auto CreateInstance() -> wgpu::Instance
Creates a WebGPU instance.
auto RequestAdapter(wgpu::Instance instance) -> wgpu::Adapter
Synchronously requests a WebGPU adapter.
auto RequestDevice(wgpu::Adapter adapter) -> wgpu::Device
Synchronously requests a WebGPU device from an adapter.
auto GetAdapterInfo(wgpu::Adapter adapter) -> wgpu::AdapterInfo
Retrieves information about a given adapter.

Public variables

std::string mName
The name of the project.

Function documentation

Library::Library()

Constructs the Library and initializes the name.

Constructs the Library and initializes the project name.

wgpu::Instance Library::CreateInstance()

Creates a WebGPU instance.

Returns A valid wgpu::Instance, or nullptr if creation failed.

wgpu::Adapter Library::RequestAdapter(wgpu::Instance instance)

Synchronously requests a WebGPU adapter.

Parameters
instance The instance from which to request the adapter.
Returns A valid wgpu::Adapter, or nullptr if the request failed.

wgpu::Device Library::RequestDevice(wgpu::Adapter adapter)

Synchronously requests a WebGPU device from an adapter.

Parameters
adapter The adapter from which to request the device.
Returns A valid wgpu::Device, or nullptr if the request failed.

wgpu::AdapterInfo Library::GetAdapterInfo(wgpu::Adapter adapter)

Retrieves information about a given adapter.

Parameters
adapter The adapter from which to retrieve information.
Returns A filled wgpu::AdapterInfo structure.