From b281dd168d552e52776184d61ddcc97d3b973cdc Mon Sep 17 00:00:00 2001 From: Stephen White Date: Thu, 14 Oct 2021 16:17:38 +0000 Subject: [PATCH] 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 Commit-Queue: Stephen White Reviewed-by: Ben Clayton --- src/writer/glsl/generator_impl.cc | 3 ++- src/writer/glsl/generator_impl_import_test.cc | 4 ++-- src/writer/glsl/generator_impl_intrinsic_test.cc | 2 +- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/writer/glsl/generator_impl.cc b/src/writer/glsl/generator_impl.cc index 55b5098a50..91fb6dc5ee 100644 --- a/src/writer/glsl/generator_impl.cc +++ b/src/writer/glsl/generator_impl.cc @@ -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: diff --git a/src/writer/glsl/generator_impl_import_test.cc b/src/writer/glsl/generator_impl_import_test.cc index 6e6ee73a2f..9f4dddf9db 100644 --- a/src/writer/glsl/generator_impl_import_test.cc +++ b/src/writer/glsl/generator_impl_import_test.cc @@ -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"}, diff --git a/src/writer/glsl/generator_impl_intrinsic_test.cc b/src/writer/glsl/generator_impl_intrinsic_test.cc index fc8183be9c..35333de19a 100644 --- a/src/writer/glsl/generator_impl_intrinsic_test.cc +++ b/src/writer/glsl/generator_impl_intrinsic_test.cc @@ -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"},