From b06f49ec349a6824ee2064531dcc8c31da620e8e Mon Sep 17 00:00:00 2001 From: Xiaochun Tong Date: Sat, 23 Sep 2023 11:04:26 -0400 Subject: [PATCH] fixed _deref_proxy, how wasn't it crashing... --- luisa_compute/src/lang/ops/impls.rs | 4 ++-- luisa_compute/src/lang/ops/spread.rs | 12 ++++++------ luisa_compute/src/lang/ops/traits.rs | 6 +++--- luisa_compute/src/lang/types.rs | 6 ++---- 4 files changed, 13 insertions(+), 15 deletions(-) diff --git a/luisa_compute/src/lang/ops/impls.rs b/luisa_compute/src/lang/ops/impls.rs index 7eb76511..2c137664 100644 --- a/luisa_compute/src/lang/ops/impls.rs +++ b/luisa_compute/src/lang/ops/impls.rs @@ -69,8 +69,8 @@ macro_rules! impl_simple_binop { impl_ops_trait!([X: Linear] MinMaxExpr[MinMaxThis] for Expr where [X::Scalar: Numeric] { type Output = Expr>; - fn max_expr[_max_expr](self, other) { Func::Max.call2(self, other) } - fn min_expr[_min_expr](self, other) { Func::Min.call2(self, other) } + fn max_[_max_](self, other) { Func::Max.call2(self, other) } + fn min_[_min_](self, other) { Func::Min.call2(self, other) } }); impl_ops_trait!([X: Linear] ClampExpr[ClampThis] for Expr where [X::Scalar: Numeric] { diff --git a/luisa_compute/src/lang/ops/spread.rs b/luisa_compute/src/lang/ops/spread.rs index 66578338..3c583d3c 100644 --- a/luisa_compute/src/lang/ops/spread.rs +++ b/luisa_compute/src/lang/ops/spread.rs @@ -213,11 +213,11 @@ where Expr: MinMaxThis, { type Output = as MinMaxThis>::Output; - fn min_expr(self, other: S) -> Self::Output { - Expr::::_min_expr(Self::lift_self(self), Self::lift_other(other)) + fn min_(self, other: S) -> Self::Output { + Expr::::_min_(Self::lift_self(self), Self::lift_other(other)) } - fn max_expr(self, other: S) -> Self::Output { - Expr::::_max_expr(Self::lift_self(self), Self::lift_other(other)) + fn max_(self, other: S) -> Self::Output { + Expr::::_max_(Self::lift_self(self), Self::lift_other(other)) } } @@ -225,13 +225,13 @@ pub fn min(x: T, y: S) -> >::Output where T: MinMaxExpr, { - x.min_expr(y) + x.min_(y) } pub fn max(x: T, y: S) -> >::Output where T: MinMaxExpr, { - x.max_expr(y) + x.max_(y) } impl ClampExpr for Expr diff --git a/luisa_compute/src/lang/ops/traits.rs b/luisa_compute/src/lang/ops/traits.rs index 129c49de..947493ad 100644 --- a/luisa_compute/src/lang/ops/traits.rs +++ b/luisa_compute/src/lang/ops/traits.rs @@ -166,8 +166,8 @@ macro_rules! assignop_trait { ops_trait!(MinMaxExpr[MinMaxThis] { type Output; - fn max_expr[_max_expr](self, other: T); - fn min_expr[_min_expr](self, other: T); + fn max_[_max_](self, other: T); + fn min_[_min_](self, other: T); }); ops_trait!(ClampExpr[ClampThis] { @@ -211,7 +211,7 @@ pub trait IntExpr { pub trait FloatExpr: Sized { type Bool; - + fn ceil(&self) -> Self; fn floor(&self) -> Self; fn round(&self) -> Self; diff --git a/luisa_compute/src/lang/types.rs b/luisa_compute/src/lang/types.rs index ddcf62e7..45f5abcc 100644 --- a/luisa_compute/src/lang/types.rs +++ b/luisa_compute/src/lang/types.rs @@ -298,7 +298,7 @@ impl Expr { let node = __current_scope(|s| s.bitcast(self.node(), ty)); Expr::::from_node(node) } - pub fn _type_tag(&self)->TypeTag { + pub fn _type_tag(&self) -> TypeTag { TypeTag(PhantomData) } } @@ -350,9 +350,7 @@ impl AtomicRef { } pub fn _deref_proxy(proxy: &P) -> &Expr { - unsafe { &*(proxy as *const P as *const Var) } - .load() - ._ref() + proxy.as_var_from_proxy().load()._ref() } #[macro_export]