[wgsl-reader] Add support for sample index/mask builtins

Bug: tint:372
Change-Id: I2cbadf31f350c49ae0689d8b05f3f7a92d074efd
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/40560
Commit-Queue: James Price <jrprice@google.com>
Auto-Submit: James Price <jrprice@google.com>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
Reviewed-by: David Neto <dneto@google.com>
This commit is contained in:
James Price 2021-02-16 21:37:01 +00:00 committed by Commit Bot service account
parent c9af597997
commit 1413733be8
2 changed files with 27 additions and 16 deletions

View File

@ -128,6 +128,15 @@ ast::Builtin ident_to_builtin(const std::string& str) {
if (str == "global_invocation_id") {
return ast::Builtin::kGlobalInvocationId;
}
if (str == "sample_index") {
return ast::Builtin::kSampleIndex;
}
if (str == "sample_mask_in") {
return ast::Builtin::kSampleMaskIn;
}
if (str == "sample_mask_out") {
return ast::Builtin::kSampleMaskOut;
}
return ast::Builtin::kNone;
}

View File

@ -112,22 +112,24 @@ TEST_P(BuiltinTest, VariableDecoration_Builtin) {
INSTANTIATE_TEST_SUITE_P(
ParserImplTest,
BuiltinTest,
testing::Values(BuiltinData{"position", ast::Builtin::kPosition},
BuiltinData{"vertex_idx", ast::Builtin::kVertexIndex},
BuiltinData{"vertex_index", ast::Builtin::kVertexIndex},
BuiltinData{"instance_idx", ast::Builtin::kInstanceIndex},
BuiltinData{"instance_index", ast::Builtin::kInstanceIndex},
BuiltinData{"front_facing", ast::Builtin::kFrontFacing},
BuiltinData{"frag_coord", ast::Builtin::kFragCoord},
BuiltinData{"frag_depth", ast::Builtin::kFragDepth},
BuiltinData{"local_invocation_id",
ast::Builtin::kLocalInvocationId},
BuiltinData{"local_invocation_idx",
ast::Builtin::kLocalInvocationIndex},
BuiltinData{"local_invocation_index",
ast::Builtin::kLocalInvocationIndex},
BuiltinData{"global_invocation_id",
ast::Builtin::kGlobalInvocationId}));
testing::Values(
BuiltinData{"position", ast::Builtin::kPosition},
BuiltinData{"vertex_idx", ast::Builtin::kVertexIndex},
BuiltinData{"vertex_index", ast::Builtin::kVertexIndex},
BuiltinData{"instance_idx", ast::Builtin::kInstanceIndex},
BuiltinData{"instance_index", ast::Builtin::kInstanceIndex},
BuiltinData{"front_facing", ast::Builtin::kFrontFacing},
BuiltinData{"frag_coord", ast::Builtin::kFragCoord},
BuiltinData{"frag_depth", ast::Builtin::kFragDepth},
BuiltinData{"local_invocation_id", ast::Builtin::kLocalInvocationId},
BuiltinData{"local_invocation_idx",
ast::Builtin::kLocalInvocationIndex},
BuiltinData{"local_invocation_index",
ast::Builtin::kLocalInvocationIndex},
BuiltinData{"global_invocation_id", ast::Builtin::kGlobalInvocationId},
BuiltinData{"sample_index", ast::Builtin::kSampleIndex},
BuiltinData{"sample_mask_in", ast::Builtin::kSampleMaskIn},
BuiltinData{"sample_mask_out", ast::Builtin::kSampleMaskOut}));
TEST_F(ParserImplTest, VariableDecoration_Builtin_MissingLeftParen) {
auto p = parser("builtin position)");