summaryrefslogtreecommitdiff
path: root/thirdparty/spirv-reflect/spirv_reflect.h
blob: 21f81607700e03bfc7af8bbdf47fb267d5744aff (plain)
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
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
2141
2142
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
2162
2163
2164
2165
2166
2167
2168
2169
2170
2171
2172
2173
2174
2175
2176
2177
2178
2179
2180
2181
2182
2183
2184
2185
2186
2187
2188
2189
2190
2191
2192
2193
2194
2195
2196
2197
2198
2199
2200
2201
2202
2203
2204
2205
2206
2207
2208
2209
2210
2211
2212
2213
2214
2215
2216
2217
2218
2219
2220
2221
2222
2223
2224
2225
2226
2227
2228
2229
2230
2231
2232
2233
2234
/*
 Copyright 2017-2018 Google Inc.

 Licensed under the Apache License, Version 2.0 (the "License");
 you may not use this file except in compliance with the License.
 You may obtain a copy of the License at

 http://www.apache.org/licenses/LICENSE-2.0

 Unless required by applicable law or agreed to in writing, software
 distributed under the License is distributed on an "AS IS" BASIS,
 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 See the License for the specific language governing permissions and
 limitations under the License.
*/

/*

VERSION HISTORY

  1.0   (2018-03-27) Initial public release

*/

/*!

 @file spirv_reflect.h

*/
#ifndef SPIRV_REFLECT_H
#define SPIRV_REFLECT_H

#include "./include/spirv/unified1/spirv.h"

#include <stdint.h>
#include <string.h>

#ifdef _MSC_VER
  #define SPV_REFLECT_DEPRECATED(msg_str) __declspec(deprecated("This symbol is deprecated. Details: " msg_str))
#elif defined(__clang__)
  #define SPV_REFLECT_DEPRECATED(msg_str) __attribute__((deprecated(msg_str)))
#elif defined(__GNUC__)
  #if GCC_VERSION >= 40500
    #define SPV_REFLECT_DEPRECATED(msg_str) __attribute__((deprecated(msg_str)))
  #else
    #define SPV_REFLECT_DEPRECATED(msg_str) __attribute__((deprecated))
  #endif
#else
  #define SPV_REFLECT_DEPRECATED(msg_str)
#endif

/*! @enum SpvReflectResult

*/
typedef enum SpvReflectResult {
  SPV_REFLECT_RESULT_SUCCESS,
  SPV_REFLECT_RESULT_NOT_READY,
  SPV_REFLECT_RESULT_ERROR_PARSE_FAILED,
  SPV_REFLECT_RESULT_ERROR_ALLOC_FAILED,
  SPV_REFLECT_RESULT_ERROR_RANGE_EXCEEDED,
  SPV_REFLECT_RESULT_ERROR_NULL_POINTER,
  SPV_REFLECT_RESULT_ERROR_INTERNAL_ERROR,
  SPV_REFLECT_RESULT_ERROR_COUNT_MISMATCH,
  SPV_REFLECT_RESULT_ERROR_ELEMENT_NOT_FOUND,
  SPV_REFLECT_RESULT_ERROR_SPIRV_INVALID_CODE_SIZE,
  SPV_REFLECT_RESULT_ERROR_SPIRV_INVALID_MAGIC_NUMBER,
  SPV_REFLECT_RESULT_ERROR_SPIRV_UNEXPECTED_EOF,
  SPV_REFLECT_RESULT_ERROR_SPIRV_INVALID_ID_REFERENCE,
  SPV_REFLECT_RESULT_ERROR_SPIRV_SET_NUMBER_OVERFLOW,
  SPV_REFLECT_RESULT_ERROR_SPIRV_INVALID_STORAGE_CLASS,
  SPV_REFLECT_RESULT_ERROR_SPIRV_RECURSION,
  SPV_REFLECT_RESULT_ERROR_SPIRV_INVALID_INSTRUCTION,
  SPV_REFLECT_RESULT_ERROR_SPIRV_UNEXPECTED_BLOCK_DATA,
  SPV_REFLECT_RESULT_ERROR_SPIRV_INVALID_BLOCK_MEMBER_REFERENCE,
  SPV_REFLECT_RESULT_ERROR_SPIRV_INVALID_ENTRY_POINT,
  SPV_REFLECT_RESULT_ERROR_SPIRV_INVALID_EXECUTION_MODE,
} SpvReflectResult;

/*! @enum SpvReflectTypeFlagBits

*/
typedef enum SpvReflectTypeFlagBits {
  SPV_REFLECT_TYPE_FLAG_UNDEFINED                       = 0x00000000,
  SPV_REFLECT_TYPE_FLAG_VOID                            = 0x00000001,
  SPV_REFLECT_TYPE_FLAG_BOOL                            = 0x00000002,
  SPV_REFLECT_TYPE_FLAG_INT                             = 0x00000004,
  SPV_REFLECT_TYPE_FLAG_FLOAT                           = 0x00000008,
  SPV_REFLECT_TYPE_FLAG_VECTOR                          = 0x00000100,
  SPV_REFLECT_TYPE_FLAG_MATRIX                          = 0x00000200,
  SPV_REFLECT_TYPE_FLAG_EXTERNAL_IMAGE                  = 0x00010000,
  SPV_REFLECT_TYPE_FLAG_EXTERNAL_SAMPLER                = 0x00020000,
  SPV_REFLECT_TYPE_FLAG_EXTERNAL_SAMPLED_IMAGE          = 0x00040000,
  SPV_REFLECT_TYPE_FLAG_EXTERNAL_BLOCK                  = 0x00080000,
  SPV_REFLECT_TYPE_FLAG_EXTERNAL_ACCELERATION_STRUCTURE = 0x00100000,
  SPV_REFLECT_TYPE_FLAG_EXTERNAL_MASK                   = 0x00FF0000,
  SPV_REFLECT_TYPE_FLAG_STRUCT                          = 0x10000000,
  SPV_REFLECT_TYPE_FLAG_ARRAY                           = 0x20000000,
} SpvReflectTypeFlagBits;

typedef uint32_t SpvReflectTypeFlags;

/*! @enum SpvReflectDecorationBits

*/
typedef enum SpvReflectDecorationFlagBits {
  SPV_REFLECT_DECORATION_NONE                   = 0x00000000,
  SPV_REFLECT_DECORATION_BLOCK                  = 0x00000001,
  SPV_REFLECT_DECORATION_BUFFER_BLOCK           = 0x00000002,
  SPV_REFLECT_DECORATION_ROW_MAJOR              = 0x00000004,
  SPV_REFLECT_DECORATION_COLUMN_MAJOR           = 0x00000008,
  SPV_REFLECT_DECORATION_BUILT_IN               = 0x00000010,
  SPV_REFLECT_DECORATION_NOPERSPECTIVE          = 0x00000020,
  SPV_REFLECT_DECORATION_FLAT                   = 0x00000040,
  SPV_REFLECT_DECORATION_NON_WRITABLE           = 0x00000080,
} SpvReflectDecorationFlagBits;

typedef uint32_t SpvReflectDecorationFlags;

/*! @enum SpvReflectResourceType

*/
typedef enum SpvReflectResourceType {
  SPV_REFLECT_RESOURCE_FLAG_UNDEFINED           = 0x00000000,
  SPV_REFLECT_RESOURCE_FLAG_SAMPLER             = 0x00000001,
  SPV_REFLECT_RESOURCE_FLAG_CBV                 = 0x00000002,
  SPV_REFLECT_RESOURCE_FLAG_SRV                 = 0x00000004,
  SPV_REFLECT_RESOURCE_FLAG_UAV                 = 0x00000008,
} SpvReflectResourceType;

/*! @enum SpvReflectFormat

*/
typedef enum SpvReflectFormat {
  SPV_REFLECT_FORMAT_UNDEFINED           =   0, // = VK_FORMAT_UNDEFINED
  SPV_REFLECT_FORMAT_R32_UINT            =  98, // = VK_FORMAT_R32_UINT
  SPV_REFLECT_FORMAT_R32_SINT            =  99, // = VK_FORMAT_R32_SINT
  SPV_REFLECT_FORMAT_R32_SFLOAT          = 100, // = VK_FORMAT_R32_SFLOAT
  SPV_REFLECT_FORMAT_R32G32_UINT         = 101, // = VK_FORMAT_R32G32_UINT
  SPV_REFLECT_FORMAT_R32G32_SINT         = 102, // = VK_FORMAT_R32G32_SINT
  SPV_REFLECT_FORMAT_R32G32_SFLOAT       = 103, // = VK_FORMAT_R32G32_SFLOAT
  SPV_REFLECT_FORMAT_R32G32B32_UINT      = 104, // = VK_FORMAT_R32G32B32_UINT
  SPV_REFLECT_FORMAT_R32G32B32_SINT      = 105, // = VK_FORMAT_R32G32B32_SINT
  SPV_REFLECT_FORMAT_R32G32B32_SFLOAT    = 106, // = VK_FORMAT_R32G32B32_SFLOAT
  SPV_REFLECT_FORMAT_R32G32B32A32_UINT   = 107, // = VK_FORMAT_R32G32B32A32_UINT
  SPV_REFLECT_FORMAT_R32G32B32A32_SINT   = 108, // = VK_FORMAT_R32G32B32A32_SINT
  SPV_REFLECT_FORMAT_R32G32B32A32_SFLOAT = 109, // = VK_FORMAT_R32G32B32A32_SFLOAT
  SPV_REFLECT_FORMAT_R64_UINT            = 110, // = VK_FORMAT_R64_UINT
  SPV_REFLECT_FORMAT_R64_SINT            = 111, // = VK_FORMAT_R64_SINT
  SPV_REFLECT_FORMAT_R64_SFLOAT          = 112, // = VK_FORMAT_R64_SFLOAT
  SPV_REFLECT_FORMAT_R64G64_UINT         = 113, // = VK_FORMAT_R64G64_UINT
  SPV_REFLECT_FORMAT_R64G64_SINT         = 114, // = VK_FORMAT_R64G64_SINT
  SPV_REFLECT_FORMAT_R64G64_SFLOAT       = 115, // = VK_FORMAT_R64G64_SFLOAT
  SPV_REFLECT_FORMAT_R64G64B64_UINT      = 116, // = VK_FORMAT_R64G64B64_UINT
  SPV_REFLECT_FORMAT_R64G64B64_SINT      = 117, // = VK_FORMAT_R64G64B64_SINT
  SPV_REFLECT_FORMAT_R64G64B64_SFLOAT    = 118, // = VK_FORMAT_R64G64B64_FLOAT
  SPV_REFLECT_FORMAT_R64G64B64A64_UINT   = 119, // = VK_FORMAT_R64G64B64A64_UINT
  SPV_REFLECT_FORMAT_R64G64B64A64_SINT   = 120, // = VK_FORMAT_R64G64B64A64_SINT
  SPV_REFLECT_FORMAT_R64G64B64A64_SFLOAT = 121, // = VK_FORMAT_R64G64B64A64_SFLOAT
} SpvReflectFormat;

