Exclude builtins from reflected stage variables

BUG=tint:456

Change-Id: I941b25dd5bf5e758d5fdecf379137d92d5db8556
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/38460
Commit-Queue: Ryan Harrison <rharrison@chromium.org>
Commit-Queue: dan sinclair <dsinclair@chromium.org>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
Auto-Submit: Ryan Harrison <rharrison@chromium.org>
This commit is contained in:
Ryan Harrison 2021-01-25 21:15:08 +00:00 committed by Commit Bot service account
parent d59cedb5a5
commit b16a5d6e9b
2 changed files with 42 additions and 0 deletions

View File

@ -66,6 +66,10 @@ std::vector<EntryPoint> Inspector::GetEntryPoints() {
for (auto* var : func->referenced_module_variables()) {
auto name = module_.SymbolToName(var->symbol());
if (var->HasBuiltinDecoration()) {
continue;
}
StageVariable stage_variable;
stage_variable.name = name;
auto* location_decoration = var->GetLocationDecoration();
@ -82,6 +86,7 @@ std::vector<EntryPoint> Inspector::GetEntryPoints() {
entry_point.output_variables.push_back(stage_variable);
}
}
result.push_back(std::move(entry_point));
}

View File

@ -1113,6 +1113,43 @@ TEST_F(InspectorGetEntryPointTest, MultipleEntryPointsSharedInOutVariables) {
EXPECT_EQ(3u, result[1].output_variables[0].location_decoration);
}
TEST_F(InspectorGetEntryPointTest, BuiltInsNotStageVariables) {
mod->AddGlobalVariable(
Var("in_var", ast::StorageClass::kInput, ty.u32, nullptr,
ast::VariableDecorationList{
create<ast::BuiltinDecoration>(ast::Builtin::kPosition)}));
mod->AddGlobalVariable(
Var("out_var", ast::StorageClass::kOutput, ty.u32, nullptr,
ast::VariableDecorationList{create<ast::LocationDecoration>(0)}));
auto* func =
MakeInOutVariableBodyFunction("func", {{"in_var", "out_var"}}, {});
mod->Functions().Add(func);
auto* foo = MakeCallerBodyFunction(
"foo", "func",
ast::FunctionDecorationList{
create<ast::StageDecoration>(ast::PipelineStage::kVertex),
});
mod->Functions().Add(foo);
ASSERT_TRUE(td()->Determine()) << td()->error();
// TODO(dsinclair): Update to run the namer transform when available.
auto result = inspector()->GetEntryPoints();
ASSERT_FALSE(inspector()->has_error()) << inspector()->error();
ASSERT_EQ(1u, result.size());
ASSERT_EQ("foo", result[0].name);
ASSERT_EQ("foo", result[0].remapped_name);
EXPECT_EQ(0u, result[0].input_variables.size());
EXPECT_EQ(1u, result[0].output_variables.size());
EXPECT_TRUE(ContainsName(result[0].output_variables, "out_var"));
EXPECT_TRUE(result[0].output_variables[0].has_location_decoration);
EXPECT_EQ(0u, result[0].output_variables[0].location_decoration);
}
// TODO(rharrison): Reenable once GetRemappedNameForEntryPoint isn't a pass
// through
TEST_F(InspectorGetRemappedNameForEntryPointTest, DISABLED_NoFunctions) {