mirror of
https://github.com/emilk/egui.git
synced 2026-08-30 21:30:03 -04:00
Don't call destroy on textures on webgl
This commit is contained in:
@@ -234,6 +234,7 @@ impl RenderState {
|
|||||||
|
|
||||||
let renderer = Renderer::new(
|
let renderer = Renderer::new(
|
||||||
&device,
|
&device,
|
||||||
|
adapter.get_info().backend,
|
||||||
target_format,
|
target_format,
|
||||||
depth_format,
|
depth_format,
|
||||||
msaa_samples,
|
msaa_samples,
|
||||||
|
|||||||
@@ -196,6 +196,8 @@ pub struct Renderer {
|
|||||||
|
|
||||||
dithering: bool,
|
dithering: bool,
|
||||||
|
|
||||||
|
backend: wgpu::Backend,
|
||||||
|
|
||||||
/// Storage for resources shared with all invocations of [`CallbackTrait`]'s methods.
|
/// Storage for resources shared with all invocations of [`CallbackTrait`]'s methods.
|
||||||
///
|
///
|
||||||
/// See also [`CallbackTrait`].
|
/// See also [`CallbackTrait`].
|
||||||
@@ -209,6 +211,7 @@ impl Renderer {
|
|||||||
/// [`wgpu::TextureFormat::Bgra8Unorm`], i.e. in gamma-space.
|
/// [`wgpu::TextureFormat::Bgra8Unorm`], i.e. in gamma-space.
|
||||||
pub fn new(
|
pub fn new(
|
||||||
device: &wgpu::Device,
|
device: &wgpu::Device,
|
||||||
|
backend: wgpu::Backend,
|
||||||
output_color_format: wgpu::TextureFormat,
|
output_color_format: wgpu::TextureFormat,
|
||||||
output_depth_format: Option<wgpu::TextureFormat>,
|
output_depth_format: Option<wgpu::TextureFormat>,
|
||||||
msaa_samples: u32,
|
msaa_samples: u32,
|
||||||
@@ -403,6 +406,9 @@ impl Renderer {
|
|||||||
next_user_texture_id: 0,
|
next_user_texture_id: 0,
|
||||||
samplers: HashMap::default(),
|
samplers: HashMap::default(),
|
||||||
dithering,
|
dithering,
|
||||||
|
|
||||||
|
backend,
|
||||||
|
|
||||||
callback_resources: CallbackResources::default(),
|
callback_resources: CallbackResources::default(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -687,7 +693,11 @@ impl Renderer {
|
|||||||
|
|
||||||
pub fn free_texture(&mut self, id: &epaint::TextureId) {
|
pub fn free_texture(&mut self, id: &epaint::TextureId) {
|
||||||
if let Some(texture) = self.textures.remove(id).and_then(|t| t.texture) {
|
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();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user