Fix operator% for f32 and vecN<f32>

https://github.com/gpuweb/gpuweb/pull/1945 changes the SPIR-V mapping of this operator so that it now maps to OpFRem instead of OpFMod. Polyfill OpFMod with `x - y * floor(x / y)`

Also map the MSL output of this operator to use `fmod()`.

Behavior of this operator is now consistent across all backends.

Fixed: tint:945
Fixed: tint:977
Fixed: tint:1010
Change-Id: Iefa009b905989c55ace24e073ab0e261c7cf69b0
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/58393
Auto-Submit: Ben Clayton <bclayton@google.com>
Commit-Queue: Ben Clayton <bclayton@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: David Neto <dneto@google.com>
This commit is contained in:
Ben Clayton
2021-07-21 14:11:01 +00:00
committed by Tint LUCI CQ
parent 1ec484410a
commit 81d4ed0d9c
17 changed files with 453 additions and 98 deletions

View File

@@ -1,19 +1,10 @@
SKIP: FAILED
#include <metal_stdlib>
using namespace metal;
kernel void f() {
float3 const a = float3(1.0f, 2.0f, 3.0f);
float3 const b = float3(4.0f, 5.0f, 6.0f);
float3 const r = (a % b);
float3 const r = fmod(a, b);
return;
}
Compilation failed:
program_source:7:23: error: invalid operands to binary expression ('const float3' (vector of 3 'float' values) and 'const float3')
float3 const r = (a % b);
~ ^ ~

View File

@@ -22,6 +22,6 @@
%14 = OpConstantComposite %v3float %float_4 %float_5 %float_6
%f = OpFunction %void None %1
%4 = OpLabel
%15 = OpFMod %v3float %10 %14
%15 = OpFRem %v3float %10 %14
OpReturn
OpFunctionEnd