|
@@ -29,13 +29,13 @@ class WebGPURenderPipelines {
|
|
const properties = this.properties;
|
|
const properties = this.properties;
|
|
|
|
|
|
const material = object.material;
|
|
const material = object.material;
|
|
-
|
|
|
|
const materialProperties = properties.get( material );
|
|
const materialProperties = properties.get( material );
|
|
- const objectProperties = properties.get( object );
|
|
|
|
|
|
|
|
- let currentPipeline = objectProperties.currentPipeline;
|
|
|
|
|
|
+ const cache = this._getCache( object );
|
|
|
|
+
|
|
|
|
+ let currentPipeline;
|
|
|
|
|
|
- if ( this._needsUpdate( object ) ) {
|
|
|
|
|
|
+ if ( this._needsUpdate( object, cache ) ) {
|
|
|
|
|
|
// get shader
|
|
// get shader
|
|
|
|
|
|
@@ -64,7 +64,7 @@ class WebGPURenderPipelines {
|
|
// determine render pipeline
|
|
// determine render pipeline
|
|
|
|
|
|
currentPipeline = this._acquirePipeline( stageVertex, stageFragment, object, nodeBuilder );
|
|
currentPipeline = this._acquirePipeline( stageVertex, stageFragment, object, nodeBuilder );
|
|
- objectProperties.currentPipeline = currentPipeline;
|
|
|
|
|
|
+ cache.currentPipeline = currentPipeline;
|
|
|
|
|
|
// keep track of all pipelines which are used by a material
|
|
// keep track of all pipelines which are used by a material
|
|
|
|
|
|
@@ -98,6 +98,10 @@ class WebGPURenderPipelines {
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ } else {
|
|
|
|
+
|
|
|
|
+ currentPipeline = cache.currentPipeline;
|
|
|
|
+
|
|
}
|
|
}
|
|
|
|
|
|
return currentPipeline;
|
|
return currentPipeline;
|
|
@@ -174,6 +178,21 @@ class WebGPURenderPipelines {
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ _getCache( object ) {
|
|
|
|
+
|
|
|
|
+ let cache = this.objectCache.get( object );
|
|
|
|
+
|
|
|
|
+ if ( cache === undefined ) {
|
|
|
|
+
|
|
|
|
+ cache = {};
|
|
|
|
+ this.objectCache.set( object, cache );
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ return cache;
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+
|
|
_releasePipeline( pipeline ) {
|
|
_releasePipeline( pipeline ) {
|
|
|
|
|
|
if ( -- pipeline.usedTimes === 0 ) {
|
|
if ( -- pipeline.usedTimes === 0 ) {
|
|
@@ -204,16 +223,7 @@ class WebGPURenderPipelines {
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
- _needsUpdate( object ) {
|
|
|
|
-
|
|
|
|
- let cache = this.objectCache.get( object );
|
|
|
|
-
|
|
|
|
- if ( cache === undefined ) {
|
|
|
|
-
|
|
|
|
- cache = {};
|
|
|
|
- this.objectCache.set( object, cache );
|
|
|
|
-
|
|
|
|
- }
|
|
|
|
|
|
+ _needsUpdate( object, cache ) {
|
|
|
|
|
|
const material = object.material;
|
|
const material = object.material;
|
|
|
|
|