From b4afdc5c530b231e913416381d3082bb533bb2b2 Mon Sep 17 00:00:00 2001 From: Dzmitry Malyshau Date: Wed, 6 Nov 2024 21:44:44 -0800 Subject: [PATCH] egl: destroy the previous surface on resize --- blade-graphics/README.md | 5 +++++ blade-graphics/src/gles/egl.rs | 10 ++++++++-- docs/CHANGELOG.md | 2 ++ 3 files changed, 15 insertions(+), 2 deletions(-) diff --git a/blade-graphics/README.md b/blade-graphics/README.md index 6a1c549..4a5c63e 100644 --- a/blade-graphics/README.md +++ b/blade-graphics/README.md @@ -48,6 +48,11 @@ RUSTFLAGS="--cfg gles" CARGO_TARGET_DIR=./target-gl cargo run --example bunnymar This path can be activated on all platforms via Angle library. For example, on macOS it's sufficient to place `libEGL.dylib` and `libGLESv2.dylib` in the working directory. +On Windows, the quotes aren't expected: +```bash +set RUSTFLAGS=--cfg gles +``` + ### WebGL2 Following command will start a web server offering the `bunnymark` example: diff --git a/blade-graphics/src/gles/egl.rs b/blade-graphics/src/gles/egl.rs index 3bf9017..e72d3bc 100644 --- a/blade-graphics/src/gles/egl.rs +++ b/blade-graphics/src/gles/egl.rs @@ -468,8 +468,7 @@ impl super::Context { .unwrap() }, }; - //TODO: remove old surface - inner.swapchain = Some(Swapchain { + let old_swapchain = inner.swapchain.replace(Swapchain { surface, extent: config.size, format, @@ -478,6 +477,13 @@ impl super::Context { crate::DisplaySync::Recent | crate::DisplaySync::Tear => 0, }, }); + if let Some(s) = old_swapchain { + inner + .egl + .instance + .destroy_surface(inner.egl.display, s.surface) + .unwrap(); + } let format_desc = super::describe_texture_format(format); inner.egl.make_current(); diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.md index a7135da..25292e9 100644 --- a/docs/CHANGELOG.md +++ b/docs/CHANGELOG.md @@ -10,6 +10,8 @@ Changelog for Blade - Metal: - support for workgroup memory - concurrent compute dispatches + - Egl: + - destroy old surface on resize ## blade-graphics-0.5, blade-macros-0.3, blade-egui-0.4, blade-util-0.1 (27 Aug 2024)