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

It will create all the GPU objects that need a device to do so, as well as a PipelineManager. It will also keep a track of all the Renderer, bind groups, Sampler, MediaTexture and 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 adapter used.

adapterOptions: GPURequestAdapterOptions

Additional options to use when requesting an adapter.

device: GPUDevice

The WebGPU 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.

indirectBuffers: Map<string, IndirectBuffer>

A Map containing all our created IndirectBuffer.

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.

texturesQueue: { sourceIndex: number; texture: MediaTexture }[]

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

Type declaration

animationFrameID: number

Request animation frame callback returned id if used.

_onBeforeRenderCallback: () => void = ...

function assigned to the onBeforeRender callback.

_onAfterRenderCallback: () => void = ...

function assigned to the onAfterRender callback.

onError: () => void

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

onDeviceLost: (info?: GPUDeviceLostInfo) => void

Callback to run whenever the device is lost.

onDeviceDestroyed: (info?: GPUDeviceLostInfo) => void

Callback to run whenever the device has been intentionally destroyed.

Accessors

Methods