UWAL / Device
Type Aliases
ConfigurationOptions
type ConfigurationOptions = Pick<Partial<CanvasConfiguration>, "format"> & Omit<CanvasConfiguration, "format">;Type Parameters
| Type Parameter |
|---|
RequestAdapterOptions
type RequestAdapterOptions = GPURequestAdapterOptions & Record<"forceCompatibility", boolean | void>;Type Parameters
| Type Parameter |
|---|
CanvasConfiguration
type CanvasConfiguration = Omit<GPUCanvasConfiguration, "device">;Type Parameters
| Type Parameter |
|---|
Classes
Device
Static class used to request and manage your GPUAdapter and GPUDevice with specified features and limits when provided. It can cleanup resources like GPUBuffers, GPUTextures and GPUQuerySets when no longer required and destroy the current GPUDevice.
Properties
OnLost
static OnLost: ((detail) => unknown) | undefined;Callback with a GPUDeviceLostInfo argument to call when a GPUDevice is lost. When present, prevents an ERROR.DEVICE_LOST from being thrown.
Methods
CreateQuerySet()
static CreateQuerySet(
type,
count,
label?): Promise<GPUQuerySet | undefined>;Create and cache a new GPUQuerySet.
Parameters
| Parameter | Type | Description |
|---|---|---|
type | GPUQueryType | The type of queries managed by the GPUQuerySet |
count | number | The number of queries managed by the GPUQuerySet |
label? | string | GPUQuerySet label, defaults to DescriptorLabel when not provided |
Returns
Promise<GPUQuerySet | undefined>
See
GPUTiming which uses a "timestamp" query set.
Destroy()
static Destroy(
buffers?,
textures?,
querySets?): void;Remove initialized GPUAdapter and GPUDevice instances, reset internal RequestAdapterOptions and GPUDeviceDescriptor objects, and optionally destroy GPUBuffer, GPUTexture and GPUQuerySet resources if passed as arguments.
Parameters
| Parameter | Type | Description |
|---|---|---|
buffers? | GPUBuffer | GPUBuffer[] | Optional buffers to destroy |
textures? | GPUTexture | GPUTexture[] | Optional textures to destroy |
querySets? | GPUQuerySet | GPUQuerySet[] | Optional query sets to destroy |
Returns
void
SetRequiredFeatures()
static SetRequiredFeatures(features): Promise<Set<GPUFeatureName>>;Set optional features when requesting a GPUDevice. The request will fail if the GPUAdapter cannot provide them. Must be called before Renderer, Computation, TextureUtils and CreateQuerySet.
Parameters
| Parameter | Type | Description |
|---|---|---|
features | GPUFeatureName | GPUFeatureName[] | List of fearures to request from the adapter |
Returns
Promise<Set<GPUFeatureName>>
Accessors
AdapterOptions
Set Signature
set static AdapterOptions(options): void;Set optional RequestAdapterOptions when requesting a GPUAdapter. Must be called before requesting a GPUDevice.
See
https://www.w3.org/TR/webgpu/#adapter-selection
Parameters
| Parameter | Type | Description |
|---|---|---|
options | RequestAdapterOptions | Standard GPURequestAdapterOptions with an optional forceCompatibility flag to enable compatibility mode even when the target device supports core |
Returns
void
RequiredLimits
Set Signature
set static RequiredLimits(requiredLimits): void;Set optional device limits when requesting a GPUDevice. The request will fail if the GPUAdapter cannot provide them. Must be called before Renderer, Computation, TextureUtils and CreateQuerySet.
Parameters
| Parameter | Type | Description |
|---|---|---|
requiredLimits | Record<string, number> | undefined | List of limits to request from the adapter |
Returns
void
DefaultQueue
Set Signature
set static DefaultQueue(descriptor): void;Set the descriptor for the default GPUQueue.
Parameters
| Parameter | Type | Description |
|---|---|---|
descriptor | GPUQueueDescriptor | undefined | Default queue descriptor object |
Returns
void
DescriptorLabel
Set Signature
set static DescriptorLabel(label): void;Set the descriptor label for the GPUDevice.
Parameters
| Parameter | Type | Description |
|---|---|---|
label | string | undefined | Device descriptor label |
Returns
void
PreferredCanvasFormat
Get Signature
get static PreferredCanvasFormat(): GPUTextureFormat;Get an optimal GPUTextureFormat for the current system.
See
https://www.w3.org/TR/webgpu/#dom-gpu-getpreferredcanvasformat
Returns
GPUTextureFormat
The only possible values are "rgba8unorm" and "bgra8unorm".
VERSION
Get Signature
get static VERSION(): string;Returns
string
The current version of the library.