naga/back/glsl/
keywords.rs

1use crate::proc::KeywordSet;
2use crate::racy_lock::RacyLock;
3
4pub const RESERVED_KEYWORDS: &[&str] = &[
5    //
6    // GLSL 4.6 keywords, from https://github.com/KhronosGroup/OpenGL-Registry/blob/d00e11dc1a1ffba581d633f21f70202051248d5c/specs/gl/GLSLangSpec.4.60.html#L2004-L2322
7    // GLSL ES 3.2 keywords, from https://github.com/KhronosGroup/OpenGL-Registry/blob/d00e11dc1a1ffba581d633f21f70202051248d5c/specs/es/3.2/GLSL_ES_Specification_3.20.html#L2166-L2478
8    //
9    // Note: The GLSL ES 3.2 keywords are the same as GLSL 4.6 keywords with some residing in the reserved section.
10    // The only exception are the missing Vulkan keywords which I think is an oversight (see https://github.com/KhronosGroup/OpenGL-Registry/issues/585).
11    //
12    "const",
13    "uniform",
14    "buffer",
15    "shared",
16    "attribute",
17    "varying",
18    "coherent",
19    "volatile",
20    "restrict",
21    "readonly",
22    "writeonly",
23    "atomic_uint",
24    "layout",
25    "centroid",
26    "flat",
27    "smooth",
28    "noperspective",
29    "patch",
30    "sample",
31    "invariant",
32    "precise",
33    "break",
34    "continue",
35    "do",
36    "for",
37    "while",
38    "switch",
39    "case",
40    "default",
41    "if",
42    "else",
43    "subroutine",
44    "in",
45    "out",
46    "inout",
47    "int",
48    "void",
49    "bool",
50    "true",
51    "false",
52    "float",
53    "double",
54    "discard",
55    "return",
56    "vec2",
57    "vec3",
58    "vec4",
59    "ivec2",
60    "ivec3",
61    "ivec4",
62    "bvec2",
63    "bvec3",
64    "bvec4",
65    "uint",
66    "uvec2",
67    "uvec3",
68    "uvec4",
69    "dvec2",
70    "dvec3",
71    "dvec4",
72    "mat2",
73    "mat3",
74    "mat4",
75    "mat2x2",
76    "mat2x3",
77    "mat2x4",
78    "mat3x2",
79    "mat3x3",
80    "mat3x4",
81    "mat4x2",
82    "mat4x3",
83    "mat4x4",
84    "dmat2",
85    "dmat3",
86    "dmat4",
87    "dmat2x2",
88    "dmat2x3",
89    "dmat2x4",
90    "dmat3x2",
91    "dmat3x3",
92    "dmat3x4",
93    "dmat4x2",
94    "dmat4x3",
95    "dmat4x4",
96    "lowp",
97    "mediump",
98    "highp",
99    "precision",
100    "sampler1D",
101    "sampler1DShadow",
102    "sampler1DArray",
103    "sampler1DArrayShadow",
104    "isampler1D",
105    "isampler1DArray",
106    "usampler1D",
107    "usampler1DArray",
108    "sampler2D",
109    "sampler2DShadow",
110    "sampler2DArray",
111    "sampler2DArrayShadow",
112    "isampler2D",
113    "isampler2DArray",
114    "usampler2D",
115    "usampler2DArray",
116    "sampler2DRect",
117    "sampler2DRectShadow",
118    "isampler2DRect",
119    "usampler2DRect",
120    "sampler2DMS",
121    "isampler2DMS",
122    "usampler2DMS",
123    "sampler2DMSArray",
124    "isampler2DMSArray",
125    "usampler2DMSArray",
126    "sampler3D",
127    "isampler3D",
128    "usampler3D",
129    "samplerCube",
130    "samplerCubeShadow",
131    "isamplerCube",
132    "usamplerCube",
133    "samplerCubeArray",
134    "samplerCubeArrayShadow",
135    "isamplerCubeArray",
136    "usamplerCubeArray",
137    "samplerBuffer",
138    "isamplerBuffer",
139    "usamplerBuffer",
140    "image1D",
141    "iimage1D",
142    "uimage1D",
143    "image1DArray",
144    "iimage1DArray",
145    "uimage1DArray",
146    "image2D",
147    "iimage2D",
148    "uimage2D",
149    "image2DArray",
150    "iimage2DArray",
151    "uimage2DArray",
152    "image2DRect",
153    "iimage2DRect",
154    "uimage2DRect",
155    "image2DMS",
156    "iimage2DMS",
157    "uimage2DMS",
158    "image2DMSArray",
159    "iimage2DMSArray",
160    "uimage2DMSArray",
161    "image3D",
162    "iimage3D",
163    "uimage3D",
164    "imageCube",
165    "iimageCube",
166    "uimageCube",
167    "imageCubeArray",
168    "iimageCubeArray",
169    "uimageCubeArray",
170    "imageBuffer",
171    "iimageBuffer",
172    "uimageBuffer",
173    "struct",
174    // Vulkan keywords
175    "texture1D",
176    "texture1DArray",
177    "itexture1D",
178    "itexture1DArray",
179    "utexture1D",
180    "utexture1DArray",
181    "texture2D",
182    "texture2DArray",
183    "itexture2D",
184    "itexture2DArray",
185    "utexture2D",
186    "utexture2DArray",
187    "texture2DRect",
188    "itexture2DRect",
189    "utexture2DRect",
190    "texture2DMS",
191    "itexture2DMS",
192    "utexture2DMS",
193    "texture2DMSArray",
194    "itexture2DMSArray",
195    "utexture2DMSArray",
196    "texture3D",
197    "itexture3D",
198    "utexture3D",
199    "textureCube",
200    "itextureCube",
201    "utextureCube",
202    "textureCubeArray",
203    "itextureCubeArray",
204    "utextureCubeArray",
205    "textureBuffer",
206    "itextureBuffer",
207    "utextureBuffer",
208    "sampler",
209    "samplerShadow",
210    "subpassInput",
211    "isubpassInput",
212    "usubpassInput",
213    "subpassInputMS",
214    "isubpassInputMS",
215    "usubpassInputMS",
216    // Reserved keywords
217    "common",
218    "partition",
219    "active",
220    "asm",
221    "class",
222    "union",
223    "enum",
224    "typedef",
225    "template",
226    "this",
227    "resource",
228    "goto",
229    "inline",
230    "noinline",
231    "public",
232    "static",
233    "extern",
234    "external",
235    "interface",
236    "long",
237    "short",
238    "half",
239    "fixed",
240    "unsigned",
241    "superp",
242    "input",
243    "output",
244    "hvec2",
245    "hvec3",
246    "hvec4",
247    "fvec2",
248    "fvec3",
249    "fvec4",
250    "filter",
251    "sizeof",
252    "cast",
253    "namespace",
254    "using",
255    "sampler3DRect",
256    // Reserved keywords that were unreserved in GLSL 4.2
257    "image1DArrayShadow",
258    "image1DShadow",
259    "image2DArrayShadow",
260    "image2DShadow",
261    // Reserved keywords that were unreserved in GLSL 4.4
262    "packed",
263    "row_major",
264    //
265    // GLSL 4.6 Built-In Functions, from https://github.com/KhronosGroup/OpenGL-Registry/blob/d00e11dc1a1ffba581d633f21f70202051248d5c/specs/gl/GLSLangSpec.4.60.html#L13314
266    //
267    // Angle and Trigonometry Functions, from https://github.com/KhronosGroup/OpenGL-Registry/blob/d00e11dc1a1ffba581d633f21f70202051248d5c/specs/gl/GLSLangSpec.4.60.html#L13469-L13561C5
268    "radians",
269    "degrees",
270    "sin",
271    "cos",
272    "tan",
273    "asin",
274    "acos",
275    "atan",
276    "sinh",
277    "cosh",
278    "tanh",
279    "asinh",
280    "acosh",
281    "atanh",
282    // Exponential Functions, from https://github.com/KhronosGroup/OpenGL-Registry/blob/d00e11dc1a1ffba581d633f21f70202051248d5c/specs/gl/GLSLangSpec.4.60.html#L13569-L13620
283    "pow",
284    "exp",
285    "log",
286    "exp2",
287    "log2",
288    "sqrt",
289    "inversesqrt",
290    // Common Functions, from https://github.com/KhronosGroup/OpenGL-Registry/blob/d00e11dc1a1ffba581d633f21f70202051248d5c/specs/gl/GLSLangSpec.4.60.html#L13628-L13908
291    "abs",
292    "sign",
293    "floor",
294    "trunc",
295    "round",
296    "roundEven",
297    "ceil",
298    "fract",
299    "mod",
300    "modf",
301    "min",
302    "max",
303    "clamp",
304    "mix",
305    "step",
306    "smoothstep",
307    "isnan",
308    "isinf",
309    "floatBitsToInt",
310    "floatBitsToUint",
311    "intBitsToFloat",
312    "uintBitsToFloat",
313    "fma",
314    "frexp",
315    "ldexp",
316    // Floating-Point Pack and Unpack Functions, from https://github.com/KhronosGroup/OpenGL-Registry/blob/d00e11dc1a1ffba581d633f21f70202051248d5c/specs/gl/GLSLangSpec.4.60.html#L13916-L14007
317    "packUnorm2x16",
318    "packSnorm2x16",
319    "packUnorm4x8",
320    "packSnorm4x8",
321    "unpackUnorm2x16",
322    "unpackSnorm2x16",
323    "unpackUnorm4x8",
324    "unpackSnorm4x8",
325    "packHalf2x16",
326    "unpackHalf2x16",
327    "packDouble2x32",
328    "unpackDouble2x32",
329    // Geometric Functions, from https://github.com/KhronosGroup/OpenGL-Registry/blob/d00e11dc1a1ffba581d633f21f70202051248d5c/specs/gl/GLSLangSpec.4.60.html#L14014-L14121
330    "length",
331    "distance",
332    "dot",
333    "cross",
334    "normalize",
335    "ftransform",
336    "faceforward",
337    "reflect",
338    "refract",
339    // Matrix Functions, from https://github.com/KhronosGroup/OpenGL-Registry/blob/d00e11dc1a1ffba581d633f21f70202051248d5c/specs/gl/GLSLangSpec.4.60.html#L14151-L14215
340    "matrixCompMult",
341    "outerProduct",
342    "transpose",
343    "determinant",
344    "inverse",
345    // Vector Relational Functions, from https://github.com/KhronosGroup/OpenGL-Registry/blob/d00e11dc1a1ffba581d633f21f70202051248d5c/specs/gl/GLSLangSpec.4.60.html#L14259-L14322
346    "lessThan",
347    "lessThanEqual",
348    "greaterThan",
349    "greaterThanEqual",
350    "equal",
351    "notEqual",
352    "any",
353    "all",
354    "not",
355    // Integer Functions, from https://github.com/KhronosGroup/OpenGL-Registry/blob/d00e11dc1a1ffba581d633f21f70202051248d5c/specs/gl/GLSLangSpec.4.60.html#L14335-L14432
356    "uaddCarry",
357    "usubBorrow",
358    "umulExtended",
359    "imulExtended",
360    "bitfieldExtract",
361    "bitfieldInsert",
362    "bitfieldReverse",
363    "bitCount",
364    "findLSB",
365    "findMSB",
366    // Texture Query Functions, from https://github.com/KhronosGroup/OpenGL-Registry/blob/d00e11dc1a1ffba581d633f21f70202051248d5c/specs/gl/GLSLangSpec.4.60.html#L14645-L14732
367    "textureSize",
368    "textureQueryLod",
369    "textureQueryLevels",
370    "textureSamples",
371    // Texel Lookup Functions, from https://github.com/KhronosGroup/OpenGL-Registry/blob/d00e11dc1a1ffba581d633f21f70202051248d5c/specs/gl/GLSLangSpec.4.60.html#L14736-L14997
372    "texture",
373    "textureProj",
374    "textureLod",
375    "textureOffset",
376    "texelFetch",
377    "texelFetchOffset",
378    "textureProjOffset",
379    "textureLodOffset",
380    "textureProjLod",
381    "textureProjLodOffset",
382    "textureGrad",
383    "textureGradOffset",
384    "textureProjGrad",
385    "textureProjGradOffset",
386    // Texture Gather Functions, from https://github.com/KhronosGroup/OpenGL-Registry/blob/d00e11dc1a1ffba581d633f21f70202051248d5c/specs/gl/GLSLangSpec.4.60.html#L15077-L15154
387    "textureGather",
388    "textureGatherOffset",
389    "textureGatherOffsets",
390    // Compatibility Profile Texture Functions, from https://github.com/KhronosGroup/OpenGL-Registry/blob/d00e11dc1a1ffba581d633f21f70202051248d5c/specs/gl/GLSLangSpec.4.60.html#L15161-L15220
391    "texture1D",
392    "texture1DProj",
393    "texture1DLod",
394    "texture1DProjLod",
395    "texture2D",
396    "texture2DProj",
397    "texture2DLod",
398    "texture2DProjLod",
399    "texture3D",
400    "texture3DProj",
401    "texture3DLod",
402    "texture3DProjLod",
403    "textureCube",
404    "textureCubeLod",
405    "shadow1D",
406    "shadow2D",
407    "shadow1DProj",
408    "shadow2DProj",
409    "shadow1DLod",
410    "shadow2DLod",
411    "shadow1DProjLod",
412    "shadow2DProjLod",
413    // Atomic Counter Functions, from https://github.com/KhronosGroup/OpenGL-Registry/blob/d00e11dc1a1ffba581d633f21f70202051248d5c/specs/gl/GLSLangSpec.4.60.html#L15241-L15531
414    "atomicCounterIncrement",
415    "atomicCounterDecrement",
416    "atomicCounter",
417    "atomicCounterAdd",
418    "atomicCounterSubtract",
419    "atomicCounterMin",
420    "atomicCounterMax",
421    "atomicCounterAnd",
422    "atomicCounterOr",
423    "atomicCounterXor",
424    "atomicCounterExchange",
425    "atomicCounterCompSwap",
426    // Atomic Memory Functions, from https://github.com/KhronosGroup/OpenGL-Registry/blob/d00e11dc1a1ffba581d633f21f70202051248d5c/specs/gl/GLSLangSpec.4.60.html#L15563-L15624
427    "atomicAdd",
428    "atomicMin",
429    "atomicMax",
430    "atomicAnd",
431    "atomicOr",
432    "atomicXor",
433    "atomicExchange",
434    "atomicCompSwap",
435    // Image Functions, from https://github.com/KhronosGroup/OpenGL-Registry/blob/d00e11dc1a1ffba581d633f21f70202051248d5c/specs/gl/GLSLangSpec.4.60.html#L15763-L15878
436    "imageSize",
437    "imageSamples",
438    "imageLoad",
439    "imageStore",
440    "imageAtomicAdd",
441    "imageAtomicMin",
442    "imageAtomicMax",
443    "imageAtomicAnd",
444    "imageAtomicOr",
445    "imageAtomicXor",
446    "imageAtomicExchange",
447    "imageAtomicCompSwap",
448    // Geometry Shader Functions, from https://github.com/KhronosGroup/OpenGL-Registry/blob/d00e11dc1a1ffba581d633f21f70202051248d5c/specs/gl/GLSLangSpec.4.60.html#L15886-L15932
449    "EmitStreamVertex",
450    "EndStreamPrimitive",
451    "EmitVertex",
452    "EndPrimitive",
453    // Fragment Processing Functions, Derivative Functions, from https://github.com/KhronosGroup/OpenGL-Registry/blob/d00e11dc1a1ffba581d633f21f70202051248d5c/specs/gl/GLSLangSpec.4.60.html#L16041-L16114
454    "dFdx",
455    "dFdy",
456    "dFdxFine",
457    "dFdyFine",
458    "dFdxCoarse",
459    "dFdyCoarse",
460    "fwidth",
461    "fwidthFine",
462    "fwidthCoarse",
463    // Fragment Processing Functions, Interpolation Functions, from https://github.com/KhronosGroup/OpenGL-Registry/blob/d00e11dc1a1ffba581d633f21f70202051248d5c/specs/gl/GLSLangSpec.4.60.html#L16150-L16198
464    "interpolateAtCentroid",
465    "interpolateAtSample",
466    "interpolateAtOffset",
467    // Noise Functions, from https://github.com/KhronosGroup/OpenGL-Registry/blob/d00e11dc1a1ffba581d633f21f70202051248d5c/specs/gl/GLSLangSpec.4.60.html#L16214-L16243
468    "noise1",
469    "noise2",
470    "noise3",
471    "noise4",
472    // Shader Invocation Control Functions, from https://github.com/KhronosGroup/OpenGL-Registry/blob/d00e11dc1a1ffba581d633f21f70202051248d5c/specs/gl/GLSLangSpec.4.60.html#L16255-L16276
473    "barrier",
474    // Shader Memory Control Functions, from https://github.com/KhronosGroup/OpenGL-Registry/blob/d00e11dc1a1ffba581d633f21f70202051248d5c/specs/gl/GLSLangSpec.4.60.html#L16336-L16382
475    "memoryBarrier",
476    "memoryBarrierAtomicCounter",
477    "memoryBarrierBuffer",
478    "memoryBarrierShared",
479    "memoryBarrierImage",
480    "groupMemoryBarrier",
481    // Subpass-Input Functions, from https://github.com/KhronosGroup/OpenGL-Registry/blob/d00e11dc1a1ffba581d633f21f70202051248d5c/specs/gl/GLSLangSpec.4.60.html#L16451-L16470
482    "subpassLoad",
483    // Shader Invocation Group Functions, from https://github.com/KhronosGroup/OpenGL-Registry/blob/d00e11dc1a1ffba581d633f21f70202051248d5c/specs/gl/GLSLangSpec.4.60.html#L16483-L16511
484    "anyInvocation",
485    "allInvocations",
486    "allInvocationsEqual",
487    //
488    // entry point name (should not be shadowed)
489    //
490    "main",
491    // Naga utilities:
492    super::MODF_FUNCTION,
493    super::FREXP_FUNCTION,
494    super::FIRST_INSTANCE_BINDING,
495];
496
497/// The above set of reserved keywords, turned into a cached HashSet. This saves
498/// significant time during [`Namer::reset`](crate::proc::Namer::reset).
499///
500/// See <https://github.com/gfx-rs/wgpu/pull/7338> for benchmarks.
501pub static RESERVED_KEYWORD_SET: RacyLock<KeywordSet> =
502    RacyLock::new(|| KeywordSet::from_iter(RESERVED_KEYWORDS));