naga/back/hlsl/
keywords.rs

1use crate::proc::{CaseInsensitiveKeywordSet, KeywordSet};
2use crate::racy_lock::RacyLock;
3
4// When compiling with FXC without strict mode, these keywords are actually case insensitive.
5// If you compile with strict mode and specify a different casing like "Pass" instead in an identifier, FXC will give this error:
6// "error X3086: alternate cases for 'pass' are deprecated in strict mode"
7// This behavior is not documented anywhere, but as far as I can tell this is the full list.
8pub const RESERVED_CASE_INSENSITIVE: &[&str] = &[
9    "asm",
10    "decl",
11    "pass",
12    "technique",
13    "Texture1D",
14    "Texture2D",
15    "Texture3D",
16    "TextureCube",
17];
18
19pub const RESERVED: &[&str] = &[
20    // FXC keywords, from https://github.com/MicrosoftDocs/win32/blob/c885cb0c63b0e9be80c6a0e6512473ac6f4e771e/desktop-src/direct3dhlsl/dx-graphics-hlsl-appendix-keywords.md?plain=1#L99-L118
21    "AppendStructuredBuffer",
22    "asm",
23    "asm_fragment",
24    "BlendState",
25    "bool",
26    "break",
27    "Buffer",
28    "ByteAddressBuffer",
29    "case",
30    "cbuffer",
31    "centroid",
32    "class",
33    "column_major",
34    "compile",
35    "compile_fragment",
36    "CompileShader",
37    "const",
38    "continue",
39    "ComputeShader",
40    "ConsumeStructuredBuffer",
41    "default",
42    "DepthStencilState",
43    "DepthStencilView",
44    "discard",
45    "do",
46    "double",
47    "DomainShader",
48    "dword",
49    "else",
50    "export",
51    "extern",
52    "false",
53    "float",
54    "for",
55    "fxgroup",
56    "GeometryShader",
57    "groupshared",
58    "half",
59    "Hullshader",
60    "if",
61    "in",
62    "inline",
63    "inout",
64    "InputPatch",
65    "int",
66    "interface",
67    "line",
68    "lineadj",
69    "linear",
70    "LineStream",
71    "matrix",
72    "min16float",
73    "min10float",
74    "min16int",
75    "min12int",
76    "min16uint",
77    "namespace",
78    "nointerpolation",
79    "noperspective",
80    "NULL",
81    "out",
82    "OutputPatch",
83    "packoffset",
84    "pass",
85    "pixelfragment",
86    "PixelShader",
87    "point",
88    "PointStream",
89    "precise",
90    "RasterizerState",
91    "RenderTargetView",
92    "return",
93    "register",
94    "row_major",
95    "RWBuffer",
96    "RWByteAddressBuffer",
97    "RWStructuredBuffer",
98    "RWTexture1D",
99    "RWTexture1DArray",
100    "RWTexture2D",
101    "RWTexture2DArray",
102    "RWTexture3D",
103    "sample",
104    "sampler",
105    "SamplerState",
106    "SamplerComparisonState",
107    "shared",
108    "snorm",
109    "stateblock",
110    "stateblock_state",
111    "static",
112    "string",
113    "struct",
114    "switch",
115    "StructuredBuffer",
116    "tbuffer",
117    "technique",
118    "technique10",
119    "technique11",
120    "texture",
121    "Texture1D",
122    "Texture1DArray",
123    "Texture2D",
124    "Texture2DArray",
125    "Texture2DMS",
126    "Texture2DMSArray",
127    "Texture3D",
128    "TextureCube",
129    "TextureCubeArray",
130    "true",
131    "typedef",
132    "triangle",
133    "triangleadj",
134    "TriangleStream",
135    "uint",
136    "uniform",
137    "unorm",
138    "unsigned",
139    "vector",
140    "vertexfragment",
141    "VertexShader",
142    "void",
143    "volatile",
144    "while",
145    // FXC reserved keywords, from https://github.com/MicrosoftDocs/win32/blob/c885cb0c63b0e9be80c6a0e6512473ac6f4e771e/desktop-src/direct3dhlsl/dx-graphics-hlsl-appendix-reserved-words.md?plain=1#L19-L38
146    "auto",
147    "case",
148    "catch",
149    "char",
150    "class",
151    "const_cast",
152    "default",
153    "delete",
154    "dynamic_cast",
155    "enum",
156    "explicit",
157    "friend",
158    "goto",
159    "long",
160    "mutable",
161    "new",
162    "operator",
163    "private",
164    "protected",
165    "public",
166    "reinterpret_cast",
167    "short",
168    "signed",
169    "sizeof",
170    "static_cast",
171    "template",
172    "this",
173    "throw",
174    "try",
175    "typename",
176    "union",
177    "unsigned",
178    "using",
179    "virtual",
180    // FXC intrinsics, from https://github.com/MicrosoftDocs/win32/blob/1682b99e203708f6f5eda972d966e30f3c1588de/desktop-src/direct3dhlsl/dx-graphics-hlsl-intrinsic-functions.md?plain=1#L26-L165
181    "abort",
182    "abs",
183    "acos",
184    "all",
185    "AllMemoryBarrier",
186    "AllMemoryBarrierWithGroupSync",
187    "any",
188    "asdouble",
189    "asfloat",
190    "asin",
191    "asint",
192    "asuint",
193    "atan",
194    "atan2",
195    "ceil",
196    "CheckAccessFullyMapped",
197    "clamp",
198    "clip",
199    "cos",
200    "cosh",
201    "countbits",
202    "cross",
203    "D3DCOLORtoUBYTE4",
204    "ddx",
205    "ddx_coarse",
206    "ddx_fine",
207    "ddy",
208    "ddy_coarse",
209    "ddy_fine",
210    "degrees",
211    "determinant",
212    "DeviceMemoryBarrier",
213    "DeviceMemoryBarrierWithGroupSync",
214    "distance",
215    "dot",
216    "dst",
217    "errorf",
218    "EvaluateAttributeCentroid",
219    "EvaluateAttributeAtSample",
220    "EvaluateAttributeSnapped",
221    "exp",
222    "exp2",
223    "f16tof32",
224    "f32tof16",
225    "faceforward",
226    "firstbithigh",
227    "firstbitlow",
228    "floor",
229    "fma",
230    "fmod",
231    "frac",
232    "frexp",
233    "fwidth",
234    "GetRenderTargetSampleCount",
235    "GetRenderTargetSamplePosition",
236    "GroupMemoryBarrier",
237    "GroupMemoryBarrierWithGroupSync",
238    "InterlockedAdd",
239    "InterlockedAnd",
240    "InterlockedCompareExchange",
241    "InterlockedCompareStore",
242    "InterlockedExchange",
243    "InterlockedMax",
244    "InterlockedMin",
245    "InterlockedOr",
246    "InterlockedXor",
247    "isfinite",
248    "isinf",
249    "isnan",
250    "ldexp",
251    "length",
252    "lerp",
253    "lit",
254    "log",
255    "log10",
256    "log2",
257    "mad",
258    "max",
259    "min",
260    "modf",
261    "msad4",
262    "mul",
263    "noise",
264    "normalize",
265    "pow",
266    "printf",
267    "Process2DQuadTessFactorsAvg",
268    "Process2DQuadTessFactorsMax",
269    "Process2DQuadTessFactorsMin",
270    "ProcessIsolineTessFactors",
271    "ProcessQuadTessFactorsAvg",
272    "ProcessQuadTessFactorsMax",
273    "ProcessQuadTessFactorsMin",
274    "ProcessTriTessFactorsAvg",
275    "ProcessTriTessFactorsMax",
276    "ProcessTriTessFactorsMin",
277    "radians",
278    "rcp",
279    "reflect",
280    "refract",
281    "reversebits",
282    "round",
283    "rsqrt",
284    "saturate",
285    "sign",
286    "sin",
287    "sincos",
288    "sinh",
289    "smoothstep",
290    "sqrt",
291    "step",
292    "tan",
293    "tanh",
294    "tex1D",
295    "tex1Dbias",
296    "tex1Dgrad",
297    "tex1Dlod",
298    "tex1Dproj",
299    "tex2D",
300    "tex2Dbias",
301    "tex2Dgrad",
302    "tex2Dlod",
303    "tex2Dproj",
304    "tex3D",
305    "tex3Dbias",
306    "tex3Dgrad",
307    "tex3Dlod",
308    "tex3Dproj",
309    "texCUBE",
310    "texCUBEbias",
311    "texCUBEgrad",
312    "texCUBElod",
313    "texCUBEproj",
314    "transpose",
315    "trunc",
316    // DXC (reserved) keywords, from https://github.com/microsoft/DirectXShaderCompiler/blob/d5d478470d3020a438d3cb810b8d3fe0992e6709/tools/clang/include/clang/Basic/TokenKinds.def#L222-L648
317    // with the KEYALL, KEYCXX, BOOLSUPPORT, WCHARSUPPORT, KEYHLSL options enabled (see https://github.com/microsoft/DirectXShaderCompiler/blob/d5d478470d3020a438d3cb810b8d3fe0992e6709/tools/clang/lib/Frontend/CompilerInvocation.cpp#L1199)
318    "auto",
319    "break",
320    "case",
321    "char",
322    "const",
323    "continue",
324    "default",
325    "do",
326    "double",
327    "else",
328    "enum",
329    "extern",
330    "float",
331    "for",
332    "goto",
333    "if",
334    "inline",
335    "int",
336    "long",
337    "register",
338    "return",
339    "short",
340    "signed",
341    "sizeof",
342    "static",
343    "struct",
344    "switch",
345    "typedef",
346    "union",
347    "unsigned",
348    "void",
349    "volatile",
350    "while",
351    "_Alignas",
352    "_Alignof",
353    "_Atomic",
354    "_Complex",
355    "_Generic",
356    "_Imaginary",
357    "_Noreturn",
358    "_Static_assert",
359    "_Thread_local",
360    "__func__",
361    "__objc_yes",
362    "__objc_no",
363    "asm",
364    "bool",
365    "catch",
366    "class",
367    "const_cast",
368    "delete",
369    "dynamic_cast",
370    "explicit",
371    "export",
372    "false",
373    "friend",
374    "mutable",
375    "namespace",
376    "new",
377    "operator",
378    "private",
379    "protected",
380    "public",
381    "reinterpret_cast",
382    "static_cast",
383    "template",
384    "this",
385    "throw",
386    "true",
387    "try",
388    "typename",
389    "typeid",
390    "using",
391    "virtual",
392    "wchar_t",
393    "_Decimal32",
394    "_Decimal64",
395    "_Decimal128",
396    "__null",
397    "__alignof",
398    "__attribute",
399    "__builtin_choose_expr",
400    "__builtin_offsetof",
401    "__builtin_va_arg",
402    "__extension__",
403    "__imag",
404    "__int128",
405    "__label__",
406    "__real",
407    "__thread",
408    "__FUNCTION__",
409    "__PRETTY_FUNCTION__",
410    "__is_nothrow_assignable",
411    "__is_constructible",
412    "__is_nothrow_constructible",
413    "__has_nothrow_assign",
414    "__has_nothrow_move_assign",
415    "__has_nothrow_copy",
416    "__has_nothrow_constructor",
417    "__has_trivial_assign",
418    "__has_trivial_move_assign",
419    "__has_trivial_copy",
420    "__has_trivial_constructor",
421    "__has_trivial_move_constructor",
422    "__has_trivial_destructor",
423    "__has_virtual_destructor",
424    "__is_abstract",
425    "__is_base_of",
426    "__is_class",
427    "__is_convertible_to",
428    "__is_empty",
429    "__is_enum",
430    "__is_final",
431    "__is_literal",
432    "__is_literal_type",
433    "__is_pod",
434    "__is_polymorphic",
435    "__is_trivial",
436    "__is_union",
437    "__is_trivially_constructible",
438    "__is_trivially_copyable",
439    "__is_trivially_assignable",
440    "__underlying_type",
441    "__is_lvalue_expr",
442    "__is_rvalue_expr",
443    "__is_arithmetic",
444    "__is_floating_point",
445    "__is_integral",
446    "__is_complete_type",
447    "__is_void",
448    "__is_array",
449    "__is_function",
450    "__is_reference",
451    "__is_lvalue_reference",
452    "__is_rvalue_reference",
453    "__is_fundamental",
454    "__is_object",
455    "__is_scalar",
456    "__is_compound",
457    "__is_pointer",
458    "__is_member_object_pointer",
459    "__is_member_function_pointer",
460    "__is_member_pointer",
461    "__is_const",
462    "__is_volatile",
463    "__is_standard_layout",
464    "__is_signed",
465    "__is_unsigned",
466    "__is_same",
467    "__is_convertible",
468    "__array_rank",
469    "__array_extent",
470    "__private_extern__",
471    "__module_private__",
472    "__declspec",
473    "__cdecl",
474    "__stdcall",
475    "__fastcall",
476    "__thiscall",
477    "__vectorcall",
478    "cbuffer",
479    "tbuffer",
480    "packoffset",
481    "linear",
482    "centroid",
483    "nointerpolation",
484    "noperspective",
485    "sample",
486    "column_major",
487    "row_major",
488    "in",
489    "out",
490    "inout",
491    "uniform",
492    "precise",
493    "center",
494    "shared",
495    "groupshared",
496    "discard",
497    "snorm",
498    "unorm",
499    "point",
500    "line",
501    "lineadj",
502    "triangle",
503    "triangleadj",
504    "globallycoherent",
505    "interface",
506    "sampler_state",
507    "technique",
508    "indices",
509    "vertices",
510    "primitives",
511    "payload",
512    "Technique",
513    "technique10",
514    "technique11",
515    "__builtin_omp_required_simd_align",
516    "__pascal",
517    "__fp16",
518    "__alignof__",
519    "__asm",
520    "__asm__",
521    "__attribute__",
522    "__complex",
523    "__complex__",
524    "__const",
525    "__const__",
526    "__decltype",
527    "__imag__",
528    "__inline",
529    "__inline__",
530    "__nullptr",
531    "__real__",
532    "__restrict",
533    "__restrict__",
534    "__signed",
535    "__signed__",
536    "__typeof",
537    "__typeof__",
538    "__volatile",
539    "__volatile__",
540    "_Nonnull",
541    "_Nullable",
542    "_Null_unspecified",
543    "__builtin_convertvector",
544    "__char16_t",
545    "__char32_t",
546    // DXC intrinsics, from https://github.com/microsoft/DirectXShaderCompiler/blob/18c9e114f9c314f93e68fbc72ce207d4ed2e65ae/utils/hct/gen_intrin_main.txt#L86-L376
547    "D3DCOLORtoUBYTE4",
548    "GetRenderTargetSampleCount",
549    "GetRenderTargetSamplePosition",
550    "abort",
551    "abs",
552    "acos",
553    "all",
554    "AllMemoryBarrier",
555    "AllMemoryBarrierWithGroupSync",
556    "any",
557    "asdouble",
558    "asfloat",
559    "asfloat16",
560    "asint16",
561    "asin",
562    "asint",
563    "asuint",
564    "asuint16",
565    "atan",
566    "atan2",
567    "ceil",
568    "clamp",
569    "clip",
570    "cos",
571    "cosh",
572    "countbits",
573    "cross",
574    "ddx",
575    "ddx_coarse",
576    "ddx_fine",
577    "ddy",
578    "ddy_coarse",
579    "ddy_fine",
580    "degrees",
581    "determinant",
582    "DeviceMemoryBarrier",
583    "DeviceMemoryBarrierWithGroupSync",
584    "distance",
585    "dot",
586    "dst",
587    "EvaluateAttributeAtSample",
588    "EvaluateAttributeCentroid",
589    "EvaluateAttributeSnapped",
590    "GetAttributeAtVertex",
591    "exp",
592    "exp2",
593    "f16tof32",
594    "f32tof16",
595    "faceforward",
596    "firstbithigh",
597    "firstbitlow",
598    "floor",
599    "fma",
600    "fmod",
601    "frac",
602    "frexp",
603    "fwidth",
604    "GroupMemoryBarrier",
605    "GroupMemoryBarrierWithGroupSync",
606    "InterlockedAdd",
607    "InterlockedMin",
608    "InterlockedMax",
609    "InterlockedAnd",
610    "InterlockedOr",
611    "InterlockedXor",
612    "InterlockedCompareStore",
613    "InterlockedExchange",
614    "InterlockedCompareExchange",
615    "InterlockedCompareStoreFloatBitwise",
616    "InterlockedCompareExchangeFloatBitwise",
617    "isfinite",
618    "isinf",
619    "isnan",
620    "ldexp",
621    "length",
622    "lerp",
623    "lit",
624    "log",
625    "log10",
626    "log2",
627    "mad",
628    "max",
629    "min",
630    "modf",
631    "msad4",
632    "mul",
633    "normalize",
634    "pow",
635    "printf",
636    "Process2DQuadTessFactorsAvg",
637    "Process2DQuadTessFactorsMax",
638    "Process2DQuadTessFactorsMin",
639    "ProcessIsolineTessFactors",
640    "ProcessQuadTessFactorsAvg",
641    "ProcessQuadTessFactorsMax",
642    "ProcessQuadTessFactorsMin",
643    "ProcessTriTessFactorsAvg",
644    "ProcessTriTessFactorsMax",
645    "ProcessTriTessFactorsMin",
646    "radians",
647    "rcp",
648    "reflect",
649    "refract",
650    "reversebits",
651    "round",
652    "rsqrt",
653    "saturate",
654    "sign",
655    "sin",
656    "sincos",
657    "sinh",
658    "smoothstep",
659    "source_mark",
660    "sqrt",
661    "step",
662    "tan",
663    "tanh",
664    "tex1D",
665    "tex1Dbias",
666    "tex1Dgrad",
667    "tex1Dlod",
668    "tex1Dproj",
669    "tex2D",
670    "tex2Dbias",
671    "tex2Dgrad",
672    "tex2Dlod",
673    "tex2Dproj",
674    "tex3D",
675    "tex3Dbias",
676    "tex3Dgrad",
677    "tex3Dlod",
678    "tex3Dproj",
679    "texCUBE",
680    "texCUBEbias",
681    "texCUBEgrad",
682    "texCUBElod",
683    "texCUBEproj",
684    "transpose",
685    "trunc",
686    "CheckAccessFullyMapped",
687    "AddUint64",
688    "NonUniformResourceIndex",
689    "WaveIsFirstLane",
690    "WaveGetLaneIndex",
691    "WaveGetLaneCount",
692    "WaveActiveAnyTrue",
693    "WaveActiveAllTrue",
694    "WaveActiveAllEqual",
695    "WaveActiveBallot",
696    "WaveReadLaneAt",
697    "WaveReadLaneFirst",
698    "WaveActiveCountBits",
699    "WaveActiveSum",
700    "WaveActiveProduct",
701    "WaveActiveBitAnd",
702    "WaveActiveBitOr",
703    "WaveActiveBitXor",
704    "WaveActiveMin",
705    "WaveActiveMax",
706    "WavePrefixCountBits",
707    "WavePrefixSum",
708    "WavePrefixProduct",
709    "WaveMatch",
710    "WaveMultiPrefixBitAnd",
711    "WaveMultiPrefixBitOr",
712    "WaveMultiPrefixBitXor",
713    "WaveMultiPrefixCountBits",
714    "WaveMultiPrefixProduct",
715    "WaveMultiPrefixSum",
716    "QuadReadLaneAt",
717    "QuadReadAcrossX",
718    "QuadReadAcrossY",
719    "QuadReadAcrossDiagonal",
720    "QuadAny",
721    "QuadAll",
722    "TraceRay",
723    "ReportHit",
724    "CallShader",
725    "IgnoreHit",
726    "AcceptHitAndEndSearch",
727    "DispatchRaysIndex",
728    "DispatchRaysDimensions",
729    "WorldRayOrigin",
730    "WorldRayDirection",
731    "ObjectRayOrigin",
732    "ObjectRayDirection",
733    "RayTMin",
734    "RayTCurrent",
735    "PrimitiveIndex",
736    "InstanceID",
737    "InstanceIndex",
738    "GeometryIndex",
739    "HitKind",
740    "RayFlags",
741    "ObjectToWorld",
742    "WorldToObject",
743    "ObjectToWorld3x4",
744    "WorldToObject3x4",
745    "ObjectToWorld4x3",
746    "WorldToObject4x3",
747    "dot4add_u8packed",
748    "dot4add_i8packed",
749    "dot2add",
750    "unpack_s8s16",
751    "unpack_u8u16",
752    "unpack_s8s32",
753    "unpack_u8u32",
754    "pack_s8",
755    "pack_u8",
756    "pack_clamp_s8",
757    "pack_clamp_u8",
758    "SetMeshOutputCounts",
759    "DispatchMesh",
760    "IsHelperLane",
761    "AllocateRayQuery",
762    "CreateResourceFromHeap",
763    "and",
764    "or",
765    "select",
766    // DXC resource and other types, from https://github.com/microsoft/DirectXShaderCompiler/blob/18c9e114f9c314f93e68fbc72ce207d4ed2e65ae/tools/clang/lib/AST/HlslTypes.cpp#L441-#L572
767    "InputPatch",
768    "OutputPatch",
769    "PointStream",
770    "LineStream",
771    "TriangleStream",
772    "Texture1D",
773    "RWTexture1D",
774    "Texture2D",
775    "RWTexture2D",
776    "Texture2DMS",
777    "RWTexture2DMS",
778    "Texture3D",
779    "RWTexture3D",
780    "TextureCube",
781    "RWTextureCube",
782    "Texture1DArray",
783    "RWTexture1DArray",
784    "Texture2DArray",
785    "RWTexture2DArray",
786    "Texture2DMSArray",
787    "RWTexture2DMSArray",
788    "TextureCubeArray",
789    "RWTextureCubeArray",
790    "FeedbackTexture2D",
791    "FeedbackTexture2DArray",
792    "RasterizerOrderedTexture1D",
793    "RasterizerOrderedTexture2D",
794    "RasterizerOrderedTexture3D",
795    "RasterizerOrderedTexture1DArray",
796    "RasterizerOrderedTexture2DArray",
797    "RasterizerOrderedBuffer",
798    "RasterizerOrderedByteAddressBuffer",
799    "RasterizerOrderedStructuredBuffer",
800    "ByteAddressBuffer",
801    "RWByteAddressBuffer",
802    "StructuredBuffer",
803    "RWStructuredBuffer",
804    "AppendStructuredBuffer",
805    "ConsumeStructuredBuffer",
806    "Buffer",
807    "RWBuffer",
808    "SamplerState",
809    "SamplerComparisonState",
810    "ConstantBuffer",
811    "TextureBuffer",
812    "RaytracingAccelerationStructure",
813    // DXC templated types, from https://github.com/microsoft/DirectXShaderCompiler/blob/18c9e114f9c314f93e68fbc72ce207d4ed2e65ae/tools/clang/lib/AST/ASTContextHLSL.cpp
814    // look for `BuiltinTypeDeclBuilder`
815    "matrix",
816    "vector",
817    "TextureBuffer",
818    "ConstantBuffer",
819    "RayQuery",
820    "RayDesc",
821    // Naga utilities
822    super::writer::MODF_FUNCTION,
823    super::writer::FREXP_FUNCTION,
824    super::writer::EXTRACT_BITS_FUNCTION,
825    super::writer::INSERT_BITS_FUNCTION,
826    super::writer::SAMPLER_HEAP_VAR,
827    super::writer::COMPARISON_SAMPLER_HEAP_VAR,
828    super::writer::SAMPLE_EXTERNAL_TEXTURE_FUNCTION,
829    super::writer::ABS_FUNCTION,
830    super::writer::DIV_FUNCTION,
831    super::writer::MOD_FUNCTION,
832    super::writer::NEG_FUNCTION,
833    super::writer::F2I32_FUNCTION,
834    super::writer::F2U32_FUNCTION,
835    super::writer::F2I64_FUNCTION,
836    super::writer::F2U64_FUNCTION,
837    super::writer::IMAGE_LOAD_EXTERNAL_FUNCTION,
838    super::writer::IMAGE_SAMPLE_BASE_CLAMP_TO_EDGE_FUNCTION,
839];
840
841// DXC scalar types, from https://github.com/microsoft/DirectXShaderCompiler/blob/18c9e114f9c314f93e68fbc72ce207d4ed2e65ae/tools/clang/lib/AST/ASTContextHLSL.cpp#L48-L254
842// + vector and matrix shorthands
843pub const TYPES: &[&str] = &{
844    const L: usize = 23 * (1 + 4 + 4 * 4);
845    let mut res = [""; L];
846    let mut c = 0;
847
848    /// For each scalar type, it will additionally generate vector and matrix shorthands
849    macro_rules! generate {
850        ([$($roots:literal),*], $x:tt) => {
851            $(
852                generate!(@inner push $roots);
853                generate!(@inner $roots, $x);
854            )*
855        };
856
857        (@inner $root:literal, [$($x:literal),*]) => {
858            generate!(@inner vector $root, $($x)*);
859            generate!(@inner matrix $root, $($x)*);
860        };
861
862        (@inner vector $root:literal, $($x:literal)*) => {
863            $(
864                generate!(@inner push concat!($root, $x));
865            )*
866        };
867
868        (@inner matrix $root:literal, $($x:literal)*) => {
869            // Duplicate the list
870            generate!(@inner matrix $root, $($x)*; $($x)*);
871        };
872
873        // The head/tail recursion: pick the first element of the first list and recursively do it for the tail.
874        (@inner matrix $root:literal, $head:literal $($tail:literal)*; $($x:literal)*) => {
875            $(
876                generate!(@inner push concat!($root, $head, "x", $x));
877            )*
878            generate!(@inner matrix $root, $($tail)*; $($x)*);
879
880        };
881
882        // The end of iteration: we exhausted the list
883        (@inner matrix $root:literal, ; $($x:literal)*) => {};
884
885        (@inner push $v:expr) => {
886            res[c] = $v;
887            c += 1;
888        };
889    }
890
891    generate!(
892        [
893            "bool",
894            "int",
895            "uint",
896            "dword",
897            "half",
898            "float",
899            "double",
900            "min10float",
901            "min16float",
902            "min12int",
903            "min16int",
904            "min16uint",
905            "int16_t",
906            "int32_t",
907            "int64_t",
908            "uint16_t",
909            "uint32_t",
910            "uint64_t",
911            "float16_t",
912            "float32_t",
913            "float64_t",
914            "int8_t4_packed",
915            "uint8_t4_packed"
916        ],
917        ["1", "2", "3", "4"]
918    );
919
920    debug_assert!(c == L);
921
922    res
923};
924
925/// The above set of reserved keywords, turned into a cached HashSet. This saves
926/// significant time during [`Namer::reset`](crate::proc::Namer::reset).
927///
928/// See <https://github.com/gfx-rs/wgpu/pull/7338> for benchmarks.
929pub static RESERVED_SET: RacyLock<KeywordSet> =
930    RacyLock::new(|| KeywordSet::from_iter(RESERVED.iter().chain(TYPES)));
931
932pub static RESERVED_CASE_INSENSITIVE_SET: RacyLock<CaseInsensitiveKeywordSet> =
933    RacyLock::new(|| CaseInsensitiveKeywordSet::from_iter(RESERVED_CASE_INSENSITIVE));
934
935pub const RESERVED_PREFIXES: &[&str] = &[
936    "__dynamic_buffer_offsets",
937    super::help::IMAGE_STORAGE_LOAD_SCALAR_WRAPPER,
938];