gcore-shaders: fix missing num-traits/libm features

This commit is contained in:
firestar99 2025-08-21 16:22:46 +02:00 committed by Firestar99
parent c5991c6f61
commit db5f2044d9
8 changed files with 14 additions and 10 deletions

1
Cargo.lock generated
View file

@ -2023,6 +2023,7 @@ dependencies = [
"kurbo",
"ndarray",
"node-macro",
"num-traits",
"rand 0.9.1",
"rand_chacha 0.9.0",
"serde",

View file

@ -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",

View file

@ -7,7 +7,7 @@ authors = ["Graphite Authors <contact@graphite.rs>"]
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

View file

@ -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)]

View file

@ -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 {

View file

@ -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]

View file

@ -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 }

View file

@ -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