Skip to content

Commit

Permalink
fix(msl-out): make unpack4x{I,U}8 output exprs. composable
Browse files Browse the repository at this point in the history
  • Loading branch information
ErichDonGubler committed Dec 17, 2024
1 parent f4b1474 commit 50f3fea
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 5 deletions.
3 changes: 2 additions & 1 deletion naga/src/back/msl/writer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2134,6 +2134,7 @@ impl<W: Write> Writer<W> {
}
}
fun @ (Mf::Unpack4xI8 | Mf::Unpack4xU8) => {
write!(self.out, "(")?;
if matches!(fun, Mf::Unpack4xU8) {
write!(self.out, "u")?;
}
Expand All @@ -2145,7 +2146,7 @@ impl<W: Write> Writer<W> {
self.put_expression(arg, context, true)?;
write!(self.out, " >> 16, ")?;
self.put_expression(arg, context, true)?;
write!(self.out, " >> 24) << 24 >> 24")?;
write!(self.out, " >> 24) << 24 >> 24)")?;
}
Mf::QuantizeToF16 => {
match *context.resolve_type(arg) {
Expand Down
4 changes: 2 additions & 2 deletions naga/tests/out/msl/6772-unpack-expr-accesses.msl
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@ using metal::uint;

kernel void main_(
) {
int phony = int4(12u, 12u >> 8, 12u >> 16, 12u >> 24) << 24 >> 24[2];
uint phony_1 = uint4(12u, 12u >> 8, 12u >> 16, 12u >> 24) << 24 >> 24.y;
int phony = (int4(12u, 12u >> 8, 12u >> 16, 12u >> 24) << 24 >> 24)[2];
uint phony_1 = (uint4(12u, 12u >> 8, 12u >> 16, 12u >> 24) << 24 >> 24).y;
}
4 changes: 2 additions & 2 deletions naga/tests/out/msl/bits.msl
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,9 @@ kernel void main_(
uint _e50 = u;
f2_ = float2(as_type<half2>(_e50));
uint _e52 = u;
i4_ = int4(_e52, _e52 >> 8, _e52 >> 16, _e52 >> 24) << 24 >> 24;
i4_ = (int4(_e52, _e52 >> 8, _e52 >> 16, _e52 >> 24) << 24 >> 24);
uint _e54 = u;
u4_ = uint4(_e54, _e54 >> 8, _e54 >> 16, _e54 >> 24) << 24 >> 24;
u4_ = (uint4(_e54, _e54 >> 8, _e54 >> 16, _e54 >> 24) << 24 >> 24);
int _e56 = i;
int _e57 = i;
i = metal::insert_bits(_e56, _e57, metal::min(5u, 32u), metal::min(10u, 32u - metal::min(5u, 32u)));
Expand Down

0 comments on commit 50f3fea

Please sign in to comment.