1 // Copyright 2015 The Shaderc Authors. All rights reserved. 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 15 #include "libshaderc_util/shader_stage.h" 16 17 namespace { 18 19 // Maps an identifier to a language. 20 struct LanguageMapping { 21 const char* id; 22 EShLanguage language; 23 }; 24 25 } // anonymous namespace 26 27 namespace shaderc_util { 28 29 EShLanguage MapStageNameToLanguage(const string_piece& stage_name) { 30 const LanguageMapping string_to_stage[] = { 31 {"vertex", EShLangVertex}, 32 {"fragment", EShLangFragment}, 33 {"tesscontrol", EShLangTessControl}, 34 {"tesseval", EShLangTessEvaluation}, 35 {"geometry", EShLangGeometry}, 36 {"compute", EShLangCompute}}; 37 38 for (const auto& entry : string_to_stage) { 39 if (stage_name == entry.id) return entry.language; 40 } 41 return EShLangCount; 42 } 43 44 } // namespace shaderc_util 45