Skip to content
8 changes: 8 additions & 0 deletions src/renderers/common/Backend.js
Original file line number Diff line number Diff line change
Expand Up @@ -725,6 +725,14 @@ class Backend {

}

/**
* Delete GPU data associated with a bind group.
*
* @abstract
* @param {BindGroup} bindGroup - The bind group.
*/
deleteBindGroupData( /*bindGroup*/ ) { }

/**
* Deletes an object from the internal data structure.
*
Expand Down
2 changes: 2 additions & 0 deletions src/renderers/common/Bindings.js
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,7 @@ class Bindings extends DataMap {

for ( const bindGroup of bindings ) {

this.backend.deleteBindGroupData( bindGroup );
this.delete( bindGroup );

}
Expand All @@ -181,6 +182,7 @@ class Bindings extends DataMap {

for ( const bindGroup of bindings ) {

this.backend.deleteBindGroupData( bindGroup );
this.delete( bindGroup );

}
Expand Down
16 changes: 15 additions & 1 deletion src/renderers/webgpu/WebGPUBackend.js
Original file line number Diff line number Diff line change
Expand Up @@ -1652,7 +1652,9 @@ class WebGPUBackend extends Backend {

data[ 0 ] = i;

const bindGroupIndex = this.bindingUtils.createBindGroupIndex( data, bindingsData.layout );
const { layoutGPU } = bindingsData.layout;

const bindGroupIndex = this.bindingUtils.createBindGroupIndex( data, layoutGPU );

indexesGPU.push( bindGroupIndex );

Expand Down Expand Up @@ -2119,6 +2121,17 @@ class WebGPUBackend extends Backend {

}

/**
* Delete data associated with the current bind group.
*
* @param {BindGroup} bindGroup - The bind group.
*/
deleteBindGroupData( bindGroup ) {

this.bindingUtils.deleteBindGroupData( bindGroup );

}

/**
* Updates the given bind group definition.
*
Expand Down Expand Up @@ -2474,6 +2487,7 @@ class WebGPUBackend extends Backend {
dispose() {

this.textureUtils.dispose();
this.bindingUtils.dispose();

}

Expand Down
Loading