mirror of
https://github.com/gfx-rs/wgpu.git
synced 2024-11-28 17:53:40 +00:00
[msl] refactor chain of if blocks to match
This commit is contained in:
parent
7078b0a061
commit
66d7387f0d
@ -1853,20 +1853,23 @@ impl<W: Write> Writer<W> {
|
||||
_ => {}
|
||||
}
|
||||
|
||||
if fun == Mf::Distance && scalar_argument {
|
||||
match fun {
|
||||
Mf::Distance if scalar_argument => {
|
||||
write!(self.out, "{NAMESPACE}::abs(")?;
|
||||
self.put_expression(arg, context, false)?;
|
||||
write!(self.out, " - ")?;
|
||||
self.put_expression(arg1.unwrap(), context, false)?;
|
||||
write!(self.out, ")")?;
|
||||
} else if fun == Mf::FindLsb {
|
||||
}
|
||||
Mf::FindLsb => {
|
||||
let scalar = context.resolve_type(arg).scalar().unwrap();
|
||||
let constant = scalar.width * 8 + 1;
|
||||
|
||||
write!(self.out, "((({NAMESPACE}::ctz(")?;
|
||||
self.put_expression(arg, context, true)?;
|
||||
write!(self.out, ") + 1) % {constant}) - 1)")?;
|
||||
} else if fun == Mf::FindMsb {
|
||||
}
|
||||
Mf::FindMsb => {
|
||||
let inner = context.resolve_type(arg);
|
||||
let scalar = inner.scalar().unwrap();
|
||||
let constant = scalar.width * 8 - 1;
|
||||
@ -1909,15 +1912,18 @@ impl<W: Write> Writer<W> {
|
||||
write!(self.out, " == 0 || ")?;
|
||||
self.put_expression(arg, context, true)?;
|
||||
write!(self.out, " == -1)")?;
|
||||
} else if fun == Mf::Unpack2x16float {
|
||||
}
|
||||
Mf::Unpack2x16float => {
|
||||
write!(self.out, "float2(as_type<half2>(")?;
|
||||
self.put_expression(arg, context, false)?;
|
||||
write!(self.out, "))")?;
|
||||
} else if fun == Mf::Pack2x16float {
|
||||
}
|
||||
Mf::Pack2x16float => {
|
||||
write!(self.out, "as_type<uint>(half2(")?;
|
||||
self.put_expression(arg, context, false)?;
|
||||
write!(self.out, "))")?;
|
||||
} else if fun == Mf::ExtractBits {
|
||||
}
|
||||
Mf::ExtractBits => {
|
||||
// The behavior of ExtractBits is undefined when offset + count > bit_width. We need
|
||||
// to first sanitize the offset and count first. If we don't do this, Apple chips
|
||||
// will return out-of-spec values if the extracted range is not within the bit width.
|
||||
@ -1945,7 +1951,8 @@ impl<W: Write> Writer<W> {
|
||||
write!(self.out, ", {scalar_bits}u - {NAMESPACE}::min(")?;
|
||||
self.put_expression(arg1.unwrap(), context, true)?;
|
||||
write!(self.out, ", {scalar_bits}u)))")?;
|
||||
} else if fun == Mf::InsertBits {
|
||||
}
|
||||
Mf::InsertBits => {
|
||||
// The behavior of InsertBits has the same issue as ExtractBits.
|
||||
//
|
||||
// insertBits(e, newBits, min(offset, w), min(count, w - min(offset, w))))
|
||||
@ -1963,18 +1970,22 @@ impl<W: Write> Writer<W> {
|
||||
write!(self.out, ", {scalar_bits}u - {NAMESPACE}::min(")?;
|
||||
self.put_expression(arg2.unwrap(), context, true)?;
|
||||
write!(self.out, ", {scalar_bits}u)))")?;
|
||||
} else if fun == Mf::Radians {
|
||||
}
|
||||
Mf::Radians => {
|
||||
write!(self.out, "((")?;
|
||||
self.put_expression(arg, context, false)?;
|
||||
write!(self.out, ") * 0.017453292519943295474)")?;
|
||||
} else if fun == Mf::Degrees {
|
||||
}
|
||||
Mf::Degrees => {
|
||||
write!(self.out, "((")?;
|
||||
self.put_expression(arg, context, false)?;
|
||||
write!(self.out, ") * 57.295779513082322865)")?;
|
||||
} else if fun == Mf::Modf || fun == Mf::Frexp {
|
||||
}
|
||||
Mf::Modf | Mf::Frexp => {
|
||||
write!(self.out, "{fun_name}")?;
|
||||
self.put_call_parameters(iter::once(arg), context)?;
|
||||
} else {
|
||||
}
|
||||
_ => {
|
||||
write!(self.out, "{NAMESPACE}::{fun_name}")?;
|
||||
self.put_call_parameters(
|
||||
iter::once(arg).chain(arg1).chain(arg2).chain(arg3),
|
||||
@ -1982,6 +1993,7 @@ impl<W: Write> Writer<W> {
|
||||
)?;
|
||||
}
|
||||
}
|
||||
}
|
||||
crate::Expression::As {
|
||||
expr,
|
||||
kind,
|
||||
|
Loading…
Reference in New Issue
Block a user