/*! @enum SpvReflectVariableFlagBits

*/
enum SpvReflectVariableFlagBits{
  SPV_REFLECT_VARIABLE_FLAGS_NONE   = 0x00000000,
  SPV_REFLECT_VARIABLE_FLAGS_UNUSED = 0x00000001,
};

typedef uint32_t SpvReflectVariableFlags;

/*! @enum SpvReflectDescriptorType

*/
typedef enum SpvReflectDescriptorType {
  SPV_REFLECT_DESCRIPTOR_TYPE_SAMPLER                    =  0,        // = VK_DESCRIPTOR_TYPE_SAMPLER
  SPV_REFLECT_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER     =  1,        // = VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER
  SPV_REFLECT_DESCRIPTOR_TYPE_SAMPLED_IMAGE              =  2,        // = VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE
  SPV_REFLECT_DESCRIPTOR_TYPE_STORAGE_IMAGE              =  3,        // = VK_DESCRIPTOR_TYPE_STORAGE_IMAGE
  SPV_REFLECT_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER       =  4,        // = VK_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER
  SPV_REFLECT_DESCRIPTOR_TYPE_STORAGE_TEXEL_BUFFER       =  5,        // = VK_DESCRIPTOR_TYPE_STORAGE_TEXEL_BUFFER
  SPV_REFLECT_DESCRIPTOR_TYPE_UNIFORM_BUFFER             =  6,        // = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER
  SPV_REFLECT_DESCRIPTOR_TYPE_STORAGE_BUFFER             =  7,        // = VK_DESCRIPTOR_TYPE_STORAGE_BUFFER
  SPV_REFLECT_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC     =  8,        // = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC
  SPV_REFLECT_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC     =  9,        // = VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC
  SPV_REFLECT_DESCRIPTOR_TYPE_INPUT_ATTACHMENT           = 10,        // = VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT
  SPV_REFLECT_DESCRIPTOR_TYPE_ACCELERATION_STRUCTURE_KHR = 1000150000 // = VK_DESCRIPTOR_TYPE_ACCELERATION_STRUCTURE_KHR
} SpvReflectDescriptorType;

/*! @enum SpvReflectShaderStageFlagBits

*/
typedef enum SpvReflectShaderStageFlagBits {
  SPV_REFLECT_SHADER_STAGE_VERTEX_BIT                  = 0x00000001, // = VK_SHADER_STAGE_VERTEX_BIT
  SPV_REFLECT_SHADER_STAGE_TESSELLATION_CONTROL_BIT    = 0x00000002, // = VK_SHADER_STAGE_TESSELLATION_CONTROL_BIT
  SPV_REFLECT_SHADER_STAGE_TESSELLATION_EVALUATION_BIT = 0x00000004, // = VK_SHADER_STAGE_TESSELLATION_EVALUATION_BIT
  SPV_REFLECT_SHADER_STAGE_GEOMETRY_BIT                = 0x00000008, // = VK_SHADER_STAGE_GEOMETRY_BIT
  SPV_REFLECT_SHADER_STAGE_FRAGMENT_BIT                = 0x00000010, // = VK_SHADER_STAGE_FRAGMENT_BIT
  SPV_REFLECT_SHADER_STAGE_COMPUTE_BIT                 = 0x00000020, // = VK_SHADER_STAGE_COMPUTE_BIT
  SPV_REFLECT_SHADER_STAGE_TASK_BIT_NV                 = 0x00000040, // = VK_SHADER_STAGE_TASK_BIT_NV
  SPV_REFLECT_SHADER_STAGE_MESH_BIT_NV                 = 0x00000080, // = VK_SHADER_STAGE_MESH_BIT_NV
  SPV_REFLECT_SHADER_STAGE_RAYGEN_BIT_KHR              = 0x00000100, // VK_SHADER_STAGE_RAYGEN_BIT_KHR
  SPV_REFLECT_SHADER_STAGE_ANY_HIT_BIT_KHR             = 0x00000200, // VK_SHADER_STAGE_ANY_HIT_BIT_KHR
  SPV_REFLECT_SHADER_STAGE_CLOSEST_HIT_BIT_KHR         = 0x00000400, // VK_SHADER_STAGE_CLOSEST_HIT_BIT_KHR
  SPV_REFLECT_SHADER_STAGE_MISS_BIT_KHR                = 0x00000800, // VK_SHADER_STAGE_MISS_BIT_KHR
  SPV_REFLECT_SHADER_STAGE_INTERSECTION_BIT_KHR        = 0x00001000, // VK_SHADER_STAGE_INTERSECTION_BIT_KHR
  SPV_REFLECT_SHADER_STAGE_CALLABLE_BIT_KHR            = 0x00002000, // VK_SHADER_STAGE_CALLABLE_BIT_KHR

} SpvReflectShaderStageFlagBits;

/*! @enum SpvReflectGenerator

*/
typedef enum SpvReflectGenerator {
  SPV_REFLECT_GENERATOR_KHRONOS_LLVM_SPIRV_TRANSLATOR         = 6,
  SPV_REFLECT_GENERATOR_KHRONOS_SPIRV_TOOLS_ASSEMBLER         = 7,
  SPV_REFLECT_GENERATOR_KHRONOS_GLSLANG_REFERENCE_FRONT_END   = 8,
  SPV_REFLECT_GENERATOR_GOOGLE_SHADERC_OVER_GLSLANG           = 13,
  SPV_REFLECT_GENERATOR_GOOGLE_SPIREGG                        = 14,
  SPV_REFLECT_GENERATOR_GOOGLE_RSPIRV                         = 15,
  SPV_REFLECT_GENERATOR_X_LEGEND_MESA_MESAIR_SPIRV_TRANSLATOR = 16,
  SPV_REFLECT_GENERATOR_KHRONOS_SPIRV_TOOLS_LINKER            = 17,
  SPV_REFLECT_GENERATOR_WINE_VKD3D_SHADER_COMPILER            = 18,
  SPV_REFLECT_GENERATOR_CLAY_CLAY_SHADER_COMPILER             = 19,
} SpvReflectGenerator;

enum {
  SPV_REFLECT_MAX_ARRAY_DIMS                    = 32,
  SPV_REFLECT_MAX_DESCRIPTOR_SETS               = 64,
};

enum {
  SPV_REFLECT_BINDING_NUMBER_DONT_CHANGE        = ~0,
  SPV_REFLECT_SET_NUMBER_DONT_CHANGE            = ~0
};

typedef struct SpvReflectNumericTraits {
  struct Scalar {
    uint32_t                        width;
    uint32_t                        signedness;
  } scalar;

  struct Vector {
    uint32_t                        component_count;
  } vector;

  struct Matrix {
    uint32_t                        column_count;
    uint32_t                        row_count;
    uint32_t                        stride; // Measured in bytes
  } matrix;
} SpvReflectNumericTraits;

typedef struct SpvReflectImageTraits {
  SpvDim                            dim;
  uint32_t                          depth;
  uint32_t                          arrayed;
  uint32_t                          ms; // 0: single-sampled; 1: multisampled
  uint32_t                          sampled;
  SpvImageFormat                    image_format;
} SpvReflectImageTraits;

typedef struct SpvReflectArrayTraits {
  uint32_t                          dims_count;
  uint32_t                          dims[SPV_REFLECT_MAX_ARRAY_DIMS];
  uint32_t                          stride; // Measured in bytes
} SpvReflectArrayTraits;

typedef struct SpvReflectBindingArrayTraits {
  uint32_t                          dims_count;
  uint32_t                          dims[SPV_REFLECT_MAX_ARRAY_DIMS];
} SpvReflectBindingArrayTraits;

/*! @struct SpvReflectTypeDescription

*/
typedef struct SpvReflectTypeDescription {
  uint32_t                          id;
  SpvOp                             op;
  const char*                       type_name;
  const char*                       struct_member_name;
  SpvStorageClass                   storage_class;
  SpvReflectTypeFlags               type_flags;
  SpvReflectDecorationFlags         decoration_flags;

  struct Traits {
    SpvReflectNumericTraits         numeric;
    SpvReflectImageTraits           image;
    SpvReflectArrayTraits           array;
  } traits;

  uint32_t                          member_count;
  struct SpvReflectTypeDescription* members;
} SpvReflectTypeDescription;

// -- GODOT begin --
/*! @struct SpvReflectSpecializationConstant

*/

typedef enum SpvReflectSpecializationConstantType {
  SPV_REFLECT_SPECIALIZATION_CONSTANT_BOOL = 0,
  SPV_REFLECT_SPECIALIZATION_CONSTANT_INT = 1,
  SPV_REFLECT_SPECIALIZATION_CONSTANT_FLOAT = 2,
} SpvReflectSpecializationConstantType;

typedef struct SpvReflectSpecializationConstant {
  const char* name;
  uint32_t spirv_id;
  uint32_t constant_id;
  SpvReflectSpecializationConstantType constant_type;
  union {
    float float_value;
    uint32_t int_bool_value;
  } default_value;
} SpvReflectSpecializationConstant;
// -- GODOT end --

/*! @struct SpvReflectInterfaceVariable

*/
typedef struct SpvReflectInterfaceVariable {
  uint32_t                            spirv_id;
  const char*                         name;
  uint32_t                            location;
  SpvStorageClass                     storage_class;
  const char*                         semantic;
  SpvReflectDecorationFlags           decoration_flags;
  SpvBuiltIn                          built_in;
  SpvReflectNumericTraits             numeric;
  SpvReflectArrayTraits               array;

  uint32_t                            member_count;
  struct SpvReflectInterfaceVariable* members;

  SpvReflectFormat                    format;

  // NOTE: SPIR-V shares type references for variables
  //       that have the same underlying type. This means
  //       that the same type name will appear for multiple
  //       variables.
  SpvReflectTypeDescription*          type_description;

  struct {
    uint32_t                          location;
  } word_offset;
} SpvReflectInterfaceVariable;

/*! @struct SpvReflectBlockVariable

*/
typedef struct SpvReflectBlockVariable {
  uint32_t                          spirv_id;
  const char*                       name;
  uint32_t                          offset;           // Measured in bytes
  uint32_t                          absolute_offset;  // Measured in bytes
  uint32_t                          size;             // Measured in bytes
  uint32_t                          padded_size;      // Measured in bytes
  SpvReflectDecorationFlags         decoration_flags;
  SpvReflectNumericTraits           numeric;
  SpvReflectArrayTraits             array;
  SpvReflectVariableFlags           flags;

  uint32_t                          member_count;
  struct SpvReflectBlockVariable*   members;

  SpvReflectTypeDescription*        type_description;
} SpvReflectBlockVariable;

