[spirv-reader] Set entry point name

Until now, we were only setting the function name.

Bug: tint:3
Change-Id: I6d82f6e9744201a04cc8969013694e2e8304a928
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/28080
Reviewed-by: Ryan Harrison <rharrison@chromium.org>
Commit-Queue: Ryan Harrison <rharrison@chromium.org>
This commit is contained in:
David Neto 2020-09-03 18:52:47 +00:00 committed by Commit Bot service account
parent e46282a956
commit f51a48dc49
2 changed files with 13 additions and 8 deletions

View File

@ -613,10 +613,11 @@ bool ParserImpl::EmitEntryPoints() {
module_->entry_points()) {
const auto stage = SpvExecutionModel(entry_point.GetSingleWordInOperand(0));
const uint32_t function_id = entry_point.GetSingleWordInOperand(1);
const std::string ep_name = entry_point.GetOperand(2).AsString();
const std::string name = namer_.GetName(function_id);
ast_module_.AddEntryPoint(std::make_unique<ast::EntryPoint>(
enum_converter_.ToPipelineStage(stage), "", name));
enum_converter_.ToPipelineStage(stage), ep_name, name));
}
// The enum conversion could have failed, so return the existing status value.
return success_;

View File

@ -47,7 +47,8 @@ TEST_F(SpvParserTest, EntryPoint_Vertex) {
EXPECT_TRUE(p->BuildAndParseInternalModule());
EXPECT_TRUE(p->error().empty());
const auto module_str = p->module().to_str();
EXPECT_THAT(module_str, HasSubstr(R"(EntryPoint{vertex = foobar})"));
EXPECT_THAT(module_str,
HasSubstr(R"(EntryPoint{vertex as foobar = foobar})"));
}
TEST_F(SpvParserTest, EntryPoint_Fragment) {
@ -55,7 +56,8 @@ TEST_F(SpvParserTest, EntryPoint_Fragment) {
EXPECT_TRUE(p->BuildAndParseInternalModule());
EXPECT_TRUE(p->error().empty());
const auto module_str = p->module().to_str();
EXPECT_THAT(module_str, HasSubstr(R"(EntryPoint{fragment = blitz})"));
EXPECT_THAT(module_str,
HasSubstr(R"(EntryPoint{fragment as blitz = blitz})"));
}
TEST_F(SpvParserTest, EntryPoint_Compute) {
@ -63,7 +65,7 @@ TEST_F(SpvParserTest, EntryPoint_Compute) {
EXPECT_TRUE(p->BuildAndParseInternalModule());
EXPECT_TRUE(p->error().empty());
const auto module_str = p->module().to_str();
EXPECT_THAT(module_str, HasSubstr(R"(EntryPoint{compute = sort})"));
EXPECT_THAT(module_str, HasSubstr(R"(EntryPoint{compute as sort = sort})"));
}
TEST_F(SpvParserTest, EntryPoint_MultiNameConflict) {
@ -73,9 +75,10 @@ TEST_F(SpvParserTest, EntryPoint_MultiNameConflict) {
EXPECT_TRUE(p->BuildAndParseInternalModule());
EXPECT_TRUE(p->error().empty());
const auto module_str = p->module().to_str();
EXPECT_THAT(module_str, HasSubstr(R"(EntryPoint{compute = work})"));
EXPECT_THAT(module_str, HasSubstr(R"(EntryPoint{vertex = work_1})"));
EXPECT_THAT(module_str, HasSubstr(R"(EntryPoint{fragment = work_2})"));
EXPECT_THAT(module_str, HasSubstr(R"(EntryPoint{compute as work = work})"));
EXPECT_THAT(module_str, HasSubstr(R"(EntryPoint{vertex as work = work_1})"));
EXPECT_THAT(module_str,
HasSubstr(R"(EntryPoint{fragment as work = work_2})"));
}
TEST_F(SpvParserTest, EntryPoint_NameIsSanitized) {
@ -83,7 +86,8 @@ TEST_F(SpvParserTest, EntryPoint_NameIsSanitized) {
EXPECT_TRUE(p->BuildAndParseInternalModule());
EXPECT_TRUE(p->error().empty());
const auto module_str = p->module().to_str();
EXPECT_THAT(module_str, HasSubstr(R"(EntryPoint{compute = x_1234})"));
EXPECT_THAT(module_str,
HasSubstr(R"(EntryPoint{compute as .1234 = x_1234})"));
}
} // namespace