1
0
mirror of https://github.com/emilk/egui.git synced 2026-08-31 22:00:03 -04:00

Fix egui-wgpu performance regression (#3580)

Introduced in the recent multi-viewports work, we accidentally recreated
the wgpu surfaces every frame. This is now fixed.

I found this while improving the profiling of `eframe`
This commit is contained in:
Emil Ernerfeldt
2023-11-19 21:14:13 +01:00
committed by GitHub
parent 960b01b67a
commit 30ee478caf
14 changed files with 372 additions and 279 deletions

View File

@@ -67,21 +67,32 @@ impl RenderState {
depth_format: Option<wgpu::TextureFormat>,
msaa_samples: u32,
) -> Result<Self, WgpuError> {
let adapter = instance
.request_adapter(&wgpu::RequestAdapterOptions {
power_preference: config.power_preference,
compatible_surface: Some(surface),
force_fallback_adapter: false,
})
.await
.ok_or(WgpuError::NoSuitableAdapterFound)?;
crate::profile_scope!("RenderState::create"); // async yield give bad names using `profile_function`
let target_format =
crate::preferred_framebuffer_format(&surface.get_capabilities(&adapter).formats)?;
let adapter = {
crate::profile_scope!("request_adapter");
instance
.request_adapter(&wgpu::RequestAdapterOptions {
power_preference: config.power_preference,
compatible_surface: Some(surface),
force_fallback_adapter: false,
})
.await
.ok_or(WgpuError::NoSuitableAdapterFound)?
};
let (device, queue) = adapter
.request_device(&(*config.device_descriptor)(&adapter), None)
.await?;
let capabilities = {
crate::profile_scope!("get_capabilities");
surface.get_capabilities(&adapter).formats
};
let target_format = crate::preferred_framebuffer_format(&capabilities)?;
let (device, queue) = {
crate::profile_scope!("request_device");
adapter
.request_device(&(*config.device_descriptor)(&adapter), None)
.await?
};
let renderer = Renderer::new(&device, target_format, depth_format, msaa_samples);