/*! @struct SpvReflectDescriptorBinding

*/
typedef struct SpvReflectDescriptorBinding {
  uint32_t                            spirv_id;
  const char*                         name;
  uint32_t                            binding;
  uint32_t                            input_attachment_index;
  uint32_t                            set;
  SpvReflectDescriptorType            descriptor_type;
  SpvReflectResourceType              resource_type;
  SpvReflectImageTraits               image;
  SpvReflectBlockVariable             block;
  SpvReflectBindingArrayTraits        array;
  uint32_t                            count;
  uint32_t                            accessed;
  uint32_t                            uav_counter_id;
  struct SpvReflectDescriptorBinding* uav_counter_binding;

  SpvReflectTypeDescription*          type_description;

  struct {
    uint32_t                          binding;
    uint32_t                          set;
  } word_offset;
} SpvReflectDescriptorBinding;

/*! @struct SpvReflectDescriptorSet

*/
typedef struct SpvReflectDescriptorSet {
  uint32_t                          set;
  uint32_t                          binding_count;
  SpvReflectDescriptorBinding**     bindings;
} SpvReflectDescriptorSet;

/*! @struct SpvReflectEntryPoint

 */
typedef struct SpvReflectEntryPoint {
  const char*                       name;
  uint32_t                          id;

  SpvExecutionModel                 spirv_execution_model;
  SpvReflectShaderStageFlagBits     shader_stage;

  uint32_t                          input_variable_count;  
  SpvReflectInterfaceVariable**     input_variables;       
  uint32_t                          output_variable_count; 
  SpvReflectInterfaceVariable**     output_variables;      
  uint32_t                          interface_variable_count;
  SpvReflectInterfaceVariable*      interface_variables;

  uint32_t                          descriptor_set_count;
  SpvReflectDescriptorSet*          descriptor_sets;

  uint32_t                          used_uniform_count;
  uint32_t*                         used_uniforms;
  uint32_t                          used_push_constant_count;
  uint32_t*                         used_push_constants;

  struct LocalSize {
    uint32_t                        x;
    uint32_t                        y;
    uint32_t                        z;
  } local_size;
} SpvReflectEntryPoint;

/*! @struct SpvReflectShaderModule

*/
typedef struct SpvReflectShaderModule {
  SpvReflectGenerator               generator;
  const char*                       entry_point_name;
  uint32_t                          entry_point_id;
  uint32_t                          entry_point_count;
  SpvReflectEntryPoint*             entry_points;
  SpvSourceLanguage                 source_language;
  uint32_t                          source_language_version;
  const char*                       source_file;
  const char*                       source_source;
  SpvExecutionModel                 spirv_execution_model;
  SpvReflectShaderStageFlagBits     shader_stage;
  uint32_t                          descriptor_binding_count;
  SpvReflectDescriptorBinding*      descriptor_bindings;
  uint32_t                          descriptor_set_count;
  SpvReflectDescriptorSet           descriptor_sets[SPV_REFLECT_MAX_DESCRIPTOR_SETS];
  uint32_t                          input_variable_count;  
  SpvReflectInterfaceVariable**     input_variables;       
  uint32_t                          output_variable_count; 
  SpvReflectInterfaceVariable**     output_variables;      
  uint32_t                          interface_variable_count;
  SpvReflectInterfaceVariable*      interface_variables;
  uint32_t                          push_constant_block_count;
  SpvReflectBlockVariable*          push_constant_blocks;
  // -- GODOT begin --
  uint32_t                          specialization_constant_count;
  SpvReflectSpecializationConstant* specialization_constants;
  // -- GODOT end --

  struct Internal {
    size_t                          spirv_size;
    uint32_t*                       spirv_code;
    uint32_t                        spirv_word_count;

    size_t                          type_description_count;
    SpvReflectTypeDescription*      type_descriptions;
  } * _internal;

} SpvReflectShaderModule;

