From 7f81524ff024157c28f1f481c199b1d8a772ba22 Mon Sep 17 00:00:00 2001 From: Andreas Reich Date: Sun, 6 Oct 2024 17:54:33 +0200 Subject: [PATCH] Update comment why it's important to destroy textures after submit, not before --- crates/egui-wgpu/src/winit.rs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/crates/egui-wgpu/src/winit.rs b/crates/egui-wgpu/src/winit.rs index d554159527e..189afbf9545 100644 --- a/crates/egui-wgpu/src/winit.rs +++ b/crates/egui-wgpu/src/winit.rs @@ -684,6 +684,9 @@ impl Painter { vsync_sec += start.elapsed().as_secs_f32(); }; + // Free textures marked for destruction **after** queue submit since they might still be used in the current frame. + // Calling `wgpu::Texture::destroy` on a texture that is still in use would invalidate the command buffer(s) it is used in. + // However, once we called `wgpu::Queue::submit`, it is up for wgpu to determine how long the underlying gpu resource has to live. { let mut renderer = render_state.renderer.write(); for id in &textures_delta.free {