From bd2de37b84f0efba95468643d78a35a255040dc4 Mon Sep 17 00:00:00 2001 From: Jay Oster Date: Sat, 4 Dec 2021 09:08:29 -0800 Subject: [PATCH] Use Fused-Multiply-Add (#232) - There are a few places in the `simple-invaders` crate that could use `f32::mul_add()` as well. --- examples/custom-shader/shaders/noise.wgsl | 2 +- shaders/scale.wgsl | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/custom-shader/shaders/noise.wgsl b/examples/custom-shader/shaders/noise.wgsl index 4ede4b4..e2a7d7a 100644 --- a/examples/custom-shader/shaders/noise.wgsl +++ b/examples/custom-shader/shaders/noise.wgsl @@ -10,7 +10,7 @@ fn vs_main( [[location(0)]] position: vec2, ) -> VertexOutput { var out: VertexOutput; - out.tex_coord = position * vec2(0.5, -0.5) + 0.5; + out.tex_coord = fma(position, vec2(0.5, -0.5), vec2(0.5, 0.5)); out.position = vec4(position, 0.0, 1.0); return out; } diff --git a/shaders/scale.wgsl b/shaders/scale.wgsl index dc7bfce..48004eb 100644 --- a/shaders/scale.wgsl +++ b/shaders/scale.wgsl @@ -15,7 +15,7 @@ fn vs_main( [[location(0)]] position: vec2, ) -> VertexOutput { var out: VertexOutput; - out.tex_coord = position * vec2(0.5, -0.5) + 0.5; + out.tex_coord = fma(position, vec2(0.5, -0.5), vec2(0.5, 0.5)); out.position = r_locals.transform * vec4(position, 0.0, 1.0); return out; }