diff --git a/include/tint/tint.h b/include/tint/tint.h index c397cdcba8..42ceda48e8 100644 --- a/include/tint/tint.h +++ b/include/tint/tint.h @@ -18,7 +18,6 @@ // TODO(tint:88): When implementing support for an install target, all of these // headers will need to be moved to include/tint/. -#include "src/tint/ast/pipeline_stage.h" #include "src/tint/demangler.h" #include "src/tint/diagnostic/printer.h" #include "src/tint/inspector/inspector.h" diff --git a/src/dawn/native/ShaderModule.cpp b/src/dawn/native/ShaderModule.cpp index 19ac17166b..a9013cc107 100644 --- a/src/dawn/native/ShaderModule.cpp +++ b/src/dawn/native/ShaderModule.cpp @@ -118,16 +118,15 @@ tint::transform::VertexStepMode ToTintVertexStepMode(wgpu::VertexStepMode mode) UNREACHABLE(); } -ResultOrError TintPipelineStageToShaderStage(tint::ast::PipelineStage stage) { +ResultOrError TintPipelineStageToShaderStage( + tint::inspector::PipelineStage stage) { switch (stage) { - case tint::ast::PipelineStage::kVertex: + case tint::inspector::PipelineStage::kVertex: return SingleShaderStage::Vertex; - case tint::ast::PipelineStage::kFragment: + case tint::inspector::PipelineStage::kFragment: return SingleShaderStage::Fragment; - case tint::ast::PipelineStage::kCompute: + case tint::inspector::PipelineStage::kCompute: return SingleShaderStage::Compute; - case tint::ast::PipelineStage::kNone: - break; } UNREACHABLE(); } diff --git a/src/tint/inspector/entry_point.h b/src/tint/inspector/entry_point.h index b9ac4e429e..493a93fe40 100644 --- a/src/tint/inspector/entry_point.h +++ b/src/tint/inspector/entry_point.h @@ -120,6 +120,9 @@ struct OverridableConstant { bool is_numeric_id_specified = false; }; +/// The pipeline stage +enum class PipelineStage { kVertex, kFragment, kCompute }; + /// Reflection data for an entry point in the shader. struct EntryPoint { /// Constructors @@ -135,7 +138,7 @@ struct EntryPoint { /// Remapped entry point name in the backend std::string remapped_name; /// The entry point stage - ast::PipelineStage stage = ast::PipelineStage::kNone; + PipelineStage stage; /// The workgroup x size uint32_t workgroup_size_x = 0; /// The workgroup y size diff --git a/src/tint/inspector/inspector.cc b/src/tint/inspector/inspector.cc index c5b3eb797f..43554875be 100644 --- a/src/tint/inspector/inspector.cc +++ b/src/tint/inspector/inspector.cc @@ -145,7 +145,22 @@ std::vector Inspector::GetEntryPoints() { EntryPoint entry_point; entry_point.name = program_->Symbols().NameFor(func->symbol); entry_point.remapped_name = program_->Symbols().NameFor(func->symbol); - entry_point.stage = func->PipelineStage(); + + switch (func->PipelineStage()) { + case ast::PipelineStage::kCompute: + entry_point.stage = PipelineStage::kCompute; + break; + case ast::PipelineStage::kFragment: + entry_point.stage = PipelineStage::kFragment; + break; + case ast::PipelineStage::kVertex: + entry_point.stage = PipelineStage::kVertex; + break; + default: + TINT_UNREACHABLE(Inspector, diagnostics_) + << "invalid pipeline stage for entry point '" << entry_point.name << "'"; + break; + } auto wgsize = sem->WorkgroupSize(); entry_point.workgroup_size_x = wgsize[0].value; diff --git a/src/tint/inspector/inspector_test.cc b/src/tint/inspector/inspector_test.cc index 4e369d5e68..2681f78bbe 100644 --- a/src/tint/inspector/inspector_test.cc +++ b/src/tint/inspector/inspector_test.cc @@ -168,7 +168,7 @@ TEST_F(InspectorGetEntryPointTest, OneEntryPoint) { ASSERT_EQ(1u, result.size()); EXPECT_EQ("foo", result[0].name); EXPECT_EQ("foo", result[0].remapped_name); - EXPECT_EQ(ast::PipelineStage::kFragment, result[0].stage); + EXPECT_EQ(PipelineStage::kFragment, result[0].stage); } TEST_F(InspectorGetEntryPointTest, MultipleEntryPoints) { @@ -191,10 +191,10 @@ TEST_F(InspectorGetEntryPointTest, MultipleEntryPoints) { ASSERT_EQ(2u, result.size()); EXPECT_EQ("foo", result[0].name); EXPECT_EQ("foo", result[0].remapped_name); - EXPECT_EQ(ast::PipelineStage::kFragment, result[0].stage); + EXPECT_EQ(PipelineStage::kFragment, result[0].stage); EXPECT_EQ("bar", result[1].name); EXPECT_EQ("bar", result[1].remapped_name); - EXPECT_EQ(ast::PipelineStage::kCompute, result[1].stage); + EXPECT_EQ(PipelineStage::kCompute, result[1].stage); } TEST_F(InspectorGetEntryPointTest, MixFunctionsAndEntryPoints) { @@ -221,10 +221,10 @@ TEST_F(InspectorGetEntryPointTest, MixFunctionsAndEntryPoints) { ASSERT_EQ(2u, result.size()); EXPECT_EQ("foo", result[0].name); EXPECT_EQ("foo", result[0].remapped_name); - EXPECT_EQ(ast::PipelineStage::kCompute, result[0].stage); + EXPECT_EQ(PipelineStage::kCompute, result[0].stage); EXPECT_EQ("bar", result[1].name); EXPECT_EQ("bar", result[1].remapped_name); - EXPECT_EQ(ast::PipelineStage::kFragment, result[1].stage); + EXPECT_EQ(PipelineStage::kFragment, result[1].stage); } TEST_F(InspectorGetEntryPointTest, DefaultWorkgroupSize) {