BufferBinding constructor
parameters used to create our BufferBindings
The label of the Binding
The name/key of the Binding
The visibility of the Binding in the shaders
Flag indicating whether we should recreate the parentMesh bind group, usually when a resource has changed
Flag indicating whether we should recreate the parentMesh GPU bind group layout, usually when a resource layout has changed
A cache key allowing to get / set bindings from the device manager map cache. Used for BufferBinding only at the moment.
The binding type of the BufferBinding
Flag to indicate whether this BufferBinding buffer elements should be packed in a single structured object or if each one of them should be a separate binding.
All the BufferBinding data inputs
Flag to indicate whether one of the inputs value has changed and we need to update the GPUBuffer linked to the arrayBuffer array
Total size of our arrayBuffer array in bytes
Array buffer that will be sent to the GPUBuffer
Data view of our array buffer
The Buffer holding the GPUBuffer
A string to append to our shaders code describing the WGSL structure representing this BufferBinding
An array of strings to append to our shaders code declaring all the WGSL variables representing this BufferBinding
Options used to create this BufferBinding
Get GPUBindGroupLayoutEntry#buffer | bind group layout entry resource
GPUBindGroupLayout | bind group layout resource
Get the resource cache key
Get GPUBindGroupEntry#resource | bind group resource
GPUBindGroup | bind group resource
Clone this BufferBinding into a new one. Allows to skip buffer layout alignment computations.
params to use for cloning
Set the buffer alignments from inputs.
Set our buffer attributes: Takes all the inputs and adds them to the bufferElements array with the correct start and end offsets (padded), then fill our arrayBuffer typed array accordingly.
Set a binding shouldUpdate flag to true
to update our arrayBuffer array during next render.
the binding name/key to update
Executed at the beginning of a Material render call. If any of the inputs has changed, run its onBeforeUpdate callback then updates our arrayBuffer array. Also sets the shouldUpdate property to true so the BindGroup knows it will need to update the GPUBuffer.
Extract the data corresponding to a specific BufferElement from a Float32Array holding the GPU buffer data of this BufferBinding
parameters used to extract the data
Float32Array holding GPUBuffer data
name of the BufferElement to use to extract the data
Used to format uniforms or storages struct inputs and create a single typed array that will hold all those inputs values. The array needs to be correctly padded depending on every value type, so it can be safely used as a GPUBuffer input.
It will also create WGSL Structs and variables according to the BufferBindings inputs parameters.
The WGSL structs and variables declaration may vary based on the input types, especially if there's one or more arrays involved (i.e.
array<f32>
,array<vec3f>
etc.).Example