Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 19 additions & 3 deletions src/renderers/common/Attributes.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,13 @@ class Attributes extends DataMap {

if ( attributeData !== null ) {


if ( attributeData.onDispose !== undefined ) {

attribute.removeEventListener( 'dispose', attributeData.onDispose );

}

this.backend.destroyAttribute( attribute );

this.info.destroyAttribute( attribute );
Expand All @@ -69,6 +76,7 @@ class Attributes extends DataMap {
update( attribute, type ) {

const data = this.get( attribute );
const bufferAttribute = this._getBufferAttribute( attribute );

if ( data.version === undefined ) {

Expand All @@ -94,11 +102,19 @@ class Attributes extends DataMap {

}

data.version = this._getBufferAttribute( attribute ).version;
// Standalone disposal is currently limited to WebGPU storage/indirect attributes.
// Other attribute types would require additional render-state invalidation before this is safe.

} else {
if ( this.backend.isWebGPUBackend === true && ( type === AttributeType.STORAGE || type === AttributeType.INDIRECT ) ) {

const bufferAttribute = this._getBufferAttribute( attribute );
data.onDispose = () => this.delete( attribute );
attribute.addEventListener( 'dispose', data.onDispose );

}

data.version = bufferAttribute.version;

} else {

if ( data.version < bufferAttribute.version || bufferAttribute.usage === DynamicDrawUsage ) {

Expand Down
4 changes: 4 additions & 0 deletions src/renderers/common/Bindings.js
Original file line number Diff line number Diff line change
Expand Up @@ -325,6 +325,10 @@ class Bindings extends DataMap {
if ( bindingData.attribute !== attribute ) {

bindingData.attribute = attribute;
const bindGroupData = backend.get( bindGroup );

bindGroupData.groups = undefined;
bindGroupData.versions = undefined;

needsBindingsUpdate = true;

Expand Down
Loading