Skip to content
Merged
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
10 changes: 5 additions & 5 deletions src/renderers/common/Bindings.js
Original file line number Diff line number Diff line change
Expand Up @@ -306,18 +306,20 @@ class Bindings extends DataMap {

this.textures.updateTexture( texture );

// generation: update the bindings if a new texture has been created
// generation: update the bindings if the binding refers to a different texture object

if ( binding.generation !== texturesTextureData.generation ) {

binding.generation = texturesTextureData.generation;

needsBindingsUpdate = true;

cacheBindings = false;

}

// keep track which bind groups refer to the current texture (this is needed for dispose)

texturesTextureData.bindGroups.add( bindGroup );

}

const textureData = backend.get( texture );
Expand Down Expand Up @@ -365,8 +367,6 @@ class Bindings extends DataMap {

needsBindingsUpdate = true;

cacheBindings = false;

}

}
Expand Down
16 changes: 16 additions & 0 deletions src/renderers/common/Textures.js
Original file line number Diff line number Diff line change
Expand Up @@ -318,6 +318,7 @@ class Textures extends DataMap {

textureData.initialized = true;
textureData.generation = texture.version;
textureData.bindGroups = new Set();

//

Expand Down Expand Up @@ -531,6 +532,21 @@ class Textures extends DataMap {
const isDefaultTexture = textureData.isDefaultTexture;
this.backend.destroyTexture( texture, isDefaultTexture );

// delete cached bind groups so they don't point to destroyed textures

if ( textureData.bindGroups ) {

for ( const bindGroup of textureData.bindGroups ) {

const bindingsData = this.backend.get( bindGroup );

bindingsData.groups = undefined;
bindingsData.versions = undefined;

}

}

this.delete( texture );

this.info.memory.textures --;
Expand Down