upgrade wgpu for eframe web backend

This commit is contained in:
Red Artist 2023-01-26 12:07:29 +05:30
parent 2ec63db81d
commit 1525e90183
3 changed files with 23 additions and 142 deletions

150
Cargo.lock generated
View file

@ -1020,17 +1020,6 @@ dependencies = [
"syn",
]
[[package]]
name = "d3d12"
version = "0.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "827914e1f53b1e0e025ecd3d967a7836b7bcb54520f90e21ef8df7b4d88a2759"
dependencies = [
"bitflags",
"libloading",
"winapi",
]
[[package]]
name = "d3d12"
version = "0.6.0"
@ -1349,8 +1338,7 @@ dependencies = [
"wasm-bindgen",
"wasm-bindgen-futures",
"web-sys",
"wgpu 0.14.2",
"wgpu 0.15.0",
"wgpu",
"winit",
]
@ -1378,7 +1366,7 @@ dependencies = [
"puffin",
"tracing",
"type-map",
"wgpu 0.15.0",
"wgpu",
"winit",
]
@ -2606,26 +2594,6 @@ dependencies = [
"windows-sys 0.42.0",
]
[[package]]
name = "naga"
version = "0.10.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "262d2840e72dbe250e8cf2f522d080988dfca624c4112c096238a4845f591707"
dependencies = [
"bit-set",
"bitflags",
"codespan-reporting",
"hexf-parse",
"indexmap",
"log",
"num-traits",
"rustc-hash",
"spirv",
"termcolor",
"thiserror",
"unicode-xid",
]
[[package]]
name = "naga"
version = "0.11.0"
@ -4627,28 +4595,6 @@ dependencies = [
"cc",
]
[[package]]
name = "wgpu"
version = "0.14.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "81f643110d228fd62a60c5ed2ab56c4d5b3704520bd50561174ec4ec74932937"
dependencies = [
"arrayvec 0.7.2",
"js-sys",
"log",
"naga 0.10.0",
"parking_lot",
"raw-window-handle 0.5.0",
"smallvec",
"static_assertions",
"wasm-bindgen",
"wasm-bindgen-futures",
"web-sys",
"wgpu-core 0.14.2",
"wgpu-hal 0.14.1",
"wgpu-types 0.14.1",
]
[[package]]
name = "wgpu"
version = "0.15.0"
@ -4659,7 +4605,7 @@ dependencies = [
"cfg-if",
"js-sys",
"log",
"naga 0.11.0",
"naga",
"parking_lot",
"profiling",
"raw-window-handle 0.5.0",
@ -4668,33 +4614,9 @@ dependencies = [
"wasm-bindgen",
"wasm-bindgen-futures",
"web-sys",
"wgpu-core 0.15.0",
"wgpu-hal 0.15.1",
"wgpu-types 0.15.0",
]
[[package]]
name = "wgpu-core"
version = "0.14.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6000d1284ef8eec6076fd5544a73125fd7eb9b635f18dceeb829d826f41724ca"
dependencies = [
"arrayvec 0.7.2",
"bit-vec",
"bitflags",
"cfg_aliases",
"codespan-reporting",
"fxhash",
"log",
"naga 0.10.0",
"parking_lot",
"profiling",
"raw-window-handle 0.5.0",
"smallvec",
"thiserror",
"web-sys",
"wgpu-hal 0.14.1",
"wgpu-types 0.14.1",
"wgpu-core",
"wgpu-hal",
"wgpu-types",
]
[[package]]
@ -4709,54 +4631,15 @@ dependencies = [
"codespan-reporting",
"fxhash",
"log",
"naga 0.11.0",
"naga",
"parking_lot",
"profiling",
"raw-window-handle 0.5.0",
"smallvec",
"thiserror",
"web-sys",
"wgpu-hal 0.15.1",
"wgpu-types 0.15.0",
]
[[package]]
name = "wgpu-hal"
version = "0.14.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3cc320a61acb26be4f549c9b1b53405c10a223fbfea363ec39474c32c348d12f"
dependencies = [
"android_system_properties",
"arrayvec 0.7.2",
"ash",
"bit-set",
"bitflags",
"block",
"core-graphics-types",
"d3d12 0.5.0",
"foreign-types 0.3.2",
"fxhash",
"glow 0.11.2",
"gpu-alloc",
"gpu-descriptor",
"js-sys",
"khronos-egl",
"libloading",
"log",
"metal",
"naga 0.10.0",
"objc",
"parking_lot",
"profiling",
"range-alloc",
"raw-window-handle 0.5.0",
"renderdoc-sys",
"smallvec",
"thiserror",
"wasm-bindgen",
"web-sys",
"wgpu-types 0.14.1",
"winapi",
"wgpu-hal",
"wgpu-types",
]
[[package]]
@ -4772,7 +4655,7 @@ dependencies = [
"bitflags",
"block",
"core-graphics-types",
"d3d12 0.6.0",
"d3d12",
"foreign-types 0.3.2",
"fxhash",
"glow 0.12.0",
@ -4786,7 +4669,7 @@ dependencies = [
"libloading",
"log",
"metal",
"naga 0.11.0",
"naga",
"objc",
"parking_lot",
"profiling",
@ -4797,19 +4680,10 @@ dependencies = [
"thiserror",
"wasm-bindgen",
"web-sys",
"wgpu-types 0.15.0",
"wgpu-types",
"winapi",
]
[[package]]
name = "wgpu-types"
version = "0.14.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fb6b28ef22cac17b9109b25b3bf8c9a103eeb293d7c5f78653979b09140375f6"
dependencies = [
"bitflags",
]
[[package]]
name = "wgpu-types"
version = "0.15.0"

View file

@ -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"] }

View file

@ -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.");