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

WebGPUTextures: Monitor number of textures when using render targets.

Mugen87 4 лет назад
Родитель
Сommit
d85592acaa
1 измененных файлов с 8 добавлено и 0 удалено
  1. 8 0
      examples/jsm/renderers/webgpu/WebGPUTextures.js

+ 8 - 0
examples/jsm/renderers/webgpu/WebGPUTextures.js

@@ -209,6 +209,8 @@ class WebGPUTextures {
 				usage: GPUTextureUsage.OUTPUT_ATTACHMENT | GPUTextureUsage.SAMPLED
 				usage: GPUTextureUsage.OUTPUT_ATTACHMENT | GPUTextureUsage.SAMPLED
 			} );
 			} );
 
 
+			this.info.memory.textures ++;
+
 			renderTargetProperties.colorTextureGPU = colorTextureGPU;
 			renderTargetProperties.colorTextureGPU = colorTextureGPU;
 			renderTargetProperties.colorTextureFormat = colorTextureFormat;
 			renderTargetProperties.colorTextureFormat = colorTextureFormat;
 
 
@@ -235,6 +237,8 @@ class WebGPUTextures {
 					usage: GPUTextureUsage.OUTPUT_ATTACHMENT
 					usage: GPUTextureUsage.OUTPUT_ATTACHMENT
 				} );
 				} );
 
 
+				this.info.memory.textures ++;
+
 				renderTargetProperties.depthTextureGPU = depthTextureGPU;
 				renderTargetProperties.depthTextureGPU = depthTextureGPU;
 				renderTargetProperties.depthTextureFormat = depthTextureFormat;
 				renderTargetProperties.depthTextureFormat = depthTextureFormat;
 
 
@@ -727,10 +731,14 @@ function onRenderTargetDispose( event ) {
 	renderTargetProperties.colorTextureGPU.destroy();
 	renderTargetProperties.colorTextureGPU.destroy();
 	properties.remove( renderTarget.texture );
 	properties.remove( renderTarget.texture );
 
 
+	this.info.memory.textures --;
+
 	if ( renderTarget.depthBuffer === true ) {
 	if ( renderTarget.depthBuffer === true ) {
 
 
 		renderTargetProperties.depthTextureGPU.destroy();
 		renderTargetProperties.depthTextureGPU.destroy();
 
 
+		this.info.memory.textures --;
+
 		if ( renderTarget.depthTexture !== null ) {
 		if ( renderTarget.depthTexture !== null ) {
 
 
 			properties.remove( renderTarget.depthTexture );
 			properties.remove( renderTarget.depthTexture );