From e47e4c64dd7a0da0cdf557ccca5b9d6024fdc00e Mon Sep 17 00:00:00 2001 From: sunag Date: Fri, 14 Jul 2023 11:31:29 -0300 Subject: [PATCH] WebGPURenderer: Not crash if texture is not supported (#26423) --- .../jsm/renderers/webgpu/utils/WebGPUTextureUtils.js | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/examples/jsm/renderers/webgpu/utils/WebGPUTextureUtils.js b/examples/jsm/renderers/webgpu/utils/WebGPUTextureUtils.js index acbf064d389f0d..6b6e1eb87895a2 100644 --- a/examples/jsm/renderers/webgpu/utils/WebGPUTextureUtils.js +++ b/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 ) {