shaderkit 0.7.0 → 0.8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/src/constants.ts CHANGED
@@ -1,1005 +1,1005 @@
1
- // https://w3.org/TR/WGSL/#grammar
2
- export const WGSL_KEYWORDS = [
3
- // 5.2.6 Vector Types
4
- 'vec2',
5
- 'vec2i',
6
- 'vec2u',
7
- 'vec2f',
8
- 'vec2h',
9
- 'vec3',
10
- 'vec3i',
11
- 'vec3u',
12
- 'vec3f',
13
- 'vec3h',
14
- 'vec4',
15
- 'vec4i',
16
- 'vec4u',
17
- 'vec4f',
18
- 'vec4h',
19
-
20
- // 5.2.7 Matrix Types
21
- 'mat2x2',
22
- 'mat2x2f',
23
- 'mat2x2h',
24
- 'mat2x3',
25
- 'mat2x3f',
26
- 'mat2x3h',
27
- 'mat2x4',
28
- 'mat2x4f',
29
- 'mat2x4h',
30
- 'mat3x2',
31
- 'mat3x2f',
32
- 'mat3x2h',
33
- 'mat3x3',
34
- 'mat3x3f',
35
- 'mat3x3h',
36
- 'mat3x4',
37
- 'mat3x4f',
38
- 'mat3x4h',
39
- 'mat4x2',
40
- 'mat4x2f',
41
- 'mat4x2h',
42
- 'mat4x3',
43
- 'mat4x3f',
44
- 'mat4x3h',
45
- 'mat4x4',
46
- 'mat4x4f',
47
- 'mat4x4h',
48
-
49
- // 15.1.1 Type-defining Keywords
50
- 'array',
51
- 'atomic',
52
- 'bool',
53
- 'f32',
54
- 'f16',
55
- 'i32',
56
- // 'mat2x2',
57
- // 'mat2x3',
58
- // 'mat2x4',
59
- // 'mat3x2',
60
- // 'mat3x3',
61
- // 'mat3x4',
62
- // 'mat4x2',
63
- // 'mat4x3',
64
- // 'mat4x4',
65
- 'ptr',
66
- 'sampler',
67
- 'sampler_comparison',
68
- 'texture_1d',
69
- 'texture_2d',
70
- 'texture_2d_array',
71
- 'texture_3d',
72
- 'texture_cube',
73
- 'texture_cube_array',
74
- 'texture_multisampled_2d',
75
- 'texture_storage_1d',
76
- 'texture_storage_2d',
77
- 'texture_storage_2d_array',
78
- 'texture_storage_3d',
79
- 'texture_depth_2d',
80
- 'texture_depth_2d_array',
81
- 'texture_depth_cube',
82
- 'texture_depth_cube_array',
83
- 'texture_depth_multisampled_2d',
84
- 'u32',
85
- // 'vec2',
86
- // 'vec3',
87
- // 'vec4',
88
-
89
- // 15.1.2 Other Keywords
90
- 'alias',
91
- 'bitcast',
92
- 'break',
93
- 'case',
94
- 'const',
95
- 'const_assert',
96
- 'continue',
97
- 'continuing',
98
- 'default',
99
- 'discard',
100
- 'else',
101
- 'enable',
102
- // 'false',
103
- 'fn',
104
- 'for',
105
- 'if',
106
- 'let',
107
- 'loop',
108
- 'override',
109
- 'return',
110
- 'struct',
111
- 'switch',
112
- // 'true',
113
- 'var',
114
- 'while',
115
-
116
- // 15.2 Reserved Words
117
- 'Hullshader',
118
- 'NULL',
119
- 'Self',
120
- 'abstract',
121
- 'active',
122
- 'alignas',
123
- 'alignof',
124
- 'as',
125
- 'asm',
126
- 'asm_fragment',
127
- 'async',
128
- 'attribute',
129
- 'auto',
130
- 'await',
131
- 'become',
132
- 'bf16',
133
- 'binding_array',
134
- 'cast',
135
- 'catch',
136
- 'class',
137
- 'co_await',
138
- 'co_return',
139
- 'co_yield',
140
- 'coherent',
141
- 'column_major',
142
- 'common',
143
- 'compile',
144
- 'compile_fragment',
145
- 'concept',
146
- 'const_cast',
147
- 'consteval',
148
- 'constexpr',
149
- 'constinit',
150
- 'crate',
151
- 'debugger',
152
- 'decltype',
153
- 'delete',
154
- 'demote',
155
- 'demote_to_helper',
156
- 'do',
157
- 'dynamic_cast',
158
- 'enum',
159
- 'explicit',
160
- 'export',
161
- 'extends',
162
- 'extern',
163
- 'external',
164
- 'f64',
165
- 'fallthrough',
166
- 'filter',
167
- 'final',
168
- 'finally',
169
- 'friend',
170
- 'from',
171
- 'fxgroup',
172
- 'get',
173
- 'goto',
174
- 'groupshared',
175
- 'handle',
176
- 'highp',
177
- 'i16',
178
- 'i64',
179
- 'i8',
180
- 'impl',
181
- 'implements',
182
- 'import',
183
- 'inline',
184
- 'instanceof',
185
- 'interface',
186
- 'layout',
187
- 'lowp',
188
- 'macro',
189
- 'macro_rules',
190
- 'match',
191
- 'mediump',
192
- 'meta',
193
- 'mod',
194
- 'module',
195
- 'move',
196
- 'mut',
197
- 'mutable',
198
- 'namespace',
199
- 'new',
200
- 'nil',
201
- 'noexcept',
202
- 'noinline',
203
- 'nointerpolation',
204
- 'noperspective',
205
- 'null',
206
- 'nullptr',
207
- 'of',
208
- 'operator',
209
- 'package',
210
- 'packoffset',
211
- 'partition',
212
- 'pass',
213
- 'patch',
214
- 'pixelfragment',
215
- 'precise',
216
- 'precision',
217
- 'premerge',
218
- 'priv',
219
- 'protected',
220
- 'pub',
221
- 'public',
222
- 'quat',
223
- 'readonly',
224
- 'ref',
225
- 'regardless',
226
- 'register',
227
- 'reinterpret_cast',
228
- 'requires',
229
- 'resource',
230
- 'restrict',
231
- 'self',
232
- 'set',
233
- 'shared',
234
- 'sizeof',
235
- 'smooth',
236
- 'snorm',
237
- 'static',
238
- 'static_assert',
239
- 'static_cast',
240
- 'std',
241
- 'subroutine',
242
- 'super',
243
- 'target',
244
- 'template',
245
- 'this',
246
- 'thread_local',
247
- 'throw',
248
- 'trait',
249
- 'try',
250
- 'type',
251
- 'typedef',
252
- 'typeid',
253
- 'typename',
254
- 'typeof',
255
- 'u16',
256
- 'u64',
257
- 'u8',
258
- 'union',
259
- 'unless',
260
- 'unorm',
261
- 'unsafe',
262
- 'unsized',
263
- 'use',
264
- 'using',
265
- 'varying',
266
- 'virtual',
267
- 'volatile',
268
- 'wgsl',
269
- 'where',
270
- 'with',
271
- 'writeonly',
272
- 'yield',
273
-
274
- // 15.4 Context-Dependent Name Tokens - Attributes
275
- '@align',
276
- '@binding',
277
- '@builtin',
278
- '@compute',
279
- '@const',
280
- '@fragment',
281
- '@group',
282
- '@id',
283
- '@interpolate',
284
- '@invariant',
285
- '@location',
286
- '@size',
287
- '@vertex',
288
- '@workgroup_size',
289
-
290
- // 15.4 Context-Dependent Name Tokens - Interpolation Types
291
- 'perspective',
292
- 'linear',
293
- 'flat',
294
-
295
- // 15.4 Context-Dependent Name Tokens - Interpolation Sampling
296
- 'center',
297
- 'centroid',
298
- 'sample',
299
-
300
- // 15.4 Context-Dependent Name Tokens - Built-in Values
301
- 'vertex_index',
302
- 'instance_index',
303
- 'position',
304
- 'front_facing',
305
- 'frag_depth',
306
- 'local_invocation_id',
307
- 'local_invocation_index',
308
- 'global_invocation_id',
309
- 'workgroup_id',
310
- 'num_workgroups',
311
- 'sample_index',
312
- 'sample_mask',
313
-
314
- // 15.4 Context-Dependent Name Tokens - Access Modes
315
- 'read',
316
- 'write',
317
- 'read_write',
318
-
319
- // 15.4 Context-Dependent Name Tokens - Address Spaces
320
- 'function',
321
- 'private',
322
- 'workgroup',
323
- 'uniform',
324
- 'storage',
325
-
326
- // 15.4 Context-Dependent Name Tokens - Texel Formats
327
- 'rgba8unorm',
328
- 'rgba8snorm',
329
- 'rgba8uint',
330
- 'rgba8sint',
331
- 'rgba16uint',
332
- 'rgba16sint',
333
- 'rgba16float',
334
- 'r32uint',
335
- 'r32sint',
336
- 'r32float',
337
- 'rg32uint',
338
- 'rg32sint',
339
- 'rg32float',
340
- 'rgba32uint',
341
- 'rgba32sint',
342
- 'rgba32float',
343
- 'bgra8unorm',
344
-
345
- // 15.4 Context-Dependent Name Tokens - Extensions
346
- 'f16', // v1 optional
347
-
348
- // 17.1 Logical Built-in Functions
349
- 'all',
350
- 'any',
351
- 'select',
352
-
353
- // 17.2 Array Built-in Functions
354
- 'arrayLength',
355
-
356
- // 17.3 Numeric Built-in Functions
357
- 'abs',
358
- 'acos',
359
- 'acosh',
360
- 'asin',
361
- 'asinh',
362
- 'atan',
363
- 'atanh',
364
- 'atan2',
365
- 'ceil',
366
- 'clamp',
367
- 'cos',
368
- 'cosh',
369
- 'countLeadingZeros',
370
- 'countOneBits',
371
- 'countTrailingZeros',
372
- 'cross',
373
- 'degrees',
374
- 'determinant',
375
- 'distance',
376
- 'dot',
377
- 'exp',
378
- 'exp2',
379
- 'extractBits',
380
- 'faceForward',
381
- 'firstLeadingBit',
382
- 'firstTrailingBit',
383
- 'floor',
384
- 'fma',
385
- 'fract',
386
- 'frexp',
387
- 'insertBits',
388
- 'inverseSqrt',
389
- 'ldexp',
390
- 'length',
391
- 'log',
392
- 'log2',
393
- 'max',
394
- 'min',
395
- 'mix',
396
- 'modf',
397
- 'normalize',
398
- 'pow',
399
- 'quantizeToF16',
400
- 'radians',
401
- 'reflect',
402
- 'refract',
403
- 'reverseBits',
404
- 'round',
405
- 'saturate',
406
- 'sign',
407
- 'sin',
408
- 'sinh',
409
- 'smoothstep',
410
- 'sqrt',
411
- 'step',
412
- 'tan',
413
- 'tanh',
414
- 'transpose',
415
- 'trunc',
416
-
417
- // 17.4 Derivative Built-in Functions
418
- 'dpdx',
419
- 'dpdxCoarse',
420
- 'dpdxFine',
421
- 'dpdy',
422
- 'dpdyCoarse',
423
- 'dpdyFine',
424
- 'fwidth',
425
- 'fwidthCoarse',
426
- 'fwidthFine',
427
-
428
- // 17.5 Texture Built-in Functions
429
- 'textureDimensions',
430
- 'textureGather',
431
- 'textureGatherCompare',
432
- 'textureLoad',
433
- 'textureNumLayers',
434
- 'textureNumLevels',
435
- 'textureNumSamples',
436
- 'textureSample',
437
- 'textureSampleBias',
438
- 'textureSampleCompare',
439
- 'textureSampleCompareLevel',
440
- 'textureSampleGrad',
441
- 'textureSampleLevel',
442
- 'textureSampleBaseClampToEdge',
443
-
444
- // 17.6 Atomic Built-in Functions
445
- 'atomicLoad',
446
- 'atomicStore',
447
- 'atomicAdd',
448
- 'atomicSub',
449
- 'atomicMax',
450
- 'atomicMin',
451
- 'atomicAnd',
452
- 'atomicOr',
453
- 'atomicXor',
454
- 'atomicExchange',
455
- 'atomicCompareExchangeWeak',
456
-
457
- // 17.7 Data Packing Built-in Functions
458
- 'pack4x8snorm',
459
- 'pack4x8unorm',
460
- 'pack2x16snorm',
461
- 'pack2x16unorm',
462
- 'pack2x16float',
463
-
464
- // 17.8 Data Unpacking Built-in Functions
465
- 'unpack4x8snorm',
466
- 'unpack4x8unorm',
467
- 'unpack2x16snorm',
468
- 'unpack2x16unorm',
469
- 'unpack2x16float',
470
-
471
- // 17.9 Synchronization Built-in Functions
472
- 'storageBarrier',
473
- 'workgroupBarrier',
474
- 'workgroupUniformLoad',
475
- ]
476
-
477
- // https://registry.khronos.org/OpenGL/specs/es/3.0/GLSL_ES_Specification_3.00.pdf
478
- // NOTE: restrictions from 5.25-5.26 apply https://registry.khronos.org/webgl/specs/latest/2.0
479
- export const GLSL_KEYWORDS = [
480
- // 3.8 Keywords
481
- 'const',
482
- 'uniform',
483
- 'layout',
484
- 'centroid',
485
- 'flat',
486
- 'smooth',
487
- 'break',
488
- 'continue',
489
- 'do',
490
- 'for',
491
- 'while',
492
- 'switch',
493
- 'case',
494
- 'default',
495
- 'if',
496
- 'else',
497
- 'in',
498
- 'out',
499
- 'inout',
500
- 'float',
501
- 'int',
502
- 'void',
503
- 'bool',
504
- // 'true',
505
- // 'false',
506
- 'invariant',
507
- 'discard',
508
- 'return',
509
- 'mat2',
510
- 'mat3',
511
- 'mat4',
512
- 'mat2x2',
513
- 'mat2x3',
514
- 'mat2x4',
515
- 'mat3x2',
516
- 'mat3x3',
517
- 'mat3x4',
518
- 'mat4x2',
519
- 'mat4x3',
520
- 'mat4x4',
521
- 'vec2',
522
- 'vec3',
523
- 'vec4',
524
- 'ivec2',
525
- 'ivec3',
526
- 'ivec4',
527
- 'bvec2',
528
- 'bvec3',
529
- 'bvec4',
530
- 'uint',
531
- 'uvec2',
532
- 'uvec3',
533
- 'uvec4',
534
- 'lowp',
535
- 'mediump',
536
- 'highp',
537
- 'precision',
538
- 'sampler2D',
539
- 'sampler3D',
540
- 'samplerCube',
541
- 'sampler2DShadow',
542
- 'samplerCubeShadow',
543
- 'sampler2DArray',
544
- 'sampler2DArrayShadow',
545
- 'isampler2D',
546
- 'isampler3D',
547
- 'isamplerCube',
548
- 'isampler2DArray',
549
- 'usampler2D',
550
- 'usampler3D',
551
- 'usamplerCube',
552
- 'usampler2DArray',
553
- 'struct',
554
-
555
- // 3.8 Keywords - Reserved for future use
556
- 'attribute',
557
- 'varying',
558
- 'coherent',
559
- 'volatile',
560
- 'restrict',
561
- 'readonly',
562
- 'writeonly',
563
- 'resource',
564
- 'atomic_uint',
565
- 'noperspective',
566
- 'patch',
567
- 'sample',
568
- 'subroutine',
569
- 'common',
570
- 'partition',
571
- 'active',
572
- 'asm',
573
- 'class',
574
- 'union',
575
- 'enum',
576
- 'typedef',
577
- 'template',
578
- 'this',
579
- 'goto',
580
- 'inline',
581
- 'noinline',
582
- 'volatile',
583
- 'public',
584
- 'static',
585
- 'extern',
586
- 'external',
587
- 'interface',
588
- 'long',
589
- 'short',
590
- 'double',
591
- 'half',
592
- 'fixed',
593
- 'unsigned',
594
- 'superp',
595
- 'input',
596
- 'output',
597
- 'hvec2',
598
- 'hvec3',
599
- 'hvec4',
600
- 'dvec2',
601
- 'dvec3',
602
- 'dvec4',
603
- 'fvec2',
604
- 'fvec3',
605
- 'fvec4',
606
- 'sampler3DRect',
607
- 'filter',
608
- 'image1D',
609
- 'image2D',
610
- 'image3D',
611
- 'imageCube',
612
- 'iimage1D',
613
- 'iimage2D',
614
- 'iimage3D',
615
- 'iimageCube',
616
- 'uimage1D',
617
- 'uimage2D',
618
- 'uimage3D',
619
- 'uimageCube',
620
- 'image1DArray',
621
- 'image2DArray',
622
- 'iimage1DArray',
623
- 'iimage2DArray',
624
- 'uimage1DArray',
625
- 'uimage2DArray',
626
- 'imageBuffer',
627
- 'iimageBuffer',
628
- 'uimageBuffer',
629
- 'sampler1D',
630
- 'sampler1DShadow',
631
- 'sampler1DArray',
632
- 'sampler1DArrayShadow',
633
- 'isampler1D',
634
- 'isampler1DArray',
635
- 'usampler1D',
636
- 'usampler1DArray',
637
- 'sampler2DRect',
638
- 'sampler2DRectShadow',
639
- 'isampler2DRect',
640
- 'usampler2DRect',
641
- 'samplerBuffer',
642
- 'isamplerBuffer',
643
- 'usamplerBuffer',
644
- 'sampler2DMS',
645
- 'isampler2DMS',
646
- 'usampler2DMS',
647
- 'sampler2DMSArray',
648
- 'isampler2DMSArray',
649
- 'usampler2DMSArray',
650
- 'sizeof',
651
- 'cast',
652
- 'namespace',
653
- 'using',
654
-
655
- // 3.5 Preprocessor
656
- '#define',
657
- '#undef',
658
- '#if',
659
- '#ifdef',
660
- '#ifndef',
661
- '#else',
662
- '#elif',
663
- '#endif',
664
- '#error',
665
- '#pragma',
666
- '#extension',
667
- '#version',
668
- '#line',
669
-
670
- // 3.5 Preprocessor - Operators
671
- 'defined',
672
-
673
- // 3.5 Preprocessor - Macros
674
- '__LINE__',
675
- '__FILE__',
676
- '__VERSION__',
677
- 'GL_ES',
678
-
679
- // 7.1 Vertex Shader Special Variables
680
- 'gl_VertexID',
681
- 'gl_InstanceID',
682
- 'gl_Position',
683
- 'gl_PointSize',
684
-
685
- // 7.2 Fragment Shader Special Variables
686
- 'gl_FragCoord',
687
- 'gl_FrontFacing',
688
- 'gl_FragDepth',
689
- 'gl_PointCoord',
690
-
691
- // 7.3 Built-in Constants
692
- 'gl_MaxVertexAttribs',
693
- 'gl_MaxVertexUniformVectors',
694
- 'gl_MaxVertexOutputVectors',
695
- 'gl_MaxFragmentInputVectors',
696
- 'gl_MaxVertexTextureImageUnits',
697
- 'gl_MaxCombinedTextureImageUnits',
698
- 'gl_MaxTextureImageUnits',
699
- 'gl_MaxFragmentUniformVectors',
700
- 'gl_MaxDrawBuffers',
701
- 'gl_MinProgramTexelOffset',
702
- 'gl_MaxProgramTexelOffset',
703
-
704
- // 7.4 Built-in Uniform State
705
- 'gl_DepthRangeParameters',
706
- 'gl_DepthRange',
707
-
708
- // 8.1 Angle and Trigonometry Functions
709
- 'radians',
710
- 'degrees',
711
- 'sin',
712
- 'cos',
713
- 'tan',
714
- 'asin',
715
- 'acos',
716
- 'atan',
717
- 'sinh',
718
- 'cosh',
719
- 'tanh',
720
- 'asinh',
721
- 'acosh',
722
- 'atanh',
723
-
724
- // 8.2 Exponential Functions
725
- 'pow',
726
- 'exp',
727
- 'log',
728
- 'exp2',
729
- 'log2',
730
- 'sqrt',
731
- 'inversesqrt',
732
-
733
- // 8.3 Common Functions
734
- 'abs',
735
- 'sign',
736
- 'floor',
737
- 'trunc',
738
- 'round',
739
- 'roundEven',
740
- 'ceil',
741
- 'fract',
742
- 'mod',
743
- 'modf',
744
- 'min',
745
- 'max',
746
- 'clamp',
747
- 'mix',
748
- 'step',
749
- 'smoothstep',
750
- 'isnan',
751
- 'isinf',
752
- 'floatBitsToInt',
753
- 'floatBitsToUint',
754
- 'intBitsToFloat',
755
- 'uintBitsToFloat',
756
-
757
- // 8.4 Floating-Point Pack and Unpack Functions
758
- 'packSnorm2x16',
759
- 'unpackSnorm2x16',
760
- 'packUnorm2x16',
761
- 'unpackUnorm2x16',
762
- 'packHalf2x16',
763
- 'unpackHalf2x16',
764
-
765
- // 8.5 Geometric Functions
766
- 'length',
767
- 'distance',
768
- 'dot',
769
- 'cross',
770
- 'normalize',
771
- 'faceforward',
772
- 'reflect',
773
- 'refract',
774
- 'matrixCompMult',
775
- 'outerProduct',
776
- 'transpose',
777
- 'determinant',
778
- 'inverse',
779
-
780
- // 8.7 Vector Relational Functions
781
- 'lessThan',
782
- 'lessThanEqual',
783
- 'greaterThan',
784
- 'greaterThanEqual',
785
- 'equal',
786
- 'notEqual',
787
- 'any',
788
- 'all',
789
- 'not',
790
-
791
- // 8.8 Texture Lookup Functions
792
- 'textureSize',
793
- 'texture',
794
- 'textureProj',
795
- 'textureLod',
796
- 'textureOffset',
797
- 'texelFetch',
798
- 'texelFetchOffset',
799
- 'textureProjOffset',
800
- 'textureLodOffset',
801
- 'textureProjLod',
802
- 'textureProjLodOffset',
803
- 'textureGrad',
804
- 'textureGradOffset',
805
- 'textureProjGrad',
806
- 'textureProjGradOffset',
807
-
808
- // 8.9 Fragment Processing Functions
809
- 'dFdx',
810
- 'dFdy',
811
- 'fwidth',
812
-
813
- // Additional directives
814
- '#include',
815
-
816
- // WebGL1 (three.js)
817
- // 'attribute',
818
- // 'varying',
819
- 'gl_FragColor',
820
- 'gl_FragDepthEXT',
821
- 'texture2D',
822
- 'textureCube',
823
- 'texture2DProj',
824
- 'texture2DLodEXT',
825
- 'texture2DProjLodEXT',
826
- 'textureCubeLodEXT',
827
- 'texture2DGradEXT',
828
- 'texture2DProjGradEXT',
829
- 'textureCubeGradEXT',
830
-
831
- // WEBGL_multi_draw https://registry.khronos.org/webgl/extensions/WEBGL_multi_draw
832
- 'gl_DrawID', // vertex only
833
-
834
- // OVR_multiview2 https://registry.khronos.org/webgl/extensions/OVR_multiview2
835
- // OCULUS_multiview https://github.com/KhronosGroup/WebGL/issues/2912
836
- 'gl_ViewID_OVR',
837
- 'GL_OVR_multiview2',
838
-
839
- // GLSL ES 3.1
840
- // https://registry.khronos.org/OpenGL/specs/es/3.1/GLSL_ES_Specification_3.10.pdf
841
-
842
- // 4.3 Storage Qualifiers
843
- 'buffer',
844
- 'shared',
845
-
846
- // 7.1.2 Fragment Shader Special Variables
847
- 'gl_HelperInvocation',
848
-
849
- // 7.1.3 Compute Shader Special Variables
850
- 'gl_NumWorkGroups',
851
- 'gl_WorkGroupSize',
852
- 'gl_WorkGroupID',
853
- 'gl_LocalInvocationID',
854
- 'gl_GlobalInvocationID',
855
- 'gl_LocalInvocationIndex',
856
-
857
- // 7.2 Built-In Constants
858
- 'gl_MaxImageUnits',
859
- 'gl_MaxVertexImageUniforms',
860
- 'gl_MaxFragmentImageUniforms',
861
- 'gl_MaxComputeImageUniforms',
862
- 'gl_MaxCombinedImageUniforms',
863
- 'gl_MaxCombinedShaderOutputResources',
864
- 'gl_MaxComputeWorkGroupCount',
865
- 'gl_MaxComputeWorkGroupSize',
866
- 'gl_MaxComputeUniformComponents',
867
- 'gl_MaxComputeTextureImageUnits',
868
- 'gl_MaxComputeAtomicCounters',
869
- 'gl_MaxComputeAtomicCounterBuffers',
870
- 'gl_MaxVertexAtomicCounters',
871
- 'gl_MaxFragmentAtomicCounters',
872
- 'gl_MaxCombinedAtomicCounters',
873
- 'gl_MaxAtomicCounterBindings',
874
- 'gl_MaxFragmentAtomicCounterBuffers',
875
- 'gl_MaxVertexAtomicCounterBuffers',
876
- 'gl_MaxCombinedAtomicCounterBuffers',
877
- 'gl_MaxAtomicCounterBufferSize',
878
-
879
- // 8 Built-in Functions
880
- 'imageSize',
881
- 'packUnorm4x8',
882
- 'packSnorm4x8',
883
- 'unpackUnorm4x8',
884
- 'unpackSnorm4x8',
885
-
886
- // 8.8 Integer Functions
887
- 'bitfieldExtract',
888
- 'bitfieldInsert',
889
- 'bitfieldReverse',
890
- 'bitCount',
891
- 'findLSB',
892
- 'findMSB',
893
- 'uaddCarry',
894
- 'usubBorrow',
895
- 'umulExtended',
896
- 'imulExtended',
897
-
898
- // 8.10 Atomic-Counter Functions
899
- 'atomicCounterIncrement',
900
- 'atomicCounterDecrement',
901
- 'atomicCounter',
902
-
903
- // 8.11 Atomic Memory Functions
904
- 'atomicAdd',
905
- 'atomicMin',
906
- 'atomicMax',
907
- 'atomicAnd',
908
- 'atomicOr',
909
- 'atomicXor',
910
- 'atomicExchange',
911
- 'atomicCompSwap',
912
-
913
- // 8.12 Image Functions
914
- 'imageLoad',
915
- 'imageStore',
916
-
917
- // 8.14 Shader Invocation Control Functions
918
- 'barrier',
919
-
920
- // 8.15 Shader Memory Control Functions
921
- 'memoryBarrier',
922
- 'memoryBarrierAtomicCounter',
923
- 'memoryBarrierBuffer',
924
- 'memoryBarrierImage',
925
- 'memoryBarrierShared',
926
- 'groupMemoryBarrier',
927
- ]
928
-
929
- const SYMBOLS = [
930
- // Comments
931
- '//',
932
- '/*',
933
- '*/',
934
-
935
- // Punctuation
936
- ':',
937
- ',',
938
- '.',
939
- '{',
940
- '[',
941
- '(',
942
- '?',
943
- '}',
944
- ']',
945
- ')',
946
- ';',
947
-
948
- // Unary
949
- '~',
950
- '--',
951
- '++',
952
- '!',
953
-
954
- // Binary
955
- '&',
956
- '|',
957
- '^',
958
- '/',
959
- '==',
960
- '>',
961
- '>=',
962
- '<',
963
- '<=',
964
- '&&',
965
- '||',
966
- '^^',
967
- '-',
968
- '*',
969
- '!=',
970
- '+',
971
- '%',
972
- '<<',
973
- '>>',
974
-
975
- // Binary assignment
976
- '=',
977
- '+=',
978
- '&=',
979
- '|=',
980
- '^=',
981
- '/=',
982
- '*=',
983
- '%=',
984
- '<<=',
985
- '>>=',
986
- '-=',
987
- ]
988
-
989
- // GLSL 3.2 Character Set, 5.1 Operators
990
- export const GLSL_SYMBOLS = [
991
- ...SYMBOLS,
992
- // Preprocessor
993
- '#',
994
- // Line continuation
995
- '\\',
996
- ]
997
-
998
- // WGSL 15.3 Syntactic Tokens
999
- export const WGSL_SYMBOLS = [
1000
- ...SYMBOLS,
1001
- // Function arrow
1002
- '->',
1003
- // Attribute
1004
- '@',
1005
- ]
1
+ // https://w3.org/TR/WGSL/#grammar
2
+ export const WGSL_KEYWORDS = [
3
+ // 5.2.6 Vector Types
4
+ 'vec2',
5
+ 'vec2i',
6
+ 'vec2u',
7
+ 'vec2f',
8
+ 'vec2h',
9
+ 'vec3',
10
+ 'vec3i',
11
+ 'vec3u',
12
+ 'vec3f',
13
+ 'vec3h',
14
+ 'vec4',
15
+ 'vec4i',
16
+ 'vec4u',
17
+ 'vec4f',
18
+ 'vec4h',
19
+
20
+ // 5.2.7 Matrix Types
21
+ 'mat2x2',
22
+ 'mat2x2f',
23
+ 'mat2x2h',
24
+ 'mat2x3',
25
+ 'mat2x3f',
26
+ 'mat2x3h',
27
+ 'mat2x4',
28
+ 'mat2x4f',
29
+ 'mat2x4h',
30
+ 'mat3x2',
31
+ 'mat3x2f',
32
+ 'mat3x2h',
33
+ 'mat3x3',
34
+ 'mat3x3f',
35
+ 'mat3x3h',
36
+ 'mat3x4',
37
+ 'mat3x4f',
38
+ 'mat3x4h',
39
+ 'mat4x2',
40
+ 'mat4x2f',
41
+ 'mat4x2h',
42
+ 'mat4x3',
43
+ 'mat4x3f',
44
+ 'mat4x3h',
45
+ 'mat4x4',
46
+ 'mat4x4f',
47
+ 'mat4x4h',
48
+
49
+ // 15.1.1 Type-defining Keywords
50
+ 'array',
51
+ 'atomic',
52
+ 'bool',
53
+ 'f32',
54
+ 'f16',
55
+ 'i32',
56
+ // 'mat2x2',
57
+ // 'mat2x3',
58
+ // 'mat2x4',
59
+ // 'mat3x2',
60
+ // 'mat3x3',
61
+ // 'mat3x4',
62
+ // 'mat4x2',
63
+ // 'mat4x3',
64
+ // 'mat4x4',
65
+ 'ptr',
66
+ 'sampler',
67
+ 'sampler_comparison',
68
+ 'texture_1d',
69
+ 'texture_2d',
70
+ 'texture_2d_array',
71
+ 'texture_3d',
72
+ 'texture_cube',
73
+ 'texture_cube_array',
74
+ 'texture_multisampled_2d',
75
+ 'texture_storage_1d',
76
+ 'texture_storage_2d',
77
+ 'texture_storage_2d_array',
78
+ 'texture_storage_3d',
79
+ 'texture_depth_2d',
80
+ 'texture_depth_2d_array',
81
+ 'texture_depth_cube',
82
+ 'texture_depth_cube_array',
83
+ 'texture_depth_multisampled_2d',
84
+ 'u32',
85
+ // 'vec2',
86
+ // 'vec3',
87
+ // 'vec4',
88
+
89
+ // 15.1.2 Other Keywords
90
+ 'alias',
91
+ 'bitcast',
92
+ 'break',
93
+ 'case',
94
+ 'const',
95
+ 'const_assert',
96
+ 'continue',
97
+ 'continuing',
98
+ 'default',
99
+ 'discard',
100
+ 'else',
101
+ 'enable',
102
+ // 'false',
103
+ 'fn',
104
+ 'for',
105
+ 'if',
106
+ 'let',
107
+ 'loop',
108
+ 'override',
109
+ 'return',
110
+ 'struct',
111
+ 'switch',
112
+ // 'true',
113
+ 'var',
114
+ 'while',
115
+
116
+ // 15.2 Reserved Words
117
+ 'Hullshader',
118
+ 'NULL',
119
+ 'Self',
120
+ 'abstract',
121
+ 'active',
122
+ 'alignas',
123
+ 'alignof',
124
+ 'as',
125
+ 'asm',
126
+ 'asm_fragment',
127
+ 'async',
128
+ 'attribute',
129
+ 'auto',
130
+ 'await',
131
+ 'become',
132
+ 'bf16',
133
+ 'binding_array',
134
+ 'cast',
135
+ 'catch',
136
+ 'class',
137
+ 'co_await',
138
+ 'co_return',
139
+ 'co_yield',
140
+ 'coherent',
141
+ 'column_major',
142
+ 'common',
143
+ 'compile',
144
+ 'compile_fragment',
145
+ 'concept',
146
+ 'const_cast',
147
+ 'consteval',
148
+ 'constexpr',
149
+ 'constinit',
150
+ 'crate',
151
+ 'debugger',
152
+ 'decltype',
153
+ 'delete',
154
+ 'demote',
155
+ 'demote_to_helper',
156
+ 'do',
157
+ 'dynamic_cast',
158
+ 'enum',
159
+ 'explicit',
160
+ 'export',
161
+ 'extends',
162
+ 'extern',
163
+ 'external',
164
+ 'f64',
165
+ 'fallthrough',
166
+ 'filter',
167
+ 'final',
168
+ 'finally',
169
+ 'friend',
170
+ 'from',
171
+ 'fxgroup',
172
+ 'get',
173
+ 'goto',
174
+ 'groupshared',
175
+ 'handle',
176
+ 'highp',
177
+ 'i16',
178
+ 'i64',
179
+ 'i8',
180
+ 'impl',
181
+ 'implements',
182
+ 'import',
183
+ 'inline',
184
+ 'instanceof',
185
+ 'interface',
186
+ 'layout',
187
+ 'lowp',
188
+ 'macro',
189
+ 'macro_rules',
190
+ 'match',
191
+ 'mediump',
192
+ 'meta',
193
+ 'mod',
194
+ 'module',
195
+ 'move',
196
+ 'mut',
197
+ 'mutable',
198
+ 'namespace',
199
+ 'new',
200
+ 'nil',
201
+ 'noexcept',
202
+ 'noinline',
203
+ 'nointerpolation',
204
+ 'noperspective',
205
+ 'null',
206
+ 'nullptr',
207
+ 'of',
208
+ 'operator',
209
+ 'package',
210
+ 'packoffset',
211
+ 'partition',
212
+ 'pass',
213
+ 'patch',
214
+ 'pixelfragment',
215
+ 'precise',
216
+ 'precision',
217
+ 'premerge',
218
+ 'priv',
219
+ 'protected',
220
+ 'pub',
221
+ 'public',
222
+ 'quat',
223
+ 'readonly',
224
+ 'ref',
225
+ 'regardless',
226
+ 'register',
227
+ 'reinterpret_cast',
228
+ 'requires',
229
+ 'resource',
230
+ 'restrict',
231
+ 'self',
232
+ 'set',
233
+ 'shared',
234
+ 'sizeof',
235
+ 'smooth',
236
+ 'snorm',
237
+ 'static',
238
+ 'static_assert',
239
+ 'static_cast',
240
+ 'std',
241
+ 'subroutine',
242
+ 'super',
243
+ 'target',
244
+ 'template',
245
+ 'this',
246
+ 'thread_local',
247
+ 'throw',
248
+ 'trait',
249
+ 'try',
250
+ 'type',
251
+ 'typedef',
252
+ 'typeid',
253
+ 'typename',
254
+ 'typeof',
255
+ 'u16',
256
+ 'u64',
257
+ 'u8',
258
+ 'union',
259
+ 'unless',
260
+ 'unorm',
261
+ 'unsafe',
262
+ 'unsized',
263
+ 'use',
264
+ 'using',
265
+ 'varying',
266
+ 'virtual',
267
+ 'volatile',
268
+ 'wgsl',
269
+ 'where',
270
+ 'with',
271
+ 'writeonly',
272
+ 'yield',
273
+
274
+ // 15.4 Context-Dependent Name Tokens - Attributes
275
+ '@align',
276
+ '@binding',
277
+ '@builtin',
278
+ '@compute',
279
+ '@const',
280
+ '@fragment',
281
+ '@group',
282
+ '@id',
283
+ '@interpolate',
284
+ '@invariant',
285
+ '@location',
286
+ '@size',
287
+ '@vertex',
288
+ '@workgroup_size',
289
+
290
+ // 15.4 Context-Dependent Name Tokens - Interpolation Types
291
+ 'perspective',
292
+ 'linear',
293
+ 'flat',
294
+
295
+ // 15.4 Context-Dependent Name Tokens - Interpolation Sampling
296
+ 'center',
297
+ 'centroid',
298
+ 'sample',
299
+
300
+ // 15.4 Context-Dependent Name Tokens - Built-in Values
301
+ 'vertex_index',
302
+ 'instance_index',
303
+ 'position',
304
+ 'front_facing',
305
+ 'frag_depth',
306
+ 'local_invocation_id',
307
+ 'local_invocation_index',
308
+ 'global_invocation_id',
309
+ 'workgroup_id',
310
+ 'num_workgroups',
311
+ 'sample_index',
312
+ 'sample_mask',
313
+
314
+ // 15.4 Context-Dependent Name Tokens - Access Modes
315
+ 'read',
316
+ 'write',
317
+ 'read_write',
318
+
319
+ // 15.4 Context-Dependent Name Tokens - Address Spaces
320
+ 'function',
321
+ 'private',
322
+ 'workgroup',
323
+ 'uniform',
324
+ 'storage',
325
+
326
+ // 15.4 Context-Dependent Name Tokens - Texel Formats
327
+ 'rgba8unorm',
328
+ 'rgba8snorm',
329
+ 'rgba8uint',
330
+ 'rgba8sint',
331
+ 'rgba16uint',
332
+ 'rgba16sint',
333
+ 'rgba16float',
334
+ 'r32uint',
335
+ 'r32sint',
336
+ 'r32float',
337
+ 'rg32uint',
338
+ 'rg32sint',
339
+ 'rg32float',
340
+ 'rgba32uint',
341
+ 'rgba32sint',
342
+ 'rgba32float',
343
+ 'bgra8unorm',
344
+
345
+ // 15.4 Context-Dependent Name Tokens - Extensions
346
+ 'f16', // v1 optional
347
+
348
+ // 17.1 Logical Built-in Functions
349
+ 'all',
350
+ 'any',
351
+ 'select',
352
+
353
+ // 17.2 Array Built-in Functions
354
+ 'arrayLength',
355
+
356
+ // 17.3 Numeric Built-in Functions
357
+ 'abs',
358
+ 'acos',
359
+ 'acosh',
360
+ 'asin',
361
+ 'asinh',
362
+ 'atan',
363
+ 'atanh',
364
+ 'atan2',
365
+ 'ceil',
366
+ 'clamp',
367
+ 'cos',
368
+ 'cosh',
369
+ 'countLeadingZeros',
370
+ 'countOneBits',
371
+ 'countTrailingZeros',
372
+ 'cross',
373
+ 'degrees',
374
+ 'determinant',
375
+ 'distance',
376
+ 'dot',
377
+ 'exp',
378
+ 'exp2',
379
+ 'extractBits',
380
+ 'faceForward',
381
+ 'firstLeadingBit',
382
+ 'firstTrailingBit',
383
+ 'floor',
384
+ 'fma',
385
+ 'fract',
386
+ 'frexp',
387
+ 'insertBits',
388
+ 'inverseSqrt',
389
+ 'ldexp',
390
+ 'length',
391
+ 'log',
392
+ 'log2',
393
+ 'max',
394
+ 'min',
395
+ 'mix',
396
+ 'modf',
397
+ 'normalize',
398
+ 'pow',
399
+ 'quantizeToF16',
400
+ 'radians',
401
+ 'reflect',
402
+ 'refract',
403
+ 'reverseBits',
404
+ 'round',
405
+ 'saturate',
406
+ 'sign',
407
+ 'sin',
408
+ 'sinh',
409
+ 'smoothstep',
410
+ 'sqrt',
411
+ 'step',
412
+ 'tan',
413
+ 'tanh',
414
+ 'transpose',
415
+ 'trunc',
416
+
417
+ // 17.4 Derivative Built-in Functions
418
+ 'dpdx',
419
+ 'dpdxCoarse',
420
+ 'dpdxFine',
421
+ 'dpdy',
422
+ 'dpdyCoarse',
423
+ 'dpdyFine',
424
+ 'fwidth',
425
+ 'fwidthCoarse',
426
+ 'fwidthFine',
427
+
428
+ // 17.5 Texture Built-in Functions
429
+ 'textureDimensions',
430
+ 'textureGather',
431
+ 'textureGatherCompare',
432
+ 'textureLoad',
433
+ 'textureNumLayers',
434
+ 'textureNumLevels',
435
+ 'textureNumSamples',
436
+ 'textureSample',
437
+ 'textureSampleBias',
438
+ 'textureSampleCompare',
439
+ 'textureSampleCompareLevel',
440
+ 'textureSampleGrad',
441
+ 'textureSampleLevel',
442
+ 'textureSampleBaseClampToEdge',
443
+
444
+ // 17.6 Atomic Built-in Functions
445
+ 'atomicLoad',
446
+ 'atomicStore',
447
+ 'atomicAdd',
448
+ 'atomicSub',
449
+ 'atomicMax',
450
+ 'atomicMin',
451
+ 'atomicAnd',
452
+ 'atomicOr',
453
+ 'atomicXor',
454
+ 'atomicExchange',
455
+ 'atomicCompareExchangeWeak',
456
+
457
+ // 17.7 Data Packing Built-in Functions
458
+ 'pack4x8snorm',
459
+ 'pack4x8unorm',
460
+ 'pack2x16snorm',
461
+ 'pack2x16unorm',
462
+ 'pack2x16float',
463
+
464
+ // 17.8 Data Unpacking Built-in Functions
465
+ 'unpack4x8snorm',
466
+ 'unpack4x8unorm',
467
+ 'unpack2x16snorm',
468
+ 'unpack2x16unorm',
469
+ 'unpack2x16float',
470
+
471
+ // 17.9 Synchronization Built-in Functions
472
+ 'storageBarrier',
473
+ 'workgroupBarrier',
474
+ 'workgroupUniformLoad',
475
+ ]
476
+
477
+ // https://registry.khronos.org/OpenGL/specs/es/3.0/GLSL_ES_Specification_3.00.pdf
478
+ // NOTE: restrictions from 5.25-5.26 apply https://registry.khronos.org/webgl/specs/latest/2.0
479
+ export const GLSL_KEYWORDS = [
480
+ // 3.8 Keywords
481
+ 'const',
482
+ 'uniform',
483
+ 'layout',
484
+ 'centroid',
485
+ 'flat',
486
+ 'smooth',
487
+ 'break',
488
+ 'continue',
489
+ 'do',
490
+ 'for',
491
+ 'while',
492
+ 'switch',
493
+ 'case',
494
+ 'default',
495
+ 'if',
496
+ 'else',
497
+ 'in',
498
+ 'out',
499
+ 'inout',
500
+ 'float',
501
+ 'int',
502
+ 'void',
503
+ 'bool',
504
+ // 'true',
505
+ // 'false',
506
+ 'invariant',
507
+ 'discard',
508
+ 'return',
509
+ 'mat2',
510
+ 'mat3',
511
+ 'mat4',
512
+ 'mat2x2',
513
+ 'mat2x3',
514
+ 'mat2x4',
515
+ 'mat3x2',
516
+ 'mat3x3',
517
+ 'mat3x4',
518
+ 'mat4x2',
519
+ 'mat4x3',
520
+ 'mat4x4',
521
+ 'vec2',
522
+ 'vec3',
523
+ 'vec4',
524
+ 'ivec2',
525
+ 'ivec3',
526
+ 'ivec4',
527
+ 'bvec2',
528
+ 'bvec3',
529
+ 'bvec4',
530
+ 'uint',
531
+ 'uvec2',
532
+ 'uvec3',
533
+ 'uvec4',
534
+ 'lowp',
535
+ 'mediump',
536
+ 'highp',
537
+ 'precision',
538
+ 'sampler2D',
539
+ 'sampler3D',
540
+ 'samplerCube',
541
+ 'sampler2DShadow',
542
+ 'samplerCubeShadow',
543
+ 'sampler2DArray',
544
+ 'sampler2DArrayShadow',
545
+ 'isampler2D',
546
+ 'isampler3D',
547
+ 'isamplerCube',
548
+ 'isampler2DArray',
549
+ 'usampler2D',
550
+ 'usampler3D',
551
+ 'usamplerCube',
552
+ 'usampler2DArray',
553
+ 'struct',
554
+
555
+ // 3.8 Keywords - Reserved for future use
556
+ 'attribute',
557
+ 'varying',
558
+ 'coherent',
559
+ 'volatile',
560
+ 'restrict',
561
+ 'readonly',
562
+ 'writeonly',
563
+ 'resource',
564
+ 'atomic_uint',
565
+ 'noperspective',
566
+ 'patch',
567
+ 'sample',
568
+ 'subroutine',
569
+ 'common',
570
+ 'partition',
571
+ 'active',
572
+ 'asm',
573
+ 'class',
574
+ 'union',
575
+ 'enum',
576
+ 'typedef',
577
+ 'template',
578
+ 'this',
579
+ 'goto',
580
+ 'inline',
581
+ 'noinline',
582
+ 'volatile',
583
+ 'public',
584
+ 'static',
585
+ 'extern',
586
+ 'external',
587
+ 'interface',
588
+ 'long',
589
+ 'short',
590
+ 'double',
591
+ 'half',
592
+ 'fixed',
593
+ 'unsigned',
594
+ 'superp',
595
+ 'input',
596
+ 'output',
597
+ 'hvec2',
598
+ 'hvec3',
599
+ 'hvec4',
600
+ 'dvec2',
601
+ 'dvec3',
602
+ 'dvec4',
603
+ 'fvec2',
604
+ 'fvec3',
605
+ 'fvec4',
606
+ 'sampler3DRect',
607
+ 'filter',
608
+ 'image1D',
609
+ 'image2D',
610
+ 'image3D',
611
+ 'imageCube',
612
+ 'iimage1D',
613
+ 'iimage2D',
614
+ 'iimage3D',
615
+ 'iimageCube',
616
+ 'uimage1D',
617
+ 'uimage2D',
618
+ 'uimage3D',
619
+ 'uimageCube',
620
+ 'image1DArray',
621
+ 'image2DArray',
622
+ 'iimage1DArray',
623
+ 'iimage2DArray',
624
+ 'uimage1DArray',
625
+ 'uimage2DArray',
626
+ 'imageBuffer',
627
+ 'iimageBuffer',
628
+ 'uimageBuffer',
629
+ 'sampler1D',
630
+ 'sampler1DShadow',
631
+ 'sampler1DArray',
632
+ 'sampler1DArrayShadow',
633
+ 'isampler1D',
634
+ 'isampler1DArray',
635
+ 'usampler1D',
636
+ 'usampler1DArray',
637
+ 'sampler2DRect',
638
+ 'sampler2DRectShadow',
639
+ 'isampler2DRect',
640
+ 'usampler2DRect',
641
+ 'samplerBuffer',
642
+ 'isamplerBuffer',
643
+ 'usamplerBuffer',
644
+ 'sampler2DMS',
645
+ 'isampler2DMS',
646
+ 'usampler2DMS',
647
+ 'sampler2DMSArray',
648
+ 'isampler2DMSArray',
649
+ 'usampler2DMSArray',
650
+ 'sizeof',
651
+ 'cast',
652
+ 'namespace',
653
+ 'using',
654
+
655
+ // 3.5 Preprocessor
656
+ '#define',
657
+ '#undef',
658
+ '#if',
659
+ '#ifdef',
660
+ '#ifndef',
661
+ '#else',
662
+ '#elif',
663
+ '#endif',
664
+ '#error',
665
+ '#pragma',
666
+ '#extension',
667
+ '#version',
668
+ '#line',
669
+
670
+ // 3.5 Preprocessor - Operators
671
+ 'defined',
672
+
673
+ // 3.5 Preprocessor - Macros
674
+ '__LINE__',
675
+ '__FILE__',
676
+ '__VERSION__',
677
+ 'GL_ES',
678
+
679
+ // 7.1 Vertex Shader Special Variables
680
+ 'gl_VertexID',
681
+ 'gl_InstanceID',
682
+ 'gl_Position',
683
+ 'gl_PointSize',
684
+
685
+ // 7.2 Fragment Shader Special Variables
686
+ 'gl_FragCoord',
687
+ 'gl_FrontFacing',
688
+ 'gl_FragDepth',
689
+ 'gl_PointCoord',
690
+
691
+ // 7.3 Built-in Constants
692
+ 'gl_MaxVertexAttribs',
693
+ 'gl_MaxVertexUniformVectors',
694
+ 'gl_MaxVertexOutputVectors',
695
+ 'gl_MaxFragmentInputVectors',
696
+ 'gl_MaxVertexTextureImageUnits',
697
+ 'gl_MaxCombinedTextureImageUnits',
698
+ 'gl_MaxTextureImageUnits',
699
+ 'gl_MaxFragmentUniformVectors',
700
+ 'gl_MaxDrawBuffers',
701
+ 'gl_MinProgramTexelOffset',
702
+ 'gl_MaxProgramTexelOffset',
703
+
704
+ // 7.4 Built-in Uniform State
705
+ 'gl_DepthRangeParameters',
706
+ 'gl_DepthRange',
707
+
708
+ // 8.1 Angle and Trigonometry Functions
709
+ 'radians',
710
+ 'degrees',
711
+ 'sin',
712
+ 'cos',
713
+ 'tan',
714
+ 'asin',
715
+ 'acos',
716
+ 'atan',
717
+ 'sinh',
718
+ 'cosh',
719
+ 'tanh',
720
+ 'asinh',
721
+ 'acosh',
722
+ 'atanh',
723
+
724
+ // 8.2 Exponential Functions
725
+ 'pow',
726
+ 'exp',
727
+ 'log',
728
+ 'exp2',
729
+ 'log2',
730
+ 'sqrt',
731
+ 'inversesqrt',
732
+
733
+ // 8.3 Common Functions
734
+ 'abs',
735
+ 'sign',
736
+ 'floor',
737
+ 'trunc',
738
+ 'round',
739
+ 'roundEven',
740
+ 'ceil',
741
+ 'fract',
742
+ 'mod',
743
+ 'modf',
744
+ 'min',
745
+ 'max',
746
+ 'clamp',
747
+ 'mix',
748
+ 'step',
749
+ 'smoothstep',
750
+ 'isnan',
751
+ 'isinf',
752
+ 'floatBitsToInt',
753
+ 'floatBitsToUint',
754
+ 'intBitsToFloat',
755
+ 'uintBitsToFloat',
756
+
757
+ // 8.4 Floating-Point Pack and Unpack Functions
758
+ 'packSnorm2x16',
759
+ 'unpackSnorm2x16',
760
+ 'packUnorm2x16',
761
+ 'unpackUnorm2x16',
762
+ 'packHalf2x16',
763
+ 'unpackHalf2x16',
764
+
765
+ // 8.5 Geometric Functions
766
+ 'length',
767
+ 'distance',
768
+ 'dot',
769
+ 'cross',
770
+ 'normalize',
771
+ 'faceforward',
772
+ 'reflect',
773
+ 'refract',
774
+ 'matrixCompMult',
775
+ 'outerProduct',
776
+ 'transpose',
777
+ 'determinant',
778
+ 'inverse',
779
+
780
+ // 8.7 Vector Relational Functions
781
+ 'lessThan',
782
+ 'lessThanEqual',
783
+ 'greaterThan',
784
+ 'greaterThanEqual',
785
+ 'equal',
786
+ 'notEqual',
787
+ 'any',
788
+ 'all',
789
+ 'not',
790
+
791
+ // 8.8 Texture Lookup Functions
792
+ 'textureSize',
793
+ 'texture',
794
+ 'textureProj',
795
+ 'textureLod',
796
+ 'textureOffset',
797
+ 'texelFetch',
798
+ 'texelFetchOffset',
799
+ 'textureProjOffset',
800
+ 'textureLodOffset',
801
+ 'textureProjLod',
802
+ 'textureProjLodOffset',
803
+ 'textureGrad',
804
+ 'textureGradOffset',
805
+ 'textureProjGrad',
806
+ 'textureProjGradOffset',
807
+
808
+ // 8.9 Fragment Processing Functions
809
+ 'dFdx',
810
+ 'dFdy',
811
+ 'fwidth',
812
+
813
+ // Additional directives
814
+ '#include',
815
+
816
+ // WebGL1 (three.js)
817
+ // 'attribute',
818
+ // 'varying',
819
+ 'gl_FragColor',
820
+ 'gl_FragDepthEXT',
821
+ 'texture2D',
822
+ 'textureCube',
823
+ 'texture2DProj',
824
+ 'texture2DLodEXT',
825
+ 'texture2DProjLodEXT',
826
+ 'textureCubeLodEXT',
827
+ 'texture2DGradEXT',
828
+ 'texture2DProjGradEXT',
829
+ 'textureCubeGradEXT',
830
+
831
+ // WEBGL_multi_draw https://registry.khronos.org/webgl/extensions/WEBGL_multi_draw
832
+ 'gl_DrawID', // vertex only
833
+
834
+ // OVR_multiview2 https://registry.khronos.org/webgl/extensions/OVR_multiview2
835
+ // OCULUS_multiview https://github.com/KhronosGroup/WebGL/issues/2912
836
+ 'gl_ViewID_OVR',
837
+ 'GL_OVR_multiview2',
838
+
839
+ // GLSL ES 3.1
840
+ // https://registry.khronos.org/OpenGL/specs/es/3.1/GLSL_ES_Specification_3.10.pdf
841
+
842
+ // 4.3 Storage Qualifiers
843
+ 'buffer',
844
+ 'shared',
845
+
846
+ // 7.1.2 Fragment Shader Special Variables
847
+ 'gl_HelperInvocation',
848
+
849
+ // 7.1.3 Compute Shader Special Variables
850
+ 'gl_NumWorkGroups',
851
+ 'gl_WorkGroupSize',
852
+ 'gl_WorkGroupID',
853
+ 'gl_LocalInvocationID',
854
+ 'gl_GlobalInvocationID',
855
+ 'gl_LocalInvocationIndex',
856
+
857
+ // 7.2 Built-In Constants
858
+ 'gl_MaxImageUnits',
859
+ 'gl_MaxVertexImageUniforms',
860
+ 'gl_MaxFragmentImageUniforms',
861
+ 'gl_MaxComputeImageUniforms',
862
+ 'gl_MaxCombinedImageUniforms',
863
+ 'gl_MaxCombinedShaderOutputResources',
864
+ 'gl_MaxComputeWorkGroupCount',
865
+ 'gl_MaxComputeWorkGroupSize',
866
+ 'gl_MaxComputeUniformComponents',
867
+ 'gl_MaxComputeTextureImageUnits',
868
+ 'gl_MaxComputeAtomicCounters',
869
+ 'gl_MaxComputeAtomicCounterBuffers',
870
+ 'gl_MaxVertexAtomicCounters',
871
+ 'gl_MaxFragmentAtomicCounters',
872
+ 'gl_MaxCombinedAtomicCounters',
873
+ 'gl_MaxAtomicCounterBindings',
874
+ 'gl_MaxFragmentAtomicCounterBuffers',
875
+ 'gl_MaxVertexAtomicCounterBuffers',
876
+ 'gl_MaxCombinedAtomicCounterBuffers',
877
+ 'gl_MaxAtomicCounterBufferSize',
878
+
879
+ // 8 Built-in Functions
880
+ 'imageSize',
881
+ 'packUnorm4x8',
882
+ 'packSnorm4x8',
883
+ 'unpackUnorm4x8',
884
+ 'unpackSnorm4x8',
885
+
886
+ // 8.8 Integer Functions
887
+ 'bitfieldExtract',
888
+ 'bitfieldInsert',
889
+ 'bitfieldReverse',
890
+ 'bitCount',
891
+ 'findLSB',
892
+ 'findMSB',
893
+ 'uaddCarry',
894
+ 'usubBorrow',
895
+ 'umulExtended',
896
+ 'imulExtended',
897
+
898
+ // 8.10 Atomic-Counter Functions
899
+ 'atomicCounterIncrement',
900
+ 'atomicCounterDecrement',
901
+ 'atomicCounter',
902
+
903
+ // 8.11 Atomic Memory Functions
904
+ 'atomicAdd',
905
+ 'atomicMin',
906
+ 'atomicMax',
907
+ 'atomicAnd',
908
+ 'atomicOr',
909
+ 'atomicXor',
910
+ 'atomicExchange',
911
+ 'atomicCompSwap',
912
+
913
+ // 8.12 Image Functions
914
+ 'imageLoad',
915
+ 'imageStore',
916
+
917
+ // 8.14 Shader Invocation Control Functions
918
+ 'barrier',
919
+
920
+ // 8.15 Shader Memory Control Functions
921
+ 'memoryBarrier',
922
+ 'memoryBarrierAtomicCounter',
923
+ 'memoryBarrierBuffer',
924
+ 'memoryBarrierImage',
925
+ 'memoryBarrierShared',
926
+ 'groupMemoryBarrier',
927
+ ]
928
+
929
+ const SYMBOLS = [
930
+ // Comments
931
+ '//',
932
+ '/*',
933
+ '*/',
934
+
935
+ // Punctuation
936
+ ':',
937
+ ',',
938
+ '.',
939
+ '{',
940
+ '[',
941
+ '(',
942
+ '?',
943
+ '}',
944
+ ']',
945
+ ')',
946
+ ';',
947
+
948
+ // Unary
949
+ '~',
950
+ '--',
951
+ '++',
952
+ '!',
953
+
954
+ // Binary
955
+ '&',
956
+ '|',
957
+ '^',
958
+ '/',
959
+ '==',
960
+ '>',
961
+ '>=',
962
+ '<',
963
+ '<=',
964
+ '&&',
965
+ '||',
966
+ '^^',
967
+ '-',
968
+ '*',
969
+ '!=',
970
+ '+',
971
+ '%',
972
+ '<<',
973
+ '>>',
974
+
975
+ // Binary assignment
976
+ '=',
977
+ '+=',
978
+ '&=',
979
+ '|=',
980
+ '^=',
981
+ '/=',
982
+ '*=',
983
+ '%=',
984
+ '<<=',
985
+ '>>=',
986
+ '-=',
987
+ ]
988
+
989
+ // GLSL 3.2 Character Set, 5.1 Operators
990
+ export const GLSL_SYMBOLS = [
991
+ ...SYMBOLS,
992
+ // Preprocessor
993
+ '#',
994
+ // Line continuation
995
+ '\\',
996
+ ]
997
+
998
+ // WGSL 15.3 Syntactic Tokens
999
+ export const WGSL_SYMBOLS = [
1000
+ ...SYMBOLS,
1001
+ // Function arrow
1002
+ '->',
1003
+ // Attribute
1004
+ '@',
1005
+ ]