From b90a56fb66ae931cc44af0a80e44ebaa876d3906 Mon Sep 17 00:00:00 2001 From: dan sinclair Date: Mon, 20 Apr 2020 15:49:33 +0000 Subject: [PATCH] Add GLSL Radians and Degrees methods. This CL adds support to the type determiner for the GLSL Radians and Degrees methods. We use the general float calls for this because we only support FP32 and have plans for FP16. Other floating point sizes are not supported but we have no support for them.. Bug: tint:5 Change-Id: I38f0551ce5f9ed7dd31496f13880697cd1f21ba4 Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/19947 Reviewed-by: David Neto --- src/type_determiner.cc | 12 +++++++++++- src/type_determiner_test.cc | 24 +++++++++++++----------- 2 files changed, 24 insertions(+), 12 deletions(-) diff --git a/src/type_determiner.cc b/src/type_determiner.cc index 26939257ce..d60ae9b0db 100644 --- a/src/type_determiner.cc +++ b/src/type_determiner.cc @@ -576,9 +576,15 @@ ast::type::Type* TypeDeterminer::GetImportData( return nullptr; } + // Most of these are floating-point general except the below which are only + // FP16 and FP32. We only have FP32 at this point so the below works, if we + // get FP64 support or otherwise we'll need to differentiate. + // * radians + // * degrees + if (name == "round" || name == "roundeven" || name == "trunc" || name == "fabs" || name == "fsign" || name == "floor" || name == "ceil" || - name == "fract") { + name == "fract" || name == "radians" || name == "degrees") { if (params.size() != 1) { error_ = "incorrect number of parameters for " + name + ". Expected 1 got " + std::to_string(params.size()); @@ -606,6 +612,10 @@ ast::type::Type* TypeDeterminer::GetImportData( *id = GLSLstd450Ceil; } else if (name == "fract") { *id = GLSLstd450Fract; + } else if (name == "radians") { + *id = GLSLstd450Radians; + } else if (name == "degrees") { + *id = GLSLstd450Degrees; } return params[0]->result_type(); diff --git a/src/type_determiner_test.cc b/src/type_determiner_test.cc index 1a7db6f11e..f12ea4bd16 100644 --- a/src/type_determiner_test.cc +++ b/src/type_determiner_test.cc @@ -1585,17 +1585,19 @@ TEST_P(ImportData_FloatTest, Error_MultipleParams) { param.name + ". Expected 1 got 3"); } -INSTANTIATE_TEST_SUITE_P(TypeDeterminerTest, - ImportData_FloatTest, - testing::Values(GLSLData{"round", GLSLstd450Round}, - GLSLData{"roundeven", - GLSLstd450RoundEven}, - GLSLData{"trunc", GLSLstd450Trunc}, - GLSLData{"fabs", GLSLstd450FAbs}, - GLSLData{"fsign", GLSLstd450FSign}, - GLSLData{"floor", GLSLstd450Floor}, - GLSLData{"ceil", GLSLstd450Ceil}, - GLSLData{"fract", GLSLstd450Fract})); +INSTANTIATE_TEST_SUITE_P( + TypeDeterminerTest, + ImportData_FloatTest, + testing::Values(GLSLData{"round", GLSLstd450Round}, + GLSLData{"roundeven", GLSLstd450RoundEven}, + GLSLData{"trunc", GLSLstd450Trunc}, + GLSLData{"fabs", GLSLstd450FAbs}, + GLSLData{"fsign", GLSLstd450FSign}, + GLSLData{"floor", GLSLstd450Floor}, + GLSLData{"ceil", GLSLstd450Ceil}, + GLSLData{"fract", GLSLstd450Fract}, + GLSLData{"radians", GLSLstd450Radians}, + GLSLData{"degrees", GLSLstd450Degrees})); } // namespace } // namespace tint