-
Notifications
You must be signed in to change notification settings - Fork 712
/
SemaHLSL.cpp
16352 lines (14630 loc) · 606 KB
/
SemaHLSL.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
//===--- SemaHLSL.cpp - HLSL support for AST nodes and operations ---===//
///////////////////////////////////////////////////////////////////////////////
// //
// SemaHLSL.cpp //
// Copyright (C) Microsoft Corporation. All rights reserved. //
// This file is distributed under the University of Illinois Open Source //
// License. See LICENSE.TXT for details. //
// //
// This file implements the semantic support for HLSL. //
// //
///////////////////////////////////////////////////////////////////////////////
#include "clang/Sema/SemaHLSL.h"
#include "VkConstantsTables.h"
#include "dxc/DXIL/DxilFunctionProps.h"
#include "dxc/DXIL/DxilShaderModel.h"
#include "dxc/HLSL/HLOperations.h"
#include "dxc/HlslIntrinsicOp.h"
#include "dxc/Support/Global.h"
#include "dxc/Support/WinIncludes.h"
#include "dxc/dxcapi.internal.h"
#include "gen_intrin_main_tables_15.h"
#include "clang/AST/ASTContext.h"
#include "clang/AST/Attr.h"
#include "clang/AST/DeclBase.h"
#include "clang/AST/DeclCXX.h"
#include "clang/AST/DeclTemplate.h"
#include "clang/AST/Expr.h"
#include "clang/AST/ExprCXX.h"
#include "clang/AST/ExternalASTSource.h"
#include "clang/AST/HlslTypes.h"
#include "clang/AST/TypeLoc.h"
#include "clang/Basic/Diagnostic.h"
#include "clang/Sema/ExternalSemaSource.h"
#include "clang/Sema/Initialization.h"
#include "clang/Sema/Lookup.h"
#include "clang/Sema/Overload.h"
#include "clang/Sema/SemaDiagnostic.h"
#include "clang/Sema/Template.h"
#include "clang/Sema/TemplateDeduction.h"
#include "llvm/ADT/DenseMap.h"
#include "llvm/ADT/SmallPtrSet.h"
#include "llvm/Support/ErrorHandling.h"
#include "llvm/Support/raw_ostream.h"
#include <algorithm>
#include <array>
#include <bitset>
#include <float.h>
enum ArBasicKind {
AR_BASIC_BOOL,
AR_BASIC_LITERAL_FLOAT,
AR_BASIC_FLOAT16,
AR_BASIC_FLOAT32_PARTIAL_PRECISION,
AR_BASIC_FLOAT32,
AR_BASIC_FLOAT64,
AR_BASIC_LITERAL_INT,
AR_BASIC_INT8,
AR_BASIC_UINT8,
AR_BASIC_INT16,
AR_BASIC_UINT16,
AR_BASIC_INT32,
AR_BASIC_UINT32,
AR_BASIC_INT64,
AR_BASIC_UINT64,
AR_BASIC_MIN10FLOAT,
AR_BASIC_MIN16FLOAT,
AR_BASIC_MIN12INT,
AR_BASIC_MIN16INT,
AR_BASIC_MIN16UINT,
AR_BASIC_INT8_4PACKED,
AR_BASIC_UINT8_4PACKED,
AR_BASIC_ENUM,
AR_BASIC_COUNT,
//
// Pseudo-entries for intrinsic tables and such.
//
AR_BASIC_NONE,
AR_BASIC_UNKNOWN,
AR_BASIC_NOCAST,
AR_BASIC_DEPENDENT,
//
// The following pseudo-entries represent higher-level
// object types that are treated as units.
//
AR_BASIC_POINTER,
AR_BASIC_ENUM_CLASS,
AR_OBJECT_NULL,
AR_OBJECT_STRING_LITERAL,
AR_OBJECT_STRING,
// AR_OBJECT_TEXTURE,
AR_OBJECT_TEXTURE1D,
AR_OBJECT_TEXTURE1D_ARRAY,
AR_OBJECT_TEXTURE2D,
AR_OBJECT_TEXTURE2D_ARRAY,
AR_OBJECT_TEXTURE3D,
AR_OBJECT_TEXTURECUBE,
AR_OBJECT_TEXTURECUBE_ARRAY,
AR_OBJECT_TEXTURE2DMS,
AR_OBJECT_TEXTURE2DMS_ARRAY,
AR_OBJECT_SAMPLER,
AR_OBJECT_SAMPLER1D,
AR_OBJECT_SAMPLER2D,
AR_OBJECT_SAMPLER3D,
AR_OBJECT_SAMPLERCUBE,
AR_OBJECT_SAMPLERCOMPARISON,
AR_OBJECT_BUFFER,
//
// View objects are only used as variable/types within the Effects
// framework, for example in calls to OMSetRenderTargets.
//
AR_OBJECT_RENDERTARGETVIEW,
AR_OBJECT_DEPTHSTENCILVIEW,
//
// Shader objects are only used as variable/types within the Effects
// framework, for example as a result of CompileShader().
//
AR_OBJECT_COMPUTESHADER,
AR_OBJECT_DOMAINSHADER,
AR_OBJECT_GEOMETRYSHADER,
AR_OBJECT_HULLSHADER,
AR_OBJECT_PIXELSHADER,
AR_OBJECT_VERTEXSHADER,
AR_OBJECT_PIXELFRAGMENT,
AR_OBJECT_VERTEXFRAGMENT,
AR_OBJECT_STATEBLOCK,
AR_OBJECT_RASTERIZER,
AR_OBJECT_DEPTHSTENCIL,
AR_OBJECT_BLEND,
AR_OBJECT_POINTSTREAM,
AR_OBJECT_LINESTREAM,
AR_OBJECT_TRIANGLESTREAM,
AR_OBJECT_INPUTPATCH,
AR_OBJECT_OUTPUTPATCH,
AR_OBJECT_RWTEXTURE1D,
AR_OBJECT_RWTEXTURE1D_ARRAY,
AR_OBJECT_RWTEXTURE2D,
AR_OBJECT_RWTEXTURE2D_ARRAY,
AR_OBJECT_RWTEXTURE3D,
AR_OBJECT_RWBUFFER,
AR_OBJECT_BYTEADDRESS_BUFFER,
AR_OBJECT_RWBYTEADDRESS_BUFFER,
AR_OBJECT_STRUCTURED_BUFFER,
AR_OBJECT_RWSTRUCTURED_BUFFER,
AR_OBJECT_RWSTRUCTURED_BUFFER_ALLOC,
AR_OBJECT_RWSTRUCTURED_BUFFER_CONSUME,
AR_OBJECT_APPEND_STRUCTURED_BUFFER,
AR_OBJECT_CONSUME_STRUCTURED_BUFFER,
AR_OBJECT_CONSTANT_BUFFER,
AR_OBJECT_TEXTURE_BUFFER,
AR_OBJECT_ROVBUFFER,
AR_OBJECT_ROVBYTEADDRESS_BUFFER,
AR_OBJECT_ROVSTRUCTURED_BUFFER,
AR_OBJECT_ROVTEXTURE1D,
AR_OBJECT_ROVTEXTURE1D_ARRAY,
AR_OBJECT_ROVTEXTURE2D,
AR_OBJECT_ROVTEXTURE2D_ARRAY,
AR_OBJECT_ROVTEXTURE3D,
AR_OBJECT_FEEDBACKTEXTURE2D,
AR_OBJECT_FEEDBACKTEXTURE2D_ARRAY,
// SPIRV change starts
#ifdef ENABLE_SPIRV_CODEGEN
AR_OBJECT_VK_SUBPASS_INPUT,
AR_OBJECT_VK_SUBPASS_INPUT_MS,
AR_OBJECT_VK_SPIRV_TYPE,
AR_OBJECT_VK_SPIRV_OPAQUE_TYPE,
AR_OBJECT_VK_INTEGRAL_CONSTANT,
AR_OBJECT_VK_LITERAL,
AR_OBJECT_VK_SPV_INTRINSIC_TYPE,
AR_OBJECT_VK_SPV_INTRINSIC_RESULT_ID,
#endif // ENABLE_SPIRV_CODEGEN
// SPIRV change ends
AR_OBJECT_INNER, // Used for internal type object
AR_OBJECT_LEGACY_EFFECT,
AR_OBJECT_WAVE,
AR_OBJECT_RAY_DESC,
AR_OBJECT_ACCELERATION_STRUCT,
AR_OBJECT_USER_DEFINED_TYPE,
AR_OBJECT_TRIANGLE_INTERSECTION_ATTRIBUTES,
// subobjects
AR_OBJECT_STATE_OBJECT_CONFIG,
AR_OBJECT_GLOBAL_ROOT_SIGNATURE,
AR_OBJECT_LOCAL_ROOT_SIGNATURE,
AR_OBJECT_SUBOBJECT_TO_EXPORTS_ASSOC,
AR_OBJECT_RAYTRACING_SHADER_CONFIG,
AR_OBJECT_RAYTRACING_PIPELINE_CONFIG,
AR_OBJECT_TRIANGLE_HIT_GROUP,
AR_OBJECT_PROCEDURAL_PRIMITIVE_HIT_GROUP,
AR_OBJECT_RAYTRACING_PIPELINE_CONFIG1,
// RayQuery
AR_OBJECT_RAY_QUERY,
// Heap Resource
AR_OBJECT_HEAP_RESOURCE,
AR_OBJECT_HEAP_SAMPLER,
AR_OBJECT_RWTEXTURE2DMS,
AR_OBJECT_RWTEXTURE2DMS_ARRAY,
// WaveMatrix
AR_OBJECT_WAVE_MATRIX_LEFT,
AR_OBJECT_WAVE_MATRIX_RIGHT,
AR_OBJECT_WAVE_MATRIX_LEFT_COL_ACC,
AR_OBJECT_WAVE_MATRIX_RIGHT_ROW_ACC,
AR_OBJECT_WAVE_MATRIX_ACCUMULATOR,
// Work Graphs
AR_OBJECT_EMPTY_NODE_INPUT,
AR_OBJECT_DISPATCH_NODE_INPUT_RECORD,
AR_OBJECT_RWDISPATCH_NODE_INPUT_RECORD,
AR_OBJECT_GROUP_NODE_INPUT_RECORDS,
AR_OBJECT_RWGROUP_NODE_INPUT_RECORDS,
AR_OBJECT_THREAD_NODE_INPUT_RECORD,
AR_OBJECT_RWTHREAD_NODE_INPUT_RECORD,
AR_OBJECT_NODE_OUTPUT,
AR_OBJECT_EMPTY_NODE_OUTPUT,
AR_OBJECT_NODE_OUTPUT_ARRAY,
AR_OBJECT_EMPTY_NODE_OUTPUT_ARRAY,
AR_OBJECT_THREAD_NODE_OUTPUT_RECORDS,
AR_OBJECT_GROUP_NODE_OUTPUT_RECORDS,
AR_BASIC_MAXIMUM_COUNT
};
#define AR_BASIC_TEXTURE_MS_CASES \
case AR_OBJECT_TEXTURE2DMS: \
case AR_OBJECT_TEXTURE2DMS_ARRAY: \
case AR_OBJECT_RWTEXTURE2DMS: \
case AR_OBJECT_RWTEXTURE2DMS_ARRAY
#define AR_BASIC_NON_TEXTURE_MS_CASES \
case AR_OBJECT_TEXTURE1D: \
case AR_OBJECT_TEXTURE1D_ARRAY: \
case AR_OBJECT_TEXTURE2D: \
case AR_OBJECT_TEXTURE2D_ARRAY: \
case AR_OBJECT_TEXTURE3D: \
case AR_OBJECT_TEXTURECUBE: \
case AR_OBJECT_TEXTURECUBE_ARRAY
#define AR_BASIC_TEXTURE_CASES \
AR_BASIC_TEXTURE_MS_CASES: \
AR_BASIC_NON_TEXTURE_MS_CASES
#define AR_BASIC_NON_CMP_SAMPLER_CASES \
case AR_OBJECT_SAMPLER: \
case AR_OBJECT_SAMPLER1D: \
case AR_OBJECT_SAMPLER2D: \
case AR_OBJECT_SAMPLER3D: \
case AR_OBJECT_SAMPLERCUBE
#define AR_BASIC_ROBJECT_CASES \
case AR_OBJECT_BLEND: \
case AR_OBJECT_RASTERIZER: \
case AR_OBJECT_DEPTHSTENCIL: \
case AR_OBJECT_STATEBLOCK
#define AR_BASIC_WAVE_MATRIX_INPUT_CASES \
case AR_OBJECT_WAVE_MATRIX_LEFT: \
case AR_OBJECT_WAVE_MATRIX_RIGHT
#define AR_BASIC_WAVE_MATRIX_ACC_FRAG_CASES \
case AR_OBJECT_WAVE_MATRIX_LEFT_COL_ACC: \
case AR_OBJECT_WAVE_MATRIX_RIGHT_ROW_ACC: \
case AR_OBJECT_WAVE_MATRIX_ACCUMULATOR
//
// Properties of entries in the ArBasicKind enumeration.
// These properties are intended to allow easy identification
// of classes of basic kinds. More specific checks on the
// actual kind values could then be done.
//
// The first four bits are used as a subtype indicator,
// such as bit count for primitive kinds or specific
// types for non-primitive-data kinds.
#define BPROP_SUBTYPE_MASK 0x0000000f
// Bit counts must be ordered from smaller to larger.
#define BPROP_BITS0 0x00000000
#define BPROP_BITS8 0x00000001
#define BPROP_BITS10 0x00000002
#define BPROP_BITS12 0x00000003
#define BPROP_BITS16 0x00000004
#define BPROP_BITS32 0x00000005
#define BPROP_BITS64 0x00000006
#define BPROP_BITS_NON_PRIM 0x00000007
#define GET_BPROP_SUBTYPE(_Props) ((_Props)&BPROP_SUBTYPE_MASK)
#define GET_BPROP_BITS(_Props) ((_Props)&BPROP_SUBTYPE_MASK)
#define BPROP_BOOLEAN 0x00000010 // Whether the type is bool
#define BPROP_INTEGER 0x00000020 // Whether the type is an integer
#define BPROP_UNSIGNED \
0x00000040 // Whether the type is an unsigned numeric (its absence implies
// signed)
#define BPROP_NUMERIC 0x00000080 // Whether the type is numeric or boolean
#define BPROP_LITERAL \
0x00000100 // Whether the type is a literal float or integer
#define BPROP_FLOATING 0x00000200 // Whether the type is a float
#define BPROP_OBJECT \
0x00000400 // Whether the type is an object (including null or stream)
#define BPROP_OTHER \
0x00000800 // Whether the type is a pseudo-entry in another table.
#define BPROP_PARTIAL_PRECISION \
0x00001000 // Whether the type has partial precision for calculations (i.e.,
// is this 'half')
#define BPROP_POINTER 0x00002000 // Whether the type is a basic pointer.
#define BPROP_TEXTURE 0x00004000 // Whether the type is any kind of texture.
#define BPROP_SAMPLER \
0x00008000 // Whether the type is any kind of sampler object.
#define BPROP_STREAM \
0x00010000 // Whether the type is a point, line or triangle stream.
#define BPROP_PATCH 0x00020000 // Whether the type is an input or output patch.
#define BPROP_RBUFFER 0x00040000 // Whether the type acts as a read-only buffer.
#define BPROP_RWBUFFER \
0x00080000 // Whether the type acts as a read-write buffer.
#define BPROP_PRIMITIVE \
0x00100000 // Whether the type is a primitive scalar type.
#define BPROP_MIN_PRECISION \
0x00200000 // Whether the type is qualified with a minimum precision.
#define BPROP_ROVBUFFER 0x00400000 // Whether the type is a ROV object.
#define BPROP_FEEDBACKTEXTURE \
0x00800000 // Whether the type is a feedback texture.
#define BPROP_ENUM 0x01000000 // Whether the type is a enum
#define BPROP_WAVE_MATRIX_INPUT \
0x02000000 // Whether the type is a wave matrix input object (Left/Right)
#define BPROP_WAVE_MATRIX_ACC \
0x04000000 // Whether the type is a wave matrix accum object
// (Accumulator/LeftColAcc/RightRowAcc)
#define GET_BPROP_PRIM_KIND(_Props) \
((_Props) & (BPROP_BOOLEAN | BPROP_INTEGER | BPROP_FLOATING))
#define GET_BPROP_PRIM_KIND_SU(_Props) \
((_Props) & (BPROP_BOOLEAN | BPROP_INTEGER | BPROP_FLOATING | BPROP_UNSIGNED))
#define IS_BPROP_PRIMITIVE(_Props) (((_Props)&BPROP_PRIMITIVE) != 0)
#define IS_BPROP_BOOL(_Props) (((_Props)&BPROP_BOOLEAN) != 0)
#define IS_BPROP_FLOAT(_Props) (((_Props)&BPROP_FLOATING) != 0)
#define IS_BPROP_SINT(_Props) \
(((_Props) & (BPROP_INTEGER | BPROP_UNSIGNED | BPROP_BOOLEAN)) == \
BPROP_INTEGER)
#define IS_BPROP_UINT(_Props) \
(((_Props) & (BPROP_INTEGER | BPROP_UNSIGNED | BPROP_BOOLEAN)) == \
(BPROP_INTEGER | BPROP_UNSIGNED))
#define IS_BPROP_AINT(_Props) \
(((_Props) & (BPROP_INTEGER | BPROP_BOOLEAN)) == BPROP_INTEGER)
#define IS_BPROP_STREAM(_Props) (((_Props)&BPROP_STREAM) != 0)
#define IS_BPROP_SAMPLER(_Props) (((_Props)&BPROP_SAMPLER) != 0)
#define IS_BPROP_TEXTURE(_Props) (((_Props)&BPROP_TEXTURE) != 0)
#define IS_BPROP_OBJECT(_Props) (((_Props)&BPROP_OBJECT) != 0)
#define IS_BPROP_MIN_PRECISION(_Props) (((_Props)&BPROP_MIN_PRECISION) != 0)
#define IS_BPROP_UNSIGNABLE(_Props) \
(IS_BPROP_AINT(_Props) && GET_BPROP_BITS(_Props) != BPROP_BITS12)
#define IS_BPROP_ENUM(_Props) (((_Props)&BPROP_ENUM) != 0)
#define IS_BPROP_WAVE_MATRIX_INPUT(_Props) \
(((_Props) & BPROP_WAVE_MATRIX_INPUT) != 0)
#define IS_BPROP_WAVE_MATRIX_ACC(_Props) \
(((_Props) & BPROP_WAVE_MATRIX_ACC) != 0)
const UINT g_uBasicKindProps[] = {
BPROP_PRIMITIVE | BPROP_BOOLEAN | BPROP_INTEGER | BPROP_NUMERIC |
BPROP_BITS0, // AR_BASIC_BOOL
BPROP_PRIMITIVE | BPROP_NUMERIC | BPROP_FLOATING | BPROP_LITERAL |
BPROP_BITS0, // AR_BASIC_LITERAL_FLOAT
BPROP_PRIMITIVE | BPROP_NUMERIC | BPROP_FLOATING |
BPROP_BITS16, // AR_BASIC_FLOAT16
BPROP_PRIMITIVE | BPROP_NUMERIC | BPROP_FLOATING | BPROP_BITS32 |
BPROP_PARTIAL_PRECISION, // AR_BASIC_FLOAT32_PARTIAL_PRECISION
BPROP_PRIMITIVE | BPROP_NUMERIC | BPROP_FLOATING |
BPROP_BITS32, // AR_BASIC_FLOAT32
BPROP_PRIMITIVE | BPROP_NUMERIC | BPROP_FLOATING |
BPROP_BITS64, // AR_BASIC_FLOAT64
BPROP_PRIMITIVE | BPROP_NUMERIC | BPROP_INTEGER | BPROP_LITERAL |
BPROP_BITS0, // AR_BASIC_LITERAL_INT
BPROP_PRIMITIVE | BPROP_NUMERIC | BPROP_INTEGER |
BPROP_BITS8, // AR_BASIC_INT8
BPROP_PRIMITIVE | BPROP_NUMERIC | BPROP_INTEGER | BPROP_UNSIGNED |
BPROP_BITS8, // AR_BASIC_UINT8
BPROP_PRIMITIVE | BPROP_NUMERIC | BPROP_INTEGER |
BPROP_BITS16, // AR_BASIC_INT16
BPROP_PRIMITIVE | BPROP_NUMERIC | BPROP_INTEGER | BPROP_UNSIGNED |
BPROP_BITS16, // AR_BASIC_UINT16
BPROP_PRIMITIVE | BPROP_NUMERIC | BPROP_INTEGER |
BPROP_BITS32, // AR_BASIC_INT32
BPROP_PRIMITIVE | BPROP_NUMERIC | BPROP_INTEGER | BPROP_UNSIGNED |
BPROP_BITS32, // AR_BASIC_UINT32
BPROP_PRIMITIVE | BPROP_NUMERIC | BPROP_INTEGER |
BPROP_BITS64, // AR_BASIC_INT64
BPROP_PRIMITIVE | BPROP_NUMERIC | BPROP_INTEGER | BPROP_UNSIGNED |
BPROP_BITS64, // AR_BASIC_UINT64
BPROP_PRIMITIVE | BPROP_NUMERIC | BPROP_FLOATING | BPROP_BITS10 |
BPROP_MIN_PRECISION, // AR_BASIC_MIN10FLOAT
BPROP_PRIMITIVE | BPROP_NUMERIC | BPROP_FLOATING | BPROP_BITS16 |
BPROP_MIN_PRECISION, // AR_BASIC_MIN16FLOAT
BPROP_PRIMITIVE | BPROP_NUMERIC | BPROP_INTEGER | BPROP_BITS12 |
BPROP_MIN_PRECISION, // AR_BASIC_MIN12INT
BPROP_PRIMITIVE | BPROP_NUMERIC | BPROP_INTEGER | BPROP_BITS16 |
BPROP_MIN_PRECISION, // AR_BASIC_MIN16INT
BPROP_PRIMITIVE | BPROP_NUMERIC | BPROP_INTEGER | BPROP_UNSIGNED |
BPROP_BITS16 | BPROP_MIN_PRECISION, // AR_BASIC_MIN16UINT
BPROP_PRIMITIVE | BPROP_NUMERIC | BPROP_INTEGER | BPROP_UNSIGNED |
BPROP_BITS32, // AR_BASIC_INT8_4PACKED
BPROP_PRIMITIVE | BPROP_NUMERIC | BPROP_INTEGER | BPROP_UNSIGNED |
BPROP_BITS32, // AR_BASIC_UINT8_4PACKED
BPROP_ENUM | BPROP_NUMERIC | BPROP_INTEGER, // AR_BASIC_ENUM
BPROP_OTHER, // AR_BASIC_COUNT
//
// Pseudo-entries for intrinsic tables and such.
//
0, // AR_BASIC_NONE
BPROP_OTHER, // AR_BASIC_UNKNOWN
BPROP_OTHER, // AR_BASIC_NOCAST
0, // AR_BASIC_DEPENDENT
//
// The following pseudo-entries represent higher-level
// object types that are treated as units.
//
BPROP_POINTER, // AR_BASIC_POINTER
BPROP_ENUM, // AR_BASIC_ENUM_CLASS
BPROP_OBJECT | BPROP_RBUFFER, // AR_OBJECT_NULL
BPROP_OBJECT | BPROP_RBUFFER, // AR_OBJECT_STRING_LITERAL
BPROP_OBJECT | BPROP_RBUFFER, // AR_OBJECT_STRING
// BPROP_OBJECT | BPROP_TEXTURE, // AR_OBJECT_TEXTURE
BPROP_OBJECT | BPROP_TEXTURE, // AR_OBJECT_TEXTURE1D
BPROP_OBJECT | BPROP_TEXTURE, // AR_OBJECT_TEXTURE1D_ARRAY
BPROP_OBJECT | BPROP_TEXTURE, // AR_OBJECT_TEXTURE2D
BPROP_OBJECT | BPROP_TEXTURE, // AR_OBJECT_TEXTURE2D_ARRAY
BPROP_OBJECT | BPROP_TEXTURE, // AR_OBJECT_TEXTURE3D
BPROP_OBJECT | BPROP_TEXTURE, // AR_OBJECT_TEXTURECUBE
BPROP_OBJECT | BPROP_TEXTURE, // AR_OBJECT_TEXTURECUBE_ARRAY
BPROP_OBJECT | BPROP_TEXTURE, // AR_OBJECT_TEXTURE2DMS
BPROP_OBJECT | BPROP_TEXTURE, // AR_OBJECT_TEXTURE2DMS_ARRAY
BPROP_OBJECT | BPROP_SAMPLER, // AR_OBJECT_SAMPLER
BPROP_OBJECT | BPROP_SAMPLER, // AR_OBJECT_SAMPLER1D
BPROP_OBJECT | BPROP_SAMPLER, // AR_OBJECT_SAMPLER2D
BPROP_OBJECT | BPROP_SAMPLER, // AR_OBJECT_SAMPLER3D
BPROP_OBJECT | BPROP_SAMPLER, // AR_OBJECT_SAMPLERCUBE
BPROP_OBJECT | BPROP_SAMPLER, // AR_OBJECT_SAMPLERCOMPARISON
BPROP_OBJECT | BPROP_RBUFFER, // AR_OBJECT_BUFFER
BPROP_OBJECT, // AR_OBJECT_RENDERTARGETVIEW
BPROP_OBJECT, // AR_OBJECT_DEPTHSTENCILVIEW
BPROP_OBJECT, // AR_OBJECT_COMPUTESHADER
BPROP_OBJECT, // AR_OBJECT_DOMAINSHADER
BPROP_OBJECT, // AR_OBJECT_GEOMETRYSHADER
BPROP_OBJECT, // AR_OBJECT_HULLSHADER
BPROP_OBJECT, // AR_OBJECT_PIXELSHADER
BPROP_OBJECT, // AR_OBJECT_VERTEXSHADER
BPROP_OBJECT, // AR_OBJECT_PIXELFRAGMENT
BPROP_OBJECT, // AR_OBJECT_VERTEXFRAGMENT
BPROP_OBJECT, // AR_OBJECT_STATEBLOCK
BPROP_OBJECT, // AR_OBJECT_RASTERIZER
BPROP_OBJECT, // AR_OBJECT_DEPTHSTENCIL
BPROP_OBJECT, // AR_OBJECT_BLEND
BPROP_OBJECT | BPROP_STREAM, // AR_OBJECT_POINTSTREAM
BPROP_OBJECT | BPROP_STREAM, // AR_OBJECT_LINESTREAM
BPROP_OBJECT | BPROP_STREAM, // AR_OBJECT_TRIANGLESTREAM
BPROP_OBJECT | BPROP_PATCH, // AR_OBJECT_INPUTPATCH
BPROP_OBJECT | BPROP_PATCH, // AR_OBJECT_OUTPUTPATCH
BPROP_OBJECT | BPROP_RWBUFFER, // AR_OBJECT_RWTEXTURE1D
BPROP_OBJECT | BPROP_RWBUFFER, // AR_OBJECT_RWTEXTURE1D_ARRAY
BPROP_OBJECT | BPROP_RWBUFFER, // AR_OBJECT_RWTEXTURE2D
BPROP_OBJECT | BPROP_RWBUFFER, // AR_OBJECT_RWTEXTURE2D_ARRAY
BPROP_OBJECT | BPROP_RWBUFFER, // AR_OBJECT_RWTEXTURE3D
BPROP_OBJECT | BPROP_RWBUFFER, // AR_OBJECT_RWBUFFER
BPROP_OBJECT | BPROP_RBUFFER, // AR_OBJECT_BYTEADDRESS_BUFFER
BPROP_OBJECT | BPROP_RWBUFFER, // AR_OBJECT_RWBYTEADDRESS_BUFFER
BPROP_OBJECT | BPROP_RBUFFER, // AR_OBJECT_STRUCTURED_BUFFER
BPROP_OBJECT | BPROP_RWBUFFER, // AR_OBJECT_RWSTRUCTURED_BUFFER
BPROP_OBJECT | BPROP_RWBUFFER, // AR_OBJECT_RWSTRUCTURED_BUFFER_ALLOC
BPROP_OBJECT | BPROP_RWBUFFER, // AR_OBJECT_RWSTRUCTURED_BUFFER_CONSUME
BPROP_OBJECT | BPROP_RWBUFFER, // AR_OBJECT_APPEND_STRUCTURED_BUFFER
BPROP_OBJECT | BPROP_RWBUFFER, // AR_OBJECT_CONSUME_STRUCTURED_BUFFER
BPROP_OBJECT | BPROP_RBUFFER, // AR_OBJECT_CONSTANT_BUFFER
BPROP_OBJECT | BPROP_RBUFFER, // AR_OBJECT_TEXTURE_BUFFER
BPROP_OBJECT | BPROP_RWBUFFER | BPROP_ROVBUFFER, // AR_OBJECT_ROVBUFFER
BPROP_OBJECT | BPROP_RWBUFFER |
BPROP_ROVBUFFER, // AR_OBJECT_ROVBYTEADDRESS_BUFFER
BPROP_OBJECT | BPROP_RWBUFFER |
BPROP_ROVBUFFER, // AR_OBJECT_ROVSTRUCTURED_BUFFER
BPROP_OBJECT | BPROP_RWBUFFER | BPROP_ROVBUFFER, // AR_OBJECT_ROVTEXTURE1D
BPROP_OBJECT | BPROP_RWBUFFER |
BPROP_ROVBUFFER, // AR_OBJECT_ROVTEXTURE1D_ARRAY
BPROP_OBJECT | BPROP_RWBUFFER | BPROP_ROVBUFFER, // AR_OBJECT_ROVTEXTURE2D
BPROP_OBJECT | BPROP_RWBUFFER |
BPROP_ROVBUFFER, // AR_OBJECT_ROVTEXTURE2D_ARRAY
BPROP_OBJECT | BPROP_RWBUFFER | BPROP_ROVBUFFER, // AR_OBJECT_ROVTEXTURE3D
BPROP_OBJECT | BPROP_TEXTURE |
BPROP_FEEDBACKTEXTURE, // AR_OBJECT_FEEDBACKTEXTURE2D
BPROP_OBJECT | BPROP_TEXTURE |
BPROP_FEEDBACKTEXTURE, // AR_OBJECT_FEEDBACKTEXTURE2D_ARRAY
// SPIRV change starts
#ifdef ENABLE_SPIRV_CODEGEN
BPROP_OBJECT | BPROP_RBUFFER, // AR_OBJECT_VK_SUBPASS_INPUT
BPROP_OBJECT | BPROP_RBUFFER, // AR_OBJECT_VK_SUBPASS_INPUT_MS
BPROP_OBJECT, // AR_OBJECT_VK_SPIRV_TYPE
BPROP_OBJECT, // AR_OBJECT_VK_SPIRV_OPAQUE_TYPE
BPROP_OBJECT, // AR_OBJECT_VK_INTEGRAL_CONSTANT,
BPROP_OBJECT, // AR_OBJECT_VK_LITERAL,
BPROP_OBJECT, // AR_OBJECT_VK_SPV_INTRINSIC_TYPE use recordType
BPROP_OBJECT, // AR_OBJECT_VK_SPV_INTRINSIC_RESULT_ID use recordType
#endif // ENABLE_SPIRV_CODEGEN
// SPIRV change ends
BPROP_OBJECT, // AR_OBJECT_INNER
BPROP_OBJECT, // AR_OBJECT_LEGACY_EFFECT
BPROP_OBJECT, // AR_OBJECT_WAVE
LICOMPTYPE_RAYDESC, // AR_OBJECT_RAY_DESC
LICOMPTYPE_ACCELERATION_STRUCT, // AR_OBJECT_ACCELERATION_STRUCT
LICOMPTYPE_USER_DEFINED_TYPE, // AR_OBJECT_USER_DEFINED_TYPE
0, // AR_OBJECT_TRIANGLE_INTERSECTION_ATTRIBUTES
// subobjects
0, // AR_OBJECT_STATE_OBJECT_CONFIG,
0, // AR_OBJECT_GLOBAL_ROOT_SIGNATURE,
0, // AR_OBJECT_LOCAL_ROOT_SIGNATURE,
0, // AR_OBJECT_SUBOBJECT_TO_EXPORTS_ASSOC,
0, // AR_OBJECT_RAYTRACING_SHADER_CONFIG,
0, // AR_OBJECT_RAYTRACING_PIPELINE_CONFIG,
0, // AR_OBJECT_TRIANGLE_HIT_GROUP,
0, // AR_OBJECT_PROCEDURAL_PRIMITIVE_HIT_GROUP,
0, // AR_OBJECT_RAYTRACING_PIPELINE_CONFIG1,
BPROP_OBJECT, // AR_OBJECT_RAY_QUERY,
BPROP_OBJECT, // AR_OBJECT_HEAP_RESOURCE,
BPROP_OBJECT, // AR_OBJECT_HEAP_SAMPLER,
BPROP_OBJECT | BPROP_RWBUFFER, // AR_OBJECT_RWTEXTURE2DMS
BPROP_OBJECT | BPROP_RWBUFFER, // AR_OBJECT_RWTEXTURE2DMS_ARRAY
BPROP_OBJECT | BPROP_WAVE_MATRIX_INPUT, // AR_OBJECT_WAVE_MATRIX_LEFT
BPROP_OBJECT | BPROP_WAVE_MATRIX_INPUT, // AR_OBJECT_WAVE_MATRIX_RIGHT
BPROP_OBJECT | BPROP_WAVE_MATRIX_ACC, // AR_OBJECT_WAVE_MATRIX_LEFT_COL_ACC
BPROP_OBJECT | BPROP_WAVE_MATRIX_ACC, // AR_OBJECT_WAVE_MATRIX_RIGHT_ROW_ACC
BPROP_OBJECT | BPROP_WAVE_MATRIX_ACC, // AR_OBJECT_WAVE_MATRIX_ACCUMULATOR
// WorkGraphs
BPROP_OBJECT, // AR_OBJECT_EMPTY_NODE_INPUT
BPROP_OBJECT, // AR_OBJECT_DISPATCH_NODE_INPUT_RECORD
BPROP_OBJECT | BPROP_RWBUFFER, // AR_OBJECT_RWDISPATCH_NODE_INPUT_RECORD
BPROP_OBJECT, // AR_OBJECT_GROUP_NODE_INPUT_RECORDS
BPROP_OBJECT | BPROP_RWBUFFER, // AR_OBJECT_RWGROUP_NODE_INPUT_RECORDS
BPROP_OBJECT, // AR_OBJECT_THREAD_NODE_INPUT_RECORD
BPROP_OBJECT | BPROP_RWBUFFER, // AR_OBJECT_RWTHREAD_NODE_INPUT_RECORD
BPROP_OBJECT, // AR_OBJECT_NODE_OUTPUT
BPROP_OBJECT, // AR_OBJECT_EMPTY_NODE_OUTPUT
BPROP_OBJECT, // AR_OBJECT_NODE_OUTPUT_ARRAY
BPROP_OBJECT, // AR_OBJECT_EMPTY_NODE_OUTPUT_ARRAY
BPROP_OBJECT | BPROP_RWBUFFER, // AR_OBJECT_THREAD_NODE_OUTPUT_RECORDS,
BPROP_OBJECT | BPROP_RWBUFFER, // AR_OBJECT_GROUP_NODE_OUTPUT_RECORDS,
// AR_BASIC_MAXIMUM_COUNT
};
C_ASSERT(ARRAYSIZE(g_uBasicKindProps) == AR_BASIC_MAXIMUM_COUNT);
#define GetBasicKindProps(_Kind) g_uBasicKindProps[(_Kind)]
#define GET_BASIC_BITS(_Kind) GET_BPROP_BITS(GetBasicKindProps(_Kind))
#define GET_BASIC_PRIM_KIND(_Kind) GET_BPROP_PRIM_KIND(GetBasicKindProps(_Kind))
#define GET_BASIC_PRIM_KIND_SU(_Kind) \
GET_BPROP_PRIM_KIND_SU(GetBasicKindProps(_Kind))
#define IS_BASIC_PRIMITIVE(_Kind) IS_BPROP_PRIMITIVE(GetBasicKindProps(_Kind))
#define IS_BASIC_BOOL(_Kind) IS_BPROP_BOOL(GetBasicKindProps(_Kind))
#define IS_BASIC_FLOAT(_Kind) IS_BPROP_FLOAT(GetBasicKindProps(_Kind))
#define IS_BASIC_SINT(_Kind) IS_BPROP_SINT(GetBasicKindProps(_Kind))
#define IS_BASIC_UINT(_Kind) IS_BPROP_UINT(GetBasicKindProps(_Kind))
#define IS_BASIC_AINT(_Kind) IS_BPROP_AINT(GetBasicKindProps(_Kind))
#define IS_BASIC_STREAM(_Kind) IS_BPROP_STREAM(GetBasicKindProps(_Kind))
#define IS_BASIC_SAMPLER(_Kind) IS_BPROP_SAMPLER(GetBasicKindProps(_Kind))
#define IS_BASIC_TEXTURE(_Kind) IS_BPROP_TEXTURE(GetBasicKindProps(_Kind))
#define IS_BASIC_OBJECT(_Kind) IS_BPROP_OBJECT(GetBasicKindProps(_Kind))
#define IS_BASIC_MIN_PRECISION(_Kind) \
IS_BPROP_MIN_PRECISION(GetBasicKindProps(_Kind))
#define IS_BASIC_UNSIGNABLE(_Kind) IS_BPROP_UNSIGNABLE(GetBasicKindProps(_Kind))
#define IS_BASIC_ENUM(_Kind) IS_BPROP_ENUM(GetBasicKindProps(_Kind))
#define IS_BASIC_WAVE_MATRIX_INPUT(_Kind) \
IS_BPROP_WAVE_MATRIX_INPUT(GetBasicKindProps(_Kind))
#define IS_BASIC_WAVE_MATRIX_ACC(_Kind) \
IS_BPROP_WAVE_MATRIX_ACC(GetBasicKindProps(_Kind))
#define IS_BASIC_WAVE_MATRIX(_Kind) \
(IS_BASIC_WAVE_MATRIX_INPUT(_Kind) || IS_BASIC_WAVE_MATRIX_ACC(_Kind))
#define BITWISE_ENUM_OPS(_Type) \
inline _Type operator|(_Type F1, _Type F2) { \
return (_Type)((UINT)F1 | (UINT)F2); \
} \
inline _Type operator&(_Type F1, _Type F2) { \
return (_Type)((UINT)F1 & (UINT)F2); \
} \
inline _Type &operator|=(_Type &F1, _Type F2) { \
F1 = F1 | F2; \
return F1; \
} \
inline _Type &operator&=(_Type &F1, _Type F2) { \
F1 = F1 & F2; \
return F1; \
} \
inline _Type &operator&=(_Type &F1, UINT F2) { \
F1 = (_Type)((UINT)F1 & F2); \
return F1; \
}
enum ArTypeObjectKind {
AR_TOBJ_INVALID, // Flag for an unassigned / unavailable object type.
AR_TOBJ_VOID, // Represents the type for functions with not returned valued.
AR_TOBJ_BASIC, // Represents a primitive type.
AR_TOBJ_COMPOUND, // Represents a struct or class.
AR_TOBJ_INTERFACE, // Represents an interface.
AR_TOBJ_POINTER, // Represents a pointer to another type.
AR_TOBJ_OBJECT, // Represents a built-in object.
AR_TOBJ_ARRAY, // Represents an array of other types.
AR_TOBJ_MATRIX, // Represents a matrix of basic types.
AR_TOBJ_VECTOR, // Represents a vector of basic types.
AR_TOBJ_QUALIFIER, // Represents another type plus an ArTypeQualifier.
AR_TOBJ_INNER_OBJ, // Represents a built-in inner object, such as an
// indexer object used to implement .mips[1].
AR_TOBJ_STRING, // Represents a string
AR_TOBJ_DEPENDENT, // Dependent type for template.
};
enum TYPE_CONVERSION_FLAGS {
TYPE_CONVERSION_DEFAULT =
0x00000000, // Indicates an implicit conversion is done.
TYPE_CONVERSION_EXPLICIT =
0x00000001, // Indicates a conversion is done through an explicit cast.
TYPE_CONVERSION_BY_REFERENCE =
0x00000002, // Indicates a conversion is done to an output parameter.
};
enum TYPE_CONVERSION_REMARKS {
TYPE_CONVERSION_NONE = 0x00000000,
TYPE_CONVERSION_PRECISION_LOSS = 0x00000001,
TYPE_CONVERSION_IDENTICAL = 0x00000002,
TYPE_CONVERSION_TO_VOID = 0x00000004,
TYPE_CONVERSION_ELT_TRUNCATION = 0x00000008,
};
BITWISE_ENUM_OPS(TYPE_CONVERSION_REMARKS)
#define AR_TOBJ_SCALAR AR_TOBJ_BASIC
#define AR_TOBJ_UNKNOWN AR_TOBJ_INVALID
#define AR_TPROP_VOID 0x0000000000000001
#define AR_TPROP_CONST 0x0000000000000002
#define AR_TPROP_IMP_CONST 0x0000000000000004
#define AR_TPROP_OBJECT 0x0000000000000008
#define AR_TPROP_SCALAR 0x0000000000000010
#define AR_TPROP_UNSIGNED 0x0000000000000020
#define AR_TPROP_NUMERIC 0x0000000000000040
#define AR_TPROP_INTEGRAL 0x0000000000000080
#define AR_TPROP_FLOATING 0x0000000000000100
#define AR_TPROP_LITERAL 0x0000000000000200
#define AR_TPROP_POINTER 0x0000000000000400
#define AR_TPROP_INPUT_PATCH 0x0000000000000800
#define AR_TPROP_OUTPUT_PATCH 0x0000000000001000
#define AR_TPROP_INH_IFACE 0x0000000000002000
#define AR_TPROP_HAS_COMPOUND 0x0000000000004000
#define AR_TPROP_HAS_TEXTURES 0x0000000000008000
#define AR_TPROP_HAS_SAMPLERS 0x0000000000010000
#define AR_TPROP_HAS_SAMPLER_CMPS 0x0000000000020000
#define AR_TPROP_HAS_STREAMS 0x0000000000040000
#define AR_TPROP_HAS_OTHER_OBJECTS 0x0000000000080000
#define AR_TPROP_HAS_BASIC 0x0000000000100000
#define AR_TPROP_HAS_BUFFERS 0x0000000000200000
#define AR_TPROP_HAS_ROBJECTS 0x0000000000400000
#define AR_TPROP_HAS_POINTERS 0x0000000000800000
#define AR_TPROP_INDEXABLE 0x0000000001000000
#define AR_TPROP_HAS_MIPS 0x0000000002000000
#define AR_TPROP_WRITABLE_GLOBAL 0x0000000004000000
#define AR_TPROP_HAS_UAVS 0x0000000008000000
#define AR_TPROP_HAS_BYTEADDRESS 0x0000000010000000
#define AR_TPROP_HAS_STRUCTURED 0x0000000020000000
#define AR_TPROP_HAS_SAMPLE 0x0000000040000000
#define AR_TPROP_MIN_PRECISION 0x0000000080000000
#define AR_TPROP_HAS_CBUFFERS 0x0000000100008000
#define AR_TPROP_HAS_TBUFFERS 0x0000000200008000
#define AR_TPROP_ALL 0xffffffffffffffff
#define AR_TPROP_HAS_OBJECTS \
(AR_TPROP_HAS_TEXTURES | AR_TPROP_HAS_SAMPLERS | AR_TPROP_HAS_SAMPLER_CMPS | \
AR_TPROP_HAS_STREAMS | AR_TPROP_HAS_OTHER_OBJECTS | AR_TPROP_HAS_BUFFERS | \
AR_TPROP_HAS_ROBJECTS | AR_TPROP_HAS_UAVS | AR_TPROP_HAS_BYTEADDRESS | \
AR_TPROP_HAS_STRUCTURED)
#define AR_TPROP_HAS_BASIC_RESOURCES \
(AR_TPROP_HAS_TEXTURES | AR_TPROP_HAS_SAMPLERS | AR_TPROP_HAS_SAMPLER_CMPS | \
AR_TPROP_HAS_BUFFERS | AR_TPROP_HAS_UAVS)
#define AR_TPROP_UNION_BITS \
(AR_TPROP_INH_IFACE | AR_TPROP_HAS_COMPOUND | AR_TPROP_HAS_TEXTURES | \
AR_TPROP_HAS_SAMPLERS | AR_TPROP_HAS_SAMPLER_CMPS | AR_TPROP_HAS_STREAMS | \
AR_TPROP_HAS_OTHER_OBJECTS | AR_TPROP_HAS_BASIC | AR_TPROP_HAS_BUFFERS | \
AR_TPROP_HAS_ROBJECTS | AR_TPROP_HAS_POINTERS | AR_TPROP_WRITABLE_GLOBAL | \
AR_TPROP_HAS_UAVS | AR_TPROP_HAS_BYTEADDRESS | AR_TPROP_HAS_STRUCTURED | \
AR_TPROP_MIN_PRECISION)
#define AR_TINFO_ALLOW_COMPLEX 0x00000001
#define AR_TINFO_ALLOW_OBJECTS 0x00000002
#define AR_TINFO_IGNORE_QUALIFIERS 0x00000004
#define AR_TINFO_OBJECTS_AS_ELEMENTS 0x00000008
#define AR_TINFO_PACK_SCALAR 0x00000010
#define AR_TINFO_PACK_ROW_MAJOR 0x00000020
#define AR_TINFO_PACK_TEMP_ARRAY 0x00000040
#define AR_TINFO_ALL_VAR_INFO 0x00000080
#define AR_TINFO_ALLOW_ALL (AR_TINFO_ALLOW_COMPLEX | AR_TINFO_ALLOW_OBJECTS)
#define AR_TINFO_PACK_CBUFFER 0
#define AR_TINFO_LAYOUT_PACK_ALL \
(AR_TINFO_PACK_SCALAR | AR_TINFO_PACK_TEMP_ARRAY)
#define AR_TINFO_SIMPLE_OBJECTS \
(AR_TINFO_ALLOW_OBJECTS | AR_TINFO_OBJECTS_AS_ELEMENTS)
struct ArTypeInfo {
ArTypeObjectKind ShapeKind; // The shape of the type (basic, matrix, etc.)
ArBasicKind EltKind; // The primitive type of elements in this type.
const clang::Type *EltTy; // Canonical element type ptr
ArBasicKind
ObjKind; // The object type for this type (textures, buffers, etc.)
UINT uRows;
UINT uCols;
UINT uTotalElts;
};
using namespace clang;
using namespace clang::sema;
using namespace hlsl;
extern const char *HLSLScalarTypeNames[];
static const bool ExplicitConversionFalse =
false; // a conversion operation is not the result of an explicit cast
static const bool ParameterPackFalse =
false; // template parameter is not an ellipsis.
static const bool TypenameTrue =
false; // 'typename' specified rather than 'class' for a template argument.
static const bool DelayTypeCreationTrue =
true; // delay type creation for a declaration
static const SourceLocation NoLoc; // no source location attribution available
static const SourceRange NoRange; // no source range attribution available
static const bool HasWrittenPrototypeTrue =
true; // function had the prototype written
static const bool InlineSpecifiedFalse =
false; // function was not specified as inline
static const bool IsConstexprFalse = false; // function is not constexpr
static const bool ListInitializationFalse =
false; // not performing a list initialization
static const bool SuppressWarningsFalse =
false; // do not suppress warning diagnostics
static const bool SuppressErrorsTrue = true; // suppress error diagnostics
static const bool SuppressErrorsFalse =
false; // do not suppress error diagnostics
static const int OneRow = 1; // a single row for a type
static const bool MipsFalse = false; // a type does not support the .mips member
static const bool MipsTrue = true; // a type supports the .mips member
static const bool SampleFalse =
false; // a type does not support the .sample member
static const bool SampleTrue = true; // a type supports the .sample member
static const size_t MaxVectorSize = 4; // maximum size for a vector
static QualType
GetOrCreateTemplateSpecialization(ASTContext &context, Sema &sema,
ClassTemplateDecl *templateDecl,
ArrayRef<TemplateArgument> templateArgs) {
DXASSERT_NOMSG(templateDecl);
DeclContext *currentDeclContext = context.getTranslationUnitDecl();
SmallVector<TemplateArgument, 3> templateArgsForDecl;
for (const TemplateArgument &Arg : templateArgs) {
if (Arg.getKind() == TemplateArgument::Type) {
// the class template need to use CanonicalType
templateArgsForDecl.emplace_back(
TemplateArgument(Arg.getAsType().getCanonicalType()));
} else
templateArgsForDecl.emplace_back(Arg);
}
// First, try looking up existing specialization
void *InsertPos = nullptr;
ClassTemplateSpecializationDecl *specializationDecl =
templateDecl->findSpecialization(templateArgsForDecl, InsertPos);
if (specializationDecl) {
// Instantiate the class template if not yet.
if (specializationDecl->getInstantiatedFrom().isNull()) {
// InstantiateClassTemplateSpecialization returns true if it finds an
// error.
DXVERIFY_NOMSG(false ==
sema.InstantiateClassTemplateSpecialization(
NoLoc, specializationDecl,
TemplateSpecializationKind::TSK_ImplicitInstantiation,
true));
}
return context.getTemplateSpecializationType(
TemplateName(templateDecl), templateArgs.data(), templateArgs.size(),
context.getTypeDeclType(specializationDecl));
}
specializationDecl = ClassTemplateSpecializationDecl::Create(
context, TagDecl::TagKind::TTK_Class, currentDeclContext, NoLoc, NoLoc,
templateDecl, templateArgsForDecl.data(), templateArgsForDecl.size(),
nullptr);
// InstantiateClassTemplateSpecialization returns true if it finds an error.
DXVERIFY_NOMSG(false ==
sema.InstantiateClassTemplateSpecialization(
NoLoc, specializationDecl,
TemplateSpecializationKind::TSK_ImplicitInstantiation,
true));
templateDecl->AddSpecialization(specializationDecl, InsertPos);
specializationDecl->setImplicit(true);
QualType canonType = context.getTypeDeclType(specializationDecl);
DXASSERT(isa<RecordType>(canonType),
"type of non-dependent specialization is not a RecordType");
TemplateArgumentListInfo templateArgumentList(NoLoc, NoLoc);
TemplateArgumentLocInfo NoTemplateArgumentLocInfo;
for (unsigned i = 0; i < templateArgs.size(); i++) {
templateArgumentList.addArgument(
TemplateArgumentLoc(templateArgs[i], NoTemplateArgumentLocInfo));
}
return context.getTemplateSpecializationType(TemplateName(templateDecl),
templateArgumentList, canonType);
}
/// <summary>Instantiates a new matrix type specialization or gets an existing
/// one from the AST.</summary>
static QualType GetOrCreateMatrixSpecialization(
ASTContext &context, Sema *sema, ClassTemplateDecl *matrixTemplateDecl,
QualType elementType, uint64_t rowCount, uint64_t colCount) {
DXASSERT_NOMSG(sema);
TemplateArgument templateArgs[3] = {
TemplateArgument(elementType),
TemplateArgument(
context,
llvm::APSInt(
llvm::APInt(context.getIntWidth(context.IntTy), rowCount), false),
context.IntTy),
TemplateArgument(
context,
llvm::APSInt(
llvm::APInt(context.getIntWidth(context.IntTy), colCount), false),
context.IntTy)};
QualType matrixSpecializationType = GetOrCreateTemplateSpecialization(
context, *sema, matrixTemplateDecl,
ArrayRef<TemplateArgument>(templateArgs));
#ifndef NDEBUG
// Verify that we can read the field member from the template record.
DXASSERT(matrixSpecializationType->getAsCXXRecordDecl(),
"type of non-dependent specialization is not a RecordType");
DeclContext::lookup_result lookupResult =
matrixSpecializationType->getAsCXXRecordDecl()->lookup(
DeclarationName(&context.Idents.get(StringRef("h"))));
DXASSERT(!lookupResult.empty(),
"otherwise matrix handle cannot be looked up");
#endif
return matrixSpecializationType;
}
/// <summary>Instantiates a new vector type specialization or gets an existing
/// one from the AST.</summary>
static QualType
GetOrCreateVectorSpecialization(ASTContext &context, Sema *sema,
ClassTemplateDecl *vectorTemplateDecl,
QualType elementType, uint64_t colCount) {
DXASSERT_NOMSG(sema);
DXASSERT_NOMSG(vectorTemplateDecl);
TemplateArgument templateArgs[2] = {
TemplateArgument(elementType),
TemplateArgument(
context,
llvm::APSInt(
llvm::APInt(context.getIntWidth(context.IntTy), colCount), false),
context.IntTy)};
QualType vectorSpecializationType = GetOrCreateTemplateSpecialization(
context, *sema, vectorTemplateDecl,
ArrayRef<TemplateArgument>(templateArgs));
#ifndef NDEBUG
// Verify that we can read the field member from the template record.
DXASSERT(vectorSpecializationType->getAsCXXRecordDecl(),
"type of non-dependent specialization is not a RecordType");
DeclContext::lookup_result lookupResult =
vectorSpecializationType->getAsCXXRecordDecl()->lookup(
DeclarationName(&context.Idents.get(StringRef("h"))));
DXASSERT(!lookupResult.empty(),
"otherwise vector handle cannot be looked up");
#endif
return vectorSpecializationType;
}
// Gets component type, dimM, and dimN from WaveMatrix* instantiated type.
// Assumes wave matrix type, returns false if anything isn't as expected.
static bool GetWaveMatrixTemplateValues(QualType objType, QualType *compType,
unsigned *dimM, unsigned *dimN) {
const CXXRecordDecl *CXXRD = objType.getCanonicalType()->getAsCXXRecordDecl();
if (const ClassTemplateSpecializationDecl *templateSpecializationDecl =
dyn_cast<ClassTemplateSpecializationDecl>(CXXRD)) {
const clang::TemplateArgumentList &args =
templateSpecializationDecl->getTemplateInstantiationArgs();
if (args.size() != 3)
return false;
if (args[0].getKind() != TemplateArgument::Type ||
!args[0].getAsType()->isBuiltinType())
return false;
if (args[1].getKind() != TemplateArgument::Integral ||
args[2].getKind() != TemplateArgument::Integral)
return false;
if (compType)
*compType = args[0].getAsType();