/src/glslang/glslang/HLSL/hlslAttributes.cpp
Line | Count | Source |
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. |
42 | | TAttributeType HlslParseContext::attributeFromName(const TString& nameSpace, const TString& name) const |
43 | 0 | { |
44 | | // handle names within a namespace |
45 | |
|
46 | 0 | if (nameSpace == "vk") { |
47 | 0 | if (name == "input_attachment_index") |
48 | 0 | return EatInputAttachment; |
49 | 0 | else if (name == "location") |
50 | 0 | return EatLocation; |
51 | 0 | else if (name == "binding") |
52 | 0 | return EatBinding; |
53 | 0 | else if (name == "global_cbuffer_binding") |
54 | 0 | return EatGlobalBinding; |
55 | 0 | else if (name == "builtin") |
56 | 0 | return EatBuiltIn; |
57 | 0 | else if (name == "constant_id") |
58 | 0 | return EatConstantId; |
59 | 0 | else if (name == "push_constant") |
60 | 0 | return EatPushConstant; |
61 | 0 | } else if (nameSpace == "spv") { |
62 | 0 | if (name == "format_rgba32f") return EatFormatRgba32f; |
63 | 0 | if (name == "format_rgba16f") return EatFormatRgba16f; |
64 | 0 | if (name == "format_r32f") return EatFormatR32f; |
65 | 0 | if (name == "format_rgba8") return EatFormatRgba8; |
66 | 0 | if (name == "format_rgba8snorm") return EatFormatRgba8Snorm; |
67 | 0 | if (name == "format_rg32f") return EatFormatRg32f; |
68 | 0 | if (name == "format_rg16f") return EatFormatRg16f; |
69 | 0 | if (name == "format_r11fg11fb10f") return EatFormatR11fG11fB10f; |
70 | 0 | if (name == "format_r16f") return EatFormatR16f; |
71 | 0 | if (name == "format_rgba16") return EatFormatRgba16; |
72 | 0 | if (name == "format_rgb10a2") return EatFormatRgb10A2; |
73 | 0 | if (name == "format_rg16") return EatFormatRg16; |
74 | 0 | if (name == "format_rg8") return EatFormatRg8; |
75 | 0 | if (name == "format_r16") return EatFormatR16; |
76 | 0 | if (name == "format_r8") return EatFormatR8; |
77 | 0 | if (name == "format_rgba16snorm") return EatFormatRgba16Snorm; |
78 | 0 | if (name == "format_rg16snorm") return EatFormatRg16Snorm; |
79 | 0 | if (name == "format_rg8snorm") return EatFormatRg8Snorm; |
80 | 0 | if (name == "format_r16snorm") return EatFormatR16Snorm; |
81 | 0 | if (name == "format_r8snorm") return EatFormatR8Snorm; |
82 | 0 | if (name == "format_rgba32i") return EatFormatRgba32i; |
83 | 0 | if (name == "format_rgba16i") return EatFormatRgba16i; |
84 | 0 | if (name == "format_rgba8i") return EatFormatRgba8i; |
85 | 0 | if (name == "format_r32i") return EatFormatR32i; |
86 | 0 | if (name == "format_rg32i") return EatFormatRg32i; |
87 | 0 | if (name == "format_rg16i") return EatFormatRg16i; |
88 | 0 | if (name == "format_rg8i") return EatFormatRg8i; |
89 | 0 | if (name == "format_r16i") return EatFormatR16i; |
90 | 0 | if (name == "format_r8i") return EatFormatR8i; |
91 | 0 | if (name == "format_rgba32ui") return EatFormatRgba32ui; |
92 | 0 | if (name == "format_rgba16ui") return EatFormatRgba16ui; |
93 | 0 | if (name == "format_rgba8ui") return EatFormatRgba8ui; |
94 | 0 | if (name == "format_r32ui") return EatFormatR32ui; |
95 | 0 | if (name == "format_rgb10a2ui") return EatFormatRgb10a2ui; |
96 | 0 | if (name == "format_rg32ui") return EatFormatRg32ui; |
97 | 0 | if (name == "format_rg16ui") return EatFormatRg16ui; |
98 | 0 | if (name == "format_rg8ui") return EatFormatRg8ui; |
99 | 0 | if (name == "format_r16ui") return EatFormatR16ui; |
100 | 0 | if (name == "format_r8ui") return EatFormatR8ui; |
101 | | |
102 | 0 | if (name == "nonwritable") return EatNonWritable; |
103 | 0 | if (name == "nonreadable") return EatNonReadable; |
104 | | |
105 | 0 | if (name == "export") return EatExport; |
106 | 0 | } else if (nameSpace.size() > 0) |
107 | 0 | return EatNone; |
108 | | |
109 | | // handle names with no namespace |
110 | | |
111 | 0 | if (name == "allow_uav_condition") |
112 | 0 | return EatAllow_uav_condition; |
113 | 0 | else if (name == "branch") |
114 | 0 | return EatBranch; |
115 | 0 | else if (name == "call") |
116 | 0 | return EatCall; |
117 | 0 | else if (name == "domain") |
118 | 0 | return EatDomain; |
119 | 0 | else if (name == "earlydepthstencil") |
120 | 0 | return EatEarlyDepthStencil; |
121 | 0 | else if (name == "fastopt") |
122 | 0 | return EatFastOpt; |
123 | 0 | else if (name == "flatten") |
124 | 0 | return EatFlatten; |
125 | 0 | else if (name == "forcecase") |
126 | 0 | return EatForceCase; |
127 | 0 | else if (name == "instance") |
128 | 0 | return EatInstance; |
129 | 0 | else if (name == "maxtessfactor") |
130 | 0 | return EatMaxTessFactor; |
131 | 0 | else if (name == "maxvertexcount") |
132 | 0 | return EatMaxVertexCount; |
133 | 0 | else if (name == "numthreads") |
134 | 0 | return EatNumThreads; |
135 | 0 | else if (name == "outputcontrolpoints") |
136 | 0 | return EatOutputControlPoints; |
137 | 0 | else if (name == "outputtopology") |
138 | 0 | return EatOutputTopology; |
139 | 0 | else if (name == "partitioning") |
140 | 0 | return EatPartitioning; |
141 | 0 | else if (name == "patchconstantfunc") |
142 | 0 | return EatPatchConstantFunc; |
143 | 0 | else if (name == "unroll") |
144 | 0 | return EatUnroll; |
145 | 0 | else if (name == "loop") |
146 | 0 | return EatLoop; |
147 | 0 | else |
148 | 0 | return EatNone; |
149 | 0 | } |
150 | | |
151 | | } // end namespace glslang |