blob: e8d64514048aa8cf59d39f0207d8b08cba6616be [file] [log] [blame]
// 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.
////////////////////////////////////////////////////////////////////////////////
// File generated by tools/src/cmd/gen
// using the template:
// src/tint/ast/builtin_value.cc.tmpl
//
// Do not modify this file directly
////////////////////////////////////////////////////////////////////////////////
#include "src/tint/ast/builtin_value.h"
namespace tint::ast {
/// ParseBuiltinValue parses a BuiltinValue from a string.
/// @param str the string to parse
/// @returns the parsed enum, or BuiltinValue::kInvalid if the string could not be parsed.
BuiltinValue ParseBuiltinValue(std::string_view str) {
if (str == "position") {
return BuiltinValue::kPosition;
}
if (str == "vertex_index") {
return BuiltinValue::kVertexIndex;
}
if (str == "instance_index") {
return BuiltinValue::kInstanceIndex;
}
if (str == "front_facing") {
return BuiltinValue::kFrontFacing;
}
if (str == "frag_depth") {
return BuiltinValue::kFragDepth;
}
if (str == "local_invocation_id") {
return BuiltinValue::kLocalInvocationId;
}
if (str == "local_invocation_index") {
return BuiltinValue::kLocalInvocationIndex;
}
if (str == "global_invocation_id") {
return BuiltinValue::kGlobalInvocationId;
}
if (str == "workgroup_id") {
return BuiltinValue::kWorkgroupId;
}
if (str == "num_workgroups") {
return BuiltinValue::kNumWorkgroups;
}
if (str == "sample_index") {
return BuiltinValue::kSampleIndex;
}
if (str == "sample_mask") {
return BuiltinValue::kSampleMask;
}
return BuiltinValue::kInvalid;
}
std::ostream& operator<<(std::ostream& out, BuiltinValue value) {
switch (value) {
case BuiltinValue::kInvalid:
return out << "invalid";
case BuiltinValue::kPosition:
return out << "position";
case BuiltinValue::kVertexIndex:
return out << "vertex_index";
case BuiltinValue::kInstanceIndex:
return out << "instance_index";
case BuiltinValue::kFrontFacing:
return out << "front_facing";
case BuiltinValue::kFragDepth:
return out << "frag_depth";
case BuiltinValue::kLocalInvocationId:
return out << "local_invocation_id";
case BuiltinValue::kLocalInvocationIndex:
return out << "local_invocation_index";
case BuiltinValue::kGlobalInvocationId:
return out << "global_invocation_id";
case BuiltinValue::kWorkgroupId:
return out << "workgroup_id";
case BuiltinValue::kNumWorkgroups:
return out << "num_workgroups";
case BuiltinValue::kSampleIndex:
return out << "sample_index";
case BuiltinValue::kSampleMask:
return out << "sample_mask";
case BuiltinValue::kPointSize:
return out << "point_size";
}
return out << "<unknown>";
}
} // namespace tint::ast