GLSL: fix boolean "not" operator on vectors.

GLSL uses not() for vectors, and ! for scalars.

Bug: tint:1444
Change-Id: I7fa9bdf0b546224737f9cda18428dea7051fe9e5
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/82362
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-03-02 14:15:52 +00:00 committed by Tint LUCI CQ
parent e4e409f2ae
commit 6c2115ee91
8 changed files with 12 additions and 71 deletions

View File

@ -2717,7 +2717,11 @@ bool GeneratorImpl::EmitUnaryOp(std::ostream& out,
out << "~";
break;
case ast::UnaryOp::kNot:
if (TypeOf(expr)->UnwrapRef()->is_scalar()) {
out << "!";
} else {
out << "not";
}
break;
case ast::UnaryOp::kNegation:
out << "-";

View File

@ -1,10 +1,8 @@
SKIP: FAILED
#version 310 es
precision mediump float;
void main_1() {
bvec2 x_1 = !(notEqual(vec2(50.0f, 60.0f), vec2(60.0f, 50.0f)));
bvec2 x_1 = not(notEqual(vec2(50.0f, 60.0f), vec2(60.0f, 50.0f)));
return;
}
@ -16,10 +14,3 @@ void main() {
tint_symbol();
return;
}
Error parsing GLSL shader:
ERROR: 0:5: '!' : wrong operand type no operation '!' exists that takes an operand of type const 2-component vector of bool (or there is no acceptable conversion)
ERROR: 0:5: '' : compilation terminated
ERROR: 2 compilation errors. No code generated.

View File

@ -1,10 +1,8 @@
SKIP: FAILED
#version 310 es
precision mediump float;
void main_1() {
bvec2 x_1 = !(lessThan(vec2(50.0f, 60.0f), vec2(60.0f, 50.0f)));
bvec2 x_1 = not(lessThan(vec2(50.0f, 60.0f), vec2(60.0f, 50.0f)));
return;
}
@ -16,10 +14,3 @@ void main() {
tint_symbol();
return;
}
Error parsing GLSL shader:
ERROR: 0:5: '!' : wrong operand type no operation '!' exists that takes an operand of type const 2-component vector of bool (or there is no acceptable conversion)
ERROR: 0:5: '' : compilation terminated
ERROR: 2 compilation errors. No code generated.

View File

@ -1,10 +1,8 @@
SKIP: FAILED
#version 310 es
precision mediump float;
void main_1() {
bvec2 x_1 = !(lessThanEqual(vec2(50.0f, 60.0f), vec2(60.0f, 50.0f)));
bvec2 x_1 = not(lessThanEqual(vec2(50.0f, 60.0f), vec2(60.0f, 50.0f)));
return;
}
@ -16,10 +14,3 @@ void main() {
tint_symbol();
return;
}
Error parsing GLSL shader:
ERROR: 0:5: '!' : wrong operand type no operation '!' exists that takes an operand of type const 2-component vector of bool (or there is no acceptable conversion)
ERROR: 0:5: '' : compilation terminated
ERROR: 2 compilation errors. No code generated.

View File

@ -1,10 +1,8 @@
SKIP: FAILED
#version 310 es
precision mediump float;
void main_1() {
bvec2 x_1 = !(greaterThan(vec2(50.0f, 60.0f), vec2(60.0f, 50.0f)));
bvec2 x_1 = not(greaterThan(vec2(50.0f, 60.0f), vec2(60.0f, 50.0f)));
return;
}
@ -16,10 +14,3 @@ void main() {
tint_symbol();
return;
}
Error parsing GLSL shader:
ERROR: 0:5: '!' : wrong operand type no operation '!' exists that takes an operand of type const 2-component vector of bool (or there is no acceptable conversion)
ERROR: 0:5: '' : compilation terminated
ERROR: 2 compilation errors. No code generated.

View File

@ -1,10 +1,8 @@
SKIP: FAILED
#version 310 es
precision mediump float;
void main_1() {
bvec2 x_1 = !(greaterThanEqual(vec2(50.0f, 60.0f), vec2(60.0f, 50.0f)));
bvec2 x_1 = not(greaterThanEqual(vec2(50.0f, 60.0f), vec2(60.0f, 50.0f)));
return;
}
@ -16,10 +14,3 @@ void main() {
tint_symbol();
return;
}
Error parsing GLSL shader:
ERROR: 0:5: '!' : wrong operand type no operation '!' exists that takes an operand of type const 2-component vector of bool (or there is no acceptable conversion)
ERROR: 0:5: '' : compilation terminated
ERROR: 2 compilation errors. No code generated.

View File

@ -1,10 +1,8 @@
SKIP: FAILED
#version 310 es
precision mediump float;
void main_1() {
bvec2 x_1 = !(equal(vec2(50.0f, 60.0f), vec2(60.0f, 50.0f)));
bvec2 x_1 = not(equal(vec2(50.0f, 60.0f), vec2(60.0f, 50.0f)));
return;
}
@ -16,10 +14,3 @@ void main() {
tint_symbol();
return;
}
Error parsing GLSL shader:
ERROR: 0:5: '!' : wrong operand type no operation '!' exists that takes an operand of type const 2-component vector of bool (or there is no acceptable conversion)
ERROR: 0:5: '' : compilation terminated
ERROR: 2 compilation errors. No code generated.

View File

@ -1,10 +1,8 @@
SKIP: FAILED
#version 310 es
precision mediump float;
void main_1() {
bvec2 x_1 = !(bvec2(true, false));
bvec2 x_1 = not(bvec2(true, false));
return;
}
@ -16,10 +14,3 @@ void main() {
tint_symbol();
return;
}
Error parsing GLSL shader:
ERROR: 0:5: '!' : wrong operand type no operation '!' exists that takes an operand of type const 2-component vector of bool (or there is no acceptable conversion)
ERROR: 0:5: '' : compilation terminated
ERROR: 2 compilation errors. No code generated.