Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove IsFinite & IsNormal completely #2532

Merged
merged 1 commit into from
Oct 16, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions src/back/glsl/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2992,12 +2992,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 @@ -3147,8 +3147,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 @@ -1657,8 +1657,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 @@ -1394,10 +1394,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 @@ -1109,8 +1109,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 @@ -862,7 +862,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