From fa5a66f192f8221c7e69768b17cfbc6075f91e83 Mon Sep 17 00:00:00 2001 From: dan sinclair Date: Mon, 20 Apr 2020 15:48:03 +0000 Subject: [PATCH] Add GLSL Trunc support. This CL adds type determination for the Trunc method. Bug: tint:5 Change-Id: I4f23dad7725f1f076fbbc7da8687de42a02cc482 Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/19941 Reviewed-by: David Neto --- src/type_determiner.cc | 5 ++++- src/type_determiner_test.cc | 3 ++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/type_determiner.cc b/src/type_determiner.cc index ad6f9c40d8..3115e7cd94 100644 --- a/src/type_determiner.cc +++ b/src/type_determiner.cc @@ -576,7 +576,7 @@ ast::type::Type* TypeDeterminer::GetImportData( return nullptr; } - if (name == "round" || name == "roundeven") { + if (name == "round" || name == "roundeven" || name == "trunc") { if (params.size() != 1) { error_ = "incorrect number of parameters for " + name + ". Expected 1 got " + std::to_string(params.size()); @@ -592,7 +592,10 @@ ast::type::Type* TypeDeterminer::GetImportData( *id = GLSLstd450Round; } else if (name == "roundeven") { *id = GLSLstd450RoundEven; + } else if (name == "trunc") { + *id = GLSLstd450Trunc; } + return params[0]->result_type(); } diff --git a/src/type_determiner_test.cc b/src/type_determiner_test.cc index bebeae49a1..f3a2b893db 100644 --- a/src/type_determiner_test.cc +++ b/src/type_determiner_test.cc @@ -1589,7 +1589,8 @@ INSTANTIATE_TEST_SUITE_P(TypeDeterminerTest, ImportData_FloatTest, testing::Values(GLSLData{"round", GLSLstd450Round}, GLSLData{"roundeven", - GLSLstd450RoundEven})); + GLSLstd450RoundEven}, + GLSLData{"trunc", GLSLstd450Trunc})); } // namespace } // namespace tint