tint/inspector: Reflect whether @builtin(frag_depth) is used.

This will be used by Dawn between other factors to decide whether to use
the ClampFragDepth transform.

Bug: dawn:1125
Change-Id: I53be846d9c3ebb9b2d424f40fc87db89c843c81b
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/105220
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
This commit is contained in:
Corentin Wallez 2022-10-11 09:52:59 +00:00 committed by Dawn LUCI CQ
parent a707ffb300
commit 8d3d4f6fd1
3 changed files with 48 additions and 0 deletions

View File

@ -175,6 +175,8 @@ struct EntryPoint {
bool sample_index_used = false;
/// Does the entry point use the num_workgroups builtin
bool num_workgroups_used = false;
/// Does the entry point use the frag_depth builtin
bool frag_depth_used = false;
};
} // namespace tint::inspector

View File

@ -192,6 +192,8 @@ EntryPoint Inspector::GetEntryPoint(const tint::ast::Function* func) {
entry_point.output_sample_mask_used = ContainsBuiltin(
ast::BuiltinValue::kSampleMask, sem->ReturnType(), func->return_type_attributes);
entry_point.frag_depth_used = ContainsBuiltin(
ast::BuiltinValue::kFragDepth, sem->ReturnType(), func->return_type_attributes);
}
for (auto* var : sem->TransitivelyReferencedGlobals()) {

View File

@ -852,6 +852,7 @@ TEST_F(InspectorGetEntryPointTest, BuiltinNotReferenced) {
EXPECT_FALSE(result[0].front_facing_used);
EXPECT_FALSE(result[0].sample_index_used);
EXPECT_FALSE(result[0].num_workgroups_used);
EXPECT_FALSE(result[0].frag_depth_used);
}
TEST_F(InspectorGetEntryPointTest, InputSampleMaskSimpleReferenced) {
@ -1134,6 +1135,49 @@ TEST_F(InspectorGetEntryPointTest, NumWorkgroupsStructReferenced) {
EXPECT_TRUE(result[0].num_workgroups_used);
}
TEST_F(InspectorGetEntryPointTest, FragDepthSimpleReferenced) {
Func("ep_func", {}, ty.f32(),
utils::Vector{
Return(Expr(0_f)),
},
utils::Vector{
Stage(ast::PipelineStage::kFragment),
},
utils::Vector{
Builtin(ast::BuiltinValue::kFragDepth),
});
Inspector& inspector = Build();
auto result = inspector.GetEntryPoints();
ASSERT_EQ(1u, result.size());
EXPECT_TRUE(result[0].frag_depth_used);
}
TEST_F(InspectorGetEntryPointTest, FragDepthStructReferenced) {
Structure("out_struct", utils::Vector{
Member("inner_frag_depth", ty.f32(),
utils::Vector{Builtin(ast::BuiltinValue::kFragDepth)}),
});
Func("ep_func", utils::Empty, ty.type_name("out_struct"),
utils::Vector{
Decl(Var("out_var", ty.type_name("out_struct"))),
Return("out_var"),
},
utils::Vector{
Stage(ast::PipelineStage::kFragment),
});
Inspector& inspector = Build();
auto result = inspector.GetEntryPoints();
ASSERT_EQ(1u, result.size());
EXPECT_TRUE(result[0].frag_depth_used);
}
TEST_F(InspectorGetEntryPointTest, ImplicitInterpolate) {
Structure("in_struct", utils::Vector{
Member("struct_inner", ty.f32(), utils::Vector{Location(0_a)}),