Skip to content

Commit

Permalink
[msl-out] Document why dot operator on ints requires baking.
Browse files Browse the repository at this point in the history
  • Loading branch information
jimblandy committed Feb 16, 2022
1 parent 205976c commit c4a6b9c
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/back/msl/writer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1856,8 +1856,12 @@ impl<W: Write> Writer<W> {
if min_ref_count <= expr_info.ref_count {
self.need_bake_expressions.insert(expr.0);
}
// if the expression is a Dot product with integer arguments,
// then the args needs baking as well

// WGSL's `dot` function works on any `vecN` type, but Metal's only
// works on floating-point vectors, so we emit inline code for
// integer vector `dot` calls. But that code uses each argument `N`
// times, once for each component (see `put_dot_product`), so to
// avoid duplicated evaluation, we must bake integer operands.
if let (
fun_handle,
&Expression::Math {
Expand Down

0 comments on commit c4a6b9c

Please sign in to comment.