mirror of
https://github.com/emilk/egui.git
synced 2026-06-26 22:53:14 -04:00
Update to wgpu 29 (#7990)
* [x] I have followed the instructions in the PR template This updates wgpu to v29 across the egui crate stack. There a a few API changes due to the requirement to provide a display handle up front to properly support GLES on linux. I have done my best to make the api changes as reasonable as possible, but I don't have all the greater project context, so lmk if things should be done a bit differently. I've also updated glow to 0.17 to make cargo deny happy, there are no source changes. I'm not sure how you want to land these. --------- Co-authored-by: lucasmerlin <hi@lucasmerlin.me>
This commit is contained in:
committed by
GitHub
parent
b077cf9102
commit
a59e803f25
@@ -184,9 +184,17 @@ impl<'app> WgpuWinitApp<'app> {
|
||||
builder: ViewportBuilder,
|
||||
) -> crate::Result<&mut WgpuWinitRunning<'app>> {
|
||||
profiling::function_scope!();
|
||||
// Inject the display handle into the wgpu setup so that wgpu can create
|
||||
// surfaces on platforms that require it (e.g. GLES on Wayland).
|
||||
let mut wgpu_options = self.native_options.wgpu_options.clone();
|
||||
if let egui_wgpu::WgpuSetup::CreateNew(ref mut create_new) = wgpu_options.wgpu_setup
|
||||
&& create_new.display_handle.is_none()
|
||||
{
|
||||
create_new.display_handle = Some(Box::new(event_loop.owned_display_handle()));
|
||||
}
|
||||
let mut painter = pollster::block_on(egui_wgpu::winit::Painter::new(
|
||||
egui_ctx.clone(),
|
||||
self.native_options.wgpu_options.clone(),
|
||||
wgpu_options,
|
||||
self.native_options.viewport.transparent.unwrap_or(false),
|
||||
egui_wgpu::RendererOptions {
|
||||
msaa_samples: self.native_options.multisampling as _,
|
||||
|
||||
@@ -38,6 +38,7 @@ mod web_painter_wgpu;
|
||||
pub use backend::*;
|
||||
|
||||
use egui::Theme;
|
||||
use js_sys::Object;
|
||||
use wasm_bindgen::prelude::*;
|
||||
use web_sys::{Document, MediaQueryList, Node};
|
||||
|
||||
@@ -370,5 +371,5 @@ pub fn percent_decode(s: &str) -> String {
|
||||
|
||||
/// Are we running inside the Safari browser?
|
||||
pub fn is_safari_browser() -> bool {
|
||||
web_sys::window().is_some_and(|window| window.has_own_property(&JsValue::from("safari")))
|
||||
web_sys::window().is_some_and(|window| Object::has_own(&window, &JsValue::from("safari")))
|
||||
}
|
||||
|
||||
@@ -15,13 +15,14 @@ pub(crate) struct WebPainterWgpu {
|
||||
surface: wgpu::Surface<'static>,
|
||||
surface_configuration: wgpu::SurfaceConfiguration,
|
||||
render_state: Option<RenderState>,
|
||||
on_surface_error: Arc<dyn Fn(wgpu::SurfaceError) -> SurfaceErrorAction>,
|
||||
on_surface_status: Arc<dyn Fn(&wgpu::CurrentSurfaceTexture) -> SurfaceErrorAction>,
|
||||
depth_stencil_format: Option<wgpu::TextureFormat>,
|
||||
depth_texture_view: Option<wgpu::TextureView>,
|
||||
screen_capture_state: Option<CaptureState>,
|
||||
capture_tx: CaptureSender,
|
||||
capture_rx: CaptureReceiver,
|
||||
ctx: egui::Context,
|
||||
needs_reconfigure: bool,
|
||||
}
|
||||
|
||||
impl WebPainterWgpu {
|
||||
@@ -105,11 +106,12 @@ impl WebPainterWgpu {
|
||||
surface_configuration,
|
||||
depth_stencil_format,
|
||||
depth_texture_view: None,
|
||||
on_surface_error: Arc::clone(&options.wgpu_options.on_surface_error) as _,
|
||||
on_surface_status: Arc::clone(&options.wgpu_options.on_surface_status) as _,
|
||||
screen_capture_state: None,
|
||||
capture_tx,
|
||||
capture_rx,
|
||||
ctx,
|
||||
needs_reconfigure: false,
|
||||
})
|
||||
}
|
||||
}
|
||||
@@ -195,18 +197,28 @@ impl WebPainter for WebPainterWgpu {
|
||||
);
|
||||
}
|
||||
|
||||
if self.needs_reconfigure {
|
||||
self.surface
|
||||
.configure(&render_state.device, &self.surface_configuration);
|
||||
self.needs_reconfigure = false;
|
||||
}
|
||||
|
||||
let output_frame = match self.surface.get_current_texture() {
|
||||
Ok(frame) => frame,
|
||||
Err(err) => match (*self.on_surface_error)(err) {
|
||||
SurfaceErrorAction::RecreateSurface => {
|
||||
self.surface
|
||||
.configure(&render_state.device, &self.surface_configuration);
|
||||
return Ok(());
|
||||
wgpu::CurrentSurfaceTexture::Success(frame) => frame,
|
||||
wgpu::CurrentSurfaceTexture::Suboptimal(frame) => {
|
||||
self.needs_reconfigure = true;
|
||||
frame
|
||||
}
|
||||
other => {
|
||||
match (*self.on_surface_status)(&other) {
|
||||
SurfaceErrorAction::RecreateSurface => {
|
||||
self.surface
|
||||
.configure(&render_state.device, &self.surface_configuration);
|
||||
}
|
||||
SurfaceErrorAction::SkipFrame => {}
|
||||
}
|
||||
SurfaceErrorAction::SkipFrame => {
|
||||
return Ok(());
|
||||
}
|
||||
},
|
||||
return Ok(());
|
||||
}
|
||||
};
|
||||
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user