From 34dced38baae2aaf2238877d74f9dd4559c3a2bc Mon Sep 17 00:00:00 2001 From: Firestar99 Date: Fri, 20 Jun 2025 00:12:30 +0200 Subject: [PATCH] Make `gcore` a std library and remove `std`, `alloc`, and more unused features (#2724) * gcore: remove features `std`, `alloc`, `gpu` and `reflections`, now always available * gcore: remove non-working features `kurbo` and `log` --- Cargo.lock | 32 -------------- editor/Cargo.toml | 1 - .../document/node_graph/node_properties.rs | 7 ---- frontend/wasm/Cargo.toml | 2 +- node-graph/gcore/Cargo.toml | 42 ++++++------------- node-graph/gcore/src/application_io.rs | 7 ---- node-graph/gcore/src/gpu.rs | 20 --------- node-graph/gcore/src/graphic_element.rs | 32 -------------- node-graph/gcore/src/instances.rs | 1 - node-graph/gcore/src/lib.rs | 31 +------------- node-graph/gcore/src/memo.rs | 5 --- node-graph/gcore/src/ops.rs | 5 +-- node-graph/gcore/src/raster.rs | 2 - node-graph/gcore/src/raster/adjustments.rs | 39 +++++------------ node-graph/gcore/src/raster/color.rs | 12 ++---- node-graph/gcore/src/raster/curve.rs | 1 - node-graph/gcore/src/raster/image.rs | 3 -- node-graph/gcore/src/structural.rs | 4 -- node-graph/gcore/src/text/to_path.rs | 6 +-- node-graph/gcore/src/types.rs | 4 -- node-graph/graph-craft/Cargo.toml | 2 +- node-graph/graphene-cli/Cargo.toml | 1 - node-graph/gstd/Cargo.toml | 8 +--- node-graph/interpreted-executor/Cargo.toml | 4 +- node-graph/wgpu-executor/Cargo.toml | 2 +- 25 files changed, 40 insertions(+), 233 deletions(-) delete mode 100644 node-graph/gcore/src/gpu.rs diff --git a/Cargo.lock b/Cargo.lock index 757768e1..c39cb775 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1982,8 +1982,6 @@ version = "0.29.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "dc46dd3ec48fdd8e693a98d2b8bafae273a2d54c1de02a2a7e3d57d501f39677" dependencies = [ - "bytemuck", - "libm", "serde", ] @@ -2194,7 +2192,6 @@ dependencies = [ "serde", "serde_json", "specta", - "spirv-std", "tinyvec", "tokio", "usvg", @@ -3676,7 +3673,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "071dfc062690e90b734c0b2273ce72ad0ffa95f0c74596bc250dcfd960262841" dependencies = [ "autocfg", - "libm", ] [[package]] @@ -5753,34 +5749,6 @@ dependencies = [ "bitflags 2.9.0", ] -[[package]] -name = "spirv-std" -version = "0.9.0" -source = "git+https://github.com/Rust-GPU/rust-gpu.git#6e2c84d4fe64e32df4c060c5a7f3e35a32e45421" -dependencies = [ - "bitflags 1.3.2", - "glam", - "num-traits", - "spirv-std-macros", - "spirv-std-types", -] - -[[package]] -name = "spirv-std-macros" -version = "0.9.0" -source = "git+https://github.com/Rust-GPU/rust-gpu.git#6e2c84d4fe64e32df4c060c5a7f3e35a32e45421" -dependencies = [ - "proc-macro2", - "quote", - "spirv-std-types", - "syn 2.0.99", -] - -[[package]] -name = "spirv-std-types" -version = "0.9.0" -source = "git+https://github.com/Rust-GPU/rust-gpu.git#6e2c84d4fe64e32df4c060c5a7f3e35a32e45421" - [[package]] name = "stable_deref_trait" version = "1.2.0" diff --git a/editor/Cargo.toml b/editor/Cargo.toml index 9fc8c7b8..9b1c3d75 100644 --- a/editor/Cargo.toml +++ b/editor/Cargo.toml @@ -15,7 +15,6 @@ default = ["wasm"] wasm = ["wasm-bindgen", "graphene-std/wasm", "wasm-bindgen-futures"] gpu = [ "interpreted-executor/gpu", - "graphene-std/gpu", "wgpu-executor", ] tauri = ["ron", "decouple-execution"] diff --git a/editor/src/messages/portfolio/document/node_graph/node_properties.rs b/editor/src/messages/portfolio/document/node_graph/node_properties.rs index 95587540..a61c33a3 100644 --- a/editor/src/messages/portfolio/document/node_graph/node_properties.rs +++ b/editor/src/messages/portfolio/document/node_graph/node_properties.rs @@ -1161,13 +1161,6 @@ pub(crate) fn selective_color_properties(node_id: NodeId, context: &mut NodeProp ] } -#[cfg(feature = "gpu")] -pub(crate) fn _gpu_map_properties(parameter_widgets_info: ParameterWidgetsInfo) -> Vec { - let map = text_widget(parameter_widgets_info); - - vec![LayoutGroup::Row { widgets: map }] -} - pub(crate) fn grid_properties(node_id: NodeId, context: &mut NodePropertiesContext) -> Vec { let grid_type_index = grid::GridTypeInput::INDEX; let spacing_index = grid::SpacingInput::::INDEX; diff --git a/frontend/wasm/Cargo.toml b/frontend/wasm/Cargo.toml index d4b308a4..98280c97 100644 --- a/frontend/wasm/Cargo.toml +++ b/frontend/wasm/Cargo.toml @@ -29,7 +29,7 @@ editor = { path = "../../editor", package = "graphite-editor", features = [ # Workspace dependencies graph-craft = { workspace = true } log = { workspace = true } -graphene-core = { workspace = true, features = ["std", "alloc"] } +graphene-core = { workspace = true } serde = { workspace = true, features = ["derive"] } wasm-bindgen = { workspace = true } serde-wasm-bindgen = { workspace = true } diff --git a/node-graph/gcore/Cargo.toml b/node-graph/gcore/Cargo.toml index a18f6a4c..9afddb05 100644 --- a/node-graph/gcore/Cargo.toml +++ b/node-graph/gcore/Cargo.toml @@ -7,28 +7,13 @@ authors = ["Graphite Authors "] license = "MIT OR Apache-2.0" [features] -default = ["serde", "kurbo", "log", "std", "rand_chacha", "wasm"] -log = ["dep:log"] -gpu = ["spirv-std", "glam/bytemuck", "dyn-any", "glam/libm"] +default = ["serde", "wasm"] nightly = [] -alloc = ["dyn-any", "bezier-rs"] type_id_logging = [] wasm = ["web-sys"] wgpu = ["dep:wgpu"] vello = ["dep:vello", "bezier-rs/kurbo", "wgpu"] -dealloc_nodes = ["reflections"] -std = [ - "dyn-any", - "dyn-any/std", - "alloc", - "glam/std", - "specta", - "num-traits/std", - "rustybuzz", - "image", - "reflections", -] -reflections = ["alloc", "ctor"] +dealloc_nodes = [] serde = [ "dep:serde", "glam/serde", @@ -55,31 +40,30 @@ petgraph = { workspace = true, default-features = false, features = [ ] } rustc-hash = { workspace = true } math-parser = { path = "../../libraries/math-parser" } +dyn-any = { workspace = true } +ctor = { workspace = true } +rand_chacha = { workspace = true } +bezier-rs = { workspace = true } +specta = { workspace = true } +rustybuzz = { workspace = true } +image = { workspace = true, default-features = false, features = [ + "png", +] } # Required dependencies half = { version = "2.4.1", default-features = false, features = ["bytemuck"] } tinyvec = { version = "1" } +kurbo = { workspace = true } +log = { workspace = true } # Optional workspace dependencies -dyn-any = { workspace = true, optional = true } -spirv-std = { workspace = true, optional = true } serde = { workspace = true, optional = true, features = ["derive"] } -ctor = { workspace = true, optional = true } -log = { workspace = true, optional = true } -rand_chacha = { workspace = true, optional = true } -bezier-rs = { workspace = true, optional = true } -kurbo = { workspace = true, optional = true } base64 = { workspace = true, optional = true } vello = { workspace = true, optional = true } wgpu = { workspace = true, optional = true } -specta = { workspace = true, optional = true } -rustybuzz = { workspace = true, optional = true } web-sys = { workspace = true, optional = true, features = [ "HtmlCanvasElement", ] } -image = { workspace = true, optional = true, default-features = false, features = [ - "png", -] } [dev-dependencies] # Workspace dependencies diff --git a/node-graph/gcore/src/application_io.rs b/node-graph/gcore/src/application_io.rs index d4e2067b..c3c44d6b 100644 --- a/node-graph/gcore/src/application_io.rs +++ b/node-graph/gcore/src/application_io.rs @@ -36,7 +36,6 @@ impl Hash for SurfaceFrame { } } -#[cfg(feature = "dyn-any")] unsafe impl StaticType for SurfaceFrame { type Static = SurfaceFrame; } @@ -52,8 +51,6 @@ impl Size for web_sys::HtmlCanvasElement { } } -// pub type TextureDataTable = Instances; - #[derive(Debug, Clone)] pub struct ImageTexture { #[cfg(feature = "wgpu")] @@ -84,7 +81,6 @@ impl PartialEq for ImageTexture { } } -#[cfg(feature = "dyn-any")] unsafe impl StaticType for ImageTexture { type Static = ImageTexture; } @@ -123,7 +119,6 @@ impl Size for SurfaceHandle { } } -#[cfg(feature = "dyn-any")] unsafe impl StaticType for SurfaceHandle { type Static = SurfaceHandle; } @@ -134,7 +129,6 @@ pub struct SurfaceHandleFrame { pub transform: DAffine2, } -#[cfg(feature = "dyn-any")] unsafe impl StaticType for SurfaceHandleFrame { type Static = SurfaceHandleFrame; } @@ -309,7 +303,6 @@ impl Debug for EditorApi { } } -#[cfg(feature = "dyn-any")] unsafe impl StaticType for EditorApi { type Static = EditorApi; } diff --git a/node-graph/gcore/src/gpu.rs b/node-graph/gcore/src/gpu.rs deleted file mode 100644 index 1bc59f21..00000000 --- a/node-graph/gcore/src/gpu.rs +++ /dev/null @@ -1,20 +0,0 @@ -use crate::Color; -use crate::raster::Sample; -use bytemuck::{Pod, Zeroable}; -use spirv_std::image::{Image2d, SampledImage}; - -#[repr(C)] -#[derive(Clone, Copy, Debug, PartialEq, Eq, Pod, Zeroable)] -pub struct PushConstants { - pub n: u32, - pub node: u32, -} - -impl Sample for SampledImage { - type Pixel = Color; - - fn sample(&self, pos: glam::DVec2, _area: glam::DVec2) -> Option { - let color = self.sample(pos); - Color::from_rgbaf32(color.x, color.y, color.z, color.w) - } -} diff --git a/node-graph/gcore/src/graphic_element.rs b/node-graph/gcore/src/graphic_element.rs index 284c11c8..4f21cdfc 100644 --- a/node-graph/gcore/src/graphic_element.rs +++ b/node-graph/gcore/src/graphic_element.rs @@ -243,38 +243,6 @@ impl GraphicElement { } } -// // TODO: Rename to Raster -// #[derive(Clone, Debug, Hash, PartialEq, DynAny)] -// pub enum RasterDataType { -// /// A CPU-based bitmap image with a finite position and extent, equivalent to the SVG tag: https://developer.mozilla.org/en-US/docs/Web/SVG/Element/image -// // TODO: Rename to ImageTable -// RasterData(RasterDataTable), -// /// A GPU texture with a finite position and extent -// // TODO: Rename to ImageTextureTable -// TextureData(TextureDataTable), -// } - -// impl<'de> serde::Deserialize<'de> for RasterDataType { -// fn deserialize(deserializer: D) -> Result -// where -// D: serde::Deserializer<'de>, -// { -// Ok(RasterDataType::RasterData(RasterDataTable::new(Image::deserialize(deserializer)?))) -// } -// } - -// impl serde::Serialize for RasterDataType { -// fn serialize(&self, serializer: S) -> Result -// where -// S: serde::Serializer, -// { -// match self { -// RasterDataType::RasterData(_) => self.serialize(serializer), -// RasterDataType::TextureData(_) => todo!(), -// } -// } -// } - impl<'de> serde::Deserialize<'de> for Raster { fn deserialize(deserializer: D) -> Result where diff --git a/node-graph/gcore/src/instances.rs b/node-graph/gcore/src/instances.rs index 18abd982..6a6918c7 100644 --- a/node-graph/gcore/src/instances.rs +++ b/node-graph/gcore/src/instances.rs @@ -142,7 +142,6 @@ impl PartialEq for Instances { } } -#[cfg(feature = "dyn-any")] unsafe impl StaticType for Instances { type Static = Instances; } diff --git a/node-graph/gcore/src/lib.rs b/node-graph/gcore/src/lib.rs index 4ebd3502..5e11bab5 100644 --- a/node-graph/gcore/src/lib.rs +++ b/node-graph/gcore/src/lib.rs @@ -1,17 +1,10 @@ -#![cfg_attr(not(feature = "std"), no_std)] - -#[cfg(feature = "alloc")] extern crate alloc; -#[cfg(feature = "alloc")] -use core::future::Future; -#[cfg_attr(feature = "log", macro_use)] -#[cfg(feature = "log")] +#[macro_use] extern crate log; pub use crate as graphene_core; pub use num_traits; -#[cfg(feature = "reflections")] pub use ctor; pub mod animation; @@ -24,37 +17,26 @@ pub mod misc; pub mod ops; pub mod raster_types; pub mod structural; -#[cfg(feature = "std")] pub mod text; -#[cfg(feature = "std")] pub mod uuid; pub mod value; -#[cfg(feature = "gpu")] -pub mod gpu; - -#[cfg(feature = "alloc")] pub mod memo; pub mod raster; -#[cfg(feature = "alloc")] pub mod transform; -#[cfg(feature = "alloc")] mod graphic_element; -#[cfg(feature = "alloc")] pub use graphic_element::*; -#[cfg(feature = "alloc")] pub mod vector; -#[cfg(feature = "alloc")] pub mod application_io; -#[cfg(feature = "reflections")] pub mod registry; pub use context::*; use core::any::TypeId; +use core::future::Future; use core::pin::Pin; pub use dyn_any::{StaticTypeSized, WasmNotSend, WasmNotSync}; pub use memo::MemoHash; @@ -75,16 +57,13 @@ pub trait Node<'i, Input> { core::any::type_name::() } /// Serialize the node which is used for the `introspect` function which can retrieve values from monitor nodes. - #[cfg(feature = "std")] fn serialize(&self) -> Option> { log::warn!("Node::serialize not implemented for {}", core::any::type_name::()); None } } -#[cfg(feature = "alloc")] mod types; -#[cfg(feature = "alloc")] pub use types::*; pub trait NodeIO<'i, Input>: Node<'i, Input> @@ -104,7 +83,6 @@ where fn output_type_name(&self) -> &'static str { core::any::type_name::() } - #[cfg(feature = "alloc")] fn to_node_io(&self, inputs: Vec) -> NodeIOTypes { NodeIOTypes { call_argument: concrete!(::Static), @@ -112,7 +90,6 @@ where inputs, } } - #[cfg(feature = "alloc")] fn to_async_node_io(&self, inputs: Vec) -> NodeIOTypes where ::Output: StaticTypeSized, @@ -139,14 +116,12 @@ impl<'i, I: 'i, N: Node<'i, I> + ?Sized> Node<'i, I> for &'i N { (*self).eval(input) } } -#[cfg(feature = "alloc")] impl<'i, I: 'i, O: 'i, N: Node<'i, I, Output = O> + ?Sized> Node<'i, I> for Box { type Output = O; fn eval(&'i self, input: I) -> O { (**self).eval(input) } } -#[cfg(feature = "alloc")] impl<'i, I: 'i, O: 'i, N: Node<'i, I, Output = O> + ?Sized> Node<'i, I> for alloc::sync::Arc { type Output = O; fn eval(&'i self, input: I) -> O { @@ -154,7 +129,6 @@ impl<'i, I: 'i, O: 'i, N: Node<'i, I, Output = O> + ?Sized> Node<'i, I> for allo } } -#[cfg(feature = "alloc")] impl<'i, I, O: 'i> Node<'i, I> for Pin + 'i>> { type Output = O; fn eval(&'i self, input: I) -> O { @@ -168,7 +142,6 @@ impl<'i, I, O: 'i> Node<'i, I> for Pin<&'i (dyn NodeIO<'i, I, Output = O> + 'i)> } } -#[cfg(feature = "alloc")] pub use crate::application_io::{SurfaceFrame, SurfaceId}; #[cfg(feature = "wasm")] pub type WasmSurfaceHandle = application_io::SurfaceHandle; diff --git a/node-graph/gcore/src/memo.rs b/node-graph/gcore/src/memo.rs index e7beb149..1f668e6a 100644 --- a/node-graph/gcore/src/memo.rs +++ b/node-graph/gcore/src/memo.rs @@ -1,5 +1,4 @@ use crate::{Node, WasmNotSend}; -#[cfg(feature = "alloc")] use alloc::sync::Arc; use core::future::Future; use core::ops::Deref; @@ -106,7 +105,6 @@ pub struct IORecord { pub output: O, } -#[cfg(feature = "alloc")] /// Caches the output of the last graph evaluation for introspection #[derive(Default)] pub struct MonitorNode { @@ -115,7 +113,6 @@ pub struct MonitorNode { node: N, } -#[cfg(feature = "alloc")] impl<'i, T, I, N> Node<'i, I> for MonitorNode where I: Clone + 'static + Send + Sync, @@ -139,7 +136,6 @@ where } } -#[cfg(feature = "alloc")] impl MonitorNode { pub fn new(node: N) -> MonitorNode { MonitorNode { io: Arc::new(Mutex::new(None)), node } @@ -173,7 +169,6 @@ impl serde::Serialize for MemoHash { } } -#[cfg(feature = "std")] impl MemoHash { pub fn new(value: T) -> Self { let hash = Self::calc_hash(&value); diff --git a/node-graph/gcore/src/ops.rs b/node-graph/gcore/src/ops.rs index 793d821a..99d6b291 100644 --- a/node-graph/gcore/src/ops.rs +++ b/node-graph/gcore/src/ops.rs @@ -495,7 +495,6 @@ fn string_value(_: impl Ctx, _primary: (), string: String) -> String { } /// Meant for debugging purposes, not general use. Returns the size of the input type in bytes. -#[cfg(feature = "std")] #[node_macro::node(category("Debug"))] fn size_of(_: impl Ctx, ty: crate::Type) -> Option { ty.size() @@ -535,8 +534,7 @@ fn extract_xy>(_: impl Ctx, #[implementations(DVec2, IVec2, UVec2 /// The X or Y component of a coordinate. #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -#[cfg_attr(feature = "std", derive(specta::Type))] -#[derive(Debug, Clone, Copy, Default, PartialEq, Eq, Hash, DynAny, node_macro::ChoiceType)] +#[derive(Debug, Clone, Copy, Default, PartialEq, Eq, Hash, DynAny, node_macro::ChoiceType, specta::Type)] #[widget(Dropdown)] pub enum XY { #[default] @@ -587,7 +585,6 @@ impl<'i, N: for<'a> Node<'a, I> + Copy, I: 'i> Copy for TypeNode(PhantomData); impl IntoNode { - #[cfg(feature = "alloc")] pub const fn new() -> Self { Self(core::marker::PhantomData) } diff --git a/node-graph/gcore/src/raster.rs b/node-graph/gcore/src/raster.rs index 7c10f000..08bc69ce 100644 --- a/node-graph/gcore/src/raster.rs +++ b/node-graph/gcore/src/raster.rs @@ -287,9 +287,7 @@ impl BitmapMut for &mut T { } } -#[cfg(feature = "alloc")] pub use self::image::Image; -#[cfg(feature = "alloc")] pub mod image; trait SetBlendMode { diff --git a/node-graph/gcore/src/raster/adjustments.rs b/node-graph/gcore/src/raster/adjustments.rs index bdb4a88e..b020856a 100644 --- a/node-graph/gcore/src/raster/adjustments.rs +++ b/node-graph/gcore/src/raster/adjustments.rs @@ -1,9 +1,7 @@ #![allow(clippy::too_many_arguments)] use crate::raster::curve::{CubicSplines, CurveManipulatorGroup}; -#[cfg(feature = "alloc")] use crate::raster::curve::{Curve, ValueMapperNode}; -#[cfg(feature = "alloc")] use crate::raster::image::Image; use crate::raster::{Channel, Color, Pixel}; use crate::raster_types::{CPU, Raster, RasterDataTable}; @@ -35,8 +33,7 @@ use spirv_std::num_traits::float::Float; // https://www.adobe.com/devnet-apps/photoshop/fileformatashtml/#:~:text=Color%20Lookup%20(Photoshop%20CS6 #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -#[cfg_attr(feature = "std", derive(specta::Type))] -#[derive(Debug, Default, Clone, Copy, Eq, PartialEq, DynAny, Hash, node_macro::ChoiceType)] +#[derive(Debug, Default, Clone, Copy, Eq, PartialEq, DynAny, Hash, node_macro::ChoiceType, specta::Type)] #[widget(Dropdown)] pub enum LuminanceCalculation { #[default] @@ -49,8 +46,7 @@ pub enum LuminanceCalculation { } #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -#[cfg_attr(feature = "std", derive(specta::Type))] -#[derive(Debug, Default, Clone, Copy, Eq, PartialEq, DynAny, Hash)] +#[derive(Debug, Default, Clone, Copy, Eq, PartialEq, DynAny, Hash, specta::Type)] #[repr(i32)] // TODO: Enable Int8 capability for SPIR-V so that we don't need this? pub enum BlendMode { // Basic group @@ -924,8 +920,7 @@ async fn vibrance>( /// Color Channel #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -#[cfg_attr(feature = "std", derive(specta::Type))] -#[derive(Debug, Clone, Copy, Default, PartialEq, Eq, Hash, DynAny, node_macro::ChoiceType)] +#[derive(Debug, Clone, Copy, Default, PartialEq, Eq, Hash, DynAny, node_macro::ChoiceType, specta::Type)] #[widget(Radio)] pub enum RedGreenBlue { #[default] @@ -936,8 +931,7 @@ pub enum RedGreenBlue { /// Color Channel #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -#[cfg_attr(feature = "std", derive(specta::Type))] -#[derive(Debug, Clone, Copy, Default, PartialEq, Eq, Hash, DynAny, node_macro::ChoiceType)] +#[derive(Debug, Clone, Copy, Default, PartialEq, Eq, Hash, DynAny, node_macro::ChoiceType, specta::Type)] #[widget(Radio)] pub enum RedGreenBlueAlpha { #[default] @@ -949,8 +943,7 @@ pub enum RedGreenBlueAlpha { /// Style of noise pattern #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -#[cfg_attr(feature = "std", derive(specta::Type))] -#[derive(Debug, Clone, Copy, Default, PartialEq, Eq, Hash, DynAny, node_macro::ChoiceType)] +#[derive(Debug, Clone, Copy, Default, PartialEq, Eq, Hash, DynAny, node_macro::ChoiceType, specta::Type)] #[widget(Dropdown)] pub enum NoiseType { #[default] @@ -966,8 +959,7 @@ pub enum NoiseType { } #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -#[cfg_attr(feature = "std", derive(specta::Type))] -#[derive(Debug, Clone, Copy, Default, PartialEq, Eq, Hash, DynAny, node_macro::ChoiceType)] +#[derive(Debug, Clone, Copy, Default, PartialEq, Eq, Hash, DynAny, node_macro::ChoiceType, specta::Type)] /// Style of layered levels of the noise pattern pub enum FractalType { #[default] @@ -984,8 +976,7 @@ pub enum FractalType { /// Distance function used by the cellular noise #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -#[cfg_attr(feature = "std", derive(specta::Type))] -#[derive(Debug, Clone, Copy, Default, PartialEq, Eq, Hash, DynAny, node_macro::ChoiceType)] +#[derive(Debug, Clone, Copy, Default, PartialEq, Eq, Hash, DynAny, node_macro::ChoiceType, specta::Type)] pub enum CellularDistanceFunction { #[default] Euclidean, @@ -996,8 +987,7 @@ pub enum CellularDistanceFunction { } #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -#[cfg_attr(feature = "std", derive(specta::Type))] -#[derive(Debug, Clone, Copy, Default, PartialEq, Eq, Hash, DynAny, node_macro::ChoiceType)] +#[derive(Debug, Clone, Copy, Default, PartialEq, Eq, Hash, DynAny, node_macro::ChoiceType, specta::Type)] pub enum CellularReturnType { CellValue, #[default] @@ -1017,8 +1007,7 @@ pub enum CellularReturnType { /// Type of domain warp #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -#[cfg_attr(feature = "std", derive(specta::Type))] -#[derive(Debug, Clone, Copy, Default, PartialEq, Eq, Hash, DynAny, node_macro::ChoiceType)] +#[derive(Debug, Clone, Copy, Default, PartialEq, Eq, Hash, DynAny, node_macro::ChoiceType, specta::Type)] #[widget(Dropdown)] pub enum DomainWarpType { #[default] @@ -1128,8 +1117,7 @@ async fn channel_mixer>( } #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -#[cfg_attr(feature = "std", derive(specta::Type))] -#[derive(Debug, Clone, Copy, Default, PartialEq, Eq, Hash, DynAny, node_macro::ChoiceType)] +#[derive(Debug, Clone, Copy, Default, PartialEq, Eq, Hash, DynAny, node_macro::ChoiceType, specta::Type)] #[widget(Radio)] pub enum RelativeAbsolute { #[default] @@ -1139,8 +1127,7 @@ pub enum RelativeAbsolute { #[repr(C)] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -#[cfg_attr(feature = "std", derive(specta::Type))] -#[derive(Debug, Clone, Copy, Default, PartialEq, Eq, Hash, DynAny, node_macro::ChoiceType)] +#[derive(Debug, Clone, Copy, Default, PartialEq, Eq, Hash, DynAny, node_macro::ChoiceType, specta::Type)] pub enum SelectiveColorChoice { #[default] Reds, @@ -1422,7 +1409,6 @@ async fn exposure>( const WINDOW_SIZE: usize = 1024; -#[cfg(feature = "alloc")] #[node_macro::node(category(""))] fn generate_curves(_: impl Ctx, curve: Curve, #[implementations(f32, f64)] _target_format: C) -> ValueMapperNode { use bezier_rs::{Bezier, TValue}; @@ -1463,7 +1449,6 @@ fn generate_curves(_: impl Ctx, curve: Curve ValueMapperNode::new(lut) } -#[cfg(feature = "alloc")] #[node_macro::node(category("Raster: Adjustment"))] fn color_overlay>( _: impl Ctx, @@ -1491,10 +1476,8 @@ fn color_overlay>( image } -// #[cfg(feature = "alloc")] // pub use index_node::IndexNode; -// #[cfg(feature = "alloc")] // mod index_node { // use crate::raster::{Color, Image}; // use crate::Ctx; diff --git a/node-graph/gcore/src/raster/color.rs b/node-graph/gcore/src/raster/color.rs index 58342827..eeba91a0 100644 --- a/node-graph/gcore/src/raster/color.rs +++ b/node-graph/gcore/src/raster/color.rs @@ -85,8 +85,7 @@ impl Pixel for RGBA16F {} #[repr(C)] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -#[cfg_attr(feature = "std", derive(specta::Type))] -#[derive(Debug, Default, Clone, Copy, PartialEq, DynAny, Pod, Zeroable)] +#[derive(Debug, Default, Clone, Copy, PartialEq, DynAny, Pod, Zeroable, specta::Type)] pub struct SRGBA8 { red: u8, green: u8, @@ -167,8 +166,7 @@ impl Pixel for SRGBA8 {} #[repr(C)] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -#[cfg_attr(feature = "std", derive(specta::Type))] -#[derive(Debug, Default, Clone, Copy, PartialEq, DynAny, Pod, Zeroable)] +#[derive(Debug, Default, Clone, Copy, PartialEq, DynAny, Pod, Zeroable, specta::Type)] pub struct Luma(pub f32); impl Luminance for Luma { @@ -209,8 +207,7 @@ impl Pixel for Luma {} /// the values encode the brightness of each channel proportional to the light intensity in cd/m² (nits) in HDR, and `0.0` (black) to `1.0` (white) in SDR color. #[repr(C)] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -#[cfg_attr(feature = "std", derive(specta::Type))] -#[derive(Debug, Default, Clone, Copy, PartialEq, DynAny, Pod, Zeroable)] +#[derive(Debug, Default, Clone, Copy, PartialEq, DynAny, Pod, Zeroable, specta::Type)] pub struct Color { red: f32, green: f32, @@ -798,7 +795,6 @@ impl Color { /// let color = Color::from_rgba8_srgb(0x52, 0x67, 0xFA, 0x61); // Premultiplied alpha /// assert_eq!("3240a261", color.to_rgba_hex_srgb()); // Equivalent hex incorporating premultiplied alpha /// ``` - #[cfg(feature = "std")] pub fn to_rgba_hex_srgb(&self) -> String { let gamma = self.to_gamma_srgb(); format!( @@ -816,7 +812,6 @@ impl Color { /// let color = Color::from_rgba8_srgb(0x52, 0x67, 0xFA, 0x61); // Premultiplied alpha /// assert_eq!("3240a2", color.to_rgb_hex_srgb()); // Equivalent hex incorporating premultiplied alpha /// ``` - #[cfg(feature = "std")] pub fn to_rgb_hex_srgb(&self) -> String { self.to_gamma_srgb().to_rgb_hex_srgb_from_gamma() } @@ -827,7 +822,6 @@ impl Color { /// let color = Color::from_rgba8_srgb(0x52, 0x67, 0xFA, 0x61); // Premultiplied alpha /// assert_eq!("3240a2", color.to_rgb_hex_srgb()); // Equivalent hex incorporating premultiplied alpha /// ``` - #[cfg(feature = "std")] pub fn to_rgb_hex_srgb_from_gamma(&self) -> String { format!("{:02x?}{:02x?}{:02x?}", (self.r() * 255.) as u8, (self.g() * 255.) as u8, (self.b() * 255.) as u8) } diff --git a/node-graph/gcore/src/raster/curve.rs b/node-graph/gcore/src/raster/curve.rs index 74342e23..edf8a5a6 100644 --- a/node-graph/gcore/src/raster/curve.rs +++ b/node-graph/gcore/src/raster/curve.rs @@ -174,7 +174,6 @@ pub struct ValueMapperNode { lut: Vec, } -#[cfg(feature = "dyn-any")] unsafe impl StaticType for ValueMapperNode { type Static = ValueMapperNode; } diff --git a/node-graph/gcore/src/raster/image.rs b/node-graph/gcore/src/raster/image.rs index a1344308..36254461 100644 --- a/node-graph/gcore/src/raster/image.rs +++ b/node-graph/gcore/src/raster/image.rs @@ -66,7 +66,6 @@ impl Debug for Image

{ } } -#[cfg(feature = "dyn-any")] unsafe impl

