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

View File

@ -33,7 +33,7 @@ default-features = false
features = ["png", "jpeg"]
[dependencies.wgpu]
version = "0.20.1"
version = "22.0.0"
features = ["webgl"]
# 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(
instance: &wgpu::Instance,
) -> Result<(Self, wgpu::Adapter, wgpu::Features), DeviceError> {
let mut all_adapters = instance
.enumerate_adapters(wgpu::Backends::all())
.into_iter();
#[cfg(not(target_arch = "wasm32"))]
{
let mut all_adapters = instance
.enumerate_adapters(wgpu::Backends::all())
.into_iter();
let result = loop {
let Some(adapter) = all_adapters.next() else {
debug!("No more adapters to try");
break None;
let result = loop {
let Some(adapter) = all_adapters.next() else {
debug!("No more adapters to try");
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 {
Ok((device, adapter)) => (device, adapter),
Err(err) => {
error!(
"Failed to get device from adapter {:?}: {:?}",
adapter.get_info(),
err,
);
continue;
}
};
for adapter in all_adapters {
debug!(
"Remaining adapter that wasn't tried: {:?}",
adapter.get_info()
);
}
break Some((device, adapter, features));
};
for adapter in all_adapters {
debug!(
"Remaining adapter that wasn't tried: {:?}",
adapter.get_info()
);
result.ok_or(DeviceError::FoundNoWorkingAdapter)
}
#[cfg(target_arch = "wasm32")]
{
_ = instance;
Err(DeviceError::FoundNoWorkingAdapter)
}
result.ok_or(DeviceError::FoundNoWorkingAdapter)
}
pub async fn new(
@ -101,6 +109,9 @@ impl Device {
label: None,
required_features,
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,
)

View File

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

View File

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

View File

@ -1,7 +1,7 @@
use std::{io, mem::size_of, vec};
use thiserror::Error;
use tracing::{debug, error, trace};
use tracing::{error, trace};
use wgpu::util::DeviceExt as _;
use crate::{
@ -46,8 +46,9 @@ impl Renderer {
// This is sound, as `window` is an object to create a surface upon.
let surface = instance.create_surface(screen.window())?;
#[cfg(not(target_arch = "wasm32"))]
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;