LiteFX 0.4.1.2025
Computer Graphics Engine
Loading...
Searching...
No Matches
rendering_api.hpp
1#pragma once
2
3#include <litefx/config.h>
4
5#if !defined (LITEFX_RENDERING_API)
6# if defined(LiteFX_Rendering_EXPORTS) && (defined _WIN32 || defined WINCE)
7# define LITEFX_RENDERING_API __declspec(dllexport)
8# elif (defined(LiteFX_Rendering_EXPORTS) || defined(__APPLE__)) && defined __GNUC__ && __GNUC__ >= 4
9# define LITEFX_RENDERING_API __attribute__ ((visibility ("default")))
10# elif !defined(LiteFX_Rendering_EXPORTS) && (defined _WIN32 || defined WINCE)
11# define LITEFX_RENDERING_API __declspec(dllimport)
12# endif
13#endif
14
15#ifndef LITEFX_RENDERING_API
16# define LITEFX_RENDERING_API
17#endif
18
19#include <litefx/app.hpp>
20#include <litefx/math.hpp>
21
22namespace LiteFX::Rendering {
23 using namespace LiteFX;
24 using namespace LiteFX::Math;
25
26 class IGraphicsAdapter;
27 class ISurface;
28 class IShaderModule;
29 class IRenderTarget;
30 class IRasterizer;
31 class IViewport;
32 class IScissor;
33 class IBufferLayout;
37 class IMappable;
38 class IDeviceMemory;
39 class IBuffer;
40 class IImage;
41 class ISampler;
45 class IBarrier;
46 class IDescriptorSet;
50 class IShaderProgram;
51 class IPipelineLayout;
52 class IVertexBuffer;
53 class IIndexBuffer;
54 class IInputAssembler;
55 class IPipeline;
56 class ICommandBuffer;
57 class IRenderPipeline;
58 class IComputePipeline;
60 class IFrameBuffer;
61 class IRenderPass;
62 class ISwapChain;
63 class ICommandQueue;
64 class IGraphicsFactory;
65 class IGraphicsDevice;
66 class IRenderBackend;
67
68#pragma region "Enumerations"
69
70 // NOLINTBEGIN(performance-enum-size)
71
79 None = 0x00000000,
80
84 GPU = 0x00000001,
85
89 CPU = 0x00000002,
90
94 Other = 0x7FFFFFFF,
95 };
96
113 enum class QueueType : UInt32 {
117 None = 0x00000000,
118
122 Graphics = 0x00000001,
123
127 Compute = 0x00000002,
128
132 Transfer = 0x00000004,
133
140 VideoDecode = 0x00000010,
141
148 VideoEncode = 0x00000020,
149
153 Other = 0x7FFFFFFF
154 };
155
159 enum class QueuePriority {
163 Normal = 33,
164
168 High = 66,
169
176 Realtime = 100
177 };
178
182 enum class Format {
183 None = 0x00000000,
192 R8_UNORM,
193 R8_SNORM,
196 R8_UINT,
197 R8_SINT,
198 R8_SRGB,
203 R8G8_UINT,
204 R8G8_SINT,
205 R8G8_SRGB,
253 R16_UNORM,
254 R16_SNORM,
257 R16_UINT,
258 R16_SINT,
281 R32_UINT,
282 R32_SINT,
293 R64_UINT,
294 R64_SINT,
307 D16_UNORM,
310 S8_UINT,
318 BC2_UNORM,
319 BC2_SRGB,
320 BC3_UNORM,
321 BC3_SRGB,
322 BC4_UNORM,
323 BC4_SNORM,
324 BC5_UNORM,
325 BC5_SNORM,
328 BC7_UNORM,
329 BC7_SRGB,
330 Other = 0x7FFFFFFF
331 };
332
339 enum class BufferFormat : UInt32 {
340 None = 0x00000000,
341 X16F = 0x10000101,
342 X16I = 0x10000201,
343 X16U = 0x10000401,
344 XY16F = 0x10000102,
345 XY16I = 0x10000202,
346 XY16U = 0x10000402,
347 XYZ16F = 0x10000103,
348 XYZ16I = 0x10000203,
349 XYZ16U = 0x10000403,
350 XYZW16F = 0x10000104,
351 XYZW16I = 0x10000204,
352 XYZW16U = 0x10000404,
353 X32F = 0x20000101,
354 X32I = 0x20000201,
355 X32U = 0x20000401,
356 XY32F = 0x20000102,
357 XY32I = 0x20000202,
358 XY32U = 0x20000402,
359 XYZ32F = 0x20000103,
360 XYZ32I = 0x20000203,
361 XYZ32U = 0x20000403,
362 XYZW32F = 0x20000104,
363 XYZW32I = 0x20000204,
364 XYZW32U = 0x20000404
365 };
366
375 Binormal = 0x00000001,
376
380 BlendIndices = 0x00000002,
381
385 BlendWeight = 0x00000003,
386
390 Color = 0x00000004,
391
395 Normal = 0x00000005,
396
400 Position = 0x00000006,
401
405 TransformedPosition = 0x00000007,
406
410 PointSize = 0x00000008,
411
415 Tangent = 0x00000009,
416
420 TextureCoordinate = 0x0000000A,
421
425 Unknown = 0x7FFFFFFF
426 };
427
436 enum class DescriptorType {
443 ConstantBuffer = 0x00000001,
444
455 StructuredBuffer = 0x00000002,
456
466 RWStructuredBuffer = 0x00000012,
467
478 Texture = 0x00000003,
479
486 RWTexture = 0x00000013,
487
491 Sampler = 0x00000004,
492
496 InputAttachment = 0x00000005,
497
504 Buffer = 0x00000006,
505
512 RWBuffer = 0x00000016,
513
520 ByteAddressBuffer = 0x00000007,
521
528 RWByteAddressBuffer = 0x00000017,
529
533 AccelerationStructure = 0x00000008
534 };
535
540 enum class BufferType {
544 Vertex = 0x00000001,
545
549 Index = 0x00000002,
550
557 Uniform = 0x00000003,
558
565 Storage = 0x00000004,
566
573 Texel = 0x00000005,
574
581 AccelerationStructure = 0x00000006,
582
586 ShaderBindingTable = 0x00000007,
587
605 Indirect = 0x00000008,
613 Other = 0x7FFFFFFF
614 };
649 enum class ResourceHeap {
658 Staging = 0x00000001,
659
667 Resource = 0x00000002,
668
676 Dynamic = 0x00000010,
677
681 Readback = 0x00000100
682 };
683
690 enum class ResourceUsage {
694 None = 0x0000,
695
703 AllowWrite = 0x0001,
704
711 TransferSource = 0x0010,
712
719 TransferDestination = 0x0020,
720
724 RenderTarget = 0x0040,
725
734
739
745 };
746
750 enum class IndexType : UInt32 {
754 UInt16 = 0x00000010,
755
759 UInt32 = 0x00000020
760 };
761
765 enum class PrimitiveTopology {
769 PointList = 0x00010001,
770
775 LineList = 0x00020001,
776
781 TriangleList = 0x00040001,
782
787 LineStrip = 0x00020002,
788
793 TriangleStrip = 0x00040002
794 };
795
799 enum class ShaderStage : UInt32 {
803 Vertex = 0x00000001,
804
808 TessellationControl = 0x00000002,
809
813 TessellationEvaluation = 0x00000004,
814
821 Geometry = 0x00000008,
822
826 Fragment = 0x00000010,
827
831 Compute = 0x00000020,
832
836 Task = 0x00000040,
837
841 Mesh = 0x00000080,
842
846 RayGeneration = 0x00000100,
847
851 AnyHit = 0x00000200,
852
856 ClosestHit = 0x00000400,
857
861 Miss = 0x00000800,
862
866 Intersection = 0x00001000,
867
871 Callable = 0x00002000,
872
877
882
887
892
896 Other = 0x7FFFFFFF
897 };
898
903 enum class ShaderRecordType {
907 RayGeneration = 0x01,
908
912 HitGroup = 0x02,
913
917 Intersection = 0x03,
918
922 Miss = 0x04,
923
927 Callable = 0x05,
928
932 Invalid = 0x7FFFFFFF
933 };
934
943 RayGeneration = 0x01,
944
948 HitGroup = 0x02,
949
953 Miss = 0x04,
954
958 Callable = 0x08,
959
964 };
965
970 enum class PolygonMode {
974 Solid = 0x00000001,
975
979 Wireframe = 0x00000002,
980
984 Point = 0x00000004
985 };
986
991 enum class CullMode {
995 FrontFaces = 0x00000001,
996
1000 BackFaces = 0x00000002,
1001
1005 Both = 0x00000004,
1006
1010 Disabled = 0x0000000F
1011 };
1012
1018 enum class CullOrder {
1022 ClockWise = 0x00000001,
1023
1027 CounterClockWise = 0x00000002
1028 };
1029
1033 enum class RenderTargetType {
1037 Color = 0x00000001,
1038
1042 DepthStencil = 0x00000002,
1043
1050 Present = 0x00000004
1051 };
1052
1060 None = 0x00,
1061
1065 Clear = 0x01,
1066
1070 ClearStencil = 0x02,
1071
1079 Volatile = 0x04
1080 };
1081
1086 enum class ImageDimensions {
1090 DIM_1 = 0x01,
1091
1095 DIM_2 = 0x02,
1096
1100 DIM_3 = 0x03,
1101
1105 CUBE = 0x04
1106 };
1107
1115 x1 = 0x00000001,
1116
1120 x2 = 0x00000002,
1121
1125 x4 = 0x00000004,
1126
1130 x8 = 0x00000008,
1131
1135 x16 = 0x00000010,
1136
1140 x32 = 0x00000020,
1141
1145 x64 = 0x00000040
1146 };
1147
1152 enum class FilterMode {
1156 Nearest = 0x00000001,
1157
1161 Linear = 0x00000002
1162 };
1163
1169 enum class MipMapMode {
1173 Nearest = 0x00000001,
1174
1178 Linear = 0x00000002
1179 };
1180
1184 enum class BorderMode {
1188 Repeat = 0x00000001,
1189
1193 RepeatMirrored = 0x00010001,
1194
1198 ClampToEdge = 0x00000002,
1199
1203 ClampToEdgeMirrored = 0x00010002,
1204
1208 ClampToBorder = 0x00000003,
1209 };
1210
1215 enum class CompareOperation {
1219 Never = 0x00000000,
1220
1224 Less = 0x00000001,
1225
1229 Greater = 0x0000002,
1230
1234 Equal = 0x00000003,
1235
1239 LessEqual = 0x00000004,
1240
1244 GreaterEqual = 0x00000005,
1245
1249 NotEqual = 0x00000006,
1250
1254 Always = 0x00000007
1255 };
1261 enum class StencilOperation {
1265 Keep = 0x00000000,
1266
1270 Zero = 0x00000001,
1271
1275 Replace = 0x00000002,
1276
1280 IncrementClamp = 0x00000003,
1281
1285 DecrementClamp = 0x00000004,
1286
1290 Invert = 0x00000005,
1291
1295 IncrementWrap = 0x00000006,
1296
1300 DecrementWrap = 0x00000007
1301 };
1302
1307 enum class BlendFactor {
1308 Zero = 0,
1309 One = 1,
1310 SourceColor = 2,
1312 DestinationColor = 4,
1314 SourceAlpha = 6,
1316 DestinationAlpha = 8,
1318 ConstantColor = 10,
1320 ConstantAlpha = 12,
1323 Source1Color = 15,
1325 Source1Alpha = 17,
1327 };
1328
1333 enum class WriteMask {
1337 R = 0x01,
1338
1342 G = 0x02,
1343
1347 B = 0x04,
1348
1352 A = 0x08
1353 };
1354
1359 enum class BlendOperation {
1360 Add = 0x01,
1361 Subtract = 0x02,
1362 ReverseSubtract = 0x03,
1363 Minimum = 0x04,
1364 Maximum = 0x05
1365 };
1366
1373 enum class PipelineStage {
1382 None = 0x00000000,
1383
1392 All = 0x00000001,
1393
1402 Draw = 0x00000002,
1403
1410 InputAssembly = 0x00000004,
1411
1418 Vertex = 0x00000006,
1419
1426 TessellationControl = 0x00000008,
1427
1434 TessellationEvaluation = 0x00000010,
1435
1442 Geometry = 0x00000020,
1443
1450 Fragment = 0x00000040,
1451
1458 DepthStencil = 0x00000080,
1459
1466 Indirect = 0x00000100,
1467
1474 RenderTarget = 0x00000200,
1475
1484 Compute = 0x00000400,
1485
1492 Transfer = 0x00000800,
1493
1500 Resolve = 0x00001000,
1501
1509 AccelerationStructureBuild = 0x00010000,
1510
1518 AccelerationStructureCopy = 0x00020000,
1519
1526 Raytracing = 0x00040000,
1527 };
1528
1537 enum class ResourceAccess {
1546 None = 0x7FFFFFFF,
1547
1554 VertexBuffer = 0x00000001,
1555
1562 IndexBuffer = 0x00000002,
1563
1570 UniformBuffer = 0x00000004,
1571
1578 RenderTarget = 0x00000008,
1579
1586 DepthStencilRead = 0x00000010,
1587
1594 DepthStencilWrite = 0x00000020,
1595
1602 ShaderRead = 0x00000040,
1603
1610 ShaderReadWrite = 0x00000080,
1611
1618 Indirect = 0x00000100,
1619
1626 TransferRead = 0x00000200,
1627
1634 TransferWrite = 0x00000400,
1635
1642 ResolveRead = 0x00000800,
1643
1650 ResolveWrite = 0x00001000,
1651
1660 Common = 0x00002000,
1661
1668 AccelerationStructureRead = 0x00010000,
1669
1676 AccelerationStructureWrite = 0x00020000,
1677 };
1678
1686 enum class ImageLayout {
1693 Common = 0x00000001,
1694
1701 ShaderResource = 0x00000002,
1702
1709 ReadWrite = 0x00000003,
1710
1717 CopySource = 0x00000010,
1718
1725 CopyDestination = 0x00000011,
1726
1733 RenderTarget = 0x00000020,
1734
1741 DepthRead = 0x00000021,
1742
1749 DepthWrite = 0x00000022,
1750
1759 Present = 0x00000023,
1760
1767 ResolveSource = 0x00000024,
1768
1775 ResolveDestination = 0x00000025,
1776
1787 Undefined = 0x7FFFFFFF
1788 };
1789
1794 enum class GeometryFlags {
1798 None = 0x00,
1799
1803 Opaque = 0x01,
1804
1808 OneShotAnyHit = 0x02
1809 };
1810
1820 None = 0x0000,
1821
1825 AllowUpdate = 0x0001,
1826
1830 AllowCompaction = 0x0002,
1831
1838 PreferFastTrace = 0x0004,
1839
1846 PreferFastBuild = 0x0008,
1847
1851 MinimizeMemory = 0x0010
1852 };
1853
1857 enum class InstanceFlags {
1861 None = 0x00,
1862
1866 DisableCull = 0x01,
1867
1871 FlipWinding = 0x02,
1872
1880 ForceOpaque = 0x04,
1881
1889 ForceNonOpaque = 0x08
1890 };
1891
1892 // NOLINTEND(performance-enum-size)
1893
1894#pragma endregion
1895
1896#pragma region "Flags"
1897
1898 LITEFX_DEFINE_FLAGS(QueueType);
1899 LITEFX_DEFINE_FLAGS(ShaderStage);
1900 LITEFX_DEFINE_FLAGS(PipelineStage);
1901 LITEFX_DEFINE_FLAGS(ResourceAccess);
1902 LITEFX_DEFINE_FLAGS(BufferFormat);
1903 LITEFX_DEFINE_FLAGS(WriteMask);
1904 LITEFX_DEFINE_FLAGS(RenderTargetFlags);
1905 LITEFX_DEFINE_FLAGS(GeometryFlags);
1906 LITEFX_DEFINE_FLAGS(ResourceUsage);
1907 LITEFX_DEFINE_FLAGS(AccelerationStructureFlags);
1908 LITEFX_DEFINE_FLAGS(InstanceFlags);
1909 LITEFX_DEFINE_FLAGS(ShaderBindingGroup);
1910
1911#pragma endregion
1912
1913#pragma region "Helper Functions"
1914
1920 return static_cast<UInt32>(format) & 0x000000FF; // NOLINT(cppcoreguidelines-avoid-magic-numbers)
1921 }
1922
1928 return (static_cast<UInt32>(format) & 0xFF000000) >> 24; // NOLINT(cppcoreguidelines-avoid-magic-numbers)
1929 }
1930
1936 return (static_cast<UInt32>(format) & 0x0000FF00) >> 8; // NOLINT(cppcoreguidelines-avoid-magic-numbers)
1937 }
1938
1942 constexpr size_t getSize(Format format) {
1943 switch (format) {
1944 using enum Format;
1945 case None:
1946 return 0; // NOLINT(cppcoreguidelines-avoid-magic-numbers)
1947 case R4G4_UNORM:
1948 case R8_UNORM:
1949 case R8_SNORM:
1950 case R8_USCALED:
1951 case R8_SSCALED:
1952 case R8_UINT:
1953 case R8_SINT:
1954 case R8_SRGB:
1955 case S8_UINT:
1956 return 1; // NOLINT(cppcoreguidelines-avoid-magic-numbers)
1957 case R4G4B4A4_UNORM:
1958 case B4G4R4A4_UNORM:
1959 case R5G6B5_UNORM:
1960 case B5G6R5_UNORM:
1961 case R5G5B5A1_UNORM:
1962 case B5G5R5A1_UNORM:
1963 case A1R5G5B5_UNORM:
1964 case R8G8_UNORM:
1965 case R8G8_SNORM:
1966 case R8G8_USCALED:
1967 case R8G8_SSCALED:
1968 case R8G8_UINT:
1969 case R8G8_SINT:
1970 case R8G8_SRGB:
1971 case R16_UNORM:
1972 case R16_SNORM:
1973 case R16_USCALED:
1974 case R16_SSCALED:
1975 case R16_UINT:
1976 case R16_SINT:
1977 case R16_SFLOAT:
1978 case D16_UNORM:
1979 return 2; // NOLINT(cppcoreguidelines-avoid-magic-numbers)
1980 case R8G8B8_UNORM:
1981 case R8G8B8_SNORM:
1982 case R8G8B8_USCALED:
1983 case R8G8B8_SSCALED:
1984 case R8G8B8_UINT:
1985 case R8G8B8_SINT:
1986 case R8G8B8_SRGB:
1987 case B8G8R8_UNORM:
1988 case B8G8R8_SNORM:
1989 case B8G8R8_USCALED:
1990 case B8G8R8_SSCALED:
1991 case B8G8R8_UINT:
1992 case B8G8R8_SINT:
1993 case B8G8R8_SRGB:
1994 case D16_UNORM_S8_UINT:
1995 return 3; // NOLINT(cppcoreguidelines-avoid-magic-numbers)
1996 case R8G8B8A8_UNORM:
1997 case R8G8B8A8_SNORM:
1998 case R8G8B8A8_USCALED:
1999 case R8G8B8A8_SSCALED:
2000 case R8G8B8A8_UINT:
2001 case R8G8B8A8_SINT:
2002 case R8G8B8A8_SRGB:
2003 case B8G8R8A8_UNORM:
2004 case B8G8R8A8_SNORM:
2005 case B8G8R8A8_USCALED:
2006 case B8G8R8A8_SSCALED:
2007 case B8G8R8A8_UINT:
2008 case B8G8R8A8_SINT:
2009 case B8G8R8A8_SRGB:
2010 case A8B8G8R8_UNORM:
2011 case A8B8G8R8_SNORM:
2012 case A8B8G8R8_USCALED:
2013 case A8B8G8R8_SSCALED:
2014 case A8B8G8R8_UINT:
2015 case A8B8G8R8_SINT:
2016 case A8B8G8R8_SRGB:
2017 case A2R10G10B10_UNORM:
2018 case A2R10G10B10_SNORM:
2021 case A2R10G10B10_UINT:
2022 case A2R10G10B10_SINT:
2023 case A2B10G10R10_UNORM:
2024 case A2B10G10R10_SNORM:
2027 case A2B10G10R10_UINT:
2028 case A2B10G10R10_SINT:
2029 case R16G16_UNORM:
2030 case R16G16_SNORM:
2031 case R16G16_USCALED:
2032 case R16G16_SSCALED:
2033 case R16G16_UINT:
2034 case R16G16_SINT:
2035 case R16G16_SFLOAT:
2036 case R32_UINT:
2037 case R32_SINT:
2038 case R32_SFLOAT:
2039 case B10G11R11_UFLOAT:
2040 case E5B9G9R9_UFLOAT:
2041 case X8_D24_UNORM:
2042 case D32_SFLOAT:
2043 case D24_UNORM_S8_UINT:
2044 return 4; // NOLINT(cppcoreguidelines-avoid-magic-numbers)
2045 case R16G16B16_UNORM:
2046 case R16G16B16_SNORM:
2047 case R16G16B16_USCALED:
2048 case R16G16B16_SSCALED:
2049 case R16G16B16_UINT:
2050 case R16G16B16_SINT:
2051 case R16G16B16_SFLOAT:
2052 return 6; // NOLINT(cppcoreguidelines-avoid-magic-numbers)
2053 case R16G16B16A16_UNORM:
2054 case R16G16B16A16_SNORM:
2057 case R16G16B16A16_UINT:
2058 case R16G16B16A16_SINT:
2060 case R32G32_UINT:
2061 case R32G32_SINT:
2062 case R32G32_SFLOAT:
2063 case R64_UINT:
2064 case R64_SINT:
2065 case R64_SFLOAT:
2066 case D32_SFLOAT_S8_UINT: // NOTE: This may be wrong here - spec states, however, that 24 bits are unused.
2067 case BC1_RGB_UNORM:
2068 case BC1_RGB_SRGB:
2069 case BC1_RGBA_UNORM:
2070 case BC1_RGBA_SRGB:
2071 case BC4_UNORM:
2072 case BC4_SNORM:
2073 return 8; // NOLINT(cppcoreguidelines-avoid-magic-numbers)
2074 case R32G32B32_UINT:
2075 case R32G32B32_SINT:
2076 case R32G32B32_SFLOAT:
2077 return 12; // NOLINT(cppcoreguidelines-avoid-magic-numbers)
2078 case R32G32B32A32_UINT:
2079 case R32G32B32A32_SINT:
2081 case R64G64_UINT:
2082 case R64G64_SINT:
2083 case R64G64_SFLOAT:
2084 case BC2_UNORM:
2085 case BC2_SRGB:
2086 case BC3_UNORM:
2087 case BC3_SRGB:
2088 case BC5_UNORM:
2089 case BC5_SNORM:
2090 case BC6H_UFLOAT:
2091 case BC6H_SFLOAT:
2092 case BC7_UNORM:
2093 case BC7_SRGB:
2094 return 16; // NOLINT(cppcoreguidelines-avoid-magic-numbers)
2095 case R64G64B64_UINT:
2096 case R64G64B64_SINT:
2097 case R64G64B64_SFLOAT:
2098 return 24; // NOLINT(cppcoreguidelines-avoid-magic-numbers)
2099 case R64G64B64A64_UINT:
2100 case R64G64B64A64_SINT:
2102 return 32; // NOLINT(cppcoreguidelines-avoid-magic-numbers)
2103 default:
2104 throw InvalidArgumentException("format", "Unsupported format: {0}.", std::to_underlying(format)); // An invalid format will not have a formatter anyway, but it also would be illegal to use it here.
2105 }
2106 }
2107
2112 constexpr bool hasDepth(Format format) noexcept {
2113 constexpr std::array<Format, 6> depthFormats {
2120 };
2121
2122 return std::any_of(std::begin(depthFormats), std::end(depthFormats), [&](Format f) { return f == format; });
2123 }
2124
2129 constexpr bool hasStencil(Format format) noexcept {
2130 constexpr std::array<Format, 4> stencilFormats {
2135 };
2136
2137 return std::any_of(std::begin(stencilFormats), std::end(stencilFormats), [&](Format f) { return f == format; });
2138 }
2139
2140#pragma endregion
2141
2142#pragma region "Data Types"
2143
2149 struct LITEFX_RENDERING_API alignas(16) IndirectBatch { // NOLINT(cppcoreguidelines-avoid-magic-numbers)
2154 UInt32 VertexCount{ };
2155
2160 UInt32 InstanceCount{ };
2161
2166 UInt32 FirstVertex{ };
2167
2172 UInt32 FirstInstance{ };
2173 };
2174
2175#pragma warning(push)
2176#pragma warning(disable: 4324) // Structure was padded due to alignment specifier
2182 struct LITEFX_RENDERING_API alignas(16) IndirectIndexedBatch { // NOLINT(cppcoreguidelines-avoid-magic-numbers)
2187 UInt32 IndexCount{ };
2188
2193 UInt32 InstanceCount{ };
2194
2199 UInt32 FirstIndex{ };
2200
2204 Int32 VertexOffset{ };
2205
2210 UInt32 FirstInstance{ };
2211 };
2212
2218 struct LITEFX_RENDERING_API alignas(16) IndirectDispatchBatch { // NOLINT(cppcoreguidelines-avoid-magic-numbers)
2222 UInt32 X{ 1 };
2223
2227 UInt32 Y{ 1 };
2228
2232 UInt32 Z{ 1 };
2233 };
2234#pragma warning(pop)
2235#pragma endregion
2236
2240 class LITEFX_RENDERING_API IStateResource {
2241 protected:
2242 IStateResource() noexcept = default;
2244 IStateResource(IStateResource&&) noexcept = default;
2245 IStateResource& operator=(const IStateResource&) = delete;
2246 IStateResource& operator=(IStateResource&&) noexcept = default;
2247
2248 public:
2252 virtual ~IStateResource() noexcept = default;
2253
2254 public:
2259 virtual const String& name() const noexcept = 0;
2260 };
2261
2265 class LITEFX_RENDERING_API StateResource : public virtual IStateResource {
2266 LITEFX_IMPLEMENTATION(StateResourceImpl);
2267
2268 protected:
2272 StateResource();
2273
2278 explicit StateResource(StringView name);
2279
2281 StateResource& operator=(StateResource&&) noexcept;
2282
2284 StateResource& operator=(const StateResource&) = delete;
2285
2286 public:
2290 ~StateResource() noexcept override;
2291
2292 protected:
2294 String& name() noexcept;
2295
2296 public:
2298 const String& name() const noexcept override;
2299 };
2300
2312 class LITEFX_RENDERING_API DeviceState {
2313 LITEFX_IMPLEMENTATION(DeviceStateImpl);
2314 friend class IGraphicsDevice;
2315
2316 public:
2320 explicit DeviceState();
2321
2326 DeviceState(DeviceState&& _other) noexcept;
2327
2333 DeviceState& operator=(DeviceState&& _other) noexcept;
2334
2338 virtual ~DeviceState() noexcept;
2339
2340 DeviceState(const DeviceState&) = delete;
2341 DeviceState& operator=(const DeviceState&) = delete;
2342
2343 public:
2347 void clear();
2348
2354 void add(SharedPtr<IRenderPass>&& renderPass);
2355
2362 void add(const String& id, SharedPtr<IRenderPass>&& renderPass);
2363
2369 void add(SharedPtr<IFrameBuffer>&& frameBuffer);
2370
2377 void add(const String& id, SharedPtr<IFrameBuffer>&& frameBuffer);
2378
2384 void add(UniquePtr<IPipeline>&& pipeline);
2385
2392 void add(const String& id, UniquePtr<IPipeline>&& pipeline);
2393
2399 void add(SharedPtr<IBuffer>&& buffer);
2400
2407 void add(const String& id, SharedPtr<IBuffer>&& buffer);
2408
2414 void add(SharedPtr<IVertexBuffer>&& vertexBuffer);
2415
2422 void add(const String& id, SharedPtr<IVertexBuffer>&& vertexBuffer);
2423
2429 void add(SharedPtr<IIndexBuffer>&& indexBuffer);
2430
2437 void add(const String& id, SharedPtr<IIndexBuffer>&& indexBuffer);
2438
2444 void add(SharedPtr<IImage>&& image);
2445
2452 void add(const String& id, SharedPtr<IImage>&& image);
2453
2459 void add(SharedPtr<ISampler>&& sampler);
2460
2467 void add(const String& id, SharedPtr<ISampler>&& sampler);
2468
2474 void add(UniquePtr<IAccelerationStructure>&& accelerationStructure);
2475
2482 void add(const String& id, UniquePtr<IAccelerationStructure>&& accelerationStructure);
2483
2490 void add(const String& id, UniquePtr<IDescriptorSet>&& descriptorSet);
2491
2498 IRenderPass& renderPass(const String& id) const;
2499
2506 IFrameBuffer& frameBuffer(const String& id) const;
2507
2514 IPipeline& pipeline(const String& id) const;
2515
2522 IBuffer& buffer(const String& id) const;
2523
2530 IVertexBuffer& vertexBuffer(const String& id) const;
2531
2538 IIndexBuffer& indexBuffer(const String& id) const;
2539
2546 IImage& image(const String& id) const;
2547
2554 ISampler& sampler(const String& id) const;
2555
2562 IAccelerationStructure& accelerationStructure(const String& id) const;
2563
2570 IDescriptorSet& descriptorSet(const String& id) const;
2571
2582 bool release(const IRenderPass& renderPass);
2583
2589 bool release(const IFrameBuffer& frameBuffer);
2590
2596 bool release(const IPipeline& pipeline);
2597
2603 bool release(const IBuffer& buffer);
2604
2610 bool release(const IVertexBuffer& buffer);
2611
2617 bool release(const IIndexBuffer& buffer);
2618
2624 bool release(const IImage& image);
2625
2631 bool release(const ISampler& sampler);
2632
2638 bool release(const IDescriptorSet& descriptorSet);
2639 };
2640
2648 class LITEFX_RENDERING_API IGraphicsAdapter : public SharedObject {
2649 protected:
2650 IGraphicsAdapter() noexcept = default;
2652 IGraphicsAdapter(IGraphicsAdapter&&) noexcept = default;
2653 IGraphicsAdapter& operator=(const IGraphicsAdapter&) = default;
2654 IGraphicsAdapter& operator=(IGraphicsAdapter&&) noexcept = default;
2655
2656 public:
2657 ~IGraphicsAdapter() noexcept override= default;
2658
2659 public:
2664 virtual String name() const = 0;
2665
2670 virtual UInt64 uniqueId() const noexcept = 0;
2671
2676 virtual UInt32 vendorId() const noexcept = 0;
2677
2682 virtual UInt32 deviceId() const noexcept = 0;
2683
2688 virtual GraphicsAdapterType type() const noexcept = 0;
2689
2698 virtual UInt64 driverVersion() const noexcept = 0;
2699
2704 virtual UInt32 apiVersion() const noexcept = 0;
2705
2710 virtual UInt64 dedicatedMemory() const noexcept = 0;
2711 };
2712
2720 class LITEFX_RENDERING_API ISurface {
2721 protected:
2722 ISurface() noexcept = default;
2723 ISurface(const ISurface&) = default;
2724 ISurface(ISurface&&) noexcept = default;
2725 ISurface& operator=(const ISurface&) = default;
2726 ISurface& operator=(ISurface&&) noexcept = default;
2727
2728 public:
2729 virtual ~ISurface() noexcept = default;
2730 };
2731
2735 struct LITEFX_RENDERING_API DescriptorBindingPoint final {
2736 public:
2740 UInt32 Register { 0 };
2741
2745 UInt32 Space { 0 };
2746 };
2747
2755 class LITEFX_RENDERING_API IShaderModule {
2756 protected:
2757 IShaderModule() noexcept = default;
2758 IShaderModule(const IShaderModule&) = default;
2759 IShaderModule(IShaderModule&&) noexcept = default;
2760 IShaderModule& operator=(const IShaderModule&) = default;
2761 IShaderModule& operator=(IShaderModule&&) noexcept = default;
2762
2763 public:
2764 virtual ~IShaderModule() noexcept = default;
2765
2766 public:
2771 virtual ShaderStage type() const noexcept = 0;
2772
2777 virtual const String& fileName() const noexcept = 0;
2778
2783 virtual const String& entryPoint() const noexcept = 0;
2784
2803 virtual const Optional<DescriptorBindingPoint>& shaderLocalDescriptor() const noexcept = 0;
2804 };
2805
2819 class LITEFX_RENDERING_API IRenderTarget {
2820 public:
2824 struct BlendState {
2825 public:
2829 bool Enable{ false };
2830
2834 BlendFactor SourceColor{ BlendFactor::One };
2835
2839 BlendFactor DestinationColor{ BlendFactor::Zero };
2840
2844 BlendFactor SourceAlpha{ BlendFactor::One };
2845
2849 BlendFactor DestinationAlpha{ BlendFactor::Zero };
2850
2854 BlendOperation ColorOperation{ BlendOperation::Add };
2855
2859 BlendOperation AlphaOperation{ BlendOperation::Add };
2860
2864 WriteMask ChannelWriteMask{ WriteMask::R | WriteMask::G | WriteMask::B | WriteMask::A };
2865 };
2866
2867 protected:
2868 IRenderTarget() noexcept = default;
2869 IRenderTarget(const IRenderTarget&) = default;
2870 IRenderTarget(IRenderTarget&&) noexcept = default;
2871 IRenderTarget& operator=(const IRenderTarget&) = default;
2872 IRenderTarget& operator=(IRenderTarget&&) noexcept = default;
2873
2874 public:
2875 virtual ~IRenderTarget() noexcept = default;
2876
2877 public:
2882 virtual UInt64 identifier() const noexcept = 0;
2883
2888 virtual const String& name() const noexcept = 0;
2889
2898 virtual UInt32 location() const noexcept = 0;
2899
2904 virtual RenderTargetType type() const noexcept = 0;
2905
2910 virtual Format format() const noexcept = 0;
2911
2916 virtual RenderTargetFlags flags() const noexcept = 0;
2917
2927 virtual bool clearBuffer() const noexcept = 0;
2928
2938 virtual bool clearStencil() const noexcept = 0;
2939
2949 virtual const Vector4f& clearValues() const noexcept = 0;
2950
2963 virtual bool isVolatile() const noexcept = 0;
2964
2969 virtual const BlendState& blendState() const noexcept = 0;
2970 };
2971
2976 class LITEFX_RENDERING_API RenderTarget : public IRenderTarget {
2977 LITEFX_IMPLEMENTATION(RenderTargetImpl);
2978
2979 public:
2990 explicit RenderTarget(UInt64 uid, UInt32 location, RenderTargetType type, Format format, RenderTargetFlags flags = RenderTargetFlags::None, const Vector4f& clearValues = { 0.f , 0.f, 0.f, 0.f }, const BlendState& blendState = {});
2991
3005 explicit RenderTarget(StringView name, UInt32 location, RenderTargetType type, Format format, RenderTargetFlags flags = RenderTargetFlags::None, const Vector4f& clearValues = { 0.f , 0.f, 0.f, 0.f }, const BlendState& blendState = {});
3006
3012
3017 RenderTarget(RenderTarget&& _other) noexcept;
3018
3025
3032
3036 ~RenderTarget() noexcept override;
3037
3038 public:
3040 UInt64 identifier() const noexcept override;
3041
3043 const String& name() const noexcept override;
3044
3046 UInt32 location() const noexcept override;
3047
3049 RenderTargetType type() const noexcept override;
3050
3052 Format format() const noexcept override;
3053
3055 RenderTargetFlags flags() const noexcept override;
3056
3058 bool clearBuffer() const noexcept override;
3059
3061 bool clearStencil() const noexcept override;
3062
3064 const Vector4f& clearValues() const noexcept override;
3065
3067 bool isVolatile() const noexcept override;
3068
3070 const BlendState& blendState() const noexcept override;
3071 };
3072
3076 class LITEFX_RENDERING_API RenderPassDependency {
3077 LITEFX_IMPLEMENTATION(RenderPassDependencyImpl);
3078
3079 public:
3085 RenderPassDependency(const RenderTarget& renderTarget, const DescriptorBindingPoint& descriptorBinding) noexcept;
3086
3093 RenderPassDependency(const RenderTarget& renderTarget, UInt32 bindingRegister, UInt32 space) noexcept;
3094
3100
3106
3113
3120
3125
3126 public:
3131 const RenderTarget& renderTarget() const noexcept;
3132
3137 const DescriptorBindingPoint& binding() const noexcept;
3138 };
3139
3143 class LITEFX_RENDERING_API DepthStencilState final {
3144 LITEFX_IMPLEMENTATION(DepthStencilStateImpl);
3145
3146 public:
3150 struct DepthState {
3151 public:
3155 bool Enable{ true };
3156
3160 bool Write{ true };
3161
3165 CompareOperation Operation{ CompareOperation::Always };
3166 };
3167
3177 struct DepthBias {
3178 public:
3182 bool Enable{ false };
3183
3187 Float Clamp{ 0.f };
3188
3192 Float SlopeFactor{ 0.f };
3193
3197 Float ConstantFactor{ 0.f };
3198 };
3199
3204 public:
3208 StencilOperation StencilFailOp{ StencilOperation::Keep };
3209
3213 StencilOperation StencilPassOp{ StencilOperation::Replace };
3214
3218 StencilOperation DepthFailOp{ StencilOperation::Keep };
3219
3223 CompareOperation Operation{ CompareOperation::Never };
3224 };
3225
3230 public:
3234 bool Enable{ false };
3235
3239 Byte WriteMask{ 0xFF }; // NOLINT(cppcoreguidelines-avoid-magic-numbers)
3240
3244 Byte ReadMask{ 0xFF }; // NOLINT(cppcoreguidelines-avoid-magic-numbers)
3245
3249 StencilTest FrontFace{};
3250
3254 StencilTest BackFace{};
3255 };
3256
3257 public:
3264 explicit DepthStencilState(const DepthState& depthState, const DepthBias& depthBias, const StencilState& stencilState) noexcept;
3265
3270
3275
3280
3286
3291 DepthStencilState& operator=(DepthStencilState&&) noexcept;
3292
3296 virtual ~DepthStencilState() noexcept;
3297
3298 public:
3303 virtual DepthState& depthState() const noexcept;
3304
3309 virtual DepthBias& depthBias() const noexcept;
3310
3315 virtual StencilState& stencilState() const noexcept;
3316 };
3317
3321 class LITEFX_RENDERING_API IRasterizer : public SharedObject {
3322 protected:
3323 IRasterizer() noexcept = default;
3324 IRasterizer(const IRasterizer&) = default;
3325 IRasterizer(IRasterizer&&) noexcept = default;
3326 IRasterizer& operator=(const IRasterizer&) = default;
3327 IRasterizer& operator=(IRasterizer&&) noexcept = default;
3328
3329 public:
3330 ~IRasterizer() noexcept override = default;
3331
3332 public:
3337 virtual PolygonMode polygonMode() const noexcept = 0;
3338
3343 virtual CullMode cullMode() const noexcept = 0;
3344
3349 virtual CullOrder cullOrder() const noexcept = 0;
3350
3359 virtual Float lineWidth() const noexcept = 0;
3360
3365 virtual const DepthStencilState& depthStencilState() const noexcept = 0;
3366 };
3367
3371 class LITEFX_RENDERING_API Rasterizer : public IRasterizer {
3372 LITEFX_IMPLEMENTATION(RasterizerImpl);
3373
3374 protected:
3383 explicit Rasterizer(PolygonMode polygonMode, CullMode cullMode, CullOrder cullOrder, Float lineWidth = 1.f, const DepthStencilState& depthStencilState = {}) noexcept;
3384
3389 Rasterizer(const Rasterizer& _other);
3390
3395 Rasterizer(Rasterizer&& _other) noexcept;
3396
3403
3409 Rasterizer& operator=(Rasterizer&& _other) noexcept;
3410
3411 public:
3415 ~Rasterizer() noexcept override;
3416
3417 public:
3419 PolygonMode polygonMode() const noexcept override;
3420
3422 CullMode cullMode() const noexcept override;
3423
3425 CullOrder cullOrder() const noexcept override;
3426
3428 Float lineWidth() const noexcept override;
3429
3431 const DepthStencilState& depthStencilState() const noexcept override;
3432
3433 protected:
3434 virtual PolygonMode& polygonMode() noexcept;
3435 virtual CullMode& cullMode() noexcept;
3436 virtual CullOrder& cullOrder() noexcept;
3437 virtual Float& lineWidth() noexcept;
3438 virtual DepthStencilState& depthStencilState() noexcept;
3439 };
3440
3444 class LITEFX_RENDERING_API IViewport {
3445 protected:
3446 IViewport() noexcept = default;
3447 IViewport(const IViewport&) = default;
3448 IViewport(IViewport&&) noexcept = default;
3449 IViewport& operator=(const IViewport&) = default;
3450 IViewport& operator=(IViewport&&) noexcept = default;
3451
3452 public:
3453 virtual ~IViewport() noexcept = default;
3454
3455 public:
3460 virtual RectF getRectangle() const noexcept = 0;
3461
3466 virtual void setRectangle(const RectF& rectangle) noexcept = 0;
3467
3472 virtual float getMinDepth() const noexcept = 0;
3473
3478 virtual void setMinDepth(Float depth) const noexcept = 0;
3479
3484 virtual float getMaxDepth() const noexcept = 0;
3485
3490 virtual void setMaxDepth(Float depth) const noexcept = 0;
3491 };
3492
3496 class LITEFX_RENDERING_API Viewport : public IViewport {
3497 LITEFX_IMPLEMENTATION(ViewportImpl);
3498
3499 public:
3506 explicit Viewport(const RectF& clientRect = { }, Float minDepth = 0.f, Float maxDepth = 1.f) noexcept;
3507
3512 Viewport(const Viewport& _other);
3513
3518 Viewport(Viewport&& _other) noexcept;
3519
3525 Viewport& operator=(const Viewport& _other);
3526
3532 Viewport& operator=(Viewport&& _other) noexcept;
3533
3537 ~Viewport() noexcept override;
3538
3539 public:
3541 RectF getRectangle() const noexcept override;
3542
3544 void setRectangle(const RectF& rectangle) noexcept override;
3545
3547 Float getMinDepth() const noexcept override;
3548
3550 void setMinDepth(Float depth) const noexcept override;
3551
3553 Float getMaxDepth() const noexcept override;
3554
3556 void setMaxDepth(Float depth) const noexcept override;
3557 };
3558
3562 class LITEFX_RENDERING_API IScissor {
3563 protected:
3564 IScissor() noexcept = default;
3565 IScissor(IScissor&&) noexcept = default;
3566 IScissor(const IScissor&) = default;
3567 IScissor& operator=(IScissor&&) noexcept = default;
3568 IScissor& operator=(const IScissor&) = default;
3569
3570 public:
3571 virtual ~IScissor() noexcept = default;
3572
3573 public:
3578 virtual RectF getRectangle() const noexcept = 0;
3579
3584 virtual void setRectangle(const RectF& rectangle) noexcept = 0;
3585 };
3586
3590 class LITEFX_RENDERING_API Scissor final : public IScissor {
3591 LITEFX_IMPLEMENTATION(ScissorImpl);
3592
3593 public:
3598 explicit Scissor(const RectF& scissorRect = { }) noexcept;
3599
3604 Scissor(const Scissor& _other);
3605
3610 Scissor(Scissor&& _other) noexcept;
3611
3617 Scissor& operator=(const Scissor& _other);
3618
3624 Scissor& operator=(Scissor&& _other) noexcept;
3625
3629 ~Scissor() noexcept override;
3630
3631 public:
3633 RectF getRectangle() const noexcept override;
3634
3636 void setRectangle(const RectF& rectangle) noexcept override;
3637 };
3638
3646 struct LITEFX_RENDERING_API ShaderBindingTableOffsets {
3650 UInt64 RayGenerationGroupOffset { std::numeric_limits<UInt64>::max() };
3651
3655 UInt64 RayGenerationGroupSize { 0 };
3656
3660 UInt64 RayGenerationGroupStride { 0 };
3661
3665 UInt64 HitGroupOffset { std::numeric_limits<UInt64>::max() };
3666
3670 UInt64 HitGroupSize { 0 };
3671
3675 UInt64 HitGroupStride { 0 };
3676
3680 UInt64 MissGroupOffset{ std::numeric_limits<UInt64>::max() };
3681
3685 UInt64 MissGroupSize { 0 };
3686
3690 UInt64 MissGroupStride { 0 };
3691
3695 UInt64 CallableGroupOffset { std::numeric_limits<UInt64>::max() };
3696
3700 UInt64 CallableGroupSize { 0 };
3701
3705 UInt64 CallableGroupStride { 0 };
3706 };
3707
3726 class LITEFX_RENDERING_API TimingEvent final : public SharedObject {
3727 LITEFX_IMPLEMENTATION(TimingEventImpl);
3728 friend class ISwapChain;
3729 friend struct SharedObject::Allocator<TimingEvent>;
3730
3731 private:
3737 explicit TimingEvent(const ISwapChain& swapChain, StringView name = "");
3738
3739 public:
3743 ~TimingEvent() noexcept override;
3744
3745 TimingEvent(TimingEvent&&) noexcept = delete;
3746 TimingEvent(const TimingEvent&) = delete;
3747 auto operator=(TimingEvent&&) noexcept = delete;
3748 auto operator=(const TimingEvent&) = delete;
3749
3750 private:
3757 static inline auto create(const ISwapChain& swapChain, StringView name = "") {
3758 return SharedObject::create<TimingEvent>(swapChain, name);
3759 }
3760
3761 public:
3766 StringView name() const noexcept;
3767
3778 UInt64 readTimestamp() const;
3779
3786 UInt32 queryId() const;
3787 };
3788
3792 class LITEFX_RENDERING_API BufferAttribute final {
3793 LITEFX_IMPLEMENTATION(BufferAttributeImpl);
3794
3795 public:
3799 BufferAttribute() noexcept;
3800
3809 BufferAttribute(UInt32 location, UInt32 offset, BufferFormat format, AttributeSemantic semantic, UInt32 semanticIndex = 0) noexcept;
3810
3816
3822
3829
3836
3840 virtual ~BufferAttribute() noexcept;
3841
3842 public:
3850 virtual UInt32 location() const noexcept;
3851
3856 virtual BufferFormat format() const noexcept;
3857
3862 virtual UInt32 offset() const noexcept;
3863
3872 virtual AttributeSemantic semantic() const noexcept;
3873
3882 virtual UInt32 semanticIndex() const noexcept;
3883 };
3884
3891 class LITEFX_RENDERING_API IBufferLayout {
3892 protected:
3893 IBufferLayout() noexcept = default;
3894 IBufferLayout(IBufferLayout&&) noexcept = default;
3895 IBufferLayout(const IBufferLayout&) = default;
3896 IBufferLayout& operator=(IBufferLayout&&) noexcept = default;
3897 IBufferLayout& operator=(const IBufferLayout&) = default;
3898
3899 public:
3900 virtual ~IBufferLayout() noexcept = default;
3901
3902 public:
3907 virtual size_t elementSize() const noexcept = 0;
3908
3916 virtual UInt32 binding() const noexcept = 0;
3917
3922 virtual BufferType type() const noexcept = 0;
3923 };
3924
3929 class LITEFX_RENDERING_API IVertexBufferLayout : public IBufferLayout, public SharedObject {
3930 protected:
3931 IVertexBufferLayout() noexcept = default;
3934 IVertexBufferLayout& operator=(IVertexBufferLayout&&) noexcept = default;
3935 IVertexBufferLayout& operator=(const IVertexBufferLayout&) = default;
3936
3937 public:
3938 ~IVertexBufferLayout() noexcept override = default;
3939
3940 public:
3945 virtual const Array<BufferAttribute>& attributes() const = 0;
3946 };
3947
3952 class LITEFX_RENDERING_API IIndexBufferLayout : public IBufferLayout, public SharedObject {
3953 protected:
3954 IIndexBufferLayout() noexcept = default;
3957 IIndexBufferLayout& operator=(IIndexBufferLayout&&) noexcept = default;
3958 IIndexBufferLayout& operator=(const IIndexBufferLayout&) = default;
3959
3960 public:
3961 ~IIndexBufferLayout() noexcept override = default;
3962
3963 public:
3968 virtual IndexType indexType() const noexcept = 0;
3969 };
3970
3993 class LITEFX_RENDERING_API IDescriptorLayout : public IBufferLayout {
3994 protected:
3995 IDescriptorLayout() noexcept = default;
3998 IDescriptorLayout& operator=(IDescriptorLayout&&) noexcept = default;
3999 IDescriptorLayout& operator=(const IDescriptorLayout&) = default;
4000
4001 public:
4002 ~IDescriptorLayout() noexcept override = default;
4003
4004 public:
4009 virtual DescriptorType descriptorType() const noexcept = 0;
4010
4021 virtual UInt32 descriptors() const noexcept = 0;
4022
4032 virtual const ISampler* staticSampler() const noexcept = 0;
4033 };
4034
4038 class LITEFX_RENDERING_API IMappable {
4039 protected:
4040 IMappable() noexcept = default;
4041 IMappable(IMappable&&) noexcept = default;
4042 IMappable(const IMappable&) = default;
4043 IMappable& operator=(IMappable&&) noexcept = default;
4044 IMappable& operator=(const IMappable&) = default;
4045
4046 public:
4047 virtual ~IMappable() noexcept = default;
4048
4049 public:
4056 virtual void map(const void* const data, size_t size, UInt32 element = 0) = 0;
4057
4064 virtual void map(Span<const void* const> data, size_t elementSize, UInt32 firstElement = 0) = 0;
4065
4073 virtual void map(void* data, size_t size, UInt32 element = 0, bool write = true) = 0;
4074
4082 virtual void map(Span<void*> data, size_t elementSize, UInt32 firstElement = 0, bool write = true) = 0;
4083 };
4084
4088 class LITEFX_RENDERING_API IDeviceMemory {
4089 protected:
4090 IDeviceMemory() noexcept = default;
4091 IDeviceMemory(IDeviceMemory&&) noexcept = default;
4092 IDeviceMemory(const IDeviceMemory&) = default;
4093 IDeviceMemory& operator=(IDeviceMemory&&) noexcept = default;
4094 IDeviceMemory& operator=(const IDeviceMemory&) = default;
4095
4096 public:
4097 virtual ~IDeviceMemory() noexcept = default;
4098
4099 public:
4109 virtual UInt32 elements() const noexcept = 0;
4110
4124 virtual size_t size() const noexcept = 0;
4125
4135 virtual size_t elementSize() const noexcept = 0;
4136
4143 virtual size_t elementAlignment() const noexcept = 0;
4144
4154 virtual size_t alignedElementSize() const noexcept = 0;
4155
4160 virtual ResourceUsage usage() const noexcept = 0;
4161
4169 inline bool writable() const noexcept {
4170 return LITEFX_FLAG_IS_SET(this->usage(), ResourceUsage::AllowWrite);
4171 }
4172
4180 virtual UInt64 virtualAddress() const noexcept = 0;
4181 };
4182
4186 class LITEFX_RENDERING_API IBuffer : public virtual IDeviceMemory, public virtual IMappable, public virtual IStateResource, public SharedObject {
4187 protected:
4188 IBuffer() noexcept = default;
4189 IBuffer(IBuffer&&) noexcept = default;
4190 IBuffer(const IBuffer&) = delete;
4191 IBuffer& operator=(IBuffer&&) noexcept = default;
4192 IBuffer& operator=(const IBuffer&) = delete;
4193
4194 public:
4195 ~IBuffer() noexcept override = default;
4196
4197 public:
4202 virtual BufferType type() const noexcept = 0;
4203 };
4204
4208 class LITEFX_RENDERING_API IImage : public virtual IDeviceMemory, public virtual IStateResource, public SharedObject {
4209 public:
4210 using IDeviceMemory::size;
4211
4212 protected:
4213 IImage() noexcept = default;
4214 IImage(IImage&&) noexcept = default;
4215 IImage(const IImage&) = delete;
4216 IImage& operator=(IImage&&) noexcept = default;
4217 IImage& operator=(const IImage&) = delete;
4218
4219 public:
4220 ~IImage() noexcept override = default;
4221
4222 public:
4232 virtual size_t size(UInt32 level) const noexcept = 0;
4233
4243 virtual Size3d extent(UInt32 level = 0) const noexcept = 0;
4244
4249 virtual Format format() const noexcept = 0;
4250
4259 virtual ImageDimensions dimensions() const noexcept = 0;
4260
4265 virtual UInt32 levels() const noexcept = 0;
4266
4271 virtual UInt32 layers() const noexcept = 0;
4272
4281 virtual UInt32 planes() const noexcept = 0;
4282
4287 virtual MultiSamplingLevel samples() const noexcept = 0;
4288
4289 // TODO: getSampler() for combined samplers?
4290
4291 public:
4300 virtual inline UInt32 subresourceId(UInt32 level, UInt32 layer, UInt32 plane) const noexcept {
4301 return level + (layer * this->levels()) + (plane * this->levels() * this->layers());
4302 }
4303
4312 virtual inline void resolveSubresource(UInt32 subresource, UInt32& plane, UInt32& layer, UInt32& level) const noexcept {
4313 const auto levels = this->levels();
4314 const UInt32 resourcesPerPlane = levels * this->layers();
4315 plane = subresource / resourcesPerPlane;
4316 layer = (subresource % resourcesPerPlane) / levels;
4317 level = subresource % levels;
4318 }
4319 };
4320
4324 class LITEFX_RENDERING_API ISampler : public virtual IStateResource, public SharedObject {
4325 protected:
4326 ISampler() noexcept = default;
4327 ISampler(ISampler&&) noexcept = default;
4328 ISampler(const ISampler&) = delete;
4329 ISampler& operator=(ISampler&&) noexcept = default;
4330 ISampler& operator=(const ISampler&) = delete;
4331
4332 public:
4333 ~ISampler() noexcept override = default;
4334
4335 public:
4340 virtual FilterMode getMinifyingFilter() const noexcept = 0;
4341
4346 virtual FilterMode getMagnifyingFilter() const noexcept = 0;
4347
4352 virtual BorderMode getBorderModeU() const noexcept = 0;
4353
4358 virtual BorderMode getBorderModeV() const noexcept = 0;
4359
4364 virtual BorderMode getBorderModeW() const noexcept = 0;
4365
4373 virtual Float getAnisotropy() const noexcept = 0;
4374
4379 virtual MipMapMode getMipMapMode() const noexcept = 0;
4380
4385 virtual Float getMipMapBias() const noexcept = 0;
4386
4391 virtual Float getMaxLOD() const noexcept = 0;
4392
4397 virtual Float getMinLOD() const noexcept = 0;
4398 };
4399
4403 class LITEFX_RENDERING_API IVertexBuffer : public virtual IBuffer {
4404 protected:
4405 IVertexBuffer() noexcept = default;
4407 IVertexBuffer(IVertexBuffer&&) noexcept = default;
4408 IVertexBuffer& operator=(const IVertexBuffer&) = delete;
4409 IVertexBuffer& operator=(IVertexBuffer&&) noexcept = default;
4410
4411 public:
4412 ~IVertexBuffer() noexcept override = default;
4413
4414 public:
4419 virtual const IVertexBufferLayout& layout() const noexcept = 0;
4420 };
4421
4425 class LITEFX_RENDERING_API IIndexBuffer : public virtual IBuffer {
4426 protected:
4427 IIndexBuffer() noexcept = default;
4428 IIndexBuffer(const IIndexBuffer&) = delete;
4429 IIndexBuffer(IIndexBuffer&&) noexcept = default;
4430 IIndexBuffer& operator=(const IIndexBuffer&) = delete;
4431 IIndexBuffer& operator=(IIndexBuffer&&) noexcept = default;
4432
4433 public:
4434 ~IIndexBuffer() noexcept override = default;
4435
4436 public:
4441 virtual const IIndexBufferLayout& layout() const noexcept = 0;
4442 };
4443
4449 class LITEFX_RENDERING_API IAccelerationStructure : public virtual IStateResource {
4450 protected:
4451 IAccelerationStructure() noexcept = default;
4454 IAccelerationStructure& operator=(IAccelerationStructure&&) noexcept = default;
4456
4457 public:
4458 ~IAccelerationStructure() noexcept override = default;
4459
4460 public:
4465 virtual AccelerationStructureFlags flags() const noexcept = 0;
4466
4494 inline void build(const ICommandBuffer& commandBuffer, const SharedPtr<const IBuffer>& scratchBuffer = nullptr, const SharedPtr<const IBuffer>& buffer = nullptr, UInt64 offset = 0, UInt64 maxSize = 0) {
4495 this->doBuild(commandBuffer, scratchBuffer, buffer, offset, maxSize);
4496 }
4497
4530 inline void update(const ICommandBuffer& commandBuffer, const SharedPtr<const IBuffer>& scratchBuffer = nullptr, const SharedPtr<const IBuffer>& buffer = nullptr, UInt64 offset = 0, UInt64 maxSize = 0) {
4531 this->doUpdate(commandBuffer, scratchBuffer, buffer, offset, maxSize);
4532 }
4533
4540 inline SharedPtr<const IBuffer> buffer() const noexcept {
4541 return this->getBuffer();
4542 }
4543
4549 virtual UInt64 offset() const noexcept = 0;
4550
4565 virtual UInt64 size() const noexcept = 0;
4566
4567 private:
4568 virtual SharedPtr<const IBuffer> getBuffer() const noexcept = 0;
4569 virtual void doBuild(const ICommandBuffer& commandBuffer, const SharedPtr<const IBuffer>& scratchBuffer, const SharedPtr<const IBuffer>& buffer, UInt64 offset, UInt64 maxSize) = 0;
4570 virtual void doUpdate(const ICommandBuffer& commandBuffer, const SharedPtr<const IBuffer>& scratchBuffer, const SharedPtr<const IBuffer>& buffer, UInt64 offset, UInt64 maxSize) = 0;
4571 };
4572
4588 class LITEFX_RENDERING_API IBottomLevelAccelerationStructure : public virtual IAccelerationStructure {
4589 public:
4593 struct TriangleMesh final {
4594 public:
4602 TriangleMesh(const SharedPtr<const IVertexBuffer>& vertexBuffer, const SharedPtr<const IIndexBuffer>& indexBuffer = nullptr, const SharedPtr<const IBuffer>& transformBuffer = nullptr, GeometryFlags flags = GeometryFlags::None) :
4603 VertexBuffer(vertexBuffer), IndexBuffer(indexBuffer), TransformBuffer(transformBuffer), Flags(flags) {
4604 if (vertexBuffer == nullptr) [[unlikely]]
4605 throw ArgumentNotInitializedException("vertexBuffer", "The vertex buffer must be initialized.");
4606 }
4607
4612 TriangleMesh(TriangleMesh&& other) noexcept = default;
4613
4618 TriangleMesh(const TriangleMesh& other) = default;
4619
4625 TriangleMesh& operator=(TriangleMesh&& other) noexcept = default;
4626
4632 TriangleMesh& operator=(const TriangleMesh& other) = default;
4633
4637 ~TriangleMesh() noexcept = default;
4638
4639 public:
4644
4649
4656 SharedPtr<const IBuffer> TransformBuffer;
4657
4662 };
4663
4694
4695 protected:
4701
4702 public:
4703 ~IBottomLevelAccelerationStructure() noexcept override = default;
4704
4705 public:
4710 virtual const Array<TriangleMesh>& triangleMeshes() const noexcept = 0;
4711
4717 virtual void addTriangleMesh(const TriangleMesh& mesh) = 0;
4718
4727 inline void addTriangleMesh(const SharedPtr<const IVertexBuffer>& vertexBuffer, const SharedPtr<const IIndexBuffer>& indexBuffer = nullptr, const SharedPtr<const IBuffer>& transformBuffer = nullptr, GeometryFlags flags = GeometryFlags::None) {
4728 this->addTriangleMesh(TriangleMesh(vertexBuffer, indexBuffer, transformBuffer, flags));
4729 }
4730
4735 virtual const Array<BoundingBoxes>& boundingBoxes() const noexcept = 0;
4736
4742 virtual void addBoundingBox(const BoundingBoxes& aabbs) = 0;
4743
4750 inline void addBoundingBox(const SharedPtr<const IBuffer>& buffer, GeometryFlags flags = GeometryFlags::None) {
4751 this->addBoundingBox(BoundingBoxes { .Buffer = buffer, .Flags = flags });
4752 }
4753
4757 virtual void clear() noexcept = 0;
4758
4764 virtual bool remove(const TriangleMesh& mesh) noexcept = 0;
4765
4771 virtual bool remove(const BoundingBoxes& aabb) noexcept = 0;
4772
4807 inline void copy(const ICommandBuffer& commandBuffer, IBottomLevelAccelerationStructure& destination, bool compress = false, const SharedPtr<const IBuffer>& buffer = nullptr, UInt64 offset = 0, bool copyBuildInfo = true) const {
4808 this->doCopy(commandBuffer, destination, compress, buffer, offset, copyBuildInfo);
4809 }
4810
4811 public:
4818 template <typename TSelf>
4819 inline auto withTriangleMesh(this TSelf&& self, const TriangleMesh& mesh) -> TSelf&& {
4820 self.addTriangleMesh(mesh);
4821 return std::forward<TSelf>(self);
4822 }
4823
4833 template <typename TSelf>
4834 inline auto withTriangleMesh(this TSelf&& self, const SharedPtr<const IVertexBuffer>& vertexBuffer, const SharedPtr<const IIndexBuffer>& indexBuffer = nullptr, const SharedPtr<const IBuffer>& transformBuffer = nullptr, GeometryFlags flags = GeometryFlags::None) -> TSelf&& {
4835 return std::forward<TSelf>(self).withTriangleMesh(TriangleMesh(vertexBuffer, indexBuffer, transformBuffer, flags));
4836 }
4837
4844 template <typename TSelf>
4845 inline auto withBoundingBox(this TSelf&& self, const BoundingBoxes& aabb) -> TSelf&& {
4846 self.addBoundingBox(aabb);
4847 return std::forward<TSelf>(self);
4848 }
4849
4857 template <typename TSelf>
4858 inline auto withBoundingBox(this TSelf&& self, const SharedPtr<const IBuffer>& buffer, GeometryFlags flags = GeometryFlags::None) -> TSelf&& {
4859 return std::forward<TSelf>(self).withBoundingBox(BoundingBoxes { .Buffer = buffer, .Flags = flags });
4860 }
4861
4862 private:
4863 virtual void doCopy(const ICommandBuffer& commandBuffer, IBottomLevelAccelerationStructure& destination, bool compress, const SharedPtr<const IBuffer>& buffer, UInt64 offset, bool copyBuildInfo) const = 0;
4864 };
4865
4870 class LITEFX_RENDERING_API ITopLevelAccelerationStructure : public virtual IAccelerationStructure {
4871 public:
4872#pragma warning(push)
4873#pragma warning(disable: 4324) // Structure was padded due to alignment specifier
4877 struct alignas(16) Instance final { // NOLINT(cppcoreguidelines-avoid-magic-numbers)
4881 SharedPtr<const IBottomLevelAccelerationStructure> BottomLevelAccelerationStructure;
4882
4887
4891 UInt32 Id : 24 = 0;
4892
4896 Byte Mask : 8 = 0xFF;
4897
4913
4917 InstanceFlags Flags : 8 = InstanceFlags::None;
4918 };
4919#pragma warning(pop)
4920
4921 protected:
4927
4928 public:
4929 ~ITopLevelAccelerationStructure() noexcept override = default;
4930
4931 public:
4936 virtual const Array<Instance>& instances() const noexcept = 0;
4937
4943 virtual void addInstance(const Instance& instance) = 0;
4944
4953 inline void addInstance(const SharedPtr<const IBottomLevelAccelerationStructure>& blas, UInt32 id, UInt32 hitGroupOffset = 0, Byte mask = 0xFF, InstanceFlags flags = InstanceFlags::None) noexcept { // NOLINT(cppcoreguidelines-avoid-magic-numbers)
4954 this->addInstance(Instance { .BottomLevelAccelerationStructure = blas, .Id = id, .Mask = mask, .HitGroupOffset = hitGroupOffset, .Flags = flags });
4955 }
4956
4966 inline void addInstance(const SharedPtr<const IBottomLevelAccelerationStructure>& blas, const TMatrix3x4<Float>& transform, UInt32 id, UInt32 hitGroupOffset = 0, Byte mask = 0xFF, InstanceFlags flags = InstanceFlags::None) noexcept { // NOLINT(cppcoreguidelines-avoid-magic-numbers)
4967 this->addInstance(Instance { .BottomLevelAccelerationStructure = blas, .Transform = transform, .Id = id, .Mask = mask, .HitGroupOffset = hitGroupOffset, .Flags = flags });
4968 }
4969
4973 virtual void clear() noexcept = 0;
4974
4980 virtual bool remove(const Instance& instance) noexcept = 0;
4981
5016 inline void copy(const ICommandBuffer& commandBuffer, ITopLevelAccelerationStructure& destination, bool compress = false, const SharedPtr<const IBuffer>& buffer = nullptr, UInt64 offset = 0, bool copyBuildInfo = true) const {
5017 this->doCopy(commandBuffer, destination, compress, buffer, offset, copyBuildInfo);
5018 }
5019
5020 public:
5026 template<typename TSelf>
5027 inline auto withInstance(this TSelf&& self, const Instance& instance) noexcept -> TSelf&& {
5028 self.addInstance(instance);
5029 return std::forward<TSelf>(self);
5030 }
5031
5041 template<typename TSelf>
5042 inline auto withInstance(this TSelf&& self, const SharedPtr<const IBottomLevelAccelerationStructure>& blas, UInt32 id, UInt32 hitGroupOffset = 0, Byte mask = 0xFF, InstanceFlags flags = InstanceFlags::None) noexcept -> TSelf&& { // NOLINT(cppcoreguidelines-avoid-magic-numbers)
5043 self.addInstance(Instance { .BottomLevelAccelerationStructure = blas, .Id = id, .Mask = mask, .HitGroupOffset = hitGroupOffset, .Flags = flags });
5044 return std::forward<TSelf>(self);
5045 }
5046
5057 template<typename TSelf>
5058 inline auto withInstance(this TSelf&& self, const SharedPtr<const IBottomLevelAccelerationStructure>& blas, const TMatrix3x4<Float>& transform, UInt32 id, UInt32 hitGroupOffset = 0, Byte mask = 0xFF, InstanceFlags flags = InstanceFlags::None) noexcept -> TSelf&& { // NOLINT(cppcoreguidelines-avoid-magic-numbers)
5059 self.addInstance(Instance { .BottomLevelAccelerationStructure = blas, .Transform = transform, .Id = id, .Mask = mask, .HitGroupOffset = hitGroupOffset, .Flags = flags });
5060 return std::forward<TSelf>(self);
5061 }
5062
5063 private:
5064 virtual void doCopy(const ICommandBuffer& commandBuffer, ITopLevelAccelerationStructure& destination, bool compress, const SharedPtr<const IBuffer>& buffer, UInt64 offset, bool copyBuildInfo) const = 0;
5065 };
5066
5110 class LITEFX_RENDERING_API IBarrier {
5111 protected:
5112 IBarrier() noexcept = default;
5113 IBarrier(const IBarrier&) = default;
5114 IBarrier(IBarrier&&) noexcept = default;
5115 IBarrier& operator=(const IBarrier&) = default;
5116 IBarrier& operator=(IBarrier&&) noexcept = default;
5117
5118 public:
5119 virtual ~IBarrier() noexcept = default;
5120
5121 public:
5126 constexpr virtual PipelineStage syncBefore() const noexcept = 0;
5127
5132 constexpr virtual PipelineStage syncAfter() const noexcept = 0;
5133
5140 constexpr virtual void wait(ResourceAccess accessBefore, ResourceAccess accessAfter) = 0;
5141
5149 constexpr void transition(const IBuffer& buffer, ResourceAccess accessBefore, ResourceAccess accessAfter) {
5150 this->doTransition(buffer, accessBefore, accessAfter);
5151 };
5152
5165 constexpr void transition(const IBuffer& buffer, UInt32 element, ResourceAccess accessBefore, ResourceAccess accessAfter) {
5166 this->doTransition(buffer, element, accessBefore, accessAfter);
5167 }
5168
5178 constexpr void transition(const IImage& image, ResourceAccess accessBefore, ResourceAccess accessAfter, ImageLayout layout) {
5179 this->doTransition(image, accessBefore, accessAfter, layout);
5180 }
5181
5196 constexpr void transition(const IImage& image, UInt32 level, UInt32 levels, UInt32 layer, UInt32 layers, UInt32 plane, ResourceAccess accessBefore, ResourceAccess accessAfter, ImageLayout layout) {
5197 this->doTransition(image, level, levels, layer, layers, plane, accessBefore, accessAfter, layout);
5198 }
5199
5214 constexpr void transition(const IImage& image, ResourceAccess accessBefore, ResourceAccess accessAfter, ImageLayout fromLayout, ImageLayout toLayout) {
5215 this->doTransition(image, accessBefore, accessAfter, fromLayout, toLayout);
5216 }
5217
5237 constexpr void transition(const IImage& image, UInt32 level, UInt32 levels, UInt32 layer, UInt32 layers, UInt32 plane, ResourceAccess accessBefore, ResourceAccess accessAfter, ImageLayout fromLayout, ImageLayout toLayout) {
5238 this->doTransition(image, level, levels, layer, layers, plane, accessBefore, accessAfter, fromLayout, toLayout);
5239 }
5240
5241 private:
5242 constexpr virtual void doTransition(const IBuffer& buffer, ResourceAccess accessBefore, ResourceAccess accessAfter) = 0;
5243 constexpr virtual void doTransition(const IBuffer& buffer, UInt32 element, ResourceAccess accessBefore, ResourceAccess accessAfter) = 0;
5244 constexpr virtual void doTransition(const IImage& image, ResourceAccess accessBefore, ResourceAccess accessAfter, ImageLayout layout) = 0;
5245 constexpr virtual void doTransition(const IImage& image, ResourceAccess accessBefore, ResourceAccess accessAfter, ImageLayout fromLayout, ImageLayout toLayout) = 0;
5246 constexpr virtual void doTransition(const IImage& image, UInt32 level, UInt32 levels, UInt32 layer, UInt32 layers, UInt32 plane, ResourceAccess accessBefore, ResourceAccess accessAfter, ImageLayout layout) = 0;
5247 constexpr virtual void doTransition(const IImage& image, UInt32 level, UInt32 levels, UInt32 layer, UInt32 layers, UInt32 plane, ResourceAccess accessBefore, ResourceAccess accessAfter, ImageLayout fromLayout, ImageLayout toLayout) = 0;
5248 };
5249
5253 class LITEFX_RENDERING_API IDescriptorSet {
5254 protected:
5255 IDescriptorSet() noexcept = default;
5257 IDescriptorSet(IDescriptorSet&&) noexcept = default;
5258 IDescriptorSet& operator=(const IDescriptorSet&) = default;
5259 IDescriptorSet& operator=(IDescriptorSet&&) noexcept = default;
5260
5261 public:
5262 virtual ~IDescriptorSet() noexcept = default;
5263
5264 public:
5273 void update(UInt32 binding, const IBuffer& buffer, UInt32 bufferElement = 0, UInt32 elements = 0, UInt32 firstDescriptor = 0) const {
5274 this->doUpdate(binding, buffer, bufferElement, elements, firstDescriptor);
5275 }
5276
5298 void update(UInt32 binding, const IImage& texture, UInt32 descriptor = 0, UInt32 firstLevel = 0, UInt32 levels = 0, UInt32 firstLayer = 0, UInt32 layers = 0) const {
5299 this->doUpdate(binding, texture, descriptor, firstLevel, levels, firstLayer, layers);
5300 }
5301
5308 void update(UInt32 binding, const ISampler& sampler, UInt32 descriptor = 0) const {
5309 this->doUpdate(binding, sampler, descriptor);
5310 }
5311
5318 void update(UInt32 binding, const IAccelerationStructure& accelerationStructure, UInt32 descriptor = 0) const {
5319 this->doUpdate(binding, accelerationStructure, descriptor);
5320 }
5321
5322 private:
5323 virtual void doUpdate(UInt32 binding, const IBuffer& buffer, UInt32 bufferElement, UInt32 elements, UInt32 firstDescriptor) const = 0;
5324 virtual void doUpdate(UInt32 binding, const IImage& texture, UInt32 descriptor, UInt32 firstLevel, UInt32 levels, UInt32 firstLayer, UInt32 layers) const = 0;
5325 virtual void doUpdate(UInt32 binding, const ISampler& sampler, UInt32 descriptor) const = 0;
5326 virtual void doUpdate(UInt32 binding, const IAccelerationStructure& accelerationStructure, UInt32 descriptor) const = 0;
5327 };
5328
5334 struct LITEFX_RENDERING_API DescriptorBinding {
5335 public:
5337
5338 public:
5342 Optional<UInt32> binding = std::nullopt;
5343
5355 resource_container resource = {};
5356
5366 UInt32 firstDescriptor = 0;
5367
5375 UInt32 firstElement = 0;
5376
5384 UInt32 elements = 0;
5385
5392 UInt32 firstLevel = 0;
5393
5400 UInt32 levels = 0;
5401 };
5402
5406 class LITEFX_RENDERING_API IDescriptorSetLayout : public SharedObject {
5407 protected:
5408 IDescriptorSetLayout() noexcept = default;
5411 IDescriptorSetLayout& operator=(const IDescriptorSetLayout&) = default;
5412 IDescriptorSetLayout& operator=(IDescriptorSetLayout&&) noexcept = default;
5413
5414 public:
5415 ~IDescriptorSetLayout() noexcept override = default;
5416
5417 public:
5422 inline Enumerable<const IDescriptorLayout&> descriptors() const noexcept {
5423 return this->getDescriptors();
5424 }
5425
5431 virtual const IDescriptorLayout& descriptor(UInt32 binding) const = 0;
5432
5440 virtual UInt32 space() const noexcept = 0;
5441
5446 virtual ShaderStage shaderStages() const noexcept = 0;
5447
5452 virtual UInt32 uniforms() const noexcept = 0;
5453
5458 virtual UInt32 storages() const noexcept = 0;
5459
5464 virtual UInt32 images() const noexcept = 0;
5465
5470 virtual UInt32 buffers() const noexcept = 0;
5471
5477 virtual UInt32 samplers() const noexcept = 0;
5478
5484 virtual UInt32 staticSamplers() const noexcept = 0;
5485
5490 virtual UInt32 inputAttachments() const noexcept = 0;
5491
5492 public:
5519 inline UniquePtr<IDescriptorSet> allocate(std::initializer_list<DescriptorBinding> bindings = { }) const {
5520 return this->getDescriptorSet(0, bindings);
5521 }
5522
5525 return this->getDescriptorSet(0, bindings);
5526 }
5527
5530 return this->getDescriptorSet(0, std::move(bindings));
5531 }
5532
5541 inline UniquePtr<IDescriptorSet> allocate(UInt32 descriptors, std::initializer_list<DescriptorBinding> bindings) const {
5542 return this->getDescriptorSet(descriptors, bindings);
5543 }
5544
5547 return this->getDescriptorSet(descriptors, bindings);
5548 }
5549
5558 return this->getDescriptorSet(descriptors, std::move(bindings));
5559 }
5560
5568 inline Generator<UniquePtr<IDescriptorSet>> allocate(UInt32 descriptorSets, std::initializer_list<std::initializer_list<DescriptorBinding>> bindings = { }) const {
5569 return this->getDescriptorSets(descriptorSets, 0, bindings);
5570 }
5571
5572#ifdef __cpp_lib_mdspan
5574 inline Generator<UniquePtr<IDescriptorSet>> allocate(UInt32 descriptorSets, std::mdspan<DescriptorBinding, std::dextents<size_t, 2>> bindings) const {
5575 return this->getDescriptorSets(descriptorSets, 0, bindings);
5576 }
5577#endif
5578
5586 inline Generator<UniquePtr<IDescriptorSet>> allocate(UInt32 descriptorSets, std::function<Generator<DescriptorBinding>(UInt32)> bindingFactory) const {
5587 return this->getDescriptorSets(descriptorSets, 0, std::move(bindingFactory));
5588 }
5589
5598 inline Generator<UniquePtr<IDescriptorSet>> allocate(UInt32 descriptorSets, UInt32 descriptors, std::initializer_list<std::initializer_list<DescriptorBinding>> bindings = { }) const {
5599 return this->getDescriptorSets(descriptorSets, descriptors, bindings);
5600 }
5601
5602#ifdef __cpp_lib_mdspan
5604 inline Generator<UniquePtr<IDescriptorSet>> allocate(UInt32 descriptorSets, UInt32 descriptors, std::mdspan<DescriptorBinding, std::dextents<size_t, 2>> bindings) const {
5605 return this->getDescriptorSets(descriptorSets, descriptors, bindings);
5606 }
5607#endif
5608
5617 inline Generator<UniquePtr<IDescriptorSet>> allocate(UInt32 descriptorSets, UInt32 descriptors, std::function<Generator<DescriptorBinding>(UInt32)> bindingFactory) const {
5618 return this->getDescriptorSets(descriptorSets, descriptors, std::move(bindingFactory));
5619 }
5620
5625 inline void free(const IDescriptorSet& descriptorSet) const {
5626 this->releaseDescriptorSet(descriptorSet);
5627 }
5628
5629 private:
5630 virtual Enumerable<const IDescriptorLayout&> getDescriptors() const noexcept = 0;
5631 virtual UniquePtr<IDescriptorSet> getDescriptorSet(UInt32 descriptors, std::initializer_list<DescriptorBinding> bindings) const = 0;
5632 virtual UniquePtr<IDescriptorSet> getDescriptorSet(UInt32 descriptors, Span<DescriptorBinding> bindings) const = 0;
5633 virtual UniquePtr<IDescriptorSet> getDescriptorSet(UInt32 descriptors, Generator<DescriptorBinding> bindings) const = 0;
5634 virtual Generator<UniquePtr<IDescriptorSet>> getDescriptorSets(UInt32 descriptorSets, UInt32 descriptors, std::initializer_list<std::initializer_list<DescriptorBinding>> bindings) const = 0;
5635#ifdef __cpp_lib_mdspan
5636 virtual Generator<UniquePtr<IDescriptorSet>> getDescriptorSets(UInt32 descriptorSets, UInt32 descriptors, std::mdspan<DescriptorBinding, std::dextents<size_t, 2>> bindings) const = 0;
5637#endif
5638 virtual Generator<UniquePtr<IDescriptorSet>> getDescriptorSets(UInt32 descriptorSets, UInt32 descriptors, std::function<Generator<DescriptorBinding>(UInt32)> bindingFactory) const = 0;
5639 virtual void releaseDescriptorSet(const IDescriptorSet& descriptorSet) const = 0;
5640 };
5641
5645 class LITEFX_RENDERING_API IPushConstantsRange {
5646 protected:
5647 IPushConstantsRange() noexcept = default;
5650 IPushConstantsRange& operator=(const IPushConstantsRange&) = default;
5651 IPushConstantsRange& operator=(IPushConstantsRange&&) noexcept = default;
5652
5653 public:
5654 virtual ~IPushConstantsRange() noexcept = default;
5655
5656 public:
5661 virtual UInt32 space() const noexcept = 0;
5662
5667 virtual UInt32 binding() const noexcept = 0;
5668
5674 virtual UInt32 offset() const noexcept = 0;
5675
5681 virtual UInt32 size() const noexcept = 0;
5682
5687 virtual ShaderStage stage() const noexcept = 0;
5688 };
5689
5693 class LITEFX_RENDERING_API IPushConstantsLayout {
5694 protected:
5695 IPushConstantsLayout() noexcept = default;
5698 IPushConstantsLayout& operator=(const IPushConstantsLayout&) = default;
5699 IPushConstantsLayout& operator=(IPushConstantsLayout&&) noexcept = default;
5700
5701 public:
5702 virtual ~IPushConstantsLayout() noexcept = default;
5703
5704 public:
5709 virtual UInt32 size() const noexcept = 0;
5710
5719 virtual const IPushConstantsRange& range(ShaderStage stage) const = 0;
5720
5726 inline Enumerable<const IPushConstantsRange&> ranges() const {
5727 return this->getRanges();
5728 }
5729
5730 private:
5731 virtual Enumerable<const IPushConstantsRange&> getRanges() const = 0;
5732 };
5733
5746 struct LITEFX_RENDERING_API IShaderRecord {
5747 public:
5767
5772
5773 protected:
5774 IShaderRecord() noexcept = default;
5775 IShaderRecord(const IShaderRecord&) = default;
5776 IShaderRecord(IShaderRecord&&) noexcept = default;
5777 IShaderRecord& operator=(const IShaderRecord&) = default;
5778 IShaderRecord& operator=(IShaderRecord&&) noexcept = default;
5779
5780 public:
5781 constexpr virtual ~IShaderRecord() noexcept = default;
5782
5783 public:
5788 constexpr ShaderRecordType type() const noexcept {
5789 const auto& group = this->shaderGroup();
5790
5791 if (std::holds_alternative<MeshGeometryHitGroup>(group))
5792 {
5793 return ShaderRecordType::HitGroup;
5794 }
5795 else if (std::holds_alternative<const IShaderModule*>(group))
5796 {
5797 switch (std::get<const IShaderModule*>(group)->type())
5798 {
5799 case ShaderStage::RayGeneration: return ShaderRecordType::RayGeneration;
5800 case ShaderStage::Miss: return ShaderRecordType::Miss;
5801 case ShaderStage::Callable: return ShaderRecordType::Callable;
5802 case ShaderStage::Intersection: return ShaderRecordType::Intersection;
5803 default: return ShaderRecordType::Invalid;
5804 }
5805 }
5806
5807 std::unreachable();
5808 }
5809
5810 public:
5814 constexpr virtual const shader_group_type& shaderGroup() const noexcept = 0;
5815
5826 constexpr virtual const void* localData() const noexcept = 0;
5827
5833 constexpr virtual UInt64 localDataSize() const noexcept = 0;
5834 };
5835
5841 template <typename... TLocalData>
5843
5847 const size_t SHADER_RECORD_LOCAL_DATA_ALIGNMENT { 8 };
5848
5859 template <typename TLocalData> requires
5860 (std::alignment_of_v<TLocalData> == SHADER_RECORD_LOCAL_DATA_ALIGNMENT) &&
5861 std::is_standard_layout_v<TLocalData>
5862 struct ShaderRecord<TLocalData> final : public IShaderRecord {
5863 public:
5865
5866 private:
5870 TLocalData m_payload;
5871
5875 shader_group_type m_shaderGroup;
5876
5877 public:
5879 constexpr const shader_group_type& shaderGroup() const noexcept override {
5880 return m_shaderGroup;
5881 }
5882
5884 constexpr const void* localData() const noexcept override {
5885 return static_cast<const void*>(&m_payload);
5886 }
5887
5889 constexpr UInt64 localDataSize() const noexcept override {
5890 return sizeof(TLocalData);
5891 }
5892
5893 public:
5894 ShaderRecord() = delete;
5895
5897 constexpr ~ShaderRecord() noexcept override = default;
5898
5904 ShaderRecord(const shader_group_type& group, TLocalData payload) noexcept :
5905 m_payload(payload), m_shaderGroup(group) { }
5906
5911 constexpr ShaderRecord(const ShaderRecord& _other) = default;
5912
5917 constexpr ShaderRecord(ShaderRecord&& _other) noexcept = default;
5918
5924 constexpr ShaderRecord& operator=(const ShaderRecord& _other) = default;
5925
5931 constexpr ShaderRecord& operator=(ShaderRecord&& _other) noexcept = default;
5932 };
5933
5937 template <>
5938 struct ShaderRecord<> final : public IShaderRecord {
5939 public:
5941
5942 private:
5946 shader_group_type m_shaderGroup;
5947
5948 public:
5950 constexpr const shader_group_type& shaderGroup() const noexcept override {
5951 return m_shaderGroup;
5952 }
5953
5955 constexpr const void* localData() const noexcept override {
5956 return nullptr;
5957 }
5958
5960 constexpr UInt64 localDataSize() const noexcept override {
5961 return 0_ui64;
5962 }
5963
5964 public:
5965 ShaderRecord() = delete;
5966
5968 constexpr ~ShaderRecord() noexcept override = default;
5969
5974 ShaderRecord(const shader_group_type& group) noexcept :
5975 m_shaderGroup(group) { }
5976
5981 constexpr ShaderRecord(const ShaderRecord& _other) = default;
5982
5987 constexpr ShaderRecord(ShaderRecord&& _other) noexcept = default;
5988
5994 constexpr ShaderRecord& operator=(const ShaderRecord& _other) = default;
5995
6001 constexpr ShaderRecord& operator=(ShaderRecord&& _other) noexcept = default;
6002 };
6003
6007 class LITEFX_RENDERING_API ShaderRecordCollection final {
6008 friend class IShaderProgram;
6009
6010 private:
6013
6019 m_program(std::move(shaderProgram))
6020 {
6021 // This can only be built from a shader program, which passes the pointer to itself, which must not be nullptr. If more factory methods are added,
6022 // we must validate the program pointer here.
6023 }
6024
6025 public:
6027
6029 ShaderRecordCollection& operator=(ShaderRecordCollection&&) noexcept = default;
6032 ~ShaderRecordCollection() noexcept = default;
6033
6034 private:
6040 const IShaderModule* findShaderModule(StringView name) const noexcept;
6041
6042 public:
6047 inline SharedPtr<const IShaderProgram> program() const noexcept {
6048 return m_program;
6049 }
6050
6055 const Array<UniquePtr<const IShaderRecord>>& shaderRecords() const noexcept;
6056
6063 void addShaderRecord(UniquePtr<const IShaderRecord>&& record);
6064
6065 public:
6075 inline void addShaderRecord(StringView shaderName) {
6076 auto shaderModule = this->findShaderModule(shaderName);
6077
6078 if (shaderModule == nullptr) [[unlikely]]
6079 throw InvalidArgumentException("shaderName", "The parent shader program does not contain a shader named \"{}\".", shaderName);
6080
6081 if (shaderModule->type() == ShaderStage::AnyHit)
6082 this->addShaderRecord(makeUnique<ShaderRecord<>>(IShaderRecord::MeshGeometryHitGroup{ .AnyHitShader = shaderModule }));
6083 else if (shaderModule->type() == ShaderStage::ClosestHit)
6084 this->addShaderRecord(makeUnique<ShaderRecord<>>(IShaderRecord::MeshGeometryHitGroup{ .ClosestHitShader = shaderModule }));
6085 else
6086 this->addShaderRecord(makeUnique<ShaderRecord<>>(shaderModule));
6087 }
6088
6100 template <typename TLocalData> requires (std::alignment_of_v<TLocalData> == SHADER_RECORD_LOCAL_DATA_ALIGNMENT)
6101 inline void addShaderRecord(StringView shaderName, TLocalData payload) {
6102 auto shaderModule = this->findShaderModule(shaderName);
6103
6104 if (shaderModule == nullptr) [[unlikely]]
6105 throw InvalidArgumentException("shaderName", "The parent shader program does not contain a shader named \"{}\".", shaderName);
6106
6107 if (shaderModule->type() == ShaderStage::AnyHit)
6108 this->addShaderRecord(makeUnique<ShaderRecord<TLocalData>>(IShaderRecord::MeshGeometryHitGroup{ .AnyHitShader = shaderModule }, payload));
6109 else if (shaderModule->type() == ShaderStage::ClosestHit)
6110 this->addShaderRecord(makeUnique<ShaderRecord<TLocalData>>(IShaderRecord::MeshGeometryHitGroup{ .ClosestHitShader = shaderModule }, payload));
6111 else
6112 this->addShaderRecord(makeUnique<ShaderRecord<TLocalData>>(shaderModule, payload));
6113 }
6114
6121 inline void addMeshGeometryShaderHitGroupRecord(std::optional<StringView> anyHitShaderName, std::optional<StringView> closestHitShaderName) {
6123 .ClosestHitShader = closestHitShaderName.has_value() ? this->findShaderModule(closestHitShaderName.value()) : nullptr,
6124 .AnyHitShader = anyHitShaderName.has_value() ? this->findShaderModule(anyHitShaderName.value()) : nullptr
6125 };
6126
6127 this->addShaderRecord(makeUnique<ShaderRecord<>>(hitGroup));
6128 }
6129
6138 template <typename TLocalData> requires (std::alignment_of_v<TLocalData> == SHADER_RECORD_LOCAL_DATA_ALIGNMENT)
6139 inline void addMeshGeometryShaderHitGroupRecord(std::optional<StringView> anyHitShaderName, std::optional<StringView> closestHitShaderName, TLocalData payload) {
6141 .ClosestHitShader = closestHitShaderName.has_value() ? this->findShaderModule(closestHitShaderName.value()) : nullptr,
6142 .AnyHitShader = anyHitShaderName.has_value() ? this->findShaderModule(anyHitShaderName.value()) : nullptr
6143 };
6144
6145 this->addShaderRecord(makeUnique<ShaderRecord<TLocalData>>(hitGroup, payload));
6146 }
6147
6152 inline void addShaderRecord(const ShaderRecord<>::shader_group_type& shaderGroup) {
6153 this->addShaderRecord(makeUnique<ShaderRecord<>>(shaderGroup));
6154 }
6155
6162 template <typename TLocalData> requires (std::alignment_of_v<TLocalData> == SHADER_RECORD_LOCAL_DATA_ALIGNMENT)
6163 inline void addShaderRecord(ShaderRecord<TLocalData>::shader_group_type shaderGroup, TLocalData payload) {
6164 this->addShaderRecord(makeUnique<ShaderRecord<TLocalData>>(shaderGroup, payload));
6165 }
6166
6177 this->addShaderRecord(shaderName);
6178 return std::forward<ShaderRecordCollection>(*this);
6179 }
6180
6192 template <typename TLocalData> requires (std::alignment_of_v<TLocalData> == SHADER_RECORD_LOCAL_DATA_ALIGNMENT)
6193 inline ShaderRecordCollection&& withShaderRecord(StringView shaderName, TLocalData payload) {
6194 this->addShaderRecord(shaderName, payload);
6195 return std::forward<ShaderRecordCollection>(*this);
6196 }
6197
6204 inline ShaderRecordCollection&& withMeshGeometryHitGroupRecord(std::optional<StringView> anyHitShaderName, std::optional<StringView> closestHitShaderName) {
6205 this->addMeshGeometryShaderHitGroupRecord(anyHitShaderName, closestHitShaderName);
6206 return std::forward<ShaderRecordCollection>(*this);
6207 }
6208
6217 template <typename TLocalData> requires (std::alignment_of_v<TLocalData> == SHADER_RECORD_LOCAL_DATA_ALIGNMENT)
6218 inline ShaderRecordCollection&& withMeshGeometryHitGroupRecord(std::optional<StringView> anyHitShaderName, std::optional<StringView> closestHitShaderName, TLocalData payload) {
6219 this->addMeshGeometryShaderHitGroupRecord(anyHitShaderName, closestHitShaderName, payload);
6220 return std::forward<ShaderRecordCollection>(*this);
6221 }
6222
6229 this->addShaderRecord(shaderGroup);
6230 return std::forward<ShaderRecordCollection>(*this);
6231 }
6232
6240 template <typename TLocalData> requires (std::alignment_of_v<TLocalData> == SHADER_RECORD_LOCAL_DATA_ALIGNMENT)
6242 this->addShaderRecord(shaderGroup, payload);
6243 return std::forward<ShaderRecordCollection>(*this);
6244 }
6245 };
6246
6286 class LITEFX_RENDERING_API IShaderProgram : public SharedObject {
6287 protected:
6288 IShaderProgram() noexcept = default;
6289
6290 public:
6291 ~IShaderProgram() noexcept override = default;
6292
6294 IShaderProgram(IShaderProgram&&) noexcept = delete;
6295 auto operator=(const IShaderProgram&) = delete;
6296 auto operator=(IShaderProgram&&) noexcept = delete;
6297
6298 public:
6304 inline const IShaderModule* operator[](StringView name) const {
6305 auto modules = this->getModules();
6306
6307 if (auto match = std::ranges::find_if(modules, [name](auto& module) { return module.fileName().compare(name) == 0; }); match != modules.end())
6308 return std::addressof(*match);
6309
6310 return nullptr;
6311 }
6312
6318 inline bool contains(StringView name) const {
6319 auto modules = this->getModules();
6320 return std::ranges::find_if(modules, [name](const auto& module) { return module.fileName().compare(name) == 0; }) != modules.end();
6321 };
6322
6328 inline bool contains(const IShaderModule& module) const {
6329 auto modules = this->getModules();
6330 return std::ranges::find_if(modules, [&module](const auto& m) { return std::addressof(m) == std::addressof(module); }) != modules.end();
6331 };
6332
6338 return this->getModules();
6339 }
6340
6366 return this->parsePipelineLayout();
6367 };
6368
6373 [[nodiscard]] inline ShaderRecordCollection buildShaderRecordCollection() const noexcept {
6374 return { this->shared_from_this() };
6375 }
6376
6377 private:
6378 virtual Enumerable<const IShaderModule&> getModules() const = 0;
6379 virtual SharedPtr<IPipelineLayout> parsePipelineLayout() const = 0;
6380 };
6381
6385 class LITEFX_RENDERING_API IPipelineLayout : public SharedObject {
6386 protected:
6387 IPipelineLayout() noexcept = default;
6389 IPipelineLayout(IPipelineLayout&&) noexcept = default;
6390 IPipelineLayout& operator=(const IPipelineLayout&) = default;
6391 IPipelineLayout& operator=(IPipelineLayout&&) noexcept = default;
6392
6393 public:
6394 ~IPipelineLayout() noexcept override = default;
6395
6396 public:
6401 //virtual const IGraphicsDevice& device() const noexcept;
6402
6408 virtual const IDescriptorSetLayout& descriptorSet(UInt32 space) const = 0;
6409
6414 inline Enumerable<SharedPtr<const IDescriptorSetLayout>> descriptorSets() const {
6415 return this->getDescriptorSets();
6416 }
6417
6422 virtual const IPushConstantsLayout* pushConstants() const noexcept = 0;
6423
6424 private:
6425 virtual Enumerable<SharedPtr<const IDescriptorSetLayout>> getDescriptorSets() const = 0;
6426 };
6427
6431 class LITEFX_RENDERING_API IInputAssembler : public SharedObject {
6432 protected:
6433 IInputAssembler() noexcept = default;
6435 IInputAssembler(IInputAssembler&&) noexcept = default;
6436 IInputAssembler& operator=(const IInputAssembler&) = default;
6437 IInputAssembler& operator=(IInputAssembler&&) noexcept = default;
6438
6439 public:
6440 ~IInputAssembler() noexcept override = default;
6441
6442 public:
6447 inline Enumerable<const IVertexBufferLayout&> vertexBufferLayouts() const {
6448 return this->getVertexBufferLayouts();
6449 }
6450
6457 virtual const IVertexBufferLayout& vertexBufferLayout(UInt32 binding) const = 0;
6458
6463 virtual const IIndexBufferLayout* indexBufferLayout() const noexcept = 0;
6464
6469 virtual PrimitiveTopology topology() const noexcept = 0;
6470
6471 private:
6472 virtual Enumerable<const IVertexBufferLayout&> getVertexBufferLayouts() const = 0;
6473 };
6474
6481 class LITEFX_RENDERING_API IPipeline : public virtual IStateResource {
6482 protected:
6483 IPipeline() noexcept = default;
6484 IPipeline(const IPipeline&) = delete;
6485 IPipeline(IPipeline&&) noexcept = default;
6486 IPipeline& operator=(const IPipeline&) = delete;
6487 IPipeline& operator=(IPipeline&&) noexcept = default;
6488
6489 public:
6490 ~IPipeline() noexcept override = default;
6491
6492 public:
6497 inline SharedPtr<const IShaderProgram> program() const noexcept {
6498 return this->getProgram();
6499 }
6500
6506 return this->getLayout();
6507 }
6508
6509 private:
6510 virtual SharedPtr<const IShaderProgram> getProgram() const noexcept = 0;
6511 virtual SharedPtr<const IPipelineLayout> getLayout() const noexcept = 0;
6512 };
6513
6517 class LITEFX_RENDERING_API ICommandBuffer : public SharedObject {
6518 public:
6519 friend class ICommandQueue;
6520
6521 protected:
6522 ICommandBuffer() noexcept = default;
6523 ICommandBuffer(ICommandBuffer&&) noexcept = default;
6525 ICommandBuffer& operator=(const ICommandBuffer&) = default;
6526 ICommandBuffer& operator=(ICommandBuffer&&) noexcept = default;
6527
6528 public:
6529 ~ICommandBuffer() noexcept override = default;
6530
6531 public:
6540 virtual void begin() const = 0;
6541
6549 virtual void end() const = 0;
6550
6555 virtual bool isSecondary() const noexcept = 0;
6556
6574 virtual void track(SharedPtr<const IBuffer> buffer) const = 0;
6575
6582 virtual void track(SharedPtr<const IImage> image) const = 0;
6583
6590 virtual void track(SharedPtr<const ISampler> sampler) const = 0;
6591
6592 public:
6597 inline SharedPtr<const ICommandQueue> queue() const noexcept {
6598 return this->getQueue();
6599 }
6600
6607 [[nodiscard]] inline UniquePtr<IBarrier> makeBarrier(PipelineStage syncBefore, PipelineStage syncAfter) const {
6608 return this->getBarrier(syncBefore, syncAfter);
6609 }
6610
6620 inline void barrier(const IBarrier& barrier) const noexcept {
6621 this->cmdBarrier(barrier);
6622 }
6623
6638 inline void transfer(const IBuffer& source, const IBuffer& target, UInt32 sourceElement = 0, UInt32 targetElement = 0, UInt32 elements = 1) const {
6639 this->cmdTransfer(source, target, sourceElement, targetElement, elements);
6640 }
6641
6662 inline void transfer(const SharedPtr<const IBuffer>& source, const IBuffer& target, UInt32 sourceElement = 0, UInt32 targetElement = 0, UInt32 elements = 1) const {
6663 this->cmdTransfer(source, target, sourceElement, targetElement, elements);
6664 }
6665
6679 inline void transfer(const void* const data, size_t size, const IBuffer& target, UInt32 targetElement = 0, UInt32 elements = 1) const {
6680 this->cmdTransfer(data, size, target, targetElement, elements);
6681 }
6682
6695 inline void transfer(Span<const void* const> data, size_t elementSize, const IBuffer& target, UInt32 targetElement = 0) const {
6696 this->cmdTransfer(data, elementSize, target, targetElement);
6697 }
6698
6734 inline void transfer(const IBuffer& source, const IImage& target, UInt32 sourceElement = 0, UInt32 firstSubresource = 0, UInt32 elements = 1) const {
6735 this->cmdTransfer(source, target, sourceElement, firstSubresource, elements);
6736 }
6737
6780 inline void transfer(const SharedPtr<const IBuffer>& source, const IImage& target, UInt32 sourceElement = 0, UInt32 firstSubresource = 0, UInt32 elements = 1) const {
6781 this->cmdTransfer(source, target, sourceElement, firstSubresource, elements);
6782 }
6783
6797 inline void transfer(const void* const data, size_t size, const IImage& target, UInt32 subresource = 0) const {
6798 this->cmdTransfer(data, size, target, subresource);
6799 }
6800
6814 inline void transfer(Span<const void* const> data, size_t elementSize, const IImage& target, UInt32 firstSubresource = 0, UInt32 elements = 1) const {
6815 this->cmdTransfer(data, elementSize, target, firstSubresource, elements);
6816 }
6817
6831 inline void transfer(const IImage& source, const IImage& target, UInt32 sourceSubresource = 0, UInt32 targetSubresource = 0, UInt32 subresources = 1) const {
6832 this->cmdTransfer(source, target, sourceSubresource, targetSubresource, subresources);
6833 }
6834
6855 inline void transfer(const SharedPtr<const IImage>& source, const IImage& target, UInt32 sourceSubresource = 0, UInt32 targetSubresource = 0, UInt32 subresources = 1) const {
6856 this->cmdTransfer(source, target, sourceSubresource, targetSubresource, subresources);
6857 }
6858
6894 inline void transfer(const IImage& source, const IBuffer& target, UInt32 firstSubresource = 0, UInt32 targetElement = 0, UInt32 subresources = 1) const {
6895 this->cmdTransfer(source, target, firstSubresource, targetElement, subresources);
6896 }
6897
6940 inline void transfer(const SharedPtr<const IImage>& source, const IBuffer& target, UInt32 firstSubresource = 0, UInt32 targetElement = 0, UInt32 subresources = 1) const {
6941 this->cmdTransfer(source, target, firstSubresource, targetElement, subresources);
6942 }
6943
6947 inline void use(const IPipeline& pipeline) const noexcept {
6948 this->cmdUse(pipeline);
6949 }
6950
6957 inline void bind(const IDescriptorSet& descriptorSet) const {
6958 this->cmdBind(descriptorSet);
6959 }
6960
6970 template <typename TSelf, typename T>
6971 inline void bind(this const TSelf& self, std::initializer_list<const T*> descriptorSets) requires
6972 std::derived_from<T, IDescriptorSet>
6973 {
6974 // NOTE: In the future we might be able to remove this method, if P2447R4 is added to the language.
6975 Array<const T*> sets = descriptorSets;
6976 self.bind(Span<const T*>(sets));
6977 }
6978
6987 template <typename TSelf>
6988 inline void bind(this const TSelf& self, std::ranges::input_range auto&& descriptorSets) requires
6989 std::derived_from<std::remove_cv_t<std::remove_pointer_t<std::iter_value_t<std::ranges::iterator_t<std::remove_cv_t<std::remove_reference_t<decltype(descriptorSets)>>>>>>, IDescriptorSet>
6990 {
6991 using descriptor_set_type = std::remove_cv_t<std::remove_pointer_t<std::iter_value_t<std::ranges::iterator_t<std::remove_cv_t<std::remove_reference_t<decltype(descriptorSets)>>>>>>;
6992 auto sets = descriptorSets | std::ranges::to<Array<const descriptor_set_type*>>();
6993 self.bind(Span<const descriptor_set_type*>(sets));
6994 }
6995
7003 inline void bind(Span<const IDescriptorSet*> descriptorSets) const {
7004 this->cmdBind(descriptorSets);
7005 }
7006
7012 inline void bind(const IDescriptorSet& descriptorSet, const IPipeline& pipeline) const {
7013 this->cmdBind(descriptorSet, pipeline);
7014 }
7015
7026 template <typename TSelf, typename T>
7027 inline void bind(this const TSelf& self, std::initializer_list<const T*> descriptorSets, const typename TSelf::pipeline_type& pipeline)
7028 {
7029 // NOTE: In the future we might be able to remove this method, if P2447R4 is added to the language.
7030 Array<const T*> sets = descriptorSets;
7031 self.bind(Span<const T*>(sets), pipeline);
7032 }
7033
7042 template <typename TSelf>
7043 inline void bind(this const TSelf& self, std::ranges::input_range auto&& descriptorSets, const typename TSelf::pipeline_type& pipeline) requires
7044 std::derived_from<std::remove_cv_t<std::remove_pointer_t<std::iter_value_t<std::ranges::iterator_t<std::remove_cv_t<std::remove_reference_t<decltype(descriptorSets)>>>>>>, IDescriptorSet>
7045 {
7046 using descriptor_set_type = std::remove_cv_t<std::remove_pointer_t<std::iter_value_t<std::ranges::iterator_t<std::remove_cv_t<std::remove_reference_t<decltype(descriptorSets)>>>>>>;
7047 auto sets = descriptorSets | std::ranges::to<Array<const descriptor_set_type*>>();
7048 self.bind(Span<const descriptor_set_type*>(sets), pipeline);
7049 }
7050
7059 inline void bind(Span<const IDescriptorSet*> descriptorSets, const IPipeline& pipeline) const {
7060 this->cmdBind(descriptorSets, pipeline);
7061 }
7062
7073 inline void bind(const IVertexBuffer& buffer) const {
7074 this->cmdBind(buffer);
7075 }
7076
7086 inline void bind(const IIndexBuffer& buffer) const {
7087 this->cmdBind(buffer);
7088 }
7089
7095 virtual void dispatch(const Vector3u& threadGroupCount) const noexcept = 0;
7096
7103 inline void dispatch(UInt32 x, UInt32 y, UInt32 z) const noexcept {
7104 this->dispatch({ x, y, z });
7105 }
7106
7114 inline void dispatchIndirect(const IBuffer& batchBuffer, UInt32 batchCount, UInt64 offset = 0) const noexcept {
7115 this->cmdDispatchIndirect(batchBuffer, batchCount, offset);
7116 }
7117
7125 virtual void dispatchMesh(const Vector3u& threadGroupCount) const noexcept = 0;
7126
7136 inline void dispatchMesh(UInt32 x, UInt32 y, UInt32 z) const noexcept {
7137 this->dispatchMesh({ x, y, z });
7138 }
7139
7147 inline void dispatchMeshIndirect(const IBuffer& batchBuffer, UInt32 batchCount, UInt64 offset = 0) const noexcept {
7148 this->cmdDispatchMeshIndirect(batchBuffer, batchCount, offset);
7149 }
7150
7160 inline void dispatchMeshIndirect(const IBuffer& batchBuffer, const IBuffer& countBuffer, UInt64 offset = 0, UInt64 countOffset = 0, UInt32 maxBatches = std::numeric_limits<UInt32>::max()) const noexcept {
7161 this->cmdDispatchMeshIndirect(batchBuffer, countBuffer, offset, countOffset, maxBatches);
7162 }
7163
7178 inline void traceRays(UInt32 width, UInt32 height, UInt32 depth, const ShaderBindingTableOffsets& offsets, const IBuffer& rayGenerationShaderBindingTable, const IBuffer* missShaderBindingTable = nullptr, const IBuffer* hitShaderBindingTable = nullptr, const IBuffer* callableShaderBindingTable = nullptr) const noexcept {
7179 this->cmdTraceRays(width, height, depth, offsets, rayGenerationShaderBindingTable, missShaderBindingTable, hitShaderBindingTable, callableShaderBindingTable);
7180 }
7181
7194 inline void traceRays(const Vector3u& dimensions, const ShaderBindingTableOffsets& offsets, const IBuffer& rayGenerationShaderBindingTable, const IBuffer* missShaderBindingTable = nullptr, const IBuffer* hitShaderBindingTable = nullptr, const IBuffer* callableShaderBindingTable = nullptr) const noexcept {
7195 this->traceRays(dimensions.x(), dimensions.y(), dimensions.z(), offsets, rayGenerationShaderBindingTable, missShaderBindingTable, hitShaderBindingTable, callableShaderBindingTable);
7196 }
7197
7206 virtual void draw(UInt32 vertices, UInt32 instances = 1, UInt32 firstVertex = 0, UInt32 firstInstance = 0) const noexcept = 0;
7207
7218 inline void draw(const IVertexBuffer& vertexBuffer, UInt32 instances = 1, UInt32 firstVertex = 0, UInt32 firstInstance = 0) const {
7219 this->cmdDraw(vertexBuffer, instances, firstVertex, firstInstance);
7220 }
7221
7229 inline void drawIndirect(const IBuffer& batchBuffer, UInt32 batchCount, UInt64 offset = 0) const noexcept {
7230 this->cmdDrawIndirect(batchBuffer, batchCount, offset);
7231 }
7232
7242 inline void drawIndirect(const IBuffer& batchBuffer, const IBuffer& countBuffer, UInt64 offset = 0, UInt64 countOffset = 0, UInt32 maxBatches = std::numeric_limits<UInt32>::max()) const noexcept {
7243 this->cmdDrawIndirect(batchBuffer, countBuffer, offset, countOffset, maxBatches);
7244 }
7245
7255 virtual void drawIndexed(UInt32 indices, UInt32 instances = 1, UInt32 firstIndex = 0, Int32 vertexOffset = 0, UInt32 firstInstance = 0) const noexcept = 0;
7256
7268 inline void drawIndexed(const IIndexBuffer& indexBuffer, UInt32 instances = 1, UInt32 firstIndex = 0, Int32 vertexOffset = 0, UInt32 firstInstance = 0) const {
7269 this->cmdDrawIndexed(indexBuffer, instances, firstIndex, vertexOffset, firstInstance);
7270 }
7271
7284 inline void drawIndexed(const IVertexBuffer& vertexBuffer, const IIndexBuffer& indexBuffer, UInt32 instances = 1, UInt32 firstIndex = 0, Int32 vertexOffset = 0, UInt32 firstInstance = 0) const {
7285 this->cmdDrawIndexed(vertexBuffer, indexBuffer, instances, firstIndex, vertexOffset, firstInstance);
7286 }
7287
7295 inline void drawIndexedIndirect(const IBuffer& batchBuffer, UInt32 batchCount, UInt64 offset = 0) const noexcept {
7296 this->cmdDrawIndexedIndirect(batchBuffer, batchCount, offset);
7297 }
7298
7308 inline void drawIndexedIndirect(const IBuffer& batchBuffer, const IBuffer& countBuffer, UInt64 offset = 0, UInt64 countOffset = 0, UInt32 maxBatches = std::numeric_limits<UInt32>::max()) const noexcept {
7309 this->cmdDrawIndexedIndirect(batchBuffer, countBuffer, offset, countOffset, maxBatches);
7310 }
7311
7317 inline void pushConstants(const IPushConstantsLayout& layout, const void* const memory) const {
7318 this->cmdPushConstants(layout, memory);
7319 }
7320
7325 virtual void setViewports(Span<const IViewport*> viewports) const = 0;
7326
7331 virtual void setViewports(const IViewport* viewport) const = 0;
7332
7337 virtual void setScissors(Span<const IScissor*> scissors) const = 0;
7338
7343 virtual void setScissors(const IScissor* scissor) const = 0;
7344
7353 virtual void setBlendFactors(const Vector4f& blendFactors) const noexcept = 0;
7354
7359 virtual void setStencilRef(UInt32 stencilRef) const noexcept = 0;
7360
7365 virtual UInt64 submit() const = 0;
7366
7371 virtual void writeTimingEvent(const SharedPtr<const TimingEvent>& timingEvent) const = 0;
7372
7377 inline void execute(const SharedPtr<const ICommandBuffer>& commandBuffer) const {
7378 this->cmdExecute(commandBuffer);
7379 }
7380
7385 inline void execute(Enumerable<SharedPtr<const ICommandBuffer>> commandBuffers) const {
7386 this->cmdExecute(std::move(commandBuffers));
7387 }
7388
7401 inline void buildAccelerationStructure(IBottomLevelAccelerationStructure& blas, const SharedPtr<const IBuffer>& scratchBuffer, const IBuffer& buffer, UInt64 offset = 0) const {
7402 this->cmdBuildAccelerationStructure(blas, scratchBuffer, buffer, offset);
7403 }
7404
7417 inline void buildAccelerationStructure(ITopLevelAccelerationStructure& tlas, const SharedPtr<const IBuffer>& scratchBuffer, const IBuffer& buffer, UInt64 offset = 0) const {
7418 this->cmdBuildAccelerationStructure(tlas, scratchBuffer, buffer, offset);
7419 }
7420
7433 inline void updateAccelerationStructure(IBottomLevelAccelerationStructure& blas, const SharedPtr<const IBuffer>& scratchBuffer, const IBuffer& buffer, UInt64 offset = 0) const {
7434 this->cmdUpdateAccelerationStructure(blas, scratchBuffer, buffer, offset);
7435 }
7436
7449 inline void updateAccelerationStructure(ITopLevelAccelerationStructure& tlas, const SharedPtr<const IBuffer>& scratchBuffer, const IBuffer& buffer, UInt64 offset = 0) const {
7450 this->cmdUpdateAccelerationStructure(tlas, scratchBuffer, buffer, offset);
7451 }
7452
7466 inline void copyAccelerationStructure(const IBottomLevelAccelerationStructure& from, const IBottomLevelAccelerationStructure& to, bool compress = false) const noexcept {
7467 this->cmdCopyAccelerationStructure(from, to, compress);
7468 }
7469
7483 inline void copyAccelerationStructure(const ITopLevelAccelerationStructure& from, const ITopLevelAccelerationStructure& to, bool compress = false) const noexcept {
7484 this->cmdCopyAccelerationStructure(from, to, compress);
7485 }
7486
7487 protected:
7491 virtual void releaseSharedState() const = 0;
7492
7493 private:
7494 virtual SharedPtr<const ICommandQueue> getQueue() const noexcept = 0;
7495 virtual UniquePtr<IBarrier> getBarrier(PipelineStage syncBefore, PipelineStage syncAfter) const = 0;
7496 virtual void cmdBarrier(const IBarrier& barrier) const noexcept = 0;
7497 virtual void cmdTransfer(const IBuffer& source, const IBuffer& target, UInt32 sourceElement, UInt32 targetElement, UInt32 elements) const = 0;
7498 virtual void cmdTransfer(const IBuffer& source, const IImage& target, UInt32 sourceElement, UInt32 firstSubresource, UInt32 elements) const = 0;
7499 virtual void cmdTransfer(const IImage& source, const IImage& target, UInt32 sourceSubresource, UInt32 targetSubresource, UInt32 subresources) const = 0;
7500 virtual void cmdTransfer(const IImage& source, const IBuffer& target, UInt32 firstSubresource, UInt32 targetElement, UInt32 subresources) const = 0;
7501 virtual void cmdTransfer(const SharedPtr<const IBuffer>& source, const IBuffer& target, UInt32 sourceElement, UInt32 targetElement, UInt32 elements) const = 0;
7502 virtual void cmdTransfer(const SharedPtr<const IBuffer>& source, const IImage& target, UInt32 sourceElement, UInt32 firstSubresource, UInt32 elements) const = 0;
7503 virtual void cmdTransfer(const SharedPtr<const IImage>& source, const IImage& target, UInt32 sourceSubresource, UInt32 targetSubresource, UInt32 subresources) const = 0;
7504 virtual void cmdTransfer(const SharedPtr<const IImage>& source, const IBuffer& target, UInt32 firstSubresource, UInt32 targetElement, UInt32 subresources) const = 0;
7505 virtual void cmdTransfer(const void* const data, size_t size, const IBuffer& target, UInt32 targetElement, UInt32 elements) const = 0;
7506 virtual void cmdTransfer(Span<const void* const> data, size_t elementSize, const IBuffer& target, UInt32 targetElement) const = 0;
7507 virtual void cmdTransfer(const void* const data, size_t size, const IImage& target, UInt32 subresource) const = 0;
7508 virtual void cmdTransfer(Span<const void* const> data, size_t elementSize, const IImage& target, UInt32 firstSubresource, UInt32 elements) const = 0;
7509 virtual void cmdUse(const IPipeline& pipeline) const noexcept = 0;
7510 virtual void cmdBind(const IDescriptorSet& descriptorSet) const = 0;
7511 virtual void cmdBind(Span<const IDescriptorSet*> descriptorSets) const = 0;
7512 virtual void cmdBind(const IDescriptorSet& descriptorSet, const IPipeline& pipeline) const = 0;
7513 virtual void cmdBind(Span<const IDescriptorSet*> descriptorSets, const IPipeline& pipeline) const = 0;
7514 virtual void cmdBind(const IVertexBuffer& buffer) const = 0;
7515 virtual void cmdBind(const IIndexBuffer& buffer) const = 0;
7516 virtual void cmdPushConstants(const IPushConstantsLayout& layout, const void* const memory) const = 0;
7517 virtual void cmdDispatchIndirect(const IBuffer& batchBuffer, UInt32 batchCount, UInt64 offset) const noexcept = 0;
7518 virtual void cmdDispatchMeshIndirect(const IBuffer& batchBuffer, UInt32 batchCount, UInt64 offset) const noexcept = 0;
7519 virtual void cmdDispatchMeshIndirect(const IBuffer& batchBuffer, const IBuffer& countBuffer, UInt64 offset, UInt64 countOffset, UInt32 maxBatches) const noexcept = 0;
7520 virtual void cmdDraw(const IVertexBuffer& vertexBuffer, UInt32 instances, UInt32 firstVertex, UInt32 firstInstance) const = 0;
7521 virtual void cmdDrawIndirect(const IBuffer& batchBuffer, UInt32 batchCount, UInt64 offset) const noexcept = 0;
7522 virtual void cmdDrawIndirect(const IBuffer& batchBuffer, const IBuffer& countBuffer, UInt64 offset, UInt64 countOffset, UInt32 maxBatches) const noexcept = 0;
7523 virtual void cmdDrawIndexed(const IIndexBuffer& indexBuffer, UInt32 instances, UInt32 firstIndex, Int32 vertexOffset, UInt32 firstInstance) const = 0;
7524 virtual void cmdDrawIndexed(const IVertexBuffer& vertexBuffer, const IIndexBuffer& indexBuffer, UInt32 instances, UInt32 firstIndex, Int32 vertexOffset, UInt32 firstInstance) const = 0;
7525 virtual void cmdDrawIndexedIndirect(const IBuffer& batchBuffer, UInt32 batchCount, UInt64 offset) const noexcept = 0;
7526 virtual void cmdDrawIndexedIndirect(const IBuffer& batchBuffer, const IBuffer& countBuffer, UInt64 offset, UInt64 countOffset, UInt32 maxBatches) const noexcept = 0;
7527 virtual void cmdExecute(const SharedPtr<const ICommandBuffer>& commandBuffer) const = 0;
7528 virtual void cmdExecute(Enumerable<SharedPtr<const ICommandBuffer>> commandBuffer) const = 0;
7529 virtual void cmdBuildAccelerationStructure(IBottomLevelAccelerationStructure& blas, const SharedPtr<const IBuffer>& scratchBuffer, const IBuffer& buffer, UInt64 offset) const = 0;
7530 virtual void cmdBuildAccelerationStructure(ITopLevelAccelerationStructure& tlas, const SharedPtr<const IBuffer>& scratchBuffer, const IBuffer& buffer, UInt64 offset) const = 0;
7531 virtual void cmdUpdateAccelerationStructure(IBottomLevelAccelerationStructure& blas, const SharedPtr<const IBuffer>& scratchBuffer, const IBuffer& buffer, UInt64 offset) const = 0;
7532 virtual void cmdUpdateAccelerationStructure(ITopLevelAccelerationStructure& tlas, const SharedPtr<const IBuffer>& scratchBuffer, const IBuffer& buffer, UInt64 offset) const = 0;
7533 virtual void cmdCopyAccelerationStructure(const IBottomLevelAccelerationStructure& from, const IBottomLevelAccelerationStructure& to, bool compress) const noexcept = 0;
7534 virtual void cmdCopyAccelerationStructure(const ITopLevelAccelerationStructure& from, const ITopLevelAccelerationStructure& to, bool compress) const noexcept = 0;
7535 virtual void cmdTraceRays(UInt32 width, UInt32 height, UInt32 depth, const ShaderBindingTableOffsets& offsets, const IBuffer& rayGenerationShaderBindingTable, const IBuffer* missShaderBindingTable, const IBuffer* hitShaderBindingTable, const IBuffer* callableShaderBindingTable) const noexcept = 0;
7536 };
7537
7541 class LITEFX_RENDERING_API IRenderPipeline : public virtual IPipeline {
7542 protected:
7543 IRenderPipeline() noexcept = default;
7544 IRenderPipeline(IRenderPipeline&&) noexcept = default;
7546 IRenderPipeline& operator=(IRenderPipeline&&) noexcept = default;
7547 IRenderPipeline& operator=(const IRenderPipeline&) = delete;
7548
7549 public:
7550 ~IRenderPipeline() noexcept override = default;
7551
7552 public:
7557 inline SharedPtr<IInputAssembler> inputAssembler() const noexcept {
7558 return this->getInputAssembler();
7559 }
7560
7565 inline SharedPtr<IRasterizer> rasterizer() const noexcept {
7566 return this->getRasterizer();
7567 }
7568
7582 virtual bool alphaToCoverage() const noexcept = 0;
7583
7592 virtual MultiSamplingLevel samples() const noexcept = 0;
7593
7601 virtual void updateSamples(MultiSamplingLevel samples) = 0;
7602
7603 private:
7604 virtual SharedPtr<IInputAssembler> getInputAssembler() const noexcept = 0;
7605 virtual SharedPtr<IRasterizer> getRasterizer() const noexcept = 0;
7606 };
7607
7611 class LITEFX_RENDERING_API IComputePipeline : public virtual IPipeline {
7612 protected:
7613 IComputePipeline() noexcept = default;
7614 IComputePipeline(IComputePipeline&&) noexcept = default;
7616 IComputePipeline& operator=(IComputePipeline&&) noexcept = default;
7617 IComputePipeline& operator=(const IComputePipeline&) = delete;
7618
7619 public:
7620 ~IComputePipeline() noexcept override = default;
7621 };
7622
7626 class LITEFX_RENDERING_API IRayTracingPipeline : public virtual IPipeline {
7627 protected:
7628 IRayTracingPipeline() noexcept = default;
7631 IRayTracingPipeline& operator=(IRayTracingPipeline&&) noexcept = default;
7632 IRayTracingPipeline& operator=(const IRayTracingPipeline&) = delete;
7633
7634 public:
7635 ~IRayTracingPipeline() noexcept override = default;
7636
7637 public:
7642 virtual const ShaderRecordCollection& shaderRecords() const noexcept = 0;
7643
7648 virtual UInt32 maxRecursionDepth() const noexcept = 0;
7649
7661 virtual UInt32 maxPayloadSize() const noexcept = 0;
7662
7672 virtual UInt32 maxAttributeSize() const noexcept = 0;
7673
7689 inline SharedPtr<IBuffer> allocateShaderBindingTable(ShaderBindingTableOffsets& offsets, ShaderBindingGroup groups = ShaderBindingGroup::All) const {
7690 return this->getShaderBindingTable(offsets, groups);
7691 }
7692
7693 private:
7694 virtual SharedPtr<IBuffer> getShaderBindingTable(ShaderBindingTableOffsets& offsets, ShaderBindingGroup groups) const = 0;
7695 };
7696
7709 class LITEFX_RENDERING_API IFrameBuffer : public virtual IStateResource, public SharedObject {
7710 public:
7716 struct ResizeEventArgs : public EventArgs {
7717 private:
7718 Size2d m_newSize;
7719
7720 public:
7721 ResizeEventArgs(Size2d newSize) noexcept :
7722 EventArgs(), m_newSize(std::move(newSize)) { }
7724 ResizeEventArgs(ResizeEventArgs&&) noexcept = default;
7725 ResizeEventArgs& operator=(const ResizeEventArgs&) = default;
7726 ResizeEventArgs& operator=(ResizeEventArgs&&) noexcept = default;
7727 ~ResizeEventArgs() noexcept override = default;
7728
7729 public:
7734 inline const Size2d& newSize() const noexcept {
7735 return m_newSize;
7736 }
7737 };
7738
7745 public:
7747 EventArgs() { }
7750 ReleasedEventArgs& operator=(const ReleasedEventArgs&) = default;
7751 ReleasedEventArgs& operator=(ReleasedEventArgs&&) noexcept = default;
7752 ~ReleasedEventArgs() noexcept override = default;
7753 };
7754
7755 protected:
7756 IFrameBuffer() noexcept = default;
7757 IFrameBuffer(IFrameBuffer&&) noexcept = default;
7758 IFrameBuffer(const IFrameBuffer&) = delete;
7759 IFrameBuffer& operator=(IFrameBuffer&&) noexcept = default;
7760 IFrameBuffer& operator=(const IFrameBuffer&) = delete;
7761
7762 public:
7766 inline ~IFrameBuffer() noexcept override {
7767 released.invoke(this, { });
7768 }
7769
7770 public:
7776
7787
7788 public:
7796 virtual const Size2d& size() const noexcept = 0;
7797
7805 virtual size_t getWidth() const noexcept = 0;
7806
7814 virtual size_t getHeight() const noexcept = 0;
7815
7829 virtual void mapRenderTarget(const RenderTarget& renderTarget, UInt32 index) = 0;
7830
7844 virtual void mapRenderTarget(const RenderTarget& renderTarget, StringView imageName) = 0;
7845
7858 inline void mapRenderTarget(const RenderTarget& renderTarget) {
7859 this->mapRenderTarget(renderTarget, renderTarget.name());
7860 }
7861
7869 inline void mapRenderTargets(Span<const RenderTarget> renderTargets) {
7870 std::ranges::for_each(renderTargets, [this](auto& renderTarget) { this->mapRenderTarget(renderTarget); });
7871 }
7872
7881 virtual void unmapRenderTarget(const RenderTarget& renderTarget) noexcept = 0;
7882
7888 return this->getImages();
7889 }
7890
7897 virtual const IImage& operator[](UInt32 index) const = 0;
7898
7905 virtual const IImage& image(UInt32 index) const = 0;
7906
7913 virtual const IImage& operator[](const RenderTarget& renderTarget) const = 0;
7914
7921 virtual const IImage& image(const RenderTarget& renderTarget) const = 0;
7922
7929 virtual const IImage& operator[](StringView renderTargetName) const = 0;
7930
7937 virtual const IImage& image(StringView renderTargetName) const = 0;
7938
7946 virtual const IImage& resolveImage(UInt64 hash) const = 0;
7947
7954 template <typename TSelf>
7955 inline auto addImage(this TSelf&& self, Format format, MultiSamplingLevel samples = MultiSamplingLevel::x1, ResourceUsage usage = ResourceUsage::FrameBufferImage) -> TSelf&& {
7956 self.addImage(format, samples, usage);
7957 return std::forward<TSelf>(self);
7958 }
7959
7966 inline void addImage(Format format, MultiSamplingLevel samples = MultiSamplingLevel::x1, ResourceUsage usage = ResourceUsage::FrameBufferImage) {
7967 this->addImage("", format, samples, usage);
7968 }
7969
7977 template <typename TSelf>
7978 inline auto addImage(this TSelf&& self, StringView name, Format format, MultiSamplingLevel samples = MultiSamplingLevel::x1, ResourceUsage usage = ResourceUsage::FrameBufferImage) -> TSelf&& {
7979 self.addImage(name, format, samples, usage);
7980 return std::forward<TSelf>(self);
7981 }
7982
7991 virtual void addImage(const String& name, Format format, MultiSamplingLevel samples = MultiSamplingLevel::x1, ResourceUsage usage = ResourceUsage::FrameBufferImage) = 0;
7992
7999 template <typename TSelf>
8000 inline auto addImage(this TSelf&& self, const RenderTarget& renderTarget, MultiSamplingLevel samples = MultiSamplingLevel::x1, ResourceUsage usage = ResourceUsage::FrameBufferImage) -> TSelf&& {
8001 self.addImage(renderTarget, samples, usage);
8002 return std::forward<TSelf>(self);
8003 }
8004
8011 inline void addImage(const RenderTarget& renderTarget, MultiSamplingLevel samples = MultiSamplingLevel::x1, ResourceUsage usage = ResourceUsage::FrameBufferImage) {
8012 this->addImage(renderTarget.name(), renderTarget, samples, usage);
8013 }
8014
8022 template <typename TSelf>
8023 inline auto addImage(this TSelf&& self, StringView name, const RenderTarget& renderTarget, MultiSamplingLevel samples = MultiSamplingLevel::x1, ResourceUsage usage = ResourceUsage::FrameBufferImage) -> TSelf&& {
8024 self.addImage(name, renderTarget, samples, usage);
8025 return std::forward<TSelf>(self);
8026 }
8027
8035 virtual void addImage(const String& name, const RenderTarget& renderTarget, MultiSamplingLevel samples = MultiSamplingLevel::x1, ResourceUsage usage = ResourceUsage::FrameBufferImage) = 0;
8036
8046 template <typename TSelf>
8047 inline auto addImages(this TSelf&& self, Span<const RenderTarget> renderTargets, MultiSamplingLevel samples = MultiSamplingLevel::x1, ResourceUsage usage = ResourceUsage::FrameBufferImage) -> TSelf&& {
8048 std::ranges::for_each(renderTargets, [&](auto& renderTarget) { self.addImage(renderTarget.name(), renderTarget, samples, usage); });
8049 return std::forward<TSelf>(self);
8050 }
8051
8056 virtual void resize(const Size2d& renderArea) = 0;
8057
8058 private:
8059 virtual Enumerable<const IImage&> getImages() const = 0;
8060 };
8061
8065 class LITEFX_RENDERING_API IRenderPass : public virtual IStateResource, public SharedObject {
8066 public:
8071 struct BeginEventArgs : public EventArgs {
8072 private:
8073 const IFrameBuffer* m_frameBuffer;
8074
8075 public:
8076 BeginEventArgs(const IFrameBuffer& frameBuffer) noexcept :
8077 EventArgs(), m_frameBuffer(&frameBuffer) { }
8079 BeginEventArgs(BeginEventArgs&&) noexcept = default;
8080 BeginEventArgs& operator=(const BeginEventArgs&) = default;
8081 BeginEventArgs& operator=(BeginEventArgs&&) noexcept = default;
8082 ~BeginEventArgs() noexcept override = default;
8083
8084 public:
8089 inline const IFrameBuffer& frameBuffer() const noexcept {
8090 return *m_frameBuffer;
8091 }
8092 };
8093
8094 protected:
8095 IRenderPass() noexcept = default;
8096 IRenderPass(IRenderPass&&) noexcept = default;
8097 IRenderPass(const IRenderPass&) = delete;
8098 IRenderPass& operator=(IRenderPass&&) noexcept = default;
8099 IRenderPass& operator=(const IRenderPass&) = delete;
8100
8101 public:
8102 ~IRenderPass() noexcept override = default;
8103
8104 public:
8109 mutable Event<BeginEventArgs> beginning;
8110
8115 mutable Event<EventArgs> ending;
8116
8117 public:
8122 //virtual const IGraphicsDevice& device() const noexcept;
8123
8134 inline SharedPtr<const IFrameBuffer> activeFrameBuffer() const noexcept {
8135 return this->getActiveFrameBuffer();
8136 }
8137
8142 inline const ICommandQueue& commandQueue() const noexcept {
8143 return this->getCommandQueue();
8144 }
8145
8155 return this->getCommandBuffers();
8156 }
8157
8167 return this->getCommandBuffer(index);
8168 }
8169
8174 virtual UInt32 secondaryCommandBuffers() const noexcept = 0;
8175
8184 virtual const Array<RenderTarget>& renderTargets() const noexcept = 0;
8185
8191 virtual const RenderTarget& renderTarget(UInt32 location) const = 0;
8192
8198 virtual bool hasPresentTarget() const noexcept = 0;
8199
8204 virtual const Array<RenderPassDependency>& inputAttachments() const noexcept = 0;
8205
8211 virtual const RenderPassDependency& inputAttachment(UInt32 location) const = 0;
8212
8220 virtual const Optional<DescriptorBindingPoint>& inputAttachmentSamplerBinding() const noexcept = 0;
8221
8226 inline void begin(const IFrameBuffer& frameBuffer) const {
8227 this->beginRenderPass(frameBuffer);
8228 };
8229
8237 virtual UInt64 end() const = 0;
8238
8239 private:
8240 virtual SharedPtr<const IFrameBuffer> getActiveFrameBuffer() const noexcept = 0;
8241 virtual void beginRenderPass(const IFrameBuffer& frameBuffer) const = 0;
8242 virtual const ICommandQueue& getCommandQueue() const noexcept = 0;
8243 virtual SharedPtr<const ICommandBuffer> getCommandBuffer(UInt32 index) const noexcept = 0;
8244 virtual Enumerable<SharedPtr<const ICommandBuffer>> getCommandBuffers() const = 0;
8245 };
8246
8250 class LITEFX_RENDERING_API ISwapChain {
8251 public:
8255 struct ResetEventArgs : public EventArgs {
8256 private:
8257 Format m_surfaceFormat;
8258 Size2d m_renderArea;
8259 UInt32 m_buffers;
8260 bool m_vsync;
8261
8262 public:
8263 ResetEventArgs(Format surfaceFormat, Size2d renderArea, UInt32 buffers, bool enableVsync) noexcept :
8264 EventArgs(), m_surfaceFormat(surfaceFormat), m_renderArea(std::move(renderArea)), m_buffers(buffers), m_vsync(enableVsync) { }
8266 ResetEventArgs(ResetEventArgs&&) noexcept = default;
8267 ResetEventArgs& operator=(const ResetEventArgs&) = default;
8268 ResetEventArgs& operator=(ResetEventArgs&&) noexcept = default;
8269 ~ResetEventArgs() noexcept override = default;
8270
8271 public:
8276 inline Format surfaceFormat() const noexcept {
8277 return m_surfaceFormat;
8278 }
8279
8284 inline const Size2d& renderArea() const noexcept {
8285 return m_renderArea;
8286 }
8287
8292 inline UInt32 buffers() const noexcept {
8293 return m_buffers;
8294 }
8295
8300 inline bool enableVsync() const noexcept {
8301 return m_vsync;
8302 }
8303 };
8304
8305 protected:
8306 ISwapChain() noexcept = default;
8307 ISwapChain(ISwapChain&&) noexcept = default;
8308 ISwapChain(const ISwapChain&) = default;
8309 ISwapChain& operator=(const ISwapChain&) = default;
8310 ISwapChain& operator=(ISwapChain&&) noexcept = default;
8311
8312 public:
8313 virtual ~ISwapChain() noexcept = default;
8314
8315 public:
8325 [[nodiscard]] inline SharedPtr<const TimingEvent> registerTimingEvent(StringView name = "") {
8326 auto timingEvent = TimingEvent::create(*this, name);
8327 this->addTimingEvent(timingEvent);
8328 return timingEvent;
8329 }
8330
8336
8343
8355
8363
8369 virtual const IGraphicsDevice& device() const = 0;
8370
8371 public:
8376 virtual Format surfaceFormat() const noexcept = 0;
8377
8382 virtual UInt32 buffers() const noexcept = 0;
8383
8388 virtual const Size2d& renderArea() const noexcept = 0;
8389
8394 virtual bool verticalSynchronization() const noexcept = 0;
8395
8401 virtual IImage* image(UInt32 backBuffer) const = 0;
8402
8407 virtual const IImage& image() const noexcept = 0;
8408
8413 inline Enumerable<IImage&> images() const {
8414 return this->getImages();
8415 };
8416
8427 virtual void present(UInt64 fence) const = 0;
8428
8429 public:
8435
8441
8449
8465 virtual void reset(Format surfaceFormat, const Size2d& renderArea, UInt32 buffers, bool enableVsync = false) = 0;
8466
8471 [[nodiscard]] virtual UInt32 swapBackBuffer() const = 0;
8472
8473 private:
8474 virtual Enumerable<IImage&> getImages() const = 0;
8475 virtual void addTimingEvent(SharedPtr<const TimingEvent> timingEvent) = 0;
8476 };
8477
8481 class LITEFX_RENDERING_API ICommandQueue : public SharedObject {
8482 public:
8487 private:
8488 Array<SharedPtr<const ICommandBuffer>> m_commandBuffers;
8489
8490 public:
8492 EventArgs(), m_commandBuffers(std::move(commandBuffers)) { }
8493
8497 QueueSubmittingEventArgs& operator=(QueueSubmittingEventArgs&&) noexcept = default;
8498 ~QueueSubmittingEventArgs() noexcept override = default;
8499
8500 public:
8505 inline const Array<SharedPtr<const ICommandBuffer>>& commandBuffers() const noexcept {
8506 return m_commandBuffers;
8507 }
8508 };
8509
8514 private:
8515 UInt64 m_fence;
8516
8517 public:
8519 EventArgs(), m_fence(fence) { }
8523 QueueSubmittedEventArgs& operator=(QueueSubmittedEventArgs&&) noexcept = default;
8524 ~QueueSubmittedEventArgs() noexcept override = default;
8525
8526 public:
8531 inline UInt64 fence() const noexcept {
8532 return m_fence;
8533 }
8534 };
8535
8536 protected:
8537 ICommandQueue() noexcept = default;
8538 ICommandQueue(const ICommandQueue&) = default;
8539 ICommandQueue(ICommandQueue&&) noexcept = default;
8540 ICommandQueue& operator=(const ICommandQueue&) = default;
8541 ICommandQueue& operator=(ICommandQueue&&) noexcept = default;
8542
8543 public:
8544 ~ICommandQueue() noexcept override = default;
8545
8546 public:
8551 virtual QueuePriority priority() const noexcept = 0;
8552
8557 virtual QueueType type() const noexcept = 0;
8558
8559 public:
8565 static constexpr Vectors::ByteVector3 DEFAULT_DEBUG_COLOR = { 128_b, 128_b, 128_b };
8566
8575 virtual void beginDebugRegion([[maybe_unused]] const String& label, [[maybe_unused]] const Vectors::ByteVector3& color = DEFAULT_DEBUG_COLOR) const noexcept { };
8576
8583 virtual void endDebugRegion() const noexcept { };
8584
8593 virtual void setDebugMarker([[maybe_unused]] const String& label, [[maybe_unused]] const Vectors::ByteVector3& color = DEFAULT_DEBUG_COLOR) const noexcept { };
8594
8595 public:
8600
8605
8619 inline SharedPtr<ICommandBuffer> createCommandBuffer(bool beginRecording = false, bool secondary = false) const {
8620 return this->getCommandBuffer(beginRecording, secondary);
8621 }
8622
8635 inline UInt64 submit(const SharedPtr<const ICommandBuffer>& commandBuffer) const {
8636 return this->submitCommandBuffer(commandBuffer);
8637 }
8638
8651 inline UInt64 submit(const SharedPtr<ICommandBuffer>& commandBuffer) const {
8652 return this->submitCommandBuffer(commandBuffer);
8653 }
8654
8668 return this->submitCommandBuffers(std::move(commandBuffers));
8669 }
8670
8679 virtual void waitFor(UInt64 fence) const = 0;
8680
8690 inline void waitFor(const ICommandQueue& queue, UInt64 fence) const {
8691 this->waitForQueue(queue, fence);
8692 }
8693
8699 virtual UInt64 currentFence() const noexcept = 0;
8700
8701 private:
8702 virtual SharedPtr<ICommandBuffer> getCommandBuffer(bool beginRecording, bool secondary) const = 0;
8703 virtual UInt64 submitCommandBuffer(const SharedPtr<const ICommandBuffer>& commandBuffer) const = 0;
8704 virtual UInt64 submitCommandBuffers(Enumerable<SharedPtr<const ICommandBuffer>> commandBuffers) const = 0;
8705 virtual void waitForQueue(const ICommandQueue& queue, UInt64 fence) const = 0;
8706
8707 protected:
8708 inline void releaseSharedState(const ICommandBuffer& commandBuffer) const {
8709 commandBuffer.releaseSharedState();
8710 }
8711 };
8712
8716 class LITEFX_RENDERING_API IGraphicsFactory : public SharedObject {
8717 protected:
8718 IGraphicsFactory() noexcept = default;
8719 IGraphicsFactory(IGraphicsFactory&&) noexcept = default;
8721 IGraphicsFactory& operator=(const IGraphicsFactory&) = default;
8722 IGraphicsFactory& operator=(IGraphicsFactory&&) noexcept = default;
8723
8724 public:
8725 ~IGraphicsFactory() noexcept override = default;
8726
8727 public:
8737 inline SharedPtr<IBuffer> createBuffer(BufferType type, ResourceHeap heap, size_t elementSize, UInt32 elements = 1, ResourceUsage usage = ResourceUsage::Default) const {
8738 return this->getBuffer(type, heap, elementSize, elements, usage);
8739 };
8740
8750 inline SharedPtr<IBuffer> createBuffer(const IDescriptorSetLayout& descriptorSet, UInt32 binding, ResourceHeap heap, UInt32 elements = 1, ResourceUsage usage = ResourceUsage::Default) const {
8751 auto& descriptor = descriptorSet.descriptor(binding);
8752 return this->createBuffer(descriptor.type(), heap, descriptor.elementSize(), elements, usage);
8753 };
8754
8764 inline SharedPtr<IBuffer> createBuffer(const IDescriptorSetLayout& descriptorSet, UInt32 binding, ResourceHeap heap, UInt32 elementSize, UInt32 elements, ResourceUsage usage = ResourceUsage::Default) const {
8765 auto& descriptor = descriptorSet.descriptor(binding);
8766 return this->createBuffer(descriptor.type(), heap, elementSize, elements, usage);
8767 };
8768
8779 inline SharedPtr<IBuffer> createBuffer(const IPipeline& pipeline, UInt32 space, UInt32 binding, ResourceHeap heap, UInt32 elementSize, UInt32 elements, ResourceUsage usage = ResourceUsage::Default) const {
8780 return this->createBuffer(pipeline.layout()->descriptorSet(space), binding, heap, elementSize, elements, usage);
8781 };
8782
8793 inline SharedPtr<IBuffer> createBuffer(const IPipeline& pipeline, UInt32 space, UInt32 binding, ResourceHeap heap, UInt32 elements = 1, ResourceUsage usage = ResourceUsage::Default) const {
8794 return this->createBuffer(pipeline.layout()->descriptorSet(space), binding, heap, elements, usage);
8795 };
8796
8807 inline SharedPtr<IBuffer> createBuffer(const String& name, BufferType type, ResourceHeap heap, size_t elementSize, UInt32 elements, ResourceUsage usage = ResourceUsage::Default) const {
8808 return this->getBuffer(name, type, heap, elementSize, elements, usage);
8809 };
8810
8821 inline SharedPtr<IBuffer> createBuffer(const String& name, const IDescriptorSetLayout& descriptorSet, UInt32 binding, ResourceHeap heap, UInt32 elements = 1, ResourceUsage usage = ResourceUsage::Default) const {
8822 auto& descriptor = descriptorSet.descriptor(binding);
8823 return this->createBuffer(name, descriptor.type(), heap, descriptor.elementSize(), elements, usage);
8824 };
8825
8837 inline SharedPtr<IBuffer> createBuffer(const String& name, const IDescriptorSetLayout& descriptorSet, UInt32 binding, ResourceHeap heap, size_t elementSize, UInt32 elements, ResourceUsage usage = ResourceUsage::Default) const {
8838 auto& descriptor = descriptorSet.descriptor(binding);
8839 return this->createBuffer(name, descriptor.type(), heap, elementSize, elements, usage);
8840 };
8841
8853 inline SharedPtr<IBuffer> createBuffer(const String& name, const IPipeline& pipeline, UInt32 space, UInt32 binding, ResourceHeap heap, UInt32 elements = 1, ResourceUsage usage = ResourceUsage::Default) const {
8854 return this->createBuffer(name, pipeline.layout()->descriptorSet(space), binding, heap, elements, usage);
8855 };
8856
8869 inline SharedPtr<IBuffer> createBuffer(const String& name, const IPipeline& pipeline, UInt32 space, UInt32 binding, ResourceHeap heap, size_t elementSize, UInt32 elements = 1, ResourceUsage usage = ResourceUsage::Default) const {
8870 return this->createBuffer(name, pipeline.layout()->descriptorSet(space), binding, heap, elementSize, elements, usage);
8871 };
8872
8886 inline SharedPtr<IVertexBuffer> createVertexBuffer(const IVertexBufferLayout& layout, ResourceHeap heap, UInt32 elements = 1, ResourceUsage usage = ResourceUsage::Default) const {
8887 return this->getVertexBuffer(layout, heap, elements, usage);
8888 }
8889
8904 inline SharedPtr<IVertexBuffer> createVertexBuffer(const String& name, const IVertexBufferLayout& layout, ResourceHeap heap, UInt32 elements = 1, ResourceUsage usage = ResourceUsage::Default) const {
8905 return this->getVertexBuffer(name, layout, heap, elements, usage);
8906 }
8907
8921 inline SharedPtr<IIndexBuffer> createIndexBuffer(const IIndexBufferLayout& layout, ResourceHeap heap, UInt32 elements, ResourceUsage usage = ResourceUsage::Default) const {
8922 return this->getIndexBuffer(layout, heap, elements, usage);
8923 }
8924
8939 inline SharedPtr<IIndexBuffer> createIndexBuffer(const String& name, const IIndexBufferLayout& layout, ResourceHeap heap, UInt32 elements, ResourceUsage usage = ResourceUsage::Default) const {
8940 return this->getIndexBuffer(name, layout, heap, elements, usage);
8941 }
8942
8959 inline SharedPtr<IImage> createTexture(Format format, const Size3d& size, ImageDimensions dimension = ImageDimensions::DIM_2, UInt32 levels = 1, UInt32 layers = 1, MultiSamplingLevel samples = MultiSamplingLevel::x1, ResourceUsage usage = ResourceUsage::Default) const {
8960 return this->getTexture(format, size, dimension, levels, layers, samples, usage);
8961 }
8962
8980 inline SharedPtr<IImage> createTexture(const String& name, Format format, const Size3d& size, ImageDimensions dimension = ImageDimensions::DIM_2, UInt32 levels = 1, UInt32 layers = 1, MultiSamplingLevel samples = MultiSamplingLevel::x1, ResourceUsage usage = ResourceUsage::Default) const {
8981 return this->getTexture(name, format, size, dimension, levels, layers, samples, usage);
8982 }
8983
8995 inline Generator<SharedPtr<IImage>> createTextures(Format format, const Size3d& size, ImageDimensions dimension = ImageDimensions::DIM_2, UInt32 layers = 1, UInt32 levels = 1, MultiSamplingLevel samples = MultiSamplingLevel::x1, ResourceUsage usage = ResourceUsage::Default) const {
8996 return this->getTextures(format, size, dimension, layers, levels, samples, usage);
8997 }
8998
9014 inline SharedPtr<ISampler> createSampler(FilterMode magFilter = FilterMode::Nearest, FilterMode minFilter = FilterMode::Nearest, BorderMode borderU = BorderMode::Repeat, BorderMode borderV = BorderMode::Repeat, BorderMode borderW = BorderMode::Repeat, MipMapMode mipMapMode = MipMapMode::Nearest, Float mipMapBias = 0.f, Float maxLod = std::numeric_limits<Float>::max(), Float minLod = 0.f, Float anisotropy = 0.f) const {
9015 return this->getSampler(magFilter, minFilter, borderU, borderV, borderW, mipMapMode, mipMapBias, maxLod, minLod, anisotropy);
9016 }
9017
9034 inline SharedPtr<ISampler> createSampler(const String& name, FilterMode magFilter = FilterMode::Nearest, FilterMode minFilter = FilterMode::Nearest, BorderMode borderU = BorderMode::Repeat, BorderMode borderV = BorderMode::Repeat, BorderMode borderW = BorderMode::Repeat, MipMapMode mipMapMode = MipMapMode::Nearest, Float mipMapBias = 0.f, Float maxLod = std::numeric_limits<Float>::max(), Float minLod = 0.f, Float anisotropy = 0.f) const {
9035 return this->getSampler(name, magFilter, minFilter, borderU, borderV, borderW, mipMapMode, mipMapBias, maxLod, minLod, anisotropy);
9036 }
9037
9053 inline Generator<SharedPtr<ISampler>> createSamplers(FilterMode magFilter = FilterMode::Nearest, FilterMode minFilter = FilterMode::Nearest, BorderMode borderU = BorderMode::Repeat, BorderMode borderV = BorderMode::Repeat, BorderMode borderW = BorderMode::Repeat, MipMapMode mipMapMode = MipMapMode::Nearest, Float mipMapBias = 0.f, Float maxLod = std::numeric_limits<Float>::max(), Float minLod = 0.f, Float anisotropy = 0.f) const {
9054 return this->getSamplers(magFilter, minFilter, borderU, borderV, borderW, mipMapMode, mipMapBias, maxLod, minLod, anisotropy);
9055 }
9056
9067 return this->createBottomLevelAccelerationStructure("", flags);
9068 }
9069
9081 return this->getBlas(name, flags);
9082 }
9083
9094 return this->createTopLevelAccelerationStructure("", flags);
9095 }
9096
9108 return this->getTlas(name, flags);
9109 }
9110
9111 private:
9112 virtual SharedPtr<IBuffer> getBuffer(BufferType type, ResourceHeap heap, size_t elementSize, UInt32 elements, ResourceUsage usage) const = 0;
9113 virtual SharedPtr<IBuffer> getBuffer(const String& name, BufferType type, ResourceHeap heap, size_t elementSize, UInt32 elements, ResourceUsage usage) const = 0;
9114 virtual SharedPtr<IVertexBuffer> getVertexBuffer(const IVertexBufferLayout& layout, ResourceHeap heap, UInt32 elements, ResourceUsage usage) const = 0;
9115 virtual SharedPtr<IVertexBuffer> getVertexBuffer(const String& name, const IVertexBufferLayout& layout, ResourceHeap heap, UInt32 elements, ResourceUsage usage) const = 0;
9116 virtual SharedPtr<IIndexBuffer> getIndexBuffer(const IIndexBufferLayout& layout, ResourceHeap heap, UInt32 elements, ResourceUsage usage) const = 0;
9117 virtual SharedPtr<IIndexBuffer> getIndexBuffer(const String& name, const IIndexBufferLayout& layout, ResourceHeap heap, UInt32 elements, ResourceUsage usage) const = 0;
9118 virtual SharedPtr<IImage> getTexture(Format format, const Size3d& size, ImageDimensions dimension, UInt32 levels, UInt32 layers, MultiSamplingLevel samples, ResourceUsage usage) const = 0;
9119 virtual SharedPtr<IImage> getTexture(const String& name, Format format, const Size3d& size, ImageDimensions dimension, UInt32 levels, UInt32 layers, MultiSamplingLevel samples, ResourceUsage usage) const = 0;
9120 virtual Generator<SharedPtr<IImage>> getTextures(Format format, const Size3d& size, ImageDimensions dimension, UInt32 layers, UInt32 levels, MultiSamplingLevel samples, ResourceUsage usage) const = 0;
9121 virtual SharedPtr<ISampler> getSampler(FilterMode magFilter, FilterMode minFilter, BorderMode borderU, BorderMode borderV, BorderMode borderW, MipMapMode mipMapMode, Float mipMapBias, Float maxLod, Float minLod, Float anisotropy) const = 0;
9122 virtual SharedPtr<ISampler> getSampler(const String& name, FilterMode magFilter, FilterMode minFilter, BorderMode borderU, BorderMode borderV, BorderMode borderW, MipMapMode mipMapMode, Float mipMapBias, Float maxLod, Float minLod, Float anisotropy) const = 0;
9123 virtual Generator<SharedPtr<ISampler>> getSamplers(FilterMode magFilter, FilterMode minFilter, BorderMode borderU, BorderMode borderV, BorderMode borderW, MipMapMode mipMapMode, Float mipMapBias, Float maxLod, Float minLod, Float anisotropy) const = 0;
9126 };
9127
9138 struct LITEFX_RENDERING_API GraphicsDeviceFeatures {
9139 public:
9143 bool MeshShaders { false };
9144
9148 bool RayTracing { false };
9149
9153 bool RayQueries { false };
9154
9158 bool DrawIndirect { false };
9159 };
9160
9164 class LITEFX_RENDERING_API IGraphicsDevice : public SharedObject {
9165 protected:
9166 IGraphicsDevice() noexcept = default;
9167 IGraphicsDevice(IGraphicsDevice&&) noexcept = default;
9169 IGraphicsDevice& operator=(const IGraphicsDevice&) = default;
9170 IGraphicsDevice& operator=(IGraphicsDevice&&) noexcept = default;
9171
9172 public:
9173 ~IGraphicsDevice() noexcept override = default;
9174
9175 public:
9180 virtual DeviceState& state() const noexcept = 0;
9181
9186 virtual const ISurface& surface() const noexcept = 0;
9187
9192 virtual const IGraphicsAdapter& adapter() const noexcept = 0;
9193
9198 virtual const ISwapChain& swapChain() const noexcept = 0;
9199
9204 virtual ISwapChain& swapChain() noexcept = 0;
9205
9210 virtual const IGraphicsFactory& factory() const noexcept = 0;
9211
9225 inline const ICommandQueue& defaultQueue(QueueType type) const {
9226 return this->getDefaultQueue(type);
9227 }
9228
9247 inline SharedPtr<const ICommandQueue> createQueue(QueueType type, QueuePriority priority = QueuePriority::Normal) {
9248 return this->getNewQueue(type, priority);
9249 }
9250
9257 [[nodiscard]] inline UniquePtr<IBarrier> makeBarrier(PipelineStage syncBefore, PipelineStage syncAfter) const {
9258 return this->getNewBarrier(syncBefore, syncAfter);
9259 }
9260
9266 [[nodiscard]] inline SharedPtr<IFrameBuffer> makeFrameBuffer(const Size2d& renderArea) const {
9267 return this->makeFrameBuffer("", renderArea);
9268 }
9269
9276 [[nodiscard]] inline SharedPtr<IFrameBuffer> makeFrameBuffer(StringView name, const Size2d& renderArea) const {
9277 return this->getNewFrameBuffer(name, renderArea);
9278 }
9279
9289 virtual MultiSamplingLevel maximumMultiSamplingLevel(Format format) const noexcept = 0;
9290
9296 virtual double ticksPerMillisecond() const noexcept = 0;
9297
9312 inline void computeAccelerationStructureSizes(const IBottomLevelAccelerationStructure& blas, UInt64& bufferSize, UInt64& scratchSize, bool forUpdate = false) const {
9313 this->getAccelerationStructureSizes(blas, bufferSize, scratchSize, forUpdate);
9314 }
9315
9330 inline void computeAccelerationStructureSizes(const ITopLevelAccelerationStructure& tlas, UInt64& bufferSize, UInt64& scratchSize, bool forUpdate = false) const {
9331 this->getAccelerationStructureSizes(tlas, bufferSize, scratchSize, forUpdate);
9332 }
9333
9334 private:
9335 virtual void getAccelerationStructureSizes(const IBottomLevelAccelerationStructure& blas, UInt64& bufferSize, UInt64& scratchSize, bool forUpdate) const = 0;
9336 virtual void getAccelerationStructureSizes(const ITopLevelAccelerationStructure& tlas, UInt64& bufferSize, UInt64& scratchSize, bool forUpdate) const = 0;
9337
9338 public:
9346 virtual void wait() const = 0;
9347
9348 private:
9349 virtual UniquePtr<IBarrier> getNewBarrier(PipelineStage syncBefore, PipelineStage syncAfter) const = 0;
9350 virtual SharedPtr<IFrameBuffer> getNewFrameBuffer(StringView name, const Size2d& renderArea) const = 0;
9351 virtual const ICommandQueue& getDefaultQueue(QueueType type) const = 0;
9352 virtual SharedPtr<const ICommandQueue> getNewQueue(QueueType type, QueuePriority priority) = 0;
9353 };
9354
9358 class LITEFX_RENDERING_API IRenderBackend : public IBackend {
9359 protected:
9360 IRenderBackend() noexcept = default;
9361 IRenderBackend(IRenderBackend&&) noexcept = default;
9363 IRenderBackend& operator=(const IRenderBackend&) = default;
9364 IRenderBackend& operator=(IRenderBackend&&) noexcept = default;
9365
9366 public:
9367 ~IRenderBackend() noexcept override = default;
9368
9369 public:
9374 inline Enumerable<SharedPtr<const IGraphicsAdapter>> listAdapters() const {
9375 return this->getAdapters();
9376 }
9377
9389 virtual const IGraphicsAdapter* findAdapter(const Optional<UInt64>& adapterId = std::nullopt) const noexcept = 0;
9390
9396 virtual IGraphicsDevice* device(const String& name) noexcept = 0;
9397
9403 virtual const IGraphicsDevice* device(const String& name) const noexcept = 0;
9404
9410 virtual inline const IGraphicsDevice* operator[](const String& name) const noexcept {
9411 return this->device(name);
9412 };
9413
9419 virtual inline IGraphicsDevice* operator[](const String& name) noexcept {
9420 return this->device(name);
9421 };
9422
9423 private:
9424 virtual Enumerable<SharedPtr<const IGraphicsAdapter>> getAdapters() const = 0;
9425 };
9426
9430 template <typename T>
9432
9433}
An exception that is thrown, if a provided non-optional argument was not initialized.
Definition exceptions.hpp:185
Base class for additional event arguments.
Definition app.hpp:86
A class that is used to declare an event, which a number of listeners can subscribe to.
Definition app.hpp:168
The base class for an app backend.
Definition app.hpp:18
An exception that is thrown, if a provided argument is not valid.
Definition exceptions.hpp:60
Definition math.hpp:926
Definition math.hpp:850
Definition math.hpp:819
Definition math.hpp:490
Definition math.hpp:534
Stores meta data about a buffer attribute, i.e. a member or field of a descriptor or buffer.
Definition rendering_api.hpp:3792
virtual ~BufferAttribute() noexcept
Releases the buffer attribute instance.
BufferAttribute & operator=(const BufferAttribute &_other)
Assigns a buffer attribute by copying it.
BufferAttribute(const BufferAttribute &_other)
Creates a copy of a buffer attribute.
BufferAttribute(BufferAttribute &&_other) noexcept
Takes over another instance of a buffer attribute.
BufferAttribute & operator=(BufferAttribute &&_other) noexcept
Assigns a buffer attribute by taking it over.
Stores the depth/stencil state of a see IRasterizer.
Definition rendering_api.hpp:3143
DepthStencilState() noexcept
Initializes a new rasterizer depth/stencil state.
A class that can be used to manage the state of a IGraphicsDevice.
Definition rendering_api.hpp:2312
DeviceState(DeviceState &&_other) noexcept
Takes over another instance of a device state.
DeviceState()
Creates a new device state instance.
DeviceState & operator=(DeviceState &&_other) noexcept
Assigns a device state by taking it over.
Base interface for a ray tracing acceleration structure.
Definition rendering_api.hpp:4449
void update(const ICommandBuffer &commandBuffer, const SharedPtr< const IBuffer > &scratchBuffer=nullptr, const SharedPtr< const IBuffer > &buffer=nullptr, UInt64 offset=0, UInt64 maxSize=0)
Performs an update on the acceleration structure.
Definition rendering_api.hpp:4530
SharedPtr< const IBuffer > buffer() const noexcept
Returns the acceleration structure backing buffer, that stores its last build.
Definition rendering_api.hpp:4540
virtual UInt64 offset() const noexcept=0
Returns the offset into buffer at which the acceleration structure is stored.
The interface for a barrier.
Definition rendering_api.hpp:5110
constexpr void transition(const IImage &image, UInt32 level, UInt32 levels, UInt32 layer, UInt32 layers, UInt32 plane, ResourceAccess accessBefore, ResourceAccess accessAfter, ImageLayout layout)
Inserts an image barrier that blocks access to a sub-resource range of image of the types contained ...
Definition rendering_api.hpp:5196
constexpr void transition(const IImage &image, UInt32 level, UInt32 levels, UInt32 layer, UInt32 layers, UInt32 plane, ResourceAccess accessBefore, ResourceAccess accessAfter, ImageLayout fromLayout, ImageLayout toLayout)
Inserts an image barrier that blocks access to a sub-resource range of image of the types contained ...
Definition rendering_api.hpp:5237
constexpr void transition(const IImage &image, ResourceAccess accessBefore, ResourceAccess accessAfter, ImageLayout layout)
Inserts an image barrier that blocks access to all sub-resources of image of the types contained in ...
Definition rendering_api.hpp:5178
IBarrier() noexcept=default
constexpr void transition(const IBuffer &buffer, UInt32 element, ResourceAccess accessBefore, ResourceAccess accessAfter)
Inserts a buffer barrier that blocks access to a buffer s element of types contained in accessAfter ...
Definition rendering_api.hpp:5165
constexpr void transition(const IImage &image, ResourceAccess accessBefore, ResourceAccess accessAfter, ImageLayout fromLayout, ImageLayout toLayout)
Inserts an image barrier that blocks access to all sub-resources of image of the types contained in ...
Definition rendering_api.hpp:5214
A structure that holds a singular entity of geometry for hardware ray-tracing.
Definition rendering_api.hpp:4588
virtual void clear() noexcept=0
Clears all bounding boxes and triangle meshes from the acceleration structure.
auto withBoundingBox(this TSelf &&self, const SharedPtr< const IBuffer > &buffer, GeometryFlags flags=GeometryFlags::None) -> TSelf &&
Adds a buffer containing axis-aligned bounding boxes to the BLAS.
Definition rendering_api.hpp:4858
auto withTriangleMesh(this TSelf &&self, const TriangleMesh &mesh) -> TSelf &&
Adds a triangle mesh to the BLAS.
Definition rendering_api.hpp:4819
auto withTriangleMesh(this TSelf &&self, const SharedPtr< const IVertexBuffer > &vertexBuffer, const SharedPtr< const IIndexBuffer > &indexBuffer=nullptr, const SharedPtr< const IBuffer > &transformBuffer=nullptr, GeometryFlags flags=GeometryFlags::None) -> TSelf &&
Adds a triangle mesh to the BLAS.
Definition rendering_api.hpp:4834
auto withBoundingBox(this TSelf &&self, const BoundingBoxes &aabb) -> TSelf &&
Adds a buffer containing axis-aligned bounding boxes to the BLAS.
Definition rendering_api.hpp:4845
virtual const Array< BoundingBoxes > & boundingBoxes() const noexcept=0
Returns an array of buffers, each containing axis-aligned bounding boxes stored in the BLAS.
Base interface for buffer objects.
Definition rendering_api.hpp:4186
IBuffer() noexcept=default
Describes a buffer layout.
Definition rendering_api.hpp:3891
IBufferLayout() noexcept=default
The interface for a command buffer.
Definition rendering_api.hpp:6517
virtual UInt64 submit() const =0
Submits the command buffer to parent command.
void traceRays(UInt32 width, UInt32 height, UInt32 depth, const ShaderBindingTableOffsets &offsets, const IBuffer &rayGenerationShaderBindingTable, const IBuffer *missShaderBindingTable=nullptr, const IBuffer *hitShaderBindingTable=nullptr, const IBuffer *callableShaderBindingTable=nullptr) const noexcept
Executes a query on a ray-tracing pipeline.
Definition rendering_api.hpp:7178
virtual void setBlendFactors(const Vector4f &blendFactors) const noexcept=0
Sets the blend factors for the subsequent draw calls.
void updateAccelerationStructure(ITopLevelAccelerationStructure &tlas, const SharedPtr< const IBuffer > &scratchBuffer, const IBuffer &buffer, UInt64 offset=0) const
Updates a top-level acceleration structure.
Definition rendering_api.hpp:7449
void drawIndirect(const IBuffer &batchBuffer, const IBuffer &countBuffer, UInt64 offset=0, UInt64 countOffset=0, UInt32 maxBatches=std::numeric_limits< UInt32 >::max()) const noexcept
Executes a set of indirect non-indexed draw calls.
Definition rendering_api.hpp:7242
void barrier(const IBarrier &barrier) const noexcept
Executes the transitions that have been added to barrier .
Definition rendering_api.hpp:6620
ICommandBuffer() noexcept=default
virtual void setViewports(const IViewport *viewport) const =0
Sets the viewport used for the subsequent draw calls.
void transfer(Span< const void *const > data, size_t elementSize, const IImage &target, UInt32 firstSubresource=0, UInt32 elements=1) const
Performs a buffer-to-buffer transfer from a temporary buffer into target .
Definition rendering_api.hpp:6814
void bind(const IDescriptorSet &descriptorSet) const
Binds the provided descriptor to the last pipeline that was used by the command buffer.
Definition rendering_api.hpp:6957
void pushConstants(const IPushConstantsLayout &layout, const void *const memory) const
Pushes a block of memory into the push constants backing memory.
Definition rendering_api.hpp:7317
void bind(this const TSelf &self, std::ranges::input_range auto &&descriptorSets, const typename TSelf::pipeline_type &pipeline)
Binds an arbitrary input range of descriptor sets to the provided pipeline.
Definition rendering_api.hpp:7043
void buildAccelerationStructure(ITopLevelAccelerationStructure &tlas, const SharedPtr< const IBuffer > &scratchBuffer, const IBuffer &buffer, UInt64 offset=0) const
Builds a top-level acceleration structure.
Definition rendering_api.hpp:7417
void transfer(const void *const data, size_t size, const IImage &target, UInt32 subresource=0) const
Performs a buffer-to-buffer transfer from a temporary buffer into target .
Definition rendering_api.hpp:6797
void dispatchMesh(UInt32 x, UInt32 y, UInt32 z) const noexcept
Executes a mesh shader pipeline.
Definition rendering_api.hpp:7136
void transfer(const IBuffer &source, const IBuffer &target, UInt32 sourceElement=0, UInt32 targetElement=0, UInt32 elements=1) const
Performs a buffer-to-buffer transfer from source to target .
Definition rendering_api.hpp:6638
virtual void drawIndexed(UInt32 indices, UInt32 instances=1, UInt32 firstIndex=0, Int32 vertexOffset=0, UInt32 firstInstance=0) const noexcept=0
Draws the currently bound vertex buffer with a set of indices from the currently bound index buffer.
void copyAccelerationStructure(const ITopLevelAccelerationStructure &from, const ITopLevelAccelerationStructure &to, bool compress=false) const noexcept
Copies the acceleration structure from into the acceleration structure to .
Definition rendering_api.hpp:7483
virtual void dispatchMesh(const Vector3u &threadGroupCount) const noexcept=0
Executes a mesh shader pipeline.
virtual void writeTimingEvent(const SharedPtr< const TimingEvent > &timingEvent) const =0
Writes the current GPU time stamp value for the timing event.
void bind(const IVertexBuffer &buffer) const
Binds a vertex buffer to the pipeline.
Definition rendering_api.hpp:7073
void execute(const SharedPtr< const ICommandBuffer > &commandBuffer) const
Executes a secondary command buffer/bundle.
Definition rendering_api.hpp:7377
void updateAccelerationStructure(IBottomLevelAccelerationStructure &blas, const SharedPtr< const IBuffer > &scratchBuffer, const IBuffer &buffer, UInt64 offset=0) const
Updates a bottom-level acceleration structure.
Definition rendering_api.hpp:7433
void transfer(const SharedPtr< const IImage > &source, const IBuffer &target, UInt32 firstSubresource=0, UInt32 targetElement=0, UInt32 subresources=1) const
Performs an image-to-buffer transfer from source to target .
Definition rendering_api.hpp:6940
void drawIndexed(const IVertexBuffer &vertexBuffer, const IIndexBuffer &indexBuffer, UInt32 instances=1, UInt32 firstIndex=0, Int32 vertexOffset=0, UInt32 firstInstance=0) const
Draws the vertex buffer provided by vertexBuffer using the index buffer, provided by indexBuffer .
Definition rendering_api.hpp:7284
virtual void releaseSharedState() const =0
Called by the parent command queue to signal that the command buffer should release it's shared state...
virtual void setScissors(const IScissor *scissor) const =0
Sets the scissor rectangle used for the subsequent draw calls.
void bind(this const TSelf &self, std::ranges::input_range auto &&descriptorSets)
Binds an arbitrary input range of descriptor sets to the last pipeline that was used by the command b...
Definition rendering_api.hpp:6988
void transfer(const IImage &source, const IImage &target, UInt32 sourceSubresource=0, UInt32 targetSubresource=0, UInt32 subresources=1) const
Performs an image-to-image transfer from source to target .
Definition rendering_api.hpp:6831
void bind(Span< const IDescriptorSet * > descriptorSets) const
Binds an arbitrary input range of descriptor sets to the last pipeline that was used by the command b...
Definition rendering_api.hpp:7003
void transfer(const SharedPtr< const IImage > &source, const IImage &target, UInt32 sourceSubresource=0, UInt32 targetSubresource=0, UInt32 subresources=1) const
Performs an image-to-image transfer from source to target .
Definition rendering_api.hpp:6855
void transfer(const IBuffer &source, const IImage &target, UInt32 sourceElement=0, UInt32 firstSubresource=0, UInt32 elements=1) const
Performs a buffer-to-image transfer from source to target .
Definition rendering_api.hpp:6734
void execute(Enumerable< SharedPtr< const ICommandBuffer > > commandBuffers) const
Executes a series of secondary command buffers/bundles.
Definition rendering_api.hpp:7385
void use(const IPipeline &pipeline) const noexcept
Sets the active pipeline state.
Definition rendering_api.hpp:6947
void transfer(const SharedPtr< const IBuffer > &source, const IBuffer &target, UInt32 sourceElement=0, UInt32 targetElement=0, UInt32 elements=1) const
Performs a buffer-to-buffer transfer from source to target .
Definition rendering_api.hpp:6662
void copyAccelerationStructure(const IBottomLevelAccelerationStructure &from, const IBottomLevelAccelerationStructure &to, bool compress=false) const noexcept
Copies the acceleration structure from into the acceleration structure to .
Definition rendering_api.hpp:7466
virtual void dispatch(const Vector3u &threadGroupCount) const noexcept=0
Executes a compute shader.
void drawIndexedIndirect(const IBuffer &batchBuffer, UInt32 batchCount, UInt64 offset=0) const noexcept
Executes a set of indirect indexed draw calls.
Definition rendering_api.hpp:7295
void transfer(const void *const data, size_t size, const IBuffer &target, UInt32 targetElement=0, UInt32 elements=1) const
Performs a buffer-to-buffer transfer from a temporary buffer into target .
Definition rendering_api.hpp:6679
void transfer(const SharedPtr< const IBuffer > &source, const IImage &target, UInt32 sourceElement=0, UInt32 firstSubresource=0, UInt32 elements=1) const
Performs a buffer-to-image transfer from source to target .
Definition rendering_api.hpp:6780
virtual void setScissors(Span< const IScissor * > scissors) const =0
Sets the scissor rectangles used for the subsequent draw calls.
void dispatch(UInt32 x, UInt32 y, UInt32 z) const noexcept
Executes a compute shader.
Definition rendering_api.hpp:7103
void dispatchIndirect(const IBuffer &batchBuffer, UInt32 batchCount, UInt64 offset=0) const noexcept
Executes a set of indirect dispatches.
Definition rendering_api.hpp:7114
void traceRays(const Vector3u &dimensions, const ShaderBindingTableOffsets &offsets, const IBuffer &rayGenerationShaderBindingTable, const IBuffer *missShaderBindingTable=nullptr, const IBuffer *hitShaderBindingTable=nullptr, const IBuffer *callableShaderBindingTable=nullptr) const noexcept
Executes a query on a ray-tracing pipeline.
Definition rendering_api.hpp:7194
virtual void setViewports(Span< const IViewport * > viewports) const =0
Sets the viewports used for the subsequent draw calls.
void dispatchMeshIndirect(const IBuffer &batchBuffer, UInt32 batchCount, UInt64 offset=0) const noexcept
Executes a set of indirect mesh shader dispatches.
Definition rendering_api.hpp:7147
void transfer(Span< const void *const > data, size_t elementSize, const IBuffer &target, UInt32 targetElement=0) const
Performs a buffer-to-buffer transfer from a temporary buffer into target .
Definition rendering_api.hpp:6695
void drawIndirect(const IBuffer &batchBuffer, UInt32 batchCount, UInt64 offset=0) const noexcept
Executes a set of indirect non-indexed draw calls.
Definition rendering_api.hpp:7229
UniquePtr< IBarrier > makeBarrier(PipelineStage syncBefore, PipelineStage syncAfter) const
Creates a new barrier instance.
Definition rendering_api.hpp:6607
void bind(this const TSelf &self, std::initializer_list< const T * > descriptorSets, const typename TSelf::pipeline_type &pipeline)
Binds an arbitrary input range of descriptor sets to the last pipeline that was used by the command b...
Definition rendering_api.hpp:7027
void bind(Span< const IDescriptorSet * > descriptorSets, const IPipeline &pipeline) const
Binds an arbitrary input range of descriptor sets to the provided pipeline.
Definition rendering_api.hpp:7059
virtual void setStencilRef(UInt32 stencilRef) const noexcept=0
Sets the stencil reference for the subsequent draw calls.
void bind(const IDescriptorSet &descriptorSet, const IPipeline &pipeline) const
Binds the provided descriptor set to the provided pipeline.
Definition rendering_api.hpp:7012
void bind(this const TSelf &self, std::initializer_list< const T * > descriptorSets)
Binds an arbitrary input range of descriptor sets to the last pipeline that was used by the command b...
Definition rendering_api.hpp:6971
void bind(const IIndexBuffer &buffer) const
Binds a index buffer to the pipeline.
Definition rendering_api.hpp:7086
void transfer(const IImage &source, const IBuffer &target, UInt32 firstSubresource=0, UInt32 targetElement=0, UInt32 subresources=1) const
Performs an image-to-buffer transfer from source to target .
Definition rendering_api.hpp:6894
void buildAccelerationStructure(IBottomLevelAccelerationStructure &blas, const SharedPtr< const IBuffer > &scratchBuffer, const IBuffer &buffer, UInt64 offset=0) const
Builds a bottom-level acceleration structure.
Definition rendering_api.hpp:7401
virtual void draw(UInt32 vertices, UInt32 instances=1, UInt32 firstVertex=0, UInt32 firstInstance=0) const noexcept=0
Draws a number of vertices from the currently bound vertex buffer.
void drawIndexedIndirect(const IBuffer &batchBuffer, const IBuffer &countBuffer, UInt64 offset=0, UInt64 countOffset=0, UInt32 maxBatches=std::numeric_limits< UInt32 >::max()) const noexcept
Executes a set of indirect indexed draw calls.
Definition rendering_api.hpp:7308
void dispatchMeshIndirect(const IBuffer &batchBuffer, const IBuffer &countBuffer, UInt64 offset=0, UInt64 countOffset=0, UInt32 maxBatches=std::numeric_limits< UInt32 >::max()) const noexcept
Executes a set of indirect mesh shader dispatches.
Definition rendering_api.hpp:7160
The interface for a command queue.
Definition rendering_api.hpp:8481
ICommandQueue() noexcept=default
Event< QueueSubmittingEventArgs > submitting
Invoked, when one or more command buffers are submitted to the queue.
Definition rendering_api.hpp:8599
Event< QueueSubmittedEventArgs > submitted
Invoked, after one or more command buffers have been submitted to the queue.
Definition rendering_api.hpp:8604
virtual UInt64 currentFence() const noexcept=0
Returns the value of the latest fence inserted into the queue.
virtual void waitFor(UInt64 fence) const =0
Lets the CPU wait for a certain fence value to complete on the command queue.
virtual void beginDebugRegion(const String &label, const Vectors::ByteVector3 &color=DEFAULT_DEBUG_COLOR) const noexcept
Starts a new debug region.
Definition rendering_api.hpp:8575
SharedPtr< ICommandBuffer > createCommandBuffer(bool beginRecording=false, bool secondary=false) const
Creates a command buffer that can be used to allocate commands on the queue.
Definition rendering_api.hpp:8619
virtual void setDebugMarker(const String &label, const Vectors::ByteVector3 &color=DEFAULT_DEBUG_COLOR) const noexcept
Inserts a debug marker.
Definition rendering_api.hpp:8593
UInt64 submit(const SharedPtr< const ICommandBuffer > &commandBuffer) const
Submits a single command buffer with shared ownership and inserts a fence to wait for it.
Definition rendering_api.hpp:8635
UInt64 submit(Enumerable< SharedPtr< const ICommandBuffer > > commandBuffers) const
Submits a set of command buffers with shared ownership and inserts a fence to wait for them.
Definition rendering_api.hpp:8667
virtual void endDebugRegion() const noexcept
Ends the current debug region.
Definition rendering_api.hpp:8583
void waitFor(const ICommandQueue &queue, UInt64 fence) const
Lets the command queue wait for a certain fence value to complete on another queue.
Definition rendering_api.hpp:8690
UInt64 submit(const SharedPtr< ICommandBuffer > &commandBuffer) const
Submits a single command buffer with shared ownership and inserts a fence to wait for it.
Definition rendering_api.hpp:8651
The interface for a compute pipeline.
Definition rendering_api.hpp:7611
Describes a the layout of a single descriptor within a DescriptorSet.
Definition rendering_api.hpp:3993
The interface for a descriptor set.
Definition rendering_api.hpp:5253
IDescriptorSet() noexcept=default
void update(UInt32 binding, const IImage &texture, UInt32 descriptor=0, UInt32 firstLevel=0, UInt32 levels=0, UInt32 firstLayer=0, UInt32 layers=0) const
Updates one or more texture descriptors within the current descriptor set.
Definition rendering_api.hpp:5298
void update(UInt32 binding, const IAccelerationStructure &accelerationStructure, UInt32 descriptor=0) const
Updates an acceleration structure within the current descriptor set.
Definition rendering_api.hpp:5318
void update(UInt32 binding, const ISampler &sampler, UInt32 descriptor=0) const
Updates one or more sampler descriptors within the current descriptor set.
Definition rendering_api.hpp:5308
The interface for a descriptor set layout.
Definition rendering_api.hpp:5406
virtual UInt32 space() const noexcept=0
Returns the space index of the descriptor set.
UniquePtr< IDescriptorSet > allocate(Generator< DescriptorBinding > bindings) const
Definition rendering_api.hpp:5529
UniquePtr< IDescriptorSet > allocate(UInt32 descriptors, Generator< DescriptorBinding > bindings) const
Allocates an array of descriptor sets.
Definition rendering_api.hpp:5557
void free(const IDescriptorSet &descriptorSet) const
Marks a descriptor set as unused, so that it can be handed out again instead of allocating a new one.
Definition rendering_api.hpp:5625
Generator< UniquePtr< IDescriptorSet > > allocate(UInt32 descriptorSets, UInt32 descriptors, std::initializer_list< std::initializer_list< DescriptorBinding > > bindings={ }) const
Allocates an array of descriptor sets.
Definition rendering_api.hpp:5598
Generator< UniquePtr< IDescriptorSet > > allocate(UInt32 descriptorSets, std::function< Generator< DescriptorBinding >(UInt32)> bindingFactory) const
Allocates an array of descriptor sets.
Definition rendering_api.hpp:5586
UniquePtr< IDescriptorSet > allocate(Span< DescriptorBinding > bindings) const
Definition rendering_api.hpp:5524
virtual const IDescriptorLayout & descriptor(UInt32 binding) const =0
Returns the descriptor layout for the descriptor bound to the binding point provided with binding .
Generator< UniquePtr< IDescriptorSet > > allocate(UInt32 descriptorSets, std::initializer_list< std::initializer_list< DescriptorBinding > > bindings={ }) const
Allocates an array of descriptor sets.
Definition rendering_api.hpp:5568
Generator< UniquePtr< IDescriptorSet > > allocate(UInt32 descriptorSets, UInt32 descriptors, std::function< Generator< DescriptorBinding >(UInt32)> bindingFactory) const
Allocates an array of descriptor sets.
Definition rendering_api.hpp:5617
UniquePtr< IDescriptorSet > allocate(UInt32 descriptors, std::initializer_list< DescriptorBinding > bindings) const
Allocates a new descriptor set or returns an instance of an unused descriptor set.
Definition rendering_api.hpp:5541
UniquePtr< IDescriptorSet > allocate(UInt32 descriptors, Span< DescriptorBinding > bindings) const
Definition rendering_api.hpp:5546
Describes a chunk of device memory.
Definition rendering_api.hpp:4088
virtual UInt64 virtualAddress() const noexcept=0
Gets the address of the resource in GPU memory.
IDeviceMemory() noexcept=default
The interface for a frame buffer.
Definition rendering_api.hpp:7709
Event< ResizeEventArgs > resized
Invoked when the frame buffer gets resized.
Definition rendering_api.hpp:7775
void mapRenderTargets(Span< const RenderTarget > renderTargets)
Maps a set of render targets to the frame buffer images, using the names of the render targets to loo...
Definition rendering_api.hpp:7869
virtual void addImage(const String &name, Format format, MultiSamplingLevel samples=MultiSamplingLevel::x1, ResourceUsage usage=ResourceUsage::FrameBufferImage)=0
Adds an image to the frame buffer.
void addImage(const RenderTarget &renderTarget, MultiSamplingLevel samples=MultiSamplingLevel::x1, ResourceUsage usage=ResourceUsage::FrameBufferImage)
Adds an image for a render target to the frame buffer.
Definition rendering_api.hpp:8011
auto addImage(this TSelf &&self, StringView name, Format format, MultiSamplingLevel samples=MultiSamplingLevel::x1, ResourceUsage usage=ResourceUsage::FrameBufferImage) -> TSelf &&
Adds an image to the frame buffer.
Definition rendering_api.hpp:7978
virtual void resize(const Size2d &renderArea)=0
Causes the frame buffer to be invalidated and recreated with a new size.
auto addImages(this TSelf &&self, Span< const RenderTarget > renderTargets, MultiSamplingLevel samples=MultiSamplingLevel::x1, ResourceUsage usage=ResourceUsage::FrameBufferImage) -> TSelf &&
Adds multiple images for a set of render targets to the frame buffer.
Definition rendering_api.hpp:8047
virtual const Size2d & size() const noexcept=0
Returns the current size of the frame buffer.
virtual const IImage & operator[](StringView renderTargetName) const =0
Resolves a render target name and returns the image mapped to it.
void addImage(Format format, MultiSamplingLevel samples=MultiSamplingLevel::x1, ResourceUsage usage=ResourceUsage::FrameBufferImage)
Adds an image to the frame buffer.
Definition rendering_api.hpp:7966
virtual const IImage & resolveImage(UInt64 hash) const =0
Resolves a render target name hash and returns the image mapped to it.
virtual const IImage & operator[](UInt32 index) const =0
Returns an image from the frame buffer.
virtual const IImage & image(const RenderTarget &renderTarget) const =0
Resolves a render target and returns the image mapped to it.
virtual const IImage & image(UInt32 index) const =0
Returns an image from the frame buffer.
virtual void unmapRenderTarget(const RenderTarget &renderTarget) noexcept=0
Removes a mapping between a render target and an image in the frame buffer.
auto addImage(this TSelf &&self, Format format, MultiSamplingLevel samples=MultiSamplingLevel::x1, ResourceUsage usage=ResourceUsage::FrameBufferImage) -> TSelf &&
Adds an image to the frame buffer.
Definition rendering_api.hpp:7955
virtual const IImage & image(StringView renderTargetName) const =0
Resolves a render target name and returns the image mapped to it.
auto addImage(this TSelf &&self, StringView name, const RenderTarget &renderTarget, MultiSamplingLevel samples=MultiSamplingLevel::x1, ResourceUsage usage=ResourceUsage::FrameBufferImage) -> TSelf &&
Adds an image for a render target to the frame buffer.
Definition rendering_api.hpp:8023
Enumerable< const IImage & > images() const
Returns all images contained by the frame buffer.
Definition rendering_api.hpp:7887
virtual void addImage(const String &name, const RenderTarget &renderTarget, MultiSamplingLevel samples=MultiSamplingLevel::x1, ResourceUsage usage=ResourceUsage::FrameBufferImage)=0
Adds an image for a render target to the frame buffer.
Event< ReleasedEventArgs > released
Invoked when the frame buffer gets released.
Definition rendering_api.hpp:7786
auto addImage(this TSelf &&self, const RenderTarget &renderTarget, MultiSamplingLevel samples=MultiSamplingLevel::x1, ResourceUsage usage=ResourceUsage::FrameBufferImage) -> TSelf &&
Adds an image for a render target to the frame buffer.
Definition rendering_api.hpp:8000
virtual const IImage & operator[](const RenderTarget &renderTarget) const =0
Resolves a render target and returns the image mapped to it.
Represents a physical graphics adapter.
Definition rendering_api.hpp:2648
The interface for a graphics device that.
Definition rendering_api.hpp:9164
SharedPtr< IFrameBuffer > makeFrameBuffer(const Size2d &renderArea) const
Creates a new frame buffer instance.
Definition rendering_api.hpp:9266
virtual double ticksPerMillisecond() const noexcept=0
Returns the number of GPU ticks per milliseconds.
IGraphicsDevice() noexcept=default
virtual MultiSamplingLevel maximumMultiSamplingLevel(Format format) const noexcept=0
Queries the device for the maximum supported number of multi-sampling levels.
SharedPtr< const ICommandQueue > createQueue(QueueType type, QueuePriority priority=QueuePriority::Normal)
Attempts to create a new queue that supports the combination of queue types specified by the type pa...
Definition rendering_api.hpp:9247
UniquePtr< IBarrier > makeBarrier(PipelineStage syncBefore, PipelineStage syncAfter) const
Creates a memory barrier instance.
Definition rendering_api.hpp:9257
virtual void wait() const =0
Waits until all queues allocated from the device have finished the work issued prior to this point.
void computeAccelerationStructureSizes(const ITopLevelAccelerationStructure &tlas, UInt64 &bufferSize, UInt64 &scratchSize, bool forUpdate=false) const
Computes the required amount of device memory for an ITopLevelAccelerationStructure.
Definition rendering_api.hpp:9330
SharedPtr< IFrameBuffer > makeFrameBuffer(StringView name, const Size2d &renderArea) const
Creates a new frame buffer instance.
Definition rendering_api.hpp:9276
The interface for a graphics factory.
Definition rendering_api.hpp:8716
SharedPtr< IVertexBuffer > createVertexBuffer(const String &name, const IVertexBufferLayout &layout, ResourceHeap heap, UInt32 elements=1, ResourceUsage usage=ResourceUsage::Default) const
Creates a vertex buffer, based on the layout
Definition rendering_api.hpp:8904
UniquePtr< IBottomLevelAccelerationStructure > createBottomLevelAccelerationStructure(AccelerationStructureFlags flags=AccelerationStructureFlags::None) const
Creates a bottom-level acceleration structure.
Definition rendering_api.hpp:9066
SharedPtr< ISampler > createSampler(const String &name, FilterMode magFilter=FilterMode::Nearest, FilterMode minFilter=FilterMode::Nearest, BorderMode borderU=BorderMode::Repeat, BorderMode borderV=BorderMode::Repeat, BorderMode borderW=BorderMode::Repeat, MipMapMode mipMapMode=MipMapMode::Nearest, Float mipMapBias=0.f, Float maxLod=std::numeric_limits< Float >::max(), Float minLod=0.f, Float anisotropy=0.f) const
Creates a texture sampler.
Definition rendering_api.hpp:9034
SharedPtr< IIndexBuffer > createIndexBuffer(const IIndexBufferLayout &layout, ResourceHeap heap, UInt32 elements, ResourceUsage usage=ResourceUsage::Default) const
Creates an index buffer, based on the layout .
Definition rendering_api.hpp:8921
SharedPtr< IImage > createTexture(const String &name, Format format, const Size3d &size, ImageDimensions dimension=ImageDimensions::DIM_2, UInt32 levels=1, UInt32 layers=1, MultiSamplingLevel samples=MultiSamplingLevel::x1, ResourceUsage usage=ResourceUsage::Default) const
Creates a texture.
Definition rendering_api.hpp:8980
SharedPtr< IBuffer > createBuffer(const String &name, const IDescriptorSetLayout &descriptorSet, UInt32 binding, ResourceHeap heap, size_t elementSize, UInt32 elements, ResourceUsage usage=ResourceUsage::Default) const
Creates a buffer that can be bound to a specific descriptor.
Definition rendering_api.hpp:8837
UniquePtr< ITopLevelAccelerationStructure > createTopLevelAccelerationStructure(StringView name, AccelerationStructureFlags flags=AccelerationStructureFlags::None) const
Creates a top-level acceleration structure.
Definition rendering_api.hpp:9107
SharedPtr< IBuffer > createBuffer(const IPipeline &pipeline, UInt32 space, UInt32 binding, ResourceHeap heap, UInt32 elementSize, UInt32 elements, ResourceUsage usage=ResourceUsage::Default) const
Creates a buffer that can be bound to a descriptor of a specific descriptor set.
Definition rendering_api.hpp:8779
SharedPtr< IBuffer > createBuffer(const String &name, const IPipeline &pipeline, UInt32 space, UInt32 binding, ResourceHeap heap, UInt32 elements=1, ResourceUsage usage=ResourceUsage::Default) const
Creates a buffer that can be bound to a descriptor of a specific descriptor set.
Definition rendering_api.hpp:8853
Generator< SharedPtr< IImage > > createTextures(Format format, const Size3d &size, ImageDimensions dimension=ImageDimensions::DIM_2, UInt32 layers=1, UInt32 levels=1, MultiSamplingLevel samples=MultiSamplingLevel::x1, ResourceUsage usage=ResourceUsage::Default) const
Creates a series of textures.
Definition rendering_api.hpp:8995
SharedPtr< IImage > createTexture(Format format, const Size3d &size, ImageDimensions dimension=ImageDimensions::DIM_2, UInt32 levels=1, UInt32 layers=1, MultiSamplingLevel samples=MultiSamplingLevel::x1, ResourceUsage usage=ResourceUsage::Default) const
Creates a texture.
Definition rendering_api.hpp:8959
SharedPtr< IBuffer > createBuffer(const String &name, const IDescriptorSetLayout &descriptorSet, UInt32 binding, ResourceHeap heap, UInt32 elements=1, ResourceUsage usage=ResourceUsage::Default) const
Creates a buffer that can be bound to a specific descriptor.
Definition rendering_api.hpp:8821
SharedPtr< IVertexBuffer > createVertexBuffer(const IVertexBufferLayout &layout, ResourceHeap heap, UInt32 elements=1, ResourceUsage usage=ResourceUsage::Default) const
Creates a vertex buffer, based on the layout
Definition rendering_api.hpp:8886
SharedPtr< IBuffer > createBuffer(const IDescriptorSetLayout &descriptorSet, UInt32 binding, ResourceHeap heap, UInt32 elements=1, ResourceUsage usage=ResourceUsage::Default) const
Creates a buffer that can be bound to a specific descriptor.
Definition rendering_api.hpp:8750
SharedPtr< IIndexBuffer > createIndexBuffer(const String &name, const IIndexBufferLayout &layout, ResourceHeap heap, UInt32 elements, ResourceUsage usage=ResourceUsage::Default) const
Creates an index buffer, based on the layout .
Definition rendering_api.hpp:8939
Generator< SharedPtr< ISampler > > createSamplers(FilterMode magFilter=FilterMode::Nearest, FilterMode minFilter=FilterMode::Nearest, BorderMode borderU=BorderMode::Repeat, BorderMode borderV=BorderMode::Repeat, BorderMode borderW=BorderMode::Repeat, MipMapMode mipMapMode=MipMapMode::Nearest, Float mipMapBias=0.f, Float maxLod=std::numeric_limits< Float >::max(), Float minLod=0.f, Float anisotropy=0.f) const
Creates a series of texture samplers.
Definition rendering_api.hpp:9053
SharedPtr< IBuffer > createBuffer(const String &name, const IPipeline &pipeline, UInt32 space, UInt32 binding, ResourceHeap heap, size_t elementSize, UInt32 elements=1, ResourceUsage usage=ResourceUsage::Default) const
Creates a buffer that can be bound to a descriptor of a specific descriptor set.
Definition rendering_api.hpp:8869
SharedPtr< IBuffer > createBuffer(const IPipeline &pipeline, UInt32 space, UInt32 binding, ResourceHeap heap, UInt32 elements=1, ResourceUsage usage=ResourceUsage::Default) const
Creates a buffer that can be bound to a descriptor of a specific descriptor set.
Definition rendering_api.hpp:8793
SharedPtr< ISampler > createSampler(FilterMode magFilter=FilterMode::Nearest, FilterMode minFilter=FilterMode::Nearest, BorderMode borderU=BorderMode::Repeat, BorderMode borderV=BorderMode::Repeat, BorderMode borderW=BorderMode::Repeat, MipMapMode mipMapMode=MipMapMode::Nearest, Float mipMapBias=0.f, Float maxLod=std::numeric_limits< Float >::max(), Float minLod=0.f, Float anisotropy=0.f) const
Creates a texture sampler.
Definition rendering_api.hpp:9014
SharedPtr< IBuffer > createBuffer(const String &name, BufferType type, ResourceHeap heap, size_t elementSize, UInt32 elements, ResourceUsage usage=ResourceUsage::Default) const
Creates a buffer of type type .
Definition rendering_api.hpp:8807
SharedPtr< IBuffer > createBuffer(const IDescriptorSetLayout &descriptorSet, UInt32 binding, ResourceHeap heap, UInt32 elementSize, UInt32 elements, ResourceUsage usage=ResourceUsage::Default) const
Creates a buffer that can be bound to a specific descriptor.
Definition rendering_api.hpp:8764
UniquePtr< IBottomLevelAccelerationStructure > createBottomLevelAccelerationStructure(StringView name, AccelerationStructureFlags flags=AccelerationStructureFlags::None) const
Creates a bottom-level acceleration structure.
Definition rendering_api.hpp:9080
UniquePtr< ITopLevelAccelerationStructure > createTopLevelAccelerationStructure(AccelerationStructureFlags flags=AccelerationStructureFlags::None) const
Creates a top-level acceleration structure.
Definition rendering_api.hpp:9093
Describes a generic image.
Definition rendering_api.hpp:4208
virtual void resolveSubresource(UInt32 subresource, UInt32 &plane, UInt32 &layer, UInt32 &level) const noexcept
Returns the plane , layer and level for the provided subresource .
Definition rendering_api.hpp:4312
IImage() noexcept=default
The interface for an index buffer.
Definition rendering_api.hpp:4425
IIndexBuffer() noexcept=default
Describes a index buffer layout.
Definition rendering_api.hpp:3952
The interface for an input assembler state.
Definition rendering_api.hpp:6431
IInputAssembler() noexcept=default
virtual const IIndexBufferLayout * indexBufferLayout() const noexcept=0
Returns a pointer to the index buffer layout, or nullptr if the input assembler does not handle indic...
virtual const IVertexBufferLayout & vertexBufferLayout(UInt32 binding) const =0
Returns a pointer the vertex buffer layout for binding provided with binding .
Allows for data to be mapped into the object.
Definition rendering_api.hpp:4038
IMappable() noexcept=default
The interface for a pipeline.
Definition rendering_api.hpp:6481
IPipeline() noexcept=default
SharedPtr< const IPipelineLayout > layout() const noexcept
Returns the layout of the render pipeline.
Definition rendering_api.hpp:6505
The interface for a pipeline layout.
Definition rendering_api.hpp:6385
IPipelineLayout() noexcept=default
virtual const IPushConstantsLayout * pushConstants() const noexcept=0
Returns the push constants layout, or nullptr, if the pipeline does not use any push constants.
The interface for a push constants layout.
Definition rendering_api.hpp:5693
Describes a range within a IPushConstantsLayout.
Definition rendering_api.hpp:5645
Represents the rasterizer state of a RenderPipeline.
Definition rendering_api.hpp:3321
IRasterizer() noexcept=default
The interface for a ray tracing pipeline.
Definition rendering_api.hpp:7626
The interface to access a render backend.
Definition rendering_api.hpp:9358
virtual const IGraphicsDevice * operator[](const String &name) const noexcept
Looks up a device and returns a pointer to it, or nullptr, if no device with the provided name could...
Definition rendering_api.hpp:9410
virtual IGraphicsDevice * device(const String &name) noexcept=0
Looks up a device and returns a pointer to it, or nullptr, if no device with the provided name could...
virtual const IGraphicsAdapter * findAdapter(const Optional< UInt64 > &adapterId=std::nullopt) const noexcept=0
Finds an adapter using its unique ID.
virtual IGraphicsDevice * operator[](const String &name) noexcept
Looks up a device and returns a pointer to it, or nullptr, if no device with the provided name could...
Definition rendering_api.hpp:9419
virtual const IGraphicsDevice * device(const String &name) const noexcept=0
Looks up a device and returns a pointer to it, or nullptr, if no device with the provided name could...
IRenderBackend() noexcept=default
The interface for a render pass.
Definition rendering_api.hpp:8065
SharedPtr< const ICommandBuffer > commandBuffer(UInt32 index) const
Returns a command buffer that can be currently used for recording multi-threaded commands in the rend...
Definition rendering_api.hpp:8166
const ICommandQueue & commandQueue() const noexcept
Returns the command queue, the render pass is executing on or nullptr, if the queue has already been ...
Definition rendering_api.hpp:8142
Enumerable< SharedPtr< const ICommandBuffer > > commandBuffers() const
Returns all command buffers, that can be currently used for recording multi-threaded commands in the ...
Definition rendering_api.hpp:8154
IRenderPass() noexcept=default
virtual UInt64 end() const =0
Ends the render pass.
virtual UInt32 secondaryCommandBuffers() const noexcept=0
Returns the number of secondary command buffers the render pass stores for multi-threaded command rec...
The interface for a render pipeline.
Definition rendering_api.hpp:7541
SharedPtr< IRasterizer > rasterizer() const noexcept
Returns the rasterizer state used by the render pipeline.
Definition rendering_api.hpp:7565
IRenderPipeline() noexcept=default
virtual bool alphaToCoverage() const noexcept=0
Returns true, if the pipeline uses Alpha-to-Coverage multi-sampling.
Represents a render target, i.e. an abstract view of the output of an RenderPass.
Definition rendering_api.hpp:2819
IRenderTarget() noexcept=default
Describes a texture sampler.
Definition rendering_api.hpp:4324
ISampler() noexcept=default
The interface of a scissor.
Definition rendering_api.hpp:3562
IScissor() noexcept=default
Represents a single shader module, i.e. a part of a IShaderProgram.
Definition rendering_api.hpp:2755
IShaderModule() noexcept=default
The interface for a shader program.
Definition rendering_api.hpp:6286
Enumerable< const IShaderModule & > modules() const
Returns the modules, the shader program is build from.
Definition rendering_api.hpp:6337
ShaderRecordCollection buildShaderRecordCollection() const noexcept
Builds a shader record collection based on the current shader program.
Definition rendering_api.hpp:6373
IShaderProgram() noexcept=default
SharedPtr< IPipelineLayout > reflectPipelineLayout() const
Uses shader reflection to extract the pipeline layout of a shader. May not be available in all backen...
Definition rendering_api.hpp:6365
bool contains(StringView name) const
Returns true, if the program contains a shader module with the provided name or file name and false o...
Definition rendering_api.hpp:6318
bool contains(const IShaderModule &module) const
Returns true, if the program contains the provided shader module and false otherwise.
Definition rendering_api.hpp:6328
The interface for a state resource.
Definition rendering_api.hpp:2240
IStateResource() noexcept=default
Represents a surface to render to.
Definition rendering_api.hpp:2720
ISurface() noexcept=default
Interface for a swap chain.
Definition rendering_api.hpp:8250
virtual SharedPtr< const TimingEvent > timingEvent(UInt32 queryId) const =0
Returns the timing event registered for queryId .
virtual const IGraphicsDevice & device() const =0
Returns the swap chain's parent device instance.
virtual UInt32 swapBackBuffer() const =0
Swaps the front buffer with the next back buffer in order.
virtual UInt32 resolveQueryId(SharedPtr< const TimingEvent > timingEvent) const =0
Returns the query ID for the timing event.
virtual void reset(Format surfaceFormat, const Size2d &renderArea, UInt32 buffers, bool enableVsync=false)=0
Causes the swap chain to be re-created. All frame and command buffers will be invalidated and rebuilt...
Event< ResetEventArgs > reseted
Invoked, after the swap chain has been reseted.
Definition rendering_api.hpp:8440
virtual Enumerable< Format > getSurfaceFormats() const =0
Returns an array of supported formats, that can be drawn to the surface.
ISwapChain() noexcept=default
virtual Format surfaceFormat() const noexcept=0
Returns the swap chain image format.
Event< EventArgs > swapped
Invoked, when the swap chain has swapped the back buffers.
Definition rendering_api.hpp:8434
virtual void present(UInt64 fence) const =0
Queues a present that gets executed after fence has been signaled on the default graphics queue.
virtual const Array< SharedPtr< const TimingEvent > > & timingEvents() const =0
Returns all registered timing events.
virtual UInt64 readTimingEvent(SharedPtr< const TimingEvent > timingEvent) const =0
Reads the current time stamp value (in ticks) of a timing event.
A structure that stores the instance data for a IBottomLevelAccelerationStructure.
Definition rendering_api.hpp:4870
void addInstance(const SharedPtr< const IBottomLevelAccelerationStructure > &blas, const TMatrix3x4< Float > &transform, UInt32 id, UInt32 hitGroupOffset=0, Byte mask=0xFF, InstanceFlags flags=InstanceFlags::None) noexcept
Adds an instance to the TLAS.
Definition rendering_api.hpp:4966
auto withInstance(this TSelf &&self, const SharedPtr< const IBottomLevelAccelerationStructure > &blas, const TMatrix3x4< Float > &transform, UInt32 id, UInt32 hitGroupOffset=0, Byte mask=0xFF, InstanceFlags flags=InstanceFlags::None) noexcept -> TSelf &&
Adds an instance to the current TLAS.
Definition rendering_api.hpp:5058
auto withInstance(this TSelf &&self, const Instance &instance) noexcept -> TSelf &&
Adds an instance to the current TLAS.
Definition rendering_api.hpp:5027
auto withInstance(this TSelf &&self, const SharedPtr< const IBottomLevelAccelerationStructure > &blas, UInt32 id, UInt32 hitGroupOffset=0, Byte mask=0xFF, InstanceFlags flags=InstanceFlags::None) noexcept -> TSelf &&
Adds an instance to the current TLAS.
Definition rendering_api.hpp:5042
virtual void clear() noexcept=0
Clears all instances from the acceleration structure.
The interface for a vertex buffer.
Definition rendering_api.hpp:4403
IVertexBuffer() noexcept=default
Describes a vertex buffer layout.
Definition rendering_api.hpp:3929
Interface for a viewport.
Definition rendering_api.hpp:3444
IViewport() noexcept=default
Describes an index buffer.
Definition rendering.hpp:479
Implements a IRasterizer.
Definition rendering_api.hpp:3371
Rasterizer & operator=(const Rasterizer &_other)
Assigns a rasterizer by copying it.
Rasterizer(Rasterizer &&_other) noexcept
Takes over another instance of a rasterizer.
Rasterizer & operator=(Rasterizer &&_other) noexcept
Assigns a rasterizer by taking it over.
Rasterizer(const Rasterizer &_other)
Creates a copy of a rasterizer.
~Rasterizer() noexcept override
Releases the rasterizer instance.
Represents a ray-tracing Pipeline.
Definition rendering.hpp:1020
Represents a mapping between a set of RenderTarget instances and the input attachments of a IRenderPa...
Definition rendering_api.hpp:3076
RenderPassDependency & operator=(RenderPassDependency &&_other) noexcept
Assigns another render pass dependency by taking it over.
RenderPassDependency(RenderPassDependency &&_other) noexcept
Takes over another render pass dependency instance.
RenderPassDependency & operator=(const RenderPassDependency &_other)
Assigns another render pass dependency instance by copying it.
~RenderPassDependency() noexcept
Releases the current render pass dependency instance.
RenderPassDependency(const RenderPassDependency &_other)
Creates a copy of another render pass dependency.
Implements a render target.
Definition rendering_api.hpp:2976
RenderTarget & operator=(RenderTarget &&_other) noexcept
Assigns a render target by taking it over.
RenderTarget(const RenderTarget &_other)
Creates a copy of a render target.
RenderTarget(RenderTarget &&_other) noexcept
Takes over another instance of a render target.
~RenderTarget() noexcept override
Releases the render target instance.
const String & name() const noexcept override
Returns the name of the render target.The name of the render target.
Definition render_target.cpp:55
RenderTarget & operator=(const RenderTarget &_other)
Assigns a render target by copying it.
Implements a scissor.
Definition rendering_api.hpp:3590
Scissor(const Scissor &_other)
Creates a copy of a scissor.
~Scissor() noexcept override
Releases the scissor instance.
Scissor & operator=(const Scissor &_other)
Assigns a scissor by copying it.
Scissor & operator=(Scissor &&_other) noexcept
Assigns a scissor by taking it over.
Scissor(Scissor &&_other) noexcept
Takes over another instance of a scissor.
Stores a set of IShaderRecords in that later form a shader binding table used for ray-tracing.
Definition rendering_api.hpp:6007
void addShaderRecord(const ShaderRecord<>::shader_group_type &shaderGroup)
Adds a new shader record to the shader record collection.
Definition rendering_api.hpp:6152
void addShaderRecord(StringView shaderName, TLocalData payload)
Adds a new shader record based on the name of a shader module in the parent shader program.
Definition rendering_api.hpp:6101
ShaderRecordCollection && withShaderRecord(StringView shaderName)
Adds a new shader record based on the name of a shader module in the parent shader program.
Definition rendering_api.hpp:6176
void addMeshGeometryShaderHitGroupRecord(std::optional< StringView > anyHitShaderName, std::optional< StringView > closestHitShaderName, TLocalData payload)
Adds a new mesh geometry hit group record based on names of the shader modules.
Definition rendering_api.hpp:6139
void addMeshGeometryShaderHitGroupRecord(std::optional< StringView > anyHitShaderName, std::optional< StringView > closestHitShaderName)
Adds a new mesh geometry hit group record based on names of the shader modules.
Definition rendering_api.hpp:6121
ShaderRecordCollection && withShaderRecord(StringView shaderName, TLocalData payload)
Adds a new shader record based on the name of a shader module in the parent shader program.
Definition rendering_api.hpp:6193
ShaderRecordCollection && withMeshGeometryHitGroupRecord(std::optional< StringView > anyHitShaderName, std::optional< StringView > closestHitShaderName, TLocalData payload)
Adds a new mesh geometry hit group record based on names of the shader modules.
Definition rendering_api.hpp:6218
ShaderRecordCollection(ShaderRecordCollection &&) noexcept=default
ShaderRecordCollection && withMeshGeometryHitGroupRecord(std::optional< StringView > anyHitShaderName, std::optional< StringView > closestHitShaderName)
Adds a new mesh geometry hit group record based on names of the shader modules.
Definition rendering_api.hpp:6204
void addShaderRecord(ShaderRecord< TLocalData >::shader_group_type shaderGroup, TLocalData payload)
Adds a new shader record to the shader record collection.
Definition rendering_api.hpp:6163
ShaderRecordCollection && withShaderRecord(ShaderRecord< TLocalData >::shader_group_type shaderGroup, TLocalData payload)
Adds a new shader record to the shader record collection.
Definition rendering_api.hpp:6241
ShaderRecordCollection && withShaderRecord(ShaderRecord<>::shader_group_type shaderGroup)
Adds a new shader record to the shader record collection.
Definition rendering_api.hpp:6228
Base class for a resource that can be identified by a name string within a DeviceState.
Definition rendering_api.hpp:2265
StateResource(StateResource &&) noexcept
An event that is used to measure timestamps in a command queue.
Definition rendering_api.hpp:3726
~TimingEvent() noexcept override
Releases the render target instance.
Describes a vertex buffer.
Definition rendering.hpp:455
Implements a viewport.
Definition rendering_api.hpp:3496
Viewport & operator=(const Viewport &_other)
Assigns a viewport by copying it.
Viewport(Viewport &&_other) noexcept
Takes over another instance of a viewport.
Viewport & operator=(Viewport &&_other) noexcept
Assigns a viewport by taking it over.
Viewport(const Viewport &_other)
Creates a copy of a viewport.
~Viewport() noexcept override
Releases the render target instance.
Implements the IResource interface.
Definition containers.hpp:823
Base class for an object that can be shared.
Definition containers.hpp:1075
Concept that can be used to refer to render backend implementations.
Definition rendering_api.hpp:9431
Checks if a type TDerived is derived from another type TBase and is non-abstract.
Definition traits.hpp:118
Definition math.hpp:30
uint16_t UInt16
A type for an unsigned 16 bit integer.
Definition math.hpp:46
uint64_t UInt64
A type for an unsigned 64 bit integer.
Definition math.hpp:66
float_t Float
A type for a floating point value with single precision.
Definition math.hpp:71
uint32_t UInt32
A type for an unsigned 32 bit integer.
Definition math.hpp:56
uint8_t Byte
A type for an unsigned 8 bit integer.
Definition math.hpp:36
int32_t Int32
A type for a signed 32 bit integer.
Definition math.hpp:51
Definition dx12.hpp:11
BorderMode
Describes how to treat texture coordinates that are outside the domain [0..1].
Definition rendering_api.hpp:1184
@ RepeatMirrored
Mirror the texture.
@ Repeat
Repeat the texture.
@ ClampToEdge
Take the closest edge texel.
@ ClampToEdgeMirrored
Take the closest edge texel from the opposite site.
@ ClampToBorder
Return a pre-specified border color.
CullOrder
Describes the order or vertex winding, that is used to determine, whether a polygon is facing towards...
Definition rendering_api.hpp:1018
@ CounterClockWise
Vertices are evaluated in a counter clock-wise manner.
@ ClockWise
Vertices are evaluated in a clock-wise manner.
RenderTargetFlags
Describes the behavior of render targets.
Definition rendering_api.hpp:1056
@ Volatile
If enabled, the render target is discarded after ending the render pass.
@ ClearStencil
If enabled and the render target format supports stencil storage, the stencil part is cleared when th...
@ Clear
If enabled, color or depth (depending on the render target type) are cleared when starting a render p...
ImageLayout
Specifies the layout of an IImage resource.
Definition rendering_api.hpp:1686
@ ResolveSource
Indicates that the image is resolved from a multi-sampled image.
@ ResolveDestination
Indicates that the image is a render-target that a multi-sampled image is resolved into.
@ CopyDestination
Allows the image to be used as a destination for transfer operations.
@ DepthRead
Indicates that image is used as a read-only depth/stencil target.
@ ReadWrite
Indicates that the image is used as a read-write storage or texel buffer.
@ DepthWrite
Indicates that the image is used as a write-only depth/stencil target.
@ ShaderResource
Indicates that the image is used as a read-only storage or texel buffer.
@ Undefined
The layout of the image is not known by the engine.
@ CopySource
Allows the image to be used as a source for transfer operations.
MipMapMode
Describes the filter operation between two mip-map levels.
Definition rendering_api.hpp:1169
BlendFactor
Specifies a blend factor.
Definition rendering_api.hpp:1307
CullMode
Describes which faces are culled by the Rasterizer stage.
Definition rendering_api.hpp:991
@ FrontFaces
The rasterizer will discard front-facing polygons.
@ Both
The rasterizer will discard front and back-facing polygons.
@ Disabled
The rasterizer will not discard any polygons.
@ BackFaces
The rasterizer will discard back-facing polygons.
ShaderStage
Describes the valid shader stages of a graphics pipeline.
Definition rendering_api.hpp:799
@ Fragment
Represents the fragment or pixel shader stage.
@ MeshPipeline
Represents the complete mesh shading pipeline.
@ Mesh
Represents the mesh shader stage.
@ Callable
Represents the callable shader stage.
@ TessellationEvaluation
Represents the tessellation evaluation or domain shader stage.
@ TessellationControl
Represents the tessellation control or hull shader stage.
@ Intersection
Represents the intersection shader stage.
@ RasterizationPipeline
Represents the complete rasterization pipeline.
@ RayGeneration
Represents the ray generation shader stage.
@ ClosestHit
Represents the closest-hit shader stage.
@ Geometry
Represents the geometry shader stage.
@ Miss
Represents the miss shader stage.
@ Task
Represents the task or amplification shader stage.
@ Any
Enables all supported shader stages.
@ AnyHit
Represents the any-hit shader stage.
RenderTargetType
Describes the type of a render target.
Definition rendering_api.hpp:1033
@ DepthStencil
Represents a depth/stencil target.
@ Present
Represents a color target that should be presented.
constexpr UInt32 getBufferFormatChannelSize(BufferFormat format)
Returns the number of bytes used by a channel of a buffer format.
Definition rendering_api.hpp:1927
GraphicsAdapterType
Defines different types of graphics adapters.
Definition rendering_api.hpp:75
@ CPU
The adapter is a software driver.
@ GPU
The adapter is a dedicated GPU or integrated CPU adapter.
CompareOperation
Describes the operation used to compare depth or stencil values during depth/stencil tests.
Definition rendering_api.hpp:1215
@ NotEqual
The test succeeds, if the current value is not equal to the stencil ref or previous depth value.
@ Less
The test succeeds, if the current value is less than the stencil ref or previous depth value.
@ Always
The test always succeeds.
@ Never
The test always fails.
@ GreaterEqual
The test succeeds, if the current value is greater or equal to the stencil ref or previous depth valu...
@ Greater
The test succeeds, if the current value is greater than the stencil ref or previous depth value.
@ LessEqual
The test succeeds, if the current value is less or equal to the stencil ref or previous depth value.
@ Equal
The test succeeds, if the current value is equal to the stencil ref or previous depth value.
BlendOperation
Specifies a blend operation.
Definition rendering_api.hpp:1359
IndexType
Describes the element type of an index buffer.
Definition rendering_api.hpp:750
PrimitiveTopology
Describes the topology of a mesh primitive.
Definition rendering_api.hpp:765
@ PointList
A list of points where each vertex refers to an individual point.
@ TriangleStrip
A strip of triangles, where each vertex (except the first two) refers to the third vertex of the next...
@ LineList
A list of lines where each vertex pair refers to the start and end points of a line.
@ LineStrip
A strip of lines where each vertex (except the first one) refers to the end point for the next line s...
@ TriangleList
A list of triangles, where each triplet of vertices refers to a whole triangle.
ShaderBindingGroup
Describes a group or combination of groups of a shader binding table.
Definition rendering_api.hpp:939
@ All
Refers to a combination of all possible groups that can be stored in a shader binding table.
PolygonMode
Describes the draw mode for polygons.
Definition rendering_api.hpp:970
@ Point
Polygons are drawn as points at the vertex positions.
@ Wireframe
Polygons are only drawn as wire-frames.
@ Solid
Polygons are drawn as solid surfaces.
BufferType
Describes the type of a IBuffer.
Definition rendering_api.hpp:540
@ Indirect
Describes a buffer that stores data to generate indirect draw calls.
@ ShaderBindingTable
Describes a shader binding table for ray-tracing.
@ Index
Describes an index buffer.
@ Storage
Describes a shader storage buffer object (Vulkan) or unordered access view (DirectX).
@ Texel
Describes a shader texel storage buffer object (Vulkan) or unordered access view (DirectX).
@ Uniform
Describes an uniform buffer object (Vulkan) or constant buffer view (DirectX).
InstanceFlags
Controls how an instance within a ITopLevelAccelerationStructure behaves during ray-tracing.
Definition rendering_api.hpp:1857
@ DisableCull
If this flag is set front- and backface culling is disabled for the instance.
@ ForceNonOpaque
If this flag is set, each geometry of the instance will ignore the GeometryFlags::Opaquesetting.
@ ForceOpaque
If this flag is set, no geometry of the instance invokes the any-hit shader. This overwrites per-geom...
@ FlipWinding
If this flag is set, front- and backfaces flip their default cull order.
AttributeSemantic
Describes the semantic of a buffer attribute.
Definition rendering_api.hpp:371
@ BlendIndices
The attribute contains blend indices.
@ PointSize
The attribute contains a point size.
@ Binormal
The attribute contains a bi-normal vector.
@ Position
The attribute contains a position vector.
@ Tangent
The attribute contains a tangent vector.
@ BlendWeight
The attribute contains blend weights.
@ Unknown
The attribute is a generic, unknown semantic.
@ TransformedPosition
The attribute contains a pre-transformed position vector.
@ Color
The attribute contains a color value.
@ TextureCoordinate
The attribute contains a texture coordinate.
constexpr UInt32 getBufferFormatType(BufferFormat format)
Returns the underlying data type of a buffer format.
Definition rendering_api.hpp:1935
ResourceUsage
Describes the intended usage for a resource.
Definition rendering_api.hpp:690
@ FrameBufferImage
Default usage for frame buffer images.
@ Default
Shortcut for commonly used TransferSource | TransferDestination combination.
@ TransferSource
Allows the resource data to be copied into another resource.
@ RenderTarget
Allows the resource to be used as a render target.
@ TransferDestination
Allows the resource data to be copied from another resource.
@ AccelerationStructureBuildInput
Allows the resource to be used to build acceleration structures.
@ AllowWrite
Allows the resource to be written to.
GeometryFlags
Controls how a geometry that is part of a bottom-level acceleration structure (BLAS) behaves during r...
Definition rendering_api.hpp:1794
@ OneShotAnyHit
If this flag is set, the any-hit shader for this geometry is only invoked once for each primitive of ...
@ Opaque
If this flag is set, the any-hit shader for this geometry is never invoked, even if it is present wit...
ImageDimensions
Describes the dimensions of a image resource, i.e. the dimensions that are required to access a texel...
Definition rendering_api.hpp:1086
@ DIM_1
Represents a 1D image.
@ DIM_2
Represents a 2D image.
@ DIM_3
Represents a 3D image.
@ CUBE
Represents a set of six 2D images that are used to build a cube map.
constexpr bool hasDepth(Format format) noexcept
Returns true, if the format contains a depth channel.
Definition rendering_api.hpp:2112
DescriptorType
Describes the type of a IDescriptor.
Definition rendering_api.hpp:436
@ RWStructuredBuffer
A writable shader storage object in Vulkan. Maps to a read/write structured buffer in DirectX.
@ InputAttachment
The result of a render target from an earlier render pass. Maps to a SubpassInput in HLSL.
@ AccelerationStructure
Represents a ray-tracing acceleration structure.
@ Sampler
A sampler state of a texture or image.
@ ByteAddressBuffer
Represents an unformatted buffer.
@ RWByteAddressBuffer
Represents an unformatted writable buffer.
@ Buffer
Represents a read-only texel buffer (uniform texel buffer).
@ RWBuffer
Represents a writable texel buffer (storage texel buffer).
@ Texture
A read-only sampled image.
@ StructuredBuffer
A shader storage buffer object in Vulkan. Maps to a structured buffer in DirectX.
@ ConstantBuffer
A uniform buffer in Vulkan. Maps to a constant buffer in DirectX.
QueuePriority
Specifies the priority with which a queue is scheduled on the GPU.
Definition rendering_api.hpp:159
@ High
A high queue priority.
@ Normal
The default queue priority.
@ Realtime
The highest possible queue priority. Submitting work to this queue might block other queues.
QueueType
Represents the type of a CommandQueue.
Definition rendering_api.hpp:113
@ VideoDecode
Represents a queue that can perform hardware video decoding.
@ Transfer
Represents a queue that can execute only transfer workloads.
@ Compute
Represents a queue that can execute compute and transfer workloads.
@ VideoEncode
Represents a queue that can perform hardware video encoding.
@ Graphics
Represents a queue that can execute graphics, compute and transfer workloads.
ResourceHeap
Defines where a resource (buffer or image) memory is located and from where it can be accessed.
Definition rendering_api.hpp:649
@ Staging
Creates a resource that can be mapped from the CPU in order to be transferred to the GPU later.
@ Dynamic
Creates a resource that can be mapped from the CPU and read by the GPU.
@ Readback
Creates a buffer that can be written on the GPU and read by the CPU.
StencilOperation
An operation that is applied to the stencil buffer.
Definition rendering_api.hpp:1261
@ Keep
Keep the current stencil value.
@ Replace
Replace the current stencil value with the stencil ref.
@ IncrementClamp
Increment the current stencil value.
@ DecrementClamp
Decrement the current stencil value.
@ DecrementWrap
Decrement the current stencil value and wrap it, if it goes out of bounds.
@ Invert
Bitwise invert the current stencil value.
@ IncrementWrap
Increment the current stencil value and wrap it, if it goes out of bounds.
@ Zero
Set the stencil value to 0.
AccelerationStructureFlags
Controls how an acceleration structure should be built.
Definition rendering_api.hpp:1816
@ MinimizeMemory
Prefer to minimize the memory footprint of the acceleration structure, but at the cost of ray-tracing...
@ PreferFastBuild
Prefer fast build times for the acceleration structure, but sacrifice ray-tracing performance.
@ AllowCompaction
Allow the acceleration structure to be compacted.
@ PreferFastTrace
Prefer building a better performing acceleration structure, that possibly takes longer to build.
@ AllowUpdate
Allow the acceleration structure to be updated.
struct LITEFX_RENDERING_API alignas(16) IndirectBatch
An indirect batch used to execute an standard draw call.
Definition rendering_api.hpp:2149
FilterMode
Describes the filter operation when accessing a pixel from a texture coordinate.
Definition rendering_api.hpp:1152
@ Linear
Linearly interpolate between the two closest texels with respect to the texture coordinate.
@ Nearest
Take the nearest texel with respect to the texture coordinate.
const size_t SHADER_RECORD_LOCAL_DATA_ALIGNMENT
The size (in bytes) to which shader record local data must be aligned.
Definition rendering_api.hpp:5847
ShaderRecordType
Describes the type of a shader module record within a shader collection or shader binting table.
Definition rendering_api.hpp:903
@ HitGroup
Represents a hit group shader record.
PipelineStage
Defines pipeline stages as points where synchronization may occur.
Definition rendering_api.hpp:1373
@ Resolve
Waits for previous commands to finish the multi-sampling resolution stage, or blocks following comman...
@ Raytracing
Waits for the previous commands to finish ray-tracing shader stages, or blocks the following commands...
@ Draw
Waits for previous commands to finish all graphics stages, or blocks following commands until the gra...
@ InputAssembly
Waits for previous commands to finish the input assembly stage, or blocks following commands until th...
@ AccelerationStructureCopy
Waits for previous commands to finish the copying stage for an acceleration structure,...
@ AccelerationStructureBuild
Waits for previous commands to finish the building stage for an acceleration structure,...
BufferFormat
Describes a buffer attribute format.
Definition rendering_api.hpp:339
constexpr bool hasStencil(Format format) noexcept
Returns true, if the format contains a stencil channel.
Definition rendering_api.hpp:2129
constexpr UInt32 getBufferFormatChannels(BufferFormat format)
Returns the number of channels for a buffer format.
Definition rendering_api.hpp:1919
constexpr size_t getSize(Format format)
Returns the size of an element of a specified format.
Definition rendering_api.hpp:1942
ResourceAccess
Defines how a IBuffer or IImage resource is accessed.
Definition rendering_api.hpp:1537
@ ResolveWrite
Indicates that a resource is accessed as to write during a resolve operation.
@ ResolveRead
Indicates that a resource is accessed as to read during a resolve operation.
@ AccelerationStructureRead
Indicates that a resources is accessed to read an acceleration structure.
@ ShaderRead
Indicates that a resource is accessed as a read-only shader resource.
@ UniformBuffer
Indicates that a resource is accessed as an uniform/constant buffer.
@ DepthStencilRead
Indicates that a resource is accessed as to read depth/stencil values.
@ DepthStencilWrite
Indicates that a resource is accessed as to write depth/stencil values.
@ TransferRead
Indicates that a resource is accessed as to read during a transfer operation.
@ AccelerationStructureWrite
Indicates that a resources is accessed to write an acceleration structure.
@ ShaderReadWrite
Indicates that a resource is accessed as a read-write shader resource.
@ Common
Indicates that a resource can be accessed in any way, compatible to the layout.
@ TransferWrite
Indicates that a resource is accessed as to write during a transfer operation.
WriteMask
Specifies a write mask for a color buffer.
Definition rendering_api.hpp:1333
@ A
Write into the alpha channel.
@ B
Write into the blue channel.
@ G
Write into the green channel.
@ R
Write into the red channel.
Format
Describes a texel format.
Definition rendering_api.hpp:182
MultiSamplingLevel
Describes the number of samples with which a IImage is sampled.
Definition rendering_api.hpp:1111
@ x32
Use 32 samples per pixel.
@ x16
Use 16 samples per pixel.
@ x1
The default number of samples. Multi-sampling will be deactivated, if this sampling level is used.
@ x2
Use 2 samples per pixel.
@ x64
Use 64 samples per pixel.
@ x4
Use 4 samples per pixel.
@ x8
Use 8 samples per pixel.
Definition app.hpp:6
std::generator< T, TVal > Generator
Describes an intermediate container for elements of type T .
Definition containers.hpp:206
std::reference_wrapper< T > Ref
Represents a copyable and assignable reference wrapper.
Definition containers.hpp:145
constexpr UniquePtr< T > makeUnique()
Creates a new unique pointer.
Definition containers.hpp:153
std::vector< T > Array
Represents a dynamic array.
Definition containers.hpp:73
std::optional< T > Optional
Represents an optional value.
Definition containers.hpp:94
std::shared_ptr< T > SharedPtr
Represents a shared pointer, that expresses non-exclusive ownership.
Definition containers.hpp:109
std::unique_ptr< T, TDeleter > UniquePtr
Represents a unique pointer, that expresses exclusive ownership.
Definition containers.hpp:102
std::string String
Definition string.hpp:24
std::string_view StringView
Definition string.hpp:26
std::span< T > Span
Represents a view of an array.
Definition containers.hpp:87
std::variant< T... > Variant
Represents a variant of objects.
Definition containers.hpp:130
An input range over another range, where the returned values of type T are covariants of the values ...
Definition containers.hpp:529
An algebraic matrix type.
Definition matrix.hpp:39
An algebraic vector type.
Definition vector.hpp:23
constexpr scalar_type x() const noexcept
Returns the value of the x component of the vector.
Definition vector.hpp:252
constexpr scalar_type z() const noexcept
Returns the value of the z component of the vector.
Definition vector.hpp:284
constexpr scalar_type y() const noexcept
Returns the value of the y component of the vector.
Definition vector.hpp:268
Describes the rasterizer depth bias.
Definition rendering_api.hpp:3177
Describes the rasterizer depth state.
Definition rendering_api.hpp:3150
Describes the rasterizer stencil state.
Definition rendering_api.hpp:3229
Describes a stencil test for either front or back faces.
Definition rendering_api.hpp:3203
Describes a resource binding to a descriptor or descriptor set.
Definition rendering_api.hpp:5334
Variant< std::monostate, Ref< const IBuffer >, Ref< const IImage >, Ref< const ISampler >, Ref< const IAccelerationStructure > > resource_container
Definition rendering_api.hpp:5336
Describes a single descriptor binding point within a IShaderModule.
Definition rendering_api.hpp:2735
Describes optional features that can be supported by a device.
Definition rendering_api.hpp:9138
Stores a buffer that contains axis-aligned bounding boxes.
Definition rendering_api.hpp:4670
GeometryFlags Flags
The flags that control how the primitives in the geometry behaves during ray-tracing.
Definition rendering_api.hpp:4692
SharedPtr< const IBuffer > Buffer
A buffer containing the bounding box definitions.
Definition rendering_api.hpp:4687
Represents a triangle mesh.
Definition rendering_api.hpp:4593
TriangleMesh(const TriangleMesh &other)=default
Initializes a new triangle mesh by copying another one.
TriangleMesh(const SharedPtr< const IVertexBuffer > &vertexBuffer, const SharedPtr< const IIndexBuffer > &indexBuffer=nullptr, const SharedPtr< const IBuffer > &transformBuffer=nullptr, GeometryFlags flags=GeometryFlags::None)
Initializes a new triangle mesh.
Definition rendering_api.hpp:4602
~TriangleMesh() noexcept=default
Releases the triangle mesh.
TriangleMesh & operator=(TriangleMesh &&other) noexcept=default
Takes over another triangle mesh.
TriangleMesh(TriangleMesh &&other) noexcept=default
Initializes a new triangle mesh by taking over another one.
TriangleMesh & operator=(const TriangleMesh &other)=default
Copies another triangle mesh.
Event arguments for a ICommandQueue::submitted event.
Definition rendering_api.hpp:8513
QueueSubmittedEventArgs(QueueSubmittedEventArgs &&) noexcept=default
QueueSubmittedEventArgs(UInt64 fence) noexcept
Definition rendering_api.hpp:8518
QueueSubmittedEventArgs(const QueueSubmittedEventArgs &)=default
Event arguments for a ICommandQueue::submitting event.
Definition rendering_api.hpp:8486
QueueSubmittingEventArgs(QueueSubmittingEventArgs &&) noexcept=default
QueueSubmittingEventArgs(Array< SharedPtr< const ICommandBuffer > > &&commandBuffers)
Definition rendering_api.hpp:8491
QueueSubmittingEventArgs(const QueueSubmittingEventArgs &)=default
Event arguments that are published to subscribers when a frame buffer gets released.
Definition rendering_api.hpp:7744
ReleasedEventArgs(ReleasedEventArgs &&) noexcept=default
ReleasedEventArgs() noexcept
Definition rendering_api.hpp:7746
ReleasedEventArgs(const ReleasedEventArgs &)=default
Event arguments that are published to subscribers when a frame buffer gets resized.
Definition rendering_api.hpp:7716
ResizeEventArgs(Size2d newSize) noexcept
Definition rendering_api.hpp:7721
ResizeEventArgs(ResizeEventArgs &&) noexcept=default
ResizeEventArgs(const ResizeEventArgs &)=default
Event arguments that are published to subscribers when a render pass is beginning.
Definition rendering_api.hpp:8071
BeginEventArgs(const IFrameBuffer &frameBuffer) noexcept
Definition rendering_api.hpp:8076
BeginEventArgs(BeginEventArgs &&) noexcept=default
BeginEventArgs(const BeginEventArgs &)=default
Describes the blend state of the render target.
Definition rendering_api.hpp:2824
Describes a hit group for a triangle mesh geometry.
Definition rendering_api.hpp:5756
const IShaderModule * AnyHitShader
The any hit shader for the triangle mesh.
Definition rendering_api.hpp:5765
const IShaderModule * ClosestHitShader
The closest hit shader for the triangle mesh.
Definition rendering_api.hpp:5760
Describes a record within a shader binding table.
Definition rendering_api.hpp:5746
virtual constexpr const shader_group_type & shaderGroup() const noexcept=0
Returns the shader group containing the modules for this record.
IShaderRecord() noexcept=default
Variant< const IShaderModule *, MeshGeometryHitGroup > shader_group_type
Defines the type that stores the shaders of the shader group.
Definition rendering_api.hpp:5771
Event arguments for a ISwapChain::reseted event.
Definition rendering_api.hpp:8255
ResetEventArgs(const ResetEventArgs &)=default
const Size2d & renderArea() const noexcept
Gets the new render area of the swap chain back-buffers.
Definition rendering_api.hpp:8284
ResetEventArgs(Format surfaceFormat, Size2d renderArea, UInt32 buffers, bool enableVsync) noexcept
Definition rendering_api.hpp:8263
ResetEventArgs(ResetEventArgs &&) noexcept=default
UInt32 buffers() const noexcept
Gets the number of back-buffers in the swap chain.
Definition rendering_api.hpp:8292
bool enableVsync() const noexcept
Returns true if vertical synchronization is enabled or false otherwise.
Definition rendering_api.hpp:8300
Represents an instance of an IBottomLevelAccelerationStructure.
Definition rendering_api.hpp:4877
UInt32 HitGroupOffset
An offset added to the address of the shader-local data of the shader record that is invoked for the ...
Definition rendering_api.hpp:4912
UInt32 Id
The instance ID used in shaders to identify the instance.
Definition rendering_api.hpp:4891
InstanceFlags Flags
The flags that control the behavior of this instance.
Definition rendering_api.hpp:4917
Byte Mask
A user-defined mask value that is matched with another mask value during ray-tracing to include or di...
Definition rendering_api.hpp:4896
Describes the offsets and sizes of a shader group within a shader binding table buffer.
Definition rendering_api.hpp:3646
constexpr ShaderRecord & operator=(ShaderRecord &&_other) noexcept=default
Takes over another shader record.
constexpr const void * localData() const noexcept override
Returns a pointer to the shader-local data of the record.Shader-local data is a piece of constant dat...
Definition rendering_api.hpp:5884
constexpr ShaderRecord & operator=(const ShaderRecord &_other)=default
Copies another shader record.
constexpr UInt64 localDataSize() const noexcept override
Returns the size of the shader-local data of the record.The size of the shader-local data of the reco...
Definition rendering_api.hpp:5889
constexpr ShaderRecord(const ShaderRecord &_other)=default
Copies another shader record.
constexpr ShaderRecord(ShaderRecord &&_other) noexcept=default
Takes over another shader record.
constexpr ~ShaderRecord() noexcept override=default
IShaderRecord::shader_group_type shader_group_type
Definition rendering_api.hpp:5864
constexpr const shader_group_type & shaderGroup() const noexcept override
Returns the shader group containing the modules for this record.
Definition rendering_api.hpp:5879
Denotes a shader record containing no shader-local data.
Definition rendering_api.hpp:5938
constexpr UInt64 localDataSize() const noexcept override
Returns the size of the shader-local data of the record.The size of the shader-local data of the reco...
Definition rendering_api.hpp:5960
constexpr ShaderRecord & operator=(ShaderRecord &&_other) noexcept=default
Takes over another shader record.
constexpr const void * localData() const noexcept override
Returns a pointer to the shader-local data of the record.Shader-local data is a piece of constant dat...
Definition rendering_api.hpp:5955
constexpr ShaderRecord(const ShaderRecord &_other)=default
Copies another shader record.
constexpr ~ShaderRecord() noexcept override=default
constexpr ShaderRecord & operator=(const ShaderRecord &_other)=default
Copies another shader record.
constexpr const shader_group_type & shaderGroup() const noexcept override
Returns the shader group containing the modules for this record.
Definition rendering_api.hpp:5950
IShaderRecord::shader_group_type shader_group_type
Definition rendering_api.hpp:5940
constexpr ShaderRecord(ShaderRecord &&_other) noexcept=default
Takes over another shader record.
Defines a generic shader record.
Definition rendering_api.hpp:5842
An allocator used to allocate the shared object.
Definition containers.hpp:1098
Definition alloc_descriptor_set.cpp:13