diff --git a/Cargo.lock b/Cargo.lock index db71f65cb..e38f273a2 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2023,6 +2023,7 @@ dependencies = [ "kurbo", "ndarray", "node-macro", + "num-traits", "rand 0.9.1", "rand_chacha 0.9.0", "serde", diff --git a/Cargo.toml b/Cargo.toml index 62f086609..fbd1ad73b 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -142,7 +142,7 @@ pretty_assertions = "1.4.1" fern = { version = "0.7", features = ["colored"] } num_enum = "0.7" num-derive = "0.4" -num-traits = { version = "0.2", default-features = false, features = ["i128"] } +num-traits = { version = "0.2", default-features = false, features = ["libm"] } specta = { version = "2.0.0-rc.22", features = [ "glam", "derive", diff --git a/node-graph/gcore-shaders/Cargo.toml b/node-graph/gcore-shaders/Cargo.toml index 9759217f0..0a969febe 100644 --- a/node-graph/gcore-shaders/Cargo.toml +++ b/node-graph/gcore-shaders/Cargo.toml @@ -7,7 +7,7 @@ authors = ["Graphite Authors "] license = "MIT OR Apache-2.0" [features] -std = ["dep:dyn-any", "dep:serde", "dep:specta", "dep:log", "half/std", "half/serde"] +std = ["dep:dyn-any", "dep:serde", "dep:specta", "dep:log", "half/std", "half/serde", "num-traits/std"] [dependencies] # Local std dependencies diff --git a/node-graph/gcore-shaders/src/blending.rs b/node-graph/gcore-shaders/src/blending.rs index 0d57bd0aa..c3701e2cc 100644 --- a/node-graph/gcore-shaders/src/blending.rs +++ b/node-graph/gcore-shaders/src/blending.rs @@ -1,6 +1,6 @@ use core::fmt::Display; use core::hash::{Hash, Hasher}; -#[cfg(target_arch = "spirv")] +#[cfg(not(feature = "std"))] use num_traits::float::Float; #[derive(Debug, Clone, Copy, PartialEq)] diff --git a/node-graph/gcore-shaders/src/color/color_traits.rs b/node-graph/gcore-shaders/src/color/color_traits.rs index 08e6895b3..05b024232 100644 --- a/node-graph/gcore-shaders/src/color/color_traits.rs +++ b/node-graph/gcore-shaders/src/color/color_traits.rs @@ -3,7 +3,7 @@ use bytemuck::{Pod, Zeroable}; use core::fmt::Debug; use glam::DVec2; use num_derive::*; -#[cfg(target_arch = "spirv")] +#[cfg(not(feature = "std"))] use num_traits::float::Float; pub trait Linear { diff --git a/node-graph/gcore-shaders/src/color/color_types.rs b/node-graph/gcore-shaders/src/color/color_types.rs index b745d5654..6a3f276e3 100644 --- a/node-graph/gcore-shaders/src/color/color_types.rs +++ b/node-graph/gcore-shaders/src/color/color_types.rs @@ -4,9 +4,9 @@ use bytemuck::{Pod, Zeroable}; use core::fmt::Debug; use core::hash::Hash; use half::f16; -#[cfg(target_arch = "spirv")] +#[cfg(not(feature = "std"))] use num_traits::Euclid; -#[cfg(target_arch = "spirv")] +#[cfg(not(feature = "std"))] use num_traits::float::Float; #[repr(C)] @@ -439,9 +439,9 @@ impl Color { lightness + saturation - lightness * saturation }; let temp2 = 2. * lightness - temp1; - #[cfg(not(target_arch = "spirv"))] + #[cfg(feature = "std")] let rem = |x: f32| x.rem_euclid(1.); - #[cfg(target_arch = "spirv")] + #[cfg(not(feature = "std"))] let rem = |x: f32| x.rem_euclid(&1.); let mut red = rem(hue + 1. / 3.); @@ -892,9 +892,9 @@ impl Color { } else { 4. + (self.red - self.green) / (max_channel - min_channel) } / 6.; - #[cfg(not(target_arch = "spirv"))] + #[cfg(feature = "std")] let hue = hue.rem_euclid(1.); - #[cfg(target_arch = "spirv")] + #[cfg(not(feature = "std"))] let hue = hue.rem_euclid(&1.); [hue, saturation, lightness, self.alpha] diff --git a/node-graph/graster-nodes/Cargo.toml b/node-graph/graster-nodes/Cargo.toml index a3555a05e..3dfcc96e5 100644 --- a/node-graph/graster-nodes/Cargo.toml +++ b/node-graph/graster-nodes/Cargo.toml @@ -34,6 +34,7 @@ graphene-core = { workspace = true, optional = true } bytemuck = { workspace = true } # glam is reexported from gcore-shaders in no_std mode glam = { workspace = true, optional = true } +num-traits = { workspace = true } # Workspace std dependencies specta = { workspace = true, optional = true } diff --git a/node-graph/graster-nodes/src/adjustments.rs b/node-graph/graster-nodes/src/adjustments.rs index fdfae312d..4d745b14b 100644 --- a/node-graph/graster-nodes/src/adjustments.rs +++ b/node-graph/graster-nodes/src/adjustments.rs @@ -11,6 +11,8 @@ use graphene_core::table::Table; use graphene_core_shaders::color::Color; use graphene_core_shaders::context::Ctx; use graphene_core_shaders::registry::types::{Angle, Percentage, SignedPercentage}; +#[cfg(not(feature = "std"))] +use num_traits::float::Float; // TODO: Implement the following: // Color Balance