Skip to content

Commit

Permalink
New bounds
Browse files Browse the repository at this point in the history
  • Loading branch information
nanoqsh committed Jun 22, 2024
1 parent 4554328 commit e317550
Show file tree
Hide file tree
Showing 7 changed files with 28 additions and 57 deletions.
3 changes: 1 addition & 2 deletions dunge_shader/src/access.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,7 @@ impl<A, E> Take<A, E> {

impl<A, E> Eval<E> for Ret<Take<A, E>, <A::Out as Access>::Member>
where
A: Eval<E>,
A::Out: Access,
A: Eval<E, Out: Access>,
E: GetEntry,
{
type Out = <A::Out as Access>::Member;
Expand Down
12 changes: 4 additions & 8 deletions dunge_shader/src/branch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@ where
C: Eval<E, Out = bool>,
A: FnOnce() -> X,
B: FnOnce() -> Y,
X: Eval<E>,
X::Out: types::Value,
X: Eval<E, Out: types::Value>,
Y: Eval<E, Out = X::Out>,
{
Ret::new(IfThenElse {
Expand All @@ -36,8 +35,7 @@ where
C: Eval<E>,
A: FnOnce() -> X,
B: FnOnce() -> Y,
X: Eval<E>,
X::Out: types::Value,
X: Eval<E, Out: types::Value>,
Y: Eval<E>,
E: GetEntry,
{
Expand Down Expand Up @@ -72,8 +70,7 @@ impl<B> Else<B> {
C: Eval<E, Out = bool>,
A: FnOnce() -> X,
B: FnOnce() -> Y,
X: Eval<E>,
X::Out: types::Value,
X: Eval<E, Out: types::Value>,
Y: Eval<E, Out = X::Out>,
{
Ret::new(When {
Expand Down Expand Up @@ -114,8 +111,7 @@ where
C: Eval<E>,
A: FnOnce() -> X,
B: EvalBranch<E>,
X: Eval<E>,
X::Out: types::Value,
X: Eval<E, Out: types::Value>,
E: GetEntry,
{
type Out = X::Out;
Expand Down
12 changes: 4 additions & 8 deletions dunge_shader/src/convert.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,32 +9,28 @@ use {

pub const fn f32<A, E>(a: A) -> Ret<As<A, E>, f32>
where
A: Eval<E>,
A::Out: Scalar,
A: Eval<E, Out: Scalar>,
{
Ret::new(As::new(a))
}

pub const fn i32<A, E>(a: A) -> Ret<As<A, E>, i32>
where
A: Eval<E>,
A::Out: Scalar,
A: Eval<E, Out: Scalar>,
{
Ret::new(As::new(a))
}

pub const fn u32<A, E>(a: A) -> Ret<As<A, E>, u32>
where
A: Eval<E>,
A::Out: Scalar,
A: Eval<E, Out: Scalar>,
{
Ret::new(As::new(a))
}

pub const fn bool<A, E>(a: A) -> Ret<As<A, E>, bool>
where
A: Eval<E>,
A::Out: Scalar,
A: Eval<E, Out: Scalar>,
{
Ret::new(As::new(a))
}
Expand Down
6 changes: 2 additions & 4 deletions dunge_shader/src/eval.rs
Original file line number Diff line number Diff line change
Expand Up @@ -300,8 +300,7 @@ where

pub const fn fragment<A>(a: A) -> Ret<Fragment<A>, A::Out>
where
A: Eval<Vs>,
A::Out: types::Vector,
A: Eval<Vs, Out: types::Vector>,
{
Ret::new(Fragment(a))
}
Expand All @@ -310,8 +309,7 @@ pub struct Fragment<A>(A);

impl<A> Eval<Fs> for Ret<Fragment<A>, A::Out>
where
A: Eval<Vs> + 'static,
A::Out: types::Vector,
A: Eval<Vs, Out: types::Vector> + 'static,
{
type Out = A::Out;

Expand Down
10 changes: 3 additions & 7 deletions dunge_shader/src/math.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,7 @@ use {

pub const fn abs<X, E>(x: X) -> Ret<Math<(X,), E>, X::Out>
where
X: Eval<E>,
X::Out: types::Number,
X: Eval<E, Out: types::Number>,
{
Ret::new(Math::new((x,), MathFunction::Abs))
}
Expand Down Expand Up @@ -75,8 +74,7 @@ where

pub const fn clamp<X, L, H, E>(x: X, lo: L, hi: H) -> Ret<Math<(X, L, H), E>, f32>
where
X: Eval<E>,
X::Out: types::Number,
X: Eval<E, Out: types::Number>,
L: Eval<E, Out = X::Out>,
H: Eval<E, Out = X::Out>,
{
Expand Down Expand Up @@ -108,9 +106,7 @@ where
#[allow(clippy::type_complexity)]
pub const fn dot<X, Y, E>(x: X, y: Y) -> Ret<Math<(X, Y), E>, <X::Out as types::Vector>::Scalar>
where
X: Eval<E>,
X::Out: types::Vector,
<X::Out as types::Vector>::Scalar: types::Number,
X: Eval<E, Out: types::Vector<Scalar: types::Number>>,
Y: Eval<E, Out = X::Out>,
{
Ret::new(Math::new((x, y), MathFunction::Dot))
Expand Down
18 changes: 6 additions & 12 deletions dunge_shader/src/op.rs
Original file line number Diff line number Diff line change
Expand Up @@ -210,53 +210,47 @@ where

pub const fn eq<A, B, E>(a: A, b: B) -> Ret<Binary<A, B>, bool>
where
A: Eval<E>,
A::Out: Scalar,
A: Eval<E, Out: Scalar>,
B: Eval<E, Out = A::Out>,
{
Ret::new(Binary { a, b, op: Bi::Eq })
}

pub const fn ne<A, B, E>(a: A, b: B) -> Ret<Binary<A, B>, bool>
where
A: Eval<E>,
A::Out: Scalar,
A: Eval<E, Out: Scalar>,
B: Eval<E, Out = A::Out>,
{
Ret::new(Binary { a, b, op: Bi::Ne })
}

pub const fn lt<A, B, E>(a: A, b: B) -> Ret<Binary<A, B>, bool>
where
A: Eval<E>,
A::Out: Number,
A: Eval<E, Out: Number>,
B: Eval<E, Out = A::Out>,
{
Ret::new(Binary { a, b, op: Bi::Lt })
}

pub const fn le<A, B, E>(a: A, b: B) -> Ret<Binary<A, B>, bool>
where
A: Eval<E>,
A::Out: Number,
A: Eval<E, Out: Number>,
B: Eval<E, Out = A::Out>,
{
Ret::new(Binary { a, b, op: Bi::Le })
}

pub const fn gt<A, B, E>(a: A, b: B) -> Ret<Binary<A, B>, bool>
where
A: Eval<E>,
A::Out: Number,
A: Eval<E, Out: Number>,
B: Eval<E, Out = A::Out>,
{
Ret::new(Binary { a, b, op: Bi::Gt })
}

pub const fn ge<A, B, E>(a: A, b: B) -> Ret<Binary<A, B>, bool>
where
A: Eval<E>,
A::Out: Number,
A: Eval<E, Out: Number>,
B: Eval<E, Out = A::Out>,
{
Ret::new(Binary { a, b, op: Bi::Ge })
Expand Down
24 changes: 8 additions & 16 deletions dunge_shader/src/vector.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,24 +68,21 @@ where

pub const fn splat_vec2<A, E>(a: A) -> Ret<Splat<A, E>, types::Vec2<A::Out>>
where
A: Eval<E>,
A::Out: Scalar,
A: Eval<E, Out: Scalar>,
{
Ret::new(Splat::new(a))
}

pub const fn splat_vec3<A, E>(a: A) -> Ret<Splat<A, E>, types::Vec3<A::Out>>
where
A: Eval<E>,
A::Out: Scalar,
A: Eval<E, Out: Scalar>,
{
Ret::new(Splat::new(a))
}

pub const fn splat_vec4<A, E>(a: A) -> Ret<Splat<A, E>, types::Vec4<A::Out>>
where
A: Eval<E>,
A::Out: Scalar,
A: Eval<E, Out: Scalar>,
{
Ret::new(Splat::new(a))
}
Expand Down Expand Up @@ -122,8 +119,7 @@ type Vector2<X, Y, O, E> = Ret<NewVec<(X, Y), E>, types::Vec2<O>>;

pub const fn vec2<X, Y, E>(x: X, y: Y) -> Vector2<X, Y, X::Out, E>
where
X: Eval<E>,
X::Out: Scalar,
X: Eval<E, Out: Scalar>,
Y: Eval<E, Out = X::Out>,
{
Ret::new(NewVec::new((x, y)))
Expand All @@ -133,8 +129,7 @@ type Vector3<X, Y, Z, O, E> = Ret<NewVec<(X, Y, Z), E>, types::Vec3<O>>;

pub const fn vec3<X, Y, Z, E>(x: X, y: Y, z: Z) -> Vector3<X, Y, Z, X::Out, E>
where
X: Eval<E>,
X::Out: Scalar,
X: Eval<E, Out: Scalar>,
Y: Eval<E, Out = X::Out>,
Z: Eval<E, Out = X::Out>,
{
Expand All @@ -145,8 +140,7 @@ type Vector4<X, Y, Z, W, O, E> = Ret<NewVec<(X, Y, Z, W), E>, types::Vec4<O>>;

pub const fn vec4<X, Y, Z, W, E>(x: X, y: Y, z: Z, w: W) -> Vector4<X, Y, Z, W, X::Out, E>
where
X: Eval<E>,
X::Out: Scalar,
X: Eval<E, Out: Scalar>,
Y: Eval<E, Out = X::Out>,
Z: Eval<E, Out = X::Out>,
W: Eval<E, Out = X::Out>,
Expand Down Expand Up @@ -195,17 +189,15 @@ where
pub const fn vec3_with<A, B, S, E>(a: A, b: B) -> Ret<Compose<A, B>, types::Vec3<B::Out>>
where
A: Eval<E, Out = types::Vec2<B::Out>>,
B: Eval<E>,
B::Out: Scalar,
B: Eval<E, Out: Scalar>,
{
Ret::new(Compose { a, b })
}

pub const fn vec4_with<A, B, E>(a: A, b: B) -> Ret<Compose<A, B>, types::Vec4<B::Out>>
where
A: Eval<E, Out = types::Vec3<B::Out>>,
B: Eval<E>,
B::Out: Scalar,
B: Eval<E, Out: Scalar>,
{
Ret::new(Compose { a, b })
}
Expand Down

0 comments on commit e317550

Please sign in to comment.