Skip to content

Commit

Permalink
remove IsFinite & IsNormal completely
Browse files Browse the repository at this point in the history
  • Loading branch information
teoxoy authored and jimblandy committed Oct 16, 2023
1 parent 04562de commit d71f254
Show file tree
Hide file tree
Showing 8 changed files with 18 additions and 35 deletions.
4 changes: 0 additions & 4 deletions src/back/glsl/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2981,12 +2981,8 @@ impl<'a, W: Write> Writer<'a, W> {
use crate::RelationalFunction as Rf;

let fun_name = match fun {
// There's no specific function for this but we can invert the result of `isinf`
Rf::IsFinite => "!isinf",
Rf::IsInf => "isinf",
Rf::IsNan => "isnan",
// There's also no function for this but we can invert `isnan`
Rf::IsNormal => "!isnan",
Rf::All => "all",
Rf::Any => "any",
};
Expand Down
2 changes: 0 additions & 2 deletions src/back/hlsl/writer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3151,8 +3151,6 @@ impl<'a, W: fmt::Write> super::Writer<'a, W> {
Rf::Any => "any",
Rf::IsNan => "isnan",
Rf::IsInf => "isinf",
Rf::IsFinite => "isfinite",
Rf::IsNormal => "isnormal",
};
write!(self.out, "{fun_str}(")?;
self.write_expr(module, argument, func_ctx)?;
Expand Down
2 changes: 0 additions & 2 deletions src/back/msl/writer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1671,8 +1671,6 @@ impl<W: Write> Writer<W> {
crate::RelationalFunction::All => "all",
crate::RelationalFunction::IsNan => "isnan",
crate::RelationalFunction::IsInf => "isinf",
crate::RelationalFunction::IsFinite => "isfinite",
crate::RelationalFunction::IsNormal => "isnormal",
};
write!(self.out, "{NAMESPACE}::{op}")?;
self.put_call_parameters(iter::once(argument), context)?;
Expand Down
4 changes: 0 additions & 4 deletions src/back/spv/block.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1406,10 +1406,6 @@ impl<'w> BlockContext<'w> {
Rf::Any => spirv::Op::Any,
Rf::IsNan => spirv::Op::IsNan,
Rf::IsInf => spirv::Op::IsInf,
//TODO: these require Kernel capability
Rf::IsFinite | Rf::IsNormal => {
return Err(Error::FeatureNotImplemented("is finite/normal"))
}
};
let id = self.gen_id();
block
Expand Down
2 changes: 0 additions & 2 deletions src/front/spv/convert.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,6 @@ pub(super) const fn map_relational_fun(
Op::Any => Ok(Rf::Any),
Op::IsNan => Ok(Rf::IsNan),
Op::IsInf => Ok(Rf::IsInf),
Op::IsFinite => Ok(Rf::IsFinite),
Op::IsNormal => Ok(Rf::IsNormal),
_ => Err(Error::UnknownRelationalFunction(word)),
}
}
Expand Down
2 changes: 0 additions & 2 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1117,8 +1117,6 @@ pub enum RelationalFunction {
Any,
IsNan,
IsInf,
IsFinite,
IsNormal,
}

/// Built-in shader function for math.
Expand Down
35 changes: 17 additions & 18 deletions src/proc/typifier.rs
Original file line number Diff line number Diff line change
Expand Up @@ -648,25 +648,24 @@ impl<'a> ResolveContext<'a> {
width: crate::BOOL_WIDTH,
})
}
crate::RelationalFunction::IsNan
| crate::RelationalFunction::IsInf
| crate::RelationalFunction::IsFinite
| crate::RelationalFunction::IsNormal => match *past(argument)?.inner_with(types) {
Ti::Scalar { .. } => TypeResolution::Value(Ti::Scalar {
kind: crate::ScalarKind::Bool,
width: crate::BOOL_WIDTH,
}),
Ti::Vector { size, .. } => TypeResolution::Value(Ti::Vector {
kind: crate::ScalarKind::Bool,
width: crate::BOOL_WIDTH,
size,
}),
ref other => {
return Err(ResolveError::IncompatibleOperands(format!(
"{fun:?}({other:?})"
)))
crate::RelationalFunction::IsNan | crate::RelationalFunction::IsInf => {
match *past(argument)?.inner_with(types) {
Ti::Scalar { .. } => TypeResolution::Value(Ti::Scalar {
kind: crate::ScalarKind::Bool,
width: crate::BOOL_WIDTH,
}),
Ti::Vector { size, .. } => TypeResolution::Value(Ti::Vector {
kind: crate::ScalarKind::Bool,
width: crate::BOOL_WIDTH,
size,
}),
ref other => {
return Err(ResolveError::IncompatibleOperands(format!(
"{fun:?}({other:?})"
)))
}
}
},
}
},
crate::Expression::Math {
fun,
Expand Down
2 changes: 1 addition & 1 deletion src/valid/expression.rs
Original file line number Diff line number Diff line change
Expand Up @@ -897,7 +897,7 @@ impl super::Validator {
return Err(ExpressionError::InvalidBooleanVector(argument));
}
},
Rf::IsNan | Rf::IsInf | Rf::IsFinite | Rf::IsNormal => match *argument_inner {
Rf::IsNan | Rf::IsInf => match *argument_inner {
Ti::Scalar {
kind: Sk::Float, ..
}
Expand Down

0 comments on commit d71f254

Please sign in to comment.