Merge pull request #2828 from dtzxporter/add-wgpu-feature-no-backends

Add an option for the wgpu feature to disable the default backends.
This commit is contained in:
Héctor 2025-11-21 02:20:55 +01:00 committed by GitHub
commit 1e5fddd42a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 17 additions and 13 deletions

View file

@ -23,9 +23,11 @@ maintenance = { status = "actively-developed" }
[features] [features]
default = ["wgpu", "tiny-skia", "crisp", "web-colors", "thread-pool", "linux-theme-detection"] default = ["wgpu", "tiny-skia", "crisp", "web-colors", "thread-pool", "linux-theme-detection"]
# Enables the `wgpu` GPU-accelerated renderer backend # Enables the `wgpu` GPU-accelerated renderer with all its default features (Vulkan, Metal, DX12, OpenGL, and WebGPU)
wgpu = ["iced_renderer/wgpu", "iced_widget/wgpu"] wgpu = ["wgpu-bare", "iced_renderer/wgpu"]
# Enables the `tiny-skia` software renderer backend # Enables the `wgpu` GPU-accelerated renderer with the minimum required features (no backends!)
wgpu-bare = ["iced_renderer/wgpu-bare", "iced_widget/wgpu"]
# Enables the `tiny-skia` software renderer
tiny-skia = ["iced_renderer/tiny-skia"] tiny-skia = ["iced_renderer/tiny-skia"]
# Enables the `image` widget # Enables the `image` widget
image = ["image-without-codecs", "image/default"] image = ["image-without-codecs", "image/default"]
@ -175,7 +177,7 @@ iced_selector = { version = "0.14.0-dev", path = "selector" }
iced_test = { version = "0.14.0-dev", path = "test" } iced_test = { version = "0.14.0-dev", path = "test" }
iced_tester = { version = "0.14.0-dev", path = "tester" } iced_tester = { version = "0.14.0-dev", path = "tester" }
iced_tiny_skia = { version = "0.14.0-dev", path = "tiny_skia" } iced_tiny_skia = { version = "0.14.0-dev", path = "tiny_skia" }
iced_wgpu = { version = "0.14.0-dev", path = "wgpu" } iced_wgpu = { version = "0.14.0-dev", path = "wgpu", default-features = false }
iced_widget = { version = "0.14.0-dev", path = "widget" } iced_widget = { version = "0.14.0-dev", path = "widget" }
iced_winit = { version = "0.14.0-dev", path = "winit" } iced_winit = { version = "0.14.0-dev", path = "winit" }
@ -227,7 +229,7 @@ wasm-bindgen-futures = "0.4"
wasmtimer = "0.4.1" wasmtimer = "0.4.1"
web-sys = "0.3.69" web-sys = "0.3.69"
web-time = "1.1" web-time = "1.1"
wgpu = "27.0" wgpu = { version = "27.0", default-features = false, features = ["std", "wgsl"] }
window_clipboard = "0.4.1" window_clipboard = "0.4.1"
winit = { git = "https://github.com/iced-rs/winit.git", rev = "05b8ff17a06562f0a10bb46e6eaacbe2a95cb5ed" } winit = { git = "https://github.com/iced-rs/winit.git", rev = "05b8ff17a06562f0a10bb46e6eaacbe2a95cb5ed" }

View file

@ -14,7 +14,8 @@ keywords.workspace = true
workspace = true workspace = true
[features] [features]
wgpu = ["iced_wgpu"] wgpu = ["iced_wgpu/default"]
wgpu-bare = ["iced_wgpu"]
tiny-skia = ["iced_tiny_skia"] tiny-skia = ["iced_tiny_skia"]
image = ["iced_tiny_skia?/image", "iced_wgpu?/image"] image = ["iced_tiny_skia?/image", "iced_wgpu?/image"]
svg = ["iced_tiny_skia?/svg", "iced_wgpu?/svg"] svg = ["iced_tiny_skia?/svg", "iced_wgpu?/svg"]

View file

