Merge pull request #2427 from felix91gr/main

Upgrade to wgpu 22
This commit is contained in:
Hanno Braun 2024-07-26 09:41:22 +02:00 committed by GitHub
commit 8146afdb93
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
6 changed files with 77 additions and 76 deletions

77
Cargo.lock generated
View File

@ -216,11 +216,11 @@ checksum = "175571dd1d178ced59193a6fc02dde1b972eb0bc56c892cde9beeceac5bf0f6b"
[[package]] [[package]]
name = "ash" name = "ash"
version = "0.37.3+1.3.251" version = "0.38.0+1.3.281"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "39e9c3835d686b0a6084ab4234fcd1b07dbf6e4767dce60874b12356a25ecd4a" checksum = "0bb44936d800fea8f016d7f2311c6a4f97aebd5dc86f09906139ec848cf3a46f"
dependencies = [ dependencies = [
"libloading 0.7.4", "libloading",
] ]
[[package]] [[package]]
@ -304,18 +304,18 @@ checksum = "72b3254f16251a8381aa12e40e3c4d2f0199f8c6508fbecb9d91f575e0fbb8c6"
[[package]] [[package]]
name = "bit-set" name = "bit-set"
version = "0.5.3" version = "0.6.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0700ddab506f33b20a03b13996eccd309a48e5ff77d0d95926aa0210fb4e95f1" checksum = "f0481a0e032742109b1133a095184ee93d88f3dc9e0d28a5d033dc77a073f44f"
dependencies = [ dependencies = [
"bit-vec", "bit-vec",
] ]
[[package]] [[package]]
name = "bit-vec" name = "bit-vec"
version = "0.6.3" version = "0.7.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "349f9b6a179ed607305526ca489b34ad0a41aed5f7980fa90eb03160b69598fb" checksum = "d2c54ff287cfc0a34f38a6b832ea1bd8e448a330b3e40a50859e6488bee07f22"
[[package]] [[package]]
name = "bitflags" name = "bitflags"
@ -718,12 +718,12 @@ checksum = "96a6ac251f4a2aca6b3f91340350eab87ae57c3f127ffeb585e92bd336717991"
[[package]] [[package]]
name = "d3d12" name = "d3d12"
version = "0.20.0" version = "22.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b28bfe653d79bd16c77f659305b195b82bb5ce0c0eb2a4846b82ddbd77586813" checksum = "bdbd1f579714e3c809ebd822c81ef148b1ceaeb3d535352afc73fd0c4c6a0017"
dependencies = [ dependencies = [
"bitflags 2.6.0", "bitflags 2.6.0",
"libloading 0.8.5", "libloading",
"winapi", "winapi",
] ]
@ -766,7 +766,7 @@ version = "0.5.2"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "330c60081dcc4c72131f8eb70510f1ac07223e5d4163db481a04a0befcffa412" checksum = "330c60081dcc4c72131f8eb70510f1ac07223e5d4163db481a04a0befcffa412"
dependencies = [ dependencies = [
"libloading 0.8.5", "libloading",
] ]
[[package]] [[package]]
@ -1194,9 +1194,9 @@ dependencies = [
[[package]] [[package]]
name = "glutin_wgl_sys" name = "glutin_wgl_sys"
version = "0.5.0" version = "0.6.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6c8098adac955faa2d31079b65dc48841251f69efd3ac25477903fc424362ead" checksum = "0a4e1951bbd9434a81aa496fe59ccc2235af3820d27b85f9314e279609211e2c"
dependencies = [ dependencies = [
"gl_generator", "gl_generator",
] ]
@ -1222,9 +1222,9 @@ dependencies = [
[[package]] [[package]]
name = "gpu-allocator" name = "gpu-allocator"
version = "0.25.0" version = "0.26.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6f56f6318968d03c18e1bcf4857ff88c61157e9da8e47c5f29055d60e1228884" checksum = "fdd4240fc91d3433d5e5b0fc5b67672d771850dc19bbee03c1381e19322803d7"
dependencies = [ dependencies = [
"log", "log",
"presser", "presser",
@ -1300,7 +1300,7 @@ dependencies = [
"bitflags 2.6.0", "bitflags 2.6.0",
"com", "com",
"libc", "libc",
"libloading 0.8.5", "libloading",
"thiserror", "thiserror",
"widestring", "widestring",
"winapi", "winapi",
@ -1666,7 +1666,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6aae1df220ece3c0ada96b8153459b67eebe9ae9212258bb0134ae60416fdf76" checksum = "6aae1df220ece3c0ada96b8153459b67eebe9ae9212258bb0134ae60416fdf76"
dependencies = [ dependencies = [
"libc", "libc",
"libloading 0.8.5", "libloading",
"pkg-config", "pkg-config",
] ]
@ -1688,16 +1688,6 @@ version = "0.2.155"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "97b3888a4aecf77e811145cadf6eef5901f4782c53886191b2f693f24761847c" checksum = "97b3888a4aecf77e811145cadf6eef5901f4782c53886191b2f693f24761847c"
[[package]]
name = "libloading"
version = "0.7.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b67380fd3b2fbe7527a606e18729d21c6f3951633d0500574c4dc22d2d638b9f"
dependencies = [
"cfg-if",
"winapi",
]
[[package]] [[package]]
name = "libloading" name = "libloading"
version = "0.8.5" version = "0.8.5"
@ -1804,9 +1794,9 @@ dependencies = [
[[package]] [[package]]
name = "metal" name = "metal"
version = "0.28.0" version = "0.29.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5637e166ea14be6063a3f8ba5ccb9a4159df7d8f6d61c02fc3d480b1f90dcfcb" checksum = "7ecfd3296f8c56b7c1f6fbac3c71cefa9d78ce009850c45000015f206dc7fa21"
dependencies = [ dependencies = [
"bitflags 2.6.0", "bitflags 2.6.0",
"block", "block",
@ -1846,18 +1836,18 @@ dependencies = [
[[package]] [[package]]
name = "naga" name = "naga"
version = "0.20.0" version = "22.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e536ae46fcab0876853bd4a632ede5df4b1c2527a58f6c5a4150fe86be858231" checksum = "09eeccb9b50f4f7839b214aa3e08be467159506a986c18e0702170ccf720a453"
dependencies = [ dependencies = [
"arrayvec", "arrayvec",
"bit-set", "bit-set",
"bitflags 2.6.0", "bitflags 2.6.0",
"cfg_aliases 0.1.1",
"codespan-reporting", "codespan-reporting",
"hexf-parse", "hexf-parse",
"indexmap", "indexmap",
"log", "log",
"num-traits",
"rustc-hash 1.1.0", "rustc-hash 1.1.0",
"spirv", "spirv",
"termcolor", "termcolor",
@ -4070,12 +4060,11 @@ dependencies = [
[[package]] [[package]]
name = "wgpu" name = "wgpu"
version = "0.20.1" version = "22.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "90e37c7b9921b75dfd26dd973fdcbce36f13dfa6e2dc82aece584e0ed48c355c" checksum = "c87e07e87a179614940ad845397e03201847453a37b43a31a3b54eee2e6e32ce"
dependencies = [ dependencies = [
"arrayvec", "arrayvec",
"cfg-if",
"cfg_aliases 0.1.1", "cfg_aliases 0.1.1",
"document-features", "document-features",
"js-sys", "js-sys",
@ -4096,15 +4085,14 @@ dependencies = [
[[package]] [[package]]
name = "wgpu-core" name = "wgpu-core"
version = "0.21.1" version = "22.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d50819ab545b867d8a454d1d756b90cd5f15da1f2943334ca314af10583c9d39" checksum = "e0f191908a21968991463fcf3b42cb6c9648c0fb7fa301b8fc733bc21a9ed9bd"
dependencies = [ dependencies = [
"arrayvec", "arrayvec",
"bit-vec", "bit-vec",
"bitflags 2.6.0", "bitflags 2.6.0",
"cfg_aliases 0.1.1", "cfg_aliases 0.1.1",
"codespan-reporting",
"document-features", "document-features",
"indexmap", "indexmap",
"log", "log",
@ -4116,16 +4104,15 @@ dependencies = [
"rustc-hash 1.1.0", "rustc-hash 1.1.0",
"smallvec", "smallvec",
"thiserror", "thiserror",
"web-sys",
"wgpu-hal", "wgpu-hal",
"wgpu-types", "wgpu-types",
] ]
[[package]] [[package]]
name = "wgpu-hal" name = "wgpu-hal"
version = "0.21.1" version = "22.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "172e490a87295564f3fcc0f165798d87386f6231b04d4548bca458cbbfd63222" checksum = "f6bbf4b4de8b2a83c0401d9e5ae0080a2792055f25859a02bf9be97952bbed4f"
dependencies = [ dependencies = [
"android_system_properties", "android_system_properties",
"arrayvec", "arrayvec",
@ -4145,7 +4132,7 @@ dependencies = [
"js-sys", "js-sys",
"khronos-egl", "khronos-egl",
"libc", "libc",
"libloading 0.8.5", "libloading",
"log", "log",
"metal", "metal",
"naga", "naga",
@ -4168,9 +4155,9 @@ dependencies = [
[[package]] [[package]]
name = "wgpu-types" name = "wgpu-types"
version = "0.20.0" version = "22.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1353d9a46bff7f955a680577f34c69122628cc2076e1d6f3a9be6ef00ae793ef" checksum = "bc9d91f0e2c4b51434dfa6db77846f2793149d8e73f800fa2e41f52b8eac3c5d"
dependencies = [ dependencies = [
"bitflags 2.6.0", "bitflags 2.6.0",
"js-sys", "js-sys",
@ -4539,7 +4526,7 @@ dependencies = [
"as-raw-xcb-connection", "as-raw-xcb-connection",
"gethostname", "gethostname",
"libc", "libc",
"libloading 0.8.5", "libloading",
"once_cell", "once_cell",
"rustix", "rustix",
"x11rb-protocol", "x11rb-protocol",

View File

@ -33,7 +33,7 @@ default-features = false
features = ["png", "jpeg"] features = ["png", "jpeg"]
[dependencies.wgpu] [dependencies.wgpu]
version = "0.20.1" version = "22.0.0"
features = ["webgl"] features = ["webgl"]
# We don't depend on `getrandom` directly, but we need this to enable the `js` # We don't depend on `getrandom` directly, but we need this to enable the `js`

View File

@ -30,39 +30,47 @@ impl Device {
pub async fn try_from_all_adapters( pub async fn try_from_all_adapters(
instance: &wgpu::Instance, instance: &wgpu::Instance,
) -> Result<(Self, wgpu::Adapter, wgpu::Features), DeviceError> { ) -> Result<(Self, wgpu::Adapter, wgpu::Features), DeviceError> {
let mut all_adapters = instance #[cfg(not(target_arch = "wasm32"))]
.enumerate_adapters(wgpu::Backends::all()) {
.into_iter(); let mut all_adapters = instance
.enumerate_adapters(wgpu::Backends::all())
.into_iter();
let result = loop { let result = loop {
let Some(adapter) = all_adapters.next() else { let Some(adapter) = all_adapters.next() else {
debug!("No more adapters to try"); debug!("No more adapters to try");
break None; break None;
};
let (device, features) = match Device::new(&adapter).await {
Ok((device, adapter)) => (device, adapter),
Err(err) => {
error!(
"Failed to get device from adapter {:?}: {:?}",
adapter.get_info(),
err,
);
continue;
}
};
break Some((device, adapter, features));
}; };
let (device, features) = match Device::new(&adapter).await { for adapter in all_adapters {
Ok((device, adapter)) => (device, adapter), debug!(
Err(err) => { "Remaining adapter that wasn't tried: {:?}",
error!( adapter.get_info()
"Failed to get device from adapter {:?}: {:?}", );
adapter.get_info(), }
err,
);
continue;
}
};
break Some((device, adapter, features)); result.ok_or(DeviceError::FoundNoWorkingAdapter)
}; }
#[cfg(target_arch = "wasm32")]
for adapter in all_adapters { {
debug!( _ = instance;
"Remaining adapter that wasn't tried: {:?}", Err(DeviceError::FoundNoWorkingAdapter)
adapter.get_info()
);
} }
result.ok_or(DeviceError::FoundNoWorkingAdapter)
} }
pub async fn new( pub async fn new(
@ -101,6 +109,9 @@ impl Device {
label: None, label: None,
required_features, required_features,
required_limits, required_limits,
// Here we give a memory hint to preserve memory usage.
// This should allow us to run in as much devices as possible.
memory_hints: wgpu::MemoryHints::MemoryUsage,
}, },
None, None,
) )

View File

@ -146,6 +146,7 @@ impl NavigationCubeRenderer {
alpha_to_coverage_enabled: false, alpha_to_coverage_enabled: false,
}, },
multiview: None, multiview: None,
cache: None,
}); });
let cube_model = let cube_model =

View File

@ -128,6 +128,7 @@ impl Pipeline {
})], })],
}), }),
multiview: None, multiview: None,
cache: None,
}); });
Self(pipeline) Self(pipeline)

View File

@ -1,7 +1,7 @@
use std::{io, mem::size_of, vec}; use std::{io, mem::size_of, vec};
use thiserror::Error; use thiserror::Error;
use tracing::{debug, error, trace}; use tracing::{error, trace};
use wgpu::util::DeviceExt as _; use wgpu::util::DeviceExt as _;
use crate::{ use crate::{
@ -46,8 +46,9 @@ impl Renderer {
// This is sound, as `window` is an object to create a surface upon. // This is sound, as `window` is an object to create a surface upon.
let surface = instance.create_surface(screen.window())?; let surface = instance.create_surface(screen.window())?;
#[cfg(not(target_arch = "wasm32"))]
for adapter in instance.enumerate_adapters(wgpu::Backends::all()) { for adapter in instance.enumerate_adapters(wgpu::Backends::all()) {
debug!("Available adapter: {:?}", adapter.get_info()); tracing::debug!("Available adapter: {:?}", adapter.get_info());
} }
let result = Device::from_preferred_adapter(&instance, &surface).await; let result = Device::from_preferred_adapter(&instance, &surface).await;