Skip to content

Commit

Permalink
bind groups cache per renderer
Browse files Browse the repository at this point in the history
  • Loading branch information
sunag committed Jun 24, 2024
1 parent 9f5fdae commit 6fe58cc
Showing 1 changed file with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion examples/jsm/nodes/core/NodeBuilder.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ import ChainMap from '../../renderers/common/ChainMap.js';

import PMREMGenerator from '../../renderers/common/extras/PMREMGenerator.js';

const bindGroupsCache = new ChainMap();
const rendererCache = new WeakMap();

const typeFromLength = new Map( [
[ 2, 'vec2' ],
Expand Down Expand Up @@ -122,6 +122,22 @@ class NodeBuilder {

}

getBingGroupsCache() {

let bindGroupsCache = rendererCache.get( this.renderer );

if ( bindGroupsCache === undefined ) {

bindGroupsCache = new ChainMap();

rendererCache.set( this.renderer, bindGroupsCache );

}

return bindGroupsCache;

}

createRenderTarget( width, height, options ) {

return new RenderTarget( width, height, options );
Expand Down Expand Up @@ -150,6 +166,8 @@ class NodeBuilder {

_getBindGroup( groupName, bindings ) {

const bindGroupsCache = this.getBingGroupsCache();

// cache individual uniforms group

const bindingsArray = [];
Expand Down

0 comments on commit 6fe58cc

Please sign in to comment.