1
0
mirror of https://github.com/emilk/egui.git synced 2026-06-26 22:53:14 -04:00

Don't call destroy on textures on webgl

This commit is contained in:
Andreas Reich
2025-07-02 16:01:00 +02:00
parent 3345c36235
commit fc0b4cfe95
2 changed files with 12 additions and 1 deletions

View File

@@ -234,6 +234,7 @@ impl RenderState {
let renderer = Renderer::new(
&device,
adapter.get_info().backend,
target_format,
depth_format,
msaa_samples,

View File

@@ -196,6 +196,8 @@ pub struct Renderer {
dithering: bool,
backend: wgpu::Backend,
/// Storage for resources shared with all invocations of [`CallbackTrait`]'s methods.
///
/// See also [`CallbackTrait`].
@@ -209,6 +211,7 @@ impl Renderer {
/// [`wgpu::TextureFormat::Bgra8Unorm`], i.e. in gamma-space.
pub fn new(
device: &wgpu::Device,
backend: wgpu::Backend,
output_color_format: wgpu::TextureFormat,
output_depth_format: Option<wgpu::TextureFormat>,
msaa_samples: u32,
@@ -403,6 +406,9 @@ impl Renderer {
next_user_texture_id: 0,
samplers: HashMap::default(),
dithering,
backend,
callback_resources: CallbackResources::default(),
}
}
@@ -687,7 +693,11 @@ impl Renderer {
pub fn free_texture(&mut self, id: &epaint::TextureId) {
if let Some(texture) = self.textures.remove(id).and_then(|t| t.texture) {
texture.destroy();
// TODO: explain why.
let is_webgl = self.backend == wgpu::Backend::Gl && cfg!(target_arch = "wasm32");
if !is_webgl {
texture.destroy();
}
}
}