Add GLSL trig methods.
This CL adds support for the GLSL trig functions. * sin * cos * tan * asin * acos * atan * sinh * cosh * tanh * asinh * acosh * atanh Bug: tint:5 Change-Id: I38c8bf45c3aeeef81711de3a3eca6a9339af146c Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/19948 Reviewed-by: David Neto <dneto@google.com>
This commit is contained in:
parent
b90a56fb66
commit
132b2daa19
|
@ -581,10 +581,17 @@ ast::type::Type* TypeDeterminer::GetImportData(
|
||||||
// get FP64 support or otherwise we'll need to differentiate.
|
// get FP64 support or otherwise we'll need to differentiate.
|
||||||
// * radians
|
// * radians
|
||||||
// * degrees
|
// * degrees
|
||||||
|
// * sin, cos, tan
|
||||||
|
// * asin, acos, atan
|
||||||
|
// * sinh, cosh, tanh
|
||||||
|
// * asinh, acosh, atanh
|
||||||
|
|
||||||
if (name == "round" || name == "roundeven" || name == "trunc" ||
|
if (name == "round" || name == "roundeven" || name == "trunc" ||
|
||||||
name == "fabs" || name == "fsign" || name == "floor" || name == "ceil" ||
|
name == "fabs" || name == "fsign" || name == "floor" || name == "ceil" ||
|
||||||
name == "fract" || name == "radians" || name == "degrees") {
|
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") {
|
||||||
if (params.size() != 1) {
|
if (params.size() != 1) {
|
||||||
error_ = "incorrect number of parameters for " + name +
|
error_ = "incorrect number of parameters for " + name +
|
||||||
". Expected 1 got " + std::to_string(params.size());
|
". Expected 1 got " + std::to_string(params.size());
|
||||||
|
@ -616,6 +623,30 @@ ast::type::Type* TypeDeterminer::GetImportData(
|
||||||
*id = GLSLstd450Radians;
|
*id = GLSLstd450Radians;
|
||||||
} else if (name == "degrees") {
|
} else if (name == "degrees") {
|
||||||
*id = GLSLstd450Degrees;
|
*id = GLSLstd450Degrees;
|
||||||
|
} else if (name == "sin") {
|
||||||
|
*id = GLSLstd450Sin;
|
||||||
|
} else if (name == "cos") {
|
||||||
|
*id = GLSLstd450Cos;
|
||||||
|
} else if (name == "tan") {
|
||||||
|
*id = GLSLstd450Tan;
|
||||||
|
} else if (name == "asin") {
|
||||||
|
*id = GLSLstd450Asin;
|
||||||
|
} else if (name == "acos") {
|
||||||
|
*id = GLSLstd450Acos;
|
||||||
|
} else if (name == "atan") {
|
||||||
|
*id = GLSLstd450Atan;
|
||||||
|
} else if (name == "sinh") {
|
||||||
|
*id = GLSLstd450Sinh;
|
||||||
|
} else if (name == "cosh") {
|
||||||
|
*id = GLSLstd450Cosh;
|
||||||
|
} else if (name == "tanh") {
|
||||||
|
*id = GLSLstd450Tanh;
|
||||||
|
} else if (name == "asinh") {
|
||||||
|
*id = GLSLstd450Asinh;
|
||||||
|
} else if (name == "acosh") {
|
||||||
|
*id = GLSLstd450Acosh;
|
||||||
|
} else if (name == "atanh") {
|
||||||
|
*id = GLSLstd450Atanh;
|
||||||
}
|
}
|
||||||
|
|
||||||
return params[0]->result_type();
|
return params[0]->result_type();
|
||||||
|
|
|
@ -1585,19 +1585,31 @@ TEST_P(ImportData_FloatTest, Error_MultipleParams) {
|
||||||
param.name + ". Expected 1 got 3");
|
param.name + ". Expected 1 got 3");
|
||||||
}
|
}
|
||||||
|
|
||||||
INSTANTIATE_TEST_SUITE_P(
|
INSTANTIATE_TEST_SUITE_P(TypeDeterminerTest,
|
||||||
TypeDeterminerTest,
|
ImportData_FloatTest,
|
||||||
ImportData_FloatTest,
|
testing::Values(GLSLData{"round", GLSLstd450Round},
|
||||||
testing::Values(GLSLData{"round", GLSLstd450Round},
|
GLSLData{"roundeven",
|
||||||
GLSLData{"roundeven", GLSLstd450RoundEven},
|
GLSLstd450RoundEven},
|
||||||
GLSLData{"trunc", GLSLstd450Trunc},
|
GLSLData{"trunc", GLSLstd450Trunc},
|
||||||
GLSLData{"fabs", GLSLstd450FAbs},
|
GLSLData{"fabs", GLSLstd450FAbs},
|
||||||
GLSLData{"fsign", GLSLstd450FSign},
|
GLSLData{"fsign", GLSLstd450FSign},
|
||||||
GLSLData{"floor", GLSLstd450Floor},
|
GLSLData{"floor", GLSLstd450Floor},
|
||||||
GLSLData{"ceil", GLSLstd450Ceil},
|
GLSLData{"ceil", GLSLstd450Ceil},
|
||||||
GLSLData{"fract", GLSLstd450Fract},
|
GLSLData{"fract", GLSLstd450Fract},
|
||||||
GLSLData{"radians", GLSLstd450Radians},
|
GLSLData{"radians", GLSLstd450Radians},
|
||||||
GLSLData{"degrees", GLSLstd450Degrees}));
|
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}));
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
} // namespace tint
|
} // namespace tint
|
||||||
|
|
Loading…
Reference in New Issue