reader::spirv fix entry point tests

Define the ID targeted by the entry point.  Do this to avoid
asserts in the optimizer code

Bug: tint:3
Change-Id: Idbd4c8a058f2d51ff44696d2029502044d01b424
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/17562
Reviewed-by: dan sinclair <dsinclair@google.com>
This commit is contained in:
David Neto 2020-03-24 12:46:20 +00:00 committed by dan sinclair
parent a14fec951e
commit a65ea31910
1 changed files with 5 additions and 4 deletions

View File

@ -30,8 +30,9 @@ using SpvParseImport = ::testing::Test;
std::string MakeEntryPoint(const std::string& stage, std::string MakeEntryPoint(const std::string& stage,
const std::string& name, const std::string& name,
const std::string& id = "42") { const std::string& id = "42") {
return std::string("OpEntryPoint ") + stage + " %" + id + "2 \"" + name + return std::string("OpEntryPoint ") + stage + " %" + id + " \"" + name +
"\"\n"; "\"\n" + // Give the target ID a definition.
"%" + id + " = OpTypeVoid\n";
} }
TEST_F(SpvParseImport, NoEntryPoint) { TEST_F(SpvParseImport, NoEntryPoint) {
@ -43,11 +44,11 @@ TEST_F(SpvParseImport, NoEntryPoint) {
} }
TEST_F(SpvParseImport, EntryPointVertex) { TEST_F(SpvParseImport, EntryPointVertex) {
ParserImpl p(test::Assemble(MakeEntryPoint("GLCompute", "foobar"))); ParserImpl p(test::Assemble(MakeEntryPoint("Vertex", "foobar")));
EXPECT_TRUE(p.BuildAndParseInternalModule()); EXPECT_TRUE(p.BuildAndParseInternalModule());
EXPECT_TRUE(p.error().empty()); EXPECT_TRUE(p.error().empty());
const auto module_str = p.module().to_str(); const auto module_str = p.module().to_str();
EXPECT_THAT(module_str, HasSubstr(R"(EntryPoint{compute = foobar})")); EXPECT_THAT(module_str, HasSubstr(R"(EntryPoint{vertex = foobar})"));
} }
TEST_F(SpvParseImport, EntryPointFragment) { TEST_F(SpvParseImport, EntryPointFragment) {