From 564000fdd3a5c525d272ecd21f9953e054a04fdd Mon Sep 17 00:00:00 2001 From: James Price Date: Thu, 27 May 2021 17:03:27 +0000 Subject: [PATCH] Remove deprecated functionality The following deprecated features are no longer supported: - frag_coord builtin - sample_mask_in and sample_mask_out builtins - void keyword - const keyword Fixed: tint:677 Fixed: tint:699 Fixed: tint:714 Fixed: tint:715 Change-Id: I40ce9711310e70e62465f58f2a7f4d959039e307 Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/52041 Kokoro: Kokoro Commit-Queue: James Price Reviewed-by: Ben Clayton --- src/CMakeLists.txt | 1 - src/ast/builtin.cc | 12 ---- src/ast/builtin.h | 3 - src/reader/wgsl/lexer.cc | 8 +-- src/reader/wgsl/lexer_test.cc | 6 +- src/reader/wgsl/parser_impl.cc | 64 ++--------------- src/reader/wgsl/parser_impl.h | 3 - src/reader/wgsl/parser_impl_error_msg_test.cc | 6 +- .../wgsl/parser_impl_function_header_test.cc | 13 ---- .../parser_impl_function_type_decl_test.cc | 59 --------------- .../parser_impl_global_constant_decl_test.cc | 17 ----- .../parser_impl_variable_decoration_test.cc | 71 +------------------ .../wgsl/parser_impl_variable_stmt_test.cc | 13 ---- src/reader/wgsl/token.cc | 4 -- src/reader/wgsl/token.h | 8 --- src/transform/spirv.cc | 4 +- src/writer/hlsl/generator_impl.cc | 6 -- src/writer/hlsl/generator_impl_test.cc | 5 +- src/writer/msl/generator_impl.cc | 6 -- src/writer/msl/generator_impl_test.cc | 6 +- src/writer/spirv/builder.cc | 6 -- .../spirv/builder_global_variable_test.cc | 6 -- src/writer/wgsl/generator_impl_test.cc | 5 +- test/BUILD.gn | 1 - 24 files changed, 22 insertions(+), 311 deletions(-) delete mode 100644 src/reader/wgsl/parser_impl_function_type_decl_test.cc diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index bdf7995240..bed580761b 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -679,7 +679,6 @@ if(${TINT_BUILD_TESTS}) reader/wgsl/parser_impl_function_decoration_list_test.cc reader/wgsl/parser_impl_function_decoration_test.cc reader/wgsl/parser_impl_function_header_test.cc - reader/wgsl/parser_impl_function_type_decl_test.cc reader/wgsl/parser_impl_global_constant_decl_test.cc reader/wgsl/parser_impl_global_decl_test.cc reader/wgsl/parser_impl_global_variable_decl_test.cc diff --git a/src/ast/builtin.cc b/src/ast/builtin.cc index bdfaf887c7..3e49d14993 100644 --- a/src/ast/builtin.cc +++ b/src/ast/builtin.cc @@ -39,10 +39,6 @@ std::ostream& operator<<(std::ostream& out, Builtin builtin) { out << "front_facing"; break; } - case Builtin::kFragCoord: { - out << "frag_coord"; - break; - } case Builtin::kFragDepth: { out << "frag_depth"; break; @@ -71,14 +67,6 @@ std::ostream& operator<<(std::ostream& out, Builtin builtin) { out << "sample_mask"; break; } - case Builtin::kSampleMaskIn: { - out << "sample_mask_in"; - break; - } - case Builtin::kSampleMaskOut: { - out << "sample_mask_out"; - break; - } case Builtin::kPointSize: { out << "pointsize"; } diff --git a/src/ast/builtin.h b/src/ast/builtin.h index 5b37aeb55b..e5092c886d 100644 --- a/src/ast/builtin.h +++ b/src/ast/builtin.h @@ -27,7 +27,6 @@ enum class Builtin { kVertexIndex, kInstanceIndex, kFrontFacing, - kFragCoord, // TODO(crbug.com/tint/714): Remove this kFragDepth, kLocalInvocationId, kLocalInvocationIndex, @@ -35,8 +34,6 @@ enum class Builtin { kWorkgroupId, kSampleIndex, kSampleMask, - kSampleMaskIn, // TODO(crbug.com/tint/715): Remove this - kSampleMaskOut, // TODO(crbug.com/tint/715): Remove this // Below are not currently WGSL builtins, but are included in this enum as // they are used by certain backends. diff --git a/src/reader/wgsl/lexer.cc b/src/reader/wgsl/lexer.cc index bfc34c0ff7..be7b2bc996 100644 --- a/src/reader/wgsl/lexer.cc +++ b/src/reader/wgsl/lexer.cc @@ -478,8 +478,6 @@ Token Lexer::check_keyword(const Source& source, const std::string& str) { return {Token::Type::kBreak, source, "break"}; if (str == "case") return {Token::Type::kCase, source, "case"}; - if (str == "const") - return {Token::Type::kConst, source, "const"}; if (str == "continue") return {Token::Type::kContinue, source, "continue"}; if (str == "continuing") @@ -686,8 +684,6 @@ Token Lexer::check_keyword(const Source& source, const std::string& str) { return {Token::Type::kVec3, source, "vec3"}; if (str == "vec4") return {Token::Type::kVec4, source, "vec4"}; - if (str == "void") - return {Token::Type::kVoid, source, "void"}; if (str == "workgroup") return {Token::Type::kWorkgroup, source, "workgroup"}; return {}; @@ -698,6 +694,8 @@ Token Lexer::check_reserved(const Source& source, const std::string& str) { return {Token::Type::kReservedKeyword, source, "asm"}; if (str == "bf16") return {Token::Type::kReservedKeyword, source, "bf16"}; + if (str == "const") + return {Token::Type::kReservedKeyword, source, "const"}; if (str == "do") return {Token::Type::kReservedKeyword, source, "do"}; if (str == "enum") @@ -728,6 +726,8 @@ Token Lexer::check_reserved(const Source& source, const std::string& str) { return {Token::Type::kReservedKeyword, source, "u64"}; if (str == "unless") return {Token::Type::kReservedKeyword, source, "unless"}; + if (str == "void") + return {Token::Type::kReservedKeyword, source, "void"}; return {}; } diff --git a/src/reader/wgsl/lexer_test.cc b/src/reader/wgsl/lexer_test.cc index bb2ba86dae..30348706e9 100644 --- a/src/reader/wgsl/lexer_test.cc +++ b/src/reader/wgsl/lexer_test.cc @@ -423,7 +423,6 @@ INSTANTIATE_TEST_SUITE_P( TokenData{"bool", Token::Type::kBool}, TokenData{"break", Token::Type::kBreak}, TokenData{"case", Token::Type::kCase}, - TokenData{"const", Token::Type::kConst}, TokenData{"continue", Token::Type::kContinue}, TokenData{"continuing", Token::Type::kContinuing}, TokenData{"default", Token::Type::kDefault}, @@ -523,7 +522,6 @@ INSTANTIATE_TEST_SUITE_P( TokenData{"vec2", Token::Type::kVec2}, TokenData{"vec3", Token::Type::kVec3}, TokenData{"vec4", Token::Type::kVec4}, - TokenData{"void", Token::Type::kVoid}, TokenData{"workgroup", Token::Type::kWorkgroup})); using KeywordTest_Reserved = testing::TestWithParam; @@ -540,6 +538,7 @@ INSTANTIATE_TEST_SUITE_P(LexerTest, KeywordTest_Reserved, testing::Values("asm", "bf16", + "const", "do", "enum", "f16", @@ -554,7 +553,8 @@ INSTANTIATE_TEST_SUITE_P(LexerTest, "u16", "u64", "unless", - "regardless")); + "regardless", + "void")); } // namespace } // namespace wgsl diff --git a/src/reader/wgsl/parser_impl.cc b/src/reader/wgsl/parser_impl.cc index 8c91da6d8c..ca63df2a7f 100644 --- a/src/reader/wgsl/parser_impl.cc +++ b/src/reader/wgsl/parser_impl.cc @@ -83,9 +83,6 @@ ast::Builtin ident_to_builtin(const std::string& str) { if (str == "front_facing") { return ast::Builtin::kFrontFacing; } - if (str == "frag_coord") { - return ast::Builtin::kFragCoord; - } if (str == "frag_depth") { return ast::Builtin::kFragDepth; } @@ -107,12 +104,6 @@ ast::Builtin ident_to_builtin(const std::string& str) { if (str == "sample_mask") { return ast::Builtin::kSampleMask; } - if (str == "sample_mask_in") { - return ast::Builtin::kSampleMaskIn; - } - if (str == "sample_mask_out") { - return ast::Builtin::kSampleMaskOut; - } return ast::Builtin::kNone; } @@ -500,13 +491,7 @@ Maybe ParserImpl::global_variable_decl( Maybe ParserImpl::global_constant_decl( ast::DecorationList& decos) { if (!match(Token::Type::kLet)) { - Source source; - if (match(Token::Type::kConst, &source)) { - // crbug.com/tint/699: 'const' renamed to 'let' - deprecated(source, "use 'let' instead of 'const'"); - } else { - return Failure::kNoMatch; - } + return Failure::kNoMatch; } const char* use = "let declaration"; @@ -1327,19 +1312,11 @@ Maybe ParserImpl::function_decl(ast::DecorationList& decos) { header->return_type, body.value, decos, header->return_type_decorations); } -// function_type_decl -// : type_decl -// | VOID -Maybe ParserImpl::function_type_decl() { - Source source; - if (match(Token::Type::kVoid, &source)) - return builder_.ty.void_(source); - - return type_decl(); -} - // function_header -// : FN IDENT PAREN_LEFT param_list PAREN_RIGHT ARROW function_type_decl +// : FN IDENT PAREN_LEFT param_list PAREN_RIGHT return_type_decl_optional +// return_type_decl_optional +// : +// | ARROW attribute_list* type_decl Maybe ParserImpl::function_header() { Source source; if (!match(Token::Type::kFn, &source)) { @@ -1377,7 +1354,7 @@ Maybe ParserImpl::function_header() { auto tok = peek(); - auto type = function_type_decl(); + auto type = type_decl(); if (type.errored) { errored = true; } else if (!type.matched) { @@ -1385,13 +1362,6 @@ Maybe ParserImpl::function_header() { } else { return_type = type.value; } - - if (Is(return_type)) { - // crbug.com/tint/677: void has been removed from the language - deprecated(tok.source(), - "omit '-> void' for functions that do not return a value"); - } - } else { return_type = builder_.ty.void_(); } @@ -1489,16 +1459,6 @@ Expect ParserImpl::expect_builtin() { if (builtin == ast::Builtin::kNone) return add_error(ident.source, "invalid value for builtin decoration"); - if (builtin == ast::Builtin::kFragCoord) { - deprecated(ident.source, "use 'position' instead of 'frag_coord'"); - } - if (builtin == ast::Builtin::kSampleMaskIn) { - deprecated(ident.source, "use 'sample_mask' instead of 'sample_mask_in'"); - } - if (builtin == ast::Builtin::kSampleMaskOut) { - deprecated(ident.source, "use 'sample_mask' instead of 'sample_mask_out'"); - } - return {builtin, ident.source}; } @@ -1695,17 +1655,7 @@ Maybe ParserImpl::return_stmt() { // | variable_decl EQUAL logical_or_expression // | CONST variable_ident_decl EQUAL logical_or_expression Maybe ParserImpl::variable_stmt() { - bool is_const = match(Token::Type::kLet); - if (!is_const) { - Source source; - if (match(Token::Type::kConst, &source)) { - // crbug.com/tint/699: 'const' renamed to 'let' - deprecated(source, "use 'let' instead of 'const'"); - is_const = true; - } - } - - if (is_const) { + if (match(Token::Type::kLet)) { auto decl = expect_variable_ident_decl("let declaration"); if (decl.errored) return Failure::kErrored; diff --git a/src/reader/wgsl/parser_impl.h b/src/reader/wgsl/parser_impl.h index 261d2c919f..1fa4f31c08 100644 --- a/src/reader/wgsl/parser_impl.h +++ b/src/reader/wgsl/parser_impl.h @@ -458,9 +458,6 @@ class ParserImpl { /// @param use a description of what was being parsed if an error was raised /// @returns returns the image format or kNone if none matched. Expect expect_image_storage_type(const std::string& use); - /// Parses a `function_type_decl` grammar element - /// @returns the parsed type or nullptr otherwise - Maybe function_type_decl(); /// Parses a `function_header` grammar element /// @returns the parsed function header Maybe function_header(); diff --git a/src/reader/wgsl/parser_impl_error_msg_test.cc b/src/reader/wgsl/parser_impl_error_msg_test.cc index ba54f604a5..bfefc25f0b 100644 --- a/src/reader/wgsl/parser_impl_error_msg_test.cc +++ b/src/reader/wgsl/parser_impl_error_msg_test.cc @@ -367,10 +367,10 @@ TEST_F(ParserImplErrorTest, FunctionDeclMissingRParen) { } TEST_F(ParserImplErrorTest, FunctionDeclMissingArrow) { - EXPECT("fn f() void {}", + EXPECT("fn f() f32 {}", "test.wgsl:1:8 error: expected '{'\n" - "fn f() void {}\n" - " ^^^^\n"); + "fn f() f32 {}\n" + " ^^^\n"); } TEST_F(ParserImplErrorTest, FunctionDeclInvalidReturnType) { diff --git a/src/reader/wgsl/parser_impl_function_header_test.cc b/src/reader/wgsl/parser_impl_function_header_test.cc index 52071a32d5..193950ca1a 100644 --- a/src/reader/wgsl/parser_impl_function_header_test.cc +++ b/src/reader/wgsl/parser_impl_function_header_test.cc @@ -124,19 +124,6 @@ TEST_F(ParserImplTest, FunctionHeader_MissingReturnType) { EXPECT_EQ(p->error(), "1:13: unable to determine function return type"); } -TEST_F(ParserImplTest, FunctionHeader_ArrowVoid) { - auto p = parser("fn main() -> void"); - auto f = p->function_header(); - EXPECT_TRUE(f.matched); - EXPECT_FALSE(f.errored); - EXPECT_EQ( - p->builder().Diagnostics().str(), - R"(test.wgsl:1:14 warning: use of deprecated language feature: omit '-> void' for functions that do not return a value -fn main() -> void - ^^^^ -)"); -} - } // namespace } // namespace wgsl } // namespace reader diff --git a/src/reader/wgsl/parser_impl_function_type_decl_test.cc b/src/reader/wgsl/parser_impl_function_type_decl_test.cc deleted file mode 100644 index c9865ab2fe..0000000000 --- a/src/reader/wgsl/parser_impl_function_type_decl_test.cc +++ /dev/null @@ -1,59 +0,0 @@ -// Copyright 2020 The Tint Authors. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#include "src/reader/wgsl/parser_impl_test_helper.h" - -namespace tint { -namespace reader { -namespace wgsl { -namespace { - -TEST_F(ParserImplTest, FunctionTypeDecl_Void) { - auto p = parser("void"); - - auto e = p->function_type_decl(); - EXPECT_TRUE(e.matched); - EXPECT_FALSE(e.errored); - EXPECT_FALSE(p->has_error()) << p->error(); - EXPECT_TRUE(e.value->Is()); - EXPECT_EQ(e.value->source().range, (Source::Range{{1u, 1u}, {1u, 5u}})); -} - -TEST_F(ParserImplTest, FunctionTypeDecl_Type) { - auto p = parser("vec2"); - - auto e = p->function_type_decl(); - EXPECT_TRUE(e.matched); - EXPECT_FALSE(e.errored); - EXPECT_FALSE(p->has_error()) << p->error(); - ASSERT_TRUE(e.value->Is()); - EXPECT_EQ(e.value->As()->size(), 2u); - EXPECT_TRUE(e.value->As()->type()->Is()); - EXPECT_EQ(e.value->source().range, (Source::Range{{1u, 1u}, {1u, 10u}})); -} - -TEST_F(ParserImplTest, FunctionTypeDecl_InvalidType) { - auto p = parser("vec2"); - auto e = p->function_type_decl(); - EXPECT_FALSE(e.matched); - EXPECT_TRUE(e.errored); - EXPECT_TRUE(p->has_error()); - EXPECT_EQ(e.value, nullptr); - EXPECT_EQ(p->error(), "1:6: unknown constructed type 'invalid'"); -} - -} // namespace -} // namespace wgsl -} // namespace reader -} // namespace tint diff --git a/src/reader/wgsl/parser_impl_global_constant_decl_test.cc b/src/reader/wgsl/parser_impl_global_constant_decl_test.cc index f8fd1d58b1..992883eb57 100644 --- a/src/reader/wgsl/parser_impl_global_constant_decl_test.cc +++ b/src/reader/wgsl/parser_impl_global_constant_decl_test.cc @@ -181,23 +181,6 @@ TEST_F(ParserImplTest, GlobalConstantDec_Override_InvalidId) { EXPECT_EQ(p->error(), "1:12: override decoration must be positive"); } -TEST_F(ParserImplTest, GlobalConstantDec_Const) { - auto p = parser("const a : i32 = 1"); - auto decos = p->decoration_list(); - EXPECT_FALSE(decos.errored); - EXPECT_FALSE(decos.matched); - - auto e = p->global_constant_decl(decos.value); - EXPECT_TRUE(e.matched); - EXPECT_FALSE(e.errored); - EXPECT_EQ( - p->builder().Diagnostics().str(), - R"(test.wgsl:1:1 warning: use of deprecated language feature: use 'let' instead of 'const' -const a : i32 = 1 -^^^^^ -)"); -} - } // namespace } // namespace wgsl } // namespace reader diff --git a/src/reader/wgsl/parser_impl_variable_decoration_test.cc b/src/reader/wgsl/parser_impl_variable_decoration_test.cc index c324483a2b..33b1d107b4 100644 --- a/src/reader/wgsl/parser_impl_variable_decoration_test.cc +++ b/src/reader/wgsl/parser_impl_variable_decoration_test.cc @@ -113,7 +113,6 @@ INSTANTIATE_TEST_SUITE_P( 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", @@ -123,9 +122,7 @@ INSTANTIATE_TEST_SUITE_P( BuiltinData{"global_invocation_id", ast::Builtin::kGlobalInvocationId}, BuiltinData{"workgroup_id", ast::Builtin::kWorkgroupId}, BuiltinData{"sample_index", ast::Builtin::kSampleIndex}, - BuiltinData{"sample_mask", ast::Builtin::kSampleMask}, - BuiltinData{"sample_mask_in", ast::Builtin::kSampleMaskIn}, - BuiltinData{"sample_mask_out", ast::Builtin::kSampleMaskOut})); + BuiltinData{"sample_mask", ast::Builtin::kSampleMask})); TEST_F(ParserImplTest, Decoration_Builtin_MissingLeftParen) { auto p = parser("builtin position)"); @@ -307,72 +304,6 @@ TEST_F(ParserImplTest, Decoration_Group_MissingInvalid) { "1:7: expected signed integer literal for group decoration"); } -TEST_F(ParserImplTest, Decoration_FragCoord_Deprecated) { - auto p = parser("builtin(frag_coord)"); - auto deco = p->decoration(); - EXPECT_TRUE(deco.matched); - EXPECT_FALSE(deco.errored); - ASSERT_NE(deco.value, nullptr); - auto* var_deco = deco.value->As(); - ASSERT_NE(var_deco, nullptr); - ASSERT_FALSE(p->has_error()); - ASSERT_TRUE(var_deco->Is()); - - auto* builtin = var_deco->As(); - EXPECT_EQ(builtin->value(), ast::Builtin::kFragCoord); - - EXPECT_EQ( - p->builder().Diagnostics().str(), - R"(test.wgsl:1:9 warning: use of deprecated language feature: use 'position' instead of 'frag_coord' -builtin(frag_coord) - ^^^^^^^^^^ -)"); -} - -TEST_F(ParserImplTest, Decoration_SampleMaskIn_Deprecated) { - auto p = parser("builtin(sample_mask_in)"); - auto deco = p->decoration(); - EXPECT_TRUE(deco.matched); - EXPECT_FALSE(deco.errored); - ASSERT_NE(deco.value, nullptr); - auto* var_deco = deco.value->As(); - ASSERT_NE(var_deco, nullptr); - ASSERT_FALSE(p->has_error()); - ASSERT_TRUE(var_deco->Is()); - - auto* builtin = var_deco->As(); - EXPECT_EQ(builtin->value(), ast::Builtin::kSampleMaskIn); - - EXPECT_EQ( - p->builder().Diagnostics().str(), - R"(test.wgsl:1:9 warning: use of deprecated language feature: use 'sample_mask' instead of 'sample_mask_in' -builtin(sample_mask_in) - ^^^^^^^^^^^^^^ -)"); -} - -TEST_F(ParserImplTest, Decoration_SampleMaskOut_Deprecated) { - auto p = parser("builtin(sample_mask_out)"); - auto deco = p->decoration(); - EXPECT_TRUE(deco.matched); - EXPECT_FALSE(deco.errored); - ASSERT_NE(deco.value, nullptr); - auto* var_deco = deco.value->As(); - ASSERT_NE(var_deco, nullptr); - ASSERT_FALSE(p->has_error()); - ASSERT_TRUE(var_deco->Is()); - - auto* builtin = var_deco->As(); - EXPECT_EQ(builtin->value(), ast::Builtin::kSampleMaskOut); - - EXPECT_EQ( - p->builder().Diagnostics().str(), - R"(test.wgsl:1:9 warning: use of deprecated language feature: use 'sample_mask' instead of 'sample_mask_out' -builtin(sample_mask_out) - ^^^^^^^^^^^^^^^ -)"); -} - } // namespace } // namespace wgsl } // namespace reader diff --git a/src/reader/wgsl/parser_impl_variable_stmt_test.cc b/src/reader/wgsl/parser_impl_variable_stmt_test.cc index bfbf6e8309..624b78fef1 100644 --- a/src/reader/wgsl/parser_impl_variable_stmt_test.cc +++ b/src/reader/wgsl/parser_impl_variable_stmt_test.cc @@ -193,19 +193,6 @@ TEST_F(ParserImplTest, VariableStmt_Let_InvalidConstructor) { EXPECT_EQ(p->error(), "1:15: missing constructor for let declaration"); } -TEST_F(ParserImplTest, VariableStmt_Const) { - auto p = parser("const a : i32 = 1"); - auto e = p->variable_stmt(); - EXPECT_TRUE(e.matched); - EXPECT_FALSE(e.errored); - EXPECT_EQ( - p->builder().Diagnostics().str(), - R"(test.wgsl:1:1 warning: use of deprecated language feature: use 'let' instead of 'const' -const a : i32 = 1 -^^^^^ -)"); -} - } // namespace } // namespace wgsl } // namespace reader diff --git a/src/reader/wgsl/token.cc b/src/reader/wgsl/token.cc index f131cd904d..224dae0fe5 100644 --- a/src/reader/wgsl/token.cc +++ b/src/reader/wgsl/token.cc @@ -115,8 +115,6 @@ std::string Token::TypeToName(Type type) { return "break"; case Token::Type::kCase: return "case"; - case Token::Type::kConst: - return "const"; case Token::Type::kContinue: return "continue"; case Token::Type::kContinuing: @@ -309,8 +307,6 @@ std::string Token::TypeToName(Type type) { return "vec3"; case Token::Type::kVec4: return "vec4"; - case Token::Type::kVoid: - return "void"; case Token::Type::kWorkgroup: return "workgroup"; } diff --git a/src/reader/wgsl/token.h b/src/reader/wgsl/token.h index 10c6b0ea65..04b66da874 100644 --- a/src/reader/wgsl/token.h +++ b/src/reader/wgsl/token.h @@ -123,8 +123,6 @@ class Token { kBreak, /// A 'case' kCase, - /// A 'const' - kConst, /// A 'continue' kContinue, /// A 'continuing' @@ -317,8 +315,6 @@ class Token { kVec3, /// A 'vec4' kVec4, - /// A 'void' - kVoid, /// A 'workgroup' kWorkgroup, }; @@ -464,8 +460,6 @@ class Token { bool IsCase() const { return type_ == Type::kCase; } /// @returns true if token is a 'sampler_comparison' bool IsComparisonSampler() const { return type_ == Type::kComparisonSampler; } - /// @returns true if token is a 'const' - bool IsConst() const { return type_ == Type::kConst; } /// @returns true if token is a 'continue' bool IsContinue() const { return type_ == Type::kContinue; } /// @returns true if token is a 'continuing' @@ -676,8 +670,6 @@ class Token { bool IsVec3() const { return type_ == Type::kVec3; } /// @returns true if token is a 'vec4' bool IsVec4() const { return type_ == Type::kVec4; } - /// @returns true if token is a 'void' - bool IsVoid() const { return type_ == Type::kVoid; } /// @returns true if token is a 'workgroup' bool IsWorkgroup() const { return type_ == Type::kWorkgroup; } diff --git a/src/transform/spirv.cc b/src/transform/spirv.cc index ffb8da8c86..459b1f5b35 100644 --- a/src/transform/spirv.cc +++ b/src/transform/spirv.cc @@ -230,9 +230,7 @@ void Spirv::HandleSampleMaskBuiltins(CloneContext& ctx) const { for (auto* var : ctx.src->AST().GlobalVariables()) { for (auto* deco : var->decorations()) { if (auto* builtin = deco->As()) { - if (builtin->value() != ast::Builtin::kSampleMask && - builtin->value() != ast::Builtin::kSampleMaskIn && - builtin->value() != ast::Builtin::kSampleMaskOut) { + if (builtin->value() != ast::Builtin::kSampleMask) { continue; } diff --git a/src/writer/hlsl/generator_impl.cc b/src/writer/hlsl/generator_impl.cc index 1c2d3f05d5..86796013f2 100644 --- a/src/writer/hlsl/generator_impl.cc +++ b/src/writer/hlsl/generator_impl.cc @@ -1957,8 +1957,6 @@ std::string GeneratorImpl::builtin_to_attribute(ast::Builtin builtin) const { return "SV_InstanceID"; case ast::Builtin::kFrontFacing: return "SV_IsFrontFace"; - case ast::Builtin::kFragCoord: - return "SV_Position"; case ast::Builtin::kFragDepth: return "SV_Depth"; case ast::Builtin::kLocalInvocationId: @@ -1973,10 +1971,6 @@ std::string GeneratorImpl::builtin_to_attribute(ast::Builtin builtin) const { return "SV_SampleIndex"; case ast::Builtin::kSampleMask: return "SV_Coverage"; - case ast::Builtin::kSampleMaskIn: - return "SV_Coverage"; - case ast::Builtin::kSampleMaskOut: - return "SV_Coverage"; default: break; } diff --git a/src/writer/hlsl/generator_impl_test.cc b/src/writer/hlsl/generator_impl_test.cc index b04d496773..4fc4e32067 100644 --- a/src/writer/hlsl/generator_impl_test.cc +++ b/src/writer/hlsl/generator_impl_test.cc @@ -76,7 +76,6 @@ INSTANTIATE_TEST_SUITE_P( HlslBuiltinData{ast::Builtin::kVertexIndex, "SV_VertexID"}, HlslBuiltinData{ast::Builtin::kInstanceIndex, "SV_InstanceID"}, HlslBuiltinData{ast::Builtin::kFrontFacing, "SV_IsFrontFace"}, - HlslBuiltinData{ast::Builtin::kFragCoord, "SV_Position"}, HlslBuiltinData{ast::Builtin::kFragDepth, "SV_Depth"}, HlslBuiltinData{ast::Builtin::kLocalInvocationId, "SV_GroupThreadID"}, HlslBuiltinData{ast::Builtin::kLocalInvocationIndex, "SV_GroupIndex"}, @@ -84,9 +83,7 @@ INSTANTIATE_TEST_SUITE_P( "SV_DispatchThreadID"}, HlslBuiltinData{ast::Builtin::kWorkgroupId, "SV_GroupID"}, HlslBuiltinData{ast::Builtin::kSampleIndex, "SV_SampleIndex"}, - HlslBuiltinData{ast::Builtin::kSampleMask, "SV_Coverage"}, - HlslBuiltinData{ast::Builtin::kSampleMaskIn, "SV_Coverage"}, - HlslBuiltinData{ast::Builtin::kSampleMaskOut, "SV_Coverage"})); + HlslBuiltinData{ast::Builtin::kSampleMask, "SV_Coverage"})); } // namespace } // namespace hlsl diff --git a/src/writer/msl/generator_impl.cc b/src/writer/msl/generator_impl.cc index fd76e6ea66..132964e86a 100644 --- a/src/writer/msl/generator_impl.cc +++ b/src/writer/msl/generator_impl.cc @@ -1341,8 +1341,6 @@ std::string GeneratorImpl::builtin_to_attribute(ast::Builtin builtin) const { return "instance_id"; case ast::Builtin::kFrontFacing: return "front_facing"; - case ast::Builtin::kFragCoord: - return "position"; case ast::Builtin::kFragDepth: return "depth(any)"; case ast::Builtin::kLocalInvocationId: @@ -1357,10 +1355,6 @@ std::string GeneratorImpl::builtin_to_attribute(ast::Builtin builtin) const { return "sample_id"; case ast::Builtin::kSampleMask: return "sample_mask"; - case ast::Builtin::kSampleMaskIn: - return "sample_mask"; - case ast::Builtin::kSampleMaskOut: - return "sample_mask"; default: break; } diff --git a/src/writer/msl/generator_impl_test.cc b/src/writer/msl/generator_impl_test.cc index f1f12cfb48..4cb99f83b1 100644 --- a/src/writer/msl/generator_impl_test.cc +++ b/src/writer/msl/generator_impl_test.cc @@ -65,7 +65,6 @@ INSTANTIATE_TEST_SUITE_P( MslBuiltinData{ast::Builtin::kVertexIndex, "vertex_id"}, MslBuiltinData{ast::Builtin::kInstanceIndex, "instance_id"}, MslBuiltinData{ast::Builtin::kFrontFacing, "front_facing"}, - MslBuiltinData{ast::Builtin::kFragCoord, "position"}, MslBuiltinData{ast::Builtin::kFragDepth, "depth(any)"}, MslBuiltinData{ast::Builtin::kLocalInvocationId, "thread_position_in_threadgroup"}, @@ -76,10 +75,7 @@ INSTANTIATE_TEST_SUITE_P( MslBuiltinData{ast::Builtin::kWorkgroupId, "threadgroup_position_in_grid"}, MslBuiltinData{ast::Builtin::kSampleIndex, "sample_id"}, - MslBuiltinData{ast::Builtin::kSampleMask, "sample_mask"}, - MslBuiltinData{ast::Builtin::kSampleMaskIn, "sample_mask"}, - MslBuiltinData{ast::Builtin::kSampleMaskOut, - "sample_mask"})); + MslBuiltinData{ast::Builtin::kSampleMask, "sample_mask"})); } // namespace } // namespace msl diff --git a/src/writer/spirv/builder.cc b/src/writer/spirv/builder.cc index 7b51c944d8..41d9f1b5e5 100644 --- a/src/writer/spirv/builder.cc +++ b/src/writer/spirv/builder.cc @@ -3369,8 +3369,6 @@ SpvBuiltIn Builder::ConvertBuiltin(ast::Builtin builtin, return SpvBuiltInInstanceIndex; case ast::Builtin::kFrontFacing: return SpvBuiltInFrontFacing; - case ast::Builtin::kFragCoord: - return SpvBuiltInFragCoord; case ast::Builtin::kFragDepth: return SpvBuiltInFragDepth; case ast::Builtin::kLocalInvocationId: @@ -3388,10 +3386,6 @@ SpvBuiltIn Builder::ConvertBuiltin(ast::Builtin builtin, return SpvBuiltInSampleId; case ast::Builtin::kSampleMask: return SpvBuiltInSampleMask; - case ast::Builtin::kSampleMaskIn: - return SpvBuiltInSampleMask; - case ast::Builtin::kSampleMaskOut: - return SpvBuiltInSampleMask; case ast::Builtin::kNone: break; } diff --git a/src/writer/spirv/builder_global_variable_test.cc b/src/writer/spirv/builder_global_variable_test.cc index f084a403ea..38a5cc0d39 100644 --- a/src/writer/spirv/builder_global_variable_test.cc +++ b/src/writer/spirv/builder_global_variable_test.cc @@ -373,8 +373,6 @@ INSTANTIATE_TEST_SUITE_P( SpvBuiltInInstanceIndex}, BuiltinData{ast::Builtin::kFrontFacing, ast::StorageClass::kInput, SpvBuiltInFrontFacing}, - BuiltinData{ast::Builtin::kFragCoord, ast::StorageClass::kInput, - SpvBuiltInFragCoord}, BuiltinData{ast::Builtin::kFragDepth, ast::StorageClass::kOutput, SpvBuiltInFragDepth}, BuiltinData{ast::Builtin::kLocalInvocationId, ast::StorageClass::kInput, @@ -390,10 +388,6 @@ INSTANTIATE_TEST_SUITE_P( BuiltinData{ast::Builtin::kSampleMask, ast::StorageClass::kInput, SpvBuiltInSampleMask}, BuiltinData{ast::Builtin::kSampleMask, ast::StorageClass::kOutput, - SpvBuiltInSampleMask}, - BuiltinData{ast::Builtin::kSampleMaskIn, ast::StorageClass::kInput, - SpvBuiltInSampleMask}, - BuiltinData{ast::Builtin::kSampleMaskOut, ast::StorageClass::kOutput, SpvBuiltInSampleMask})); TEST_F(BuilderTest, GlobalVar_DeclReadOnly) { diff --git a/src/writer/wgsl/generator_impl_test.cc b/src/writer/wgsl/generator_impl_test.cc index f61f0c7f31..985bf51e1c 100644 --- a/src/writer/wgsl/generator_impl_test.cc +++ b/src/writer/wgsl/generator_impl_test.cc @@ -66,7 +66,6 @@ INSTANTIATE_TEST_SUITE_P( WgslBuiltinData{ast::Builtin::kVertexIndex, "vertex_index"}, WgslBuiltinData{ast::Builtin::kInstanceIndex, "instance_index"}, WgslBuiltinData{ast::Builtin::kFrontFacing, "front_facing"}, - WgslBuiltinData{ast::Builtin::kFragCoord, "frag_coord"}, WgslBuiltinData{ast::Builtin::kFragDepth, "frag_depth"}, WgslBuiltinData{ast::Builtin::kLocalInvocationId, "local_invocation_id"}, @@ -75,9 +74,7 @@ INSTANTIATE_TEST_SUITE_P( WgslBuiltinData{ast::Builtin::kGlobalInvocationId, "global_invocation_id"}, WgslBuiltinData{ast::Builtin::kWorkgroupId, "workgroup_id"}, - WgslBuiltinData{ast::Builtin::kSampleIndex, "sample_index"}, - WgslBuiltinData{ast::Builtin::kSampleMaskIn, "sample_mask_in"}, - WgslBuiltinData{ast::Builtin::kSampleMaskOut, "sample_mask_out"})); + WgslBuiltinData{ast::Builtin::kSampleIndex, "sample_index"})); } // namespace } // namespace wgsl diff --git a/test/BUILD.gn b/test/BUILD.gn index 679555f009..1ea5ae7810 100644 --- a/test/BUILD.gn +++ b/test/BUILD.gn @@ -439,7 +439,6 @@ tint_unittests_source_set("tint_unittests_wgsl_reader_src") { "../src/reader/wgsl/parser_impl_function_decoration_list_test.cc", "../src/reader/wgsl/parser_impl_function_decoration_test.cc", "../src/reader/wgsl/parser_impl_function_header_test.cc", - "../src/reader/wgsl/parser_impl_function_type_decl_test.cc", "../src/reader/wgsl/parser_impl_global_constant_decl_test.cc", "../src/reader/wgsl/parser_impl_global_decl_test.cc", "../src/reader/wgsl/parser_impl_global_variable_decl_test.cc",