@ -411,7 +411,7 @@ where
} }
} }
#[cfg(feature = "wgpu")] #[cfg(feature = "wgpu-bare")]
impl<A, B> iced_wgpu::primitive::Renderer for Renderer<A, B> impl<A, B> iced_wgpu::primitive::Renderer for Renderer<A, B>
where where
A: iced_wgpu::primitive::Renderer, A: iced_wgpu::primitive::Renderer,

View file

@ -1,7 +1,7 @@
//! The official renderer for iced. //! The official renderer for iced.
#![cfg_attr(docsrs, feature(doc_cfg))] #![cfg_attr(docsrs, feature(doc_cfg))]
#[cfg(feature = "wgpu")] #[cfg(feature = "wgpu-bare")]
pub use iced_wgpu as wgpu; pub use iced_wgpu as wgpu;
pub mod fallback; pub mod fallback;
@ -22,7 +22,7 @@ pub type Renderer = renderer::Renderer;
/// [`iced`]: https://github.com/iced-rs/iced /// [`iced`]: https://github.com/iced-rs/iced
pub type Compositor = renderer::Compositor; pub type Compositor = renderer::Compositor;
#[cfg(all(feature = "wgpu", feature = "tiny-skia"))] #[cfg(all(feature = "wgpu-bare", feature = "tiny-skia"))]
mod renderer { mod renderer {
pub type Renderer = crate::fallback::Renderer< pub type Renderer = crate::fallback::Renderer<
iced_wgpu::Renderer, iced_wgpu::Renderer,
@ -35,19 +35,19 @@ mod renderer {
>; >;
} }
#[cfg(all(feature = "wgpu", not(feature = "tiny-skia")))] #[cfg(all(feature = "wgpu-bare", not(feature = "tiny-skia")))]
mod renderer { mod renderer {
pub type Renderer = iced_wgpu::Renderer; pub type Renderer = iced_wgpu::Renderer;
pub type Compositor = iced_wgpu::window::Compositor; pub type Compositor = iced_wgpu::window::Compositor;
} }
#[cfg(all(not(feature = "wgpu"), feature = "tiny-skia"))] #[cfg(all(not(feature = "wgpu-bare"), feature = "tiny-skia"))]
mod renderer { mod renderer {
pub type Renderer = iced_tiny_skia::Renderer; pub type Renderer = iced_tiny_skia::Renderer;
pub type Compositor = iced_tiny_skia::window::Compositor; pub type Compositor = iced_tiny_skia::window::Compositor;
} }
#[cfg(not(any(feature = "wgpu", feature = "tiny-skia")))] #[cfg(not(any(feature = "wgpu-bare", feature = "tiny-skia")))]
mod renderer { mod renderer {
#[cfg(not(debug_assertions))] #[cfg(not(debug_assertions))]
compile_error!( compile_error!(

View file

@ -18,6 +18,7 @@ rustdoc-args = ["--cfg", "docsrs"]
all-features = true all-features = true
[features] [features]
default = ["wgpu/default"]
geometry = ["iced_graphics/geometry", "lyon"] geometry = ["iced_graphics/geometry", "lyon"]
image = ["iced_graphics/image"] image = ["iced_graphics/image"]
svg = ["iced_graphics/svg", "resvg/text"] svg = ["iced_graphics/svg", "resvg/text"]

View file

@ -23,7 +23,7 @@ image = ["iced_renderer/image"]
svg = ["iced_renderer/svg"] svg = ["iced_renderer/svg"]
canvas = ["iced_renderer/geometry"] canvas = ["iced_renderer/geometry"]
qr_code = ["canvas", "dep:qrcode"] qr_code = ["canvas", "dep:qrcode"]
wgpu = ["iced_renderer/wgpu"] wgpu = ["iced_renderer/wgpu-bare"]
markdown = ["dep:pulldown-cmark", "dep:url"] markdown = ["dep:pulldown-cmark", "dep:url"]
highlighter = ["dep:iced_highlighter"] highlighter = ["dep:iced_highlighter"]
advanced = [] advanced = []