diff --git a/Cargo.lock b/Cargo.lock index 2cc5ef7ef..393a346c8 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -31,9 +31,9 @@ dependencies = [ [[package]] name = "accesskit_consumer" -version = "0.10.0" +version = "0.12.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "df122220244ca3ab93f6a42da59a5f8b379c8846dbcaedf922d95636d22c4e10" +checksum = "3f47393f706a2d2f9d1ebd109351f886afd256a09d2308861a6dec0853a625e2" dependencies = [ "accesskit", "parking_lot", @@ -41,9 +41,9 @@ dependencies = [ [[package]] name = "accesskit_macos" -version = "0.2.1" +version = "0.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "55c97d7b5cbb2409e05b016406a1bd057237d120205cb63220ca86c2ea3790a1" +checksum = "fabafb94d8a4dd6b20fe4112f943756ff8dc9778e3d742fb5478bf7f000a3282" dependencies = [ "accesskit", "accesskit_consumer", @@ -54,9 +54,9 @@ dependencies = [ [[package]] name = "accesskit_windows" -version = "0.10.1" +version = "0.10.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4b0cfda25182b83b24e350434a3f63676252a00a295f32760a14d3f55feb8493" +checksum = "662496f45a2e2ddff05e28d0a9fc2b319cc4f886d3664e3469c3d30800598962" dependencies = [ "accesskit", "accesskit_consumer", @@ -69,9 +69,9 @@ dependencies = [ [[package]] name = "accesskit_winit" -version = "0.7.1" +version = "0.7.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cdf20fecd6573e03bebcb4de267f82431e5ea39a293b62aa51a45bdfd69ef39b" +checksum = "2f270416d033ab5b2a8fa72a976dfdad0db1ea194721f16cadbdb45ff219779f" dependencies = [ "accesskit", "accesskit_macos", @@ -195,9 +195,9 @@ checksum = "8da52d66c7071e2e3fa2a1e5c6d088fec47b593032b254f5e980de8ea54454d6" [[package]] name = "ash" -version = "0.37.1+1.3.235" +version = "0.37.2+1.3.238" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "911015c962d56e2e4052f40182ca5462ba60a3d2ff04e827c365a0ab3d65726d" +checksum = "28bf19c1f0a470be5fbf7522a308a05df06610252c5bcf5143e1b23f629a9a03" dependencies = [ "libloading", ] @@ -728,6 +728,12 @@ version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3d7b894f5411737b7867f4827955924d7c254fc9f4d91a6aad6b097804b1018b" +[[package]] +name = "com-rs" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bf43edc576402991846b093a7ca18a3477e0ef9c588cde84964b5d3e43016642" + [[package]] name = "combine" version = "4.6.6" @@ -933,7 +939,7 @@ version = "0.1.0" dependencies = [ "eframe", "egui_glow", - "glow", + "glow 0.11.2", ] [[package]] @@ -943,7 +949,7 @@ dependencies = [ "console_error_panic_hook", "eframe", "egui_glow", - "glow", + "glow 0.11.2", "three-d", "wasm-bindgen", "wasm-bindgen-futures", @@ -1016,9 +1022,9 @@ dependencies = [ [[package]] name = "d3d12" -version = "0.5.0" +version = "0.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "827914e1f53b1e0e025ecd3d967a7836b7bcb54520f90e21ef8df7b4d88a2759" +checksum = "d8f0de2f5a8e7bd4a9eec0e3c781992a4ce1724f68aec7d7a3715344de8b39da" dependencies = [ "bitflags", "libloading", @@ -1316,7 +1322,7 @@ dependencies = [ "egui-wgpu", "egui-winit", "egui_glow", - "glow", + "glow 0.11.2", "glutin 0.30.2", "image", "js-sys", @@ -1456,7 +1462,7 @@ dependencies = [ "document-features", "egui", "egui-winit", - "glow", + "glow 0.11.2", "glutin 0.30.2", "memoffset", "puffin", @@ -1953,6 +1959,18 @@ dependencies = [ "web-sys", ] +[[package]] +name = "glow" +version = "0.12.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8edf6019dff2d92ad27c1e3ff82ad50a0aea5b01370353cc928bfdc33e95925c" +dependencies = [ + "js-sys", + "slotmap", + "wasm-bindgen", + "web-sys", +] + [[package]] name = "glutin" version = "0.29.1" @@ -2100,6 +2118,19 @@ dependencies = [ "bitflags", ] +[[package]] +name = "gpu-allocator" +version = "0.21.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "434618454f74b63f9b39328298097256977c41ea0ba9d75a47238b77790b6163" +dependencies = [ + "backtrace", + "log", + "thiserror", + "winapi", + "windows 0.43.0", +] + [[package]] name = "gpu-descriptor" version = "0.2.3" @@ -2157,6 +2188,21 @@ dependencies = [ "ahash 0.7.6", ] +[[package]] +name = "hassle-rs" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "90601c6189668c7345fc53842cb3f3a3d872203d523be1b3cb44a36a3e62fb85" +dependencies = [ + "bitflags", + "com-rs", + "libc", + "libloading", + "thiserror", + "widestring", + "winapi", +] + [[package]] name = "heck" version = "0.4.0" @@ -2564,9 +2610,9 @@ dependencies = [ [[package]] name = "naga" -version = "0.10.0" +version = "0.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "262d2840e72dbe250e8cf2f522d080988dfca624c4112c096238a4845f591707" +checksum = "5eafe22a23b797c9bc227c6c896419b26b5bb88fa903417a3adaed08778850d5" dependencies = [ "bit-set", "bitflags", @@ -3862,7 +3908,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f7a5a1017829335f6761bdbae2daf3021a88314a1f8d5f188c9b62ce62e2fd31" dependencies = [ "cgmath", - "glow", + "glow 0.11.2", "instant", "thiserror", "three-d-asset", @@ -4566,15 +4612,17 @@ dependencies = [ [[package]] name = "wgpu" -version = "0.14.2" +version = "0.15.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "81f643110d228fd62a60c5ed2ab56c4d5b3704520bd50561174ec4ec74932937" +checksum = "d14c6bfcf3b10f4273f522a95994553c0a5f2934976e62e61a720ae4bc2eb8f2" dependencies = [ "arrayvec 0.7.2", + "cfg-if", "js-sys", "log", "naga", "parking_lot", + "profiling", "raw-window-handle 0.5.0", "smallvec", "static_assertions", @@ -4588,14 +4636,13 @@ dependencies = [ [[package]] name = "wgpu-core" -version = "0.14.2" +version = "0.15.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6000d1284ef8eec6076fd5544a73125fd7eb9b635f18dceeb829d826f41724ca" +checksum = "be1f61be28e557a6ecb2506cac06c63fae3b6d302a006f38195a7a80995abeb9" dependencies = [ "arrayvec 0.7.2", "bit-vec", "bitflags", - "cfg_aliases", "codespan-reporting", "fxhash", "log", @@ -4612,9 +4659,9 @@ dependencies = [ [[package]] name = "wgpu-hal" -version = "0.14.1" +version = "0.15.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3cc320a61acb26be4f549c9b1b53405c10a223fbfea363ec39474c32c348d12f" +checksum = "82e95792925fe3d58950b9a5c2a191caa145e2bc570e2d233f0d7320f6a8e814" dependencies = [ "android_system_properties", "arrayvec 0.7.2", @@ -4626,11 +4673,14 @@ dependencies = [ "d3d12", "foreign-types 0.3.2", "fxhash", - "glow", + "glow 0.12.0", "gpu-alloc", + "gpu-allocator", "gpu-descriptor", + "hassle-rs", "js-sys", "khronos-egl", + "libc", "libloading", "log", "metal", @@ -4651,11 +4701,13 @@ dependencies = [ [[package]] name = "wgpu-types" -version = "0.14.1" +version = "0.15.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fb6b28ef22cac17b9109b25b3bf8c9a103eeb293d7c5f78653979b09140375f6" +checksum = "ecf8cfcbf98f94cc8bd5981544c687140cf9d3948e2ab83849367ead2cd737cf" dependencies = [ "bitflags", + "js-sys", + "web-sys", ] [[package]] @@ -4669,6 +4721,12 @@ dependencies = [ "once_cell", ] +[[package]] +name = "widestring" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "17882f045410753661207383517a6f62ec3dbeb6a4ed2acce01f0728238d1983" + [[package]] name = "winapi" version = "0.3.9" @@ -4738,6 +4796,21 @@ dependencies = [ "windows_x86_64_msvc 0.42.0", ] +[[package]] +name = "windows" +version = "0.43.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "04662ed0e3e5630dfa9b26e4cb823b817f1a9addda855d973a9458c236556244" +dependencies = [ + "windows_aarch64_gnullvm", + "windows_aarch64_msvc 0.42.0", + "windows_i686_gnu 0.42.0", + "windows_i686_msvc 0.42.0", + "windows_x86_64_gnu 0.42.0", + "windows_x86_64_gnullvm", + "windows_x86_64_msvc 0.42.0", +] + [[package]] name = "windows-implement" version = "0.42.0" diff --git a/crates/eframe/Cargo.toml b/crates/eframe/Cargo.toml index e7fb49355..b5012e759 100644 --- a/crates/eframe/Cargo.toml +++ b/crates/eframe/Cargo.toml @@ -116,7 +116,7 @@ image = { version = "0.24", optional = true, default-features = false, features "png", ] } puffin = { version = "0.14", optional = true } -wgpu = { version = "0.14", optional = true } +wgpu = { version = "0.15.0", optional = true } # ------------------------------------------- # web: @@ -172,4 +172,4 @@ web-sys = { version = "0.3.58", features = [ # optional web: egui-wgpu = { version = "0.20.0", path = "../egui-wgpu", optional = true } # if wgpu is used, use it without (!) winit tts = { version = "0.24", optional = true } -wgpu = { version = "0.14", optional = true, features = ["webgl"] } +wgpu = { version = "0.15.0", optional = true, features = ["webgl"] } diff --git a/crates/eframe/src/lib.rs b/crates/eframe/src/lib.rs index f0b6c69f5..4c4da674c 100644 --- a/crates/eframe/src/lib.rs +++ b/crates/eframe/src/lib.rs @@ -226,7 +226,7 @@ pub enum Error { #[cfg(feature = "wgpu")] #[error("WGPU error: {0}")] - Wgpu(#[from] wgpu::RequestDeviceError), + Wgpu(#[from] egui_wgpu::WgpuError), } pub type Result = std::result::Result; diff --git a/crates/eframe/src/native/run.rs b/crates/eframe/src/native/run.rs index d4eee2f5b..e0a1b52c8 100644 --- a/crates/eframe/src/native/run.rs +++ b/crates/eframe/src/native/run.rs @@ -958,7 +958,7 @@ mod wgpu_integration { fn set_window( &mut self, window: winit::window::Window, - ) -> std::result::Result<(), wgpu::RequestDeviceError> { + ) -> std::result::Result<(), egui_wgpu::WgpuError> { self.window = Some(window); if let Some(running) = &mut self.running { unsafe { @@ -970,7 +970,7 @@ mod wgpu_integration { #[allow(unsafe_code)] #[cfg(target_os = "android")] - fn drop_window(&mut self) -> std::result::Result<(), wgpu::RequestDeviceError> { + fn drop_window(&mut self) -> std::result::Result<(), egui_wgpu::WgpuError> { self.window = None; if let Some(running) = &mut self.running { unsafe { @@ -985,7 +985,7 @@ mod wgpu_integration { event_loop: &EventLoopWindowTarget, storage: Option>, window: winit::window::Window, - ) -> std::result::Result<(), wgpu::RequestDeviceError> { + ) -> std::result::Result<(), egui_wgpu::WgpuError> { #[allow(unsafe_code, unused_mut, unused_unsafe)] let painter = unsafe { let mut painter = egui_wgpu::winit::Painter::new( diff --git a/crates/eframe/src/web/web_painter_wgpu.rs b/crates/eframe/src/web/web_painter_wgpu.rs index 5e0055a65..d6445f0ef 100644 --- a/crates/eframe/src/web/web_painter_wgpu.rs +++ b/crates/eframe/src/web/web_painter_wgpu.rs @@ -49,6 +49,7 @@ impl WebPainterWgpu { dimension: wgpu::TextureDimension::D2, format: depth_format, usage: wgpu::TextureUsages::RENDER_ATTACHMENT, + view_formats: &[depth_format], }) .create_view(&wgpu::TextureViewDescriptor::default()) }) @@ -60,8 +61,13 @@ impl WebPainterWgpu { let canvas = super::canvas_element_or_die(canvas_id); - let instance = wgpu::Instance::new(options.wgpu_options.backends); - let surface = instance.create_surface_from_canvas(&canvas); + let instance = wgpu::Instance::new(wgpu::InstanceDescriptor { + backends: options.wgpu_options.backends, + dx12_shader_compiler: Default::default(), + }); + let surface = instance + .create_surface_from_canvas(&canvas) + .map_err(|err| format!("failed to create wgpu surface: {err}"))?; let adapter = instance .request_adapter(&wgpu::RequestAdapterOptions { @@ -81,7 +87,7 @@ impl WebPainterWgpu { .map_err(|err| format!("Failed to find wgpu device: {}", err))?; let target_format = - egui_wgpu::preferred_framebuffer_format(&surface.get_supported_formats(&adapter)); + egui_wgpu::preferred_framebuffer_format(&surface.get_capabilities(&adapter).formats); let depth_format = options.wgpu_options.depth_format; let renderer = egui_wgpu::Renderer::new(&device, target_format, depth_format, 1); @@ -99,6 +105,7 @@ impl WebPainterWgpu { height: 0, present_mode: options.wgpu_options.present_mode, alpha_mode: wgpu::CompositeAlphaMode::Auto, + view_formats: vec![target_format], }; tracing::debug!("wgpu painter initialized."); diff --git a/crates/egui-wgpu/CHANGELOG.md b/crates/egui-wgpu/CHANGELOG.md index 559fe29be..b187497b4 100644 --- a/crates/egui-wgpu/CHANGELOG.md +++ b/crates/egui-wgpu/CHANGELOG.md @@ -3,6 +3,7 @@ All notable changes to the `egui-wgpu` integration will be noted in this file. ## Unreleased +* update to wgpu 0.15 ([#2629](https://github.com/emilk/egui/pull/2629)) * Return `Err` instead of panic if we can't find a device ([#2428](https://github.com/emilk/egui/pull/2428)). * `winit::Painter::set_window` is now `async` ([#2434](https://github.com/emilk/egui/pull/2434)). * `egui-wgpu` now only depends on `epaint` instead of the entire `egui` ([#2438](https://github.com/emilk/egui/pull/2438)). diff --git a/crates/egui-wgpu/Cargo.toml b/crates/egui-wgpu/Cargo.toml index 5991abd43..1696941db 100644 --- a/crates/egui-wgpu/Cargo.toml +++ b/crates/egui-wgpu/Cargo.toml @@ -43,7 +43,7 @@ epaint = { version = "0.20.0", path = "../epaint", default-features = false, fea bytemuck = "1.7" tracing = { version = "0.1", default-features = false, features = ["std"] } type-map = "0.5.0" -wgpu = "0.14" +wgpu = "0.15.0" #! ### Optional dependencies ## Enable this when generating docs. diff --git a/crates/egui-wgpu/src/lib.rs b/crates/egui-wgpu/src/lib.rs index b7cbd3f90..339df1806 100644 --- a/crates/egui-wgpu/src/lib.rs +++ b/crates/egui-wgpu/src/lib.rs @@ -99,7 +99,35 @@ pub fn preferred_framebuffer_format(formats: &[wgpu::TextureFormat]) -> wgpu::Te } formats[0] // take the first } - +// maybe use this-error? +#[derive(Debug)] +pub enum WgpuError { + DeviceError(wgpu::RequestDeviceError), + SurfaceError(wgpu::CreateSurfaceError), +} +impl std::fmt::Display for WgpuError { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + std::fmt::Debug::fmt(self, f) + } +} +impl std::error::Error for WgpuError { + fn source(&self) -> Option<&(dyn std::error::Error + 'static)> { + match self { + WgpuError::DeviceError(e) => e.source(), + WgpuError::SurfaceError(e) => e.source(), + } + } +} +impl From for WgpuError { + fn from(e: wgpu::RequestDeviceError) -> Self { + Self::DeviceError(e) + } +} +impl From for WgpuError { + fn from(e: wgpu::CreateSurfaceError) -> Self { + Self::SurfaceError(e) + } +} // --------------------------------------------------------------------------- /// Profiling macro for feature "puffin" diff --git a/crates/egui-wgpu/src/renderer.rs b/crates/egui-wgpu/src/renderer.rs index d3e1c8596..524d98934 100644 --- a/crates/egui-wgpu/src/renderer.rs +++ b/crates/egui-wgpu/src/renderer.rs @@ -554,6 +554,7 @@ impl Renderer { dimension: wgpu::TextureDimension::D2, format: wgpu::TextureFormat::Rgba8UnormSrgb, // Minspec for wgpu WebGL emulation is WebGL2, so this should always be supported. usage: wgpu::TextureUsages::TEXTURE_BINDING | wgpu::TextureUsages::COPY_DST, + view_formats: &[wgpu::TextureFormat::Rgba8UnormSrgb], }); let sampler = self .samplers diff --git a/crates/egui-wgpu/src/winit.rs b/crates/egui-wgpu/src/winit.rs index 0ba3e3e85..515930404 100644 --- a/crates/egui-wgpu/src/winit.rs +++ b/crates/egui-wgpu/src/winit.rs @@ -42,7 +42,10 @@ impl Painter { /// a [`winit::window::Window`] with a valid `.raw_window_handle()` /// associated. pub fn new(configuration: WgpuConfiguration, msaa_samples: u32, depth_bits: u8) -> Self { - let instance = wgpu::Instance::new(configuration.backends); + let instance = wgpu::Instance::new(wgpu::InstanceDescriptor { + backends: configuration.backends, + dx12_shader_compiler: Default::default(), // + }); Self { configuration, @@ -107,7 +110,7 @@ impl Painter { match &self.adapter { Some(adapter) => { let swapchain_format = crate::preferred_framebuffer_format( - &surface.get_supported_formats(adapter), + &surface.get_capabilities(adapter).formats, ); let rs = self.init_render_state(adapter, swapchain_format).await?; self.render_state = Some(rs); @@ -134,6 +137,7 @@ impl Painter { height: height_in_pixels, present_mode: self.configuration.present_mode, alpha_mode: wgpu::CompositeAlphaMode::Auto, + view_formats: vec![format], }; let surface_state = self @@ -177,10 +181,10 @@ impl Painter { pub async unsafe fn set_window( &mut self, window: Option<&winit::window::Window>, - ) -> Result<(), wgpu::RequestDeviceError> { + ) -> Result<(), crate::WgpuError> { match window { Some(window) => { - let surface = self.instance.create_surface(&window); + let surface = self.instance.create_surface(&window)?; self.ensure_render_state_for_surface(&surface).await?; @@ -234,6 +238,7 @@ impl Painter { format: depth_format, usage: wgpu::TextureUsages::RENDER_ATTACHMENT | wgpu::TextureUsages::TEXTURE_BINDING, + view_formats: &[depth_format], }) .create_view(&wgpu::TextureViewDescriptor::default()) }); diff --git a/crates/egui_demo_app/src/apps/custom3d_wgpu.rs b/crates/egui_demo_app/src/apps/custom3d_wgpu.rs index 5a2b30c33..1a519f694 100644 --- a/crates/egui_demo_app/src/apps/custom3d_wgpu.rs +++ b/crates/egui_demo_app/src/apps/custom3d_wgpu.rs @@ -1,8 +1,8 @@ use std::{num::NonZeroU64, sync::Arc}; use eframe::{ + egui_wgpu::wgpu::util::DeviceExt, egui_wgpu::{self, wgpu}, - wgpu::util::DeviceExt, }; pub struct Custom3d {