Add Remaining 2 parameter GLSL float methods.

This CL adds conversions for the remaining GLSL methods which accept
two float parameters.

Bug: tint:5
Change-Id: I545567f67baaae62d5a85d3d7cacc64571d7a8e8
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/20020
Reviewed-by: David Neto <dneto@google.com>
This commit is contained in:
dan sinclair 2020-04-21 12:58:35 +00:00
parent 37d62c9291
commit 2ee4a7e0c9
2 changed files with 25 additions and 2 deletions

View File

@ -686,7 +686,9 @@ ast::type::Type* TypeDeterminer::GetImportData(
// Length returns a scalar of the same type as the parameter.
return result_type->is_float_scalar() ? result_type
: result_type->AsVector()->type();
} else if (name == "atan2") {
} else if (name == "atan2" || name == "pow" || name == "fmin" ||
name == "fmax" || name == "step" || name == "reflect" ||
name == "nmin" || name == "nmax") {
if (params.size() != 2) {
error_ = "incorrect number of parameters for " + name +
". Expected 2 got " + std::to_string(params.size());
@ -705,6 +707,20 @@ ast::type::Type* TypeDeterminer::GetImportData(
if (name == "atan2") {
*id = GLSLstd450Atan2;
} else if (name == "pow") {
*id = GLSLstd450Pow;
} else if (name == "fmin") {
*id = GLSLstd450FMin;
} else if (name == "fmax") {
*id = GLSLstd450FMax;
} else if (name == "step") {
*id = GLSLstd450Step;
} else if (name == "reflect") {
*id = GLSLstd450Reflect;
} else if (name == "nmin") {
*id = GLSLstd450NMin;
} else if (name == "nmax") {
*id = GLSLstd450NMax;
}
return params[0]->result_type();

View File

@ -1901,7 +1901,14 @@ TEST_P(ImportData_TwoParamTest, Error_TooManyParams) {
INSTANTIATE_TEST_SUITE_P(TypeDeterminerTest,
ImportData_TwoParamTest,
testing::Values(GLSLData{"atan2", GLSLstd450Atan2}));
testing::Values(GLSLData{"atan2", GLSLstd450Atan2},
GLSLData{"pow", GLSLstd450Pow},
GLSLData{"fmin", GLSLstd450FMin},
GLSLData{"fmax", GLSLstd450FMax},
GLSLData{"step", GLSLstd450Step},
GLSLData{"reflect", GLSLstd450Reflect},
GLSLData{"nmin", GLSLstd450NMin},
GLSLData{"nmax", GLSLstd450NMax}));
} // namespace
} // namespace tint