From b16a5d6e9b0e0c357351320afdf9a5ba5f78494a Mon Sep 17 00:00:00 2001 From: Ryan Harrison Date: Mon, 25 Jan 2021 21:15:08 +0000 Subject: [PATCH] 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 Commit-Queue: dan sinclair Reviewed-by: dan sinclair Auto-Submit: Ryan Harrison --- src/inspector/inspector.cc | 5 +++++ src/inspector/inspector_test.cc | 37 +++++++++++++++++++++++++++++++++ 2 files changed, 42 insertions(+) diff --git a/src/inspector/inspector.cc b/src/inspector/inspector.cc index 5a3c9e8f95..ab60122e76 100644 --- a/src/inspector/inspector.cc +++ b/src/inspector/inspector.cc @@ -66,6 +66,10 @@ std::vector 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 Inspector::GetEntryPoints() { entry_point.output_variables.push_back(stage_variable); } } + result.push_back(std::move(entry_point)); } diff --git a/src/inspector/inspector_test.cc b/src/inspector/inspector_test.cc index b0792bbbea..9067461db9 100644 --- a/src/inspector/inspector_test.cc +++ b/src/inspector/inspector_test.cc @@ -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::Builtin::kPosition)})); + mod->AddGlobalVariable( + Var("out_var", ast::StorageClass::kOutput, ty.u32, nullptr, + ast::VariableDecorationList{create(0)})); + auto* func = + MakeInOutVariableBodyFunction("func", {{"in_var", "out_var"}}, {}); + mod->Functions().Add(func); + + auto* foo = MakeCallerBodyFunction( + "foo", "func", + ast::FunctionDecorationList{ + create(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) {