summaryrefslogtreecommitdiffstats
path: root/Graphics/GraphicsEngine/interface/DeviceContext.h
blob: b5909451620a3b0b7cdf11adf0265cda23349db7 (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
2235
2236
2237
2238
2239
2240
2241
2242
2243
2244
2245
2246
2247
2248
2249
2250
2251
2252
2253
2254
2255
2256
2257
2258
2259
2260
2261
2262
2263
2264
2265
2266
2267
2268
2269
2270
2271
2272
2273
2274
2275
2276
2277
2278
2279
2280
2281
2282
2283
2284
2285
2286
2287
2288
2289
2290
2291
2292
2293
2294
2295
2296
2297
2298
2299
2300
2301
2302
2303
2304
2305
2306
2307
2308
2309
2310
2311
2312
2313
2314
2315
2316
2317
2318
2319
2320
2321
2322
2323
2324
2325
2326
2327
2328
2329
2330
2331
2332
2333
2334
2335
2336
2337
2338
2339
2340
2341
2342
2343
2344
2345
2346
2347
2348
2349
2350
2351
2352
2353
2354
2355
2356
2357
2358
2359
2360
2361
2362
2363
2364
2365
2366
2367
2368
2369
2370
2371
2372
2373
2374
2375
2376
2377
2378
2379
/*
 *  Copyright 2019-2021 Diligent Graphics LLC
 *  Copyright 2015-2019 Egor Yusov
 *  
 *  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.
 *
 *  In no event and under no legal theory, whether in tort (including negligence), 
 *  contract, or otherwise, unless required by applicable law (such as deliberate 
 *  and grossly negligent acts) or agreed to in writing, shall any Contributor be
 *  liable for any damages, including any direct, indirect, special, incidental, 
 *  or consequential damages of any character arising as a result of this License or 
 *  out of the use or inability to use the software (including but not limited to damages 
 *  for loss of goodwill, work stoppage, computer failure or malfunction, or any and 
 *  all other commercial damages or losses), even if such Contributor has been advised 
 *  of the possibility of such damages.
 */

#pragma once

// clang-format off

/// \file
/// Definition of the Diligent::IDeviceContext interface and related data structures

#include "../../../Primitives/interface/Object.h"
#include "../../../Primitives/interface/FlagEnum.h"
#include "GraphicsTypes.h"
#include "Constants.h"
#include "Buffer.h"
#include "InputLayout.h"
#include "Shader.h"
#include "Texture.h"
#include "Sampler.h"
#include "ResourceMapping.h"
#include "TextureView.h"
#include "BufferView.h"
#include "DepthStencilState.h"
#include "BlendState.h"
#include "PipelineState.h"
#include "Fence.h"
#include "Query.h"
#include "RenderPass.h"
#include "Framebuffer.h"
#include "CommandList.h"
#include "SwapChain.h"
#include "BottomLevelAS.h"
#include "TopLevelAS.h"
#include "ShaderBindingTable.h"

DILIGENT_BEGIN_NAMESPACE(Diligent)


// {DC92711B-A1BE-4319-B2BD-C662D1CC19E4}
static const INTERFACE_ID IID_DeviceContext =
    {0xdc92711b, 0xa1be, 0x4319, {0xb2, 0xbd, 0xc6, 0x62, 0xd1, 0xcc, 0x19, 0xe4}};

/// Draw command flags
DILIGENT_TYPED_ENUM(DRAW_FLAGS, Uint8)
{
    /// No flags.
    DRAW_FLAG_NONE                            = 0x00,

    /// Verify the sate of index and vertex buffers (if any) used by the draw 
    /// command. State validation is only performed in debug and development builds 
    /// and the flag has no effect in release build.
    DRAW_FLAG_VERIFY_STATES                   = 0x01,

    /// Verify correctness of parameters passed to the draw command.
    DRAW_FLAG_VERIFY_DRAW_ATTRIBS             = 0x02,

    /// Verify that render targets bound to the context are consistent with the pipeline state.
    DRAW_FLAG_VERIFY_RENDER_TARGETS           = 0x04,

    /// Perform all state validation checks
    DRAW_FLAG_VERIFY_ALL                      = DRAW_FLAG_VERIFY_STATES | DRAW_FLAG_VERIFY_DRAW_ATTRIBS | DRAW_FLAG_VERIFY_RENDER_TARGETS,

    /// Indicates that none of the dynamic resource buffers used by the draw command
    /// have been modified by the CPU since the last command.
    ///
    /// \remarks This flag should be used to improve performance when an application issues a
    ///          series of draw commands that use the same pipeline state and shader resources and
    ///          no dynamic buffers (constant or bound as shader resources) are updated between the
    ///          commands.
    ///          The flag has no effect on dynamic vertex and index buffers.
    ///
    ///          Details
    ///
    ///          D3D12 and Vulkan back-ends have to perform some work to make data in buffers
    ///          available to draw commands. When a dynamic buffer is mapped, the engine allocates
    ///          new memory and assigns a new GPU address to this buffer. When a draw command is issued,
    ///          this GPU address needs to be used. By default the engine assumes that the CPU may
    ///          map the buffer before any command (to write new transformation matrices for example)
    ///          and that all GPU addresses need to always be refreshed. This is not always the case, 
    ///          and the application may use the flag to inform the engine that the data in the buffer 
    ///          stay intact to avoid extra work.\n
    ///          Note that after a new PSO is bound or an SRB is committed, the engine will always set all
    ///          required buffer addresses/offsets regardless of the flag. The flag will only take effect
    ///          on the second and susbequent draw calls that use the same PSO and SRB.\n
    ///          The flag has no effect in D3D11 and OpenGL backends.
    ///
    ///          Implementation details
    ///         
    ///          Vulkan backend allocates VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC descriptors for all uniform (constant), 
    ///          buffers and VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC descriptors for storage buffers.
    ///          Note that HLSL structured buffers are mapped to read-only storage buffers in SPIRV and RW buffers
    ///          are mapped to RW-storage buffers.
    ///          By default, all dynamic descriptor sets that have dynamic buffers bound are updated every time a draw command is
    ///          issued (see PipelineStateVkImpl::BindDescriptorSetsWithDynamicOffsets). When DRAW_FLAG_DYNAMIC_RESOURCE_BUFFERS_INTACT
    ///          is specified, dynamic descriptor sets are only bound by the first draw command that uses the PSO and the SRB.
    ///          The flag avoids binding descriptors with the same offsets if none of the dynamic offsets have changed.
    ///
    ///          Direct3D12 backend binds constant buffers to root views. By default the engine assumes that virtual GPU addresses 
    ///          of all dynamic buffers may change between the draw commands and always binds dynamic buffers to root views
    ///          (see RootSignature::CommitRootViews). When DRAW_FLAG_DYNAMIC_RESOURCE_BUFFERS_INTACT is set, root views are only bound
    ///          by the first draw command that uses the PSO + SRB pair. The flag avoids setting the same GPU virtual addresses when
    ///          they stay unchanged.
    DRAW_FLAG_DYNAMIC_RESOURCE_BUFFERS_INTACT = 0x08
};
DEFINE_FLAG_ENUM_OPERATORS(DRAW_FLAGS)


/// Defines resource state transition mode performed by various commands.

/// Refer to http://diligentgraphics.com/2018/12/09/resource-state-management/ for detailed explanation
/// of resource state management in Diligent Engine.
DILIGENT_TYPED_ENUM(RESOURCE_STATE_TRANSITION_MODE, Uint8)
{
    /// Perform no state transitions and no state validation. 
    /// Resource states are not accessed (either read or written) by the command.
    RESOURCE_STATE_TRANSITION_MODE_NONE = 0,
    
    /// Transition resources to the states required by the specific command.
    /// Resources in unknown state are ignored.
    ///
    /// \note    Any method that uses this mode may alter the state of the resources it works with.
    ///          As automatic state management is not thread-safe, no other thread is allowed to read
    ///          or write the state of the resources being transitioned. 
    ///          If the application intends to use the same resources in other threads simultaneously, it needs to 
    ///          explicitly manage the states using IDeviceContext::TransitionResourceStates() method.
    ///          Refer to http://diligentgraphics.com/2018/12/09/resource-state-management/ for detailed explanation
    ///          of resource state management in Diligent Engine.
    RESOURCE_STATE_TRANSITION_MODE_TRANSITION,

    /// Do not transition, but verify that states are correct.
    /// No validation is performed if the state is unknown to the engine.
    /// This mode only has effect in debug and development builds. No validation 
    /// is performed in release build.
    ///
    /// \note    Any method that uses this mode will read the state of resources it works with.
    ///          As automatic state management is not thread-safe, no other thread is allowed to alter
    ///          the state of resources being used by the command. It is safe to read these states.
    RESOURCE_STATE_TRANSITION_MODE_VERIFY
};


/// Defines the draw command attributes.

/// This structure is used by IDeviceContext::Draw().
struct DrawAttribs
{
    /// The number of vertices to draw.
    Uint32     NumVertices           DEFAULT_INITIALIZER(0);

    /// Additional flags, see Diligent::DRAW_FLAGS.
    DRAW_FLAGS Flags                 DEFAULT_INITIALIZER(DRAW_FLAG_NONE);

    /// The number of instances to draw. If more than one instance is specified,
    /// instanced draw call will be performed.
    Uint32     NumInstances          DEFAULT_INITIALIZER(1);

    /// LOCATION (or INDEX, but NOT the byte offset) of the first vertex in the
    /// vertex buffer to start reading vertices from.
    Uint32     StartVertexLocation   DEFAULT_INITIALIZER(0);

    /// LOCATION (or INDEX, but NOT the byte offset) in the vertex buffer to start
    /// reading instance data from.
    Uint32     FirstInstanceLocation DEFAULT_INITIALIZER(0);


#if DILIGENT_CPP_INTERFACE
    /// Initializes the structure members with default values.

    /// Default values:
    ///
    /// Member                                   | Default value
    /// -----------------------------------------|--------------------------------------
    /// NumVertices                              | 0
    /// Flags                                    | DRAW_FLAG_NONE
    /// NumInstances                             | 1
    /// StartVertexLocation                      | 0
    /// FirstInstanceLocation                    | 0
    DrawAttribs()noexcept{}

    /// Initializes the structure with user-specified values.
    DrawAttribs(Uint32     _NumVertices,
                DRAW_FLAGS _Flags,
                Uint32     _NumInstances          = 1,
                Uint32     _StartVertexLocation   = 0,
                Uint32     _FirstInstanceLocation = 0)noexcept : 
        NumVertices          {_NumVertices          },
        Flags                {_Flags                },
        NumInstances         {_NumInstances         },
        StartVertexLocation  {_StartVertexLocation  },
        FirstInstanceLocation{_FirstInstanceLocation}
    {}
#endif
};
typedef struct DrawAttribs DrawAttribs;


/// Defines the indexed draw command attributes.

/// This structure is used by IDeviceContext::DrawIndexed().
struct DrawIndexedAttribs
{
    /// The number of indices to draw.
    Uint32     NumIndices            DEFAULT_INITIALIZER(0);

    /// The type of elements in the index buffer.
    /// Allowed values: VT_UINT16 and VT_UINT32.
    VALUE_TYPE IndexType             DEFAULT_INITIALIZER(VT_UNDEFINED);

    /// Additional flags, see Diligent::DRAW_FLAGS.
    DRAW_FLAGS Flags                 DEFAULT_INITIALIZER(DRAW_FLAG_NONE);

    /// Number of instances to draw. If more than one instance is specified,
    /// instanced draw call will be performed.
    Uint32     NumInstances          DEFAULT_INITIALIZER(1);

    /// LOCATION (NOT the byte offset) of the first index in
    /// the index buffer to start reading indices from.
    Uint32     FirstIndexLocation    DEFAULT_INITIALIZER(0);

    /// A constant which is added to each index before accessing the vertex buffer.
    Uint32     BaseVertex            DEFAULT_INITIALIZER(0);

    /// LOCATION (or INDEX, but NOT the byte offset) in the vertex
    /// buffer to start reading instance data from.
    Uint32     FirstInstanceLocation DEFAULT_INITIALIZER(0);


#if DILIGENT_CPP_INTERFACE
    /// Initializes the structure members with default values.

    /// Default values:
    /// Member                                   | Default value
    /// -----------------------------------------|--------------------------------------
    /// NumIndices                               | 0
    /// IndexType                                | VT_UNDEFINED
    /// Flags                                    | DRAW_FLAG_NONE
    /// NumInstances                             | 1
    /// FirstIndexLocation                       | 0
    /// BaseVertex                               | 0
    /// FirstInstanceLocation                    | 0
    DrawIndexedAttribs()noexcept{}

    /// Initializes the structure members with user-specified values.
    DrawIndexedAttribs(Uint32      _NumIndices,
                       VALUE_TYPE  _IndexType,
                       DRAW_FLAGS  _Flags,
                       Uint32      _NumInstances          = 1,
                       Uint32      _FirstIndexLocation    = 0,
                       Uint32      _BaseVertex            = 0,
                       Uint32      _FirstInstanceLocation = 0)noexcept : 
        NumIndices           {_NumIndices           },
        IndexType            {_IndexType            },
        Flags                {_Flags                },
        NumInstances         {_NumInstances         },
        FirstIndexLocation   {_FirstIndexLocation   },
        BaseVertex           {_BaseVertex           },
        FirstInstanceLocation{_FirstInstanceLocation}
    {}
#endif
};
typedef struct DrawIndexedAttribs DrawIndexedAttribs;


/// Defines the indirect draw command attributes.

/// This structure is used by IDeviceContext::DrawIndirect().
struct DrawIndirectAttribs
{
    /// Additional flags, see Diligent::DRAW_FLAGS.
    DRAW_FLAGS Flags                DEFAULT_INITIALIZER(DRAW_FLAG_NONE);

    /// State transition mode for indirect draw arguments buffer.
    RESOURCE_STATE_TRANSITION_MODE IndirectAttribsBufferStateTransitionMode DEFAULT_INITIALIZER(RESOURCE_STATE_TRANSITION_MODE_NONE);

    /// Offset from the beginning of the buffer to the location of draw command attributes.
    Uint32 IndirectDrawArgsOffset   DEFAULT_INITIALIZER(0);
    

#if DILIGENT_CPP_INTERFACE
    /// Initializes the structure members with default values

    /// Default values:
    /// Member                                   | Default value
    /// -----------------------------------------|--------------------------------------
    /// Flags                                    | DRAW_FLAG_NONE
    /// IndirectAttribsBufferStateTransitionMode | RESOURCE_STATE_TRANSITION_MODE_NONE
    /// IndirectDrawArgsOffset                   | 0
    DrawIndirectAttribs()noexcept{}

    /// Initializes the structure members with user-specified values.
    DrawIndirectAttribs(DRAW_FLAGS                     _Flags,
                        RESOURCE_STATE_TRANSITION_MODE _IndirectAttribsBufferStateTransitionMode,
                        Uint32                         _IndirectDrawArgsOffset = 0)noexcept :
        Flags                                   {_Flags                                   },
        IndirectAttribsBufferStateTransitionMode{_IndirectAttribsBufferStateTransitionMode},
        IndirectDrawArgsOffset                  {_IndirectDrawArgsOffset                  }
    {}
#endif
};
typedef struct DrawIndirectAttribs DrawIndirectAttribs;


/// Defines the indexed indirect draw command attributes.

/// This structure is used by IDeviceContext::DrawIndexedIndirect().
struct DrawIndexedIndirectAttribs
{
    /// The type of the elements in the index buffer.
    /// Allowed values: VT_UINT16 and VT_UINT32.
    VALUE_TYPE IndexType            DEFAULT_INITIALIZER(VT_UNDEFINED);

    /// Additional flags, see Diligent::DRAW_FLAGS.
    DRAW_FLAGS Flags                DEFAULT_INITIALIZER(DRAW_FLAG_NONE);

    /// State transition mode for indirect draw arguments buffer.
    RESOURCE_STATE_TRANSITION_MODE IndirectAttribsBufferStateTransitionMode DEFAULT_INITIALIZER(RESOURCE_STATE_TRANSITION_MODE_NONE);

    /// Offset from the beginning of the buffer to the location of draw command attributes.
    Uint32 IndirectDrawArgsOffset        DEFAULT_INITIALIZER(0);


#if DILIGENT_CPP_INTERFACE
    /// Initializes the structure members with default values

    /// Default values:
    /// Member                                   | Default value
    /// -----------------------------------------|--------------------------------------
    /// IndexType                                | VT_UNDEFINED
    /// Flags                                    | DRAW_FLAG_NONE
    /// IndirectAttribsBufferStateTransitionMode | RESOURCE_STATE_TRANSITION_MODE_NONE
    /// IndirectDrawArgsOffset                   | 0
    DrawIndexedIndirectAttribs()noexcept{}

    /// Initializes the structure members with user-specified values.
    DrawIndexedIndirectAttribs(VALUE_TYPE                     _IndexType,
                               DRAW_FLAGS                     _Flags,
                               RESOURCE_STATE_TRANSITION_MODE _IndirectAttribsBufferStateTransitionMode,
                               Uint32                         _IndirectDrawArgsOffset = 0)noexcept : 
        IndexType                               {_IndexType                               },
        Flags                                   {_Flags                                   },
        IndirectAttribsBufferStateTransitionMode{_IndirectAttribsBufferStateTransitionMode},
        IndirectDrawArgsOffset                  {_IndirectDrawArgsOffset                  }
    {}
#endif
};
typedef struct DrawIndexedIndirectAttribs DrawIndexedIndirectAttribs;


/// Defines the mesh draw command attributes.

/// This structure is used by IDeviceContext::DrawMesh().
struct DrawMeshAttribs
{
    /// The number of dispatched groups
    Uint32 ThreadGroupCount DEFAULT_INITIALIZER(1);

    /// Additional flags, see Diligent::DRAW_FLAGS.
    DRAW_FLAGS Flags        DEFAULT_INITIALIZER(DRAW_FLAG_NONE);

#if DILIGENT_CPP_INTERFACE
    /// Initializes the structure members with default values.
    DrawMeshAttribs()noexcept{}

    /// Initializes the structure with user-specified values.
    DrawMeshAttribs(Uint32     _ThreadGroupCount,
                    DRAW_FLAGS _Flags)noexcept :
        ThreadGroupCount {_ThreadGroupCount},
        Flags            {_Flags}
    {}
#endif
};
typedef struct DrawMeshAttribs DrawMeshAttribs;


/// Defines the mesh indirect draw command attributes.

/// This structure is used by IDeviceContext::DrawMeshIndirect().
struct DrawMeshIndirectAttribs
{
    /// Additional flags, see Diligent::DRAW_FLAGS.
    DRAW_FLAGS Flags                DEFAULT_INITIALIZER(DRAW_FLAG_NONE);
    
    /// State transition mode for indirect draw arguments buffer.
    RESOURCE_STATE_TRANSITION_MODE IndirectAttribsBufferStateTransitionMode DEFAULT_INITIALIZER(RESOURCE_STATE_TRANSITION_MODE_NONE);

    /// Offset from the beginning of the buffer to the location of draw command attributes.
    Uint32 IndirectDrawArgsOffset        DEFAULT_INITIALIZER(0);

#if DILIGENT_CPP_INTERFACE
    /// Initializes the structure members with default values

    /// Default values:
    /// Member                                   | Default value
    /// -----------------------------------------|--------------------------------------
    /// Flags                                    | DRAW_FLAG_NONE
    /// IndirectAttribsBufferStateTransitionMode | RESOURCE_STATE_TRANSITION_MODE_NONE
    /// IndirectDrawArgsOffset                   | 0
    DrawMeshIndirectAttribs()noexcept{}

    /// Initializes the structure members with user-specified values.
    DrawMeshIndirectAttribs(DRAW_FLAGS                     _Flags,
                            RESOURCE_STATE_TRANSITION_MODE _IndirectAttribsBufferStateTransitionMode,
                            Uint32                         _IndirectDrawArgsOffset = 0)noexcept : 
        Flags                                   {_Flags                                   },
        IndirectAttribsBufferStateTransitionMode{_IndirectAttribsBufferStateTransitionMode},
        IndirectDrawArgsOffset                  {_IndirectDrawArgsOffset                  }
    {}
#endif
};
typedef struct DrawMeshIndirectAttribs DrawMeshIndirectAttribs;


/// Defines the mesh indirect draw count command attributes.

/// This structure is used by IDeviceContext::DrawMeshIndirectCount().
struct DrawMeshIndirectCountAttribs
{
    /// Additional flags, see Diligent::DRAW_FLAGS.
    DRAW_FLAGS Flags                DEFAULT_INITIALIZER(DRAW_FLAG_NONE);

    /// The maximum number of commands that will be read from the count buffer.
    Uint32     MaxCommandCount      DEFAULT_INITIALIZER(1);

    /// State transition mode for indirect draw arguments buffer.
    RESOURCE_STATE_TRANSITION_MODE IndirectAttribsBufferStateTransitionMode DEFAULT_INITIALIZER(RESOURCE_STATE_TRANSITION_MODE_NONE);

    /// Offset from the beginning of the buffer to the location of draw command attributes.
    Uint32 IndirectDrawArgsOffset        DEFAULT_INITIALIZER(0);

    /// State transition mode for the count buffer.
    RESOURCE_STATE_TRANSITION_MODE CountBufferStateTransitionMode DEFAULT_INITIALIZER(RESOURCE_STATE_TRANSITION_MODE_NONE);

    /// Offset from the beginning of the buffer to the location of the command counter.
    Uint32 CountBufferOffset        DEFAULT_INITIALIZER(0);

#if DILIGENT_CPP_INTERFACE
    DrawMeshIndirectCountAttribs()noexcept{}

    /// Initializes the structure members with user-specified values.
    DrawMeshIndirectCountAttribs(DRAW_FLAGS                     _Flags,
                                 RESOURCE_STATE_TRANSITION_MODE _IndirectAttribsBufferStateTransitionMode,
                                 Uint32                         _IndirectDrawArgsOffset,
                                 RESOURCE_STATE_TRANSITION_MODE _CountBufferStateTransitionMode,
                                 Uint32                         _CountBufferOffset)noexcept : 
        Flags                                   {_Flags                                   },
        IndirectAttribsBufferStateTransitionMode{_IndirectAttribsBufferStateTransitionMode},
        IndirectDrawArgsOffset                  {_IndirectDrawArgsOffset                  },
        CountBufferStateTransitionMode          {_CountBufferStateTransitionMode          },
        CountBufferOffset                       {_CountBufferOffset                       }
    {}
#endif
};
typedef struct DrawMeshIndirectCountAttribs DrawMeshIndirectCountAttribs;


/// Defines which parts of the depth-stencil buffer to clear.

/// These flags are used by IDeviceContext::ClearDepthStencil().
DILIGENT_TYPED_ENUM(CLEAR_DEPTH_STENCIL_FLAGS, Uint32)
{
    /// Perform no clear.
    CLEAR_DEPTH_FLAG_NONE = 0x00,  

    /// Clear depth part of the buffer.
    CLEAR_DEPTH_FLAG      = 0x01,  

    /// Clear stencil part of the buffer.
    CLEAR_STENCIL_FLAG    = 0x02   
};
DEFINE_FLAG_ENUM_OPERATORS(CLEAR_DEPTH_STENCIL_FLAGS)


/// Describes dispatch command arguments.

/// This structure is used by IDeviceContext::DispatchCompute().
struct DispatchComputeAttribs
{
    Uint32 ThreadGroupCountX DEFAULT_INITIALIZER(1); ///< Number of groups dispatched in X direction.
    Uint32 ThreadGroupCountY DEFAULT_INITIALIZER(1); ///< Number of groups dispatched in Y direction.
    Uint32 ThreadGroupCountZ DEFAULT_INITIALIZER(1); ///< Number of groups dispatched in Z direction.

#if DILIGENT_CPP_INTERFACE
    DispatchComputeAttribs()noexcept{}

    /// Initializes the structure with user-specified values.
    DispatchComputeAttribs(Uint32 GroupsX, Uint32 GroupsY, Uint32 GroupsZ = 1)noexcept :
        ThreadGroupCountX {GroupsX},
        ThreadGroupCountY {GroupsY},
        ThreadGroupCountZ {GroupsZ}
    {}
#endif
};
typedef struct DispatchComputeAttribs DispatchComputeAttribs;


/// Describes dispatch command arguments.

/// This structure is used by IDeviceContext::DispatchComputeIndirect().
struct DispatchComputeIndirectAttribs
{
    /// State transition mode for indirect dispatch attributes buffer.
    RESOURCE_STATE_TRANSITION_MODE IndirectAttribsBufferStateTransitionMode DEFAULT_INITIALIZER(RESOURCE_STATE_TRANSITION_MODE_NONE);

    /// The offset from the beginning of the buffer to the dispatch command arguments.
    Uint32  DispatchArgsByteOffset    DEFAULT_INITIALIZER(0);

#if DILIGENT_CPP_INTERFACE
    DispatchComputeIndirectAttribs()noexcept{}

    /// Initializes the structure with user-specified values.
    explicit
    DispatchComputeIndirectAttribs(RESOURCE_STATE_TRANSITION_MODE StateTransitionMode,
                                   Uint32                         Offset              = 0) :
        IndirectAttribsBufferStateTransitionMode{StateTransitionMode},
        DispatchArgsByteOffset                  {Offset             }
    {}
#endif
};
typedef struct DispatchComputeIndirectAttribs DispatchComputeIndirectAttribs;


/// Describes multi-sampled texture resolve command arguments.

/// This structure is used by IDeviceContext::ResolveTextureSubresource().
struct ResolveTextureSubresourceAttribs
{
    /// Mip level of the source multi-sampled texture to resolve.
    Uint32 SrcMipLevel   DEFAULT_INITIALIZER(0);

    /// Array slice of the source multi-sampled texture to resolve.
    Uint32 SrcSlice      DEFAULT_INITIALIZER(0);

    /// Source texture state transition mode, see Diligent::RESOURCE_STATE_TRANSITION_MODE.
    RESOURCE_STATE_TRANSITION_MODE SrcTextureTransitionMode DEFAULT_INITIALIZER(RESOURCE_STATE_TRANSITION_MODE_NONE);

    /// Mip level of the destination non-multi-sampled texture.
    Uint32 DstMipLevel   DEFAULT_INITIALIZER(0);

    /// Array slice of the destination non-multi-sampled texture.
    Uint32 DstSlice      DEFAULT_INITIALIZER(0);

    /// Destination texture state transition mode, see Diligent::RESOURCE_STATE_TRANSITION_MODE.
    RESOURCE_STATE_TRANSITION_MODE DstTextureTransitionMode DEFAULT_INITIALIZER(RESOURCE_STATE_TRANSITION_MODE_NONE);

    /// If one or both textures are typeless, specifies the type of the typeless texture.
    /// If both texture formats are not typeless, in which case they must be identical, this member must be
    /// either TEX_FORMAT_UNKNOWN, or match this format.
    TEXTURE_FORMAT Format DEFAULT_INITIALIZER(TEX_FORMAT_UNKNOWN);
};
typedef struct ResolveTextureSubresourceAttribs ResolveTextureSubresourceAttribs;


/// Defines allowed flags for IDeviceContext::SetVertexBuffers() function.
DILIGENT_TYPED_ENUM(SET_VERTEX_BUFFERS_FLAGS, Uint8)
{
    /// No extra operations.
    SET_VERTEX_BUFFERS_FLAG_NONE  = 0x00,

    /// Reset the vertex buffers to only the buffers specified in this
    /// call. All buffers previously bound to the pipeline will be unbound.
    SET_VERTEX_BUFFERS_FLAG_RESET = 0x01
};
DEFINE_FLAG_ENUM_OPERATORS(SET_VERTEX_BUFFERS_FLAGS)


/// Describes the viewport.

/// This structure is used by IDeviceContext::SetViewports().
struct Viewport
{
    /// X coordinate of the left boundary of the viewport.
    Float32 TopLeftX    DEFAULT_INITIALIZER(0.f);

    /// Y coordinate of the top boundary of the viewport.
    /// When defining a viewport, DirectX convention is used:
    /// window coordinate systems originates in the LEFT TOP corner
    /// of the screen with Y axis pointing down.
    Float32 TopLeftY    DEFAULT_INITIALIZER(0.f);

    /// Viewport width.
    Float32 Width       DEFAULT_INITIALIZER(0.f);

    /// Viewport Height.
    Float32 Height      DEFAULT_INITIALIZER(0.f);

    /// Minimum depth of the viewport. Ranges between 0 and 1.
    Float32 MinDepth    DEFAULT_INITIALIZER(0.f);

    /// Maximum depth of the viewport. Ranges between 0 and 1.
    Float32 MaxDepth    DEFAULT_INITIALIZER(1.f);

#if DILIGENT_CPP_INTERFACE
    /// Initializes the structure.
    Viewport(Float32 _TopLeftX,     Float32 _TopLeftY,
             Float32 _Width,        Float32 _Height,
             Float32 _MinDepth = 0, Float32 _MaxDepth = 1)noexcept :
        TopLeftX {_TopLeftX},
        TopLeftY {_TopLeftY},
        Width    {_Width   },
        Height   {_Height  },
        MinDepth {_MinDepth},
        MaxDepth {_MaxDepth}
    {}

    Viewport()noexcept{}
#endif
};
typedef struct Viewport Viewport;


/// Describes the rectangle.

/// This structure is used by IDeviceContext::SetScissorRects().
///
/// \remarks When defining a viewport, Windows convention is used:
///          window coordinate systems originates in the LEFT TOP corner
///          of the screen with Y axis pointing down.
struct Rect
{
    Int32 left   DEFAULT_INITIALIZER(0);  ///< X coordinate of the left boundary of the viewport.
    Int32 top    DEFAULT_INITIALIZER(0);  ///< Y coordinate of the top boundary of the viewport.
    Int32 right  DEFAULT_INITIALIZER(0);  ///< X coordinate of the right boundary of the viewport.
    Int32 bottom DEFAULT_INITIALIZER(0);  ///< Y coordinate of the bottom boundary of the viewport.

#if DILIGENT_CPP_INTERFACE
    /// Initializes the structure
    Rect(Int32 _left, Int32 _top, Int32 _right, Int32 _bottom)noexcept : 
        left   {_left  },
        top    {_top   },
        right  {_right },
        bottom {_bottom}
    {}

    Rect()noexcept{}

    bool IsValid() const
    {
        return right > left && bottom > top;
    }
#endif
};
typedef struct Rect Rect;


/// Defines copy texture command attributes.

/// This structure is used by IDeviceContext::CopyTexture().
struct CopyTextureAttribs
{
    /// Source texture to copy data from.
    ITexture*                      pSrcTexture              DEFAULT_INITIALIZER(nullptr);

    /// Mip level of the source texture to copy data from.
    Uint32                         SrcMipLevel              DEFAULT_INITIALIZER(0);

    /// Array slice of the source texture to copy data from. Must be 0 for non-array textures.
    Uint32                         SrcSlice                 DEFAULT_INITIALIZER(0);
    
    /// Source region to copy. Use nullptr to copy the entire subresource.
    const Box*                     pSrcBox                  DEFAULT_INITIALIZER(nullptr);
    
    /// Source texture state transition mode (see Diligent::RESOURCE_STATE_TRANSITION_MODE).
    RESOURCE_STATE_TRANSITION_MODE SrcTextureTransitionMode DEFAULT_INITIALIZER(RESOURCE_STATE_TRANSITION_MODE_NONE);

    /// Destination texture.
    ITexture*                      pDstTexture              DEFAULT_INITIALIZER(nullptr);

    /// Destination mip level.
    Uint32                         DstMipLevel              DEFAULT_INITIALIZER(0);

    /// Destination array slice. Must be 0 for non-array textures.
    Uint32                         DstSlice                 DEFAULT_INITIALIZER(0);

    /// X offset on the destination subresource.
    Uint32                         DstX                     DEFAULT_INITIALIZER(0);

    /// Y offset on the destination subresource.
    Uint32                         DstY                     DEFAULT_INITIALIZER(0);

    /// Z offset on the destination subresource
    Uint32                         DstZ                     DEFAULT_INITIALIZER(0);

    /// Destination texture state transition mode (see Diligent::RESOURCE_STATE_TRANSITION_MODE).
    RESOURCE_STATE_TRANSITION_MODE DstTextureTransitionMode DEFAULT_INITIALIZER(RESOURCE_STATE_TRANSITION_MODE_NONE);


#if DILIGENT_CPP_INTERFACE
    CopyTextureAttribs()noexcept{}

    CopyTextureAttribs(ITexture*                      _pSrcTexture,
                       RESOURCE_STATE_TRANSITION_MODE _SrcTextureTransitionMode,
                       ITexture*                      _pDstTexture,
                       RESOURCE_STATE_TRANSITION_MODE _DstTextureTransitionMode)noexcept :
        pSrcTexture             {_pSrcTexture             },
        SrcTextureTransitionMode{_SrcTextureTransitionMode},
        pDstTexture             {_pDstTexture             },
        DstTextureTransitionMode{_DstTextureTransitionMode}
    {}
#endif
};
typedef struct CopyTextureAttribs CopyTextureAttribs;


/// BeginRenderPass command attributes.

/// This structure is used by IDeviceContext::BeginRenderPass().
struct BeginRenderPassAttribs
{
    /// Render pass to begin.
    IRenderPass*    pRenderPass     DEFAULT_INITIALIZER(nullptr);

    /// Framebuffer containing the attachments that are used with the render pass.
    IFramebuffer*   pFramebuffer    DEFAULT_INITIALIZER(nullptr);

    /// The number of elements in pClearValues array.
    Uint32 ClearValueCount          DEFAULT_INITIALIZER(0);

    /// A pointer to an array of ClearValueCount OptimizedClearValue structures that contains
    /// clear values for each attachment, if the attachment uses a LoadOp value of ATTACHMENT_LOAD_OP_CLEAR
    /// or if the attachment has a depth/stencil format and uses a StencilLoadOp value of ATTACHMENT_LOAD_OP_CLEAR.
    /// The array is indexed by attachment number. Only elements corresponding to cleared attachments are used.
    /// Other elements of pClearValues are ignored.
    OptimizedClearValue* pClearValues   DEFAULT_INITIALIZER(nullptr);

    /// Framebuffer attachments state transition mode before the render pass begins.

    /// This parameter also indicates how attachment states should be handled when
    /// transitioning between subpasses as well as after the render pass ends.
    /// When RESOURCE_STATE_TRANSITION_MODE_TRANSITION is used, attachment states will be
    /// updated so that they match the state in the current subpass as well as the final states
    /// specified by the render pass when the pass ends.
    /// Note that resources are always transitioned. The flag only indicates if the internal
    /// state variables should be updated.
    /// When RESOURCE_STATE_TRANSITION_MODE_NONE or RESOURCE_STATE_TRANSITION_MODE_VERIFY is used,
    /// internal state variables are not updated and it is the application responsibility to set them
    /// manually to match the actual states.
    RESOURCE_STATE_TRANSITION_MODE StateTransitionMode DEFAULT_INITIALIZER(RESOURCE_STATE_TRANSITION_MODE_NONE);
};
typedef struct BeginRenderPassAttribs BeginRenderPassAttribs;


/// TLAS instance flags that are used in IDeviceContext::BuildTLAS().
DILIGENT_TYPED_ENUM(RAYTRACING_INSTANCE_FLAGS, Uint8)
{
    RAYTRACING_INSTANCE_NONE = 0,

    /// Disables face culling for this instance.
    RAYTRACING_INSTANCE_TRIANGLE_FACING_CULL_DISABLE = 0x01,

    /// Indicates that the front face of the triangle for culling purposes is the face that is counter
    /// clockwise in object space relative to the ray origin. Because the facing is determined in object
    /// space, an instance transform matrix does not change the winding, but a geometry transform does.
    RAYTRACING_INSTANCE_TRIANGLE_FRONT_COUNTERCLOCKWISE = 0x02,

    /// Causes this instance to act as though RAYTRACING_GEOMETRY_FLAGS_OPAQUE were specified on all 
    /// geometries referenced by this instance. This behavior can be overridden in the shader with ray flags.
    RAYTRACING_INSTANCE_FORCE_OPAQUE = 0x04,

    /// Causes this instance to act as though RAYTRACING_GEOMETRY_FLAGS_OPAQUE were not specified on all
    /// geometries referenced by this instance. This behavior can be overridden in the shader with ray flags.
    RAYTRACING_INSTANCE_FORCE_NO_OPAQUE = 0x08,

    RAYTRACING_INSTANCE_FLAGS_LAST = RAYTRACING_INSTANCE_FORCE_NO_OPAQUE
};
DEFINE_FLAG_ENUM_OPERATORS(RAYTRACING_INSTANCE_FLAGS)


/// Defines acceleration structure copy mode.

/// These the flags used by IDeviceContext::CopyBLAS() and IDeviceContext::CopyTLAS().
DILIGENT_TYPED_ENUM(COPY_AS_MODE, Uint8)
{
    /// Creates a direct copy of the acceleration structure specified in pSrc into the one specified by pDst.
    /// The pDst acceleration structure must have been created with the same parameters as pSrc.
    COPY_AS_MODE_CLONE = 0,

    /// Creates a more compact version of an acceleration structure pSrc into pDst.
    /// The acceleration structure pDst must have been created with a CompactedSize corresponding
    /// to the one returned by IDeviceContext::WriteBLASCompactedSize() or IDeviceContext::WriteTLASCompactedSize()
    /// after the build of the acceleration structure specified by pSrc.
    COPY_AS_MODE_COMPACT,

    COPY_AS_MODE_LAST = COPY_AS_MODE_COMPACT,
};


/// Defines geometry flags for ray tracing.
DILIGENT_TYPED_ENUM(RAYTRACING_GEOMETRY_FLAGS, Uint8)
{
    RAYTRACING_GEOMETRY_FLAG_NONE = 0,

    /// Indicates that this geometry does not invoke the any-hit shaders even if present in a hit group.
    RAYTRACING_GEOMETRY_FLAG_OPAQUE = 0x01,

    /// Indicates that the implementation must only call the any-hit shader a single time for each primitive in this geometry.
    /// If this bit is absent an implementation may invoke the any-hit shader more than once for this geometry.
    RAYTRACING_GEOMETRY_FLAG_NO_DUPLICATE_ANY_HIT_INVOCATION = 0x02,

    RAYTRACING_GEOMETRY_FLAGS_LAST = RAYTRACING_GEOMETRY_FLAG_NO_DUPLICATE_ANY_HIT_INVOCATION
};
DEFINE_FLAG_ENUM_OPERATORS(RAYTRACING_GEOMETRY_FLAGS)


/// Triangle geometry data description.
struct BLASBuildTriangleData
{
    /// Geometry name used to map a geometry to a hit group in the shader binding table.
    /// Add geometry data to the geometry that is allocated by BLASTriangleDesc with the same name.
    const char* GeometryName          DEFAULT_INITIALIZER(nullptr);
    
    /// Triangle vertices data source.
    /// Triangles are considered "inactive" if the x component of each vertex is NaN.
    /// The buffer must be created with BIND_RAY_TRACING flag.
    IBuffer*    pVertexBuffer         DEFAULT_INITIALIZER(nullptr);
    
    /// Data offset in bytes in pVertexBuffer.
    Uint32      VertexOffset          DEFAULT_INITIALIZER(0);
    
    /// Stride in bytes between vertices.
    Uint32      VertexStride          DEFAULT_INITIALIZER(0);
    
    /// The number of triangle vertices.
    /// Must be less than or equal to BLASTriangleDesc::MaxVertexCount.
    Uint32      VertexCount           DEFAULT_INITIALIZER(0);
    
    /// The type of the vertex components.
    /// This is an optional value. Must be undefined or same as in BLASTriangleDesc. 
    VALUE_TYPE  VertexValueType       DEFAULT_INITIALIZER(VT_UNDEFINED);

    /// The number of vertex components.
    /// This is an optional value. Must be undefined or same as in BLASTriangleDesc. 
    Uint8       VertexComponentCount  DEFAULT_INITIALIZER(0);
    
    /// The number of triangles.
    /// Must equal to VertexCount / 3 if pIndexBuffer is null or must be equal to index count / 3.
    Uint32      PrimitiveCount        DEFAULT_INITIALIZER(0);

    /// Triangle indices data source.
    /// Must be null if BLASTriangleDesc::IndexType is undefined.
    /// The buffer must be created with BIND_RAY_TRACING flag.
    IBuffer*    pIndexBuffer          DEFAULT_INITIALIZER(nullptr);
    
    /// Data offset in bytes in pIndexBuffer.
    Uint32      IndexOffset           DEFAULT_INITIALIZER(0);
    
    /// The type of triangle indices, see Diligent::VALUE_TYPE.
    /// This is an optional value. Must be undefined or same as in BLASTriangleDesc.
    VALUE_TYPE  IndexType             DEFAULT_INITIALIZER(VT_UNDEFINED);
    
    /// Geometry transformation data source.
    /// The buffer must be created with BIND_RAY_TRACING flag.
    IBuffer*    pTransformBuffer      DEFAULT_INITIALIZER(nullptr);
    
    /// Data offset in bytes in pTransformBuffer.
    Uint32      TransformBufferOffset DEFAULT_INITIALIZER(0);

    /// Geometry flags, se Diligent::RAYTRACING_GEOMETRY_FLAGS.
    RAYTRACING_GEOMETRY_FLAGS Flags DEFAULT_INITIALIZER(RAYTRACING_GEOMETRY_FLAG_NONE);
    
#if DILIGENT_CPP_INTERFACE
    BLASBuildTriangleData() noexcept {}
#endif
};
typedef struct BLASBuildTriangleData BLASBuildTriangleData;


/// AABB geometry data description.
struct BLASBuildBoundingBoxData
{
    /// Geometry name used to map geometry to hit group in shader binding table.
    /// Put geometry data to geometry that allocated by BLASBoundingBoxDesc with the same name.
    const char* GeometryName DEFAULT_INITIALIZER(nullptr);
    
    /// AABB data source.
    /// Each AABB defined as { float3 Min; float3 Max } structure.
    /// AABB are considered inactive if AABB.Min.x is NaN.
    /// Buffer must be created with BIND_RAY_TRACING flag.
    IBuffer*    pBoxBuffer   DEFAULT_INITIALIZER(nullptr);
    
    /// Data offset in bytes in pBoxBuffer.
    Uint32      BoxOffset    DEFAULT_INITIALIZER(0);
    
    /// Stride in bytes between each AABB.
    Uint32      BoxStride    DEFAULT_INITIALIZER(0);
    
    /// Number of AABBs.
    /// Must be less than or equal to BLASBoundingBoxDesc::MaxBoxCount.
    Uint32      BoxCount     DEFAULT_INITIALIZER(0);
    
    /// Geometry flags, see Diligent::RAYTRACING_GEOMETRY_FLAGS.
    RAYTRACING_GEOMETRY_FLAGS Flags DEFAULT_INITIALIZER(RAYTRACING_GEOMETRY_FLAG_NONE);
    
#if DILIGENT_CPP_INTERFACE
    BLASBuildBoundingBoxData() noexcept {}
#endif
};
typedef struct BLASBuildBoundingBoxData BLASBuildBoundingBoxData;


/// This structure is used by IDeviceContext::BuildBLAS().
struct BuildBLASAttribs
{
    /// Target bottom-level AS.
    /// Access to the BLAS must be externally synchronized.
    IBottomLevelAS*                 pBLAS                       DEFAULT_INITIALIZER(nullptr);

    /// Bottom-level AS state transition mode (see Diligent::RESOURCE_STATE_TRANSITION_MODE).
    RESOURCE_STATE_TRANSITION_MODE  BLASTransitionMode          DEFAULT_INITIALIZER(RESOURCE_STATE_TRANSITION_MODE_NONE);

    /// Geometry data source buffers state transition mode (see Diligent::RESOURCE_STATE_TRANSITION_MODE).
    RESOURCE_STATE_TRANSITION_MODE  GeometryTransitionMode      DEFAULT_INITIALIZER(RESOURCE_STATE_TRANSITION_MODE_NONE);

    /// A pointer to an array of TriangleDataCount BLASBuildTriangleData structures that contains triangle geometry data.
    /// If Update is true:
    ///     - Only vertex positions (in pVertexBuffer) and transformation (in pTransformBuffer) can be changed.
    ///     - All other content in BLASBuildTriangleData and buffers must be the same as what was used to build BLAS.
    ///     - To disable geometry, make all triangles inactive, see BLASBuildTriangleData::pVertexBuffer description.
    BLASBuildTriangleData const*    pTriangleData               DEFAULT_INITIALIZER(nullptr);

    /// The number of triangle grometries.
    /// Must be less than or equal to BottomLevelASDesc::TriangleCount.
    /// If Update is true then the count must be the same as the one used to build BLAS.
    Uint32                          TriangleDataCount           DEFAULT_INITIALIZER(0);

    /// A pointer to an array of BoxDataCount BLASBuildBoundingBoxData structures that contain AABB geometry data.
    /// If Update is true:
    ///     - AABB coordinates (in pBoxBuffer) can be changed.
    ///     - All other content in BLASBuildBoundingBoxData must be same as used to build BLAS.
    ///     - To disable geometry make all AAABBs inactive, see BLASBuildBoundingBoxData::pBoxBuffer description.
    BLASBuildBoundingBoxData const* pBoxData                    DEFAULT_INITIALIZER(nullptr);
    
    /// The number of AABB geometries.
    /// Must be less than or equal to BottomLevelASDesc::BoxCount.
    /// If Update is true then the count must be the same as the one used to build BLAS.
    Uint32                          BoxDataCount                DEFAULT_INITIALIZER(0);
    
    /// The buffer that is used for acceleration structure building.
    /// Must be created with BIND_RAY_TRACING.
    /// Call IBottomLevelAS::GetScratchBufferSizes().Build to get the minimal size for the scratch buffer.
    IBuffer*                        pScratchBuffer              DEFAULT_INITIALIZER(nullptr);
    
    /// Offset from the beginning of the buffer.
    Uint32                          ScratchBufferOffset         DEFAULT_INITIALIZER(0);
    
    /// Scratch buffer state transition mode (see Diligent::RESOURCE_STATE_TRANSITION_MODE).
    RESOURCE_STATE_TRANSITION_MODE  ScratchBufferTransitionMode DEFAULT_INITIALIZER(RESOURCE_STATE_TRANSITION_MODE_NONE);
    
    /// if false then BLAS will be built from scratch.
    /// If true then previous content of BLAS will be updated.
    /// pBLAS must be created with RAYTRACING_BUILD_AS_ALLOW_UPDATE flag.
    /// An update will be faster than building an acceleration structure from scratch.
    Bool                            Update                      DEFAULT_INITIALIZER(False);

#if DILIGENT_CPP_INTERFACE
    BuildBLASAttribs() noexcept {}
#endif
};
typedef struct BuildBLASAttribs BuildBLASAttribs;


/// Can be used to calculate the TLASBuildInstanceData::ContributionToHitGroupIndex depending on instance count,
/// geometry count in each instance (in TLASBuildInstanceData::pBLAS) and shader binding mode in BuildTLASAttribs::BindingMode.
/// 
/// Example:
///  InstanceOffset = BaseContributionToHitGroupIndex;
///  For each instance in TLAS
///     if (Instance.ContributionToHitGroupIndex == TLAS_INSTANCE_OFFSET_AUTO)
///         Instance.ContributionToHitGroupIndex = InstanceOffset;
///         if (BindingMode == HIT_GROUP_BINDING_MODE_PER_GEOMETRY) InstanceOffset += Instance.pBLAS->GeometryCount() * HitGroupStride;
///         if (BindingMode == HIT_GROUP_BINDING_MODE_PER_INSTANCE) InstanceOffset += HitGroupStride;
static const Uint32 TLAS_INSTANCE_OFFSET_AUTO = ~0u;


/// Row-major matrix 
struct InstanceMatrix
{
    ///        rotation        translation
    /// ([0,0]  [0,1]  [0,2])   ([0,3])
    /// ([1,0]  [1,1]  [1,2])   ([1,3])
    /// ([2,0]  [2,1]  [2,2])   ([2,3])
    float data [3][4];

#if DILIGENT_CPP_INTERFACE
    /// Construct identity matrix.
    InstanceMatrix() noexcept :
        data{{1.0f, 0.0f, 0.0f, 0.0f},
             {0.0f, 1.0f, 0.0f, 0.0f},
             {0.0f, 0.0f, 1.0f, 0.0f}}
    {}

    InstanceMatrix(const InstanceMatrix&) noexcept = default;
    
    /// Sets the translation part.
    InstanceMatrix& SetTranslation(float x, float y, float z) noexcept
    {
        data[0][3] = x;
        data[1][3] = y;
        data[2][3] = z;
        return *this;
    }

    /// Sets the rotation part.
    InstanceMatrix& SetRotation(const float* pMatrix3x3) noexcept
    {
        data[0][0] = pMatrix3x3[0];  data[1][0] = pMatrix3x3[1];  data[2][0] = pMatrix3x3[2];
        data[0][1] = pMatrix3x3[3];  data[1][1] = pMatrix3x3[4];  data[2][1] = pMatrix3x3[5];
        data[0][2] = pMatrix3x3[6];  data[1][2] = pMatrix3x3[7];  data[2][2] = pMatrix3x3[8];
        return *this;
    }
#endif
};
typedef struct InstanceMatrix InstanceMatrix;


/// This structure is used by BuildTLASAttribs.
struct TLASBuildInstanceData
{
    /// Instance name that is used to map an instance to a hit group in shader binding table.
    const char*               InstanceName    DEFAULT_INITIALIZER(nullptr);
    
    /// Bottom-level AS that represents instance geometry.
    /// Once built, TLAS will hold strong reference to pBLAS until next build or copy operation.
    /// Access to the BLAS must be externally synchronized.
    IBottomLevelAS*           pBLAS           DEFAULT_INITIALIZER(nullptr);
    
    /// Instace to world transformation.
    InstanceMatrix            Transform;
    
    /// User-defined value that can be accessed in the shader via InstanceID() in HLSL and gl_InstanceCustomIndex in GLSL.
    /// Only the lower 24 bits are used.
    Uint32                    CustomId        DEFAULT_INITIALIZER(0);
    
    /// Instance flags, see Diligent::RAYTRACING_INSTANCE_FLAGS.
    RAYTRACING_INSTANCE_FLAGS Flags           DEFAULT_INITIALIZER(RAYTRACING_INSTANCE_NONE);

    /// Visibility mask for the geometry, the instance may only be hit if rayMask & instance.Mask != 0.
    /// ('rayMask' in GLSL is a 'cullMask' argument of traceRay(), 'rayMask' in HLSL is an 'InstanceInclusionMask' argument of TraceRay()).
    Uint8                     Mask            DEFAULT_INITIALIZER(0xFF);
    
    /// The index used to calculate the hit group location in the shader binding table.
    /// Must be TLAS_INSTANCE_OFFSET_AUTO if BuildTLASAttribs::BindingMode is not SHADER_BINDING_USER_DEFINED.
    /// Only the lower 24 bits are used.
    Uint32                    ContributionToHitGroupIndex DEFAULT_INITIALIZER(TLAS_INSTANCE_OFFSET_AUTO);
    
#if DILIGENT_CPP_INTERFACE
    TLASBuildInstanceData() noexcept {}
#endif
};
typedef struct TLASBuildInstanceData TLASBuildInstanceData;


/// Top-level AS instance size in bytes in GPU side.
/// Used to calculate size of BuildTLASAttribs::pInstanceBuffer.
static const Uint32 TLAS_INSTANCE_DATA_SIZE = 64;


/// This structure is used by IDeviceContext::BuildTLAS().
struct BuildTLASAttribs
{
    /// Target top-level AS.
    /// Access to the TLAS must be externally synchronized.
    ITopLevelAS*                    pTLAS                         DEFAULT_INITIALIZER(nullptr);
    
    /// Top-level AS state transition mode (see Diligent::RESOURCE_STATE_TRANSITION_MODE).
    RESOURCE_STATE_TRANSITION_MODE  TLASTransitionMode            DEFAULT_INITIALIZER(RESOURCE_STATE_TRANSITION_MODE_NONE);
    
    /// Bottom-level AS (in TLASBuildInstanceData::pBLAS) state transition mode (see Diligent::RESOURCE_STATE_TRANSITION_MODE).
    RESOURCE_STATE_TRANSITION_MODE  BLASTransitionMode            DEFAULT_INITIALIZER(RESOURCE_STATE_TRANSITION_MODE_NONE);
    
    /// A pointer to an array of InstanceCount TLASBuildInstanceData structures that contain instance data.
    /// If Update is true:
    ///     - Any instance data can be changed.
    ///     - To disable an instance set TLASBuildInstanceData::Mask to zero or set empty TLASBuildInstanceData::BLAS to pBLAS.
    TLASBuildInstanceData const*    pInstances                    DEFAULT_INITIALIZER(nullptr);
    
    /// The number of instances.
    /// Must be less than or equal to TopLevelASDesc::MaxInstanceCount.
    /// If Update is true then count must be the same as used to build TLAS.
    Uint32                          InstanceCount                 DEFAULT_INITIALIZER(0);
    
    /// The buffer that will be used to store instance data during AS building.
    /// The buffer size must be at least TLAS_INSTANCE_DATA_SIZE * InstanceCount.
    /// The buffer must be created with BIND_RAY_TRACING flag.
    IBuffer*                        pInstanceBuffer               DEFAULT_INITIALIZER(nullptr);
    
    /// Offset from the beginning of the buffer to the location of instance data.
    Uint32                          InstanceBufferOffset          DEFAULT_INITIALIZER(0);
    
    /// Instance buffer state transition mode (see Diligent::RESOURCE_STATE_TRANSITION_MODE).
    RESOURCE_STATE_TRANSITION_MODE  InstanceBufferTransitionMode  DEFAULT_INITIALIZER(RESOURCE_STATE_TRANSITION_MODE_NONE);
    
    /// The number of hit shaders that can be bound for a single geometry or an instance (depends on BindingMode).
    ///   - Used to calculate TLASBuildInstanceData::ContributionToHitGroupIndex.
    ///   - Ignored if BindingMode is SHADER_BINDING_USER_DEFINED.
    /// You should use the same value in a shader:
    /// 'MultiplierForGeometryContributionToHitGroupIndex' argument in TraceRay() in HLSL, 'sbtRecordStride' argument in traceRay() in GLSL.
    Uint32                          HitGroupStride         DEFAULT_INITIALIZER(1);
    
    /// Base offset for the hit group location.
    /// Can be used to bind hit shaders for multiple acceleration structures, see IShaderBindingTable::BindHitGroupForGeometry().
    ///   - Used to calculate TLASBuildInstanceData::ContributionToHitGroupIndex.
    ///   - Ignored if BindingMode is SHADER_BINDING_USER_DEFINED.
    Uint32                          BaseContributionToHitGroupIndex DEFAULT_INITIALIZER(0);

    /// Hit shader binding mode, see Diligent::SHADER_BINDING_MODE.
    /// Used to calculate TLASBuildInstanceData::ContributionToHitGroupIndex.
    HIT_GROUP_BINDING_MODE          BindingMode                   DEFAULT_INITIALIZER(HIT_GROUP_BINDING_MODE_PER_GEOMETRY);
    
    /// Buffer that is used for acceleration structure building.
    /// Must be created with BIND_RAY_TRACING.
    /// Call ITopLevelAS::GetScratchBufferSizes().Build to get the minimal size for the scratch buffer.
    /// Access to the TLAS must be externally synchronized.
    IBuffer*                        pScratchBuffer                DEFAULT_INITIALIZER(nullptr);
    
    /// Offset from the beginning of the buffer.
    Uint32                          ScratchBufferOffset           DEFAULT_INITIALIZER(0);
    
    /// Scratch buffer state transition mode (see Diligent::RESOURCE_STATE_TRANSITION_MODE).
    RESOURCE_STATE_TRANSITION_MODE  ScratchBufferTransitionMode   DEFAULT_INITIALIZER(RESOURCE_STATE_TRANSITION_MODE_NONE);
    
    /// if false then TLAS will be built from scratch.
    /// If true then previous content of TLAS will be updated.
    /// pTLAS must be created with RAYTRACING_BUILD_AS_ALLOW_UPDATE flag.
    /// An update will be faster than building an acceleration structure from scratch.
    Bool                            Update                        DEFAULT_INITIALIZER(False);
    
#if DILIGENT_CPP_INTERFACE
    BuildTLASAttribs() noexcept {}
#endif
};
typedef struct BuildTLASAttribs BuildTLASAttribs;


/// This structure is used by IDeviceContext::CopyBLAS().
struct CopyBLASAttribs
{
    /// Source bottom-level AS.
    /// Access to the BLAS must be externally synchronized.
    IBottomLevelAS*                pSrc              DEFAULT_INITIALIZER(nullptr);
    
    /// Destination bottom-level AS.
    /// If Mode is COPY_AS_MODE_COMPACT then pDst must be created with CompactedSize
    /// that is greater or equal to the size returned by IDeviceContext::WriteBLASCompactedSize.
    /// Access to the BLAS must be externally synchronized.
    IBottomLevelAS*                pDst              DEFAULT_INITIALIZER(nullptr);
    
    /// Acceleration structure copy mode, see Diligent::COPY_AS_MODE.
    COPY_AS_MODE                   Mode              DEFAULT_INITIALIZER(COPY_AS_MODE_CLONE);
    
    /// Source bottom-level AS state transition mode (see Diligent::RESOURCE_STATE_TRANSITION_MODE).
    RESOURCE_STATE_TRANSITION_MODE SrcTransitionMode DEFAULT_INITIALIZER(RESOURCE_STATE_TRANSITION_MODE_NONE);
    
    /// Destination bottom-level AS state transition mode (see Diligent::RESOURCE_STATE_TRANSITION_MODE).
    RESOURCE_STATE_TRANSITION_MODE DstTransitionMode DEFAULT_INITIALIZER(RESOURCE_STATE_TRANSITION_MODE_NONE);
    
#if DILIGENT_CPP_INTERFACE
    CopyBLASAttribs() noexcept {}
#endif
};
typedef struct CopyBLASAttribs CopyBLASAttribs;


/// This structure is used by IDeviceContext::CopyTLAS().
struct CopyTLASAttribs
{
    /// Source top-level AS.
    /// Access to the TLAS must be externally synchronized.
    ITopLevelAS*                   pSrc              DEFAULT_INITIALIZER(nullptr);
    
    /// Destination top-level AS.
    /// If Mode is COPY_AS_MODE_COMPACT then pDst must be created with CompactedSize
    /// that is greater or equal to size that returned by IDeviceContext::WriteTLASCompactedSize.
    /// Access to the TLAS must be externally synchronized.
    ITopLevelAS*                   pDst              DEFAULT_INITIALIZER(nullptr);
    
    /// Acceleration structure copy mode, see Diligent::COPY_AS_MODE.
    COPY_AS_MODE                   Mode              DEFAULT_INITIALIZER(COPY_AS_MODE_CLONE);
    
    /// Source top-level AS state transition mode (see Diligent::RESOURCE_STATE_TRANSITION_MODE).
    RESOURCE_STATE_TRANSITION_MODE SrcTransitionMode DEFAULT_INITIALIZER(RESOURCE_STATE_TRANSITION_MODE_NONE);
    
    /// Destination top-level AS state transition mode (see Diligent::RESOURCE_STATE_TRANSITION_MODE).
    RESOURCE_STATE_TRANSITION_MODE DstTransitionMode DEFAULT_INITIALIZER(RESOURCE_STATE_TRANSITION_MODE_NONE);
    
#if DILIGENT_CPP_INTERFACE
    CopyTLASAttribs() noexcept {}
#endif
};
typedef struct CopyTLASAttribs CopyTLASAttribs;


/// This structure is used by IDeviceContext::WriteBLASCompactedSize().
struct WriteBLASCompactedSizeAttribs
{
    /// Bottom-level AS.
    IBottomLevelAS*                pBLAS                DEFAULT_INITIALIZER(nullptr);
    
    /// The destination buffer into which a 64-bit value representing the acceleration structure compacted size will be written to.
    IBuffer*                       pDestBuffer          DEFAULT_INITIALIZER(nullptr);
    
    /// Offset from the beginning of the buffer to the location of the AS compacted size.
    Uint32                         DestBufferOffset     DEFAULT_INITIALIZER(0);
    
    /// Bottom-level AS state transition mode (see Diligent::RESOURCE_STATE_TRANSITION_MODE).
    RESOURCE_STATE_TRANSITION_MODE BLASTransitionMode   DEFAULT_INITIALIZER(RESOURCE_STATE_TRANSITION_MODE_NONE);

    /// Destination buffer state transition mode (see Diligent::RESOURCE_STATE_TRANSITION_MODE).
    RESOURCE_STATE_TRANSITION_MODE BufferTransitionMode DEFAULT_INITIALIZER(RESOURCE_STATE_TRANSITION_MODE_NONE);
    
#if DILIGENT_CPP_INTERFACE
    WriteBLASCompactedSizeAttribs() noexcept {}
#endif
};
typedef struct WriteBLASCompactedSizeAttribs WriteBLASCompactedSizeAttribs;


/// This structure is used by IDeviceContext::WriteTLASCompactedSize().
struct WriteTLASCompactedSizeAttribs
{
    /// Top-level AS.
    ITopLevelAS*                   pTLAS                DEFAULT_INITIALIZER(nullptr);
    
    /// The destination buffer into which a 64-bit value representing the acceleration structure compacted size will be written to.
    IBuffer*                       pDestBuffer          DEFAULT_INITIALIZER(nullptr);
    
    /// Offset from the beginning of the buffer to the location of the AS compacted size.
    Uint32                         DestBufferOffset     DEFAULT_INITIALIZER(0);
    
    /// Top-level AS state transition mode (see Diligent::RESOURCE_STATE_TRANSITION_MODE).
    RESOURCE_STATE_TRANSITION_MODE TLASTransitionMode   DEFAULT_INITIALIZER(RESOURCE_STATE_TRANSITION_MODE_NONE);

    /// Destination buffer state transition mode (see Diligent::RESOURCE_STATE_TRANSITION_MODE).
    RESOURCE_STATE_TRANSITION_MODE BufferTransitionMode DEFAULT_INITIALIZER(RESOURCE_STATE_TRANSITION_MODE_NONE);
    
#if DILIGENT_CPP_INTERFACE
    WriteTLASCompactedSizeAttribs() noexcept {}
#endif
};
typedef struct WriteTLASCompactedSizeAttribs WriteTLASCompactedSizeAttribs;


/// This structure is used by IDeviceContext::TraceRays().
struct TraceRaysAttribs
{
    /// Shader binding table.
    IShaderBindingTable* pSBT        DEFAULT_INITIALIZER(nullptr);
    
    Uint32               DimensionX  DEFAULT_INITIALIZER(1); ///< The number of rays dispatched in X direction.
    Uint32               DimensionY  DEFAULT_INITIALIZER(1); ///< The number of rays dispatched in Y direction.
    Uint32               DimensionZ  DEFAULT_INITIALIZER(1); ///< The number of rays dispatched in Z direction.
        
#if DILIGENT_CPP_INTERFACE
    TraceRaysAttribs() noexcept {}
#endif
};
typedef struct TraceRaysAttribs TraceRaysAttribs;


/// This structure is used by IDeviceContext::TraceRaysIndirect().
struct TraceRaysIndirectAttribs
{
    /// Shader binding table.
    IShaderBindingTable* pSBT        DEFAULT_INITIALIZER(nullptr);

    /// State transition mode for indirect trace rays attributes buffer.
    RESOURCE_STATE_TRANSITION_MODE IndirectAttribsBufferStateTransitionMode DEFAULT_INITIALIZER(RESOURCE_STATE_TRANSITION_MODE_NONE);

    /// The offset from the beginning of the buffer to the trace rays command arguments.
    Uint32  ArgsByteOffset    DEFAULT_INITIALIZER(0);

    /// For Direct3D12 backend size must be 104 bytes,
    /// for Vulkan backend size must be 12 bytes (only uint3) or 104 bytes for D3D12 compatibility.
    Uint32  ArgsByteSize      DEFAULT_INITIALIZER(104);

#if DILIGENT_CPP_INTERFACE
    TraceRaysIndirectAttribs() noexcept {}
#endif
};
typedef struct TraceRaysIndirectAttribs TraceRaysIndirectAttribs;


static const Uint32 REMAINING_MIP_LEVELS   = ~0u;
static const Uint32 REMAINING_ARRAY_SLICES = ~0u;

/// Resource state transition barrier description
struct StateTransitionDesc
{
    /// Resource to transition.
    /// Can be ITexture, IBuffer, IBottomLevelAS, ITopLevelAS.
    struct IDeviceObject* pResource DEFAULT_INITIALIZER(nullptr);
        
    /// When transitioning a texture, first mip level of the subresource range to transition.
    Uint32 FirstMipLevel     DEFAULT_INITIALIZER(0);

    /// When transitioning a texture, number of mip levels of the subresource range to transition.
    Uint32 MipLevelsCount    DEFAULT_INITIALIZER(REMAINING_MIP_LEVELS);

    /// When transitioning a texture, first array slice of the subresource range to transition.
    Uint32 FirstArraySlice   DEFAULT_INITIALIZER(0);

    /// When transitioning a texture, number of array slices of the subresource range to transition.
    Uint32 ArraySliceCount   DEFAULT_INITIALIZER(REMAINING_ARRAY_SLICES);

    /// Resource state before transition. If this value is RESOURCE_STATE_UNKNOWN,
    /// internal resource state will be used, which must be defined in this case.
    RESOURCE_STATE OldState  DEFAULT_INITIALIZER(RESOURCE_STATE_UNKNOWN);

    /// Resource state after transition.
    RESOURCE_STATE NewState  DEFAULT_INITIALIZER(RESOURCE_STATE_UNKNOWN);

    /// State transition type, see Diligent::STATE_TRANSITION_TYPE.

    /// \note When issuing UAV barrier (i.e. OldState and NewState equal RESOURCE_STATE_UNORDERED_ACCESS),
    ///       TransitionType must be STATE_TRANSITION_TYPE_IMMEDIATE.
    STATE_TRANSITION_TYPE TransitionType DEFAULT_INITIALIZER(STATE_TRANSITION_TYPE_IMMEDIATE);

    /// If set to true, the internal resource state will be set to NewState and the engine
    /// will be able to take over the resource state management. In this case it is the 
    /// responsibility of the application to make sure that all subresources are indeed in
    /// designated state.
    /// If set to false, internal resource state will be unchanged.
    /// \note When TransitionType is STATE_TRANSITION_TYPE_BEGIN, this member must be false.
    bool UpdateResourceState  DEFAULT_INITIALIZER(false);

#if DILIGENT_CPP_INTERFACE
    StateTransitionDesc()noexcept{}

    StateTransitionDesc(ITexture*             _pTexture, 
                        RESOURCE_STATE        _OldState,
                        RESOURCE_STATE        _NewState, 
                        Uint32                _FirstMipLevel   = 0,
                        Uint32                _MipLevelsCount  = REMAINING_MIP_LEVELS,
                        Uint32                _FirstArraySlice = 0,
                        Uint32                _ArraySliceCount = REMAINING_ARRAY_SLICES,
                        STATE_TRANSITION_TYPE _TransitionType  = STATE_TRANSITION_TYPE_IMMEDIATE,
                        bool                  _UpdateState     = false)noexcept : 
        pResource           {static_cast<IDeviceObject*>(_pTexture)},
        FirstMipLevel       {_FirstMipLevel  },
        MipLevelsCount      {_MipLevelsCount },
        FirstArraySlice     {_FirstArraySlice},
        ArraySliceCount     {_ArraySliceCount},
        OldState            {_OldState       },
        NewState            {_NewState       },
        TransitionType      {_TransitionType },
        UpdateResourceState {_UpdateState    }
    {}

    StateTransitionDesc(ITexture*      _pTexture, 
                        RESOURCE_STATE _OldState,
                        RESOURCE_STATE _NewState, 
                        bool           _UpdateState)noexcept :
        StateTransitionDesc
        {
            _pTexture,
            _OldState,
            _NewState,
            0,
            REMAINING_MIP_LEVELS,
            0,
            REMAINING_ARRAY_SLICES,
            STATE_TRANSITION_TYPE_IMMEDIATE,
            _UpdateState
        }
    {}

    StateTransitionDesc(IBuffer*       _pBuffer, 
                        RESOURCE_STATE _OldState,
                        RESOURCE_STATE _NewState,
                        bool           _UpdateState)noexcept : 
        pResource           {_pBuffer    },
        OldState            {_OldState   },
        NewState            {_NewState   },
        UpdateResourceState {_UpdateState}
    {}
    
    StateTransitionDesc(IBottomLevelAS* _pBLAS, 
                        RESOURCE_STATE  _OldState,
                        RESOURCE_STATE  _NewState,
                        bool            _UpdateState)noexcept : 
        pResource           {_pBLAS      },
        OldState            {_OldState   },
        NewState            {_NewState   },
        UpdateResourceState {_UpdateState}
    {}

    StateTransitionDesc(ITopLevelAS*     _pTLAS, 
                        RESOURCE_STATE  _OldState,
                        RESOURCE_STATE  _NewState,
                        bool            _UpdateState)noexcept : 
        pResource           {_pTLAS      },
        OldState            {_OldState   },
        NewState            {_NewState   },
        UpdateResourceState {_UpdateState}
    {}
#endif
};
typedef struct StateTransitionDesc StateTransitionDesc;


#define DILIGENT_INTERFACE_NAME IDeviceContext
#include "../../../Primitives/interface/DefineInterfaceHelperMacros.h"

#define IDeviceContextInclusiveMethods  \
    IObjectInclusiveMethods;            \
    IDeviceContextMethods DeviceContext

/// Device context interface.

/// \remarks Device context keeps strong references to all objects currently bound to 
///          the pipeline: buffers, states, samplers, shaders, etc.
///          The context also keeps strong reference to the device and
///          the swap chain.
DILIGENT_BEGIN_INTERFACE(IDeviceContext, IObject)
{
    /// Sets the pipeline state.

    /// \param [in] pPipelineState - Pointer to IPipelineState interface to bind to the context.
    VIRTUAL void METHOD(SetPipelineState)(THIS_
                                          IPipelineState* pPipelineState) PURE;


    /// Transitions shader resources to the states required by Draw or Dispatch command.
    ///
    /// \param [in] pPipelineState         - Pipeline state object that was used to create the shader resource binding.
    /// \param [in] pShaderResourceBinding - Shader resource binding whose resources will be transitioned.
    ///
    /// \remarks This method explicitly transitiones all resources except ones in unknown state to the states required 
    ///          by Draw or Dispatch command.
    ///          If this method was called, there is no need to use Diligent::RESOURCE_STATE_TRANSITION_MODE_TRANSITION
    ///          when calling IDeviceContext::CommitShaderResources()
    ///
    /// \remarks Resource state transitioning is not thread safe. As the method may alter the states 
    ///          of resources referenced by the shader resource binding, no other thread is allowed to read or 
    ///          write these states.
    ///
    ///          If the application intends to use the same resources in other threads simultaneously, it needs to 
    ///          explicitly manage the states using IDeviceContext::TransitionResourceStates() method.
    ///          Refer to http://diligentgraphics.com/2018/12/09/resource-state-management/ for detailed explanation
    ///          of resource state management in Diligent Engine.
    VIRTUAL void METHOD(TransitionShaderResources)(THIS_ 
                                                   IPipelineState*         pPipelineState, 
                                                   IShaderResourceBinding* pShaderResourceBinding) PURE;

    /// Commits shader resources to the device context.

    /// \param [in] pShaderResourceBinding - Shader resource binding whose resources will be committed.
    ///                                      If pipeline state contains no shader resources, this parameter
    ///                                      can be null.
    /// \param [in] StateTransitionMode    - State transition mode (see Diligent::RESOURCE_STATE_TRANSITION_MODE).
    ///
    /// \remarks Pipeline state object that was used to create the shader resource binding must be bound 
    ///          to the pipeline when CommitShaderResources() is called. If no pipeline state object is bound
    ///          or the pipeline state object does not match the shader resource binding, the method will fail.\n
    ///          If Diligent::RESOURCE_STATE_TRANSITION_MODE_TRANSITION mode is used,
    ///          the engine will also transition all shader resources to required states. If the flag
    ///          is not set, it is assumed that all resources are already in correct states.\n
    ///          Resources can be explicitly transitioned to required states by calling 
    ///          IDeviceContext::TransitionShaderResources() or IDeviceContext::TransitionResourceStates().\n
    ///
    /// \remarks Automatic resource state transitioning is not thread-safe.
    ///
    ///          - If Diligent::RESOURCE_STATE_TRANSITION_MODE_TRANSITION mode is used, the method may alter the states 
    ///            of resources referenced by the shader resource binding and no other thread is allowed to read or write these states.
    ///
    ///          - If Diligent::RESOURCE_STATE_TRANSITION_MODE_VERIFY mode is used, the method will read the states, so no other thread
    ///            should alter the states by calling any of the methods that use Diligent::RESOURCE_STATE_TRANSITION_MODE_TRANSITION mode.
    ///            It is safe for other threads to read the states.
    ///
    ///          - If Diligent::RESOURCE_STATE_TRANSITION_MODE_NONE mode is used, the method does not access the states of resources.
    ///
    ///          If the application intends to use the same resources in other threads simultaneously, it should manage the states
    ///          manually by setting the state to Diligent::RESOURCE_STATE_UNKNOWN (which will disable automatic state 
    ///          management) using IBuffer::SetState() or ITexture::SetState() and explicitly transitioning the states with 
    ///          IDeviceContext::TransitionResourceStates().
    ///          Refer to http://diligentgraphics.com/2018/12/09/resource-state-management/ for detailed explanation
    ///          of resource state management in Diligent Engine.
    ///
    ///          If an application calls any method that changes the state of any resource after it has been committed, the
    ///          application is responsible for transitioning the resource back to correct state using one of the available methods
    ///          before issuing the next draw or dispatch command.
    VIRTUAL void METHOD(CommitShaderResources)(THIS_
                                               IShaderResourceBinding*        pShaderResourceBinding,
                                               RESOURCE_STATE_TRANSITION_MODE StateTransitionMode) PURE;

    /// Sets the stencil reference value.

    /// \param [in] StencilRef - Stencil reference value.
    VIRTUAL void METHOD(SetStencilRef)(THIS_
                                       Uint32 StencilRef) PURE;

    
    /// \param [in] pBlendFactors - Array of four blend factors, one for each RGBA component. 
    ///                             Theses factors are used if the blend state uses one of the 
    ///                             Diligent::BLEND_FACTOR_BLEND_FACTOR or 
    ///                             Diligent::BLEND_FACTOR_INV_BLEND_FACTOR 
    ///                             blend factors. If nullptr is provided,
    ///                             default blend factors array {1,1,1,1} will be used.
    VIRTUAL void METHOD(SetBlendFactors)(THIS_
                                         const float* pBlendFactors DEFAULT_VALUE(nullptr)) PURE;


    /// Binds vertex buffers to the pipeline.

    /// \param [in] StartSlot           - The first input slot for binding. The first vertex buffer is 
    ///                                   explicitly bound to the start slot; each additional vertex buffer 
    ///                                   in the array is implicitly bound to each subsequent input slot. 
    /// \param [in] NumBuffersSet       - The number of vertex buffers in the array.
    /// \param [in] ppBuffers           - A pointer to an array of vertex buffers. 
    ///                                   The buffers must have been created with the Diligent::BIND_VERTEX_BUFFER flag.
    /// \param [in] pOffsets            - Pointer to an array of offset values; one offset value for each buffer 
    ///                                   in the vertex-buffer array. Each offset is the number of bytes between 
    ///                                   the first element of a vertex buffer and the first element that will be 
    ///                                   used. If this parameter is nullptr, zero offsets for all buffers will be used.
    /// \param [in] StateTransitionMode - State transition mode for buffers being set (see Diligent::RESOURCE_STATE_TRANSITION_MODE).
    /// \param [in] Flags               - Additional flags. See Diligent::SET_VERTEX_BUFFERS_FLAGS for a list of allowed values.
    ///                                   
    /// \remarks The device context keeps strong references to all bound vertex buffers.
    ///          Thus a buffer cannot be released until it is unbound from the context.\n
    ///          It is suggested to specify Diligent::SET_VERTEX_BUFFERS_FLAG_RESET flag
    ///          whenever possible. This will assure that no buffers from previous draw calls
    ///          are bound to the pipeline.
    ///
    /// \remarks When StateTransitionMode is Diligent::RESOURCE_STATE_TRANSITION_MODE_TRANSITION, the method will 
    ///          transition all buffers in known states to Diligent::RESOURCE_STATE_VERTEX_BUFFER. Resource state 
    ///          transitioning is not thread safe, so no other thread is allowed to read or write the states of 
    ///          these buffers.
    ///
    ///          If the application intends to use the same resources in other threads simultaneously, it needs to 
    ///          explicitly manage the states using IDeviceContext::TransitionResourceStates() method.
    ///          Refer to http://diligentgraphics.com/2018/12/09/resource-state-management/ for detailed explanation
    ///          of resource state management in Diligent Engine.
    VIRTUAL void METHOD(SetVertexBuffers)(THIS_
                                          Uint32                         StartSlot, 
                                          Uint32                         NumBuffersSet, 
                                          IBuffer**                      ppBuffers, 
                                          Uint32*                        pOffsets,
                                          RESOURCE_STATE_TRANSITION_MODE StateTransitionMode,
                                          SET_VERTEX_BUFFERS_FLAGS       Flags) PURE;


    /// Invalidates the cached context state.

    /// This method should be called by an application to invalidate 
    /// internal cached states.
    VIRTUAL void METHOD(InvalidateState)(THIS) PURE;


    /// Binds an index buffer to the pipeline.
    
    /// \param [in] pIndexBuffer        - Pointer to the index buffer. The buffer must have been created 
    ///                                   with the Diligent::BIND_INDEX_BUFFER flag.
    /// \param [in] ByteOffset          - Offset from the beginning of the buffer to 
    ///                                   the start of index data.
    /// \param [in] StateTransitionMode - State transiton mode for the index buffer to bind (see Diligent::RESOURCE_STATE_TRANSITION_MODE).
    ///
    /// \remarks The device context keeps strong reference to the index buffer.
    ///          Thus an index buffer object cannot be released until it is unbound 
    ///          from the context.
    ///
    /// \remarks When StateTransitionMode is Diligent::RESOURCE_STATE_TRANSITION_MODE_TRANSITION, the method will 
    ///          transition the buffer to Diligent::RESOURCE_STATE_INDEX_BUFFER (if its state is not unknown). Resource 
    ///          state transitioning is not thread safe, so no other thread is allowed to read or write the state of 
    ///          the buffer.
    ///
    ///          If the application intends to use the same resource in other threads simultaneously, it needs to 
    ///          explicitly manage the states using IDeviceContext::TransitionResourceStates() method.
    ///          Refer to http://diligentgraphics.com/2018/12/09/resource-state-management/ for detailed explanation
    ///          of resource state management in Diligent Engine.
    VIRTUAL void METHOD(SetIndexBuffer)(THIS_
                                        IBuffer*                       pIndexBuffer,
                                        Uint32                         ByteOffset,
                                        RESOURCE_STATE_TRANSITION_MODE StateTransitionMode) PURE;


    /// Sets an array of viewports.

    /// \param [in] NumViewports - Number of viewports to set.
    /// \param [in] pViewports   - An array of Viewport structures describing the viewports to bind.
    /// \param [in] RTWidth      - Render target width. If 0 is provided, width of the currently bound render target will be used.
    /// \param [in] RTHeight     - Render target height. If 0 is provided, height of the currently bound render target will be used.
    ///
    /// \remarks
    /// DirectX and OpenGL use different window coordinate systems. In DirectX, the coordinate system origin
    /// is in the left top corner of the screen with Y axis pointing down. In OpenGL, the origin
    /// is in the left bottom corener of the screen with Y axis pointing up. Render target size is 
    /// required to convert viewport from DirectX to OpenGL coordinate system if OpenGL device is used.\n\n
    /// All viewports must be set atomically as one operation. Any viewports not 
    /// defined by the call are disabled.\n\n
    /// You can set the viewport size to match the currently bound render target using the
    /// following call:
    ///
    ///     pContext->SetViewports(1, nullptr, 0, 0);
    VIRTUAL void METHOD(SetViewports)(THIS_
                                      Uint32          NumViewports,
                                      const Viewport* pViewports, 
                                      Uint32          RTWidth, 
                                      Uint32          RTHeight) PURE;


    /// Sets active scissor rects.

    /// \param [in] NumRects - Number of scissor rectangles to set.
    /// \param [in] pRects   - An array of Rect structures describing the scissor rectangles to bind.
    /// \param [in] RTWidth  - Render target width. If 0 is provided, width of the currently bound render target will be used.
    /// \param [in] RTHeight - Render target height. If 0 is provided, height of the currently bound render target will be used.
    ///
    /// \remarks
    /// DirectX and OpenGL use different window coordinate systems. In DirectX, the coordinate system origin
    /// is in the left top corner of the screen with Y axis pointing down. In OpenGL, the origin
    /// is in the left bottom corener of the screen with Y axis pointing up. Render target size is 
    /// required to convert viewport from DirectX to OpenGL coordinate system if OpenGL device is used.\n\n
    /// All scissor rects must be set atomically as one operation. Any rects not 
    /// defined by the call are disabled.
    VIRTUAL void METHOD(SetScissorRects)(THIS_
                                         Uint32      NumRects,
                                         const Rect* pRects,
                                         Uint32      RTWidth,
                                         Uint32      RTHeight) PURE;


    /// Binds one or more render targets and the depth-stencil buffer to the context. It also
    /// sets the viewport to match the first non-null render target or depth-stencil buffer.

    /// \param [in] NumRenderTargets    - Number of render targets to bind.
    /// \param [in] ppRenderTargets     - Array of pointers to ITextureView that represent the render 
    ///                                   targets to bind to the device. The type of each view in the 
    ///                                   array must be Diligent::TEXTURE_VIEW_RENDER_TARGET.
    /// \param [in] pDepthStencil       - Pointer to the ITextureView that represents the depth stencil to 
    ///                                   bind to the device. The view type must be
    ///                                   Diligent::TEXTURE_VIEW_DEPTH_STENCIL.
    /// \param [in] StateTransitionMode - State transition mode of the render targets and depth stencil buffer being set (see Diligent::RESOURCE_STATE_TRANSITION_MODE).
    /// 
    /// \remarks     The device context will keep strong references to all bound render target 
    ///              and depth-stencil views. Thus these views (and consequently referenced textures) 
    ///              cannot be released until they are unbound from the context.\n
    ///              Any render targets not defined by this call are set to nullptr.\n\n
    ///
    /// \remarks When StateTransitionMode is Diligent::RESOURCE_STATE_TRANSITION_MODE_TRANSITION, the method will 
    ///          transition all render targets in known states to Diligent::RESOURCE_STATE_REDER_TARGET,
    ///          and the depth-stencil buffer to Diligent::RESOURCE_STATE_DEPTH_WRITE state.
    ///          Resource state transitioning is not thread safe, so no other thread is allowed to read or write 
    ///          the states of resources used by the command.
    ///
    ///          If the application intends to use the same resource in other threads simultaneously, it needs to 
    ///          explicitly manage the states using IDeviceContext::TransitionResourceStates() method.
    ///          Refer to http://diligentgraphics.com/2018/12/09/resource-state-management/ for detailed explanation
    ///          of resource state management in Diligent Engine.
    VIRTUAL void METHOD(SetRenderTargets)(THIS_
                                          Uint32                         NumRenderTargets,
                                          ITextureView*                  ppRenderTargets[],
                                          ITextureView*                  pDepthStencil,
                                          RESOURCE_STATE_TRANSITION_MODE StateTransitionMode) PURE;


    /// Begins a new render pass.

    /// \param [in] Attribs - The command attributes, see Diligent::BeginRenderPassAttribs for details.
    VIRTUAL void METHOD(BeginRenderPass)(THIS_
                                         const BeginRenderPassAttribs REF Attribs) PURE;
    

    /// Transitions to the next subpass in the render pass instance.
    VIRTUAL void METHOD(NextSubpass)(THIS) PURE;


    /// Ends current render pass.
    VIRTUAL void METHOD(EndRenderPass)(THIS) PURE;


    /// Executes a draw command.

    /// \param [in] Attribs - Draw command attributes, see Diligent::DrawAttribs for details.
    ///
    /// \remarks  If Diligent::DRAW_FLAG_VERIFY_STATES flag is set, the method reads the state of vertex
    ///           buffers, so no other threads are allowed to alter the states of the same resources.
    ///           It is OK to read these states.
    ///          
    ///           If the application intends to use the same resources in other threads simultaneously, it needs to 
    ///           explicitly manage the states using IDeviceContext::TransitionResourceStates() method.
    VIRTUAL void METHOD(Draw)(THIS_
                              const DrawAttribs REF Attribs) PURE;


    /// Executes an indexed draw command.

    /// \param [in] Attribs - Draw command attributes, see Diligent::DrawIndexedAttribs for details.
    ///
    /// \remarks  If Diligent::DRAW_FLAG_VERIFY_STATES flag is set, the method reads the state of vertex/index
    ///           buffers, so no other threads are allowed to alter the states of the same resources.
    ///           It is OK to read these states.
    ///          
    ///           If the application intends to use the same resources in other threads simultaneously, it needs to 
    ///           explicitly manage the states using IDeviceContext::TransitionResourceStates() method.
    VIRTUAL void METHOD(DrawIndexed)(THIS_
                                     const DrawIndexedAttribs REF Attribs) PURE;


    /// Executes an indirect draw command.

    /// \param [in] Attribs        - Structure describing the command attributes, see Diligent::DrawIndirectAttribs for details.
    /// \param [in] pAttribsBuffer - Pointer to the buffer, from which indirect draw attributes will be read.
    ///                              The buffer must contain the following arguments at the specified offset:
    ///                                  Uint32 NumVertices;
    ///                                  Uint32 NumInstances;
    ///                                  Uint32 StartVertexLocation;
    ///                                  Uint32 FirstInstanceLocation;
    ///
    /// \remarks  If IndirectAttribsBufferStateTransitionMode member is Diligent::RESOURCE_STATE_TRANSITION_MODE_TRANSITION,
    ///           the method may transition the state of the indirect draw arguments buffer. This is not a thread safe operation, 
    ///           so no other thread is allowed to read or write the state of the buffer.
    ///
    ///           If Diligent::DRAW_FLAG_VERIFY_STATES flag is set, the method reads the state of vertex/index
    ///           buffers, so no other threads are allowed to alter the states of the same resources.
    ///           It is OK to read these states.
    ///          
    ///           If the application intends to use the same resources in other threads simultaneously, it needs to 
    ///           explicitly manage the states using IDeviceContext::TransitionResourceStates() method.
    VIRTUAL void METHOD(DrawIndirect)(THIS_
                                      const DrawIndirectAttribs REF Attribs,
                                      IBuffer*                      pAttribsBuffer) PURE;


    /// Executes an indexed indirect draw command.

    /// \param [in] Attribs        - Structure describing the command attributes, see Diligent::DrawIndexedIndirectAttribs for details.
    /// \param [in] pAttribsBuffer - Pointer to the buffer, from which indirect draw attributes will be read.
    ///                              The buffer must contain the following arguments at the specified offset:
    ///                                  Uint32 NumIndices;
    ///                                  Uint32 NumInstances;
    ///                                  Uint32 FirstIndexLocation;
    ///                                  Uint32 BaseVertex;
    ///                                  Uint32 FirstInstanceLocation
    ///
    /// \remarks  If IndirectAttribsBufferStateTransitionMode member is Diligent::RESOURCE_STATE_TRANSITION_MODE_TRANSITION,
    ///           the method may transition the state of the indirect draw arguments buffer. This is not a thread safe operation, 
    ///           so no other thread is allowed to read or write the state of the buffer.
    ///
    ///           If Diligent::DRAW_FLAG_VERIFY_STATES flag is set, the method reads the state of vertex/index
    ///           buffers, so no other threads are allowed to alter the states of the same resources.
    ///           It is OK to read these states.
    ///          
    ///           If the application intends to use the same resources in other threads simultaneously, it needs to 
    ///           explicitly manage the states using IDeviceContext::TransitionResourceStates() method.
    VIRTUAL void METHOD(DrawIndexedIndirect)(THIS_
                                             const DrawIndexedIndirectAttribs REF Attribs,
                                             IBuffer*                             pAttribsBuffer) PURE;
    

    /// Executes a mesh draw command.
    
    /// \param [in] Attribs - Draw command attributes, see Diligent::DrawMeshAttribs for details.
    /// 
    /// \remarks  For compatibility between Direct3D12 and Vulkan, only a single work group dimension is used.
    ///           Also in the shader, 'numthreads' and 'local_size' attributes must define only the first dimension,
    ///           for example: '[numthreads(ThreadCount, 1, 1)]' or 'layout(local_size_x = ThreadCount) in'.
    VIRTUAL void METHOD(DrawMesh)(THIS_
                                  const DrawMeshAttribs REF Attribs) PURE;
    

    /// Executes an mesh indirect draw command.
    
    /// \param [in] Attribs        - Structure describing the command attributes, see Diligent::DrawMeshIndirectAttribs for details.
    /// \param [in] pAttribsBuffer - Pointer to the buffer, from which indirect draw attributes will be read.
    ///                              The buffer must contain the following arguments at the specified offset:
    ///                                Direct3D12:
    ///                                     Uint32 ThreadGroupCountX;
    ///                                     Uint32 ThreadGroupCountY;
    ///                                     Uint32 ThreadGroupCountZ;
    ///                                Vulkan:
    ///                                     Uint32 TaskCount;
    ///                                     Uint32 FirstTask;
    /// 
    /// \remarks  For compatibility between Direct3D12 and Vulkan and with direct call (DrawMesh) use the first element in the structure,
    ///           for example: Direct3D12 {TaskCount, 1, 1}, Vulkan {TaskCount, 0}.
    /// 
    /// \remarks  If IndirectAttribsBufferStateTransitionMode member is Diligent::RESOURCE_STATE_TRANSITION_MODE_TRANSITION,
    ///           the method may transition the state of the indirect draw arguments buffer. This is not a thread safe operation, 
    ///           so no other thread is allowed to read or write the state of the buffer.
    /// 
    ///           If the application intends to use the same resources in other threads simultaneously, it needs to 
    ///           explicitly manage the states using IDeviceContext::TransitionResourceStates() method.
    VIRTUAL void METHOD(DrawMeshIndirect)(THIS_
                                          const DrawMeshIndirectAttribs REF Attribs,
                                          IBuffer*                          pAttribsBuffer) PURE;


    /// Executes an mesh indirect draw command with indirect command count buffer.

    /// \param [in] Attribs        - Structure describing the command attributes, see Diligent::DrawMeshIndirectCountAttribs for details.
    /// \param [in] pAttribsBuffer - Pointer to the buffer, from which indirect draw attributes will be read.
    ///                              The buffer must contain the following arguments at the specified offset:
    ///                                Direct3D12:
    ///                                     Uint32 ThreadGroupCountX;
    ///                                     Uint32 ThreadGroupCountY;
    ///                                     Uint32 ThreadGroupCountZ;
    ///                                Vulkan:
    ///                                     Uint32 TaskCount;
    ///                                     Uint32 FirstTask;
    ///                              Size of the buffer must be sizeof(Uint32[3]) * Attribs.MaxDrawCommands.
    /// \param [in] pCountBuffer   - Pointer to the buffer, from which Uint32 value with draw count will be read.
    /// 
    /// \remarks  For compatibility between Direct3D12 and Vulkan and with direct call (DrawMesh) use the first element in the structure,
    ///           for example: Direct3D12 {TaskCount, 1, 1}, Vulkan {TaskCount, 0}.
    /// 
    /// \remarks  If IndirectAttribsBufferStateTransitionMode member is Diligent::RESOURCE_STATE_TRANSITION_MODE_TRANSITION,
    ///           the method may transition the state of the indirect draw arguments buffer. This is not a thread safe operation, 
    ///           so no other thread is allowed to read or write the state of the buffer.
    /// 
    ///           If the application intends to use the same resources in other threads simultaneously, it needs to 
    ///           explicitly manage the states using IDeviceContext::TransitionResourceStates() method.
    VIRTUAL void METHOD(DrawMeshIndirectCount)(THIS_
                                               const DrawMeshIndirectCountAttribs REF Attribs,
                                               IBuffer*                               pAttribsBuffer,
                                               IBuffer*                               pCountBuffer) PURE;


    /// Executes a dispatch compute command.

    /// \param [in] Attribs - Dispatch command attributes, see Diligent::DispatchComputeAttribs for details.
    VIRTUAL void METHOD(DispatchCompute)(THIS_
                                         const DispatchComputeAttribs REF Attribs) PURE;


    /// Executes an indirect dispatch compute command.
    
    /// \param [in] Attribs        - The command attributes, see Diligent::DispatchComputeIndirectAttribs for details.
    /// \param [in] pAttribsBuffer - Pointer to the buffer containing indirect dispatch attributes.
    ///                              The buffer must contain the following arguments at the specified offset:
    ///                                 Uint32 ThreadGroupCountX;
    ///                                 Uint32 ThreadGroupCountY;
    ///                                 Uint32 ThreadGroupCountZ;
    ///
    /// \remarks  If IndirectAttribsBufferStateTransitionMode member is Diligent::RESOURCE_STATE_TRANSITION_MODE_TRANSITION,
    ///           the method may transition the state of indirect dispatch arguments buffer. This is not a thread safe operation, 
    ///           so no other thread is allowed to read or write the state of the same resource.
    ///          
    ///           If the application intends to use the same resources in other threads simultaneously, it needs to 
    ///           explicitly manage the states using IDeviceContext::TransitionResourceStates() method.
    VIRTUAL void METHOD(DispatchComputeIndirect)(THIS_
                                                 const DispatchComputeIndirectAttribs REF Attribs,
                                                 IBuffer*                                 pAttribsBuffer) PURE;


    /// Clears a depth-stencil view.
    
    /// \param [in] pView               - Pointer to ITextureView interface to clear. The view type must be 
    ///                                   Diligent::TEXTURE_VIEW_DEPTH_STENCIL.
    /// \param [in] StateTransitionMode - state transition mode of the depth-stencil buffer to clear.
    /// \param [in] ClearFlags          - Idicates which parts of the buffer to clear, see Diligent::CLEAR_DEPTH_STENCIL_FLAGS.
    /// \param [in] fDepth              - Value to clear depth part of the view with.
    /// \param [in] Stencil             - Value to clear stencil part of the view with.
    ///
    /// \remarks The full extent of the view is always cleared. Viewport and scissor settings are not applied.
    /// \note The depth-stencil view must be bound to the pipeline for clear operation to be performed.
    ///
    /// \remarks When StateTransitionMode is Diligent::RESOURCE_STATE_TRANSITION_MODE_TRANSITION, the method will 
    ///          transition the state of the texture to the state required by clear operation. 
    ///          In Direct3D12, this satate is always Diligent::RESOURCE_STATE_DEPTH_WRITE, however in Vulkan
    ///          the state depends on whether the depth buffer is bound to the pipeline.
    ///
    ///          Resource state transitioning is not thread safe, so no other thread is allowed to read or write 
    ///          the state of resources used by the command.
    ///          Refer to http://diligentgraphics.com/2018/12/09/resource-state-management/ for detailed explanation
    ///          of resource state management in Diligent Engine.
    VIRTUAL void METHOD(ClearDepthStencil)(THIS_
                                           ITextureView*                  pView,
                                           CLEAR_DEPTH_STENCIL_FLAGS      ClearFlags,
                                           float                          fDepth,
                                           Uint8                          Stencil,
                                           RESOURCE_STATE_TRANSITION_MODE StateTransitionMode) PURE;


    /// Clears a render target view

    /// \param [in] pView               - Pointer to ITextureView interface to clear. The view type must be 
    ///                                   Diligent::TEXTURE_VIEW_RENDER_TARGET.
    /// \param [in] RGBA                - A 4-component array that represents the color to fill the render target with.
    ///                                   If nullptr is provided, the default array {0,0,0,0} will be used.
    /// \param [in] StateTransitionMode - Defines required state transitions (see Diligent::RESOURCE_STATE_TRANSITION_MODE)
    ///
    /// \remarks The full extent of the view is always cleared. Viewport and scissor settings are not applied.
    ///
    ///          The render target view must be bound to the pipeline for clear operation to be performed in OpenGL backend.
    ///
    /// \remarks When StateTransitionMode is Diligent::RESOURCE_STATE_TRANSITION_MODE_TRANSITION, the method will 
    ///          transition the texture to the state required by the command. Resource state transitioning is not 
    ///          thread safe, so no other thread is allowed to read or write the states of the same textures.
    ///
    ///          If the application intends to use the same resource in other threads simultaneously, it needs to 
    ///          explicitly manage the states using IDeviceContext::TransitionResourceStates() method.
    ///
    /// \note    In D3D12 backend clearing render targets requires textures to always be transitioned to 
    ///          Diligent::RESOURCE_STATE_RENDER_TARGET state. In Vulkan backend however this depends on whether a 
    ///          render pass has been started. To clear render target outside of a render pass, the texture must be transitioned to
    ///          Diligent::RESOURCE_STATE_COPY_DEST state. Inside a render pass it must be in Diligent::RESOURCE_STATE_RENDER_TARGET
    ///          state. When using Diligent::RESOURCE_STATE_TRANSITION_TRANSITION mode, the engine takes care of proper
    ///          resource state transition, otherwise it is the responsibility of the application.
    VIRTUAL void METHOD(ClearRenderTarget)(THIS_
                                           ITextureView*                  pView,
                                           const float*                   RGBA, 
                                           RESOURCE_STATE_TRANSITION_MODE StateTransitionMode) PURE;


    /// Finishes recording commands and generates a command list.
    
    /// \param [out] ppCommandList - Memory location where pointer to the recorded command list will be written.
    VIRTUAL void METHOD(FinishCommandList)(THIS_
                                           ICommandList** ppCommandList) PURE;


    /// Submits an array of recorded command lists for execution.

    /// \param [in] NumCommandLists - The number of command lists to execute.
    /// \param [in] ppCommandLists  - Pointer to the array of NumCommandLists command lists to execute.
    /// \remarks After a command list is executed, it is no longer valid and must be released.
    VIRTUAL void METHOD(ExecuteCommandLists)(THIS_
                                             Uint32               NumCommandLists,
                                             ICommandList* const* ppCommandLists) PURE;


    /// Tells the GPU to set a fence to a specified value after all previous work has completed.

    /// \note The method does not flush the context (an application can do this explcitly if needed)
    ///       and the fence will be signaled only when the command context is flushed next time.
    ///       If an application needs to wait for the fence in a loop, it must flush the context
    ///       after signalling the fence.
    ///
    /// \param [in] pFence - The fence to signal
    /// \param [in] Value  - The value to set the fence to. This value must be greater than the
    ///                      previously signaled value on the same fence.
    VIRTUAL void METHOD(SignalFence)(THIS_
                                     IFence*    pFence,
                                     Uint64     Value) PURE;


    /// Waits until the specified fence reaches or exceeds the specified value, on the host.

    /// \note The method blocks the execution of the calling thread until the wait is complete.
    ///
    /// \param [in] pFence       - The fence to wait.
    /// \param [in] Value        - The value that the context is waiting for the fence to reach.
    /// \param [in] FlushContext - Whether to flush the commands in the context before initiating the wait.
    ///
    /// \remarks    Wait is only allowed for immediate contexts.\n
    ///             When FlushContext is true, the method flushes the context before initiating the wait 
    ///             (see IDeviceContext::Flush()), so an application must explicitly reset the PSO and 
    ///             bind all required shader resources after waiting for the fence.\n
    ///             If FlushContext is false, the commands preceding the fence (including signaling the fence itself)
    ///             may not have been submitted to the GPU and the method may never return.  If an application does 
    ///             not explicitly flush the context, it should typically set FlushContext to true.\n
    ///             If the value the context is waiting for has never been signaled, the method
    ///             may never return.\n
    ///             The fence can only be waited for from the same context it has
    ///             previously been signaled.
    VIRTUAL void METHOD(WaitForFence)(THIS_
                                      IFence*   pFence,
                                      Uint64    Value,
                                      bool      FlushContext) PURE;


    /// Submits all outstanding commands for execution to the GPU and waits until they are complete.

    /// \note The method blocks the execution of the calling thread until the wait is complete.
    ///
    /// \remarks    Only immediate contexts can be idled.\n
    ///             The methods implicitly flushes the context (see IDeviceContext::Flush()), so an 
    ///             application must explicitly reset the PSO and bind all required shader resources after 
    ///             idling the context.\n
    VIRTUAL void METHOD(WaitForIdle)(THIS) PURE;


    /// Marks the beginning of a query.

    /// \param [in] pQuery - A pointer to a query object.
    ///
    /// \remarks    Only immediate contexts can begin a query.
    ///
    ///             Vulkan requires that a query must either begin and end inside the same
    ///             subpass of a render pass instance, or must both begin and end outside of
    ///             a render pass instance. This means that an application must either begin
    ///             and end a query while preserving render targets, or begin it when no render
    ///             targets are bound to the context. In the latter case the engine will automaticaly
    ///             end the render pass, if needed, when the query is ended.
    ///             Also note that resource transitions must be performed outside of a render pass,
    ///             and may thus require ending current render pass.
    ///             To explicitly end current render pass, call
    ///             SetRenderTargets(0, nullptr, nullptr, RESOURCE_STATE_TRANSITION_MODE_NONE).
    ///
    /// \warning    OpenGL and Vulkan do not support nested queries of the same type.
    VIRTUAL void METHOD(BeginQuery)(THIS_
                                    IQuery* pQuery) PURE;


    /// Marks the end of a query.

    /// \param [in] pQuery - A pointer to a query object.
    ///
    /// \remarks    A query must be ended by the same context that began it.
    ///
    ///             In Direct3D12 and Vulkan, queries (except for timestamp queries)
    ///             cannot span command list boundaries, so the engine will never flush
    ///             the context even if the number of commands exceeds the user-specified limit
    ///             when there is an active query.
    ///             It is an error to explicitly flush the context while a query is active. 
    ///
    ///             All queries must be ended when IDeviceContext::FinishFrame() is called.
    VIRTUAL void METHOD(EndQuery)(THIS_
                                  IQuery* pQuery) PURE;


    /// Submits all pending commands in the context for execution to the command queue.

    /// \remarks    Only immediate contexts can be flushed.\n
    ///             Internally the method resets the state of the current command list/buffer.
    ///             When the next draw command is issued, the engine will restore all states 
    ///             (rebind render targets and depth-stencil buffer as well as index and vertex buffers,
    ///             restore viewports and scissor rects, etc.) except for the pipeline state and shader resource
    ///             bindings. An application must explicitly reset the PSO and bind all required shader 
    ///             resources after flushing the context.
    VIRTUAL void METHOD(Flush)(THIS) PURE;


    /// Updates the data in the buffer.

    /// \param [in] pBuffer             - Pointer to the buffer to updates.
    /// \param [in] Offset              - Offset in bytes from the beginning of the buffer to the update region.
    /// \param [in] Size                - Size in bytes of the data region to update.
    /// \param [in] pData               - Pointer to the data to write to the buffer.
    /// \param [in] StateTransitionMode - Buffer state transition mode (see Diligent::RESOURCE_STATE_TRANSITION_MODE)
    VIRTUAL void METHOD(UpdateBuffer)(THIS_
                                      IBuffer*                       pBuffer,
                                      Uint32                         Offset,
                                      Uint32                         Size,
                                      const void*                    pData,
                                      RESOURCE_STATE_TRANSITION_MODE StateTransitionMode) PURE;


    /// Copies the data from one buffer to another.

    /// \param [in] pSrcBuffer              - Source buffer to copy data from.
    /// \param [in] SrcOffset               - Offset in bytes from the beginning of the source buffer to the beginning of data to copy.
    /// \param [in] SrcBufferTransitionMode - State transition mode of the source buffer (see Diligent::RESOURCE_STATE_TRANSITION_MODE).
    /// \param [in] pDstBuffer              - Destination buffer to copy data to.
    /// \param [in] DstOffset               - Offset in bytes from the beginning of the destination buffer to the beginning 
    ///                                       of the destination region.
    /// \param [in] Size                    - Size in bytes of data to copy.
    /// \param [in] DstBufferTransitionMode - State transition mode of the destination buffer (see Diligent::RESOURCE_STATE_TRANSITION_MODE).
    VIRTUAL void METHOD(CopyBuffer)(THIS_
                                    IBuffer*                       pSrcBuffer,
                                    Uint32                         SrcOffset,
                                    RESOURCE_STATE_TRANSITION_MODE SrcBufferTransitionMode,
                                    IBuffer*                       pDstBuffer,
                                    Uint32                         DstOffset,
                                    Uint32                         Size,
                                    RESOURCE_STATE_TRANSITION_MODE DstBufferTransitionMode) PURE;


    /// Maps the buffer.

    /// \param [in] pBuffer      - Pointer to the buffer to map.
    /// \param [in] MapType      - Type of the map operation. See Diligent::MAP_TYPE.
    /// \param [in] MapFlags     - Special map flags. See Diligent::MAP_FLAGS.
    /// \param [out] pMappedData - Reference to the void pointer to store the address of the mapped region.
    VIRTUAL void METHOD(MapBuffer)(THIS_
                                   IBuffer*     pBuffer,
                                   MAP_TYPE     MapType,
                                   MAP_FLAGS    MapFlags,
                                   PVoid REF    pMappedData) PURE;


    /// Unmaps the previously mapped buffer.

    /// \param [in] pBuffer - Pointer to the buffer to unmap.
    /// \param [in] MapType - Type of the map operation. This parameter must match the type that was 
    ///                       provided to the Map() method. 
    VIRTUAL void METHOD(UnmapBuffer)(THIS_
                                     IBuffer*   pBuffer,
                                     MAP_TYPE   MapType) PURE;


    /// Updates the data in the texture.

    /// \param [in] pTexture    - Pointer to the device context interface to be used to perform the operation.
    /// \param [in] MipLevel    - Mip level of the texture subresource to update.
    /// \param [in] Slice       - Array slice. Should be 0 for non-array textures.
    /// \param [in] DstBox      - Destination region on the texture to update.
    /// \param [in] SubresData  - Source data to copy to the texture.
    /// \param [in] SrcBufferTransitionMode - If pSrcBuffer member of TextureSubResData structure is not null, this 
    ///                                       parameter defines state transition mode of the source buffer. 
    ///                                       If pSrcBuffer is null, this parameter is ignored.
    /// \param [in] TextureTransitionMode   - Texture state transition mode (see Diligent::RESOURCE_STATE_TRANSITION_MODE)
    VIRTUAL void METHOD(UpdateTexture)(THIS_
                                       ITexture*                        pTexture,
                                       Uint32                           MipLevel,
                                       Uint32                           Slice,
                                       const Box REF                    DstBox,
                                       const TextureSubResData REF      SubresData,
                                       RESOURCE_STATE_TRANSITION_MODE   SrcBufferTransitionMode,
                                       RESOURCE_STATE_TRANSITION_MODE   TextureTransitionMode) PURE;


    /// Copies data from one texture to another.

    /// \param [in] CopyAttribs - Structure describing copy command attributes, see Diligent::CopyTextureAttribs for details.
    VIRTUAL void METHOD(CopyTexture)(THIS_
                                     const CopyTextureAttribs REF CopyAttribs) PURE;


    /// Maps the texture subresource.

    /// \param [in] pTexture    - Pointer to the texture to map.
    /// \param [in] MipLevel    - Mip level to map.
    /// \param [in] ArraySlice  - Array slice to map. This parameter must be 0 for non-array textures.
    /// \param [in] MapType     - Type of the map operation. See Diligent::MAP_TYPE.
    /// \param [in] MapFlags    - Special map flags. See Diligent::MAP_FLAGS.
    /// \param [in] pMapRegion  - Texture region to map. If this parameter is null, the entire subresource is mapped.
    /// \param [out] MappedData - Mapped texture region data
    ///
    /// \remarks This method is supported in D3D11, D3D12 and Vulkan backends. In D3D11 backend, only the entire 
    ///          subresource can be mapped, so pMapRegion must either be null, or cover the entire subresource.
    ///          In D3D11 and Vulkan backends, dynamic textures are no different from non-dynamic textures, and mapping 
    ///          with MAP_FLAG_DISCARD has exactly the same behavior.
    VIRTUAL void METHOD(MapTextureSubresource)(THIS_
                                               ITexture*                    pTexture,
                                               Uint32                       MipLevel,
                                               Uint32                       ArraySlice,
                                               MAP_TYPE                     MapType,
                                               MAP_FLAGS                    MapFlags,
                                               const Box*                   pMapRegion,
                                               MappedTextureSubresource REF MappedData) PURE;


    /// Unmaps the texture subresource.
    VIRTUAL void METHOD(UnmapTextureSubresource)(THIS_
                                                 ITexture* pTexture,
                                                 Uint32    MipLevel,
                                                 Uint32    ArraySlice) PURE;

    
    /// Generates a mipmap chain.

    /// \param [in] pTextureView - Texture view to generate mip maps for.
    /// \remarks This function can only be called for a shader resource view.
    ///          The texture must be created with MISC_TEXTURE_FLAG_GENERATE_MIPS flag.
    VIRTUAL void METHOD(GenerateMips)(THIS_
                                      ITextureView* pTextureView) PURE;

    
    /// Finishes the current frame and releases dynamic resources allocated by the context.

    /// For immediate context, this method is called automatically by ISwapChain::Present() of the primary
    /// swap chain, but can also be called explicitly. For deferred contexts, the method must be called by the
    /// application to release dynamic resources. The method has some overhead, so it is better to call it once
    /// per frame, though it can be called with different frequency. Note that unless the GPU is idled,
    /// the resources may actually be released several frames after the one they were used in last time.
    /// \note After the call all dynamic resources become invalid and must be written again before the next use. 
    ///       Also, all committed resources become invalid.\n
    ///       For deferred contexts, this method must be called after all command lists referencing dynamic resources
    ///       have been executed through immediate context.\n
    ///       The method does not Flush() the context.
    VIRTUAL void METHOD(FinishFrame)(THIS) PURE;


    /// Returns the current frame number.

    /// \note The frame number is incremented every time FinishFrame() is called.
    VIRTUAL Uint64 METHOD(GetFrameNumber)(THIS) CONST PURE;


    /// Transitions resource states.

    /// \param [in] BarrierCount      - Number of barriers in pResourceBarriers array
    /// \param [in] pResourceBarriers - Pointer to the array of resource barriers
    /// \remarks When both old and new states are RESOURCE_STATE_UNORDERED_ACCESS, the engine
    ///          executes UAV barrier on the resource. The barrier makes sure that all UAV accesses 
    ///          (reads or writes) are complete before any future UAV accesses (read or write) can begin.\n
    /// 
    ///          There are two main usage scenarios for this method:
    ///          1. An application knows specifics of resource state transitions not available to the engine.
    ///             For example, only single mip level needs to be transitioned.
    ///          2. An application manages resource states in multiple threads in parallel.
    ///         
    ///          The method always reads the states of all resources to transition. If the state of a resource is managed
    ///          by multiple threads in parallel, the resource must first be transitioned to unknown state
    ///          (Diligent::RESOURCE_STATE_UNKNOWN) to disable automatic state management in the engine.
    ///          
    ///          When StateTransitionDesc::UpdateResourceState is set to true, the method may update the state of the
    ///          corresponding resource which is not thread safe. No other threads should read or write the sate of that 
    ///          resource.
    ///
    /// \note    Any method that uses Diligent::RESOURCE_STATE_TRANSITION_MODE_TRANSITION mode may alter
    ///          the state of resources it works with. Diligent::RESOURCE_STATE_TRANSITION_MODE_VERIFY mode
    ///          makes the method read the states, but not write them. When Diligent::RESOURCE_STATE_TRANSITION_MODE_NONE
    ///          is used, the method assumes the states are guaranteed to be correct and does not read or write them.
    ///          It is the responsibility of the application to make sure this is indeed true.
    ///
    ///          Refer to http://diligentgraphics.com/2018/12/09/resource-state-management/ for detailed explanation
    ///          of resource state management in Diligent Engine.
    VIRTUAL void METHOD(TransitionResourceStates)(THIS_
                                                  Uint32               BarrierCount,
                                                  StateTransitionDesc* pResourceBarriers) PURE;


    /// Resolves a multi-sampled texture subresource into a non-multi-sampled texture subresource.

    /// \param [in] pSrcTexture    - Source multi-sampled texture.
    /// \param [in] pDstTexture    - Destination non-multi-sampled texture.
    /// \param [in] ResolveAttribs - Resolve command attributes, see Diligent::ResolveTextureSubresourceAttribs for details.
    VIRTUAL void METHOD(ResolveTextureSubresource)(THIS_
                                                   ITexture*                                  pSrcTexture,
                                                   ITexture*                                  pDstTexture,
                                                   const ResolveTextureSubresourceAttribs REF ResolveAttribs) PURE;
    

    /// Builds a bottom-level acceleration structure with the specified geometries.

    /// \param [in] Attribs - Structure describing build BLAS command attributes, see Diligent::BuildBLASAttribs for details.
    /// 
    /// \note Don't call build or copy operation on the same BLAS in a different contexts, because BLAS has CPU-side data
    ///       that will not match with GPU-side, so shader binding were incorrect.
    VIRTUAL void METHOD(BuildBLAS)(THIS_
                                   const BuildBLASAttribs REF Attribs) PURE;
    

    /// Builds a top-level acceleration structure with the specified instances.

    /// \param [in] Attribs - Structure describing build TLAS command attributes, see Diligent::BuildTLASAttribs for details.
    /// 
    /// \note Don't call build or copy operation on the same TLAS in a different contexts, because TLAS has CPU-side data
    ///       that will not match with GPU-side, so shader binding were incorrect.
    VIRTUAL void METHOD(BuildTLAS)(THIS_
                                   const BuildTLASAttribs REF Attribs) PURE;
    

    /// Copies data from one acceleration structure to another.

    /// \param [in] Attribs - Structure describing copy BLAS command attributes, see Diligent::CopyBLASAttribs for details.
    /// 
    /// \note Don't call build or copy operation on the same BLAS in a different contexts, because BLAS has CPU-side data
    ///       that will not match with GPU-side, so shader binding were incorrect.
    VIRTUAL void METHOD(CopyBLAS)(THIS_
                                  const CopyBLASAttribs REF Attribs) PURE;
    

    /// Copies data from one acceleration structure to another.

    /// \param [in] Attribs - Structure describing copy TLAS command attributes, see Diligent::CopyTLASAttribs for details.
    /// 
    /// \note Don't call build or copy operation on the same TLAS in a different contexts, because TLAS has CPU-side data
    ///       that will not match with GPU-side, so shader binding were incorrect.
    VIRTUAL void METHOD(CopyTLAS)(THIS_
                                  const CopyTLASAttribs REF Attribs) PURE;
    

    /// Writes a bottom-level acceleration structure memory size required for compacting operation to a buffer.

    /// \param [in] Attribs - Structure describing write BLAS compacted size command attributes, see Diligent::WriteBLASCompactedSizeAttribs for details.
    VIRTUAL void METHOD(WriteBLASCompactedSize)(THIS_
                                                const WriteBLASCompactedSizeAttribs REF Attribs) PURE;
    

    /// Writes a top-level acceleration structure memory size required for compacting operation to a buffer.

    /// \param [in] Attribs - Structure describing write TLAS compacted size command attributes, see Diligent::WriteTLASCompactedSizeAttribs for details.
    VIRTUAL void METHOD(WriteTLASCompactedSize)(THIS_
                                                const WriteTLASCompactedSizeAttribs REF Attribs) PURE;
    

    /// Executes a trace rays command.
    
    /// \param [in] Attribs - Trace rays command attributes, see Diligent::TraceRaysAttribs for details.
    ///
    /// \remarks  The method is not thread-safe. An application must externally synchronize the access
    ///           to the shader binding table passed as an argument to the function.
    VIRTUAL void METHOD(TraceRays)(THIS_
                                   const TraceRaysAttribs REF Attribs) PURE;
    

    /// Executes an indirect trace rays command.
    ///
    /// \param [in] pAttribsBuffer - Pointer to the buffer containing indirect trace rays attributes.
    ///                              The buffer must contain the following arguments at the specified offset:
    ///                                 [88 bytes reserved] - for Direct3D12 backend
    ///                                 Uint32 DimensionX;
    ///                                 Uint32 DimensionY;
    ///                                 Uint32 DimensionZ;
    VIRTUAL void METHOD(TraceRaysIndirect)(THIS_
                                           const TraceRaysIndirectAttribs REF Attribs,
                                           IBuffer*                           pAttribsBuffer) PURE;
};
DILIGENT_END_INTERFACE

#include "../../../Primitives/interface/UndefInterfaceHelperMacros.h"

#if DILIGENT_C_INTERFACE

// clang-format off

#    define IDeviceContext_SetPipelineState(This, ...)          CALL_IFACE_METHOD(DeviceContext, SetPipelineState,          This, __VA_ARGS__)
#    define IDeviceContext_TransitionShaderResources(This, ...) CALL_IFACE_METHOD(DeviceContext, TransitionShaderResources, This, __VA_ARGS__)
#    define IDeviceContext_CommitShaderResources(This, ...)     CALL_IFACE_METHOD(DeviceContext, CommitShaderResources,     This, __VA_ARGS__)
#    define IDeviceContext_SetStencilRef(This, ...)             CALL_IFACE_METHOD(DeviceContext, SetStencilRef,             This, __VA_ARGS__)
#    define IDeviceContext_SetBlendFactors(This, ...)           CALL_IFACE_METHOD(DeviceContext, SetBlendFactors,           This, __VA_ARGS__)
#    define IDeviceContext_SetVertexBuffers(This, ...)          CALL_IFACE_METHOD(DeviceContext, SetVertexBuffers,          This, __VA_ARGS__)
#    define IDeviceContext_InvalidateState(This)                CALL_IFACE_METHOD(DeviceContext, InvalidateState,           This)
#    define IDeviceContext_SetIndexBuffer(This, ...)            CALL_IFACE_METHOD(DeviceContext, SetIndexBuffer,            This, __VA_ARGS__)
#    define IDeviceContext_SetViewports(This, ...)              CALL_IFACE_METHOD(DeviceContext, SetViewports,              This, __VA_ARGS__)
#    define IDeviceContext_SetScissorRects(This, ...)           CALL_IFACE_METHOD(DeviceContext, SetScissorRects,           This, __VA_ARGS__)
#    define IDeviceContext_SetRenderTargets(This, ...)          CALL_IFACE_METHOD(DeviceContext, SetRenderTargets,          This, __VA_ARGS__)
#    define IDeviceContext_Draw(This, ...)                      CALL_IFACE_METHOD(DeviceContext, Draw,                      This, __VA_ARGS__)
#    define IDeviceContext_DrawIndexed(This, ...)               CALL_IFACE_METHOD(DeviceContext, DrawIndexed,               This, __VA_ARGS__)
#    define IDeviceContext_DrawIndirect(This, ...)              CALL_IFACE_METHOD(DeviceContext, DrawIndirect,              This, __VA_ARGS__)
#    define IDeviceContext_DrawIndexedIndirect(This, ...)       CALL_IFACE_METHOD(DeviceContext, DrawIndexedIndirect,       This, __VA_ARGS__)
#    define IDeviceContext_DrawMesh(This, ...)                  CALL_IFACE_METHOD(DeviceContext, DrawMesh,                  This, __VA_ARGS__)
#    define IDeviceContext_DrawMeshIndirect(This, ...)          CALL_IFACE_METHOD(DeviceContext, DrawMeshIndirect,          This, __VA_ARGS__)
#    define IDeviceContext_DrawMeshIndirectCount(This, ...)     CALL_IFACE_METHOD(DeviceContext, DrawMeshIndirectCount,     This, __VA_ARGS__)
#    define IDeviceContext_DispatchCompute(This, ...)           CALL_IFACE_METHOD(DeviceContext, DispatchCompute,           This, __VA_ARGS__)
#    define IDeviceContext_DispatchComputeIndirect(This, ...)   CALL_IFACE_METHOD(DeviceContext, DispatchComputeIndirect,   This, __VA_ARGS__)
#    define IDeviceContext_ClearDepthStencil(This, ...)         CALL_IFACE_METHOD(DeviceContext, ClearDepthStencil,         This, __VA_ARGS__)
#    define IDeviceContext_ClearRenderTarget(This, ...)         CALL_IFACE_METHOD(DeviceContext, ClearRenderTarget,         This, __VA_ARGS__)
#    define IDeviceContext_FinishCommandList(This, ...)         CALL_IFACE_METHOD(DeviceContext, FinishCommandList,         This, __VA_ARGS__)
#    define IDeviceContext_ExecuteCommandLists(This, ...)       CALL_IFACE_METHOD(DeviceContext, ExecuteCommandLists,       This, __VA_ARGS__)
#    define IDeviceContext_SignalFence(This, ...)               CALL_IFACE_METHOD(DeviceContext, SignalFence,               This, __VA_ARGS__)
#    define IDeviceContext_WaitForFence(This, ...)              CALL_IFACE_METHOD(DeviceContext, WaitForFence,              This, __VA_ARGS__)
#    define IDeviceContext_WaitForIdle(This, ...)               CALL_IFACE_METHOD(DeviceContext, WaitForIdle,               This, __VA_ARGS__)
#    define IDeviceContext_BeginQuery(This, ...)                CALL_IFACE_METHOD(DeviceContext, BeginQuery,                This, __VA_ARGS__)
#    define IDeviceContext_EndQuery(This, ...)                  CALL_IFACE_METHOD(DeviceContext, EndQuery,                  This, __VA_ARGS__)
#    define IDeviceContext_Flush(This, ...)                     CALL_IFACE_METHOD(DeviceContext, Flush,                     This, __VA_ARGS__)
#    define IDeviceContext_UpdateBuffer(This, ...)              CALL_IFACE_METHOD(DeviceContext, UpdateBuffer,              This, __VA_ARGS__)
#    define IDeviceContext_CopyBuffer(This, ...)                CALL_IFACE_METHOD(DeviceContext, CopyBuffer,                This, __VA_ARGS__)
#    define IDeviceContext_MapBuffer(This, ...)                 CALL_IFACE_METHOD(DeviceContext, MapBuffer,                 This, __VA_ARGS__)
#    define IDeviceContext_UnmapBuffer(This, ...)               CALL_IFACE_METHOD(DeviceContext, UnmapBuffer,               This, __VA_ARGS__)
#    define IDeviceContext_UpdateTexture(This, ...)             CALL_IFACE_METHOD(DeviceContext, UpdateTexture,             This, __VA_ARGS__)
#    define IDeviceContext_CopyTexture(This, ...)               CALL_IFACE_METHOD(DeviceContext, CopyTexture,               This, __VA_ARGS__)
#    define IDeviceContext_MapTextureSubresource(This, ...)     CALL_IFACE_METHOD(DeviceContext, MapTextureSubresource,     This, __VA_ARGS__)
#    define IDeviceContext_UnmapTextureSubresource(This, ...)   CALL_IFACE_METHOD(DeviceContext, UnmapTextureSubresource,   This, __VA_ARGS__)
#    define IDeviceContext_GenerateMips(This, ...)              CALL_IFACE_METHOD(DeviceContext, GenerateMips,              This, __VA_ARGS__)
#    define IDeviceContext_FinishFrame(This)                    CALL_IFACE_METHOD(DeviceContext, FinishFrame,               This)
#    define IDeviceContext_GetFrameNumber(This)                 CALL_IFACE_METHOD(DeviceContext, GetFrameNumber,            This)
#    define IDeviceContext_TransitionResourceStates(This, ...)  CALL_IFACE_METHOD(DeviceContext, TransitionResourceStates,  This, __VA_ARGS__)
#    define IDeviceContext_ResolveTextureSubresource(This, ...) CALL_IFACE_METHOD(DeviceContext, ResolveTextureSubresource, This, __VA_ARGS__)
#    define IDeviceContext_BuildBLAS(This, ...)                 CALL_IFACE_METHOD(DeviceContext, BuildBLAS,                 This, __VA_ARGS__)
#    define IDeviceContext_BuildTLAS(This, ...)                 CALL_IFACE_METHOD(DeviceContext, BuildTLAS,                 This, __VA_ARGS__)
#    define IDeviceContext_CopyBLAS(This, ...)                  CALL_IFACE_METHOD(DeviceContext, CopyBLAS,                  This, __VA_ARGS__)
#    define IDeviceContext_CopyTLAS(This, ...)                  CALL_IFACE_METHOD(DeviceContext, CopyTLAS,                  This, __VA_ARGS__)
#    define IDeviceContext_WriteBLASCompactedSize(This, ...)    CALL_IFACE_METHOD(DeviceContext, WriteBLASCompactedSize,    This, __VA_ARGS__)
#    define IDeviceContext_WriteTLASCompactedSize(This, ...)    CALL_IFACE_METHOD(DeviceContext, WriteTLASCompactedSize,    This, __VA_ARGS__)
#    define IDeviceContext_TraceRays(This, ...)                 CALL_IFACE_METHOD(DeviceContext, TraceRays,                 This, __VA_ARGS__)
#    define IDeviceContext_TraceRaysIndirect(This, ...)         CALL_IFACE_METHOD(DeviceContext, TraceRaysIndirect,         This, __VA_ARGS__)

// clang-format on

#endif

DILIGENT_END_NAMESPACE // namespace Diligent