From 8b0c9acaef10bf67f82536165861eae12833301b Mon Sep 17 00:00:00 2001 From: Michael Herzog Date: Sat, 2 Nov 2024 21:17:32 +0100 Subject: [PATCH] WebGPURenderer: Make sure default instance of `CompressedTexture` works. (#29788) --- src/renderers/common/Textures.js | 14 +++++++++++--- src/renderers/webgpu/utils/WebGPUTextureUtils.js | 4 ++++ 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/src/renderers/common/Textures.js b/src/renderers/common/Textures.js index 6907194c8236c1..84635f0f95abfe 100644 --- a/src/renderers/common/Textures.js +++ b/src/renderers/common/Textures.js @@ -300,8 +300,8 @@ class Textures extends DataMap { if ( image.image !== undefined ) image = image.image; - target.width = image.width; - target.height = image.height; + target.width = image.width || 1; + target.height = image.height || 1; target.depth = texture.isCubeTexture ? 6 : ( image.depth || 1 ); } else { @@ -320,7 +320,15 @@ class Textures extends DataMap { if ( texture.isCompressedTexture ) { - mipLevelCount = texture.mipmaps.length; + if ( texture.mipmaps ) { + + mipLevelCount = texture.mipmaps.length; + + } else { + + mipLevelCount = 1; + + } } else { diff --git a/src/renderers/webgpu/utils/WebGPUTextureUtils.js b/src/renderers/webgpu/utils/WebGPUTextureUtils.js index b24be132721844..7f7a271318cabe 100644 --- a/src/renderers/webgpu/utils/WebGPUTextureUtils.js +++ b/src/renderers/webgpu/utils/WebGPUTextureUtils.js @@ -952,6 +952,10 @@ export function getFormat( texture, device = null ) { formatGPU = ( colorSpace === SRGBColorSpace ) ? GPUTextureFormat.ASTC12x12UnormSRGB : GPUTextureFormat.ASTC12x12Unorm; break; + case RGBAFormat: + formatGPU = ( colorSpace === SRGBColorSpace ) ? GPUTextureFormat.RGBA8UnormSRGB : GPUTextureFormat.RGBA8Unorm; + break; + default: console.error( 'WebGPURenderer: Unsupported texture format.', format );