소스 검색

WebGPURenderer: Bind groups cache per renderer (#28730)

sunag 1 년 전
부모
커밋
f43a827cbd
1개의 변경된 파일19개의 추가작업 그리고 1개의 파일을 삭제
  1. 19 1
      examples/jsm/nodes/core/NodeBuilder.js

+ 19 - 1
examples/jsm/nodes/core/NodeBuilder.js

@@ -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' ],
@@ -123,6 +123,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 );
@@ -151,6 +167,8 @@ class NodeBuilder {
 
 	_getBindGroup( groupName, bindings ) {
 
+		const bindGroupsCache = this.getBingGroupsCache();
+
 		// cache individual uniforms group
 
 		const bindingsArray = [];