#if defined(__cplusplus)
extern "C" {
#endif

/*! @fn spvReflectCreateShaderModule

 @param  size      Size in bytes of SPIR-V code.
 @param  p_code    Pointer to SPIR-V code.
 @param  p_module  Pointer to an instance of SpvReflectShaderModule.
 @return           SPV_REFLECT_RESULT_SUCCESS on success.

*/
SpvReflectResult spvReflectCreateShaderModule(
  size_t                   size,
  const void*              p_code,
  SpvReflectShaderModule*  p_module
);

SPV_REFLECT_DEPRECATED("renamed to spvReflectCreateShaderModule")
SpvReflectResult spvReflectGetShaderModule(
  size_t                   size,
  const void*              p_code,
  SpvReflectShaderModule*  p_module
);


/*! @fn spvReflectDestroyShaderModule

 @param  p_module  Pointer to an instance of SpvReflectShaderModule.

*/
void spvReflectDestroyShaderModule(SpvReflectShaderModule* p_module);


/*! @fn spvReflectGetCodeSize

 @param  p_module  Pointer to an instance of SpvReflectShaderModule.
 @return           Returns the size of the SPIR-V in bytes

*/
uint32_t spvReflectGetCodeSize(const SpvReflectShaderModule* p_module);


/*! @fn spvReflectGetCode

 @param  p_module  Pointer to an instance of SpvReflectShaderModule.
 @return           Returns a const pointer to the compiled SPIR-V bytecode.

*/
const uint32_t* spvReflectGetCode(const SpvReflectShaderModule* p_module);

/*! @fn spvReflectGetEntryPoint

 @param  p_module     Pointer to an instance of SpvReflectShaderModule.
 @param  entry_point  Name of the requested entry point.
 @return              Returns a const pointer to the requested entry point,
                      or NULL if it's not found.
*/
const SpvReflectEntryPoint* spvReflectGetEntryPoint(
  const SpvReflectShaderModule* p_module,
  const char*                   entry_point
);

/*! @fn spvReflectEnumerateDescriptorBindings

 @param  p_module     Pointer to an instance of SpvReflectShaderModule.
 @param  p_count      If pp_bindings is NULL, the module's descriptor binding
                      count (across all descriptor sets) will be stored here.
                      If pp_bindings is not NULL, *p_count must contain the
                      module's descriptor binding count.
 @param  pp_bindings  If NULL, the module's total descriptor binding count
                      will be written to *p_count.
                      If non-NULL, pp_bindings must point to an array with
                      *p_count entries, where pointers to the module's
                      descriptor bindings will be written. The caller must not
                      free the binding pointers written to this array.
 @return              If successful, returns SPV_REFLECT_RESULT_SUCCESS.
                      Otherwise, the error code indicates the cause of the
                      failure.

*/
SpvReflectResult spvReflectEnumerateDescriptorBindings(
  const SpvReflectShaderModule*  p_module,
  uint32_t*                      p_count,
  SpvReflectDescriptorBinding**  pp_bindings
);

/*! @fn spvReflectEnumerateEntryPointDescriptorBindings
 @brief  Creates a listing of all descriptor bindings that are used in the
         static call tree of the given entry point.
 @param  p_module     Pointer to an instance of SpvReflectShaderModule.
 @param  entry_point  The name of the entry point to get the descriptor bindings for.
 @param  p_count      If pp_bindings is NULL, the entry point's descriptor binding
                      count (across all descriptor sets) will be stored here.
                      If pp_bindings is not NULL, *p_count must contain the
                      entry points's descriptor binding count.
 @param  pp_bindings  If NULL, the entry point's total descriptor binding count
                      will be written to *p_count.
                      If non-NULL, pp_bindings must point to an array with
                      *p_count entries, where pointers to the entry point's
                      descriptor bindings will be written. The caller must not
                      free the binding pointers written to this array.
 @return              If successful, returns SPV_REFLECT_RESULT_SUCCESS.
                      Otherwise, the error code indicates the cause of the
                      failure.

*/
SpvReflectResult spvReflectEnumerateEntryPointDescriptorBindings(
  const SpvReflectShaderModule* p_module,
  const char*                   entry_point,
  uint32_t*                     p_count,
  SpvReflectDescriptorBinding** pp_bindings
);

/*! @fn spvReflectEnumerateDescriptorSets

 @param  p_module  Pointer to an instance of SpvReflectShaderModule.
 @param  p_count   If pp_sets is NULL, the module's descriptor set
                   count will be stored here.
                   If pp_sets is not NULL, *p_count must contain the
                   module's descriptor set count.
 @param  pp_sets   If NULL, the module's total descriptor set count
                   will be written to *p_count.
                   If non-NULL, pp_sets must point to an array with
                   *p_count entries, where pointers to the module's
                   descriptor sets will be written. The caller must not
                   free the descriptor set pointers written to this array.
 @return           If successful, returns SPV_REFLECT_RESULT_SUCCESS.
                   Otherwise, the error code indicates the cause of the
                   failure.

*/
SpvReflectResult spvReflectEnumerateDescriptorSets(
  const SpvReflectShaderModule* p_module,
  uint32_t*                     p_count,
  SpvReflectDescriptorSet**     pp_sets
);

/*! @fn spvReflectEnumerateEntryPointDescriptorSets
 @brief  Creates a listing of all descriptor sets and their bindings that are
         used in the static call tree of a given entry point.
 @param  p_module    Pointer to an instance of SpvReflectShaderModule.
 @param  entry_point The name of the entry point to get the descriptor bindings for.
 @param  p_count     If pp_sets is NULL, the module's descriptor set
                     count will be stored here.
                     If pp_sets is not NULL, *p_count must contain the
                     module's descriptor set count.
 @param  pp_sets     If NULL, the module's total descriptor set count
                     will be written to *p_count.
                     If non-NULL, pp_sets must point to an array with
                     *p_count entries, where pointers to the module's
                     descriptor sets will be written. The caller must not
                     free the descriptor set pointers written to this array.
 @return             If successful, returns SPV_REFLECT_RESULT_SUCCESS.
                     Otherwise, the error code indicates the cause of the
                     failure.

*/
SpvReflectResult spvReflectEnumerateEntryPointDescriptorSets(
  const SpvReflectShaderModule* p_module,
  const char*                   entry_point,
  uint32_t*                     p_count,
  SpvReflectDescriptorSet**     pp_sets
);


/*! @fn spvReflectEnumerateInterfaceVariables
 @brief  If the module contains multiple entry points, this will only get
         the interface variables for the first one.
 @param  p_module      Pointer to an instance of SpvReflectShaderModule.
 @param  p_count       If pp_variables is NULL, the module's interface variable
                       count will be stored here.
                       If pp_variables is not NULL, *p_count must contain
                       the module's interface variable count.
 @param  pp_variables  If NULL, the module's interface variable count will be
                       written to *p_count.
                       If non-NULL, pp_variables must point to an array with
                       *p_count entries, where pointers to the module's
                       interface variables will be written. The caller must not
                       free the interface variables written to this array.
 @return               If successful, returns SPV_REFLECT_RESULT_SUCCESS.
                       Otherwise, the error code indicates the cause of the
                       failure.

*/
SpvReflectResult spvReflectEnumerateInterfaceVariables(
  const SpvReflectShaderModule* p_module,
  uint32_t*                     p_count,
  SpvReflectInterfaceVariable** pp_variables
);

/*! @fn spvReflectEnumerateEntryPointInterfaceVariables
 @brief  Enumerate the interface variables for a given entry point.
 @param  entry_point The name of the entry point to get the interface variables for.
 @param  p_module      Pointer to an instance of SpvReflectShaderModule.
 @param  p_count       If pp_variables is NULL, the entry point's interface variable
                       count will be stored here.
                       If pp_variables is not NULL, *p_count must contain
                       the entry point's interface variable count.
 @param  pp_variables  If NULL, the entry point's interface variable count will be
                       written to *p_count.
                       If non-NULL, pp_variables must point to an array with
                       *p_count entries, where pointers to the entry point's
                       interface variables will be written. The caller must not
                       free the interface variables written to this array.
 @return               If successful, returns SPV_REFLECT_RESULT_SUCCESS.
                       Otherwise, the error code indicates the cause of the
                       failure.

*/
SpvReflectResult spvReflectEnumerateEntryPointInterfaceVariables(
  const SpvReflectShaderModule* p_module,
  const char*                   entry_point,
  uint32_t*                     p_count,
  SpvReflectInterfaceVariable** pp_variables
);


/*! @fn spvReflectEnumerateInputVariables
 @brief  If the module contains multiple entry points, this will only get
         the input variables for the first one.
 @param  p_module      Pointer to an instance of SpvReflectShaderModule.
 @param  p_count       If pp_variables is NULL, the module's input variable
                       count will be stored here.
                       If pp_variables is not NULL, *p_count must contain
                       the module's input variable count.
 @param  pp_variables  If NULL, the module's input variable count will be
                       written to *p_count.
                       If non-NULL, pp_variables must point to an array with
                       *p_count entries, where pointers to the module's
                       input variables will be written. The caller must not
                       free the interface variables written to this array.
 @return               If successful, returns SPV_REFLECT_RESULT_SUCCESS.
                       Otherwise, the error code indicates the cause of the
                       failure.

*/
SpvReflectResult spvReflectEnumerateInputVariables(
  const SpvReflectShaderModule* p_module,
  uint32_t*                     p_count,
  SpvReflectInterfaceVariable** pp_variables
);

// -- GOODT begin --
/*! @fn spvReflectEnumerateSpecializationConstants
 @brief  If the module contains multiple entry points, this will only get
         the specialization constants for the first one.
 @param  p_module      Pointer to an instance of SpvReflectShaderModule.
 @param  p_count       If pp_constants is NULL, the module's specialization constant
                       count will be stored here.
                       If pp_variables is not NULL, *p_count must contain
                       the module's specialization constant count.
 @param  pp_variables  If NULL, the module's specialization constant count will be
                       written to *p_count.
                       If non-NULL, pp_constants must point to an array with
                       *p_count entries, where pointers to the module's
                       specialization constants will be written. The caller must not
                       free the specialization constants written to this array.
 @return               If successful, returns SPV_REFLECT_RESULT_SUCCESS.
                       Otherwise, the error code indicates the cause of the
                       failure.

*/
SpvReflectResult spvReflectEnumerateSpecializationConstants(
  const SpvReflectShaderModule*      p_module,
  uint32_t*                          p_count,
  SpvReflectSpecializationConstant** pp_constants
);
// -- GODOT end --

/*! @fn spvReflectEnumerateEntryPointInputVariables
 @brief  Enumerate the input variables for a given entry point.
 @param  entry_point The name of the entry point to get the input variables for.
 @param  p_module      Pointer to an instance of SpvReflectShaderModule.
 @param  p_count       If pp_variables is NULL, the entry point's input variable
                       count will be stored here.
                       If pp_variables is not NULL, *p_count must contain
                       the entry point's input variable count.
 @param  pp_variables  If NULL, the entry point's input variable count will be
                       written to *p_count.
                       If non-NULL, pp_variables must point to an array with
                       *p_count entries, where pointers to the entry point's
                       input variables will be written. The caller must not
                       free the interface variables written to this array.
 @return               If successful, returns SPV_REFLECT_RESULT_SUCCESS.
                       Otherwise, the error code indicates the cause of the
                       failure.

*/
SpvReflectResult spvReflectEnumerateEntryPointInputVariables(
  const SpvReflectShaderModule* p_module,
  const char*                   entry_point,
  uint32_t*                     p_count,
  SpvReflectInterfaceVariable** pp_variables
);


/*! @fn spvReflectEnumerateOutputVariables
 @brief  Note: If the module contains multiple entry points, this will only get
         the output variables for the first one.
 @param  p_module      Pointer to an instance of SpvReflectShaderModule.
 @param  p_count       If pp_variables is NULL, the module's output variable
                       count will be stored here.
                       If pp_variables is not NULL, *p_count must contain
                       the module's output variable count.
 @param  pp_variables  If NULL, the module's output variable count will be
                       written to *p_count.
                       If non-NULL, pp_variables must point to an array with
                       *p_count entries, where pointers to the module's
                       output variables will be written. The caller must not
                       free the interface variables written to this array.
 @return               If successful, returns SPV_REFLECT_RESULT_SUCCESS.
                       Otherwise, the error code indicates the cause of the
                       failure.

*/
SpvReflectResult spvReflectEnumerateOutputVariables(
  const SpvReflectShaderModule* p_module,
  uint32_t*                     p_count,
  SpvReflectInterfaceVariable** pp_variables
);

/*! @fn spvReflectEnumerateEntryPointOutputVariables
 @brief  Enumerate the output variables for a given entry point.
 @param  p_module      Pointer to an instance of SpvReflectShaderModule.
 @param  entry_point   The name of the entry point to get the output variables for.
 @param  p_count       If pp_variables is NULL, the entry point's output variable
                       count will be stored here.
                       If pp_variables is not NULL, *p_count must contain
                       the entry point's output variable count.
 @param  pp_variables  If NULL, the entry point's output variable count will be
                       written to *p_count.
                       If non-NULL, pp_variables must point to an array with
                       *p_count entries, where pointers to the entry point's
                       output variables will be written. The caller must not
                       free the interface variables written to this array.
 @return               If successful, returns SPV_REFLECT_RESULT_SUCCESS.
                       Otherwise, the error code indicates the cause of the
                       failure.

*/
SpvReflectResult spvReflectEnumerateEntryPointOutputVariables(
  const SpvReflectShaderModule* p_module,
  const char*                   entry_point,
  uint32_t*                     p_count,
  SpvReflectInterfaceVariable** pp_variables
);


/*! @fn spvReflectEnumeratePushConstantBlocks
 @brief  Note: If the module contains multiple entry points, this will only get
         the push constant blocks for the first one.
 @param  p_module   Pointer to an instance of SpvReflectShaderModule.
 @param  p_count    If pp_blocks is NULL, the module's push constant
                    block count will be stored here.
                    If pp_blocks is not NULL, *p_count must
                    contain the module's push constant block count.
 @param  pp_blocks  If NULL, the module's push constant block count
                    will be written to *p_count.
                    If non-NULL, pp_blocks must point to an
                    array with *p_count entries, where pointers to
                    the module's push constant blocks will be written.
                    The caller must not free the block variables written
                    to this array.
 @return            If successful, returns SPV_REFLECT_RESULT_SUCCESS.
                    Otherwise, the error code indicates the cause of the
                    failure.

*/
SpvReflectResult spvReflectEnumeratePushConstantBlocks(
  const SpvReflectShaderModule* p_module,
  uint32_t*                     p_count,
  SpvReflectBlockVariable**     pp_blocks
);
SPV_REFLECT_DEPRECATED("renamed to spvReflectEnumeratePushConstantBlocks")
SpvReflectResult spvReflectEnumeratePushConstants(
  const SpvReflectShaderModule* p_module,
  uint32_t*                     p_count,
  SpvReflectBlockVariable**     pp_blocks
);

/*! @fn spvReflectEnumerateEntryPointPushConstantBlocks
 @brief  Enumerate the push constant blocks used in the static call tree of a
         given entry point.
 @param  p_module   Pointer to an instance of SpvReflectShaderModule.
 @param  p_count    If pp_blocks is NULL, the entry point's push constant
                    block count will be stored here.
                    If pp_blocks is not NULL, *p_count must
                    contain the entry point's push constant block count.
 @param  pp_blocks  If NULL, the entry point's push constant block count
                    will be written to *p_count.
                    If non-NULL, pp_blocks must point to an
                    array with *p_count entries, where pointers to
                    the entry point's push constant blocks will be written.
                    The caller must not free the block variables written
                    to this array.
 @return            If successful, returns SPV_REFLECT_RESULT_SUCCESS.
                    Otherwise, the error code indicates the cause of the
                    failure.

*/
SpvReflectResult spvReflectEnumerateEntryPointPushConstantBlocks(
  const SpvReflectShaderModule* p_module,
  const char*                   entry_point,
  uint32_t*                     p_count,
  SpvReflectBlockVariable**     pp_blocks
);


/*! @fn spvReflectGetDescriptorBinding

 @param  p_module        Pointer to an instance of SpvReflectShaderModule.
 @param  binding_number  The "binding" value of the requested descriptor
                         binding.
 @param  set_number      The "set" value of the requested descriptor binding.
 @param  p_result        If successful, SPV_REFLECT_RESULT_SUCCESS will be
                         written to *p_result. Otherwise, a error code
                         indicating the cause of the failure will be stored
                         here.
 @return                 If the module contains a descriptor binding that
                         matches the provided [binding_number, set_number]
                         values, a pointer to that binding is returned. The
                         caller must not free this pointer.
                         If no match can be found, or if an unrelated error
                         occurs, the return value will be NULL. Detailed
                         error results are written to *pResult.
@note                    If the module contains multiple desriptor bindings
                         with the same set and binding numbers, there are
                         no guarantees about which binding will be returned.

*/
const SpvReflectDescriptorBinding* spvReflectGetDescriptorBinding(
  const SpvReflectShaderModule* p_module,
  uint32_t                      binding_number,
  uint32_t                      set_number,
  SpvReflectResult*             p_result
);

/*! @fn spvReflectGetEntryPointDescriptorBinding
 @brief  Get the descriptor binding with the given binding number and set
         number that is used in the static call tree of a certain entry
         point.
 @param  p_module        Pointer to an instance of SpvReflectShaderModule.
 @param  entry_point     The entry point to get the binding from.
 @param  binding_number  The "binding" value of the requested descriptor
                         binding.
 @param  set_number      The "set" value of the requested descriptor binding.
 @param  p_result        If successful, SPV_REFLECT_RESULT_SUCCESS will be
                         written to *p_result. Otherwise, a error code
                         indicating the cause of the failure will be stored
                         here.
 @return                 If the entry point contains a descriptor binding that
                         matches the provided [binding_number, set_number]
                         values, a pointer to that binding is returned. The
                         caller must not free this pointer.
                         If no match can be found, or if an unrelated error
                         occurs, the return value will be NULL. Detailed
                         error results are written to *pResult.
@note                    If the entry point contains multiple desriptor bindings
                         with the same set and binding numbers, there are
                         no guarantees about which binding will be returned.

*/
const SpvReflectDescriptorBinding* spvReflectGetEntryPointDescriptorBinding(
  const SpvReflectShaderModule* p_module,
  const char*                   entry_point,
  uint32_t                      binding_number,
  uint32_t                      set_number,
  SpvReflectResult*             p_result
);


/*! @fn spvReflectGetDescriptorSet

 @param  p_module    Pointer to an instance of SpvReflectShaderModule.
 @param  set_number  The "set" value of the requested descriptor set.
 @param  p_result    If successful, SPV_REFLECT_RESULT_SUCCESS will be
                     written to *p_result. Otherwise, a error code
                     indicating the cause of the failure will be stored
                     here.
 @return             If the module contains a descriptor set with the
                     provided set_number, a pointer to that set is
                     returned. The caller must not free this pointer.
                     If no match can be found, or if an unrelated error
                     occurs, the return value will be NULL. Detailed
                     error results are written to *pResult.

*/
const SpvReflectDescriptorSet* spvReflectGetDescriptorSet(
  const SpvReflectShaderModule* p_module,
  uint32_t                      set_number,
  SpvReflectResult*             p_result
);

/*! @fn spvReflectGetEntryPointDescriptorSet

 @param  p_module    Pointer to an instance of SpvReflectShaderModule.
 @param  entry_point The entry point to get the descriptor set from.
 @param  set_number  The "set" value of the requested descriptor set.
 @param  p_result    If successful, SPV_REFLECT_RESULT_SUCCESS will be
                     written to *p_result. Otherwise, a error code
                     indicating the cause of the failure will be stored
                     here.
 @return             If the entry point contains a descriptor set with the
                     provided set_number, a pointer to that set is
                     returned. The caller must not free this pointer.
                     If no match can be found, or if an unrelated error
                     occurs, the return value will be NULL. Detailed
                     error results are written to *pResult.

*/
const SpvReflectDescriptorSet* spvReflectGetEntryPointDescriptorSet(
  const SpvReflectShaderModule* p_module,
  const char*                   entry_point,
  uint32_t                      set_number,
  SpvReflectResult*             p_result
);


/* @fn spvReflectGetInputVariableByLocation

 @param  p_module  Pointer to an instance of SpvReflectShaderModule.
 @param  location  The "location" value of the requested input variable.
                   A location of 0xFFFFFFFF will always return NULL
                   with *p_result == ELEMENT_NOT_FOUND.
 @param  p_result  If successful, SPV_REFLECT_RESULT_SUCCESS will be
                   written to *p_result. Otherwise, a error code
                   indicating the cause of the failure will be stored
                   here.
 @return           If the module contains an input interface variable
                   with the provided location value, a pointer to that
                   variable is returned. The caller must not free this
                   pointer.
                   If no match can be found, or if an unrelated error
                   occurs, the return value will be NULL. Detailed
                   error results are written to *pResult.
@note

*/
const SpvReflectInterfaceVariable* spvReflectGetInputVariableByLocation(
  const SpvReflectShaderModule* p_module,
  uint32_t                      location,
  SpvReflectResult*             p_result
);
SPV_REFLECT_DEPRECATED("renamed to spvReflectGetInputVariableByLocation")
const SpvReflectInterfaceVariable* spvReflectGetInputVariable(
  const SpvReflectShaderModule* p_module,
  uint32_t                      location,
  SpvReflectResult*             p_result
);

/* @fn spvReflectGetEntryPointInputVariableByLocation

 @param  p_module    Pointer to an instance of SpvReflectShaderModule.
 @param  entry_point The entry point to get the input variable from.
 @param  location    The "location" value of the requested input variable.
                     A location of 0xFFFFFFFF will always return NULL
                     with *p_result == ELEMENT_NOT_FOUND.
 @param  p_result    If successful, SPV_REFLECT_RESULT_SUCCESS will be
                     written to *p_result. Otherwise, a error code
                     indicating the cause of the failure will be stored
                     here.
 @return             If the entry point contains an input interface variable
                     with the provided location value, a pointer to that
                     variable is returned. The caller must not free this
                     pointer.
                     If no match can be found, or if an unrelated error
                     occurs, the return value will be NULL. Detailed
                     error results are written to *pResult.
@note

*/
const SpvReflectInterfaceVariable* spvReflectGetEntryPointInputVariableByLocation(
  const SpvReflectShaderModule* p_module,
  const char*                   entry_point,
  uint32_t                      location,
  SpvReflectResult*             p_result
);

/* @fn spvReflectGetInputVariableBySemantic

 @param  p_module  Pointer to an instance of SpvReflectShaderModule.
 @param  semantic  The "semantic" value of the requested input variable.
                   A semantic of NULL will return NULL.
                   A semantic of "" will always return NULL with
                   *p_result == ELEMENT_NOT_FOUND.
 @param  p_result  If successful, SPV_REFLECT_RESULT_SUCCESS will be
                   written to *p_result. Otherwise, a error code
                   indicating the cause of the failure will be stored
                   here.
 @return           If the module contains an input interface variable
                   with the provided semantic, a pointer to that
                   variable is returned. The caller must not free this
                   pointer.
                   If no match can be found, or if an unrelated error
                   occurs, the return value will be NULL. Detailed
                   error results are written to *pResult.
@note

*/
const SpvReflectInterfaceVariable* spvReflectGetInputVariableBySemantic(
  const SpvReflectShaderModule* p_module,
  const char*                   semantic,
  SpvReflectResult*             p_result
);

/* @fn spvReflectGetEntryPointInputVariableBySemantic

 @param  p_module  Pointer to an instance of SpvReflectShaderModule.
 @param  entry_point The entry point to get the input variable from.
 @param  semantic  The "semantic" value of the requested input variable.
                   A semantic of NULL will return NULL.
                   A semantic of "" will always return NULL with
                   *p_result == ELEMENT_NOT_FOUND.
 @param  p_result  If successful, SPV_REFLECT_RESULT_SUCCESS will be
                   written to *p_result. Otherwise, a error code
                   indicating the cause of the failure will be stored
                   here.
 @return           If the entry point contains an input interface variable
                   with the provided semantic, a pointer to that
                   variable is returned. The caller must not free this
                   pointer.
                   If no match can be found, or if an unrelated error
                   occurs, the return value will be NULL. Detailed
                   error results are written to *pResult.
@note

*/
const SpvReflectInterfaceVariable* spvReflectGetEntryPointInputVariableBySemantic(
  const SpvReflectShaderModule* p_module,
  const char*                   entry_point,
  const char*                   semantic,
  SpvReflectResult*             p_result
);

/* @fn spvReflectGetOutputVariableByLocation

 @param  p_module  Pointer to an instance of SpvReflectShaderModule.
 @param  location  The "location" value of the requested output variable.
                   A location of 0xFFFFFFFF will always return NULL
                   with *p_result == ELEMENT_NOT_FOUND.
 @param  p_result  If successful, SPV_REFLECT_RESULT_SUCCESS will be
                   written to *p_result. Otherwise, a error code
                   indicating the cause of the failure will be stored
                   here.
 @return           If the module contains an output interface variable
                   with the provided location value, a pointer to that
                   variable is returned. The caller must not free this
                   pointer.
                   If no match can be found, or if an unrelated error
                   occurs, the return value will be NULL. Detailed
                   error results are written to *pResult.
@note

*/
const SpvReflectInterfaceVariable* spvReflectGetOutputVariableByLocation(
  const SpvReflectShaderModule*  p_module,
  uint32_t                       location,
  SpvReflectResult*              p_result
);
SPV_REFLECT_DEPRECATED("renamed to spvReflectGetOutputVariableByLocation")
const SpvReflectInterfaceVariable* spvReflectGetOutputVariable(
  const SpvReflectShaderModule*  p_module,
  uint32_t                       location,
  SpvReflectResult*              p_result
);

/* @fn spvReflectGetEntryPointOutputVariableByLocation

 @param  p_module     Pointer to an instance of SpvReflectShaderModule.
 @param  entry_point  The entry point to get the output variable from.
 @param  location     The "location" value of the requested output variable.
                      A location of 0xFFFFFFFF will always return NULL
                      with *p_result == ELEMENT_NOT_FOUND.
 @param  p_result     If successful, SPV_REFLECT_RESULT_SUCCESS will be
                      written to *p_result. Otherwise, a error code
                      indicating the cause of the failure will be stored
                      here.
 @return              If the entry point contains an output interface variable
                      with the provided location value, a pointer to that
                      variable is returned. The caller must not free this
                      pointer.
                      If no match can be found, or if an unrelated error
                      occurs, the return value will be NULL. Detailed
                      error results are written to *pResult.
@note

*/
const SpvReflectInterfaceVariable* spvReflectGetEntryPointOutputVariableByLocation(
  const SpvReflectShaderModule*  p_module,
  const char*                    entry_point,
  uint32_t                       location,
  SpvReflectResult*              p_result
);

/* @fn spvReflectGetOutputVariableBySemantic

 @param  p_module  Pointer to an instance of SpvReflectShaderModule.
 @param  semantic  The "semantic" value of the requested output variable.
                   A semantic of NULL will return NULL.
                   A semantic of "" will always return NULL with
                   *p_result == ELEMENT_NOT_FOUND.
 @param  p_result  If successful, SPV_REFLECT_RESULT_SUCCESS will be
                   written to *p_result. Otherwise, a error code
                   indicating the cause of the failure will be stored
                   here.
 @return           If the module contains an output interface variable
                   with the provided semantic, a pointer to that
                   variable is returned. The caller must not free this
                   pointer.
                   If no match can be found, or if an unrelated error
                   occurs, the return value will be NULL. Detailed
                   error results are written to *pResult.
@note

*/
const SpvReflectInterfaceVariable* spvReflectGetOutputVariableBySemantic(
  const SpvReflectShaderModule*  p_module,
  const char*                    semantic,
  SpvReflectResult*              p_result
);

/* @fn spvReflectGetEntryPointOutputVariableBySemantic

 @param  p_module  Pointer to an instance of SpvReflectShaderModule.
 @param  entry_point  The entry point to get the output variable from.
 @param  semantic  The "semantic" value of the requested output variable.
                   A semantic of NULL will return NULL.
                   A semantic of "" will always return NULL with
                   *p_result == ELEMENT_NOT_FOUND.
 @param  p_result  If successful, SPV_REFLECT_RESULT_SUCCESS will be
                   written to *p_result. Otherwise, a error code
                   indicating the cause of the failure will be stored
                   here.
 @return           If the entry point contains an output interface variable
                   with the provided semantic, a pointer to that
                   variable is returned. The caller must not free this
                   pointer.
                   If no match can be found, or if an unrelated error
                   occurs, the return value will be NULL. Detailed
                   error results are written to *pResult.
@note

*/
const SpvReflectInterfaceVariable* spvReflectGetEntryPointOutputVariableBySemantic(
  const SpvReflectShaderModule*  p_module,
  const char*                    entry_point,
  const char*                    semantic,
  SpvReflectResult*              p_result
);

/*! @fn spvReflectGetPushConstantBlock

 @param  p_module  Pointer to an instance of SpvReflectShaderModule.
 @param  index     The index of the desired block within the module's
                   array of push constant blocks.
 @param  p_result  If successful, SPV_REFLECT_RESULT_SUCCESS will be
                   written to *p_result. Otherwise, a error code
                   indicating the cause of the failure will be stored
                   here.
 @return           If the provided index is within range, a pointer to
                   the corresponding push constant block is returned.
                   The caller must not free this pointer.
                   If no match can be found, or if an unrelated error
                   occurs, the return value will be NULL. Detailed
                   error results are written to *pResult.

*/
const SpvReflectBlockVariable* spvReflectGetPushConstantBlock(
  const SpvReflectShaderModule*  p_module,
  uint32_t                       index,
  SpvReflectResult*              p_result
);
SPV_REFLECT_DEPRECATED("renamed to spvReflectGetPushConstantBlock")
const SpvReflectBlockVariable* spvReflectGetPushConstant(
  const SpvReflectShaderModule*  p_module,
  uint32_t                       index,
  SpvReflectResult*              p_result
);

/*! @fn spvReflectGetEntryPointPushConstantBlock
 @brief  Get the push constant block corresponding to the given entry point.
         As by the Vulkan specification there can be no more than one push
         constant block used by a given entry point, so if there is one it will
         be returned, otherwise NULL will be returned.
 @param  p_module     Pointer to an instance of SpvReflectShaderModule.
 @param  entry_point  The entry point to get the push constant block from.
 @param  p_result     If successful, SPV_REFLECT_RESULT_SUCCESS will be
                      written to *p_result. Otherwise, a error code
                      indicating the cause of the failure will be stored
                      here.
 @return              If the provided index is within range, a pointer to
                      the corresponding push constant block is returned.
                      The caller must not free this pointer.
                      If no match can be found, or if an unrelated error
                      occurs, the return value will be NULL. Detailed
                      error results are written to *pResult.

*/
const SpvReflectBlockVariable* spvReflectGetEntryPointPushConstantBlock(
  const SpvReflectShaderModule*  p_module,
  const char*                    entry_point,
  SpvReflectResult*              p_result
);


/*! @fn spvReflectChangeDescriptorBindingNumbers
 @brief  Assign new set and/or binding numbers to a descriptor binding.
         In addition to updating the reflection data, this function modifies
         the underlying SPIR-V bytecode. The updated code can be retrieved
         with spvReflectGetCode().  If the binding is used in multiple
         entry points within the module, it will be changed in all of them.
 @param  p_module            Pointer to an instance of SpvReflectShaderModule.
 @param  p_binding           Pointer to the descriptor binding to modify.
 @param  new_binding_number  The new binding number to assign to the
                             provided descriptor binding.
                             To leave the binding number unchanged, pass
                             SPV_REFLECT_BINDING_NUMBER_DONT_CHANGE.
 @param  new_set_number      The new set number to assign to the
                             provided descriptor binding. Successfully changing
                             a descriptor binding's set number invalidates all
                             existing SpvReflectDescriptorBinding and
                             SpvReflectDescriptorSet pointers from this module.
                             To leave the set number unchanged, pass
                             SPV_REFLECT_SET_NUMBER_DONT_CHANGE.
 @return                     If successful, returns SPV_REFLECT_RESULT_SUCCESS.
                             Otherwise, the error code indicates the cause of
                             the failure.
*/
SpvReflectResult spvReflectChangeDescriptorBindingNumbers(
  SpvReflectShaderModule*            p_module,
  const SpvReflectDescriptorBinding* p_binding,
  uint32_t                           new_binding_number,
  uint32_t                           new_set_number
);
SPV_REFLECT_DEPRECATED("Renamed to spvReflectChangeDescriptorBindingNumbers")
SpvReflectResult spvReflectChangeDescriptorBindingNumber(
  SpvReflectShaderModule*            p_module,
  const SpvReflectDescriptorBinding* p_descriptor_binding,
  uint32_t                           new_binding_number,
  uint32_t                           optional_new_set_number
);

/*! @fn spvReflectChangeDescriptorSetNumber
 @brief  Assign a new set number to an entire descriptor set (including
         all descriptor bindings in that set).
         In addition to updating the reflection data, this function modifies
         the underlying SPIR-V bytecode. The updated code can be retrieved
         with spvReflectGetCode().  If the descriptor set is used in
         multiple entry points within the module, it will be modified in all
         of them.
 @param  p_module        Pointer to an instance of SpvReflectShaderModule.
 @param  p_set           Pointer to the descriptor binding to modify.
 @param  new_set_number  The new set number to assign to the
                         provided descriptor set, and all its descriptor
                         bindings. Successfully changing a descriptor
                         binding's set number invalidates all existing
                         SpvReflectDescriptorBinding and
                         SpvReflectDescriptorSet pointers from this module.
                         To leave the set number unchanged, pass
                         SPV_REFLECT_SET_NUMBER_DONT_CHANGE.
 @return                 If successful, returns SPV_REFLECT_RESULT_SUCCESS.
                         Otherwise, the error code indicates the cause of
                         the failure.
*/
SpvReflectResult spvReflectChangeDescriptorSetNumber(
  SpvReflectShaderModule*        p_module,
  const SpvReflectDescriptorSet* p_set,
  uint32_t                       new_set_number
);

/*! @fn spvReflectChangeInputVariableLocation
 @brief  Assign a new location to an input interface variable.
         In addition to updating the reflection data, this function modifies
         the underlying SPIR-V bytecode. The updated code can be retrieved
         with spvReflectGetCode().
         It is the caller's responsibility to avoid assigning the same
         location to multiple input variables.  If the input variable is used
         by multiple entry points in the module, it will be changed in all of
         them.
 @param  p_module          Pointer to an instance of SpvReflectShaderModule.
 @param  p_input_variable  Pointer to the input variable to update.
 @param  new_location      The new location to assign to p_input_variable.
 @return                   If successful, returns SPV_REFLECT_RESULT_SUCCESS.
                           Otherwise, the error code indicates the cause of
                           the failure.

*/
SpvReflectResult spvReflectChangeInputVariableLocation(
  SpvReflectShaderModule*            p_module,
  const SpvReflectInterfaceVariable* p_input_variable,
  uint32_t                           new_location
);


/*! @fn spvReflectChangeOutputVariableLocation
 @brief  Assign a new location to an output interface variable.
         In addition to updating the reflection data, this function modifies
         the underlying SPIR-V bytecode. The updated code can be retrieved
         with spvReflectGetCode().
         It is the caller's responsibility to avoid assigning the same
         location to multiple output variables.  If the output variable is used
         by multiple entry points in the module, it will be changed in all of
         them.
 @param  p_module          Pointer to an instance of SpvReflectShaderModule.
 @param  p_output_variable  Pointer to the output variable to update.
 @param  new_location      The new location to assign to p_output_variable.
 @return                   If successful, returns SPV_REFLECT_RESULT_SUCCESS.
                           Otherwise, the error code indicates the cause of
                           the failure.

*/
SpvReflectResult spvReflectChangeOutputVariableLocation(
  SpvReflectShaderModule*             p_module,
  const SpvReflectInterfaceVariable*  p_output_variable,
  uint32_t                            new_location
);


/*! @fn spvReflectSourceLanguage

 @param  source_lang  The source language code.
 @return Returns string of source language specified in \a source_lang.
         The caller must not free the memory associated with this string.
*/
const char* spvReflectSourceLanguage(SpvSourceLanguage source_lang);

#if defined(__cplusplus)
};
#endif

