Skip to content

Commit a1545dd

Browse files
authored
Fix compile failure in WASM without wgpu backend (#14081)
# Objective - When no wgpu backend is selected, there should be a clear explanation. - Fix a regression in 0.14 when not using default features. I hit this compile failure when trying to build bevy_framepace for 0.14.0-rc.4 ``` error[E0432]: unresolved import `crate::core_3d::DEPTH_TEXTURE_SAMPLING_SUPPORTED` --> /Users/aevyrie/.cargo/registry/src/index.crates.io-6f17d22bba15001f/bevy_core_pipeline-0.14.0-rc.4/src/dof/mod.rs:59:19 | 59 | Camera3d, DEPTH_TEXTURE_SAMPLING_SUPPORTED, | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ no `DEPTH_TEXTURE_SAMPLING_SUPPORTED` in `core_3d` | note: found an item that was configured out --> /Users/aevyrie/.cargo/registry/src/index.crates.io-6f17d22bba15001f/bevy_core_pipeline-0.14.0-rc.4/src/core_3d/mod.rs:53:11 | 53 | pub const DEPTH_TEXTURE_SAMPLING_SUPPORTED: bool = false; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ note: found an item that was configured out --> /Users/aevyrie/.cargo/registry/src/index.crates.io-6f17d22bba15001f/bevy_core_pipeline-0.14.0-rc.4/src/core_3d/mod.rs:63:11 | 63 | pub const DEPTH_TEXTURE_SAMPLING_SUPPORTED: bool = true; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ``` ## Solution - Ensure that `DEPTH_TEXTURE_SAMPLING_SUPPORTED` is either `true` or `false`, it shouldn't be completely missing. ## Testing - Building on WASM without default features, which now seemingly no longer includes webgl, will panic on startup with a message saying that no wgpu backend was selected. This is much more helpful than the compile time failure: ``` No wgpu backend feature that is implemented for the target platform was enabled ``` - I can see an argument for making this a compile time failure, however the current failure mode is very confusing for novice users, and provides no clues for how to fix it. If we want this to fail at compile time, we should do it in a way that fails with a helpful message, similar to what this PR acheives.
1 parent 8a7d3ce commit a1545dd

File tree

1 file changed

+1
-1
lines changed
  • crates/bevy_core_pipeline/src/core_3d

1 file changed

+1
-1
lines changed

crates/bevy_core_pipeline/src/core_3d/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ pub const CORE_3D_DEPTH_FORMAT: TextureFormat = TextureFormat::Depth32Float;
4949
/// `sampler2DShadow` and will cheerfully generate invalid GLSL that tries to
5050
/// perform non-percentage-closer-filtering with such a sampler. Therefore we
5151
/// disable depth of field and screen space reflections entirely on WebGL 2.
52-
#[cfg(all(feature = "webgl", target_arch = "wasm32", not(feature = "webgpu")))]
52+
#[cfg(not(any(feature = "webgpu", not(target_arch = "wasm32"))))]
5353
pub const DEPTH_TEXTURE_SAMPLING_SUPPORTED: bool = false;
5454

5555
/// True if multisampled depth textures are supported on this platform.

0 commit comments

Comments
 (0)