Просмотр исходного кода

WebGPURenderer: `getCache()` & `trackTimestamp` check optimization (#29245)

Co-authored-by: aardgoose <angus.sawyer@email.com>
aardgoose 1 год назад
Родитель
Сommit
4116f84281
2 измененных файлов с 7 добавлено и 3 удалено
  1. 1 0
      src/nodes/core/NodeUtils.js
  2. 6 3
      src/renderers/webgpu/WebGPUBackend.js

+ 1 - 0
src/nodes/core/NodeUtils.js

@@ -12,6 +12,7 @@ export function getCacheKey( object, force = false ) {
 	if ( object.isNode === true ) {
 
 		cacheKey += object.id;
+		object = object.getSelf();
 
 	}
 

+ 6 - 3
src/renderers/webgpu/WebGPUBackend.js

@@ -108,6 +108,8 @@ class WebGPUBackend extends Backend {
 
 		const alphaMode = parameters.alpha ? 'premultiplied' : 'opaque';
 
+		this.trackTimestamp = this.trackTimestamp && this.hasFeature( GPUFeatureName.TimestampQuery );
+
 		this.context.configure( {
 			device: this.device,
 			format: this.utils.getPreferredCanvasFormat(),
@@ -1129,7 +1131,7 @@ class WebGPUBackend extends Backend {
 
 	initTimestampQuery( renderContext, descriptor ) {
 
-		if ( ! this.hasFeature( GPUFeatureName.TimestampQuery ) || ! this.trackTimestamp ) return;
+		if ( ! this.trackTimestamp ) return;
 
 		const renderContextData = this.get( renderContext );
 
@@ -1159,10 +1161,11 @@ class WebGPUBackend extends Backend {
 
 	prepareTimestampBuffer( renderContext, encoder ) {
 
-		if ( ! this.hasFeature( GPUFeatureName.TimestampQuery ) || ! this.trackTimestamp ) return;
+		if ( ! this.trackTimestamp ) return;
 
 		const renderContextData = this.get( renderContext );
 
+
 		const size = 2 * BigInt64Array.BYTES_PER_ELEMENT;
 
 		if ( renderContextData.currentTimestampQueryBuffers === undefined ) {
@@ -1194,7 +1197,7 @@ class WebGPUBackend extends Backend {
 
 	async resolveTimestampAsync( renderContext, type = 'render' ) {
 
-		if ( ! this.hasFeature( GPUFeatureName.TimestampQuery ) || ! this.trackTimestamp ) return;
+		if ( ! this.trackTimestamp ) return;
 
 		const renderContextData = this.get( renderContext );
 

粤ICP备19079148号