Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix cases in which instance creation may not create any context #5059

Merged
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions wgpu/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1718,6 +1718,7 @@ impl Instance {
///
/// Which feature makes this method return true depends on the target platform:
/// * MacOS/iOS: `metal`, `vulkan-portability` or `angle`
/// * Wasm32: `webgpu`, `webgl` or target emscripten.
Wumpf marked this conversation as resolved.
Show resolved Hide resolved
/// * All other: Always returns true
///
/// TODO: Right now it's otherwise not possible yet to opt-out of all features on most platforms.
Expand All @@ -1735,7 +1736,7 @@ impl Instance {
|| cfg!(feature = "angle")
// On the web, either WebGPU or WebGL must be enabled.
} else if cfg!(target_arch = "wasm32") {
cfg!(feature = "webgpu") || cfg!(feature = "webgl")
cfg!(feature = "webgpu") || cfg!(feature = "webgl") || cfg!(target_os = "emscripten")
} else {
true
}
Expand Down Expand Up @@ -1771,8 +1772,10 @@ impl Instance {
}

#[cfg(webgpu)]
if _instance_desc.backends.contains(Backends::BROWSER_WEBGPU)
&& crate::backend::get_browser_gpu_property().map_or(false, |gpu| !gpu.is_undefined())
if !cfg!(wgpu_core) // If wgpu-core isn't enabled we can't use anything else.
|| (_instance_desc.backends.contains(Backends::BROWSER_WEBGPU)
&& crate::backend::get_browser_gpu_property()
.map_or(false, |gpu| !gpu.is_undefined()))
Wumpf marked this conversation as resolved.
Show resolved Hide resolved
{
return Self {
context: Arc::from(crate::backend::ContextWebGpu::init(_instance_desc)),
Expand Down