Used to regroup all bindings related to textures (texture, texture matrices buffers and samplers) into one single specific BindGroup.

Also responsible for uploading video textures if needed.

Example

// set our main GPUCurtains instance
const gpuCurtains = new GPUCurtains({
container: '#canvas' // selector of our WebGPU canvas container
})

// set the GPU device
// note this is asynchronous
await gpuCurtains.setDevice()

// create a texture
const texture = new Texture(gpuCurtains, {
label: 'Input texture',
name: 'inputTexture',
})

// create a texture bind group using that texture
const textureBindGroup = new TextureBindGroup(gpuCurtains, {
label: 'My texture bind group',
textures: [texture],
uniforms: {
params: {
struct: {
opacity: {
type: 'f32',
value: 1,
},
mousePosition: {
type: 'vec2f',
value: new Vec2(),
},
},
},
},
})

// create the GPU buffer, bindGroupLayout and bindGroup
textureBindGroup.createBindGroup()

Hierarchy (view full)

Constructors

Properties

type: string

The type of the BindGroup

uuid: string

The universal unique id of the BindGroup

renderer: Renderer

The Renderer used

Options used to create this BindGroup

index: number

Index of this BindGroup, used to link struct in the shaders

List of bindings (buffers, texture, etc.) handled by this BindGroup

Our BindGroup entries objects

bindGroupLayout: GPUBindGroupLayout

Our BindGroupGPUBindGroupLayout

bindGroup: GPUBindGroup

Our BindGroup GPUBindGroup

layoutCacheKey: string

A cache key allowing to get / set GPUBindGroupLayout from the device manager map cache.

pipelineCacheKey: string

A cache key allowing the PipelineManager to compare RenderPipelineEntry bind groups content.

needsPipelineFlush: boolean

Flag indicating whether we need to flush and recreate the pipeline using this BindGroup s

consumers: Set<string>

A Set to store this BindGroup consumers (Material uuid)

Accessors

  • get shouldCreateBindGroup(): boolean
  • Get whether the GPU bind group is ready to be created It can be created if it has BindGroup#bindings and has not been created yet and all GPU textures and samplers are created

    Returns boolean

Methods