1 // 2 // Copyright (C) 2016 LunarG, Inc. 3 // 4 // All rights reserved. 5 // 6 // Redistribution and use in source and binary forms, with or without 7 // modification, are permitted provided that the following conditions 8 // are met: 9 // 10 // Redistributions of source code must retain the above copyright 11 // notice, this list of conditions and the following disclaimer. 12 // 13 // Redistributions in binary form must reproduce the above 14 // copyright notice, this list of conditions and the following 15 // disclaimer in the documentation and/or other materials provided 16 // with the distribution. 17 // 18 // Neither the name of Google, Inc., nor the names of its 19 // contributors may be used to endorse or promote products derived 20 // from this software without specific prior written permission. 21 // 22 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 23 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 24 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 25 // FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 26 // COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 27 // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 28 // BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 29 // LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 30 // CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 31 // LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 32 // ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 33 // POSSIBILITY OF SUCH DAMAGE. 34 // 35 36 #include "hlslAttributes.h" 37 #include "hlslParseHelper.h" 38 39 namespace glslang { 40 // Map the given string to an attribute enum from TAttributeType, 41 // or EatNone if invalid. attributeFromName(const TString & nameSpace,const TString & name) const42 TAttributeType HlslParseContext::attributeFromName(const TString& nameSpace, const TString& name) const 43 { 44 // handle names within a namespace 45 46 if (nameSpace == "vk") { 47 if (name == "input_attachment_index") 48 return EatInputAttachment; 49 else if (name == "location") 50 return EatLocation; 51 else if (name == "binding") 52 return EatBinding; 53 else if (name == "global_cbuffer_binding") 54 return EatGlobalBinding; 55 else if (name == "builtin") 56 return EatBuiltIn; 57 else if (name == "constant_id") 58 return EatConstantId; 59 else if (name == "push_constant") 60 return EatPushConstant; 61 } else if (nameSpace == "spv") { 62 if (name == "format_rgba32f") return EatFormatRgba32f; 63 if (name == "format_rgba16f") return EatFormatRgba16f; 64 if (name == "format_r32f") return EatFormatR32f; 65 if (name == "format_rgba8") return EatFormatRgba8; 66 if (name == "format_rgba8snorm") return EatFormatRgba8Snorm; 67 if (name == "format_rg32f") return EatFormatRg32f; 68 if (name == "format_rg16f") return EatFormatRg16f; 69 if (name == "format_r11fg11fb10f") return EatFormatR11fG11fB10f; 70 if (name == "format_r16f") return EatFormatR16f; 71 if (name == "format_rgba16") return EatFormatRgba16; 72 if (name == "format_rgb10a2") return EatFormatRgb10A2; 73 if (name == "format_rg16") return EatFormatRg16; 74 if (name == "format_rg8") return EatFormatRg8; 75 if (name == "format_r16") return EatFormatR16; 76 if (name == "format_r8") return EatFormatR8; 77 if (name == "format_rgba16snorm") return EatFormatRgba16Snorm; 78 if (name == "format_rg16snorm") return EatFormatRg16Snorm; 79 if (name == "format_rg8snorm") return EatFormatRg8Snorm; 80 if (name == "format_r16snorm") return EatFormatR16Snorm; 81 if (name == "format_r8snorm") return EatFormatR8Snorm; 82 if (name == "format_rgba32i") return EatFormatRgba32i; 83 if (name == "format_rgba16i") return EatFormatRgba16i; 84 if (name == "format_rgba8i") return EatFormatRgba8i; 85 if (name == "format_r32i") return EatFormatR32i; 86 if (name == "format_rg32i") return EatFormatRg32i; 87 if (name == "format_rg16i") return EatFormatRg16i; 88 if (name == "format_rg8i") return EatFormatRg8i; 89 if (name == "format_r16i") return EatFormatR16i; 90 if (name == "format_r8i") return EatFormatR8i; 91 if (name == "format_rgba32ui") return EatFormatRgba32ui; 92 if (name == "format_rgba16ui") return EatFormatRgba16ui; 93 if (name == "format_rgba8ui") return EatFormatRgba8ui; 94 if (name == "format_r32ui") return EatFormatR32ui; 95 if (name == "format_rgb10a2ui") return EatFormatRgb10a2ui; 96 if (name == "format_rg32ui") return EatFormatRg32ui; 97 if (name == "format_rg16ui") return EatFormatRg16ui; 98 if (name == "format_rg8ui") return EatFormatRg8ui; 99 if (name == "format_r16ui") return EatFormatR16ui; 100 if (name == "format_r8ui") return EatFormatR8ui; 101 102 if (name == "nonwritable") return EatNonWritable; 103 if (name == "nonreadable") return EatNonReadable; 104 } else if (nameSpace.size() > 0) 105 return EatNone; 106 107 // handle names with no namespace 108 109 if (name == "allow_uav_condition") 110 return EatAllow_uav_condition; 111 else if (name == "branch") 112 return EatBranch; 113 else if (name == "call") 114 return EatCall; 115 else if (name == "domain") 116 return EatDomain; 117 else if (name == "earlydepthstencil") 118 return EatEarlyDepthStencil; 119 else if (name == "fastopt") 120 return EatFastOpt; 121 else if (name == "flatten") 122 return EatFlatten; 123 else if (name == "forcecase") 124 return EatForceCase; 125 else if (name == "instance") 126 return EatInstance; 127 else if (name == "maxtessfactor") 128 return EatMaxTessFactor; 129 else if (name == "maxvertexcount") 130 return EatMaxVertexCount; 131 else if (name == "numthreads") 132 return EatNumThreads; 133 else if (name == "outputcontrolpoints") 134 return EatOutputControlPoints; 135 else if (name == "outputtopology") 136 return EatOutputTopology; 137 else if (name == "partitioning") 138 return EatPartitioning; 139 else if (name == "patchconstantfunc") 140 return EatPatchConstantFunc; 141 else if (name == "unroll") 142 return EatUnroll; 143 else if (name == "loop") 144 return EatLoop; 145 else 146 return EatNone; 147 } 148 149 } // end namespace glslang 150