#if defined(__cplusplus)
#include <cstdlib>
#include <string>
#include <vector>

namespace spv_reflect {

/*! \class ShaderModule

*/
class ShaderModule {
public:
  ShaderModule();
  ShaderModule(size_t size, const void* p_code);
  ShaderModule(const std::vector<uint8_t>& code);
  ShaderModule(const std::vector<uint32_t>& code);
  ~ShaderModule();

  SpvReflectResult GetResult() const;

  const SpvReflectShaderModule& GetShaderModule() const;

  uint32_t        GetCodeSize() const;
  const uint32_t* GetCode() const;

  const char*           GetEntryPointName() const;

  const char*           GetSourceFile() const;

  uint32_t              GetEntryPointCount() const;
  const char*           GetEntryPointName(uint32_t index) const;

  SpvReflectShaderStageFlagBits GetShaderStage() const;
  SPV_REFLECT_DEPRECATED("Renamed to GetShaderStage")
  SpvReflectShaderStageFlagBits GetVulkanShaderStage() const {
    return GetShaderStage();
  }

  SpvReflectResult  EnumerateDescriptorBindings(uint32_t* p_count, SpvReflectDescriptorBinding** pp_bindings) const;
  SpvReflectResult  EnumerateEntryPointDescriptorBindings(const char* entry_point, uint32_t* p_count, SpvReflectDescriptorBinding** pp_bindings) const;
  SpvReflectResult  EnumerateDescriptorSets( uint32_t* p_count, SpvReflectDescriptorSet** pp_sets) const ;
  SpvReflectResult  EnumerateEntryPointDescriptorSets(const char* entry_point, uint32_t* p_count, SpvReflectDescriptorSet** pp_sets) const ;
  SpvReflectResult  EnumerateInterfaceVariables(uint32_t* p_count, SpvReflectInterfaceVariable** pp_variables) const;
  SpvReflectResult  EnumerateEntryPointInterfaceVariables(const char* entry_point, uint32_t* p_count, SpvReflectInterfaceVariable** pp_variables) const;
  SpvReflectResult  EnumerateInputVariables(uint32_t* p_count,SpvReflectInterfaceVariable** pp_variables) const;
  SpvReflectResult  EnumerateEntryPointInputVariables(const char* entry_point, uint32_t* p_count, SpvReflectInterfaceVariable** pp_variables) const;
  SpvReflectResult  EnumerateOutputVariables(uint32_t* p_count,SpvReflectInterfaceVariable** pp_variables) const;
  SpvReflectResult  EnumerateEntryPointOutputVariables(const char* entry_point, uint32_t* p_count, SpvReflectInterfaceVariable** pp_variables) const;
  SpvReflectResult  EnumeratePushConstantBlocks(uint32_t* p_count, SpvReflectBlockVariable** pp_blocks) const;
  SpvReflectResult  EnumerateEntryPointPushConstantBlocks(const char* entry_point, uint32_t* p_count, SpvReflectBlockVariable** pp_blocks) const;
  SPV_REFLECT_DEPRECATED("Renamed to EnumeratePushConstantBlocks")
  SpvReflectResult  EnumeratePushConstants(uint32_t* p_count, SpvReflectBlockVariable** pp_blocks) const {
    return EnumeratePushConstantBlocks(p_count, pp_blocks);
  }

