gpu-curtains
    Preparing search index...

    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 BufferBinding 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.).

    It is possible to create complex WGSL structs with children structs by using the childrenBindings parameter.

    There's a helper tool to help you understand and debug your BufferBinding WGSL declaration: BufferBinding WGSL generation helper

    A BufferBinding can also have a parent BufferBinding, in which case it won't create a GPUBuffer but use its parent GPUBuffer at the right offset. Useful to create a unique BufferBinding with a single GPUBuffer to handle multiple BufferBinding and update them with a single writeBuffer call.

    // create a GPU buffer binding
    const bufferBinding = new BufferBinding({
    name: 'params', // name of the WGSL object
    bindingType: 'uniform', // should be 'storage' for large arrays
    struct: {
    opacity: {
    type: 'f32',
    value: 1,
    },
    mousePosition: {
    type: 'vec2f',
    value: new Vec2(),
    },
    },
    })

    Hierarchy (View Summary)

    Index

    Constructors

    Properties

    label: string

    The label of the Binding.

    name: string

    The name/key of the Binding.

    visibility: number

    The visibility of the Binding in the shaders.

    shouldResetBindGroup: boolean

    Flag indicating whether we should recreate the parentMesh bind group, usually when a resource has changed.

    shouldResetBindGroupLayout: boolean

    Flag indicating whether we should recreate the parentMesh GPU bind group layout, usually when a resource layout has changed.

    cacheKey: string

    A cache key allowing to get / set bindings from the device manager map cache. Used for BufferBinding only at the moment.

    bindingType: BufferBindingType

    The binding type of the BufferBinding

    useStruct: boolean

    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.

    inputs: Record<string, BufferBindingInput>

    All the BufferBinding data inputs

    childrenBindings: BufferBinding[]

    Array of children BufferBinding used as struct children.

    shouldUpdate: boolean

    Flag to indicate whether one of the inputs value has changed and we need to update the GPUBuffer linked to the arrayBuffer array

    bufferElements: AllowedBufferElement[]

    An array describing how each corresponding inputs should be inserted into our arrayView array

    arrayBufferSize: number

    Total size of our arrayBuffer array in bytes

    arrayBuffer: ArrayBuffer

    Array buffer that will be sent to the GPUBuffer

    arrayView: DataView

    Data view of our array buffer

    parentView: DataView<ArrayBufferLike>

    DataView inside the parent arrayBuffer if set.

    parentViewSetBufferEls: {
        bufferElement: AllowedBufferElement;
        viewSetFunction: DataViewSetFunction;
    }[]

    Array of bufferElements and according view set functions to use if the parent is set.

    Type Declaration

    buffer: Buffer

    The Buffer holding the GPUBuffer

    wgslStructFragment: string

    A string to append to our shaders code describing the WGSL structure representing this BufferBinding

    wgslGroupFragment: string[]

    An array of strings to append to our shaders code declaring all the WGSL variables representing this BufferBinding

    Options used to create this BufferBinding

    Accessors

    Methods

    • Set the WGSL code snippet to append to the shaders code. It consists of variable (and Struct structures if needed) declarations.

      Returns void