Browse Source

WebGPURenderer: Not crash if texture is not supported (#26423)

sunag 2 years ago
parent
commit
e47e4c64dd
1 changed files with 11 additions and 0 deletions
  1. 11 0
      examples/jsm/renderers/webgpu/utils/WebGPUTextureUtils.js

+ 11 - 0
examples/jsm/renderers/webgpu/utils/WebGPUTextureUtils.js

@@ -144,6 +144,14 @@ class WebGPUTextureUtils {
 
 		} else {
 
+			if ( format === undefined ) {
+
+				console.warn( 'WebGPURenderer: Texture format not supported.' );
+
+				return this.createDefaultTexture( texture );
+
+			}
+
 			textureData.texture = backend.device.createTexture( textureDescriptorGPU );
 
 		}
@@ -201,6 +209,9 @@ class WebGPUTextureUtils {
 
 		const { needsMipmaps, textureDescriptorGPU } = textureData;
 
+		if ( textureDescriptorGPU === undefined ) // unsupported texture format
+			return;
+
 		// transfer texture data
 
 		if ( texture.isDataTexture || texture.isDataArrayTexture || texture.isData3DTexture ) {