Use Fused-Multiply-Add (#232)

- There are a few places in the `simple-invaders` crate that could use
  `f32::mul_add()` as well.
This commit is contained in:
Jay Oster 2021-12-04 09:08:29 -08:00 committed by GitHub
parent 2a4ebbf19d
commit bd2de37b84
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 2 additions and 2 deletions

View file

@ -10,7 +10,7 @@ fn vs_main(
[[location(0)]] position: vec2<f32>, [[location(0)]] position: vec2<f32>,
) -> VertexOutput { ) -> VertexOutput {
var out: VertexOutput; var out: VertexOutput;
out.tex_coord = position * vec2<f32>(0.5, -0.5) + 0.5; out.tex_coord = fma(position, vec2<f32>(0.5, -0.5), vec2<f32>(0.5, 0.5));
out.position = vec4<f32>(position, 0.0, 1.0); out.position = vec4<f32>(position, 0.0, 1.0);
return out; return out;
} }

View file

@ -15,7 +15,7 @@ fn vs_main(
[[location(0)]] position: vec2<f32>, [[location(0)]] position: vec2<f32>,
) -> VertexOutput { ) -> VertexOutput {
var out: VertexOutput; var out: VertexOutput;
out.tex_coord = position * vec2<f32>(0.5, -0.5) + 0.5; out.tex_coord = fma(position, vec2<f32>(0.5, -0.5), vec2<f32>(0.5, 0.5));
out.position = r_locals.transform * vec4<f32>(position, 0.0, 1.0); out.position = r_locals.transform * vec4<f32>(position, 0.0, 1.0);
return out; return out;
} }