StaticType for Image

where P: dyn_any::StaticTypeSized + Pixel, @@ -265,7 +264,6 @@ pub fn migrate_image_frame<'de, D: serde::Deserializer<'de>>(deserializer: D) -> } } - #[cfg(feature = "dyn-any")] unsafe impl

StaticType for ImageFrame

where P: dyn_any::StaticTypeSized + Pixel, @@ -362,7 +360,6 @@ pub fn migrate_image_frame_instance<'de, D: serde::Deserializer<'de>>(deserializ } } - #[cfg(feature = "dyn-any")] unsafe impl

StaticType for ImageFrame

where P: dyn_any::StaticTypeSized + Pixel, diff --git a/node-graph/gcore/src/structural.rs b/node-graph/gcore/src/structural.rs index 8ac833d1..875315a6 100644 --- a/node-graph/gcore/src/structural.rs +++ b/node-graph/gcore/src/structural.rs @@ -55,7 +55,6 @@ pub struct AsyncComposeNode { phantom: PhantomData, } -#[cfg(feature = "alloc")] impl<'i, Input: 'static, First, Second> Node<'i, Input> for AsyncComposeNode where First: Node<'i, Input>, @@ -71,7 +70,6 @@ where } } -#[cfg(feature = "alloc")] impl<'i, First, Second, Input: 'i> AsyncComposeNode where First: Node<'i, Input>, @@ -95,7 +93,6 @@ pub trait Then<'i, Input: 'i>: Sized { impl<'i, First: Node<'i, Input>, Input: 'i> Then<'i, Input> for First {} -#[cfg(feature = "alloc")] pub trait AndThen<'i, Input: 'i>: Sized { fn and_then(self, second: Second) -> AsyncComposeNode where @@ -107,7 +104,6 @@ pub trait AndThen<'i, Input: 'i>: Sized { } } -#[cfg(feature = "alloc")] impl<'i, First: Node<'i, Input>, Input: 'i> AndThen<'i, Input> for First {} pub struct ConsNode, Root>(pub Root, PhantomData); diff --git a/node-graph/gcore/src/text/to_path.rs b/node-graph/gcore/src/text/to_path.rs index 2552127b..6b4bfc5e 100644 --- a/node-graph/gcore/src/text/to_path.rs +++ b/node-graph/gcore/src/text/to_path.rs @@ -23,7 +23,7 @@ impl Builder { impl OutlineBuilder for Builder { fn move_to(&mut self, x: f32, y: f32) { if !self.current_subpath.is_empty() { - self.other_subpaths.push(core::mem::replace(&mut self.current_subpath, Subpath::new(Vec::new(), false))); + self.other_subpaths.push(std::mem::replace(&mut self.current_subpath, Subpath::new(Vec::new(), false))); } self.current_subpath.push_manipulator_group(ManipulatorGroup::new_anchor_with_id(self.point(x, y), self.id.next_id())); } @@ -47,7 +47,7 @@ impl OutlineBuilder for Builder { fn close(&mut self) { self.current_subpath.set_closed(true); - self.other_subpaths.push(core::mem::replace(&mut self.current_subpath, Subpath::new(Vec::new(), false))); + self.other_subpaths.push(std::mem::replace(&mut self.current_subpath, Subpath::new(Vec::new(), false))); } } @@ -139,7 +139,7 @@ pub fn to_path(str: &str, buzz_face: Option, typesetting: Types builder.offset = DVec2::new(glyph_position.x_offset as f64, glyph_position.y_offset as f64) * builder.scale; buzz_face.outline_glyph(glyph_id, &mut builder); if !builder.current_subpath.is_empty() { - builder.other_subpaths.push(core::mem::replace(&mut builder.current_subpath, Subpath::new(Vec::new(), false))); + builder.other_subpaths.push(std::mem::replace(&mut builder.current_subpath, Subpath::new(Vec::new(), false))); } builder.text_cursor += DVec2::new(glyph_position.x_advance as f64 * typesetting.character_spacing, glyph_position.y_advance as f64) * builder.scale; diff --git a/node-graph/gcore/src/types.rs b/node-graph/gcore/src/types.rs index b65668d1..8bad9514 100644 --- a/node-graph/gcore/src/types.rs +++ b/node-graph/gcore/src/types.rs @@ -1,8 +1,5 @@ use core::any::TypeId; -#[cfg(not(feature = "std"))] -pub use alloc::borrow::Cow; -#[cfg(feature = "std")] pub use std::borrow::Cow; #[macro_export] @@ -215,7 +212,6 @@ impl Default for Type { } } -#[cfg(feature = "dyn-any")] unsafe impl dyn_any::StaticType for Type { type Static = Self; } diff --git a/node-graph/graph-craft/Cargo.toml b/node-graph/graph-craft/Cargo.toml index 2c09d01b..71e71809 100644 --- a/node-graph/graph-craft/Cargo.toml +++ b/node-graph/graph-craft/Cargo.toml @@ -22,7 +22,7 @@ dyn-any = { path = "../../libraries/dyn-any", features = [ ] } # Workspace dependencies -graphene-core = { workspace = true, features = ["std"] } +graphene-core = { workspace = true } log = { workspace = true } glam = { workspace = true } bezier-rs = { workspace = true } diff --git a/node-graph/graphene-cli/Cargo.toml b/node-graph/graphene-cli/Cargo.toml index 00bafb10..87e0e679 100644 --- a/node-graph/graphene-cli/Cargo.toml +++ b/node-graph/graphene-cli/Cargo.toml @@ -15,7 +15,6 @@ passthrough = ["wgpu-executor/passthrough"] gpu = [ "interpreted-executor/gpu", "graphene-std/gpu", - "graphene-core/gpu", "wgpu-executor", ] diff --git a/node-graph/gstd/Cargo.toml b/node-graph/gstd/Cargo.toml index 74b222fa..80fd05a1 100644 --- a/node-graph/gstd/Cargo.toml +++ b/node-graph/gstd/Cargo.toml @@ -8,7 +8,7 @@ license = "MIT OR Apache-2.0" [features] default = ["wasm", "imaginate"] -gpu = [ "graphene-core/gpu" ] +gpu = [] wgpu = ["gpu", "graph-craft/wgpu"] wasm = ["wasm-bindgen", "web-sys"] imaginate = ["image/png", "base64", "web-sys", "wasm-bindgen-futures"] @@ -22,11 +22,7 @@ wayland = ["graph-craft/wayland"] dyn-any = { path = "../../libraries/dyn-any", features = ["derive", "reqwest"] } graph-craft = { path = "../graph-craft", features = ["serde"] } wgpu-executor = { path = "../wgpu-executor" } -graphene-core = { path = "../gcore", default-features = false, features = [ - "std", - "serde", - "alloc", -] } +graphene-core = { path = "../gcore", default-features = false, features = ["serde"] } # Workspace dependencies fastnoise-lite = { workspace = true } diff --git a/node-graph/interpreted-executor/Cargo.toml b/node-graph/interpreted-executor/Cargo.toml index 87787ee3..03c70e9e 100644 --- a/node-graph/interpreted-executor/Cargo.toml +++ b/node-graph/interpreted-executor/Cargo.toml @@ -7,7 +7,7 @@ license = "MIT OR Apache-2.0" [features] default = [] serde = ["dep:serde", "graphene-std/serde", "glam/serde"] -gpu = ["graphene-std/gpu", "graphene-core/gpu", "graphene-std/wgpu"] +gpu = ["graphene-std/gpu", "graphene-std/wgpu"] [dependencies] # Local dependencies @@ -16,7 +16,7 @@ graph-craft = { path = "../graph-craft" } wgpu-executor = { path = "../wgpu-executor" } # Workspace dependencies -graphene-core = { workspace = true, features = ["std"] } +graphene-core = { workspace = true } dyn-any = { workspace = true, features = ["log-bad-types", "glam"] } log = { workspace = true } glam = { workspace = true } diff --git a/node-graph/wgpu-executor/Cargo.toml b/node-graph/wgpu-executor/Cargo.toml index 852d70c3..ecbfc7bc 100644 --- a/node-graph/wgpu-executor/Cargo.toml +++ b/node-graph/wgpu-executor/Cargo.toml @@ -11,7 +11,7 @@ passthrough = [] [dependencies] # Workspace dependencies -graphene-core = { workspace = true, features = ["std", "alloc", "gpu", "wgpu"] } +graphene-core = { workspace = true, features = ["wgpu"] } dyn-any = { workspace = true, features = ["log-bad-types", "rc", "glam"] } node-macro = { workspace = true } glam = { workspace = true }