BindGroup constructor
a Renderer class object or a GPUCurtains class object.
parameters used to create our BindGroup.
The type of the BindGroup.
The universal unique id of the BindGroup.
The Renderer used.
Options used to create this BindGroup.
Index of this BindGroup, used to link struct in the shaders.
Our BindGroup GPUBindGroup.
A cache key allowing to get / set GPUBindGroupLayout from the device manager map cache.
A cache key allowing the PipelineManager to compare RenderPipelineEntry bind groups content.
Flag indicating whether we need to flush and recreate the pipeline using this BindGroup.
A Set to store this BindGroup consumers (Material uuid).
Get whether the GPU bind group is ready to be created. It can be created if it has bindings and has not been created yet.
Get all bind group bindings that handle a GPUBuffer
New Renderer or GPUCurtains instance to use.
Sets our bind group index.
bind group index to set.
bindings to add.
binding to add.
Destroy a BufferBinding buffers.
BufferBinding from which to destroy the buffers.
Creates Bindings based on a list of inputs.
inputs (uniform or storage) that will be used to create the binding.
Create and adds bindings based on inputs provided upon creation.
Create the GPU buffers, bindings, entries, bindGroupLayout and bindGroup.
Reset the .bindGroup | bindGroup entries, recreates them and then recreate the GPU bind group.
binding to add
Reset the .bindGroupLayout | bindGroupLayout entries, recreates them and then recreate the GPU bind group layout
binding to add
Called when the device has been lost to prepare everything for restoration
Called when the device has been restored to update our bindings.
Creates binding GPUBuffer with correct params.
The binding element.
Optional label to use for the GPUBuffer.
Get a bind group binding by name/key
the binding name or key
Create a GPUBindGroupLayout and set our bindGroupLayout
Create a GPUBindGroup and set our bindGroup
Check whether we should update (write) our GPUBuffer or not.
Update the BindGroup, which means update its buffer bindings and reset it if needed. Called at each render from the parentMesh material
Clones a BindGroup from a list of bindings. Useful to create a new bind group with already created buffers, but swapped.
parameters to use for cloning.
Optional
bindings?: BindGroupBindingElement[]our input bindings.
Optional
keepLayout?: booleanwhether we should keep original bindGroupLayout or not.
Destroy our BindGroup Most important is to destroy the GPUBuffers to free the memory
Used to handle all inputs data sent to the GPU.
In WebGPU, data (buffers, textures or samplers, called bindings) are organised by bind groups, containing those bindings.
Bindings
A BindGroup is responsible for creating each BufferBinding GPUBuffer and then the GPUBindGroup and GPUBindGroupLayout that are used to create GPUComputePipeline or GPURenderPipeline.
Those are generally automatically created by the Material using this BindGroup. If you need to manually create them, you will have to call its
createBindGroup()
methodSamplers and textures
A BindGroup is best suited to handle GPUBuffer only bindings. If you need to handle GPUSampler, a GPUTexture or a GPUExternalTexture, you should use a TextureBindGroup instead.
Updating a GPUBindGroup or GPUBindGroupLayout
Each time one of the binding resource changes, its bindGroup will be recreated (usually, when a GPUTexture is uploaded).
Each time one of the binding resource layout changes, its bindGroupLayout and bindGroup will be recreated, and the GPUComputePipeline or GPURenderPipeline will be recreated as well.
Example