  const SpvReflectDescriptorBinding*  GetDescriptorBinding(uint32_t binding_number, uint32_t set_number, SpvReflectResult* p_result = nullptr) const;
  const SpvReflectDescriptorBinding*  GetEntryPointDescriptorBinding(const char* entry_point, uint32_t binding_number, uint32_t set_number, SpvReflectResult* p_result = nullptr) const;
  const SpvReflectDescriptorSet*      GetDescriptorSet(uint32_t set_number, SpvReflectResult* p_result = nullptr) const;
  const SpvReflectDescriptorSet*      GetEntryPointDescriptorSet(const char* entry_point, uint32_t set_number, SpvReflectResult* p_result = nullptr) const;
  const SpvReflectInterfaceVariable*  GetInputVariableByLocation(uint32_t location,  SpvReflectResult* p_result = nullptr) const;
  SPV_REFLECT_DEPRECATED("Renamed to GetInputVariableByLocation")
  const SpvReflectInterfaceVariable*  GetInputVariable(uint32_t location,  SpvReflectResult* p_result = nullptr) const {
    return GetInputVariableByLocation(location, p_result);
  }
  const SpvReflectInterfaceVariable*  GetEntryPointInputVariableByLocation(const char* entry_point, uint32_t location,  SpvReflectResult* p_result = nullptr) const;
  const SpvReflectInterfaceVariable*  GetInputVariableBySemantic(const char* semantic,  SpvReflectResult* p_result = nullptr) const;
  const SpvReflectInterfaceVariable*  GetEntryPointInputVariableBySemantic(const char* entry_point, const char* semantic,  SpvReflectResult* p_result = nullptr) const;
  const SpvReflectInterfaceVariable*  GetOutputVariableByLocation(uint32_t location, SpvReflectResult*  p_result = nullptr) const;
  SPV_REFLECT_DEPRECATED("Renamed to GetOutputVariableByLocation")
  const SpvReflectInterfaceVariable*  GetOutputVariable(uint32_t location, SpvReflectResult*  p_result = nullptr) const {
    return GetOutputVariableByLocation(location, p_result);
  }
  const SpvReflectInterfaceVariable*  GetEntryPointOutputVariableByLocation(const char* entry_point, uint32_t location, SpvReflectResult*  p_result = nullptr) const;
  const SpvReflectInterfaceVariable*  GetOutputVariableBySemantic(const char* semantic, SpvReflectResult*  p_result = nullptr) const;
  const SpvReflectInterfaceVariable*  GetEntryPointOutputVariableBySemantic(const char* entry_point, const char* semantic, SpvReflectResult*  p_result = nullptr) const;
  const SpvReflectBlockVariable*      GetPushConstantBlock(uint32_t index, SpvReflectResult*  p_result = nullptr) const;
  SPV_REFLECT_DEPRECATED("Renamed to GetPushConstantBlock")
  const SpvReflectBlockVariable*      GetPushConstant(uint32_t index, SpvReflectResult*  p_result = nullptr) const {
    return GetPushConstantBlock(index, p_result);
  }
  const SpvReflectBlockVariable*      GetEntryPointPushConstantBlock(const char* entry_point, SpvReflectResult*  p_result = nullptr) const;

