[spirv-writer] Add start of single swizzle test case

This CL adds a DISABLED test for the single swizzle case.

Bug: tint:5
Change-Id: I75df147adba4e2e2b7eb6bfd0e0ede951502a73d
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/20300
Reviewed-by: David Neto <dneto@google.com>
This commit is contained in:
dan sinclair 2020-04-23 20:35:32 +00:00 committed by dan sinclair
parent 742790c8ff
commit 1a4d90667b
1 changed files with 35 additions and 2 deletions

View File

@ -235,11 +235,44 @@ TEST_F(BuilderTest, MemberAccessor_Nested) {
}
TEST_F(BuilderTest, DISABLED_MemberAccessor_Swizzle_Single) {
// vec.x
ast::type::F32Type f32;
ast::type::VectorType vec3(&f32, 3);
ast::Variable var("ident", ast::StorageClass::kFunction, &vec3);
ast::MemberAccessorExpression expr(
std::make_unique<ast::IdentifierExpression>("ident"),
std::make_unique<ast::IdentifierExpression>("y"));
Context ctx;
ast::Module mod;
TypeDeterminer td(&ctx, &mod);
td.RegisterVariableForTesting(&var);
ASSERT_TRUE(td.DetermineResultType(&expr)) << td.error();
Builder b(&mod);
b.push_function(Function{});
ASSERT_TRUE(b.GenerateFunctionVariable(&var)) << b.error();
EXPECT_EQ(b.GenerateAccessorExpression(&expr), 6u);
EXPECT_EQ(DumpInstructions(b.types()), R"(%3 = OpTypeFloat 32
%2 = OpTypeVector %3 3
%1 = OpTypePointer Function %2
%5 = OpTypeInt 32 0
%6 = OpConstant %5 1
%7 = OpTypePointer Function %3
)");
EXPECT_EQ(DumpInstructions(b.functions()[0].variables()),
R"(%1 = OpVariable %1 Function
)");
EXPECT_EQ(DumpInstructions(b.functions()[0].instructions()),
R"(%7 = OpAccessChain %7 %1 %6
)");
}
TEST_F(BuilderTest, DISABLED_MemberAccessor_Swizzle_Multiple) {
// vec.xy
// vec.yx
}
TEST_F(BuilderTest, DISABLED_Accessor_Mixed) {