From d4c8ab967b36184289e54bd96ffc2db72ff7ce38 Mon Sep 17 00:00:00 2001 From: David Neto Date: Wed, 15 Apr 2020 13:59:31 +0000 Subject: [PATCH] [spirv-reader] Add FOrdEqual, FOrdNotEqual Unordered equality and inequality is not yet in WGSL https://github.com/gpuweb/gpuweb/issues/706 Bug: tint:3 Change-Id: I45761ee490829f180110c578283bf136a185de9f Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/19563 Reviewed-by: dan sinclair --- src/reader/spirv/function.cc | 2 ++ src/reader/spirv/function_logical_test.cc | 23 +++++++++++++++++++++++ 2 files changed, 25 insertions(+) diff --git a/src/reader/spirv/function.cc b/src/reader/spirv/function.cc index ae9b9ad78c..d691c21473 100644 --- a/src/reader/spirv/function.cc +++ b/src/reader/spirv/function.cc @@ -55,8 +55,10 @@ ast::BinaryOp ConvertBinaryOp(SpvOp opcode) { case SpvOpShiftRightArithmetic: return ast::BinaryOp::kShiftRightArith; case SpvOpIEqual: + case SpvOpFOrdEqual: return ast::BinaryOp::kEqual; case SpvOpINotEqual: + case SpvOpFOrdNotEqual: return ast::BinaryOp::kNotEqual; case SpvOpBitwiseAnd: return ast::BinaryOp::kAnd; diff --git a/src/reader/spirv/function_logical_test.cc b/src/reader/spirv/function_logical_test.cc index 4973ae93ad..7f589597f6 100644 --- a/src/reader/spirv/function_logical_test.cc +++ b/src/reader/spirv/function_logical_test.cc @@ -195,6 +195,17 @@ INSTANTIATE_TEST_SUITE_P( "__vec_2__bool", AstFor("v2int_30_40"), "equal", AstFor("v2int_40_30")})); +INSTANTIATE_TEST_SUITE_P( + SpvParserTest_FOrdEqual, + SpvBinaryLogicalTest, + ::testing::Values(BinaryData{"bool", "float_50", "OpFOrdEqual", "float_60", + "__bool", "ScalarConstructor{50.000000}", + "equal", "ScalarConstructor{60.000000}"}, + BinaryData{"v2bool", "v2float_50_60", "OpFOrdEqual", + "v2float_60_50", "__vec_2__bool", + AstFor("v2float_50_60"), "equal", + AstFor("v2float_60_50")})); + INSTANTIATE_TEST_SUITE_P( SpvParserTest_INotEqual, SpvBinaryLogicalTest, @@ -216,6 +227,18 @@ INSTANTIATE_TEST_SUITE_P( "__vec_2__bool", AstFor("v2int_30_40"), "not_equal", AstFor("v2int_40_30")})); +INSTANTIATE_TEST_SUITE_P( + SpvParserTest_FOrdNotEqual, + SpvBinaryLogicalTest, + ::testing::Values(BinaryData{"bool", "float_50", "OpFOrdNotEqual", + "float_60", "__bool", + "ScalarConstructor{50.000000}", "not_equal", + "ScalarConstructor{60.000000}"}, + BinaryData{"v2bool", "v2float_50_60", "OpFOrdNotEqual", + "v2float_60_50", "__vec_2__bool", + AstFor("v2float_50_60"), "not_equal", + AstFor("v2float_60_50")})); + INSTANTIATE_TEST_SUITE_P( SpvParserTest_LogicalAnd, SpvBinaryLogicalTest,