wgpu upgraded to 0.15. demo working on linux
This commit is contained in:
parent
8ce0e1c520
commit
2ec63db81d
9 changed files with 266 additions and 33 deletions
241
Cargo.lock
generated
241
Cargo.lock
generated
|
@ -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",
|
||||
|
@ -1025,6 +1031,17 @@ dependencies = [
|
|||
"winapi",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "d3d12"
|
||||
version = "0.6.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d8f0de2f5a8e7bd4a9eec0e3c781992a4ce1724f68aec7d7a3715344de8b39da"
|
||||
dependencies = [
|
||||
"bitflags",
|
||||
"libloading",
|
||||
"winapi",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "dark-light"
|
||||
version = "0.2.3"
|
||||
|
@ -1316,7 +1333,7 @@ dependencies = [
|
|||
"egui-wgpu",
|
||||
"egui-winit",
|
||||
"egui_glow",
|
||||
"glow",
|
||||
"glow 0.11.2",
|
||||
"glutin 0.30.2",
|
||||
"image",
|
||||
"js-sys",
|
||||
|
@ -1332,7 +1349,8 @@ dependencies = [
|
|||
"wasm-bindgen",
|
||||
"wasm-bindgen-futures",
|
||||
"web-sys",
|
||||
"wgpu",
|
||||
"wgpu 0.14.2",
|
||||
"wgpu 0.15.0",
|
||||
"winit",
|
||||
]
|
||||
|
||||
|
@ -1360,7 +1378,7 @@ dependencies = [
|
|||
"puffin",
|
||||
"tracing",
|
||||
"type-map",
|
||||
"wgpu",
|
||||
"wgpu 0.15.0",
|
||||
"winit",
|
||||
]
|
||||
|
||||
|
@ -1456,7 +1474,7 @@ dependencies = [
|
|||
"document-features",
|
||||
"egui",
|
||||
"egui-winit",
|
||||
"glow",
|
||||
"glow 0.11.2",
|
||||
"glutin 0.30.2",
|
||||
"memoffset",
|
||||
"puffin",
|
||||
|
@ -1953,6 +1971,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 +2130,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 +2200,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 0.5.1",
|
||||
"winapi",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "heck"
|
||||
version = "0.4.0"
|
||||
|
@ -2568,6 +2626,26 @@ dependencies = [
|
|||
"unicode-xid",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "naga"
|
||||
version = "0.11.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "5eafe22a23b797c9bc227c6c896419b26b5bb88fa903417a3adaed08778850d5"
|
||||
dependencies = [
|
||||
"bit-set",
|
||||
"bitflags",
|
||||
"codespan-reporting",
|
||||
"hexf-parse",
|
||||
"indexmap",
|
||||
"log",
|
||||
"num-traits",
|
||||
"rustc-hash",
|
||||
"spirv",
|
||||
"termcolor",
|
||||
"thiserror",
|
||||
"unicode-xid",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "ndk"
|
||||
version = "0.6.0"
|
||||
|
@ -3848,7 +3926,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",
|
||||
|
@ -4511,7 +4589,7 @@ dependencies = [
|
|||
"raw-window-handle 0.5.0",
|
||||
"url",
|
||||
"web-sys",
|
||||
"widestring",
|
||||
"widestring 1.0.2",
|
||||
"winapi",
|
||||
]
|
||||
|
||||
|
@ -4558,7 +4636,7 @@ dependencies = [
|
|||
"arrayvec 0.7.2",
|
||||
"js-sys",
|
||||
"log",
|
||||
"naga",
|
||||
"naga 0.10.0",
|
||||
"parking_lot",
|
||||
"raw-window-handle 0.5.0",
|
||||
"smallvec",
|
||||
|
@ -4566,9 +4644,33 @@ dependencies = [
|
|||
"wasm-bindgen",
|
||||
"wasm-bindgen-futures",
|
||||
"web-sys",
|
||||
"wgpu-core",
|
||||
"wgpu-hal",
|
||||
"wgpu-types",
|
||||
"wgpu-core 0.14.2",
|
||||
"wgpu-hal 0.14.1",
|
||||
"wgpu-types 0.14.1",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "wgpu"
|
||||
version = "0.15.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d14c6bfcf3b10f4273f522a95994553c0a5f2934976e62e61a720ae4bc2eb8f2"
|
||||
dependencies = [
|
||||
"arrayvec 0.7.2",
|
||||
"cfg-if",
|
||||
"js-sys",
|
||||
"log",
|
||||
"naga 0.11.0",
|
||||
"parking_lot",
|
||||
"profiling",
|
||||
"raw-window-handle 0.5.0",
|
||||
"smallvec",
|
||||
"static_assertions",
|
||||
"wasm-bindgen",
|
||||
"wasm-bindgen-futures",
|
||||
"web-sys",
|
||||
"wgpu-core 0.15.0",
|
||||
"wgpu-hal 0.15.1",
|
||||
"wgpu-types 0.15.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
@ -4584,15 +4686,38 @@ dependencies = [
|
|||
"codespan-reporting",
|
||||
"fxhash",
|
||||
"log",
|
||||
"naga",
|
||||
"naga 0.10.0",
|
||||
"parking_lot",
|
||||
"profiling",
|
||||
"raw-window-handle 0.5.0",
|
||||
"smallvec",
|
||||
"thiserror",
|
||||
"web-sys",
|
||||
"wgpu-hal",
|
||||
"wgpu-types",
|
||||
"wgpu-hal 0.14.1",
|
||||
"wgpu-types 0.14.1",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "wgpu-core"
|
||||
version = "0.15.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "be1f61be28e557a6ecb2506cac06c63fae3b6d302a006f38195a7a80995abeb9"
|
||||
dependencies = [
|
||||
"arrayvec 0.7.2",
|
||||
"bit-vec",
|
||||
"bitflags",
|
||||
"codespan-reporting",
|
||||
"fxhash",
|
||||
"log",
|
||||
"naga 0.11.0",
|
||||
"parking_lot",
|
||||
"profiling",
|
||||
"raw-window-handle 0.5.0",
|
||||
"smallvec",
|
||||
"thiserror",
|
||||
"web-sys",
|
||||
"wgpu-hal 0.15.1",
|
||||
"wgpu-types 0.15.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
@ -4608,10 +4733,10 @@ dependencies = [
|
|||
"bitflags",
|
||||
"block",
|
||||
"core-graphics-types",
|
||||
"d3d12",
|
||||
"d3d12 0.5.0",
|
||||
"foreign-types 0.3.2",
|
||||
"fxhash",
|
||||
"glow",
|
||||
"glow 0.11.2",
|
||||
"gpu-alloc",
|
||||
"gpu-descriptor",
|
||||
"js-sys",
|
||||
|
@ -4619,7 +4744,7 @@ dependencies = [
|
|||
"libloading",
|
||||
"log",
|
||||
"metal",
|
||||
"naga",
|
||||
"naga 0.10.0",
|
||||
"objc",
|
||||
"parking_lot",
|
||||
"profiling",
|
||||
|
@ -4630,7 +4755,49 @@ dependencies = [
|
|||
"thiserror",
|
||||
"wasm-bindgen",
|
||||
"web-sys",
|
||||
"wgpu-types",
|
||||
"wgpu-types 0.14.1",
|
||||
"winapi",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "wgpu-hal"
|
||||
version = "0.15.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "82e95792925fe3d58950b9a5c2a191caa145e2bc570e2d233f0d7320f6a8e814"
|
||||
dependencies = [
|
||||
"android_system_properties",
|
||||
"arrayvec 0.7.2",
|
||||
"ash",
|
||||
"bit-set",
|
||||
"bitflags",
|
||||
"block",
|
||||
"core-graphics-types",
|
||||
"d3d12 0.6.0",
|
||||
"foreign-types 0.3.2",
|
||||
"fxhash",
|
||||
"glow 0.12.0",
|
||||
"gpu-alloc",
|
||||
"gpu-allocator",
|
||||
"gpu-descriptor",
|
||||
"hassle-rs",
|
||||
"js-sys",
|
||||
"khronos-egl",
|
||||
"libc",
|
||||
"libloading",
|
||||
"log",
|
||||
"metal",
|
||||
"naga 0.11.0",
|
||||
"objc",
|
||||
"parking_lot",
|
||||
"profiling",
|
||||
"range-alloc",
|
||||
"raw-window-handle 0.5.0",
|
||||
"renderdoc-sys",
|
||||
"smallvec",
|
||||
"thiserror",
|
||||
"wasm-bindgen",
|
||||
"web-sys",
|
||||
"wgpu-types 0.15.0",
|
||||
"winapi",
|
||||
]
|
||||
|
||||
|
@ -4643,6 +4810,17 @@ dependencies = [
|
|||
"bitflags",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "wgpu-types"
|
||||
version = "0.15.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ecf8cfcbf98f94cc8bd5981544c687140cf9d3948e2ab83849367ead2cd737cf"
|
||||
dependencies = [
|
||||
"bitflags",
|
||||
"js-sys",
|
||||
"web-sys",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "which"
|
||||
version = "4.3.0"
|
||||
|
@ -4654,6 +4832,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 = "widestring"
|
||||
version = "1.0.2"
|
||||
|
@ -4729,6 +4913,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"
|
||||
|
|
|
@ -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:
|
||||
|
|
|
@ -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<T> = std::result::Result<T, Error>;
|
||||
|
|
|
@ -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<UserEvent>,
|
||||
storage: Option<Box<dyn epi::Storage>>,
|
||||
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(
|
||||
|
|
|
@ -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.
|
||||
|
|
|
@ -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<wgpu::RequestDeviceError> for WgpuError {
|
||||
fn from(e: wgpu::RequestDeviceError) -> Self {
|
||||
Self::DeviceError(e)
|
||||
}
|
||||
}
|
||||
impl From<wgpu::CreateSurfaceError> for WgpuError {
|
||||
fn from(e: wgpu::CreateSurfaceError) -> Self {
|
||||
Self::SurfaceError(e)
|
||||
}
|
||||
}
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
/// Profiling macro for feature "puffin"
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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())
|
||||
});
|
||||
|
|
|
@ -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 {
|
||||
|
|
Loading…
Reference in a new issue