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