blob: 3a3c7869aeba0a33195bf42e43f269d741b70867 [file] [log] [blame]
Ryan Harrisondbc13af2022-02-21 15:19:07 +00001// 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 Claytonfe8e6ee2022-07-27 22:21:30 +000015////////////////////////////////////////////////////////////////////////////////
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 Claytonf3302292022-07-27 18:48:06 +000023#ifndef SRC_TINT_AST_BUILTIN_VALUE_H_
24#define SRC_TINT_AST_BUILTIN_VALUE_H_
Ryan Harrisondbc13af2022-02-21 15:19:07 +000025
26#include <ostream>
27
dan sinclair34323ac2022-04-07 18:39:35 +000028namespace tint::ast {
Ryan Harrisondbc13af2022-02-21 15:19:07 +000029
Ben Claytonf9ed9d32022-10-11 19:49:17 +000030/// Builtin value defined with `@builtin(<name>)`.
Ben Claytonf3302292022-07-27 18:48:06 +000031enum class BuiltinValue {
Ben Claytond2e0db32022-10-12 18:49:15 +000032 kUndefined,
dan sinclair41e4d9a2022-05-01 14:40:55 +000033 kFragDepth,
Ben Claytondb368f12022-10-11 18:26:18 +000034 kFrontFacing,
35 kGlobalInvocationId,
36 kInstanceIndex,
dan sinclair41e4d9a2022-05-01 14:40:55 +000037 kLocalInvocationId,
38 kLocalInvocationIndex,
dan sinclair41e4d9a2022-05-01 14:40:55 +000039 kNumWorkgroups,
Ben Claytondb368f12022-10-11 18:26:18 +000040 kPointSize, // Tint-internal enum entry - not parsed
41 kPosition,
dan sinclair41e4d9a2022-05-01 14:40:55 +000042 kSampleIndex,
43 kSampleMask,
Ben Claytondb368f12022-10-11 18:26:18 +000044 kVertexIndex,
45 kWorkgroupId,
Ryan Harrisondbc13af2022-02-21 15:19:07 +000046};
47
48/// @param out the std::ostream to write to
Ben Claytonfe8e6ee2022-07-27 22:21:30 +000049/// @param value the BuiltinValue
50/// @returns `out` so calls can be chained
51std::ostream& operator<<(std::ostream& out, BuiltinValue value);
52
53/// ParseBuiltinValue parses a BuiltinValue from a string.
54/// @param str the string to parse
Ben Claytond2e0db32022-10-12 18:49:15 +000055/// @returns the parsed enum, or BuiltinValue::kUndefined if the string could not be parsed.
Ben Claytonfe8e6ee2022-07-27 22:21:30 +000056BuiltinValue ParseBuiltinValue(std::string_view str);
Ryan Harrisondbc13af2022-02-21 15:19:07 +000057
Ben Claytonb7aef032022-10-11 19:29:11 +000058constexpr 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 sinclair34323ac2022-04-07 18:39:35 +000067} // namespace tint::ast
Ryan Harrisondbc13af2022-02-21 15:19:07 +000068
Ben Claytonf3302292022-07-27 18:48:06 +000069#endif // SRC_TINT_AST_BUILTIN_VALUE_H_