From 3df2044e36cdfd2f4bcb57f162d405e1d4f12bca Mon Sep 17 00:00:00 2001 From: dan sinclair Date: Mon, 20 Apr 2020 15:51:18 +0000 Subject: [PATCH] Add GLSL normalize method. This CL adds type determinater support for Normalize. Bug: tint:5 Change-Id: Idbea41942172f8404122b7a756ccf1ec5aad2af8 Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/19950 Reviewed-by: David Neto --- src/type_determiner.cc | 4 +++- src/type_determiner_test.cc | 3 ++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/type_determiner.cc b/src/type_determiner.cc index c250bdd6ce..06e45c57fb 100644 --- a/src/type_determiner.cc +++ b/src/type_determiner.cc @@ -595,7 +595,7 @@ ast::type::Type* TypeDeterminer::GetImportData( name == "acos" || name == "atan" || name == "sinh" || name == "cosh" || name == "tanh" || name == "asinh" || name == "acosh" || name == "atanh" || name == "exp" || name == "log" || name == "exp2" || name == "log2" || - name == "sqrt" || name == "inversesqrt") { + name == "sqrt" || name == "inversesqrt" || name == "normalize") { if (params.size() != 1) { error_ = "incorrect number of parameters for " + name + ". Expected 1 got " + std::to_string(params.size()); @@ -663,6 +663,8 @@ ast::type::Type* TypeDeterminer::GetImportData( *id = GLSLstd450Sqrt; } else if (name == "inversesqrt") { *id = GLSLstd450InverseSqrt; + } else if (name == "normalize") { + *id = GLSLstd450Normalize; } return params[0]->result_type(); diff --git a/src/type_determiner_test.cc b/src/type_determiner_test.cc index f08f4911c3..cbb52bf984 100644 --- a/src/type_determiner_test.cc +++ b/src/type_determiner_test.cc @@ -1615,7 +1615,8 @@ INSTANTIATE_TEST_SUITE_P( GLSLData{"exp2", GLSLstd450Exp2}, GLSLData{"log2", GLSLstd450Log2}, GLSLData{"sqrt", GLSLstd450Sqrt}, - GLSLData{"inversesqrt", GLSLstd450InverseSqrt})); + GLSLData{"inversesqrt", GLSLstd450InverseSqrt}, + GLSLData{"normalize", GLSLstd450Normalize})); } // namespace } // namespace tint