[glsl][ir] Polyfill float modulo
GLSL does not support float `%`. This CL adds the needed polyfill.
Bug: 42251044
Change-Id: I27a601b31252f235c9b879487711c9795af699b1
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/208354
Reviewed-by: James Price <jrprice@google.com>
Commit-Queue: dan sinclair <dsinclair@chromium.org>
diff --git a/test/tint/statements/compound_assign/divide_by_zero.wgsl.expected.ir.glsl b/test/tint/statements/compound_assign/divide_by_zero.wgsl.expected.ir.glsl
index 8dec860..8a2d327 100644
--- a/test/tint/statements/compound_assign/divide_by_zero.wgsl.expected.ir.glsl
+++ b/test/tint/statements/compound_assign/divide_by_zero.wgsl.expected.ir.glsl
@@ -2,6 +2,9 @@
int a = 0;
float b = 0.0f;
+float tint_float_modulo(float x, float y) {
+ return (x - (y * trunc((x / y))));
+}
int tint_mod_i32(int lhs, int rhs) {
uint v = uint((lhs == (-2147483647 - 1)));
bool v_1 = bool((v & uint((rhs == -1))));
@@ -19,11 +22,11 @@
a = tint_div_i32(a, maybe_zero);
a = tint_mod_i32(a, maybe_zero);
b = (b / 0.0f);
- b = (b % 0.0f);
+ b = tint_float_modulo(b, 0.0f);
float v_7 = float(maybe_zero);
b = (b / v_7);
float v_8 = float(maybe_zero);
- b = (b % v_8);
+ b = tint_float_modulo(b, v_8);
}
layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in;
void main() {