From a49328f60e950704f70363f32f38d44db3f536bd Mon Sep 17 00:00:00 2001 From: dan sinclair Date: Mon, 20 Apr 2020 15:49:50 +0000 Subject: [PATCH] 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 --- src/type_determiner.cc | 18 +++++++++++- src/type_determiner_test.cc | 56 ++++++++++++++++++++----------------- 2 files changed, 48 insertions(+), 26 deletions(-) diff --git a/src/type_determiner.cc b/src/type_determiner.cc index 325f96c074..c250bdd6ce 100644 --- a/src/type_determiner.cc +++ b/src/type_determiner.cc @@ -585,13 +585,17 @@ ast::type::Type* TypeDeterminer::GetImportData( // * 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 @@ ast::type::Type* TypeDeterminer::GetImportData( *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 6136bcb17e..f08f4911c3 100644 --- a/src/type_determiner_test.cc +++ b/src/type_determiner_test.cc @@ -1585,31 +1585,37 @@ TEST_P(ImportData_FloatTest, Error_MultipleParams) { 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