GLSL: implement inverseSqrt() and update test expectations.

Bug: tint:1447
Change-Id: I521d021a9177c75badd52ad39ce4db6def48b6ab
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/82144
Reviewed-by: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Stephen White <senorblanco@chromium.org>
This commit is contained in:
Stephen White 2022-02-28 18:23:17 +00:00 committed by Tint LUCI CQ
parent 2a02b68453
commit 7028077a6a
12 changed files with 48 additions and 194 deletions

View File

@ -1625,7 +1625,7 @@ std::string GeneratorImpl::generate_builtin_name(const sem::Builtin* builtin) {
case sem::BuiltinType::kFwidthFine:
return "fwidth";
case sem::BuiltinType::kInverseSqrt:
return "rsqrt";
return "inversesqrt";
case sem::BuiltinType::kIsFinite:
return "isfinite";
case sem::BuiltinType::kIsInf:

View File

@ -218,7 +218,7 @@ INSTANTIATE_TEST_SUITE_P(
BuiltinData{BuiltinType::kFwidth, ParamType::kF32, "fwidth"},
BuiltinData{BuiltinType::kFwidthCoarse, ParamType::kF32, "fwidth"},
BuiltinData{BuiltinType::kFwidthFine, ParamType::kF32, "fwidth"},
BuiltinData{BuiltinType::kInverseSqrt, ParamType::kF32, "rsqrt"},
BuiltinData{BuiltinType::kInverseSqrt, ParamType::kF32, "inversesqrt"},
BuiltinData{BuiltinType::kIsFinite, ParamType::kF32, "isfinite"},
BuiltinData{BuiltinType::kIsInf, ParamType::kF32, "isinf"},
BuiltinData{BuiltinType::kIsNan, ParamType::kF32, "isnan"},

View File

@ -57,7 +57,8 @@ INSTANTIATE_TEST_SUITE_P(GlslGeneratorImplTest_Import,
GlslImportData{"exp2", "exp2"},
GlslImportData{"floor", "floor"},
GlslImportData{"fract", "fract"},
GlslImportData{"inverseSqrt", "rsqrt"},
GlslImportData{"inverseSqrt",
"inversesqrt"},
GlslImportData{"length", "length"},
GlslImportData{"log", "log"},
GlslImportData{"log2", "log2"},
@ -102,7 +103,8 @@ TEST_P(GlslImportData_SingleVectorParamTest, FloatVector) {
EXPECT_EQ(out.str(),
std::string(param.glsl_name) + "(vec3(1.0f, 2.0f, 3.0f))");
}
INSTANTIATE_TEST_SUITE_P(GlslGeneratorImplTest_Import,
INSTANTIATE_TEST_SUITE_P(
GlslGeneratorImplTest_Import,
GlslImportData_SingleVectorParamTest,
testing::Values(GlslImportData{"abs", "abs"},
GlslImportData{"acos", "acos"},
@ -115,12 +117,11 @@ INSTANTIATE_TEST_SUITE_P(GlslGeneratorImplTest_Import,
GlslImportData{"exp2", "exp2"},
GlslImportData{"floor", "floor"},
GlslImportData{"fract", "fract"},
GlslImportData{"inverseSqrt", "rsqrt"},
GlslImportData{"inverseSqrt", "inversesqrt"},
GlslImportData{"length", "length"},
GlslImportData{"log", "log"},
GlslImportData{"log2", "log2"},
GlslImportData{"normalize",
"normalize"},
GlslImportData{"normalize", "normalize"},
GlslImportData{"round", "round"},
GlslImportData{"sign", "sign"},
GlslImportData{"sin", "sin"},

View File

@ -1,5 +1,3 @@
SKIP: FAILED
#version 310 es
precision mediump float;
@ -102,7 +100,7 @@ mat3 cotangent_frame_vf3_vf3_vf2_vf2_(inout vec3 normal_1, inout vec3 p, inout v
tangent = (tangent * x_173);
float x_177 = tangentSpaceParams.y;
bitangent = (bitangent * x_177);
invmax = rsqrt(max(dot(tangent, tangent), dot(bitangent, bitangent)));
invmax = inversesqrt(max(dot(tangent, tangent), dot(bitangent, bitangent)));
vec3 x_191 = (tangent * invmax);
vec3 x_194 = (bitangent * invmax);
vec3 x_195 = normal_1;
@ -374,10 +372,3 @@ void main() {
glFragColor_1_1 = inner_result.glFragColor_1;
return;
}
Error parsing GLSL shader:
ERROR: 0:103: 'rsqrt' : no matching overloaded function found
ERROR: 0:103: '' : compilation terminated
ERROR: 2 compilation errors. No code generated.

View File

@ -1,9 +1,7 @@
SKIP: FAILED
#version 310 es
void inverseSqrt_84407e() {
float res = rsqrt(1.0f);
float res = inversesqrt(1.0f);
}
vec4 vertex_main() {
@ -18,18 +16,11 @@ void main() {
gl_Position.z = ((2.0f * gl_Position.z) - gl_Position.w);
return;
}
Error parsing GLSL shader:
ERROR: 0:4: 'rsqrt' : no matching overloaded function found
ERROR: 0:4: '' : compilation terminated
ERROR: 2 compilation errors. No code generated.
#version 310 es
precision mediump float;
void inverseSqrt_84407e() {
float res = rsqrt(1.0f);
float res = inversesqrt(1.0f);
}
void fragment_main() {
@ -40,17 +31,10 @@ void main() {
fragment_main();
return;
}
Error parsing GLSL shader:
ERROR: 0:5: 'rsqrt' : no matching overloaded function found
ERROR: 0:5: '' : compilation terminated
ERROR: 2 compilation errors. No code generated.
#version 310 es
void inverseSqrt_84407e() {
float res = rsqrt(1.0f);
float res = inversesqrt(1.0f);
}
void compute_main() {
@ -62,10 +46,3 @@ void main() {
compute_main();
return;
}
Error parsing GLSL shader:
ERROR: 0:4: 'rsqrt' : no matching overloaded function found
ERROR: 0:4: '' : compilation terminated
ERROR: 2 compilation errors. No code generated.

View File

@ -1,9 +1,7 @@
SKIP: FAILED
#version 310 es
void inverseSqrt_8f2bd2() {
vec2 res = rsqrt(vec2(0.0f, 0.0f));
vec2 res = inversesqrt(vec2(0.0f, 0.0f));
}
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: 'rsqrt' : no matching overloaded function found
ERROR: 0:4: '=' : cannot convert from ' const float' to ' temp highp 2-component vector of float'
ERROR: 0:4: '' : compilation terminated
ERROR: 3 compilation errors. No code generated.
#version 310 es
precision mediump float;
void inverseSqrt_8f2bd2() {
vec2 res = rsqrt(vec2(0.0f, 0.0f));
vec2 res = inversesqrt(vec2(0.0f, 0.0f));
}
void fragment_main() {
@ -41,18 +31,10 @@ void main() {
fragment_main();
return;
}
Error parsing GLSL shader:
ERROR: 0:5: 'rsqrt' : no matching overloaded function found
ERROR: 0:5: '=' : cannot convert from ' const float' to ' temp mediump 2-component vector of float'
ERROR: 0:5: '' : compilation terminated
ERROR: 3 compilation errors. No code generated.
#version 310 es
void inverseSqrt_8f2bd2() {
vec2 res = rsqrt(vec2(0.0f, 0.0f));
vec2 res = inversesqrt(vec2(0.0f, 0.0f));
}
void compute_main() {
@ -64,11 +46,3 @@ void main() {
compute_main();
return;
}
Error parsing GLSL shader:
ERROR: 0:4: 'rsqrt' : no matching overloaded function found
ERROR: 0:4: '=' : cannot convert from ' const float' to ' temp highp 2-component vector of float'
ERROR: 0:4: '' : compilation terminated
ERROR: 3 compilation errors. No code generated.

View File

@ -1,9 +1,7 @@
SKIP: FAILED
#version 310 es
void inverseSqrt_b197b1() {
vec3 res = rsqrt(vec3(0.0f, 0.0f, 0.0f));
vec3 res = inversesqrt(vec3(0.0f, 0.0f, 0.0f));
}
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: 'rsqrt' : no matching overloaded function found
ERROR: 0:4: '=' : cannot convert from ' const float' to ' temp highp 3-component vector of float'
ERROR: 0:4: '' : compilation terminated
ERROR: 3 compilation errors. No code generated.
#version 310 es
precision mediump float;
void inverseSqrt_b197b1() {
vec3 res = rsqrt(vec3(0.0f, 0.0f, 0.0f));
vec3 res = inversesqrt(vec3(0.0f, 0.0f, 0.0f));
}
void fragment_main() {
@ -41,18 +31,10 @@ void main() {
fragment_main();
return;
}
Error parsing GLSL shader:
ERROR: 0:5: 'rsqrt' : no matching overloaded function found
ERROR: 0:5: '=' : cannot convert from ' const float' to ' temp mediump 3-component vector of float'
ERROR: 0:5: '' : compilation terminated
ERROR: 3 compilation errors. No code generated.
#version 310 es
void inverseSqrt_b197b1() {
vec3 res = rsqrt(vec3(0.0f, 0.0f, 0.0f));
vec3 res = inversesqrt(vec3(0.0f, 0.0f, 0.0f));
}
void compute_main() {
@ -64,11 +46,3 @@ void main() {
compute_main();
return;
}
Error parsing GLSL shader:
ERROR: 0:4: 'rsqrt' : no matching overloaded function found
ERROR: 0:4: '=' : cannot convert from ' const float' to ' temp highp 3-component vector of float'
ERROR: 0:4: '' : compilation terminated
ERROR: 3 compilation errors. No code generated.

View File

@ -1,9 +1,7 @@
SKIP: FAILED
#version 310 es
void inverseSqrt_c22347() {
vec4 res = rsqrt(vec4(0.0f, 0.0f, 0.0f, 0.0f));
vec4 res = inversesqrt(vec4(0.0f, 0.0f, 0.0f, 0.0f));
}
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: 'rsqrt' : no matching overloaded function found
ERROR: 0:4: '=' : cannot convert from ' const float' to ' temp highp 4-component vector of float'
ERROR: 0:4: '' : compilation terminated
ERROR: 3 compilation errors. No code generated.
#version 310 es
precision mediump float;
void inverseSqrt_c22347() {
vec4 res = rsqrt(vec4(0.0f, 0.0f, 0.0f, 0.0f));
vec4 res = inversesqrt(vec4(0.0f, 0.0f, 0.0f, 0.0f));
}
void fragment_main() {
@ -41,18 +31,10 @@ void main() {
fragment_main();
return;
}
Error parsing GLSL shader:
ERROR: 0:5: 'rsqrt' : no matching overloaded function found
ERROR: 0:5: '=' : cannot convert from ' const float' to ' temp mediump 4-component vector of float'
ERROR: 0:5: '' : compilation terminated
ERROR: 3 compilation errors. No code generated.
#version 310 es
void inverseSqrt_c22347() {
vec4 res = rsqrt(vec4(0.0f, 0.0f, 0.0f, 0.0f));
vec4 res = inversesqrt(vec4(0.0f, 0.0f, 0.0f, 0.0f));
}
void compute_main() {
@ -64,11 +46,3 @@ void main() {
compute_main();
return;
}
Error parsing GLSL shader:
ERROR: 0:4: 'rsqrt' : no matching overloaded function found
ERROR: 0:4: '=' : cannot convert from ' const float' to ' temp highp 4-component vector of float'
ERROR: 0:4: '' : compilation terminated
ERROR: 3 compilation errors. No code generated.

View File

@ -1,5 +1,3 @@
SKIP: FAILED
#version 310 es
void main_1() {
@ -25,7 +23,7 @@ void main_1() {
vec3 v3f2 = vec3(60.0f, 70.0f, 50.0f);
vec4 v4f1 = vec4(50.0f, 50.0f, 50.0f, 50.0f);
vec4 v4f2 = v4f1;
float x_1 = rsqrt(f1);
float x_1 = inversesqrt(f1);
return;
}
@ -38,10 +36,3 @@ void main() {
tint_symbol();
return;
}
Error parsing GLSL shader:
ERROR: 0:26: 'rsqrt' : no matching overloaded function found
ERROR: 0:26: '' : compilation terminated
ERROR: 2 compilation errors. No code generated.

View File

@ -1,5 +1,3 @@
SKIP: FAILED
#version 310 es
void main_1() {
@ -25,7 +23,7 @@ void main_1() {
vec3 v3f2 = vec3(60.0f, 70.0f, 50.0f);
vec4 v4f1 = vec4(50.0f, 50.0f, 50.0f, 50.0f);
vec4 v4f2 = v4f1;
vec2 x_1 = rsqrt(v2f1);
vec2 x_1 = inversesqrt(v2f1);
return;
}
@ -38,11 +36,3 @@ void main() {
tint_symbol();
return;
}
Error parsing GLSL shader:
ERROR: 0:26: 'rsqrt' : no matching overloaded function found
ERROR: 0:26: '=' : cannot convert from ' const float' to ' temp highp 2-component vector of float'
ERROR: 0:26: '' : compilation terminated
ERROR: 3 compilation errors. No code generated.

View File

@ -1,5 +1,3 @@
SKIP: FAILED
#version 310 es
precision mediump float;
@ -19,7 +17,7 @@ layout(binding = 0) uniform buf0_1 {
vec4 x_GLF_color = vec4(0.0f, 0.0f, 0.0f, 0.0f);
void main_1() {
float x_23 = x_5.x_GLF_uniform_float_values[1].el;
if ((rsqrt(x_23) < -1.0f)) {
if ((inversesqrt(x_23) < -1.0f)) {
float x_30 = x_5.x_GLF_uniform_float_values[0].el;
x_GLF_color = vec4(x_30, x_30, x_30, x_30);
} else {
@ -47,10 +45,3 @@ void main() {
x_GLF_color_1_1 = inner_result.x_GLF_color_1;
return;
}
Error parsing GLSL shader:
ERROR: 0:20: 'rsqrt' : no matching overloaded function found
ERROR: 0:20: '' : compilation terminated
ERROR: 2 compilation errors. No code generated.

View File

@ -1,5 +1,3 @@
SKIP: FAILED
vk-gl-cts/graphicsfuzz/cov-inst-value-tracking-inversesqrt/0-opt.wgsl:1:13 warning: use of deprecated language feature: the @stride attribute is deprecated; use a larger type if necessary
type Arr = @stride(16) array<f32, 2>;
^^^^^^
@ -23,7 +21,7 @@ layout(binding = 0) uniform buf0_1 {
vec4 x_GLF_color = vec4(0.0f, 0.0f, 0.0f, 0.0f);
void main_1() {
float x_23 = x_5.x_GLF_uniform_float_values[1].el;
if ((rsqrt(x_23) < -1.0f)) {
if ((inversesqrt(x_23) < -1.0f)) {
float x_30 = x_5.x_GLF_uniform_float_values[0].el;
x_GLF_color = vec4(x_30, x_30, x_30, x_30);
} else {
@ -51,10 +49,3 @@ void main() {
x_GLF_color_1_1 = inner_result.x_GLF_color_1;
return;
}
Error parsing GLSL shader:
ERROR: 0:20: 'rsqrt' : no matching overloaded function found
ERROR: 0:20: '' : compilation terminated
ERROR: 2 compilation errors. No code generated.