Responsible for the WebGPU GPUAdapter | adapter and GPUDevice | device creations, losing and restoration.

It will create all the GPU objects that need a GPUDevice | device to do so, as well as a PipelineManager. It will also keep a track of all the Renderer, bind groups, Sampler, DOMTexture and GPUBuffer | GPU buffers created.

The GPUDeviceManager is also responsible for creating the GPUCommandBuffer, rendering all the Renderer and then submitting the GPUCommandBuffer at each render calls.

Constructors

Properties

index: number

Number of times a GPUDevice has been created

label: string

The label of the GPUDeviceManager, used to create the GPUDevice for debugging purpose

production: boolean

Flag indicating whether we're running the production mode or not. If not, useful warnings could be logged to the console

gpu: GPU

The navigator GPU object

adapter: void | GPUAdapter

The WebGPU GPUAdapter | adapter used

adapterOptions: GPURequestAdapterOptions

Additional options to use when requesting an GPUAdapter | adapter

device: GPUDevice

The WebGPU GPUDevice | device used

ready: boolean

Flag indicating whether the GPUDeviceManager is ready, i.e. its adapter and device have been successfully created

pipelineManager: PipelineManager

The PipelineManager used to cache GPURenderPipeline and GPUComputePipeline and set them only when appropriate

renderers: Renderer[]

Array of renderers using that GPUDeviceManager

bindGroups: Map<string, AllowedBindGroups>

A Map containing all our created AllowedBindGroups

buffers: Map<string, Buffer>

An array containing all our created GPUBuffer

bindGroupLayouts: Map<string, GPUBindGroupLayout>

A Map containing all our created GPUBindGroupLayout indexed by cache keys

bufferBindings: Map<string, BufferBinding>

A Map containing all our created BufferBinding indexed by cache keys

samplers: Sampler[]

An array containing all our created Sampler

domTextures: DOMTexture[]

An array containing all our created DOMTexture

texturesQueue: DOMTexture[]

An array to keep track of the newly uploaded DOMTexture and set their sourceUploaded property

onError: (() => void)

Callback to run if there's any error while trying to set up the GPUAdapter | adapter or GPUDevice | device

Type declaration

    • (): void
    • Callback to run if there's any error while trying to set up the GPUAdapter | adapter or GPUDevice | device

      Returns void

onDeviceLost: ((info?) => void)

Callback to run whenever the device is lost.

Type declaration

    • (info?): void
    • Callback to run whenever the device is lost.

      Parameters

      • Optional info: GPUDeviceLostInfo

      Returns void

onDeviceDestroyed: ((info?) => void)

Callback to run whenever the device has been intentionally destroyed.

Type declaration

    • (info?): void
    • Callback to run whenever the device has been intentionally destroyed.

      Parameters

      • Optional info: GPUDeviceLostInfo

      Returns void

Accessors

Methods

  • Set our adapter if possible. The adapter represents a specific GPU. Some devices have multiple GPUs.

    Parameters

    • adapter: GPUAdapter = null

      GPUAdapter to use if set.

    Returns Promise<void>

    Async