spirv-reader: Add test for mixed-size vector shuffle

The other test use the same vector width for the operands.

Change-Id: I2437c2ebef9f87eef4dc91c266460c837c019cd4
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/67500
Auto-Submit: David Neto <dneto@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: David Neto <dneto@google.com>
Reviewed-by: James Price <jrprice@google.com>
This commit is contained in:
David Neto 2021-11-01 14:18:51 +00:00 committed by Tint LUCI CQ
parent 85a4282de6
commit 98dc04329f
1 changed files with 23 additions and 0 deletions

View File

@ -834,6 +834,29 @@ TEST_F(SpvParserTest_VectorShuffle, ConstantOperands_AllOnesMapToNull) {
HasSubstr("let x_10 : vec2<u32> = vec2<u32>(0u, x_1.y);"));
}
TEST_F(SpvParserTest_VectorShuffle,
FunctionScopeOperands_MixedInputOperandSizes) {
// Note that variables are generated for the vector operands.
const auto assembly = Preamble() + R"(
%v3uint_3_4_5 = OpConstantComposite %v3uint %uint_3 %uint_4 %uint_5
%100 = OpFunction %void None %voidfn
%entry = OpLabel
%1 = OpCopyObject %v2uint %v2uint_3_4
%3 = OpCopyObject %v3uint %v3uint_3_4_5
%10 = OpVectorShuffle %v2uint %1 %3 1 4
OpReturn
OpFunctionEnd
)";
auto p = parser(test::Assemble(assembly));
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << assembly;
auto fe = p->function_emitter(100);
EXPECT_TRUE(fe.EmitBody()) << p->error();
auto ast_body = fe.ast_body();
EXPECT_THAT(test::ToString(p->program(), ast_body),
HasSubstr("let x_10 : vec2<u32> = vec2<u32>(x_1.y, x_3.z);"));
}
TEST_F(SpvParserTest_VectorShuffle, IndexTooBig_IsError) {
const auto assembly = Preamble() + R"(
%100 = OpFunction %void None %voidfn