GLSL: implement atan2.

GLSL has no atan2() instrinsic, but a 2-parameter overloaded atan()
instead.

Bug: tint:1222
Change-Id: I368b3989117cd329fea1020cd941daa0a69525cd
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/66360
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Stephen White <senorblanco@chromium.org>
Reviewed-by: Ben Clayton <bclayton@google.com>
This commit is contained in:
Stephen White 2021-10-14 16:17:38 +00:00 committed by Tint LUCI CQ
parent 7f1c8d98c5
commit b281dd168d
3 changed files with 5 additions and 4 deletions

View File

@ -1174,7 +1174,6 @@ std::string GeneratorImpl::generate_builtin_name(
case sem::IntrinsicType::kAny:
case sem::IntrinsicType::kAsin:
case sem::IntrinsicType::kAtan:
case sem::IntrinsicType::kAtan2:
case sem::IntrinsicType::kCeil:
case sem::IntrinsicType::kClamp:
case sem::IntrinsicType::kCos:
@ -1209,6 +1208,8 @@ std::string GeneratorImpl::generate_builtin_name(
case sem::IntrinsicType::kTranspose:
case sem::IntrinsicType::kTrunc:
return intrinsic->str();
case sem::IntrinsicType::kAtan2:
return "atan";
case sem::IntrinsicType::kCountOneBits:
return "countbits";
case sem::IntrinsicType::kDpdx:

View File

@ -145,7 +145,7 @@ TEST_P(GlslImportData_DualParam_ScalarTest, Float) {
}
INSTANTIATE_TEST_SUITE_P(GlslGeneratorImplTest_Import,
GlslImportData_DualParam_ScalarTest,
testing::Values(GlslImportData{"atan2", "atan2"},
testing::Values(GlslImportData{"atan2", "atan"},
GlslImportData{"distance", "distance"},
GlslImportData{"max", "max"},
GlslImportData{"min", "min"},
@ -169,7 +169,7 @@ TEST_P(GlslImportData_DualParam_VectorTest, Float) {
}
INSTANTIATE_TEST_SUITE_P(GlslGeneratorImplTest_Import,
GlslImportData_DualParam_VectorTest,
testing::Values(GlslImportData{"atan2", "atan2"},
testing::Values(GlslImportData{"atan2", "atan"},
GlslImportData{"cross", "cross"},
GlslImportData{"distance", "distance"},
GlslImportData{"max", "max"},

View File

@ -192,7 +192,7 @@ INSTANTIATE_TEST_SUITE_P(
IntrinsicData{IntrinsicType::kAny, ParamType::kBool, "any"},
IntrinsicData{IntrinsicType::kAsin, ParamType::kF32, "asin"},
IntrinsicData{IntrinsicType::kAtan, ParamType::kF32, "atan"},
IntrinsicData{IntrinsicType::kAtan2, ParamType::kF32, "atan2"},
IntrinsicData{IntrinsicType::kAtan2, ParamType::kF32, "atan"},
IntrinsicData{IntrinsicType::kCeil, ParamType::kF32, "ceil"},
IntrinsicData{IntrinsicType::kClamp, ParamType::kF32, "clamp"},
IntrinsicData{IntrinsicType::kClamp, ParamType::kU32, "clamp"},