Add support for GLSL exp, exp2, log, log2, sqrt and inversesqrt
This CL adds type determiner support for the Exp, Exp2, Log, Log2, Sqrt
and InverseSqrt GLSL methods.
Bug: tint:5
Change-Id: I3b9e799a8ebe5e8c96c1daf07131feae40e0c54e
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/19949
Reviewed-by: David Neto <dneto@google.com>
diff --git a/src/type_determiner.cc b/src/type_determiner.cc
index 325f96c..c250bdd 100644
--- a/src/type_determiner.cc
+++ b/src/type_determiner.cc
@@ -585,13 +585,17 @@
// * asin, acos, atan
// * sinh, cosh, tanh
// * asinh, acosh, atanh
+ // * exp, exp2
+ // * log, log2
if (name == "round" || name == "roundeven" || name == "trunc" ||
name == "fabs" || name == "fsign" || name == "floor" || name == "ceil" ||
name == "fract" || name == "radians" || name == "degrees" ||
name == "sin" || name == "cos" || name == "tan" || name == "asin" ||
name == "acos" || name == "atan" || name == "sinh" || name == "cosh" ||
- name == "tanh" || name == "asinh" || name == "acosh" || name == "atanh") {
+ name == "tanh" || name == "asinh" || name == "acosh" || name == "atanh" ||
+ name == "exp" || name == "log" || name == "exp2" || name == "log2" ||
+ name == "sqrt" || name == "inversesqrt") {
if (params.size() != 1) {
error_ = "incorrect number of parameters for " + name +
". Expected 1 got " + std::to_string(params.size());
@@ -647,6 +651,18 @@
*id = GLSLstd450Acosh;
} else if (name == "atanh") {
*id = GLSLstd450Atanh;
+ } else if (name == "exp") {
+ *id = GLSLstd450Exp;
+ } else if (name == "log") {
+ *id = GLSLstd450Log;
+ } else if (name == "exp2") {
+ *id = GLSLstd450Exp2;
+ } else if (name == "log2") {
+ *id = GLSLstd450Log2;
+ } else if (name == "sqrt") {
+ *id = GLSLstd450Sqrt;
+ } else if (name == "inversesqrt") {
+ *id = GLSLstd450InverseSqrt;
}
return params[0]->result_type();
diff --git a/src/type_determiner_test.cc b/src/type_determiner_test.cc
index 6136bcb..f08f491 100644
--- a/src/type_determiner_test.cc
+++ b/src/type_determiner_test.cc
@@ -1585,31 +1585,37 @@
param.name + ". Expected 1 got 3");
}
-INSTANTIATE_TEST_SUITE_P(TypeDeterminerTest,
- ImportData_FloatTest,
- testing::Values(GLSLData{"round", GLSLstd450Round},
- GLSLData{"roundeven",
- GLSLstd450RoundEven},
- GLSLData{"trunc", GLSLstd450Trunc},
- GLSLData{"fabs", GLSLstd450FAbs},
- GLSLData{"fsign", GLSLstd450FSign},
- GLSLData{"floor", GLSLstd450Floor},
- GLSLData{"ceil", GLSLstd450Ceil},
- GLSLData{"fract", GLSLstd450Fract},
- GLSLData{"radians", GLSLstd450Radians},
- GLSLData{"degrees", GLSLstd450Degrees},
- GLSLData{"sin", GLSLstd450Sin},
- GLSLData{"cos", GLSLstd450Cos},
- GLSLData{"tan", GLSLstd450Tan},
- GLSLData{"asin", GLSLstd450Asin},
- GLSLData{"acos", GLSLstd450Acos},
- GLSLData{"atan", GLSLstd450Atan},
- GLSLData{"sinh", GLSLstd450Sinh},
- GLSLData{"cosh", GLSLstd450Cosh},
- GLSLData{"tanh", GLSLstd450Tanh},
- GLSLData{"asinh", GLSLstd450Asinh},
- GLSLData{"acosh", GLSLstd450Acosh},
- GLSLData{"atanh", GLSLstd450Atanh}));
+INSTANTIATE_TEST_SUITE_P(
+ TypeDeterminerTest,
+ ImportData_FloatTest,
+ testing::Values(GLSLData{"round", GLSLstd450Round},
+ GLSLData{"roundeven", GLSLstd450RoundEven},
+ GLSLData{"trunc", GLSLstd450Trunc},
+ GLSLData{"fabs", GLSLstd450FAbs},
+ GLSLData{"fsign", GLSLstd450FSign},
+ GLSLData{"floor", GLSLstd450Floor},
+ GLSLData{"ceil", GLSLstd450Ceil},
+ GLSLData{"fract", GLSLstd450Fract},
+ GLSLData{"radians", GLSLstd450Radians},
+ GLSLData{"degrees", GLSLstd450Degrees},
+ GLSLData{"sin", GLSLstd450Sin},
+ GLSLData{"cos", GLSLstd450Cos},
+ GLSLData{"tan", GLSLstd450Tan},
+ GLSLData{"asin", GLSLstd450Asin},
+ GLSLData{"acos", GLSLstd450Acos},
+ GLSLData{"atan", GLSLstd450Atan},
+ GLSLData{"sinh", GLSLstd450Sinh},
+ GLSLData{"cosh", GLSLstd450Cosh},
+ GLSLData{"tanh", GLSLstd450Tanh},
+ GLSLData{"asinh", GLSLstd450Asinh},
+ GLSLData{"acosh", GLSLstd450Acosh},
+ GLSLData{"atanh", GLSLstd450Atanh},
+ GLSLData{"exp", GLSLstd450Exp},
+ GLSLData{"log", GLSLstd450Log},
+ GLSLData{"exp2", GLSLstd450Exp2},
+ GLSLData{"log2", GLSLstd450Log2},
+ GLSLData{"sqrt", GLSLstd450Sqrt},
+ GLSLData{"inversesqrt", GLSLstd450InverseSqrt}));
} // namespace
} // namespace tint