tint/writer/wgsl: Emit inferred-type arrays
Bug: tint:1628 Change-Id: If0907ee7c4dc3d0216aba0282dc2c5203a3ea727 Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/97590 Reviewed-by: Dan Sinclair <dsinclair@chromium.org> Commit-Queue: Ben Clayton <bclayton@google.com>
This commit is contained in:
parent
19e9673e0a
commit
db5d2ea4f2
|
@ -382,7 +382,11 @@ bool GeneratorImpl::EmitType(std::ostream& out, const ast::Type* ty) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
out << "array<";
|
out << "array";
|
||||||
|
if (ary->type) {
|
||||||
|
out << "<";
|
||||||
|
TINT_DEFER(out << ">");
|
||||||
|
|
||||||
if (!EmitType(out, ary->type)) {
|
if (!EmitType(out, ary->type)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -393,8 +397,7 @@ bool GeneratorImpl::EmitType(std::ostream& out, const ast::Type* ty) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
out << ">";
|
|
||||||
return true;
|
return true;
|
||||||
},
|
},
|
||||||
[&](const ast::Bool*) {
|
[&](const ast::Bool*) {
|
||||||
|
|
|
@ -174,5 +174,17 @@ TEST_F(WgslGeneratorImplTest, EmitConstructor_Type_Array) {
|
||||||
"vec3<f32>(4.0f, 5.0f, 6.0f), vec3<f32>(7.0f, 8.0f, 9.0f))"));
|
"vec3<f32>(4.0f, 5.0f, 6.0f), vec3<f32>(7.0f, 8.0f, 9.0f))"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TEST_F(WgslGeneratorImplTest, EmitConstructor_Type_ImplicitArray) {
|
||||||
|
WrapInFunction(Construct(ty.array(nullptr, nullptr), vec3<f32>(1_f, 2_f, 3_f),
|
||||||
|
vec3<f32>(4_f, 5_f, 6_f), vec3<f32>(7_f, 8_f, 9_f)));
|
||||||
|
|
||||||
|
GeneratorImpl& gen = Build();
|
||||||
|
|
||||||
|
ASSERT_TRUE(gen.Generate()) << gen.error();
|
||||||
|
EXPECT_THAT(gen.result(),
|
||||||
|
HasSubstr("array(vec3<f32>(1.0f, 2.0f, 3.0f), "
|
||||||
|
"vec3<f32>(4.0f, 5.0f, 6.0f), vec3<f32>(7.0f, 8.0f, 9.0f))"));
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
} // namespace tint::writer::wgsl
|
} // namespace tint::writer::wgsl
|
||||||
|
|
Loading…
Reference in New Issue