GLSL: special-case BinaryOp::kModulo for floating point.

The '%' operator in GLSL is integer-only. Use the full OpFRem
expression: (a - b * trunc(a / b)).

Bug: tint:1270
Change-Id: I0a969983bef132e004ce456d4a738488e400a61b
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/68760
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: Stephen White <senorblanco@chromium.org>
This commit is contained in:
Stephen White
2022-02-28 21:15:02 +00:00
committed by Tint LUCI CQ
parent 9b152e655f
commit 59f1e8d06c
29 changed files with 246 additions and 235 deletions

View File

@@ -1,10 +1,13 @@
SKIP: FAILED
#version 310 es
precision mediump float;
float tint_float_modulo(float lhs, float rhs) {
return (lhs - rhs * trunc(lhs / rhs));
}
void main_1() {
float x_1 = (50.0f % 60.0f);
float x_1 = tint_float_modulo(50.0f, 60.0f);
return;
}
@@ -16,10 +19,3 @@ void main() {
tint_symbol();
return;
}
Error parsing GLSL shader:
ERROR: 0:5: '%' : wrong operand types: no operation '%' exists that takes a left-hand operand of type ' const float' and a right operand of type ' const float' (or there is no acceptable conversion)
ERROR: 0:5: '' : compilation terminated
ERROR: 2 compilation errors. No code generated.

View File

@@ -1,10 +1,13 @@
SKIP: FAILED
#version 310 es
precision mediump float;
vec2 tint_float_modulo(vec2 lhs, vec2 rhs) {
return (lhs - rhs * trunc(lhs / rhs));
}
void main_1() {
vec2 x_1 = (vec2(50.0f, 60.0f) % vec2(60.0f, 50.0f));
vec2 x_1 = tint_float_modulo(vec2(50.0f, 60.0f), vec2(60.0f, 50.0f));
return;
}
@@ -16,10 +19,3 @@ void main() {
tint_symbol();
return;
}
Error parsing GLSL shader:
ERROR: 0:5: '%' : wrong operand types: no operation '%' exists that takes a left-hand operand of type ' const 2-component vector of float' and a right operand of type ' const 2-component vector of float' (or there is no acceptable conversion)
ERROR: 0:5: '' : compilation terminated
ERROR: 2 compilation errors. No code generated.