From 16353c9ccff5bd8837ddb019b021c8323c79d995 Mon Sep 17 00:00:00 2001 From: Mugen87 Date: Wed, 16 Sep 2020 18:30:52 +0200 Subject: [PATCH] WebGPUBindings: Make texture update more robust. --- .../jsm/renderers/webgpu/WebGPUBindings.js | 28 ++++++++++++------- 1 file changed, 18 insertions(+), 10 deletions(-) diff --git a/examples/jsm/renderers/webgpu/WebGPUBindings.js b/examples/jsm/renderers/webgpu/WebGPUBindings.js index 1f617e088eb009..df9f7b447abc68 100644 --- a/examples/jsm/renderers/webgpu/WebGPUBindings.js +++ b/examples/jsm/renderers/webgpu/WebGPUBindings.js @@ -121,14 +121,18 @@ class WebGPUBindings { const material = object.material; const texture = material[ binding.name ]; - textures.updateSampler( texture ); + if ( texture !== null ) { - const samplerGPU = textures.getSampler( texture ); + textures.updateSampler( texture ); - if ( binding.samplerGPU !== samplerGPU ) { + const samplerGPU = textures.getSampler( texture ); - binding.samplerGPU = samplerGPU; - needsBindGroupRefresh = true; + if ( binding.samplerGPU !== samplerGPU ) { + + binding.samplerGPU = samplerGPU; + needsBindGroupRefresh = true; + + } } @@ -137,13 +141,17 @@ class WebGPUBindings { const material = object.material; const texture = material[ binding.name ]; - const forceUpdate = textures.updateTexture( texture ); - const textureGPU = textures.getTextureGPU( texture ); + if ( texture !== null ) { + + const forceUpdate = textures.updateTexture( texture ); + const textureGPU = textures.getTextureGPU( texture ); + + if ( binding.textureGPU !== textureGPU || forceUpdate === true ) { - if ( binding.textureGPU !== textureGPU || forceUpdate === true ) { + binding.textureGPU = textureGPU; + needsBindGroupRefresh = true; - binding.textureGPU = textureGPU; - needsBindGroupRefresh = true; + } }