Ryan Harrison | dbc13af | 2022-02-21 15:19:07 +0000 | [diff] [blame] | 1 | // Copyright 2020 The Tint Authors. |
| 2 | // |
| 3 | // Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 | // you may not use this file except in compliance with the License. |
| 5 | // You may obtain a copy of the License at |
| 6 | // |
| 7 | // http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | // |
| 9 | // Unless required by applicable law or agreed to in writing, software |
| 10 | // distributed under the License is distributed on an "AS IS" BASIS, |
| 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 | // See the License for the specific language governing permissions and |
| 13 | // limitations under the License. |
| 14 | |
Ben Clayton | fe8e6ee | 2022-07-27 22:21:30 +0000 | [diff] [blame] | 15 | //////////////////////////////////////////////////////////////////////////////// |
| 16 | // File generated by tools/src/cmd/gen |
| 17 | // using the template: |
| 18 | // src/tint/ast/builtin_value.h.tmpl |
| 19 | // |
| 20 | // Do not modify this file directly |
| 21 | //////////////////////////////////////////////////////////////////////////////// |
| 22 | |
Ben Clayton | f330229 | 2022-07-27 18:48:06 +0000 | [diff] [blame] | 23 | #ifndef SRC_TINT_AST_BUILTIN_VALUE_H_ |
| 24 | #define SRC_TINT_AST_BUILTIN_VALUE_H_ |
Ryan Harrison | dbc13af | 2022-02-21 15:19:07 +0000 | [diff] [blame] | 25 | |
| 26 | #include <ostream> |
| 27 | |
dan sinclair | 34323ac | 2022-04-07 18:39:35 +0000 | [diff] [blame] | 28 | namespace tint::ast { |
Ryan Harrison | dbc13af | 2022-02-21 15:19:07 +0000 | [diff] [blame] | 29 | |
Ben Clayton | f9ed9d3 | 2022-10-11 19:49:17 +0000 | [diff] [blame] | 30 | /// Builtin value defined with `@builtin(<name>)`. |
Ben Clayton | f330229 | 2022-07-27 18:48:06 +0000 | [diff] [blame] | 31 | enum class BuiltinValue { |
Ben Clayton | d2e0db3 | 2022-10-12 18:49:15 +0000 | [diff] [blame] | 32 | kUndefined, |
dan sinclair | 41e4d9a | 2022-05-01 14:40:55 +0000 | [diff] [blame] | 33 | kFragDepth, |
Ben Clayton | db368f1 | 2022-10-11 18:26:18 +0000 | [diff] [blame] | 34 | kFrontFacing, |
| 35 | kGlobalInvocationId, |
| 36 | kInstanceIndex, |
dan sinclair | 41e4d9a | 2022-05-01 14:40:55 +0000 | [diff] [blame] | 37 | kLocalInvocationId, |
| 38 | kLocalInvocationIndex, |
dan sinclair | 41e4d9a | 2022-05-01 14:40:55 +0000 | [diff] [blame] | 39 | kNumWorkgroups, |
Ben Clayton | db368f1 | 2022-10-11 18:26:18 +0000 | [diff] [blame] | 40 | kPointSize, // Tint-internal enum entry - not parsed |
| 41 | kPosition, |
dan sinclair | 41e4d9a | 2022-05-01 14:40:55 +0000 | [diff] [blame] | 42 | kSampleIndex, |
| 43 | kSampleMask, |
Ben Clayton | db368f1 | 2022-10-11 18:26:18 +0000 | [diff] [blame] | 44 | kVertexIndex, |
| 45 | kWorkgroupId, |
Ryan Harrison | dbc13af | 2022-02-21 15:19:07 +0000 | [diff] [blame] | 46 | }; |
| 47 | |
| 48 | /// @param out the std::ostream to write to |
Ben Clayton | fe8e6ee | 2022-07-27 22:21:30 +0000 | [diff] [blame] | 49 | /// @param value the BuiltinValue |
| 50 | /// @returns `out` so calls can be chained |
| 51 | std::ostream& operator<<(std::ostream& out, BuiltinValue value); |
| 52 | |
| 53 | /// ParseBuiltinValue parses a BuiltinValue from a string. |
| 54 | /// @param str the string to parse |
Ben Clayton | d2e0db3 | 2022-10-12 18:49:15 +0000 | [diff] [blame] | 55 | /// @returns the parsed enum, or BuiltinValue::kUndefined if the string could not be parsed. |
Ben Clayton | fe8e6ee | 2022-07-27 22:21:30 +0000 | [diff] [blame] | 56 | BuiltinValue ParseBuiltinValue(std::string_view str); |
Ryan Harrison | dbc13af | 2022-02-21 15:19:07 +0000 | [diff] [blame] | 57 | |
Ben Clayton | b7aef03 | 2022-10-11 19:29:11 +0000 | [diff] [blame] | 58 | constexpr const char* kBuiltinValueStrings[] = { |
| 59 | "frag_depth", "front_facing", |
| 60 | "global_invocation_id", "instance_index", |
| 61 | "local_invocation_id", "local_invocation_index", |
| 62 | "num_workgroups", "position", |
| 63 | "sample_index", "sample_mask", |
| 64 | "vertex_index", "workgroup_id", |
| 65 | }; |
| 66 | |
dan sinclair | 34323ac | 2022-04-07 18:39:35 +0000 | [diff] [blame] | 67 | } // namespace tint::ast |
Ryan Harrison | dbc13af | 2022-02-21 15:19:07 +0000 | [diff] [blame] | 68 | |
Ben Clayton | f330229 | 2022-07-27 18:48:06 +0000 | [diff] [blame] | 69 | #endif // SRC_TINT_AST_BUILTIN_VALUE_H_ |