Inspector: Add input [[sample_mask]] to EntryPoint
This patch adds the missing input [[sample_mask]] to EntryPoint in the Inspector and the related unittests to inspector_test.cc. According to the latest WGSL SPEC [[sample_mask]] can be used as both fragment shader input and output. Bug: dawn:802, dawn:1032 Change-Id: I80640f26c7d771e35039fd7f3c941859729f26ce Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/61020 Kokoro: Kokoro <noreply+kokoro@google.com> Reviewed-by: Ryan Harrison <rharrison@chromium.org> Reviewed-by: Ben Clayton <bclayton@google.com> Commit-Queue: Jiawei Shao <jiawei.shao@intel.com>
This commit is contained in:
parent
608738d59b
commit
b612c50593
|
@ -122,8 +122,12 @@ struct EntryPoint {
|
|||
std::vector<StageVariable> output_variables;
|
||||
/// List of the pipeline overridable constants accessed via this entry point.
|
||||
std::vector<OverridableConstant> 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;
|
||||
|
|
|
@ -170,6 +170,9 @@ std::vector<EntryPoint> 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<sem::Void>()) {
|
||||
|
@ -177,7 +180,7 @@ std::vector<EntryPoint> 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());
|
||||
}
|
||||
|
|
|
@ -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) {
|
||||
|
|
Loading…
Reference in New Issue