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 <nwj@skybox.gg>
This commit is contained in:
Nicklas Warming Jacobsen 2021-10-22 14:58:24 +02:00 committed by GitHub
parent 3ec17cf9ed
commit ea0c974bed
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -188,10 +188,12 @@ impl crate::Surface<super::Api> 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(