From ea0c974bed82ae1e37c4fa5447750da7730822dc Mon Sep 17 00:00:00 2001 From: Nicklas Warming Jacobsen Date: Fri, 22 Oct 2021 14:58:24 +0200 Subject: [PATCH] webgl2: recreate surface texture in fn configure (#2067) Currently the configure function reuses the surface texture if it already exist, and will call Glow::Context::tex_storage_2d to reconfigure the texture. However doing so on an already configured texture will cause the browser warning: WebGL warning: texStorage(Multisample)?: Specified texture is immutable. and will NOT apply the new configuration such as new dimensions. Co-authored-by: Nicklas Warming Jacobsen --- wgpu-hal/src/gles/web.rs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/wgpu-hal/src/gles/web.rs b/wgpu-hal/src/gles/web.rs index 2fd0351c29..6d531dd797 100644 --- a/wgpu-hal/src/gles/web.rs +++ b/wgpu-hal/src/gles/web.rs @@ -188,10 +188,12 @@ impl crate::Surface for Surface { self.present_program = Some(Self::create_present_program(gl)); } - if self.texture.is_none() { - self.texture = Some(gl.create_texture().unwrap()); + if let Some(texture) = self.texture.take() { + gl.delete_texture(texture); } + self.texture = Some(gl.create_texture().unwrap()); + let desc = device.shared.describe_texture_format(config.format); gl.bind_texture(glow::TEXTURE_2D, self.texture); gl.tex_parameter_i32(