diff --git a/src/inspector/entry_point.h b/src/inspector/entry_point.h index 167702d641..a97cc67cce 100644 --- a/src/inspector/entry_point.h +++ b/src/inspector/entry_point.h @@ -122,8 +122,12 @@ struct EntryPoint { std::vector output_variables; /// List of the pipeline overridable constants accessed via this entry point. std::vector overridable_constants; - /// Does the entry point use the sample_mask builtin - bool sample_mask_used = false; + /// Does the entry point use the sample_mask builtin as an input builtin + /// variable. + bool input_sample_mask_used = false; + /// Does the entry point use the sample_mask builtin as an output builtin + /// variable. + bool output_sample_mask_used = false; /// Does the entry point use the position builtin as an input builtin /// variable. bool input_position_used = false; diff --git a/src/inspector/inspector.cc b/src/inspector/inspector.cc index 91ef6211ff..dc057c6e29 100644 --- a/src/inspector/inspector.cc +++ b/src/inspector/inspector.cc @@ -170,6 +170,9 @@ std::vector Inspector::GetEntryPoints() { entry_point.sample_index_used |= ContainsBuiltin(ast::Builtin::kSampleIndex, param->Type(), param->Declaration()->decorations()); + entry_point.input_sample_mask_used |= + ContainsBuiltin(ast::Builtin::kSampleMask, param->Type(), + param->Declaration()->decorations()); } if (!sem->ReturnType()->Is()) { @@ -177,7 +180,7 @@ std::vector Inspector::GetEntryPoints() { func->return_type_decorations(), entry_point.output_variables); - entry_point.sample_mask_used = + entry_point.output_sample_mask_used = ContainsBuiltin(ast::Builtin::kSampleMask, sem->ReturnType(), func->return_type_decorations()); } diff --git a/src/inspector/inspector_test.cc b/src/inspector/inspector_test.cc index 6a8c946acc..488d928685 100644 --- a/src/inspector/inspector_test.cc +++ b/src/inspector/inspector_test.cc @@ -637,13 +637,46 @@ TEST_F(InspectorGetEntryPointTest, BuiltinNotReferenced) { auto result = inspector.GetEntryPoints(); ASSERT_EQ(1u, result.size()); - EXPECT_FALSE(result[0].sample_mask_used); + EXPECT_FALSE(result[0].input_sample_mask_used); + EXPECT_FALSE(result[0].output_sample_mask_used); EXPECT_FALSE(result[0].input_position_used); EXPECT_FALSE(result[0].front_facing_used); EXPECT_FALSE(result[0].sample_index_used); } -TEST_F(InspectorGetEntryPointTest, SampleMaskSimpleReferenced) { +TEST_F(InspectorGetEntryPointTest, InputSampleMaskSimpleReferenced) { + auto* in_var = + Param("in_var", ty.u32(), {Builtin(ast::Builtin::kSampleMask)}); + Func("ep_func", {in_var}, ty.void_(), {Return()}, + {Stage(ast::PipelineStage::kFragment)}, {}); + + Inspector& inspector = Build(); + + auto result = inspector.GetEntryPoints(); + + ASSERT_EQ(1u, result.size()); + EXPECT_TRUE(result[0].input_sample_mask_used); +} + +TEST_F(InspectorGetEntryPointTest, InputSampleMaskStructReferenced) { + ast::StructMemberList members; + members.push_back( + Member("inner_position", ty.u32(), {Builtin(ast::Builtin::kSampleMask)})); + Structure("in_struct", members, {}); + auto* in_var = Param("in_var", ty.type_name("in_struct"), {}); + + Func("ep_func", {in_var}, ty.void_(), {Return()}, + {Stage(ast::PipelineStage::kFragment)}, {}); + + Inspector& inspector = Build(); + + auto result = inspector.GetEntryPoints(); + + ASSERT_EQ(1u, result.size()); + EXPECT_TRUE(result[0].input_sample_mask_used); +} + +TEST_F(InspectorGetEntryPointTest, OutputSampleMaskSimpleReferenced) { auto* in_var = Param("in_var", ty.u32(), {Builtin(ast::Builtin::kSampleMask)}); Func("ep_func", {in_var}, ty.u32(), {Return("in_var")}, @@ -655,10 +688,10 @@ TEST_F(InspectorGetEntryPointTest, SampleMaskSimpleReferenced) { auto result = inspector.GetEntryPoints(); ASSERT_EQ(1u, result.size()); - EXPECT_TRUE(result[0].sample_mask_used); + EXPECT_TRUE(result[0].output_sample_mask_used); } -TEST_F(InspectorGetEntryPointTest, SampleMaskStructReferenced) { +TEST_F(InspectorGetEntryPointTest, OutputSampleMaskStructReferenced) { ast::StructMemberList members; members.push_back(Member("inner_sample_mask", ty.u32(), {Builtin(ast::Builtin::kSampleMask)})); @@ -673,7 +706,7 @@ TEST_F(InspectorGetEntryPointTest, SampleMaskStructReferenced) { auto result = inspector.GetEntryPoints(); ASSERT_EQ(1u, result.size()); - EXPECT_TRUE(result[0].sample_mask_used); + EXPECT_TRUE(result[0].output_sample_mask_used); } TEST_F(InspectorGetEntryPointTest, InputPositionSimpleReferenced) {