  SpvReflectResult ChangeDescriptorBindingNumbers(const SpvReflectDescriptorBinding* p_binding,
      uint32_t new_binding_number = SPV_REFLECT_BINDING_NUMBER_DONT_CHANGE,
      uint32_t optional_new_set_number = SPV_REFLECT_SET_NUMBER_DONT_CHANGE);
  SPV_REFLECT_DEPRECATED("Renamed to ChangeDescriptorBindingNumbers")
  SpvReflectResult ChangeDescriptorBindingNumber(const SpvReflectDescriptorBinding* p_binding, uint32_t new_binding_number = SPV_REFLECT_BINDING_NUMBER_DONT_CHANGE,
      uint32_t new_set_number = SPV_REFLECT_SET_NUMBER_DONT_CHANGE) {
    return ChangeDescriptorBindingNumbers(p_binding, new_binding_number, new_set_number);
  }
  SpvReflectResult ChangeDescriptorSetNumber(const SpvReflectDescriptorSet* p_set, uint32_t new_set_number = SPV_REFLECT_SET_NUMBER_DONT_CHANGE);
  SpvReflectResult ChangeInputVariableLocation(const SpvReflectInterfaceVariable* p_input_variable, uint32_t new_location);
  SpvReflectResult ChangeOutputVariableLocation(const SpvReflectInterfaceVariable* p_output_variable, uint32_t new_location);

private:
  // Make noncopyable
  ShaderModule(const ShaderModule&);
  ShaderModule& operator=(const ShaderModule&);

private:
  mutable SpvReflectResult  m_result = SPV_REFLECT_RESULT_NOT_READY;
  SpvReflectShaderModule    m_module = {};
};


// =================================================================================================
// ShaderModule
// =================================================================================================

/*! @fn ShaderModule

*/
inline ShaderModule::ShaderModule() {}


/*! @fn ShaderModule

  @param  size
  @param  p_code

*/
inline ShaderModule::ShaderModule(size_t size, const void* p_code) {
  m_result = spvReflectCreateShaderModule(
    size,
    p_code,
    &m_module);
}

/*! @fn ShaderModule

  @param  code
  
*/
inline ShaderModule::ShaderModule(const std::vector<uint8_t>& code) {
  m_result = spvReflectCreateShaderModule(
    code.size(),
    code.data(),
    &m_module);
}

/*! @fn ShaderModule

  @param  code
  
*/
inline ShaderModule::ShaderModule(const std::vector<uint32_t>& code) {
  m_result = spvReflectCreateShaderModule(
    code.size() * sizeof(uint32_t),
    code.data(),
    &m_module);
}

/*! @fn  ~ShaderModule

*/
inline ShaderModule::~ShaderModule() {
  spvReflectDestroyShaderModule(&m_module);
}


/*! @fn GetResult

  @return

*/
inline SpvReflectResult ShaderModule::GetResult() const {
  return m_result;
}


/*! @fn GetShaderModule

  @return

*/
inline const SpvReflectShaderModule& ShaderModule::GetShaderModule() const {
  return m_module;
}


/*! @fn GetCodeSize

  @return

  */
inline uint32_t ShaderModule::GetCodeSize() const {
  return spvReflectGetCodeSize(&m_module);
}


/*! @fn GetCode

  @return

*/
inline const uint32_t* ShaderModule::GetCode() const {
  return spvReflectGetCode(&m_module);
}


/*! @fn GetEntryPoint

  @return Returns entry point

*/
inline const char* ShaderModule::GetEntryPointName() const {
  return this->GetEntryPointName(0);
}

/*! @fn GetEntryPoint

  @return Returns entry point

*/
inline const char* ShaderModule::GetSourceFile() const {
  return m_module.source_file;
}

/*! @fn GetEntryPointCount

  @param
  @return
*/
inline uint32_t ShaderModule::GetEntryPointCount() const {
  return m_module.entry_point_count;
}

/*! @fn GetEntryPointName

  @param index
  @return
*/
inline const char* ShaderModule::GetEntryPointName(uint32_t index) const {
  return m_module.entry_points[index].name;
}

/*! @fn GetShaderStage

  @return Returns Vulkan shader stage

*/
inline SpvReflectShaderStageFlagBits ShaderModule::GetShaderStage() const {
  return m_module.shader_stage;
}

/*! @fn EnumerateDescriptorBindings

  @param  count
  @param  p_binding_numbers
  @param  pp_bindings
  @return

*/
inline SpvReflectResult ShaderModule::EnumerateDescriptorBindings(
  uint32_t*                     p_count,
  SpvReflectDescriptorBinding** pp_bindings
) const
{
  m_result = spvReflectEnumerateDescriptorBindings(
    &m_module,
    p_count,
    pp_bindings);
  return m_result;
}

/*! @fn EnumerateEntryPointDescriptorBindings

  @param  entry_point
  @param  count
  @param  pp_bindings
  @return

*/
inline SpvReflectResult ShaderModule::EnumerateEntryPointDescriptorBindings(
  const char*                   entry_point,
  uint32_t*                     p_count,
  SpvReflectDescriptorBinding** pp_bindings
) const
{
  m_result = spvReflectEnumerateEntryPointDescriptorBindings(
      &m_module,
      entry_point,
      p_count,
      pp_bindings);
  return m_result;
}


/*! @fn EnumerateDescriptorSets

  @param  count
  @param  pp_sets
  @return

*/
inline SpvReflectResult ShaderModule::EnumerateDescriptorSets(
  uint32_t*                 p_count,
  SpvReflectDescriptorSet** pp_sets
) const
{
  m_result = spvReflectEnumerateDescriptorSets(
    &m_module,
    p_count,
    pp_sets);
  return m_result;
}

/*! @fn EnumerateEntryPointDescriptorSets

  @param  entry_point
  @param  count
  @param  pp_sets
  @return

*/
inline SpvReflectResult ShaderModule::EnumerateEntryPointDescriptorSets(
  const char*               entry_point,
  uint32_t*                 p_count,
  SpvReflectDescriptorSet** pp_sets
) const
{
  m_result = spvReflectEnumerateEntryPointDescriptorSets(
      &m_module,
      entry_point,
      p_count,
      pp_sets);
  return m_result;
}


/*! @fn EnumerateInterfaceVariables

  @param  count
  @param  pp_variables
  @return

*/
inline SpvReflectResult ShaderModule::EnumerateInterfaceVariables(
  uint32_t*                     p_count,
  SpvReflectInterfaceVariable** pp_variables
) const
{
  m_result = spvReflectEnumerateInterfaceVariables(
    &m_module,
    p_count,
    pp_variables);
  return m_result;
}

/*! @fn EnumerateEntryPointInterfaceVariables

  @param  entry_point
  @param  count
  @param  pp_variables
  @return

*/
inline SpvReflectResult ShaderModule::EnumerateEntryPointInterfaceVariables(
  const char*                   entry_point,
  uint32_t*                     p_count,
  SpvReflectInterfaceVariable** pp_variables
) const
{
  m_result = spvReflectEnumerateEntryPointInterfaceVariables(
      &m_module,
      entry_point,
      p_count,
      pp_variables);
  return m_result;
}


/*! @fn EnumerateInputVariables

  @param  count
  @param  pp_variables
  @return

*/
inline SpvReflectResult ShaderModule::EnumerateInputVariables(
  uint32_t*                     p_count,
  SpvReflectInterfaceVariable** pp_variables
) const
{
  m_result = spvReflectEnumerateInputVariables(
    &m_module,
    p_count,
    pp_variables);
  return m_result;
}

/*! @fn EnumerateEntryPointInputVariables

  @param  entry_point
  @param  count
  @param  pp_variables
  @return

*/
inline SpvReflectResult ShaderModule::EnumerateEntryPointInputVariables(
  const char*                   entry_point,
  uint32_t*                     p_count,
  SpvReflectInterfaceVariable** pp_variables
) const
{
  m_result = spvReflectEnumerateEntryPointInputVariables(
      &m_module,
      entry_point,
      p_count,
      pp_variables);
  return m_result;
}


/*! @fn EnumerateOutputVariables

  @param  count
  @param  pp_variables
  @return

*/
inline SpvReflectResult ShaderModule::EnumerateOutputVariables(
  uint32_t*                     p_count,
  SpvReflectInterfaceVariable** pp_variables
) const
{
  m_result = spvReflectEnumerateOutputVariables(
    &m_module,
    p_count,
    pp_variables);
  return m_result;
}

/*! @fn EnumerateEntryPointOutputVariables

  @param  entry_point
  @param  count
  @param  pp_variables
  @return

*/
inline SpvReflectResult ShaderModule::EnumerateEntryPointOutputVariables(
  const char*                   entry_point,
  uint32_t*                     p_count,
  SpvReflectInterfaceVariable** pp_variables
) const
{
  m_result = spvReflectEnumerateEntryPointOutputVariables(
      &m_module,
      entry_point,
      p_count,
      pp_variables);
  return m_result;
}


/*! @fn EnumeratePushConstantBlocks

  @param  count
  @param  pp_blocks
  @return

*/
inline SpvReflectResult ShaderModule::EnumeratePushConstantBlocks(
  uint32_t*                 p_count,
  SpvReflectBlockVariable** pp_blocks
) const
{
  m_result = spvReflectEnumeratePushConstantBlocks(
    &m_module,
    p_count,
    pp_blocks);
  return m_result;
}

/*! @fn EnumerateEntryPointPushConstantBlocks

  @param  entry_point
  @param  count
  @param  pp_blocks
  @return

*/
inline SpvReflectResult ShaderModule::EnumerateEntryPointPushConstantBlocks(
  const char*               entry_point,
  uint32_t*                 p_count,
  SpvReflectBlockVariable** pp_blocks
) const
{
  m_result = spvReflectEnumerateEntryPointPushConstantBlocks(
      &m_module,
      entry_point,
      p_count,
      pp_blocks);
  return m_result;
}


/*! @fn GetDescriptorBinding

  @param  binding_number
  @param  set_number
  @param  p_result
  @return

*/
inline const SpvReflectDescriptorBinding* ShaderModule::GetDescriptorBinding(
  uint32_t          binding_number,
  uint32_t          set_number,
  SpvReflectResult* p_result
) const
{
  return spvReflectGetDescriptorBinding(
    &m_module,
    binding_number,
    set_number,
    p_result);
}

/*! @fn GetEntryPointDescriptorBinding

  @param  entry_point
  @param  binding_number
  @param  set_number
  @param  p_result
  @return

*/
inline const SpvReflectDescriptorBinding* ShaderModule::GetEntryPointDescriptorBinding(
  const char*       entry_point,
  uint32_t          binding_number,
  uint32_t          set_number,
  SpvReflectResult* p_result
) const
{
  return spvReflectGetEntryPointDescriptorBinding(
    &m_module,
    entry_point,
    binding_number,
    set_number,
    p_result);
}


/*! @fn GetDescriptorSet

  @param  set_number
  @param  p_result
  @return

*/
inline const SpvReflectDescriptorSet* ShaderModule::GetDescriptorSet(
  uint32_t          set_number,
  SpvReflectResult* p_result
) const
{
  return spvReflectGetDescriptorSet(
    &m_module,
    set_number,
    p_result);
}

/*! @fn GetEntryPointDescriptorSet

  @param  entry_point
  @param  set_number
  @param  p_result
  @return

*/
inline const SpvReflectDescriptorSet* ShaderModule::GetEntryPointDescriptorSet(
  const char*       entry_point,
  uint32_t          set_number,
  SpvReflectResult* p_result
) const
{
  return spvReflectGetEntryPointDescriptorSet(
    &m_module,
    entry_point,
    set_number,
    p_result);
}


/*! @fn GetInputVariable

  @param  location
  @param  p_result
  @return

*/
inline const SpvReflectInterfaceVariable* ShaderModule::GetInputVariableByLocation(
  uint32_t          location,
  SpvReflectResult* p_result
) const
{
  return spvReflectGetInputVariableByLocation(
    &m_module,
    location,
    p_result);
}
inline const SpvReflectInterfaceVariable* ShaderModule::GetInputVariableBySemantic(
  const char*       semantic,
  SpvReflectResult* p_result
) const
{
  return spvReflectGetInputVariableBySemantic(
    &m_module,
    semantic,
    p_result);
}

/*! @fn GetEntryPointInputVariable

  @param  entry_point
  @param  location
  @param  p_result
  @return

*/
inline const SpvReflectInterfaceVariable* ShaderModule::GetEntryPointInputVariableByLocation(
  const char*       entry_point,
  uint32_t          location,
  SpvReflectResult* p_result
) const
{
  return spvReflectGetEntryPointInputVariableByLocation(
    &m_module,
    entry_point,
    location,
    p_result);
}
inline const SpvReflectInterfaceVariable* ShaderModule::GetEntryPointInputVariableBySemantic(
  const char*       entry_point,
  const char*       semantic,
  SpvReflectResult* p_result
) const
{
  return spvReflectGetEntryPointInputVariableBySemantic(
    &m_module,
    entry_point,
    semantic,
    p_result);
}


/*! @fn GetOutputVariable

  @param  location
  @param  p_result
  @return

*/
inline const SpvReflectInterfaceVariable* ShaderModule::GetOutputVariableByLocation(
  uint32_t           location,
  SpvReflectResult*  p_result
) const
{
  return spvReflectGetOutputVariableByLocation(
    &m_module,
    location,
    p_result);
}
inline const SpvReflectInterfaceVariable* ShaderModule::GetOutputVariableBySemantic(
  const char*       semantic,
  SpvReflectResult* p_result
) const
{
  return spvReflectGetOutputVariableBySemantic(&m_module,
    semantic,
    p_result);
}

/*! @fn GetEntryPointOutputVariable

  @param  entry_point
  @param  location
  @param  p_result
  @return

*/
inline const SpvReflectInterfaceVariable* ShaderModule::GetEntryPointOutputVariableByLocation(
  const char*        entry_point,
  uint32_t           location,
  SpvReflectResult*  p_result
) const
{
  return spvReflectGetEntryPointOutputVariableByLocation(
    &m_module,
    entry_point,
    location,
    p_result);
}
inline const SpvReflectInterfaceVariable* ShaderModule::GetEntryPointOutputVariableBySemantic(
  const char*       entry_point,
  const char*       semantic,
  SpvReflectResult* p_result
) const
{
  return spvReflectGetEntryPointOutputVariableBySemantic(
    &m_module,
    entry_point,
    semantic,
    p_result);
}


/*! @fn GetPushConstant

  @param  index
  @param  p_result
  @return

*/
inline const SpvReflectBlockVariable* ShaderModule::GetPushConstantBlock(
  uint32_t           index,
  SpvReflectResult*  p_result
) const
{
  return spvReflectGetPushConstantBlock(
    &m_module,
    index,
    p_result);
}

/*! @fn GetEntryPointPushConstant

  @param  entry_point
  @param  index
  @param  p_result
  @return

*/
inline const SpvReflectBlockVariable* ShaderModule::GetEntryPointPushConstantBlock(
  const char*        entry_point,
  SpvReflectResult*  p_result
) const
{
  return spvReflectGetEntryPointPushConstantBlock(
    &m_module,
    entry_point,
    p_result);
}


/*! @fn ChangeDescriptorBindingNumbers

  @param  p_binding
  @param  new_binding_number
  @param  new_set_number
  @return

*/
inline SpvReflectResult ShaderModule::ChangeDescriptorBindingNumbers(
  const SpvReflectDescriptorBinding* p_binding,
  uint32_t                           new_binding_number,
  uint32_t                           new_set_number
)
{
  return spvReflectChangeDescriptorBindingNumbers(
    &m_module,
    p_binding,
    new_binding_number,
    new_set_number);
}


/*! @fn ChangeDescriptorSetNumber

  @param  p_set
  @param  new_set_number
  @return

*/
inline SpvReflectResult ShaderModule::ChangeDescriptorSetNumber(
  const SpvReflectDescriptorSet* p_set,
  uint32_t                       new_set_number
)
{
  return spvReflectChangeDescriptorSetNumber(
    &m_module,
    p_set,
    new_set_number);
}


/*! @fn ChangeInputVariableLocation

  @param  p_input_variable
  @param  new_location
  @return

*/
inline SpvReflectResult ShaderModule::ChangeInputVariableLocation(
  const SpvReflectInterfaceVariable* p_input_variable,
  uint32_t                           new_location)
{
  return spvReflectChangeInputVariableLocation(
    &m_module,
    p_input_variable,
    new_location);
}


/*! @fn ChangeOutputVariableLocation

  @param  p_input_variable
  @param  new_location
  @return

*/
inline SpvReflectResult ShaderModule::ChangeOutputVariableLocation(
  const SpvReflectInterfaceVariable* p_output_variable,
  uint32_t                           new_location)
{
  return spvReflectChangeOutputVariableLocation(
    &m_module,
    p_output_variable,
    new_location);
}

} // namespace spv_reflect
#endif // defined(__cplusplus)
#endif // SPIRV_REFLECT_H