From ecb570ff6489869abb0198d376d77619e4bd241f Mon Sep 17 00:00:00 2001 From: Stephen White Date: Wed, 2 Mar 2022 14:39:52 +0000 Subject: [PATCH] GLSL: support any() and all() on scalars. It's a no-op. Bug: tint:1462 Change-Id: Ic79f33682097be075eb2e99b714d1e65bed10d4d Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/82365 Kokoro: Kokoro Reviewed-by: Ben Clayton Commit-Queue: Stephen White --- src/tint/writer/glsl/generator_impl.cc | 6 ++++ .../gen/all/353d6a.wgsl.expected.glsl | 32 ++----------------- .../gen/any/2ab91a.wgsl.expected.glsl | 32 ++----------------- .../ba1481.wgsl.expected.glsl | 2 +- .../gen/textureLoad/8acf41.wgsl.expected.glsl | 2 +- .../979816.wgsl.expected.glsl | 2 +- 6 files changed, 15 insertions(+), 61 deletions(-) diff --git a/src/tint/writer/glsl/generator_impl.cc b/src/tint/writer/glsl/generator_impl.cc index 4ce15d587d..4adbbc76d0 100644 --- a/src/tint/writer/glsl/generator_impl.cc +++ b/src/tint/writer/glsl/generator_impl.cc @@ -689,6 +689,12 @@ bool GeneratorImpl::EmitBuiltinCall(std::ostream& out, // GLSL does not support abs() on unsigned arguments. However, it's a no-op. return EmitExpression(out, expr->args[0]); } + if ((builtin->Type() == sem::BuiltinType::kAny || + builtin->Type() == sem::BuiltinType::kAll) && + TypeOf(expr->args[0])->UnwrapRef()->is_scalar()) { + // GLSL does not support any() or all() on scalar arguments. It's a no-op. + return EmitExpression(out, expr->args[0]); + } if (builtin->IsBarrier()) { return EmitBarrierCall(out, builtin); } diff --git a/test/tint/builtins/gen/all/353d6a.wgsl.expected.glsl b/test/tint/builtins/gen/all/353d6a.wgsl.expected.glsl index 120819846d..b66c3f59c1 100644 --- a/test/tint/builtins/gen/all/353d6a.wgsl.expected.glsl +++ b/test/tint/builtins/gen/all/353d6a.wgsl.expected.glsl @@ -1,9 +1,7 @@ -SKIP: FAILED - #version 310 es void all_353d6a() { - bool res = all(false); + bool res = false; } vec4 vertex_main() { @@ -18,19 +16,11 @@ void main() { gl_Position.z = ((2.0f * gl_Position.z) - gl_Position.w); return; } -Error parsing GLSL shader: -ERROR: 0:4: 'all' : no matching overloaded function found -ERROR: 0:4: '=' : cannot convert from ' const float' to ' temp bool' -ERROR: 0:4: '' : compilation terminated -ERROR: 3 compilation errors. No code generated. - - - #version 310 es precision mediump float; void all_353d6a() { - bool res = all(false); + bool res = false; } void fragment_main() { @@ -41,18 +31,10 @@ void main() { fragment_main(); return; } -Error parsing GLSL shader: -ERROR: 0:5: 'all' : no matching overloaded function found -ERROR: 0:5: '=' : cannot convert from ' const float' to ' temp bool' -ERROR: 0:5: '' : compilation terminated -ERROR: 3 compilation errors. No code generated. - - - #version 310 es void all_353d6a() { - bool res = all(false); + bool res = false; } void compute_main() { @@ -64,11 +46,3 @@ void main() { compute_main(); return; } -Error parsing GLSL shader: -ERROR: 0:4: 'all' : no matching overloaded function found -ERROR: 0:4: '=' : cannot convert from ' const float' to ' temp bool' -ERROR: 0:4: '' : compilation terminated -ERROR: 3 compilation errors. No code generated. - - - diff --git a/test/tint/builtins/gen/any/2ab91a.wgsl.expected.glsl b/test/tint/builtins/gen/any/2ab91a.wgsl.expected.glsl index eef474eed1..bbde39558c 100644 --- a/test/tint/builtins/gen/any/2ab91a.wgsl.expected.glsl +++ b/test/tint/builtins/gen/any/2ab91a.wgsl.expected.glsl @@ -1,9 +1,7 @@ -SKIP: FAILED - #version 310 es void any_2ab91a() { - bool res = any(false); + bool res = false; } vec4 vertex_main() { @@ -18,19 +16,11 @@ void main() { gl_Position.z = ((2.0f * gl_Position.z) - gl_Position.w); return; } -Error parsing GLSL shader: -ERROR: 0:4: 'any' : no matching overloaded function found -ERROR: 0:4: '=' : cannot convert from ' const float' to ' temp bool' -ERROR: 0:4: '' : compilation terminated -ERROR: 3 compilation errors. No code generated. - - - #version 310 es precision mediump float; void any_2ab91a() { - bool res = any(false); + bool res = false; } void fragment_main() { @@ -41,18 +31,10 @@ void main() { fragment_main(); return; } -Error parsing GLSL shader: -ERROR: 0:5: 'any' : no matching overloaded function found -ERROR: 0:5: '=' : cannot convert from ' const float' to ' temp bool' -ERROR: 0:5: '' : compilation terminated -ERROR: 3 compilation errors. No code generated. - - - #version 310 es void any_2ab91a() { - bool res = any(false); + bool res = false; } void compute_main() { @@ -64,11 +46,3 @@ void main() { compute_main(); return; } -Error parsing GLSL shader: -ERROR: 0:4: 'any' : no matching overloaded function found -ERROR: 0:4: '=' : cannot convert from ' const float' to ' temp bool' -ERROR: 0:4: '' : compilation terminated -ERROR: 3 compilation errors. No code generated. - - - diff --git a/test/tint/builtins/gen/textureDimensions/ba1481.wgsl.expected.glsl b/test/tint/builtins/gen/textureDimensions/ba1481.wgsl.expected.glsl index 5104880b7a..4b0b14516c 100644 --- a/test/tint/builtins/gen/textureDimensions/ba1481.wgsl.expected.glsl +++ b/test/tint/builtins/gen/textureDimensions/ba1481.wgsl.expected.glsl @@ -1,6 +1,6 @@ SKIP: FAILED -../../src/tint/writer/glsl/generator_impl.cc:2577 internal compiler error: Multiplanar external texture transform was not run. +../../src/tint/writer/glsl/generator_impl.cc:2582 internal compiler error: Multiplanar external texture transform was not run. ******************************************************************** diff --git a/test/tint/builtins/gen/textureLoad/8acf41.wgsl.expected.glsl b/test/tint/builtins/gen/textureLoad/8acf41.wgsl.expected.glsl index 5104880b7a..4b0b14516c 100644 --- a/test/tint/builtins/gen/textureLoad/8acf41.wgsl.expected.glsl +++ b/test/tint/builtins/gen/textureLoad/8acf41.wgsl.expected.glsl @@ -1,6 +1,6 @@ SKIP: FAILED -../../src/tint/writer/glsl/generator_impl.cc:2577 internal compiler error: Multiplanar external texture transform was not run. +../../src/tint/writer/glsl/generator_impl.cc:2582 internal compiler error: Multiplanar external texture transform was not run. ******************************************************************** diff --git a/test/tint/builtins/gen/textureSampleLevel/979816.wgsl.expected.glsl b/test/tint/builtins/gen/textureSampleLevel/979816.wgsl.expected.glsl index 5104880b7a..4b0b14516c 100644 --- a/test/tint/builtins/gen/textureSampleLevel/979816.wgsl.expected.glsl +++ b/test/tint/builtins/gen/textureSampleLevel/979816.wgsl.expected.glsl @@ -1,6 +1,6 @@ SKIP: FAILED -../../src/tint/writer/glsl/generator_impl.cc:2577 internal compiler error: Multiplanar external texture transform was not run. +../../src/tint/writer/glsl/generator_impl.cc:2582 internal compiler error: Multiplanar external texture transform was not run. ********************************************************************