Skip to content

Commit

Permalink
Handle Unpack2x16float in hlsl (#2002)
Browse files Browse the repository at this point in the history
  • Loading branch information
expenses authored Jul 17, 2022
1 parent 8f302a8 commit cc98539
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/back/hlsl/writer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2422,6 +2422,7 @@ impl<'a, W: fmt::Write> super::Writer<'a, W> {
enum Function {
Asincosh { is_sin: bool },
Atanh,
Unpack2x16float,
Regular(&'static str),
MissingIntOverload(&'static str),
}
Expand Down Expand Up @@ -2489,6 +2490,7 @@ impl<'a, W: fmt::Write> super::Writer<'a, W> {
Mf::ReverseBits => Function::MissingIntOverload("reversebits"),
Mf::FindLsb => Function::Regular("firstbitlow"),
Mf::FindMsb => Function::Regular("firstbithigh"),
Mf::Unpack2x16float => Function::Unpack2x16float,
_ => return Err(Error::Unimplemented(format!("write_expr_math {:?}", fun))),
};

Expand All @@ -2512,6 +2514,13 @@ impl<'a, W: fmt::Write> super::Writer<'a, W> {
self.write_expr(module, arg, func_ctx)?;
write!(self.out, "))")?;
}
Function::Unpack2x16float => {
write!(self.out, "float2(f16tof32(")?;
self.write_expr(module, arg, func_ctx)?;
write!(self.out, "), f16tof32((")?;
self.write_expr(module, arg, func_ctx)?;
write!(self.out, ") >> 16))")?;
}
Function::Regular(fun_name) => {
write!(self.out, "{}(", fun_name)?;
self.write_expr(module, arg, func_ctx)?;
Expand Down

0 comments on commit cc98539

Please sign in to comment.