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 <dneto@google.com>
This commit is contained in:
dan sinclair 2020-04-20 15:48:03 +00:00 committed by dan sinclair
parent ca1723e990
commit fa5a66f192
2 changed files with 6 additions and 2 deletions

View File

@ -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();
}

View File

@ -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